blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
e7b820d8af1142d1f86bd0c8f9468f02c34f19fc | a86b5f554165b44de6ab97cb46f3a0504a278c34 | /icode/springboot/src/main/java/com/diwt/Application.java | d6c973db67b6333517cddb486d6734ea5a023a1f | [] | no_license | diwt/icode | 41889f2c018c3677ac59a2ff6d7f53d882e7edf5 | e5deeb8e9b1f71a949f05acf78f70fc1837c679c | refs/heads/master | 2021-06-06T15:29:04.471126 | 2016-09-05T01:56:41 | 2016-09-05T01:56:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 900 | java | package com.diwt;
import javafx.scene.Parent;
import org.springframework.boot.Banner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
/**
* Created by xiaod on 2016/9/4.
*/
public class Application {
/**
* 自定义Application
* @param args
*/
public static void main(String[] args) {
/*//1.3.7
SpringApplication application = new SpringApplication(Application.class);
application.setBannerMode(Banner.Mode.OFF);
application.run(args);
//1.3.0
//application.setShowBanner(false);
//application.run(args);*/
//分层的ApplicationContext
new SpringApplicationBuilder()
.bannerMode(Banner.Mode.OFF)
.sources(Parent.class)
.child(Application.class)
.run(args);
}
}
| [
"[email protected]"
] | |
86338b0bcc35fd58791abafd347c3fc78838f7b7 | 9b848101ca59ec1e00705867d8721a1ffbb4bdd3 | /src/main/java/com/ihsinformatics/spring/appgpa/controller/CourseController.java | a3e660193d4aeb4355625619a500735cce1d09e2 | [] | no_license | qaximalee/appgpa-spring | 1c45e1cf5a2b985642e80f4eb9782aa4444016bf | 0df54c6d811d5608e4be5278532ff387ca95ab84 | refs/heads/master | 2022-12-22T11:52:09.729880 | 2019-11-29T05:23:54 | 2019-11-29T05:23:54 | 222,930,496 | 0 | 0 | null | 2022-12-16T12:01:36 | 2019-11-20T12:17:04 | JavaScript | UTF-8 | Java | false | false | 3,656 | java | package com.ihsinformatics.spring.appgpa.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.ihsinformatics.spring.appgpa.model.Course;
import com.ihsinformatics.spring.appgpa.model.Semester;
import com.ihsinformatics.spring.appgpa.service.CourseService;
import com.ihsinformatics.spring.appgpa.service.SemesterService;
import com.ihsinformatics.spring.appgpa.service.imp.CourseServiceImp;
import com.ihsinformatics.spring.appgpa.values.Values;
@Controller
@RequestMapping("/course")
public class CourseController {
@Autowired
private CourseService courseService;
@Autowired
private SemesterService semesterService;
public void setCourseService(CourseServiceImp courseService) {
this.courseService = courseService;
}
public void setSemesterService(SemesterService semesterService) {
this.semesterService = semesterService;
}
@RequestMapping(value = "/addCourse", method = RequestMethod.POST)
public ModelAndView addCourse(@RequestParam("courseCode") int courseCode, @RequestParam("semester") int semesterId,
@RequestParam("name") String name) {
Semester semester = semesterService.getSemesterById(semesterId);
Course course = new Course(0, courseCode, name, semester);
if (courseService.save(course))
return viewCourses(Values.CREATED_SUCCESS);
else
return viewCourses(Values.CREATED_UNSUCCESS);
}
@RequestMapping(value = "/editCourse", method = RequestMethod.POST)
public ModelAndView editCourse(@RequestParam("courseId") int courseId, @RequestParam("courseCode") int courseCode,
@RequestParam("semesterId") int semesterId, @RequestParam("name") String name) {
Semester semester = semesterService.getSemesterById(semesterId);
Course course = new Course(courseId, courseCode, name, semester);
if (courseService.update(course))
return viewCourses(Values.UPDATED_SUCCESS);
else
return viewCourses(Values.UPDATED_UNSUCCESS);
}
@RequestMapping(value = "/editCourseForm", method = RequestMethod.GET)
public ModelAndView editCourseForm(@RequestParam("id") int courseId) {
ModelAndView mav = new ModelAndView("course_views/edit_course_form");
mav.addObject("course", courseService.getCourseById(courseId));
mav.addObject("semesters", semesterService.getAllSemester());
return mav;
}
@RequestMapping(value = "/deleteCourse", method = RequestMethod.GET)
public ModelAndView deleteCourse(@RequestParam("id") int courseId) {
if (courseService.deleteCourseById(courseId))
return viewCourses(Values.DELETED_SUCCESS);
else
return viewCourses(Values.DELETED_UNSUCCESS);
}
@RequestMapping(value = "/viewCourses")
public ModelAndView viewCourses(String alertMessageIdentifier) {
if (alertMessageIdentifier == null) {
alertMessageIdentifier = "just-view";
System.out.println(alertMessageIdentifier);
}
ModelAndView mav = new ModelAndView(Values.COURSE_VIEW_URL);
mav.addObject("courseList", courseService.getAllCourses());
mav.addObject("alertMessageIdentitfier", alertMessageIdentifier);
return mav;
}
@RequestMapping(method = RequestMethod.GET)
public ModelAndView initialView() {
ModelAndView mav = new ModelAndView("course_views/add_course_form");
mav.addObject("semesterList", semesterService.getAllSemester());
return mav;
}
}
| [
"[email protected]"
] | |
6509f5661a3b07ea2b5cecb9e4e80ac5ed608359 | 3e8b35d2280baa3a1cc1dea9836adab9948f9e93 | /src/main/java/com/cybertek/entity/BaseEntity.java | 0ace72bf02fcc34f7733d369028d47ab23ed2f7d | [] | no_license | Dilarka1/jd_ticketing-project-security | 3c9ea32bee0931c86d272b6c478f59c0c0cafe1e | 7c2f2d388dad0603632487597bfa81dbf2b09968 | refs/heads/main | 2023-02-24T09:49:24.095887 | 2021-01-30T23:18:18 | 2021-01-30T23:18:18 | 333,833,664 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 817 | java | package com.cybertek.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.apache.tomcat.jni.Local;
import javax.persistence.*;
import java.time.LocalDateTime;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@MappedSuperclass
@EntityListeners(BaseEntityListener.class)
public class BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(nullable = false, updatable = false)
public LocalDateTime insertDateTime;
@Column(nullable = false, updatable = false)
public Long insertUserId;
@Column(nullable = false)
public LocalDateTime lastUpdateDateTime;
@Column(nullable = false)
public Long lastUpdateUserId;
private Boolean isDeleted = false;
} | [
"[email protected]"
] | |
20a9b24e909914d95ae3f51374ba25fb26f42466 | fb7d7b587ffc0ff0b86cfa46940149cf5e4663c8 | /sfs-server/src/test/java/org/sfs/integration/java/test/contextroot/ContextRootTest.java | b0fe205eabca7b5c1287c4eef83f26b328eac69d | [
"Apache-2.0"
] | permissive | pitchpoint-solutions/sfs | 9c9d231118d7bf37c9d5672d070a527a1435f3e9 | d62387f494b369c819e03e5dc9e97b39a9fc85b0 | refs/heads/master | 2022-11-11T22:48:48.868752 | 2019-12-13T18:32:07 | 2019-12-13T18:32:07 | 69,255,078 | 94 | 14 | Apache-2.0 | 2022-10-04T23:43:10 | 2016-09-26T13:53:44 | Java | UTF-8 | Java | false | false | 2,963 | java | /*
* Copyright 2019 The Simple File Server Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.sfs.integration.java.test.contextroot;
import io.vertx.core.buffer.Buffer;
import io.vertx.ext.unit.TestContext;
import org.junit.Test;
import org.sfs.integration.java.BaseTestVerticle;
import org.sfs.integration.java.func.AssertHttpClientResponseStatusCode;
import org.sfs.integration.java.func.GetHealth;
import org.sfs.rx.HttpClientResponseBodyBuffer;
import org.sfs.rx.ToVoid;
import org.sfs.util.HttpBodyLogger;
import org.sfs.util.HttpClientResponseHeaderLogger;
import static java.net.HttpURLConnection.HTTP_NOT_FOUND;
import static java.net.HttpURLConnection.HTTP_OK;
import static rx.Observable.just;
public class ContextRootTest extends BaseTestVerticle {
@Test
public void testWithoutContextRoot(TestContext context) {
runOnServerContext(context, () -> {
return just((Void) null)
.flatMap(new GetHealth(httpClient()))
.map(new HttpClientResponseHeaderLogger())
.map(new AssertHttpClientResponseStatusCode(context, HTTP_OK))
.flatMap(new HttpClientResponseBodyBuffer())
.map(new HttpBodyLogger())
.map(new ToVoid<Buffer>());
});
}
@Test
public void testWithContextRoot(TestContext context) {
runOnServerContext(context, () -> {
return just((Void) null)
.flatMap(new GetHealth(httpClient()).setContextRoot("sfs"))
.map(new HttpClientResponseHeaderLogger())
.map(new AssertHttpClientResponseStatusCode(context, HTTP_OK))
.flatMap(new HttpClientResponseBodyBuffer())
.map(new HttpBodyLogger())
.map(new ToVoid<Buffer>());
});
}
@Test
public void testWithInvalidContextRoot(TestContext context) {
runOnServerContext(context, () -> {
return just((Void) null)
.flatMap(new GetHealth(httpClient()).setContextRoot("abc123"))
.map(new HttpClientResponseHeaderLogger())
.map(new AssertHttpClientResponseStatusCode(context, HTTP_NOT_FOUND))
.flatMap(new HttpClientResponseBodyBuffer())
.map(new HttpBodyLogger())
.map(new ToVoid<Buffer>());
});
}
}
| [
"[email protected]"
] | |
fabaf2096ad48a0393e0414632b53da398d5304d | 8c6f8d31691a30eba79d67db97ee6972ecd7dbee | /src/main/java/com/data/PlayerEquipment.java | 62514e316b0e1374a7511c4cc5037a7b97edf0f2 | [] | no_license | Profesor-Caos/dps-calculator | a13c547d4fd5fed85c94a059d27d15dfd556f0f1 | bbfaeff0655f9a3901fc9fde82ce7b2d862011c6 | refs/heads/master | 2023-02-27T03:03:28.689013 | 2021-02-05T23:34:55 | 2021-02-05T23:34:55 | 334,789,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,790 | java | package com.data;
import com.data.weapontypes.AttackType;
import com.data.weapontypes.CombatOption;
import net.runelite.api.Skill;
import net.runelite.http.api.item.ItemEquipmentStats;
import net.runelite.http.api.item.ItemStats;
import java.util.Arrays;
import java.util.List;
public class PlayerEquipment
{
private List<ItemStats> Equipment;
void Equip(ItemStats item)
{
if (!item.isEquipable())
return;
Equipment.removeIf(e -> e.getEquipment().getSlot() == item.getEquipment().getSlot());
Equipment.add(item);
}
public int GetDamageBonus(CombatOption combatOption)
{
if (combatOption.getAttackType() == AttackType.RANGED)
return Equipment.stream().mapToInt(e -> e.getEquipment().getRstr()).sum();
if (combatOption.getAttackType() == AttackType.MAGIC)
return Equipment.stream().mapToInt(e -> e.getEquipment().getMdmg()).sum();
return Equipment.stream().mapToInt(e -> e.getEquipment().getStr()).sum();
}
public int GetAttackBonus(CombatOption combatOption)
{
if (combatOption.getAttackType() == AttackType.RANGED)
return Equipment.stream().mapToInt(e -> e.getEquipment().getArange()).sum();
if (combatOption.getAttackType() == AttackType.MAGIC)
return Equipment.stream().mapToInt(e -> e.getEquipment().getAmagic()).sum();
if (combatOption.getAttackType() == AttackType.SLASH)
return Equipment.stream().mapToInt(e -> e.getEquipment().getAslash()).sum();
if (combatOption.getAttackType() == AttackType.CRUSH)
return Equipment.stream().mapToInt(e -> e.getEquipment().getAcrush()).sum();
return Equipment.stream().mapToInt(e -> e.getEquipment().getAstab()).sum();
}
}
| [
"[email protected]"
] | |
b0723c583b815a8344426eadf1e75a333ea46e87 | 15966d5c1043fa5a8681637f957f3aaf508fe541 | /src/main/java/com/nkhomad/aspect/LoggingAspect.java | 2d238982b4c34640addfbd779c103b8db32a4264 | [] | no_license | dannkhoma/medical-record | aa5acde4b5d7a278eb64022a512011857bf76b6a | 580ba4f3fbaecba1b005de866b7abcdb6ffce55f | refs/heads/master | 2023-07-09T04:17:35.927211 | 2021-08-09T14:47:18 | 2021-08-09T14:47:18 | 394,333,405 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,417 | java | package com.nkhomad.aspect;
import com.nkhomad.exception.CityNotFoundException;
import com.nkhomad.exception.CountryNotFoundException;
import com.nkhomad.exception.PatientsNotFoundException;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.CodeSignature;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.boot.logging.LogLevel;
import java.lang.reflect.Method;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.StringJoiner;
@Aspect
@Slf4j
public class LoggingAspect {
@AfterThrowing(pointcut = "execution(* com.nkhomad.patient.service.PatientServiceImpl.*(..))", throwing = "ex")
public void logAfterThrowingAllMethods(Exception ex) throws Throwable {
log.error("An exception occurred ", ex);
}
@AfterThrowing(pointcut = "within(com.nkhomad.city.service..*)", throwing = "ex")
public void logAfterThrowingAllMethods(CityNotFoundException ex) throws Throwable {
log.error("An exception occurred ", ex);
}
@AfterThrowing(pointcut = "within(com.nkhomad.country.service..*)", throwing = "ex")
public void logAfterThrowingAllMethods(CountryNotFoundException ex) throws Throwable {
log.error("An exception occurred ", ex);
}
@Around("@annotation(com.nkhomad.aspect.LogEntryExit)")
public Object log(ProceedingJoinPoint point) throws Throwable {
log.info(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
var codeSignature = (CodeSignature) point.getSignature();
var methodSignature = (MethodSignature) point.getSignature();
Method method = methodSignature.getMethod();
var annotation = method.getAnnotation(LogEntryExit.class);
LogLevel level = annotation.value();
ChronoUnit unit = annotation.unit();
boolean showArgs = annotation.showArgs();
boolean showResult = annotation.showResult();
boolean showExecutionTime = annotation.showExecutionTime();
String methodName = method.getName();
Object[] methodArgs = point.getArgs();
String[] methodParams = codeSignature.getParameterNames();
log(level, entry(methodName, showArgs, methodParams, methodArgs));
var start = Instant.now();
var response = point.proceed();
var end = Instant.now();
var duration = String.format("%s %s", unit.between(start, end), unit.name().toLowerCase());
log(level, exit(methodName, duration, response, showResult, showExecutionTime));
return response;
}
static String entry(String methodName, boolean showArgs, String[] params, Object[] args) {
StringJoiner message = new StringJoiner(" ")
.add("Started").add(methodName).add("method");
if (showArgs && Objects.nonNull(params) && Objects.nonNull(args) && params.length == args.length) {
Map<String, Object> values = new HashMap<>(params.length);
for (int i = 0; i < params.length; i++) {
values.put(params[i], args[i]);
}
message.add("with args:")
.add(values.toString());
}
return message.toString();
}
static String exit(String methodName, String duration, Object result, boolean showResult, boolean showExecutionTime) {
StringJoiner message = new StringJoiner(" ")
.add("Finished").add(methodName).add("method");
if (showExecutionTime) {
message.add("in").add(duration);
}
if (showResult) {
message.add("with return:").add(result.toString());
}
return message.toString();
}
static void log(LogLevel level, String message) {
switch (level) {
case DEBUG:
log.debug(message);
break;
case TRACE:
log.trace(message);
break;
case WARN:
log.warn(message);
break;
case ERROR:
log.error(message);
break;
default:
log.info(message);
break;
}
}
}
| [
"[email protected]"
] | |
7c6840e71f0520d23b80ee351e51d0690c04ba0c | 5e970c7dbf63dd6580174ea1546b6ddffcc978da | /Java/.history/DataChange_20201122083629.java | c103d0ef7d2667d578fadd274b6646b2afa00af3 | [] | no_license | havecourage/program | 195ac5470bb2a9d13df1e26f74b4c80b4421e05b | 6c388c4448ce1e64bab19b9753e702b4ab807d06 | refs/heads/master | 2023-08-30T19:26:07.062109 | 2021-10-21T13:31:46 | 2021-10-21T13:31:46 | 207,100,434 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 300 | java | /*
java中函数的传入只能是传值,只有当引用的对象发生那个变化的时候,变量的值才会发生变化。
*/
public final class DataChange {
public static void main() {
}
}
public class Student()
{
name="匿名";
age=0;
major="未知";
} | [
"[email protected]"
] | |
cbf95962bd5efb6005e7ad56da0161394dc02df5 | 784832cdbfbd13f26a7de024223bf4197a86dd3e | /spring-boot-with-ms-sql-server/src/main/java/com/example/springBootWithMsSqlServer/Dao/ScanDataRepository.java | 7d662d77fd875ad835517b46280ca410e3b5f78b | [] | no_license | rajdeepf1/SpringTuts | b7a12e1691106a378518a5dbf440aa89fda3f492 | 4b5daba73a0c91f568064ea0ccafbff42cfbd63b | refs/heads/master | 2022-04-01T23:49:12.512745 | 2020-01-28T12:06:47 | 2020-01-28T12:06:47 | 230,255,547 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.example.springBootWithMsSqlServer.Dao;
import com.example.springBootWithMsSqlServer.Models.ScanDataModel;
import org.springframework.data.jpa.repository.JpaRepository;
import java.util.List;
public interface ScanDataRepository extends JpaRepository<ScanDataModel,Integer> {
List<ScanDataModel> findAllByScanData(String scanData);
}
| [
"[email protected]"
] | |
fdb888b98beb91dfe8679341f8610f66f40bd0ce | f681f1a323447ef237791716eaece89753cbd71b | /src/Praktikum/laithan4Aksi.java | 7039df680211e74c8c507cf0079a472106e35d59 | [] | no_license | Ronyzs/PBO-Gui | e59987b0ed96d97a2d1ff61b8052187f352b4b2c | 42a3cf947afbad0af031c9825201e8bcbe5d669f | refs/heads/master | 2023-08-14T07:34:22.129003 | 2021-10-13T03:13:12 | 2021-10-13T03:13:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,666 | 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 Praktikum;
import java.util.Scanner;
import Praktikum.latihan4.TreeNode;
import static Praktikum.latihan4.createBinaryTree;
/**
*
* @author Ronyzs
*/
public class laithan4Aksi {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
latihan4 op = new latihan4();
System.out.println("Pilih menu : ");
System.out.println("1. Quick Sort\n2. Binary Tree");
System.out.print("Pilih : ");
int menu = in.nextInt();
if (menu == 1) {
System.out.print("\nJumlah data : ");
int jmlData = in.nextInt();
int[] data = new int[jmlData];
for (int i = 0; i < jmlData; i++) {
System.out.print("Data ke-" + (i + 1) + " : ");
data[i] = in.nextInt();
}
op.cetak(data);
}
else if(menu==2)
{
TreeNode rootNode = createBinaryTree();
System.out.println("\nTampilan PreOrder Tree : ");
op.preorder(rootNode);
System.out.println();
System.out.println("-------------------------");
System.out.println("Tampilan PostOrder Tree :");
op.postOrder(rootNode);
System.out.println();
System.out.println("-------------------------");
System.out.println("Tampilan InOrder Tree:");
op.inOrder(rootNode);
System.out.println();
}
}
}
| [
"[email protected],id"
] | |
abe292fd27f973157d8e843597792a514ce1f8a9 | 591820bfbbff2432f9d2552d257e8f5d27d17c7c | /DesignPatterns/src/strupattern/decorator/OnlineBanking.java | 91009af2b81bc9b5b4c5e413a562c4cfc381cda6 | [] | no_license | sku286/coreJava | 623a502b346f3e6f2bc6de1c4fd6eecca7cffee4 | b49e2f63cc2e5dc692e93f686cd5711c7a354e9c | refs/heads/master | 2021-01-10T03:22:30.708010 | 2016-03-03T10:55:48 | 2016-03-03T10:55:48 | 50,653,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 376 | java | package strupattern.decorator;
public class OnlineBanking extends FeatureDecorator {
BankAccount account;
public OnlineBanking(BankAccount account) {
super(account);
this.account=account;
}
@Override
public double balanceToMaintain() {
// TODO Auto-generated method stub
return account.balanceToMaintain()+5000;
}
}
| [
"[email protected]"
] | |
5b7b880e05dfff00fe3b371c1aea3892bacc332b | 59ca8a5e4ca088f8d93fe29859313c60099403a4 | /src/main/java/com/cms/entities/admin/AccountDutyInfo.java | 7b6e7a2919863a09d5b0d02b5ebb975194f66e66 | [
"Apache-2.0"
] | permissive | EvilGreenArmy/cms | f208db2ae88ed6256e22ab3e82ce3a30955aae9c | 67713060a8b0718dcbc29dbf9ff2a4301c7b7cd7 | refs/heads/master | 2021-01-17T12:36:02.183714 | 2016-06-20T12:41:08 | 2016-06-20T12:41:08 | 57,881,538 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 472 | java | package com.cms.entities.admin;
/**
* Created by Evan on 2016/4/3.
*/
public class AccountDutyInfo {
private Integer accountId;
private Integer dutyId;
public Integer getAccountId() {
return accountId;
}
public void setAccountId(Integer accountId) {
this.accountId = accountId;
}
public Integer getDutyId() {
return dutyId;
}
public void setDutyId(Integer dutyId) {
this.dutyId = dutyId;
}
}
| [
"[email protected]"
] | |
b153475405091385765b28bd07212ee9ccc0e99c | cae4b09e7b100d1e6cbd23043d34f4ba4453f23e | /ext/ext-service/src/com/ext/portlet/plans/model/PlansFilterSoap.java | d26ee3ad0fd42bc1d2fdee49450d3a26ce9a87a0 | [] | no_license | Letractively/climatecollaboratorium | 27d7e9008a0a998c37eb913e1daa21716946a35a | dcc352d338c0259bbc55ff2c6be70814b6c461b0 | refs/heads/master | 2021-01-10T16:49:41.318159 | 2012-07-11T08:50:47 | 2012-07-11T08:50:47 | 46,159,622 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,308 | java | package com.ext.portlet.plans.model;
import com.ext.portlet.plans.service.persistence.PlansFilterPK;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <a href="PlansFilterSoap.java.html"><b><i>View Source</i></b></a>
*
* <p>
* ServiceBuilder generated this class. Modifications in this class will be
* overwritten the next time is generated.
* </p>
*
* <p>
* This class is used by
* <code>com.ext.portlet.plans.service.http.PlansFilterServiceSoap</code>.
* </p>
*
* @author Brian Wing Shun Chan
*
* @see com.ext.portlet.plans.service.http.PlansFilterServiceSoap
*
*/
public class PlansFilterSoap implements Serializable {
private Long _userId;
private Long _planTypeId;
private String _name;
private String _creator;
private String _description;
private Double _CO2From;
private Double _CO2To;
private Double _votesFrom;
private Double _votesTo;
private Double _damageFrom;
private Double _damageTo;
private Double _mitigationFrom;
private Double _mitigationTo;
private Date _dateFrom;
private Date _dateTo;
private Boolean _filterPositionsAll;
private Boolean _enabled;
public PlansFilterSoap() {
}
public static PlansFilterSoap toSoapModel(PlansFilter model) {
PlansFilterSoap soapModel = new PlansFilterSoap();
soapModel.setUserId(model.getUserId());
soapModel.setPlanTypeId(model.getPlanTypeId());
soapModel.setName(model.getName());
soapModel.setCreator(model.getCreator());
soapModel.setDescription(model.getDescription());
soapModel.setCO2From(model.getCO2From());
soapModel.setCO2To(model.getCO2To());
soapModel.setVotesFrom(model.getVotesFrom());
soapModel.setVotesTo(model.getVotesTo());
soapModel.setDamageFrom(model.getDamageFrom());
soapModel.setDamageTo(model.getDamageTo());
soapModel.setMitigationFrom(model.getMitigationFrom());
soapModel.setMitigationTo(model.getMitigationTo());
soapModel.setDateFrom(model.getDateFrom());
soapModel.setDateTo(model.getDateTo());
soapModel.setFilterPositionsAll(model.getFilterPositionsAll());
soapModel.setEnabled(model.getEnabled());
return soapModel;
}
public static PlansFilterSoap[] toSoapModels(PlansFilter[] models) {
PlansFilterSoap[] soapModels = new PlansFilterSoap[models.length];
for (int i = 0; i < models.length; i++) {
soapModels[i] = toSoapModel(models[i]);
}
return soapModels;
}
public static PlansFilterSoap[][] toSoapModels(PlansFilter[][] models) {
PlansFilterSoap[][] soapModels = null;
if (models.length > 0) {
soapModels = new PlansFilterSoap[models.length][models[0].length];
} else {
soapModels = new PlansFilterSoap[0][0];
}
for (int i = 0; i < models.length; i++) {
soapModels[i] = toSoapModels(models[i]);
}
return soapModels;
}
public static PlansFilterSoap[] toSoapModels(List<PlansFilter> models) {
List<PlansFilterSoap> soapModels = new ArrayList<PlansFilterSoap>(models.size());
for (PlansFilter model : models) {
soapModels.add(toSoapModel(model));
}
return soapModels.toArray(new PlansFilterSoap[soapModels.size()]);
}
public PlansFilterPK getPrimaryKey() {
return new PlansFilterPK(_userId, _planTypeId);
}
public void setPrimaryKey(PlansFilterPK pk) {
setUserId(pk.userId);
setPlanTypeId(pk.planTypeId);
}
public Long getUserId() {
return _userId;
}
public void setUserId(Long userId) {
_userId = userId;
}
public Long getPlanTypeId() {
return _planTypeId;
}
public void setPlanTypeId(Long planTypeId) {
_planTypeId = planTypeId;
}
public String getName() {
return _name;
}
public void setName(String name) {
_name = name;
}
public String getCreator() {
return _creator;
}
public void setCreator(String creator) {
_creator = creator;
}
public String getDescription() {
return _description;
}
public void setDescription(String description) {
_description = description;
}
public Double getCO2From() {
return _CO2From;
}
public void setCO2From(Double CO2From) {
_CO2From = CO2From;
}
public Double getCO2To() {
return _CO2To;
}
public void setCO2To(Double CO2To) {
_CO2To = CO2To;
}
public Double getVotesFrom() {
return _votesFrom;
}
public void setVotesFrom(Double votesFrom) {
_votesFrom = votesFrom;
}
public Double getVotesTo() {
return _votesTo;
}
public void setVotesTo(Double votesTo) {
_votesTo = votesTo;
}
public Double getDamageFrom() {
return _damageFrom;
}
public void setDamageFrom(Double damageFrom) {
_damageFrom = damageFrom;
}
public Double getDamageTo() {
return _damageTo;
}
public void setDamageTo(Double damageTo) {
_damageTo = damageTo;
}
public Double getMitigationFrom() {
return _mitigationFrom;
}
public void setMitigationFrom(Double mitigationFrom) {
_mitigationFrom = mitigationFrom;
}
public Double getMitigationTo() {
return _mitigationTo;
}
public void setMitigationTo(Double mitigationTo) {
_mitigationTo = mitigationTo;
}
public Date getDateFrom() {
return _dateFrom;
}
public void setDateFrom(Date dateFrom) {
_dateFrom = dateFrom;
}
public Date getDateTo() {
return _dateTo;
}
public void setDateTo(Date dateTo) {
_dateTo = dateTo;
}
public Boolean getFilterPositionsAll() {
return _filterPositionsAll;
}
public void setFilterPositionsAll(Boolean filterPositionsAll) {
_filterPositionsAll = filterPositionsAll;
}
public Boolean getEnabled() {
return _enabled;
}
public void setEnabled(Boolean enabled) {
_enabled = enabled;
}
}
| [
"jintrone@e9ce9132-09df-11df-a843-f99e4352f152"
] | jintrone@e9ce9132-09df-11df-a843-f99e4352f152 |
f56cbdf2e752640e05a6f0e3521d046d4726f198 | a948792938d08a7141ef219908454ab6c86dc821 | /ejb-connector1/src/main/java/org/wso2/carbon/custom/connector/EJBStatelessBean.java | 21765b572d88d4944778dd38879be9e32942ec49 | [
"Apache-2.0"
] | permissive | hmrajas/WSO2-EJB2-Connector | 41fd390c91e0ed3c07d1d0301678261bfd85473f | c83ac7f96bc008bfbda34a3066344c8e90b9839d | refs/heads/master | 2021-01-10T10:01:07.161535 | 2015-11-17T12:32:44 | 2015-11-17T12:32:44 | 46,222,977 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,891 | java | /**
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* <p/>
* 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
* <p/>
* http://www.apache.org/licenses/LICENSE-2.0
* <p/>
* 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.wso2.carbon.custom.connector;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
import org.wso2.carbon.connector.core.AbstractConnector;
import javax.xml.stream.XMLStreamException;
import java.lang.reflect.Method;
public class EJBStatelessBean extends AbstractConnector {
private static final Log log = LogFactory.getLog(EJBStatelessBean.class);
EJBFactory ejbFacrory = new EJBFactory();
Method method;
@Override
public void connect(MessageContext ctx) {
log.info("Initializing EJBConnector");
Thread currentThread = Thread.currentThread();
ClassLoader oldClassLoader = currentThread.getContextClassLoader();
try {
//switching the classloader to prevent class loading glassfish classloading issues
currentThread.setContextClassLoader(getClass().getClassLoader());
callEJB(ctx);
} catch (Exception e) {
handleException("Error calling EJB Service from EJBConnector", e, ctx);
} finally {
if (oldClassLoader != null) {
//resetting the classloader
currentThread.setContextClassLoader(oldClassLoader);
}
}
}
/**
* Calls the EJB Service..
*
* @param ctx
* @throws Exception
*/
private void callEJB(MessageContext ctx) {
Object ejbObj = ejbFacrory.getEJBObject(ctx,EJBConstance.JNDI_NAME);
Class aClass = ejbObj.getClass();
Object[] args = ejbFacrory.buildArguments(ctx, EJBConstance.STATELESS);
String methodName = getParameter(ctx, EJBConstance.METHOD_NAME).toString();
try {
method = ejbFacrory.resolveMethod(Class.forName(aClass.getName()),
methodName, args.length);
ctx.setProperty(EJBConstance.Response, ejbFacrory.invokeInstanceMethod(ejbObj, method, args));
} catch (ClassNotFoundException e) {
handleException("Could not load '" + aClass.getName() + "' class.", e, ctx);
} catch (XMLStreamException e) {
handleException("Could not load '" + aClass.getName() + "' class.", e, ctx);
}
}
}
| [
"[email protected]"
] | |
55bbfd287387db17062602684b66de553dbe3690 | 7e1dc678f14d6ef325669b2a122ee930e226aab8 | /src/main/java/extend/GenericUDFArrayContainsEither.java | e69718d145930a117574f70a53db872b81fc9b9a | [] | no_license | qifengdao/extend-udf | e9cb075796082104f997b5cb6d3d2132463fd630 | c51dfff548ceaff731ade22c3385604b951202d4 | refs/heads/master | 2020-12-07T05:11:45.093205 | 2017-11-13T02:18:28 | 2017-11-13T02:18:28 | 68,571,718 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,925 | java | package extend.udf;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDFArgumentException;
import org.apache.hadoop.hive.ql.exec.UDFArgumentTypeException;
import org.apache.hadoop.hive.ql.metadata.HiveException;
import org.apache.hadoop.hive.ql.udf.generic.GenericUDF;
import org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector.Category;
import org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils;
import org.apache.hadoop.hive.serde2.objectinspector.primitive.PrimitiveObjectInspectorFactory;
import org.apache.hadoop.io.BooleanWritable;
/**
* GenericUDFArrayContainsEither.
*
*/
@Description(name = "array_contains_either",
value="_FUNC_(array, array) - Returns TRUE if the array contains value.",
extended="Example:\n"
+ " > SELECT _FUNC_(array(1, 2, 3), array(2, 4)) FROM src LIMIT 1;\n"
+ " true")
public class GenericUDFArrayContainsEither extends GenericUDF {
private static final int ARRAY_IDX = 0;
private static final int VALUE_IDX = 1;
private static final int ARG_COUNT = 2; // Number of arguments to this UDF
private static final String FUNC_NAME = "ARRAY_CONTAINS_EITHER"; // External Name
private transient ListObjectInspector valueOI;
private transient ListObjectInspector arrayOI;
private transient ObjectInspector arrayElementOI;
private transient ObjectInspector valueElementOI;
private BooleanWritable result;
@Override
public ObjectInspector initialize(ObjectInspector[] arguments)
throws UDFArgumentException {
// Check if two arguments were passed
if (arguments.length != ARG_COUNT) {
throw new UDFArgumentException(
"The function " + FUNC_NAME + " accepts "
+ ARG_COUNT + " arguments.");
}
// Check if ARRAY_IDX argument is of category LIST
if (!arguments[ARRAY_IDX].getCategory().equals(Category.LIST)) {
throw new UDFArgumentTypeException(ARRAY_IDX,
"\"" + org.apache.hadoop.hive.serde.serdeConstants.LIST_TYPE_NAME + "\" "
+ "expected at function ARRAY_CONTAINS_EITHER, but "
+ "\"" + arguments[ARRAY_IDX].getTypeName() + "\" "
+ "is found");
}
// Check if ARRAY_IDX argument is of category LIST
if (!arguments[VALUE_IDX].getCategory().equals(Category.LIST)) {
throw new UDFArgumentTypeException(VALUE_IDX,
"\"" + org.apache.hadoop.hive.serde.serdeConstants.LIST_TYPE_NAME + "\" "
+ "expected at function ARRAY_CONTAINS_EITHER, but "
+ "\"" + arguments[VALUE_IDX].getTypeName() + "\" "
+ "is found");
}
arrayOI = (ListObjectInspector) arguments[ARRAY_IDX];
arrayElementOI = arrayOI.getListElementObjectInspector();
valueOI = (ListObjectInspector) arguments[VALUE_IDX];
valueElementOI = valueOI.getListElementObjectInspector();
// Check if list element and value are of same type
if (!ObjectInspectorUtils.compareTypes(arrayElementOI, valueElementOI)) {
throw new UDFArgumentTypeException(VALUE_IDX,
"\"" + arrayElementOI.getTypeName() + "\""
+ " expected at function ARRAY_CONTAINS, but "
+ "\"" + valueElementOI.getTypeName() + "\""
+ " is found");
}
result = new BooleanWritable(false);
return PrimitiveObjectInspectorFactory.writableBooleanObjectInspector;
}
@Override
public Object evaluate(DeferredObject[] arguments) throws HiveException {
result.set(false);
Object array = arguments[ARRAY_IDX].get();
Object arrayValue = arguments[VALUE_IDX].get();
int arrayLength = arrayOI.getListLength(array);
int arrayValLength = valueOI.getListLength(arrayValue);
// Check if array is null or empty or value is null
if (arrayValLength <=0 || arrayLength <= 0) {
return result;
}
// Compare the value to each element of array until a match is found
outer:for (int j=0; j<arrayValLength; ++j) {
Object value = arrayOI.getListElement(arrayValue, j);
for (int i=0; i<arrayLength; ++i) {
Object listElement = arrayOI.getListElement(array, i);
if (listElement != null && value != null) {
if (ObjectInspectorUtils.compare(value, valueElementOI,
listElement, arrayElementOI) == 0) {
result.set(true);
break outer;
}
}
}
}
return result;
}
@Override
public String getDisplayString(String[] children) {
assert (children.length == ARG_COUNT);
return "array_contains(" + children[ARRAY_IDX] + ", "
+ children[VALUE_IDX] + ")";
}
}
| [
"[email protected]"
] | |
c51d79a2efd362d857097f7523e45f503d5f3222 | d14bf7f7060d207bb976e018e66f52b993b8615f | /service/service_acl/src/main/java/com/atguigu/aclservice/service/impl/UserDetailsServiceImpl.java | c3fc28d8c7d400a4565fd45bef912ee4abf6f042 | [] | no_license | Soliton3/OnlineSys | f1c4406f791c93843fc71616ce38724b4f704843 | 8ef16072b69e90f3d57dbcc8b0986f02b0887817 | refs/heads/master | 2023-06-06T05:32:28.020937 | 2021-06-28T01:37:55 | 2021-06-28T01:37:55 | 352,540,514 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,927 | java | package com.atguigu.aclservice.service.impl;
import com.atguigu.aclservice.entity.User;
import com.atguigu.aclservice.service.PermissionService;
import com.atguigu.aclservice.service.UserService;
import com.atguigu.serurity.entity.SecurityUser;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* <p>
* 自定义userDetailsService - 认证用户详情
* </p>
*
* @author qy
* @since 2019-11-08
*/
@Service("userDetailsService")
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserService userService;
@Autowired
private PermissionService permissionService;
/***
* 根据账号获取用户信息
* @param username:
* @return: org.springframework.security.core.userdetails.UserDetails
*/
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// 从数据库中取出用户信息
User user = userService.selectByUsername(username);
// 判断用户是否存在
if (null == user){
//throw new UsernameNotFoundException("用户名不存在!");
}
// 返回UserDetails实现类
com.atguigu.serurity.entity.User curUser = new com.atguigu.serurity.entity.User();
BeanUtils.copyProperties(user,curUser);
List<String> authorities = permissionService.selectPermissionValueByUserId(user.getId());
SecurityUser securityUser = new SecurityUser(curUser);
securityUser.setPermissionValueList(authorities);
return securityUser;
}
}
| [
"[email protected]"
] | |
cd5199331dc454f5af03b1306fabda40db50cde7 | 18c91b710f017b426e2586bb1814f947dbe78a8d | /commands/emoji/select/AbstractCommandSelectEmoji.java | cf4c477e266f1fa7d9354930a104d77f6654fc31 | [] | no_license | aliounebfall/someweireBot | bb5034dbae589e247204f23eaae7a5113a08d4e2 | bd88668f00553700225f6b24b2d0e39096f0eb3e | refs/heads/master | 2023-03-17T12:34:13.043052 | 2021-03-16T23:26:48 | 2021-03-16T23:26:48 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,281 | java | package com.bot.someweire.commands.emoji.select;
import com.bot.someweire.commands.abstractModel.AbstractCommandEmoji;
import com.bot.someweire.model.Character;
import com.bot.someweire.model.Enigme;
import com.bot.someweire.model.World;
import discord4j.core.event.domain.message.ReactionAddEvent;
import discord4j.core.object.entity.Message;
import discord4j.core.object.reaction.ReactionEmoji;
public abstract class AbstractCommandSelectEmoji extends AbstractCommandEmoji {
protected Character player;
protected Enigme enigme;
protected World world;
public void loadContext(Character player,
Enigme enigme,
World world){
this.player = player;
this.enigme = enigme;
this.world = world;
}
protected boolean filter(Message userMessage, Message botMessage, ReactionAddEvent event){
return event
.getMessageId()
.asString()
.equals(botMessage
.getId()
.asString()) && event
.getUserId()
.asString()
.equals(userMessage
.getAuthor()
.get()
.getId()
.asString());
}
protected void manageReactionsConfirmEmojis(Message msg){
msg.removeAllReactions()
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getConfirmEmoji())))
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getCancelEmoji())))
.subscribe();
}
protected void manageReactionRemoveConfirmEmojis(Message msg,
boolean forfeitPower,
boolean isSoldier){
msg.removeAllReactions()
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getIndiceEmoji())))
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getForfeitEmoji())))
.thenMany(subscriber -> {
if (!isSoldier){
msg.addReaction(ReactionEmoji.unicode(emojiHelper.getPowerEmoji())).subscribe();
}
if (forfeitPower){
msg.addReaction(ReactionEmoji.unicode(emojiHelper.getForfeitPowerEmoji())).subscribe();
}
})
.subscribe();
}
protected void manageReactionRemoveConfirmEmojisGetEnigme(Message msg){
msg.removeAllReactions()
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getFragmentEmoji())))
.then(msg.addReaction(ReactionEmoji.unicode(emojiHelper.getPowerEmoji())))
.subscribe();
}
protected void manageReactionsExceptionEmojis(Message userMessage, Message botMessage){
subscriptionManager.cancelSubscriptionOnMessage(userMessage, botMessage);
botMessage.suppressEmbeds(true)
.then(botMessage.removeAllReactions())
.subscribe();
}
@Override
public types getType() {
return types.SELECT;
}
}
| [
"[email protected]"
] | |
75e64653d9ff33f553168db9b8effc69cfb456f9 | de7b67d4f8aa124f09fc133be5295a0c18d80171 | /workspace_java-src/java-src-test/src/com/sun/xml/internal/bind/v2/runtime/unmarshaller/StAXEventConnector.java | baa356c0299e907d7a4835034936e9e51f67141b | [] | no_license | lin-lee/eclipse_workspace_test | adce936e4ae8df97f7f28965a6728540d63224c7 | 37507f78bc942afb11490c49942cdfc6ef3dfef8 | refs/heads/master | 2021-05-09T10:02:55.854906 | 2018-01-31T07:19:02 | 2018-01-31T07:19:02 | 119,460,523 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 8,616 | java | /*
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.sun.xml.internal.bind.v2.runtime.unmarshaller;
import java.util.Iterator;
import javax.xml.namespace.QName;
import javax.xml.stream.Location;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamConstants;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Characters;
import javax.xml.stream.events.EndElement;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
/**
* This is a simple utility class that adapts StAX events from an
* {@link XMLEventReader} to unmarshaller events on a
* {@link XmlVisitor}, bridging between the two
* parser technologies.
*
* @author [email protected]
* @version 1.0
*/
final class StAXEventConnector extends StAXConnector {
// StAX event source
private final XMLEventReader staxEventReader;
/** Current event. */
private XMLEvent event;
/**
* Shared and reused {@link Attributes}.
*/
private final AttributesImpl attrs = new AttributesImpl();
/**
* SAX may fire consective characters event, but we don't allow it.
* so use this buffer to perform buffering.
*/
private final StringBuilder buffer = new StringBuilder();
private boolean seenText;
/**
* Construct a new StAX to SAX adapter that will convert a StAX event
* stream into a SAX event stream.
*
* @param staxCore
* StAX event source
* @param visitor
* sink
*/
public StAXEventConnector(XMLEventReader staxCore, XmlVisitor visitor) {
super(visitor);
staxEventReader = staxCore;
}
public void bridge() throws XMLStreamException {
try {
// remembers the nest level of elements to know when we are done.
int depth=0;
event = staxEventReader.peek();
if( !event.isStartDocument() && !event.isStartElement() )
throw new IllegalStateException();
// if the parser is on START_DOCUMENT, skip ahead to the first element
do {
event = staxEventReader.nextEvent();
} while( !event.isStartElement() );
handleStartDocument(event.asStartElement().getNamespaceContext());
OUTER:
while(true) {
// These are all of the events listed in the javadoc for
// XMLEvent.
// The spec only really describes 11 of them.
switch (event.getEventType()) {
case XMLStreamConstants.START_ELEMENT :
handleStartElement(event.asStartElement());
depth++;
break;
case XMLStreamConstants.END_ELEMENT :
depth--;
handleEndElement(event.asEndElement());
if(depth==0) break OUTER;
break;
case XMLStreamConstants.CHARACTERS :
case XMLStreamConstants.CDATA :
case XMLStreamConstants.SPACE :
handleCharacters(event.asCharacters());
break;
}
event=staxEventReader.nextEvent();
}
handleEndDocument();
event = null; // avoid keeping a stale reference
} catch (SAXException e) {
throw new XMLStreamException(e);
}
}
protected Location getCurrentLocation() {
return event.getLocation();
}
protected String getCurrentQName() {
QName qName;
if(event.isEndElement())
qName = event.asEndElement().getName();
else
qName = event.asStartElement().getName();
return getQName(qName.getPrefix(), qName.getLocalPart());
}
private void handleCharacters(Characters event) throws SAXException, XMLStreamException {
if(!predictor.expectText())
return; // text isn't expected. simply skip
seenText = true;
// check the next event
XMLEvent next;
while(true) {
next = staxEventReader.peek();
if(!isIgnorable(next))
break;
staxEventReader.nextEvent();
}
if(isTag(next)) {
// this is by far the common case --- you have <foo>abc</foo> or <foo>abc<bar/>...</foo>
visitor.text(event.getData());
return;
}
// otherwise we have things like "abc<!-- test -->def".
// concatenate all text
buffer.append(event.getData());
while(true) {
while(true) {
next = staxEventReader.peek();
if(!isIgnorable(next))
break;
staxEventReader.nextEvent();
}
if(isTag(next)) {
// found all adjacent text
visitor.text(buffer);
buffer.setLength(0);
return;
}
buffer.append(next.asCharacters().getData());
staxEventReader.nextEvent(); // consume
}
}
private boolean isTag(XMLEvent event) {
int eventType = event.getEventType();
return eventType==XMLEvent.START_ELEMENT || eventType==XMLEvent.END_ELEMENT;
}
private boolean isIgnorable(XMLEvent event) {
int eventType = event.getEventType();
return eventType==XMLEvent.COMMENT || eventType==XMLEvent.PROCESSING_INSTRUCTION;
}
private void handleEndElement(EndElement event) throws SAXException {
if(!seenText && predictor.expectText()) {
visitor.text("");
}
// fire endElement
QName qName = event.getName();
tagName.uri = fixNull(qName.getNamespaceURI());
tagName.local = qName.getLocalPart();
visitor.endElement(tagName);
// end namespace bindings
for( Iterator<Namespace> i = event.getNamespaces(); i.hasNext();) {
String prefix = fixNull(i.next().getPrefix()); // be defensive
visitor.endPrefixMapping(prefix);
}
seenText = false;
}
private void handleStartElement(StartElement event) throws SAXException {
// start namespace bindings
for (Iterator i = event.getNamespaces(); i.hasNext();) {
Namespace ns = (Namespace)i.next();
visitor.startPrefixMapping(
fixNull(ns.getPrefix()),
fixNull(ns.getNamespaceURI()));
}
// fire startElement
QName qName = event.getName();
tagName.uri = fixNull(qName.getNamespaceURI());
String localName = qName.getLocalPart();
tagName.uri = fixNull(qName.getNamespaceURI());
tagName.local = localName;
tagName.atts = getAttributes(event);
visitor.startElement(tagName);
seenText = false;
}
/**
* Get the attributes associated with the given START_ELEMENT StAXevent.
*
* @return the StAX attributes converted to an org.xml.sax.Attributes
*/
private Attributes getAttributes(StartElement event) {
attrs.clear();
// in SAX, namespace declarations are not part of attributes by default.
// (there's a property to control that, but as far as we are concerned
// we don't use it.) So don't add xmlns:* to attributes.
// gather non-namespace attrs
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute staxAttr = (Attribute)i.next();
QName name = staxAttr.getName();
String uri = fixNull(name.getNamespaceURI());
String localName = name.getLocalPart();
String prefix = name.getPrefix();
String qName;
if (prefix == null || prefix.length() == 0)
qName = localName;
else
qName = prefix + ':' + localName;
String type = staxAttr.getDTDType();
String value = staxAttr.getValue();
attrs.addAttribute(uri, localName, qName, type, value);
}
return attrs;
}
}
| [
"[email protected]"
] | |
44e4f5b78b2881c4659895e99992c5df489e3680 | 71cbeec1f6f2dd05e6223370ed228659e51da2e4 | /src/main/java/com/blogspot/mydailyjava/guava/cache/overflow/FileSystemLoadingPersistingCache.java | 24529072db6769017e04a3a0a8e7fbbe9520fe53 | [
"Apache-2.0"
] | permissive | rdenaux/guava-cache-overflow-extension | 37b10928a0fc67a7e4d256af272df8c37d5b0e72 | 364db04ba8b85091ab04547f1a8805e23ae65aba | refs/heads/master | 2021-01-15T09:46:27.587148 | 2016-04-12T14:12:07 | 2016-04-12T14:12:07 | 56,068,215 | 0 | 0 | null | 2016-04-12T14:03:55 | 2016-04-12T14:03:55 | null | UTF-8 | Java | false | false | 3,328 | java | package com.blogspot.mydailyjava.guava.cache.overflow;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.cache.RemovalListener;
import com.google.common.collect.ImmutableMap;
import com.google.common.io.Files;
import java.io.File;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
public class FileSystemLoadingPersistingCache<K, V> extends FileSystemPersistingCache<K, V> implements LoadingCache<K, V> {
private final CacheLoader<? super K, V> cacheLoader;
protected FileSystemLoadingPersistingCache(CacheBuilder<Object, Object> cacheBuilder, CacheLoader<? super K, V> cacheLoader) {
this(cacheBuilder, cacheLoader, Files.createTempDir());
}
protected FileSystemLoadingPersistingCache(CacheBuilder<Object, Object> cacheBuilder, CacheLoader<? super K, V> cacheLoader, File persistenceDirectory) {
this(cacheBuilder, cacheLoader, persistenceDirectory, null);
}
protected FileSystemLoadingPersistingCache(CacheBuilder<Object, Object> cacheBuilder, CacheLoader<? super K, V> cacheLoader, RemovalListener<K, V> removalListener) {
this(cacheBuilder, cacheLoader, Files.createTempDir(), removalListener);
}
protected FileSystemLoadingPersistingCache(CacheBuilder<Object, Object> cacheBuilder, CacheLoader<? super K, V> cacheLoader,
File persistenceDirectory, RemovalListener<K, V> removalListener) {
super(cacheBuilder, persistenceDirectory, removalListener);
this.cacheLoader = cacheLoader;
}
private class ValueLoaderFromCacheLoader implements Callable<V> {
private final K key;
private final CacheLoader<? super K, V> cacheLoader;
private ValueLoaderFromCacheLoader(CacheLoader<? super K, V> cacheLoader, K key) {
this.key = key;
this.cacheLoader = cacheLoader;
}
@Override
public V call() throws Exception {
return cacheLoader.load(key);
}
}
@Override
public V get(K key) throws ExecutionException {
return get(key, new ValueLoaderFromCacheLoader(cacheLoader, key));
}
@Override
public V getUnchecked(K key) {
try {
return get(key, new ValueLoaderFromCacheLoader(cacheLoader, key));
} catch (ExecutionException e) {
throw new RuntimeException(e.getCause());
}
}
@Override
public ImmutableMap<K, V> getAll(Iterable<? extends K> keys) throws ExecutionException {
ImmutableMap.Builder<K, V> all = ImmutableMap.builder();
for (K key : keys) {
all.put(key, get(key));
}
return all.build();
}
@Override
public V apply(K key) {
try {
return cacheLoader.load(key);
} catch (Exception e) {
throw new RuntimeException(String.format("Could not apply cache on key %s", key), e);
}
}
@Override
public void refresh(K key) {
try {
getUnderlyingCache().put(key, cacheLoader.load(key));
} catch (Exception e) {
throw new RuntimeException(String.format("Could not refresh value for key %s", key), e);
}
}
}
| [
"[email protected]"
] | |
13217a67b42c6cdd7db97204318a8cc1a94f62ea | da1b8097a29f89730ff6ce34e0192fcf4577919e | /src/main/java/br/mppe/mp/recadastro/domain/CategoriaESocial.java | ff632158e73e520d42aca0676e3c87866f3ea6a8 | [] | no_license | acsn2/recadastro | d53ce5f7bdaf7b109328d2540d68a6c1e26b0206 | bb2cb66ab329605bda28f6403110e91438b22c3b | refs/heads/master | 2020-03-21T06:25:11.852812 | 2018-06-21T20:49:09 | 2018-06-21T20:49:09 | 138,218,276 | 0 | 0 | null | 2018-06-21T20:49:10 | 2018-06-21T20:26:35 | Java | UTF-8 | Java | false | false | 3,495 | java | package br.mppe.mp.recadastro.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import javax.validation.constraints.*;
import org.springframework.data.elasticsearch.annotations.Document;
import java.io.Serializable;
import java.util.Objects;
/**
* A CategoriaESocial.
*/
@Entity
@Table(name = "categoria_e_social")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "categoriaesocial")
public class CategoriaESocial implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sequenceGenerator")
@SequenceGenerator(name = "sequenceGenerator")
private Long id;
@NotNull
@Column(name = "cod_categoria", nullable = false)
private Integer codCategoria;
@Column(name = "desc_categoria")
private String descCategoria;
@Column(name = "grupo_cat")
private String grupoCat;
@OneToOne
@JoinColumn(unique = true)
private Servidor categoriaESocial;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getCodCategoria() {
return codCategoria;
}
public CategoriaESocial codCategoria(Integer codCategoria) {
this.codCategoria = codCategoria;
return this;
}
public void setCodCategoria(Integer codCategoria) {
this.codCategoria = codCategoria;
}
public String getDescCategoria() {
return descCategoria;
}
public CategoriaESocial descCategoria(String descCategoria) {
this.descCategoria = descCategoria;
return this;
}
public void setDescCategoria(String descCategoria) {
this.descCategoria = descCategoria;
}
public String getGrupoCat() {
return grupoCat;
}
public CategoriaESocial grupoCat(String grupoCat) {
this.grupoCat = grupoCat;
return this;
}
public void setGrupoCat(String grupoCat) {
this.grupoCat = grupoCat;
}
public Servidor getCategoriaESocial() {
return categoriaESocial;
}
public CategoriaESocial categoriaESocial(Servidor servidor) {
this.categoriaESocial = servidor;
return this;
}
public void setCategoriaESocial(Servidor servidor) {
this.categoriaESocial = servidor;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CategoriaESocial categoriaESocial = (CategoriaESocial) o;
if (categoriaESocial.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), categoriaESocial.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "CategoriaESocial{" +
"id=" + getId() +
", codCategoria=" + getCodCategoria() +
", descCategoria='" + getDescCategoria() + "'" +
", grupoCat='" + getGrupoCat() + "'" +
"}";
}
}
| [
"[email protected]"
] | |
7e50d9b324fe956afea6e1c71f7d2ed3acc09d2c | 63b904315830636060a8254ae2ad1919c6bd9979 | /online-safe-monitor/src/main/java/cn/com/qytx/platform/impl/IPlatformParameterServiceImpl.java | 3062dc77229d3f8fbb0875d3c7d33ba027c08ed3 | [] | no_license | anxingg/online-safe-monitor | a7f07edf64c11963afd3a376a6ce77e8cfdcf1d5 | ab340521bc1a18d82657572eed740ba0356d02d9 | refs/heads/master | 2021-01-21T10:55:07.980749 | 2017-04-16T12:59:40 | 2017-04-16T12:59:40 | 83,502,219 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,816 | java | package cn.com.qytx.platform.impl;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.com.qytx.cbb.notify.domain.PlatformParameter;
import cn.com.qytx.platform.base.query.Page;
import cn.com.qytx.platform.base.query.Pageable;
import cn.com.qytx.platform.base.service.impl.BaseServiceImpl;
import cn.com.qytx.platform.dao.PlatformParameterDao;
import cn.com.qytx.platform.service.IPlatformParameterService;
@Transactional
@Service("platformParameter")
public class IPlatformParameterServiceImpl extends BaseServiceImpl<PlatformParameter> implements IPlatformParameterService {
@Resource(name="hotlinePlatformParameterDao")
private PlatformParameterDao parmsDao;
public void setParmsDao(PlatformParameterDao parmsDao) {
this.parmsDao = parmsDao;
}
@Override
public PlatformParameter findById(int vId) {
return parmsDao.findById(vId);
}
@Override
public void deletePlatformParameter(int vId) {
parmsDao.deletePlatformParameter(vId);
}
@Override
public void savePlatformParameter(PlatformParameter pp) {
parmsDao.savePlatformParameter(pp);
}
@Override
public void updatePlatformParameter(PlatformParameter pp) {
parmsDao.updatePlatformParameter(pp);
}
@Override
public Object findByParItems(String parItems) {
return parmsDao.findByParItems(parItems);
}
@Override
public Page<PlatformParameter> findPageByMd(Pageable page,
String moduleName) {
return null;
}
@Override
public List<Object> getAllPar() {
return parmsDao.getAllPar();
}
@Override
public void saveObj(Object obj) {
parmsDao.savePlatformParameter(obj);
}
@Override
public Map<String, Object> getParsMap() {
return null;
}
}
| [
"[email protected]"
] | |
06424889d7697cbbd66dd784800988e08d28b0da | 9dcc88f0ffde3987955be00f51b290ac0e9d3a82 | /src/main/java/com/miaoshaproject/dataobject/ItemDo.java | eaa1739e92bac2065a76f25d78fed5f9ae4bfb2c | [] | no_license | perception952/miaosha | c919f49c6b0a2469fd3b654ff789d0cbf9dad115 | d5566cc115768142432ddf3717cf8defd65e290b | refs/heads/master | 2022-07-11T08:26:38.905839 | 2020-02-26T02:21:05 | 2020-02-26T02:21:05 | 239,403,824 | 0 | 0 | null | 2022-06-21T02:46:13 | 2020-02-10T01:31:18 | JavaScript | UTF-8 | Java | false | false | 1,171 | java | package com.miaoshaproject.dataobject;
public class ItemDo {
private Integer id;
private String title;
private Double price;
private String description;
private Integer sales;
private String imgUrl;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title == null ? null : title.trim();
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description == null ? null : description.trim();
}
public Integer getSales() {
return sales;
}
public void setSales(Integer sales) {
this.sales = sales;
}
public String getImgUrl() {
return imgUrl;
}
public void setImgUrl(String imgUrl) {
this.imgUrl = imgUrl == null ? null : imgUrl.trim();
}
} | [
"[email protected]"
] | |
b87df417190feeb389f1eb2ea29f8dbf42176610 | d642d8f9efb6a266c54b29d3e9c93b5c23371165 | /Software/EstacaoBase/backup/Main.java | ae06e614b82bfa4ad8b39443c5bbda26f51bbdb5 | [] | no_license | telmofriesen/oficinas3-bellator | e246cca972b85e0210571c8e9dc3994bc115ed7e | 9606401cf661183fd485a22949e0526f1ba6532f | refs/heads/master | 2016-09-03T00:31:26.111857 | 2013-07-30T14:29:06 | 2013-07-30T14:29:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,484 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package robo;
import robo.ServerListener;
import robo.ServerConnection;
import com.github.sarxos.webcam.util.ImageUtils;
import comunicacao.Base64new;
import dados.AmostraSensores;
import robo.gerenciamento.EnginesManager;
import robo.gerenciamento.SensorsManager;
import robo.gerenciamento.WebcamManager;
import robo.gerenciamento.old.WebcamManagerNew;
import robo.gerenciamento.old.WebcamManagerNew2;
import events.MyChangeEvent;
import events.MyChangeListener;
import java.awt.Dimension;
import java.awt.image.BufferedImage;
/**
* Classe que contem os objetos principais do servidor (robô).
*
* @version 1
* A versão atual é um simulador básico de robô. Quando a leitura dos sensores é ativada, são enviados continuamente para a estação base alguns valores previamente definidos.
*
* @author Stefan
*/
public class Main extends Thread {
//listener, que escuta novas conexões de clientes (estações base)
private ServerListener listener;
//Amostragem dos sensores
private SensorsManager sensorsManager;
private SensorsInfoListnener sensorsInfoListener;
//Amostragem da webcam
private WebcamManager webcamManager;
private WebcamInfoListener webcamInfoListener;
private EnginesManager enginesManager;
private SerialCommunicator serialCommunicator;
// private WebcamStreamer webcamStreamer;
//Indica se amostras de sensores devem ser enviadas ou não à estação base.
// private boolean send_sensor_info = false;
//Velocidades normalizadas (valor de 1 até -1) das rodas esquerda e direita;
//TODO criar classe com thread para controle dos motores. Remover estas variáveis.
// private float velocidade_roda_direita = 0, velocidade_roda_esquerda = 0;
//Porta de escuta do servidor
private int port = ServerListener.LISTENER_DEFAULT_PORT;
/**
* Inicializa os objetos do Server.
* IMPORTANTE: não esquecer de chamar o método startThreads() para iniciar as threads.
*/
public Main(boolean enable_serial) {
//Inicializa o listener, que escuta novas conexões de clientes (estações base)
listener = new ServerListener(this, ServerListener.LISTENER_DEFAULT_PORT);
sensorsManager = new SensorsManager(1);
sensorsInfoListener = new SensorsInfoListnener();
sensorsManager.addMyChangeListener(sensorsInfoListener);
//[176x144] [320x240] [352x288] [480x400] [640x480] [1024x768]
webcamManager = new WebcamManager(1, new Dimension(320, 240));
// webcamManager = new WebcamManager(new Dimension(640, 480));
webcamInfoListener = new WebcamInfoListener();
webcamManager.addMyChangeListener(webcamInfoListener);
enginesManager = new EnginesManager();
if (enable_serial) {
serialCommunicator = new SerialCommunicator(this);
}
// webcamStreamer = new WebcamStreamer(5050, Webcam.getDefault(), 30, true);
}
@Override
public void run() {
}
/**
* Inicia as threads do servidor.
*/
public void startThreads() {
listener.start();
sensorsManager.start();
// webcamManager.start();
this.start();
}
public synchronized ServerListener getListener() {
return listener;
}
public ServerConnection getMainHost() {
if (listener.getNumServerConnections() < 1) {
return null;
} else {
return listener.getServerConnection(0);
}
}
/**
* Notifica que foi estabelecida uma conexão a um host.
*
* @param ip Ip do host
* @param port Porta da conexão
*/
public void mainHostConnected(String ip, int port) {
//Configura o ip e porta da stream da webcam.
webcamManager.setHost(ip, WebcamManager.WEBCAM_STREAM_DEFAULT_PORT);
}
/**
* Notifica que a conexão com o host principal foi finalizada.
*/
public void mainHostDisconnected() {
sensorsManager.stopSampling();
sensorsManager.setSample_rate(1);
sensorsManager.resetTests();
webcamManager.reset();
}
/**
* Muda a velocidade das rodas esquerda e direita.
* O valor de velocidade é normalizado, ou seja, 1 significa velocidade máxima para frente e -1 velocidade máxima para trás.
*
* @param dir Velocidade normalizada da roda direita.
* @param esq Valocidade normalizada da roda esquerda.
*/
// public synchronized void setVelocidadeRodas(float dir, float esq) {
// this.velocidade_roda_direita = dir;
// this.velocidade_roda_esquerda = esq;
// System.out.printf("[Server] Velocidade rodas: %.2f %.2f\n", dir, esq);
// }
//
// public synchronized float getVelocidade_roda_direita() {
// return velocidade_roda_direita;
// }
//
// public synchronized void setVelocidade_roda_direita(float velocidade_roda_direita) {
// this.velocidade_roda_direita = velocidade_roda_direita;
// }
//
// public synchronized float getVelocidade_roda_esquerda() {
// return velocidade_roda_esquerda;
// }
//
// public synchronized void setVelocidade_roda_esquerda(float velocidade_roda_esquerda) {
// this.velocidade_roda_esquerda = velocidade_roda_esquerda;
// }
public synchronized int getPort() {
return port;
}
public synchronized void setPort(int port) {
this.port = port;
}
public SensorsManager getSensorsSampler() {
return sensorsManager;
}
public WebcamManager getWebcamManager() {
return webcamManager;
}
public EnginesManager getEnginesManager() {
return enginesManager;
}
class SensorsInfoListnener implements MyChangeListener {
private AmostraSensores lastSample;
private boolean lastSamplingStatus = false;
@Override
public void changeEventReceived(MyChangeEvent evt) {
// long currentTime = System.currentTimeMillis();
if (evt.getSource() instanceof SensorsManager) {
SensorsManager s = (SensorsManager) evt.getSource();
boolean samplingStatus = s.isSamplingEnabled();
//Verifica o numero de conexões abertas
if (listener.getNumServerConnections() < 1) {
return;
}
//Envia a última amostra à estação base se houver uma nova.
ServerConnection con = listener.getServerConnection(0);
//Envia o status à estação base se o mesmo mudar.
if (samplingStatus != lastSamplingStatus) {
//Envia o status
con.sendMessageWithPriority(s.getStatusMessage(), false);
synchronized (this) {
lastSamplingStatus = samplingStatus;
}
}
AmostraSensores a = s.getCurrentSample();
//Envia a última amostra à estação base se houver uma nova (e a amostragem estiver ativada).
if (samplingStatus == true && lastSample != a) {
//Monsta a string da mensagem a partir da amostra
String str = String.format("SENSORS SAMPLE %.2f %.2f ", a.getAceleracao(), a.getAceleracaoAngular());
float[] distIR = a.getDistIR();
for (int i = 0; i < distIR.length; i++) {
str += String.format("%.2f ", distIR[i]);
}
str += String.format("%d", a.getTimestamp());
con.sendMessage(str, false);
lastSample = a;
}
}
}
}
class WebcamInfoListener implements MyChangeListener {
BufferedImage lastImage = null;
private boolean lastSamplingStatus = false;
private boolean lastWebcamStatus = false;
private boolean lastStreamStatus = false;
@Override
public void changeEventReceived(MyChangeEvent evt) {
if (evt.getSource() instanceof WebcamManager) {
WebcamManager w = (WebcamManager) evt.getSource();
boolean sampling_enabled = w.isSamplingEnabled();
boolean webcam_status = w.isWebcam_available();
boolean stream_status = w.isStream_open();
//Envia o status à estação base se o mesmo mudar.
if (sampling_enabled != lastSamplingStatus || webcam_status != lastWebcamStatus || lastStreamStatus != stream_status) {
if (listener.getNumServerConnections() < 1) {
return;
}
ServerConnection con = listener.getServerConnection(0);
//Envia o status
con.sendMessageWithPriority(w.getStatusMessage(), true);
synchronized (this) {
lastSamplingStatus = sampling_enabled;
lastWebcamStatus = webcam_status;
lastStreamStatus = stream_status;
}
}
}
}
/**
* Envia uma imagem ao host remoto pelo Sender, obedencendo ao protocolo de comunicação.
*
* @param img
* @deprecated
*/
public void sendImage(BufferedImage img) {
byte[] byteArray = ImageUtils.toByteArray(img, "jpg");
// String base64Image = new BASE64Encoder().encodeBuffer(byteArray);
// String base64Image_new = base64Image.replace('\n', '\0');
String base64Image = Base64new.encode(byteArray);
//Verifica o numero de conexões abertas
if (listener.getNumServerConnections() < 1) {
return;
}
//Envia a última amostra à estação base se houver uma nova.
ServerConnection con = listener.getServerConnection(0);
con.sendMessage("WEBCAM SAMPLE " + base64Image, true);
// System.out.println(base64Image);
}
}
public static void main(String args[]) {
boolean enable_serial = false;
// if (args[0].equals("serial")) {
//enable_serial = true;
// }
Main s = new Main(enable_serial);
s.startThreads();
// s.getWebcamSampler().startSampling();
}
}
| [
"[email protected]"
] | |
7a73c76bd9bcbe81f13017b5847566ccfcee6e0e | c253cefcf0e9b01532974e66295bed88e7bd07c0 | /ExpenseManager/app/src/main/java/ict/com/expensemanager/data/database/dao/PartnerDao.java | 8198b11c606b9f8ec522ef8a705798a6e5c703dd | [] | no_license | huyct3105/ExpenseManager | 60b99715064e9919486b3743b3a0106514f65b29 | 3fa4e4d3cbb14592f1043e7a4240aa23155821d3 | refs/heads/master | 2020-03-28T06:42:45.100370 | 2018-09-07T17:28:12 | 2018-09-07T17:28:12 | 147,854,575 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 615 | java | package ict.com.expensemanager.data.database.dao;
import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import ict.com.expensemanager.data.database.entity.Partner;
/**
* Created by PHAMHOAN on 1/26/2018.
*/
@Dao
public interface PartnerDao {
@Insert(onConflict = OnConflictStrategy.REPLACE)
Long insertPartners(Partner partner);
@Query("SELECT id_partner FROM Partner WHERE partner_name LIKE :partnerName")
int isPartnerAlreadyExists(String partnerName);
}
| [
"="
] | = |
2b6f9d73965eae8b7e2ac7ec4aa09fca129ad17e | 366ea02bb96ae539271c6b16d55bed605a4477af | /src/main/java/com/brewer/model/Usuario.java | 5e82a4bdaa9d90f86736bdf4831c183c18ac923c | [] | no_license | MAGSON-OLIVEIRA/brewer | 0d9ec3aa1f0ce4ef9368750a0de634ecf2a55b88 | b067822f6af324809d856c0530168b4fa72413dc | refs/heads/master | 2020-03-18T15:06:41.062258 | 2018-06-15T20:34:08 | 2018-06-15T20:34:08 | 134,887,670 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,598 | java | package com.brewer.model;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotBlank;
@Entity
@Table(name = "usuario")
public class Usuario {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name="id")
private Long id;
@NotBlank(message = "Nome é obrigatorio")
@Column(name="nome")
private String nome;
@NotBlank(message = "Email é obrigatorio")
@Column(name="email")
private String email;
@Size(min= 1, max = 6, message = "Tamanho entre 1 a 6")
@Column(name="senha")
private String senha;
@ManyToOne
@JoinColumn(name="idTipoUsuario")
private TipoUsuario tipo;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public TipoUsuario getTipo() {
return tipo;
}
public void setTipo(TipoUsuario tipo) {
this.tipo = tipo;
}
}
| [
"[email protected]"
] | |
61bf52c061a39ea0522893fe953d61b26123f5c3 | 55b93ddeb025281f1e5bdfa165cb5074ec622544 | /graphsdk/src/main/java/com/microsoft/graph/extensions/OnenoteSectionCollectionPage.java | be3c0f0020b3f1ada60f208e0dbe476314ffd998 | [
"MIT"
] | permissive | Glennmen/msgraph-sdk-android | 7c13e8367fb6cb7bb9a655860a4c14036601296b | cb774abbaa1abde0c63229a70256b3d97f212a3e | refs/heads/master | 2020-03-30T15:56:29.622277 | 2018-10-03T09:07:00 | 2018-10-03T09:07:00 | 151,386,422 | 1 | 0 | NOASSERTION | 2018-10-03T09:03:00 | 2018-10-03T09:02:59 | null | UTF-8 | Java | false | false | 1,377 | java | // ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
package com.microsoft.graph.extensions;
import com.microsoft.graph.concurrency.*;
import com.microsoft.graph.core.*;
import com.microsoft.graph.extensions.*;
import com.microsoft.graph.http.*;
import com.microsoft.graph.generated.*;
import com.microsoft.graph.options.*;
import com.microsoft.graph.serializer.*;
import java.util.Arrays;
import java.util.EnumSet;
// This file is available for extending, afterwards please submit a pull request.
/**
* The class for the Onenote Section Collection Page.
*/
public class OnenoteSectionCollectionPage extends BaseOnenoteSectionCollectionPage implements IOnenoteSectionCollectionPage {
/**
* A collection page for SectionGroup.
*
* @param response The serialized BaseOnenoteSectionCollectionResponse from the service
* @param builder The request builder for the next collection page
*/
public OnenoteSectionCollectionPage(final BaseOnenoteSectionCollectionResponse response, final IOnenoteSectionCollectionRequestBuilder builder) {
super(response, builder);
}
}
| [
"[email protected]"
] | |
a65f6639aef02d07504cb61c832ba73f23c58a53 | d82acd125fb7d6570e58a522ed1b8f28af11123a | /ui/data/City floor findbugs/model/src/edu/umd/cs/findbugs/ba/npe/IsNullValue.java | 2ccc9c16b9b915fcafadcc4de5ed6f01dcb4a32b | [
"Apache-2.0"
] | permissive | fetteradler/Getaviz | dba3323060d3bca81d2d93a2c1a19444ca406e16 | 9e80d842312f55b798044c069a1ef297e64da86f | refs/heads/master | 2020-03-22T11:34:46.963754 | 2018-08-29T14:19:09 | 2018-08-29T14:19:09 | 139,980,787 | 0 | 0 | Apache-2.0 | 2018-07-06T12:16:17 | 2018-07-06T12:16:17 | null | UTF-8 | Java | false | false | 17,643 | java | /*
* Bytecode Analysis Framework
* Copyright (C) 2003-2005 University of Maryland
*
* This library 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 library 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 library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package edu.umd.cs.findbugs.ba.npe;
import javax.annotation.Nonnull;
import edu.umd.cs.findbugs.SystemProperties;
import edu.umd.cs.findbugs.ba.Debug;
import edu.umd.cs.findbugs.ba.Location;
import edu.umd.cs.findbugs.ba.XField;
import edu.umd.cs.findbugs.ba.XMethod;
import edu.umd.cs.findbugs.ba.XMethodParameter;
/**
* A class to abstractly represent values in stack slots, indicating whether
* thoses values can be null, non-null, null on some incoming path, or unknown.
*
* @author David Hovemeyer
* @see IsNullValueFrame
* @see IsNullValueAnalysis
*/
public class IsNullValue implements IsNullValueAnalysisFeatures, Debug {
private static final boolean DEBUG_EXCEPTION = SystemProperties.getBoolean("inv.debugException");
private static final boolean DEBUG_KABOOM = SystemProperties.getBoolean("inv.debugKaboom");
/** Definitely null. */
private static final int NULL = 0;
/** Definitely null because of a comparison to a known null value. */
private static final int CHECKED_NULL = 1;
/** Definitely not null. */
private static final int NN = 2;
/** Definitely not null because of a comparison to a known null value. */
private static final int CHECKED_NN = 3;
/**
* Definitely not null an NPE would have occurred and we would not be here
* if it were null.
*/
private static final int NO_KABOOM_NN = 4;
/** Null on some simple path (at most one branch) to current location. */
private static final int NSP = 5;
/**
* Unknown value (method param, value read from heap, etc.), assumed not
* null.
*/
private static final int NN_UNKNOWN = 6;
/** Null on some complex path (at least two branches) to current location. */
private static final int NCP2 = 7;
/** Null on some complex path (at least three branches) to current location. */
private static final int NCP3 = 8;
private static final int FLAG_SHIFT = 8;
/** Value was propagated along an exception path. */
private static final int EXCEPTION = 1 << FLAG_SHIFT;
/** Value is (potentially) null because of a parameter passed to the method. */
private static final int PARAM = 2 << FLAG_SHIFT;
/**
* Value is (potentially) null because of a value returned from a called
* method.
*/
private static final int RETURN_VAL = 4 << FLAG_SHIFT;
private static final int FIELD_VAL = 8 << FLAG_SHIFT;
/** Value is (potentially) null because of a value returned from readline. */
private static final int READLINE_VAL = (16 << FLAG_SHIFT) | RETURN_VAL;
private static final int FLAG_MASK = EXCEPTION | PARAM | RETURN_VAL | FIELD_VAL | READLINE_VAL;
private static final int[][] mergeMatrix = {
// NULL, CHECKED_NULL, NN, CHECKED_NN, NO_KABOOM_NN, NSP,
// NN_UNKNOWN, NCP2, NCP3
{ NULL }, // NULL
{ NULL, CHECKED_NULL, }, // CHECKED_NULL
{ NSP, NSP, NN }, // NN
{ NSP, NSP, NN, CHECKED_NN, }, // CHECKED_NN
{ NSP, NSP, NN, NN, NO_KABOOM_NN }, // NO_KABOOM_NN
{ NSP, NSP, NSP, NSP, NSP, NSP }, // NSP
{ NSP, NSP, NN_UNKNOWN, NN_UNKNOWN, NN_UNKNOWN, NSP, NN_UNKNOWN, }, // NN_UNKNOWN
{ NSP, NSP, NCP2, NCP2, NCP2, NSP, NCP2, NCP2, }, // NCP2
{ NSP, NSP, NCP3, NCP3, NCP3, NSP, NCP3, NCP3, NCP3 } // NCP3
};
private static final IsNullValue[][] instanceByFlagsList = createInstanceByFlagList();
private static IsNullValue[][] createInstanceByFlagList() {
final int max = FLAG_MASK >>> FLAG_SHIFT;
IsNullValue[][] result = new IsNullValue[max + 1][];
for (int i = 0; i <= max; ++i) {
final int flags = i << FLAG_SHIFT;
result[i] = new IsNullValue[] { new IsNullValue(NULL | flags), new IsNullValue(CHECKED_NULL | flags),
new IsNullValue(NN | flags), new IsNullValue(CHECKED_NN | flags),
null, // NO_KABOOM_NN values must be allocated dynamically
new IsNullValue(NSP | flags), new IsNullValue(NN_UNKNOWN | flags), new IsNullValue(NCP2 | flags),
new IsNullValue(NCP3 | flags), };
}
return result;
}
// Fields
private final int kind;
private final Location locationOfKaBoom;
private IsNullValue(int kind) {
this.kind = kind;
locationOfKaBoom = null;
if (VERIFY_INTEGRITY)
checkNoKaboomNNLocation();
}
private IsNullValue(int kind, Location ins) {
this.kind = kind;
locationOfKaBoom = ins;
if (VERIFY_INTEGRITY)
checkNoKaboomNNLocation();
}
private void checkNoKaboomNNLocation() {
if (getBaseKind() == NO_KABOOM_NN && locationOfKaBoom == null) {
throw new IllegalStateException("construction of no-KaBoom NN without Location");
}
}
@Override
public boolean equals(Object o) {
if (o == null || this.getClass() != o.getClass())
return false;
IsNullValue other = (IsNullValue) o;
if (kind != other.kind)
return false;
if (locationOfKaBoom == other.locationOfKaBoom)
return true;
if (locationOfKaBoom == null || other.locationOfKaBoom == null)
return false;
return locationOfKaBoom.equals(other.locationOfKaBoom);
}
@Override
public int hashCode() {
int hashCode = kind;
if (locationOfKaBoom != null)
hashCode += locationOfKaBoom.hashCode();
return hashCode;
}
private int getBaseKind() {
return kind & ~FLAG_MASK;
}
private int getFlags() {
return kind & FLAG_MASK;
}
private boolean hasFlag(int flag) {
return (kind & flag) == flag;
}
/**
* Was this value propagated on an exception path?
*/
public boolean isException() {
return hasFlag(EXCEPTION);
}
/**
* Was this value marked as a possibly null return value?
*/
public boolean isReturnValue() {
return hasFlag(RETURN_VAL);
}
public boolean isReadlineValue() {
return hasFlag(READLINE_VAL);
}
public boolean isFieldValue() {
return hasFlag(FIELD_VAL);
}
/**
* Was this value marked as a possibly null parameter?
*/
public boolean isParamValue() {
return (kind & PARAM) != 0;
}
/**
* Is this value known because of an explicit null check?
*/
public boolean isChecked() {
return getBaseKind() == CHECKED_NULL || getBaseKind() == CHECKED_NN;
}
/**
* Is this value known to be non null because a NPE would have occurred
* otherwise?
*/
public boolean wouldHaveBeenAKaboom() {
return getBaseKind() == NO_KABOOM_NN;
}
private IsNullValue toBaseValue() {
return instanceByFlagsList[0][getBaseKind()];
}
/**
* Convert to an exception path value.
*/
public IsNullValue toExceptionValue() {
if (getBaseKind() == NO_KABOOM_NN)
return new IsNullValue(kind | EXCEPTION, locationOfKaBoom);
return instanceByFlagsList[(getFlags() | EXCEPTION) >> FLAG_SHIFT][getBaseKind()];
}
/**
* Convert to a value known because it was returned from a method in a
* method property database.
*
* @param methodInvoked
* TODO
*/
public IsNullValue markInformationAsComingFromReturnValueOfMethod(XMethod methodInvoked) {
int flag = RETURN_VAL;
if (methodInvoked.getName().equals("readLine") && methodInvoked.getSignature().equals("()Ljava/lang/String;"))
flag = READLINE_VAL;
if (getBaseKind() == NO_KABOOM_NN)
return new IsNullValue(kind | flag, locationOfKaBoom);
return instanceByFlagsList[(getFlags() | flag) >> FLAG_SHIFT][getBaseKind()];
}
/**
* Convert to a value known because it was returned from a method in a
* method property database.
*
* @param field
* TODO
*/
public IsNullValue markInformationAsComingFromFieldValue(XField field) {
if (getBaseKind() == NO_KABOOM_NN)
return new IsNullValue(kind | FIELD_VAL, locationOfKaBoom);
return instanceByFlagsList[(getFlags() | FIELD_VAL) >> FLAG_SHIFT][getBaseKind()];
}
/**
* Get the instance representing values that are definitely null.
*/
public static IsNullValue nullValue() {
return instanceByFlagsList[0][NULL];
}
/**
* Get the instance representing a value known to be null because it was
* compared against null value, or because we saw that it was assigned the
* null constant.
*/
public static IsNullValue checkedNullValue() {
return instanceByFlagsList[0][CHECKED_NULL];
}
/**
* Get the instance representing values that are definitely not null.
*/
public static IsNullValue nonNullValue() {
return instanceByFlagsList[0][NN];
}
/**
* Get the instance representing a value known to be non-null because it was
* compared against null value, or because we saw the object creation.
*/
public static IsNullValue checkedNonNullValue() {
return instanceByFlagsList[0][CHECKED_NN];
}
/**
* Get the instance representing a value known to be non-null because a NPE
* would have occurred if it were null.
*/
public static IsNullValue noKaboomNonNullValue(@Nonnull Location ins) {
if (ins == null)
throw new NullPointerException("ins cannot be null");
return new IsNullValue(NO_KABOOM_NN, ins);
}
/**
* Get the instance representing values that are definitely null on some
* simple (no branches) incoming path.
*/
public static IsNullValue nullOnSimplePathValue() {
return instanceByFlagsList[0][NSP];
}
/**
* Get instance representing a parameter marked as MightBeNull
*/
public static IsNullValue parameterMarkedAsMightBeNull(XMethodParameter mp) {
return instanceByFlagsList[PARAM >> FLAG_SHIFT][NSP];
}
/**
* Get non-reporting non-null value. This is what we use for unknown values.
*/
public static IsNullValue nonReportingNotNullValue() {
return instanceByFlagsList[0][NN_UNKNOWN];
}
/**
* Get null on complex path value. This is like null on simple path value,
* but there are at least two branches between the explicit null value and
* the current location. If the conditions are correlated, then the path on
* which the value is null may be infeasible.
*/
public static IsNullValue nullOnComplexPathValue() {
return instanceByFlagsList[0][NCP2];
}
/**
* Like "null on complex path" except that there are at least <em>three</em>
* branches between the explicit null value and the current location.
*/
public static IsNullValue nullOnComplexPathValue3() {
return instanceByFlagsList[0][NCP3];
}
/**
* Get null value resulting from comparison to explicit null.
*/
public static IsNullValue pathSensitiveNullValue() {
return instanceByFlagsList[0][CHECKED_NULL];
}
/**
* Get non-null value resulting from comparison to explicit null.
*/
public static IsNullValue pathSensitiveNonNullValue() {
return instanceByFlagsList[0][CHECKED_NN];
}
/**
* Merge two values.
*/
public static IsNullValue merge(IsNullValue a, IsNullValue b) {
if (a == b)
return a;
if (a.equals(b))
return a;
int aKind = a.kind & 0xff;
int bKind = b.kind & 0xff;
int aFlags = a.getFlags();
int bFlags = b.getFlags();
int combinedFlags = aFlags & bFlags;
if (!(a.isNullOnSomePath() || a.isDefinitelyNull()) && b.isException())
combinedFlags |= EXCEPTION;
else if (!(b.isNullOnSomePath() || b.isDefinitelyNull()) && a.isException())
combinedFlags |= EXCEPTION;
// Left hand value should be >=, since it is used
// as the first dimension of the matrix to index.
if (aKind < bKind) {
int tmp = aKind;
aKind = bKind;
bKind = tmp;
}
assert aKind >= bKind;
int result = mergeMatrix[aKind][bKind];
IsNullValue resultValue = (result == NO_KABOOM_NN) ? noKaboomNonNullValue(a.locationOfKaBoom)
: instanceByFlagsList[combinedFlags >> FLAG_SHIFT][result];
return resultValue;
}
/**
* Is this value definitely null?
*/
public boolean isDefinitelyNull() {
int baseKind = getBaseKind();
return baseKind == NULL || baseKind == CHECKED_NULL;
}
/**
* Is this value null on some path?
*/
public boolean isNullOnSomePath() {
int baseKind = getBaseKind();
if (NCP_EXTRA_BRANCH) {
// Note: NCP_EXTRA_BRANCH is an experimental feature
// to see how many false warnings we get when we allow
// two branches between an explicit null and a
// a dereference.
return baseKind == NSP || baseKind == NCP2;
} else {
return baseKind == NSP;
}
}
/**
* Is this value null on a complicated path?
*/
public boolean isNullOnComplicatedPath() {
int baseKind = getBaseKind();
return baseKind == NN_UNKNOWN || baseKind == NCP2 || baseKind == NCP3;
}
/**
* Is this value null on a complicated path?
*/
public boolean isNullOnComplicatedPath23() {
int baseKind = getBaseKind();
return baseKind == NCP2 || baseKind == NCP3;
}
/**
* Is this value null on a complicated path?
*/
public boolean isNullOnComplicatedPath2() {
int baseKind = getBaseKind();
return baseKind == NCP2;
}
/**
* Return true if this value is either definitely null, or might be null on
* a simple path.
*
* @return true if this value is either definitely null, or might be null on
* a simple path, false otherwise
*/
public boolean mightBeNull() {
return isDefinitelyNull() || isNullOnSomePath();
}
/**
* Is this value definitely not null?
*/
public boolean isDefinitelyNotNull() {
int baseKind = getBaseKind();
return baseKind == NN || baseKind == CHECKED_NN || baseKind == NO_KABOOM_NN;
}
@Override
public String toString() {
String pfx = "";
if (DEBUG_EXCEPTION) {
int flags = getFlags();
if (flags == 0)
pfx = "_";
else {
if ((flags & EXCEPTION) != 0)
pfx += "e";
if ((flags & PARAM) != 0)
pfx += "p";
if ((flags & RETURN_VAL) != 0)
pfx += "r";
if ((flags & FIELD_VAL) != 0)
pfx += "f";
}
}
if (DEBUG_KABOOM && locationOfKaBoom == null) {
pfx += "[?]";
}
switch (getBaseKind()) {
case NULL:
return pfx + "n" + ",";
case CHECKED_NULL:
return pfx + "w" + ",";
case NN:
return pfx + "N" + ",";
case CHECKED_NN:
return pfx + "W" + ",";
case NO_KABOOM_NN:
return pfx + "K" + ",";
case NSP:
return pfx + "s" + ",";
case NN_UNKNOWN:
return pfx + "-" + ",";
case NCP2:
return pfx + "/" + ",";
default:
throw new IllegalStateException("unknown kind of IsNullValue: " + kind);
}
}
public Location getLocationOfKaBoom() {
return locationOfKaBoom;
}
/**
* Control split: move given value down in the lattice if it is a
* conditionally-null value.
*
* @return another value (equal or further down in the lattice)
*/
public IsNullValue downgradeOnControlSplit() {
IsNullValue value = this;
if (NCP_EXTRA_BRANCH) {
// Experimental: track two distinct kinds of "null on complex path"
// values.
if (value.isNullOnSomePath())
value = nullOnComplexPathValue();
else if (value.equals(nullOnComplexPathValue()))
value = nullOnComplexPathValue3();
} else {
// Downgrade "null on simple path" values to
// "null on complex path".
if (value.isNullOnSomePath())
value = nullOnComplexPathValue();
}
return value;
}
}
// vim:ts=4
| [
"[email protected]"
] | |
90b92d38a1c72f9c455ed8a9c6c3524f42011d8f | c4ecca93675f5aa08c106035b32474d22c28b676 | /app/src/main/java/com/yq/yzs/musicdemo21/MyService.java | 1c3cfdceebb9651bb23aeceeda2af8de0c6719e3 | [] | no_license | Yanzhishang/MusicDemo | c4f1649f3fe751527f75e5aa7e331743ca536322 | 7584dd5a0ea163aef9df0da241573d073af7986d | refs/heads/master | 2021-07-10T17:25:51.515587 | 2017-10-09T11:46:00 | 2017-10-09T11:46:00 | 106,276,517 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,301 | java | package com.yq.yzs.musicdemo21;
import android.app.Service;
import android.content.ContentResolver;
import android.content.Intent;
import android.database.Cursor;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;
import android.os.RemoteException;
import android.provider.MediaStore;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Random;
import static com.yq.yzs.musicdemo21.MainActivity.mRecyclerView;
public class MyService extends Service {
private static final String TAG = "/MyService";
//控制播放、暂停的命令
// 命令
public static final int CMD_PLAY = Binder.FIRST_CALL_TRANSACTION + 0;//播放
public static final int CMD_PAUSE = Binder.FIRST_CALL_TRANSACTION + 1;//暂停
public static final int CMD_PREVIOUS = Binder.FIRST_CALL_TRANSACTION + 2;//上一首
public static final int CMD_NEXT = Binder.FIRST_CALL_TRANSACTION + 3;//下一首
public static final int CMD_CIRCULATE = Binder.FIRST_CALL_TRANSACTION + 4;//循环播放
public static final int CMD_RANDOM = Binder.FIRST_CALL_TRANSACTION + 5;//随机播放
public static final int CMD_LIST = Binder.FIRST_CALL_TRANSACTION + 6;//随机播放
public static final int CMD_TOUCh = Binder.FIRST_CALL_TRANSACTION + 7;//
public static final int CMD_DEL = Binder.FIRST_CALL_TRANSACTION + 8;//删除
private ContentResolver resolver;//遍历数据
private Intent mIntent = new Intent("com.yzs.music2");//广播
private IBinder mBinder = new MyBinder();
private ArrayList<String> mListName = new ArrayList();//遍历存放SDCard的音乐的文件名
private ArrayList<Data> mListDatas;//存放歌曲的列表
public static MediaPlayer mMediaPlayer = new MediaPlayer();//音乐播放器
private boolean isSttoped = true;//判断是否播放
private boolean Completion = false;//判断完成播放
public int pos = 9;//播放的是哪一首音乐
private boolean mIsRan = false;//判断是否循环播放
private String musicPath;//播放时的文件路径
//定时器
// Timer timer = new Timer();
private int mDuration;
//构造器
public MyService() {
}
@Override
public void onCreate() {
super.onCreate();
// timer.schedule(timerTask, 1000, 1000);
loadMusicInfo();
//播放完成
mMediaPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mediaPlayer) {
if (Completion) {
if (mIsRan) {
Random random = new Random();
pos = random.nextInt(mListDatas.size());
mIsRan = true;
} else {
pos = (pos + 1) % mListDatas.size();
mIsRan = false;
}
prepareMusic(pos);
if (pos < (mListName.size() - 3)) {
mRecyclerView.scrollToPosition(pos + 3);
}
mRecyclerView.scrollToPosition(pos + 3);
}
}
});
}
@Override
public IBinder onBind(Intent intent) {
return mBinder;
}
//搜索公有目录的音频文件
private void loadMusicInfo() {
// mListName.clear();
// mListDatas.clear();
// 访问系统外部的音频信息
// 使用 MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
resolver = getContentResolver();
// 获取所有歌曲
Cursor cursor = resolver.query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
null, null, null, null);
mListDatas = new ArrayList<>();
while (cursor.moveToNext()) {
// 获取多媒体标题
int index = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
String title = cursor.getString(index);
int index2 = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
String name = cursor.getString(index2);
//时间
int index3 = cursor.getColumnIndex(MediaStore.Audio.Media.DURATION);
int sum = cursor.getInt(index3);
String path = cursor.getString(cursor.getColumnIndexOrThrow(MediaStore.Audio.Media.DATA));//获得歌曲的绝对路径
int tMinute = sum / 1000 / 60;
int tSecond = ((sum) / 1000 - tMinute * 60);
String time = tMinute + ":" + tSecond;
Data data = new Data(false, title, name, time);
mListDatas.add(data);
mListName.add(path);
}
//发送Action为com.example.communication.RECEIVER的广播
Bundle bundle = new Bundle();
bundle.putParcelableArrayList("data", mListDatas);
mIntent.putExtra("list", bundle);
mIntent.putExtra("isUpDate", true);
sendBroadcast(mIntent);
}
int ran;//当前播放的歌曲条目
//播放前的准备
private void prepareMusic(int pos) {
mMediaPlayer.reset();
try {
if (mIsRan) {//如果为true,就是随机播放
Random random = new Random();
pos = random.nextInt(mListDatas.size());
if (pos != ran) {
musicPath = mListName.get(pos);
} else {
pos++;
if (pos <= (mListName.size() - 1)) {
playMusic(musicPath);
}
}
ran = pos;//当前播放的歌曲条目
playMusic(musicPath);
} else {
musicPath = mListName.get(pos);
playMusic(musicPath);
}
if (pos < (mListName.size() - 3)) {
mRecyclerView.scrollToPosition(pos + 3);
}
mRecyclerView.scrollToPosition(pos + 3);
} catch (IOException e) {
e.printStackTrace();
}
}
//播放
private void playMusic(String musicPath) throws IOException {
mMediaPlayer.setDataSource(musicPath);
mMediaPlayer.prepare();
mDuration = mMediaPlayer.getDuration();
mIntent.putExtra("duration", mDuration);
sendBroadcast(mIntent);
mMediaPlayer.start();
mMediaPlayer.setLooping(false);
}
/*
//定时器//用于发送当前的播放的时间== 到主线程跟新UI
public TimerTask timerTask = new TimerTask() {
@Override
public void run() {
int nowTime = mMediaPlayer.getCurrentPosition();
mIntent.putExtra("pos", nowTime);
sendBroadcast(mIntent);
}
};
*/
//测试删除歌曲
public void ddd(String mStr) {
// String mFilePath = SDCardUtils.getSDCardPublicDir(Environment.DIRECTORY_MUSIC) + File.separator + mStr;
//// String mFilePath = SDCardUtils.getSDCardPublicDir(mStr);
// SDCardUtils.removeFileFromSDCard(mStr);
// loadMusicInfo();
// Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
}
//播放歌曲
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
int cmd = intent.getIntExtra("cmd", 0);//命令
switch (cmd) {
case CMD_PLAY://播放
if (isSttoped) {
// 未开始
isSttoped = false;
Completion = true;
prepareMusic(pos);
// }
} else if (mMediaPlayer != null && !mMediaPlayer.isPlaying()) {
// 暂停中
mMediaPlayer.start();
isSttoped = false;
} else if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
isSttoped = false;
}
break;
case CMD_PAUSE://暂停
if (mMediaPlayer != null && mMediaPlayer.isPlaying()) {
mMediaPlayer.pause();
}
break;
case CMD_PREVIOUS://上一首
if (pos > 0) {
pos = (pos - 1) % mListDatas.size();
} else if (pos == 0) {
pos = mListName.size() - 1;
}
Completion = true;
prepareMusic(pos);
break;
case CMD_NEXT://下一首
if (pos < mListName.size() - 1) {
pos = (pos + 1) % mListDatas.size();
} else {
pos = 0;
}
Completion = true;
prepareMusic(pos);
break;
case CMD_LIST://点击播放
isSttoped = false;
Completion = true;
pos = intent.getIntExtra("pos", 0);
prepareMusic(pos);
break;
case CMD_CIRCULATE://循环播放
mIsRan = false;
Completion = true;
break;
case CMD_RANDOM://随机播放
mIsRan = true;
Completion = true;
break;
case CMD_TOUCh://随机播放
int seek = intent.getIntExtra("seekbarPos", 0);
mMediaPlayer.seekTo(seek);
break;
case CMD_DEL://长按删除
// int delPos = intent.getIntExtra("delPos", 0);
// ddd(mListName.get(delPos));
break;
}
return Service.START_STICKY;
}
private class MyBinder extends Binder {
@Override
protected boolean onTransact(int code, Parcel data, Parcel reply, int flags) throws RemoteException {
return super.onTransact(code, data, reply, flags);
}
}
@Override
public void onDestroy() {
super.onDestroy();
if (mMediaPlayer != null) {
mMediaPlayer.release();
mMediaPlayer = null;
}
}
}
| [
"[email protected]"
] | |
e8d5fbd9aa86cc647c39511bae1ad4b5cd67c7a9 | e81cc9dfcacfdfd41bfe68923545ac8a3bf25fc5 | /StreamsExample/src/com/hari/StreamLimitSkipExample.java | 87ace22fe4a17f58fcc610739888afe2cdc0cee4 | [] | no_license | NarahariP/Java8Features | 7fdf02cc911066e82fb93e30ea1449bcf6af88bc | 234506011760635c6c2e8a0808b9018f82cdee18 | refs/heads/master | 2020-09-21T05:49:12.193377 | 2020-03-14T11:07:12 | 2020-03-14T11:07:12 | 224,699,873 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,185 | java | package com.hari;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
/**
* @author Narahari
*
*/
public class StreamLimitSkipExample {
static List<Integer> intergerList = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
/**
* @param intergerList
* @return - it perform the summation of first 5 elements
*/
private static Optional<Integer> limit(List<Integer> intergerList2) {
return intergerList.stream().limit(5).reduce((a, b) -> a + b);
}
/**
* @param intergerList2
* @return - it perform the summation by skipping first 5 elements
*/
private static Optional<Integer> skip(List<Integer> intergerList2) {
return intergerList.stream().skip(5).reduce((a, b) -> a + b);
}
/**
* @param args
*/
public static void main(String[] args) {
final Optional<Integer> limitOptional = limit(intergerList);
if (limitOptional.isPresent()) {
System.out.println("The limit result is:: " + limitOptional.get());
}
final Optional<Integer> skipOptional = skip(intergerList);
if (skipOptional.isPresent()) {
System.out.println("The skip result is:: " + skipOptional.get());
}
}
}
| [
"[email protected]"
] | |
1cea3d22bb36101bc684c5554eb62eac363114ea | fcf690c9117fabfa11fd243dc4cc37e2c9038eb6 | /src/com/googlecode/penguin/devices/MediaRender.java | 7b59eaa49a824c48a3827604ce5ed474a0686886 | [] | no_license | maraya/penguin | 54d9a8e655471f08b650b80761273d8182ac63d2 | b8242f74ce0425d60bed1575df4b407b67b1e92a | refs/heads/master | 2021-01-19T08:31:11.944436 | 2011-02-27T20:19:54 | 2011-02-27T20:19:54 | 32,325,366 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,253 | java | package com.googlecode.penguin.devices;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import javax.swing.ImageIcon;
import org.cybergarage.upnp.Device;
import org.cybergarage.upnp.Icon;
import org.cybergarage.upnp.IconList;
import org.cybergarage.upnp.device.InvalidDescriptionException;
public class MediaRender extends Device {
private URL locationURL;
public MediaRender (String location) throws MalformedURLException, InvalidDescriptionException, IOException {
super(new URL(location).openStream());
this.locationURL = new URL(location);
}
public List<ImageIcon> getImageIconList () throws MalformedURLException {
IconList iconList = getIconList();
List<ImageIcon> imageIconList = new ArrayList<ImageIcon>();
for (int i=0; i<iconList.size(); i++) {
Icon icon = iconList.getIcon(i);
String iconURL = locationURL.getProtocol() +"://"+ locationURL.getAuthority() + icon.getURL();
imageIconList.add(new ImageIcon(new URL(iconURL)));
}
return imageIconList;
}
public String getCompleteHost() {
return locationURL.getProtocol()+"://"+locationURL.getAuthority();
}
}
| [
"marayag@07205126-0114-5dfe-d775-059882da7b07"
] | marayag@07205126-0114-5dfe-d775-059882da7b07 |
d668cdeb0516399bda18ecfa645fddeac83f8bb3 | c60dfd23ce217ebb074bfcaaad220babd65c883e | /APP源码/app/src/main/java/online/letmesleep/iotbasedhome/bean/Robot.java | 2b803fe8eb6a6e0dd3b1db51e4106d7042de3023 | [] | no_license | alemoke/XiaoxinSmartHome | 90555bebaf9df9111973a48db1cdf60ec5f0fe6b | fd5ba180bab969274fd6007b3df4934b8a833ef2 | refs/heads/master | 2022-10-29T19:09:00.406861 | 2019-11-21T03:34:31 | 2019-11-21T03:34:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 406 | java | package online.letmesleep.iotbasedhome.bean;
/**
* Created by Letmesleep on 2018/4/15.
*/
public class Robot {
String key;
String info;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getInfo() {
return info;
}
public void setInfo(String info) {
this.info = info;
}
}
| [
"[email protected]"
] | |
f13aa892da5d4cfbc66c727f9e0c019b8952bb80 | 7cc2fe256e723fb90ae40333882a7330302523e5 | /health_parent/health_pojo/src/main/java/com/dengwang/pojo/Setmeal_CheckGroupExample.java | cccd47d14d1e433a5c270da0c19d8305245acd10 | [] | no_license | wangdeng-dw/repository | 1897f6b9255a88130b1651e90e87b0a3ecc9d0d1 | f5fcb186b4dc9b926055b9ae823897e7357286b6 | refs/heads/master | 2023-04-14T13:35:10.880018 | 2021-04-07T08:12:46 | 2021-04-07T08:12:46 | 346,277,355 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,532 | java | package com.dengwang.pojo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
public class Setmeal_CheckGroupExample implements Serializable {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public Setmeal_CheckGroupExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
public Criteria andSetmeal_idIsNull() {
addCriterion("setmeal_id is null");
return (Criteria) this;
}
public Criteria andSetmeal_idIsNotNull() {
addCriterion("setmeal_id is not null");
return (Criteria) this;
}
public Criteria andSetmeal_idEqualTo(Integer value) {
addCriterion("setmeal_id =", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idNotEqualTo(Integer value) {
addCriterion("setmeal_id <>", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idGreaterThan(Integer value) {
addCriterion("setmeal_id >", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idGreaterThanOrEqualTo(Integer value) {
addCriterion("setmeal_id >=", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idLessThan(Integer value) {
addCriterion("setmeal_id <", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idLessThanOrEqualTo(Integer value) {
addCriterion("setmeal_id <=", value, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idIn(List<Integer> values) {
addCriterion("setmeal_id in", values, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idNotIn(List<Integer> values) {
addCriterion("setmeal_id not in", values, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idBetween(Integer value1, Integer value2) {
addCriterion("setmeal_id between", value1, value2, "setmeal_id");
return (Criteria) this;
}
public Criteria andSetmeal_idNotBetween(Integer value1, Integer value2) {
addCriterion("setmeal_id not between", value1, value2, "setmeal_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idIsNull() {
addCriterion("checkgroup_id is null");
return (Criteria) this;
}
public Criteria andCheckgroup_idIsNotNull() {
addCriterion("checkgroup_id is not null");
return (Criteria) this;
}
public Criteria andCheckgroup_idEqualTo(Integer value) {
addCriterion("checkgroup_id =", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idNotEqualTo(Integer value) {
addCriterion("checkgroup_id <>", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idGreaterThan(Integer value) {
addCriterion("checkgroup_id >", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idGreaterThanOrEqualTo(Integer value) {
addCriterion("checkgroup_id >=", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idLessThan(Integer value) {
addCriterion("checkgroup_id <", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idLessThanOrEqualTo(Integer value) {
addCriterion("checkgroup_id <=", value, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idIn(List<Integer> values) {
addCriterion("checkgroup_id in", values, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idNotIn(List<Integer> values) {
addCriterion("checkgroup_id not in", values, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idBetween(Integer value1, Integer value2) {
addCriterion("checkgroup_id between", value1, value2, "checkgroup_id");
return (Criteria) this;
}
public Criteria andCheckgroup_idNotBetween(Integer value1, Integer value2) {
addCriterion("checkgroup_id not between", value1, value2, "checkgroup_id");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | [
"[email protected]"
] | |
e0a677c3ecc911446559817c68599e89ef594a62 | 441836594b8691f57106347f06ae540f6224c12a | /command/BankApplication/MainNoCommand.java | 357fbe2a6c4fd0c61cedba0220a9abefe70df84d | [] | no_license | yyzh/Lab5-Command | 42b91c26a9bc7c4c11a177ad9d4ea3d80d8542ae | d4905374674678c1f5e6e1d75a1ab31fe8c93d1d | refs/heads/master | 2021-01-11T04:52:38.676075 | 2015-11-14T04:15:32 | 2015-11-14T04:15:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,549 | java | import java.util.Stack;
public class MainNoCommand {
public static void main(String[] args) {
double [] balance = {100.0, 200.0};
double amount;
Account acc[] = new Account[2];
Stack commandStack = new Stack();
for (int i = 0; i < acc.length; i++) {
acc[i] = new Account(i, balance[i]);
}
// execute the commands in order
System.out.println("Execute Comannds Begin");
amount = 30.0;
// deposit command
System.out.println("---Deposit Transaction---");
System.out.println(acc[0]);
System.out.println("Deposit Amount = " + amount);
acc[0].deposit(amount);
System.out.println("After deposit, balance = " + acc[0].getBalance());
System.out.println("----End------");
// save the deposit command in the stack for undo
commandStack.push(new Double(amount));
commandStack.push(acc[0]);
commandStack.push("deposit");
amount = 40.0;
// withdraw command
System.out.println("---Withdraw Transaction---");
System.out.println(acc[1]);
System.out.println("Withdraw Amount = " + amount);
acc[1].withdraw(amount);
System.out.println("After uithdraw, balance = " + acc[1].getBalance());
System.out.println("----End------");
// save the withdraw command in the stack for undo
commandStack.push(new Double(amount));
commandStack.push(acc[1]);
commandStack.push("withdraw");
System.out.println();
System.out.println("Undo Commands Begin");
// undo the commands
while (!commandStack.empty()) {
// get the latest command in the stack
String c = (String) commandStack.pop();
if (c.equals("deposit")) {
Account account = (Account) commandStack.pop();
amount = ((Double) commandStack.pop()).doubleValue();
System.out.println("---Undo Deposit Transaction---");
System.out.println(account);
System.out.println("Deposit Amount = " + amount);
account.withdraw(amount);
System.out.println("After undo deposit, balance = " + account.getBalance());
System.out.println("----End------");
} else if (c.equals("withdraw")) {
Account account = (Account) commandStack.pop();
amount = ((Double) commandStack.pop()).doubleValue();
System.out.println("---Undo Withdraw Transaction---");
System.out.println(account);
System.out.println("Withdraw Amount = " + amount);
account.deposit(amount);
System.out.println("After undo withdraw, balance = " + account.getBalance());
System.out.println("----End------");
}
}
}
} | [
"[email protected]"
] | |
3528667dd714c881214972ebddddf9bcc94d822d | 6bd36e6d1879453097c5287a83f2fe54691574df | /src/main/java/gb/internship/controller/DoctorController.java | 6c7562bb865e2d30a56008511babbea9edc11fbe | [] | no_license | Merch2803/ClinicAutomation | c285d2c511857095a8080b5b7c632045fc3613da | 7abd58323c008e061e4a579563fe29d427670964 | refs/heads/master | 2023-03-28T00:35:00.772597 | 2021-03-30T08:16:59 | 2021-03-30T08:16:59 | 352,960,349 | 0 | 0 | null | 2021-03-30T10:27:11 | 2021-03-30T10:27:10 | null | UTF-8 | Java | false | false | 668 | java | package gb.internship.controller;
import gb.internship.service.DoctorService;
import gb.internship.view.Templatable;
import gb.internship.view.TemplateType;
import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import java.util.Collections;
import java.util.Map;
@Path ("doctors")
public class DoctorController {
@Inject
private DoctorService doctorService;
@Inject
private Templatable templatable;
@GET
public String getDoctors() {
Map<String, Object> variables = Collections.singletonMap("doctors", doctorService.getDoctors());
return templatable.template(TemplateType.DOCTORS, variables);
}
}
| [
"[email protected]"
] | |
a86299259851b6dbadc9bfe306588a94a0c9fc4a | 5e588c0fbf4be7eb7577df1d37d443a442da8b5a | /projects/Tennis/tennis-portal-server/src/main/java/com/rozarltd/module/betfairapi/internal/function/MarketPriceLoader.java | 6221dae01b183812aaa367337c620bc4c41146b4 | [] | no_license | rozky/learning | 28a602d12127998a6876cd51eb2977dc8341c235 | 60bb0c58f26f6acec6ae410046e7e576371d1e4f | refs/heads/master | 2021-01-20T21:00:45.283236 | 2013-09-10T17:30:04 | 2013-09-10T17:30:04 | 2,304,068 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 747 | java | package com.rozarltd.module.betfairapi.internal.function;
import com.googlecode.functionalcollections.Block;
import com.rozarltd.module.betfairapi.domain.market.BetfairMarket;
import com.rozarltd.module.betfairwebsite.service.BetfairWebsiteClient;
import org.springframework.beans.factory.annotation.Autowired;
public class MarketPriceLoader implements Block<BetfairMarket> {
private BetfairWebsiteClient betfairWebsiteService;
@Autowired
public MarketPriceLoader(BetfairWebsiteClient betfairWebsiteService) {
this.betfairWebsiteService = betfairWebsiteService;
}
@Override
public void apply(BetfairMarket market) {
// WebMarket webMarket = betfairWebsiteService.getMarket(market.getMarketId());
}
}
| [
"[email protected]"
] | |
3dc015477ea6f170d8a4159a42a7029f5fe4a6ca | e26f814f695d1d26fb15a7f6f04651b1790f125a | /src/main/java/com/renren/api/service/CommentType.java | 4ac91ba053f3281f9a232c7c1ce130c47989758d | [] | no_license | crackerlover/renren-api2-sdk-java | 70abf8e3651b853f68eff3fbf282f951abe5cfce | 107a353abfbd22fd50d44d7d057f7a83affe3755 | refs/heads/master | 2020-12-29T00:41:42.146879 | 2015-02-05T08:30:44 | 2015-02-05T08:30:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 392 | java | /**
* Autogenerated by renren-api2-generator 2014-04-23 18:03:22
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.renren.api.service;
/**
* 评论的类型。
*/
public enum CommentType {
/*
* 分享
*/
SHARE,
/*
* 相册
*/
ALBUM,
/*
* 日志
*/
BLOG,
/*
* 状态
*/
STATUS,
/*
* 照片
*/
PHOTO;
}
| [
"platform@renren@2013"
] | platform@renren@2013 |
81c87928b11e71d6fa8c6205f2ad10946c2b1fc1 | b18d4da781185dd1b74529d9f15cf9fc0a32443d | /src/main/java/com/wper/controller/MeServlet.java | 3127b3b3a93119a119de1bb15a0821795f15a483 | [] | no_license | wpersmile/TrainingSystem | 862af9d4ba096a4106f990a06fd3c698d4c99f4b | 7eec3a4ecc2515b1d6a7d97e76109a71a0a2f43b | refs/heads/master | 2022-07-06T06:35:01.415273 | 2019-05-25T03:11:17 | 2019-05-25T03:11:17 | 131,416,340 | 0 | 0 | null | 2022-06-20T22:55:11 | 2018-04-28T14:26:48 | Java | UTF-8 | Java | false | false | 1,718 | java | package com.wper.controller;
import com.wper.model.MySubject;
import com.wper.model.User;
import com.wper.service.Impl.MySubServiceImpl;
import com.wper.service.Impl.UserServiceImpl;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;
public class MeServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (req.getSession().getAttribute("user")==null){
resp.sendRedirect("/index.jsp");
}
else {
doPost(req,resp);
}
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//super.doPost(req, resp);
HttpSession session=req.getSession();
//根据session -user 存在phone信息
String phone=(String) session.getAttribute("user");
UserServiceImpl userService=new UserServiceImpl();
List<User> userList=userService.getUser(phone);
req.setAttribute("userList",userList);
MySubServiceImpl mySubService=new MySubServiceImpl();
List<MySubject> mySubjectList=mySubService.getMySubInfo(phone);
req.setAttribute("mySubjectList",mySubjectList);
int subNum=mySubService.getCountSub(phone);
req.setAttribute("subNum",subNum);
req.setAttribute("deleteType",req.getAttribute("deleteType"));
req.getRequestDispatcher("/WEB-INF/jsp/me.jsp").forward(req,resp);
}
}
| [
"[email protected]"
] | |
2fd1abd7122adb23be8eeaf1d8fd8388847e8054 | 53db1a0c07d86937ff09a7706dc499369bbb8c10 | /Hadoop/src/Selenium/WorkingWithEdge.java | e715630e7b86d9755ca686e520529db8a1ea4493 | [] | no_license | austindarren/bookish-chainsaw | 2fa794943b184fdaea4fb25ffe5595dec1de5fb9 | 7483a87d11bade5c9700517acae92ed053607039 | refs/heads/master | 2020-05-05T07:17:29.481833 | 2019-06-24T12:13:38 | 2019-06-24T12:13:38 | 179,819,950 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 978 | java | package Selenium;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.edge.EdgeDriver;
public class WorkingWithEdge {
EdgeDriver driver;
public void invokeBrowser() {
System.setProperty("webdriver.edge.driver", "C:/libs/MicrosoftWebDriver.exe");
driver = new EdgeDriver();
Dimension dim = new Dimension(500, 500);
driver.manage().window().setSize(dim);
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.get("https://qatechhub.com");
}
public void printTitleOfThePage() {
String titleOfThePage = driver.getTitle();
System.out.println("titleOfThePage: " +titleOfThePage);
}
public void navigateCommands() {
driver.navigate().to("https://facebook.com");
driver.navigate().back();
driver.navigate().forward();
driver.navigate().refresh();
}
public void closeWindow() {
//driver.close();
driver.quit();
}
}
| [
"Srikanth@Srikanth-PC"
] | Srikanth@Srikanth-PC |
b1dc11283361e4dfc3ae9860b79602df4e621abc | f606d21572b90b6ff86454a79aee35538a0972d5 | /Serveur-Client/Client/src/profil/Profil.java | e408f17ecd8d32438ba7ac446733606fbf3414a1 | [] | no_license | PDS-MASK/PDS | 48845b6c4586d1a7518117c47eddb383838b6601 | 2dfa41e4affa3ae53ba4f48c4d6f59883d09d8c7 | refs/heads/master | 2018-09-30T19:17:42.561766 | 2018-06-28T22:06:05 | 2018-06-28T22:06:05 | 120,525,342 | 0 | 1 | null | 2018-02-13T17:36:14 | 2018-02-06T21:27:57 | Java | ISO-8859-1 | Java | false | false | 13,935 | java | package profil;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
public class Profil {
private int id_person;
private ArrayList<String> profil;
private ArrayList<String> catégorie;
public Profil(int id) throws SQLException {
this.id_person = id;
this.profil = new ArrayList<String>();
this.catégorie = new ArrayList<String>();
if(id != 0) {
this.Define_profil();
this.Define_categorie();
}
}
public Profil() throws SQLException{
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Profil g = null;
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select id_personne from personne");
while (rset.next()) {
g = new Profil(rset.getInt(1));
}
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("null")
public Object[][] Affiche_Profil() {
Object[][] text = null;
ArrayList<String> tmp_text = new ArrayList<String>();
int index1 = 0;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
Statement stmt2 = conn.createStatement();
Statement stmt3 = conn.createStatement();
ResultSet rset = stmt.executeQuery("select id_personne,nom_personne,prenom_personne from personne");
String text_categorie = "";
String text_profil ="";
String id_personne = null;
while (rset.next()) {
id_personne = rset.getString(1);
tmp_text.add(id_personne);
tmp_text.add(rset.getString(2));
tmp_text.add(rset.getString(3));
System.out.println("ID PERSONNE : " + id_personne);
ResultSet rset_Person = stmt2.executeQuery("select nom_profil from profil_personne, profil where PROFIL_PERSONNE.ID_PROFIL = profil.ID_PROFIL and id_personne ="+id_personne);
while (rset_Person.next()) {
text_profil += " " + rset_Person.getString(1) + "\n";
System.out.println(rset_Person.getString(1));
}
ResultSet rset_Person2 = stmt3.executeQuery("select nom_souscategorie from sous_categorie,categorie_personne where SOUS_CATEGORIE.ID_SOUSCATEGORIE = categorie_personne.ID_SOUSCATEGORIE and categorie_personne.ID_PERSONNE ="+id_personne);
while(rset_Person2.next()) {
System.out.println(rset_Person2.getString(1));
text_categorie += " " + rset_Person2.getString(1) + "\n";
}
tmp_text.add(text_profil);
tmp_text.add(text_categorie);
index1++;
text_profil ="";
text_categorie ="";
}
} catch (Exception e) {
e.printStackTrace();
}
text = new Object[index1+1][5];
int j = 0;
int index = 0;
for(int i=0;i<tmp_text.size();i++){
if(j == 5) {
j=0;
index++;
}
text[index][j] = tmp_text.get(i);
j++;
}
return text;
}
@SuppressWarnings("null")
public Object[][] Affiche_Profil_One(int id) {
Object[][] text = null;
ArrayList<String> tmp_text = new ArrayList<String>();
int index1 = 0;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
Statement stmt2 = conn.createStatement();
Statement stmt3 = conn.createStatement();
ResultSet rset = stmt.executeQuery("select id_personne,nom_personne,prenom_personne from personne where id_personne =" +id);
String text_categorie = "";
String text_profil ="";
String id_personne = null;
while (rset.next()) {
id_personne = rset.getString(1);
tmp_text.add(id_personne);
tmp_text.add(rset.getString(2));
tmp_text.add(rset.getString(3));
System.out.println("ID PERSONNE : " + id_personne);
ResultSet rset_Person = stmt2.executeQuery("select nom_profil from profil_personne, profil where PROFIL_PERSONNE.ID_PROFIL = profil.ID_PROFIL and id_personne ="+id_personne);
while (rset_Person.next()) {
text_profil += " " + rset_Person.getString(1) + "\n";
System.out.println(rset_Person.getString(1));
}
ResultSet rset_Person2 = stmt3.executeQuery("select nom_souscategorie from sous_categorie,categorie_personne where SOUS_CATEGORIE.ID_SOUSCATEGORIE = categorie_personne.ID_SOUSCATEGORIE and categorie_personne.ID_PERSONNE ="+id_personne);
while(rset_Person2.next()) {
System.out.println(rset_Person2.getString(1));
text_categorie += " " + rset_Person2.getString(1) + "\n";
}
tmp_text.add(text_profil);
tmp_text.add(text_categorie);
index1++;
text_profil ="";
text_categorie ="";
}
} catch (Exception e) {
e.printStackTrace();
}
text = new Object[index1+1][5];
int j = 0;
int index = 0;
for(int i=0;i<tmp_text.size();i++){
if(j == 5) {
j=0;
index++;
}
text[index][j] = tmp_text.get(i);
j++;
}
return text;
}
public int get_id() {
System.out.println(this.id_person);
return this.id_person;
}
public void Insert_Data_Profil() throws SQLException {
ArrayList<String> tmp_profil = new ArrayList<String>();
for (int i = 0;i<this.profil.size();i++) {
tmp_profil.add("false");
}
int index = 0 ;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select profil.nom_profil,profil.id_profil from profil,profil_personne where profil.ID_PROFIL = profil_personne.ID_PROFIL and profil_personne.ID_PERSONNE = " + this.id_person);
while (rset.next()) {
if(!(this.profil.contains(rset.getString(1)))) {
stmt.executeQuery("delete from profil_personne where id_personne=" + this.id_person +" and id_profil ='"+rset.getString(2)+"'");
}
else {
tmp_profil.set(index,"true");
}
index++;
}
for(int i=0; i<tmp_profil.size();i++) {
if (tmp_profil.get(i).equals("false")) {
stmt.executeQuery("insert into profil_personne values("+this.id_person+",(Select id_profil from profil where nom_profil='"+this.profil.get(i)+"'))");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void Insert_Data_Categorie() throws SQLException {
ArrayList<String> tmp_categorie = new ArrayList<String>();
for (int i = 0;i<this.catégorie.size();i++) {
tmp_categorie.add("false");
}
int index = 0 ;
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select id_souscategorie from categorie_personne where id_personne =" + this.id_person);
while (rset.next()) {
if(!(this.catégorie.contains(rset.getString(1)))) {
stmt.executeQuery("delete from categorie_personne where id_personne=" + this.id_person +" and id_souscategorie ="+rset.getString(1)+"");
}
else {
tmp_categorie.set(index,"true");
}
index++;
}
for(int i=0; i<tmp_categorie.size();i++) {
if (tmp_categorie.get(i).equals("false")) {
stmt.executeQuery("insert into categorie_personne values("+this.id_person+",'"+this.catégorie.get(i));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void Define_profil() throws SQLException {
//Connection à faire
// Requete sur les achats en particulier d'un profil
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select date_commande from commande where id_personne ="+ this.id_person);
int Nbr_Semaine = 0;
int Nbr_Mois = 0;
int Nbr_Year = 0;
Calendar week = Calendar.getInstance();
Calendar month = Calendar.getInstance();
Calendar year = Calendar.getInstance();
week.add(Calendar.DAY_OF_MONTH,-7);
month.add(Calendar.MONTH,-1);
year.add(Calendar.YEAR, -1);
Date dat_week = week.getTime();
Date dat_month = month.getTime();
Date dat_year = year.getTime();
System.out.println("ANNEE :" + dat_year);
System.out.println("ANNEE :" + dat_month);
System.out.println("ANNEE :" + dat_week);
while (rset.next()) {
if (rset.getDate(1).after(dat_week)) {
System.out.println("Passe à une semaine");
Nbr_Semaine++;
Nbr_Mois++;
Nbr_Year++;
}
if (rset.getDate(1).after(dat_month)) {
System.out.println("Passe au mois");
Nbr_Mois++;
Nbr_Year++;
}
if(rset.getDate(1).before(dat_month) && rset.getDate(1).after(dat_year)) {
Nbr_Year++;
System.out.println("Passe à l'année");
}
}
if(Nbr_Semaine > 6) {
(this.profil).add("Compulsif");
}
else if(Nbr_Mois > 4) {
(this.profil).add("Normal");
}
else if(Nbr_Mois >= 1) {
(this.profil).add("Modere");
}
else if(Nbr_Year > 1) {
(this.profil).add("Absent");
}
else {
(this.profil).add("Disparu");
}
} catch (Exception e) {
e.printStackTrace();
}
for(int i=0;i<this.profil.size();i++) {
System.out.println(this.profil.get(i));
}
this.Profil_Econome();
this.Insert_Data_Profil();
}
public void Define_categorie() throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select count(*),sous_categorie.id_souscategorie from sous_categorie, souscategorie_article, sous_article, commande_sousarticle, commande where date_commande > sysdate - interval '3' MONTH and commande.ID_COMMANDE = commande_sousarticle.ID_COMMANDE and commande_sousarticle.ID_SOUSARTICLE = sous_article.ID_SOUSARTICLE and sous_article.ID_ARTICLE = souscategorie_article.ID_ARTICLE and souscategorie_article.ID_SOUSCATEGORIE = sous_categorie.ID_SOUSCATEGORIE and commande.ID_PERSONNE = "+this.id_person +" group by sous_categorie.id_souscategorie");
while (rset.next()) {
if(rset.getInt(1) >= 3) {
(this.catégorie).add(rset.getString(2));
}
}
} catch (Exception e) {
e.printStackTrace();
}
this.Insert_Data_Categorie();
}
public void Profil_Econome() throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("Driver O.K.");
String url = "jdbc:oracle:thin:@localhost:1521/xe";
String user = "moi";
String passwd = "moi";
Connection conn = DriverManager.getConnection(url, user, passwd);
System.out.println("Connexion effective !");
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select count(*) from commande,commande_sousarticle,reduction where date_commande > sysdate - interval '3' MONTH and commande.id_commande = commande_sousarticle.id_commande and COMMANDE_SOUSARTICLE.ID_SOUSARTICLE = reduction.ID_SOUSARTICLE and commande.DATE_COMMANDE between reduction.DATE_DEBUT_REDUC and reduction.DATE_FIN_REDUC and id_personne = "+this.id_person);
while (rset.next()) {
if(rset.getInt(1) >= 3) {
(this.catégorie).add("Econome");
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
580b745c22dafa03a9f763c2e340b897bc437865 | 48e835e6f176a8ac9ae3ca718e8922891f1e5a18 | /benchmark/training/com/taobao/meta/test/OneProducerOneConsumerWithFilterTest.java | 0f4dfa14f27d987569f6547993ef291f3e19770e | [] | no_license | STAMP-project/dspot-experiments | f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5 | 121487e65cdce6988081b67f21bbc6731354a47f | refs/heads/master | 2023-02-07T14:40:12.919811 | 2019-11-06T07:17:09 | 2019-11-06T07:17:09 | 75,710,758 | 14 | 19 | null | 2023-01-26T23:57:41 | 2016-12-06T08:27:42 | null | UTF-8 | Java | false | false | 2,195 | java | package com.taobao.meta.test;
import com.taobao.metamorphosis.Message;
import com.taobao.metamorphosis.client.consumer.MessageListener;
import com.taobao.metamorphosis.exception.MetaClientException;
import java.util.concurrent.Executor;
import org.junit.Assert;
import org.junit.Test;
/**
* meta???????_OneProducerOneConsumer
*
* @author gongyangyu([email protected])
*/
public class OneProducerOneConsumerWithFilterTest extends BaseMetaTest {
private final String topic = "filter-test";
@Test
public void sendConsume() throws Exception {
this.createProducer();
this.producer.publish(this.topic);
// ????????????????
this.createConsumer("group1");
try {
// ???????
final int count = 1000;
this.sendMessage(count, "hello", this.topic);
// ??????????
try {
this.consumer.subscribe(this.topic, (1024 * 1024), new MessageListener() {
public void recieveMessages(final Message messages) {
OneProducerOneConsumerWithFilterTest.this.queue.add(messages);
}
public Executor getExecutor() {
return null;
}
}).completeSubscribe();
} catch (final MetaClientException e) {
throw e;
}
while ((this.queue.size()) < (count / 2)) {
Thread.sleep(1000);
System.out.println((((("??????????" + (count / 2)) + "???????????") + (this.queue.size())) + "??"));
}
// ??????????????????????
Assert.assertEquals((count / 2), this.queue.size());
int i = 0;
if (count != 0) {
for (final Message msg : this.messages) {
if (((++i) % 2) == 0) {
Assert.assertTrue(this.queue.contains(msg));
}
}
}
this.log.info(("received message count:" + (this.queue.size())));
} finally {
this.producer.shutdown();
this.consumer.shutdown();
}
}
}
| [
"[email protected]"
] | |
45f410f2d16dcd395ba2b8af76ba6d0eeb748a18 | cde61da202453792561b2fe08062a4b2ad4a502d | /core-web/src/main/java/com/halflife/MainApplication.java | 75f23287b9f82a004bfc245fecd3220d72764a5f | [
"Apache-2.0"
] | permissive | yangdaodao92/half-life | 5709c07a1c7b87c944f3a5c1ffe890dc794a70b9 | 9dd04fe06362f685cb05546458fe74c5d126984b | refs/heads/master | 2021-05-07T21:00:25.652430 | 2017-11-11T14:25:04 | 2017-11-11T14:25:04 | 108,952,361 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 326 | java | package com.halflife;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @author yangnx
*/
@SpringBootApplication
public class MainApplication {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
}
| [
"[email protected]"
] | |
1bbec95505924c0ab0c1a70abdb1c8ffb05f949c | 01733a08d922bdb32abd928c3a54eee35f77eca0 | /mall-sms/src/main/java/com/wubaba/mall/sms/entity/SmsHomeSubjectSpuEntity.java | 4008226c5238309176139ab7a0c343c47d97ef51 | [] | no_license | wujuxuan/wubaba-mall | 2509d5a50d9cd93b52e522e7bbe92b5c6fe46f1f | 4347bb0d7522a46040ef79f29d6598cc4b664be0 | refs/heads/master | 2023-05-11T02:23:49.101888 | 2021-06-03T09:18:43 | 2021-06-03T09:18:43 | 373,347,454 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 709 | java | package com.wubaba.mall.sms.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 专题商品
*
* @author wujuxuan
* @email [email protected]
* @date 2021-06-02 10:01:50
*/
@Data
@TableName("sms_home_subject_spu")
public class SmsHomeSubjectSpuEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
private Long id;
/**
* 专题名字
*/
private String name;
/**
* 专题id
*/
private Long subjectId;
/**
* spu_id
*/
private Long spuId;
/**
* 排序
*/
private Integer sort;
}
| [
"[email protected]"
] | |
2a71b0c9b468d32db40dd53c99c4678557d1f8fc | c0163d6924d50810d341fe03649acd647a463839 | /custom-annotation/src/main/java/com/java/examples/repeatable/Shirt.java | 2f1b9c099f2665127f245bc5ebed8cb44e405ae0 | [] | no_license | legend59/tutorials-java | 2156d165041d042e23c7106c7ce46ad17e378bc8 | 783bdf228142fe1a0dc7c06b0d0d20d3101dead5 | refs/heads/master | 2023-06-26T18:28:46.801212 | 2021-07-25T01:47:38 | 2021-07-25T01:47:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 128 | java | package com.java.examples.repeatable;
@Color(name = "red")
@Color(name = "blue")
@Color(name = "green")
public class Shirt {
}
| [
"[email protected]"
] | |
17307934be24ec67c2586cb00c628154abffc1a5 | dd9267473292a3b6eb3eb97b9846d7df9768e0cc | /app/src/main/java/com/snagtag/fragment/ClosetFragment.java | b1b3fda7e8cf5202a386a7aec2e28d0748e1078a | [] | no_license | guezandy/android_snagtag | a10535e0c23a6a62e2e89f2a739991c3a5cedd79 | 5388aad6a97fff94517a6a7cd1502911b7fede71 | refs/heads/master | 2020-12-25T20:30:34.664017 | 2015-05-29T14:32:01 | 2015-05-29T14:32:01 | 24,120,225 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,708 | java | package com.snagtag.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.TextView;
import com.parse.ParseImageView;
import com.snagtag.R;
import com.snagtag.models.TagHistoryItem;
import com.snagtag.service.IParseCallback;
import com.snagtag.service.ParseService;
import java.text.NumberFormat;
import java.util.Collections;
import java.util.List;
/**
* Shows items already purchased.
*
* Created by benjamin on 10/7/14.
*/
public class ClosetFragment extends Fragment {
private View mView;
private View mItemDetailPopup;
ViewPager mTopsView;
private TextView mItemDescription;
private TextView mItemColor;
private TextView mItemSize;
private TextView mItemCost;
private TextView mItemHistory;
private ParseImageView mItemDetailImage;
private View mButtonReorder;
private View mHeaderFilter;
private View mFilterOpenIndicator;
private View mFilterOptions;
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_closet, container, false);
mItemDetailPopup = mView.findViewById(R.id.item_detail_popup);
mTopsView = (ViewPager) mView.findViewById(R.id.scroll_tops);
ViewPager bottomsView = (ViewPager) mView.findViewById(R.id.scroll_bottoms);
ViewPager shoesView = (ViewPager) mView.findViewById(R.id.scroll_shoes);
mTopsView.setAdapter(new TagHistoryItemPagerAdapter(TagHistoryItemPagerAdapter.TOPS));
bottomsView.setAdapter(new TagHistoryItemPagerAdapter((TagHistoryItemPagerAdapter.BOTTOMS)));
shoesView.setAdapter(new TagHistoryItemPagerAdapter((TagHistoryItemPagerAdapter.SHOES)));
mItemDescription = (TextView)mView.findViewById(R.id.item_description);
mItemColor = (TextView)mView.findViewById(R.id.item_color);
mItemSize = (TextView)mView.findViewById(R.id.item_size);
mItemCost = (TextView)mView.findViewById(R.id.item_cost);
mItemHistory = (TextView)mView.findViewById(R.id.item_history);
mItemDetailImage = (ParseImageView)mView.findViewById(R.id.item_image);
mButtonReorder = mView.findViewById(R.id.button_reorder);
mHeaderFilter = mView.findViewById(R.id.header_filter);
mFilterOpenIndicator = mView.findViewById(R.id.filter_open_indicator);
mFilterOptions = mView.findViewById(R.id.filter_options);
setClickListeners();
return mView;
}
private void setClickListeners() {
mItemDetailPopup.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mItemDetailPopup.setVisibility(View.GONE);
}
});
mButtonReorder.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//TODO: Go to order screen?
}
});
mHeaderFilter.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if(mFilterOptions.getVisibility()==View.GONE) {
Animation animation = AnimationUtils.loadAnimation(ClosetFragment.this.getActivity(), R.anim.in_from_bottom);
mFilterOptions.setVisibility(View.VISIBLE);
mHeaderFilter.startAnimation(animation);
mFilterOpenIndicator.setRotation(0);
} else {
Animation animation = AnimationUtils.loadAnimation(ClosetFragment.this.getActivity(), R.anim.out_to_bottom);
animation.setAnimationListener(new Animation.AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
mFilterOptions.setVisibility(View.GONE);
mFilterOpenIndicator.setRotation(180);
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mHeaderFilter.startAnimation(animation);
}
}
});
}
private void showDetail(TagHistoryItem selectedItem) {
mItemDetailPopup.setVisibility(View.VISIBLE);
mItemHistory.setText("history not in object");
mItemColor.setText("color not in object");
NumberFormat format = NumberFormat.getCurrencyInstance();
mItemCost.setText(format.format(selectedItem.getPrice()));
mItemDescription.setText(selectedItem.getDescription());
mItemSize.setText("size not in object");
mItemDetailImage.setParseFile(selectedItem.getImage());
mItemDetailImage.loadInBackground();
}
/**
* PagerAdapter to show the outfits in my closet. I don't know if there is a ParsePagerAdapter, so I'm making one here.
* I am creating a method in the service to 'get' the TagHistoryItems. This is the pattern I would prefer to use for ListAdapters as well.
*/
class TagHistoryItemPagerAdapter extends PagerAdapter implements IParseCallback<List<TagHistoryItem>>{
static final int TOPS = 0;
static final int BOTTOMS = 1;
static final int SHOES = 2;
TagHistoryItemPagerAdapter(int itemType) {
switch (itemType) {
case TOPS:
new ParseService(getActivity().getApplicationContext()).getClosetTops(getActivity().getApplicationContext(), this);
break;
case BOTTOMS:
new ParseService(getActivity().getApplicationContext()).getClosetBottoms(getActivity().getApplicationContext(), this);
break;
case SHOES:
new ParseService(getActivity().getApplicationContext()).getClosetShoes(getActivity().getApplicationContext(), this);
break;
}
}
// As per docs, you may use views as key objects directly
// if they aren't too complex
private List<TagHistoryItem> mItems = Collections.emptyList();
@Override
public void onSuccess(List<TagHistoryItem> items) {
mItems = items;
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
mTopsView.invalidate();
TagHistoryItemPagerAdapter.this.notifyDataSetChanged();
}
});
}
@Override
public void onFail(String message) {
}
@Override
public Object instantiateItem(ViewGroup container, final int position) {
LayoutInflater inflater = LayoutInflater.from(getActivity().getApplicationContext());
View view = inflater.inflate(R.layout.row_item_closet_view, null);
final TagHistoryItem selectedItem = mItems.get(position);
((ParseImageView)view.findViewById(R.id.item_image)).setParseFile(selectedItem.getImage());
((ParseImageView)view.findViewById(R.id.item_image)).loadInBackground();
selectedItem.setDescription("Test item " + position);
view.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
showDetail(selectedItem);
}
});
container.addView(view);
return view;
}
@Override
public void destroyItem(ViewGroup container, int position, Object object) {
container.removeView((View) object);
}
@Override
public int getCount() {
return mItems.size();
}
@Override
public boolean isViewFromObject(View view, Object object) {
return view == object;
}
// Important: page takes all available width by default,
// so let's override this method to fit 5 pages within single screen
@Override
public float getPageWidth(int position) {
return 0.33f;
}
}
}
| [
"[email protected]"
] | |
b36882072f41b2e63d4f0d7223b6e1e650d939fe | 961c6dc0cedca3870b93ef0d68531a3c4432be5d | /app/src/main/java/com/kooloco/util/Util.java | e9168b5853510008ae770598d47d63d008945048 | [] | no_license | softwrengr/Kolocco | 53f061f3be0c3e4dc46bb0b318540fe7b113f092 | 2c54e9d1a9ddca849c9bfe5f2b1c751b4e42fe80 | refs/heads/master | 2020-04-07T12:16:27.008968 | 2018-11-28T14:49:34 | 2018-11-28T14:49:34 | 158,360,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,971 | java | /*
* Copyright 2015 Amazon.com, Inc. or its affiliates. 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.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file 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.kooloco.util;
import android.content.Context;
import android.net.Uri;
import com.amazonaws.auth.AWSCredentials;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferObserver;
import com.amazonaws.mobileconnectors.s3.transferutility.TransferUtility;
import com.amazonaws.regions.Region;
import com.amazonaws.regions.Regions;
import com.amazonaws.services.s3.AmazonS3Client;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
import java.util.UUID;
/*
* Handles basic helper functions used throughout the app.
*/
public class Util {
// We only need one instance of the clients and credentials provider
private static AmazonS3Client sS3Client;
// private static CognitoCachingCredentialsProvider sCredProvider;
private static TransferUtility sTransferUtility;
private static AWSCredentials awsCredentials;
public static final String IMAGE_PATH = "https://s3-eu-west-1.amazonaws.com/";
public static final String MY_BUCKET = "hlink-bucket/kooloco/";
public static final String BUCKET_PROFILE_IMAGE = MY_BUCKET + "profile_image";
public static final String BUCKET_ORGANIZATION = MY_BUCKET + "organisation";
public static final String BUCKET_BLOG = MY_BUCKET + "blog_media";
public static final String BUCKET_LOCAL_ACHIVEMENT = MY_BUCKET + "local/achievement";
public static final String BUCKET_LOCAL_CERTIFICATES = MY_BUCKET + "local/certificate";
public static final String BUCKET_LOCAL_SPORT_IMAGES = MY_BUCKET + "local/sports";
public static final String BUCKET_LOCAL_EXP_IMAGES = MY_BUCKET + "local/experience/images";
public static final String BUCKET_LOCAL_EXP_OTHER_FIELDS_IMAGES = MY_BUCKET + "local/experience/otherImages";
/* *//**
* Gets an instance of CognitoCachingCredentialsProvider which is
* constructed using the given Context.
*
* @param context An Context instance.
* @return A default credential provider.
*//*
private static CognitoCachingCredentialsProvider getCredProvider(Context context) {
if (sCredProvider == null) {
sCredProvider = new CognitoCachingCredentialsProvider(
context.getApplicationContext(),
Constants.COGNITO_POOL_ID,
Regions.fromName(Constants.COGNITO_POOL_REGION));
}
return sCredProvider;
}
*/
/**
* Gets an instance of a S3 client which is constructed using the given
* Context.
*
* @param context An Context instance.
* @return A default S3 client.
*/
public static AmazonS3Client getS3Client(Context context) {
if (sS3Client == null) {
awsCredentials = new AWSCredentials() {
@Override
public String getAWSAccessKeyId() {
return "AKIAIQQ2ISB7GLYH57JA";
}
@Override
public String getAWSSecretKey() {
return "NSlnDRphsHCcPVdDyZmhxfEu2QbkbJ7v98kGFymL ";
}
};
sS3Client = new AmazonS3Client(awsCredentials);
sS3Client.setRegion(Region.getRegion(Regions.EU_WEST_1));
/*transferUtility = new TransferUtility(s3, context);
sS3Client = new AmazonS3Client(getCredProvider(context.getApplicationContext()));
sS3Client.setRegion(Region.getRegion(Regions.fromName(Constants.BUCKET_REGION)));*/
}
return sS3Client;
}
/**
* Gets an instance of the TransferUtility which is constructed using the
* given Context
*
* @param context
* @return a TransferUtility instance
*/
public static TransferUtility getTransferUtility(Context context) {
if (sTransferUtility == null) {
sTransferUtility = new TransferUtility(getS3Client(context.getApplicationContext()),
context.getApplicationContext());
}
return sTransferUtility;
}
/**
* Converts number of bytes into proper scale.
*
* @param bytes number of bytes to be converted.
* @return A string that represents the bytes in a proper scale.
*/
public static String getBytesString(long bytes) {
String[] quantifiers = new String[]{
"KB", "MB", "GB", "TB"
};
double speedNum = bytes;
for (int i = 0; ; i++) {
if (i >= quantifiers.length) {
return "";
}
speedNum /= 1024;
if (speedNum < 512) {
return String.format("%.2f", speedNum) + " " + quantifiers[i];
}
}
}
/**
* Copies the data from the passed in Uri, to a new file for use with the
* Transfer Service
*
* @param context
* @param uri
* @return
* @throws IOException
*/
public static File copyContentUriToFile(Context context, Uri uri) throws IOException {
InputStream is = context.getContentResolver().openInputStream(uri);
File copiedData = new File(context.getDir("SampleImagesDir", Context.MODE_PRIVATE), UUID
.randomUUID().toString());
copiedData.createNewFile();
FileOutputStream fos = new FileOutputStream(copiedData);
byte[] buf = new byte[2046];
int read = -1;
while ((read = is.read(buf)) != -1) {
fos.write(buf, 0, read);
}
fos.flush();
fos.close();
return copiedData;
}
/*
* Fills in the map with information in the observer so that it can be used
* with a SimpleAdapter to populate the UI
*/
public static void fillMap(Map<String, Object> map, TransferObserver observer, boolean isChecked) {
int progress = (int) ((double) observer.getBytesTransferred() * 100 / observer
.getBytesTotal());
map.put("id", observer.getId());
map.put("checked", isChecked);
map.put("fileName", observer.getAbsoluteFilePath());
map.put("progress", progress);
map.put("bytes",
getBytesString(observer.getBytesTransferred()) + "/"
+ getBytesString(observer.getBytesTotal()));
map.put("state", observer.getState());
map.put("percentage", progress + "%");
}
}
| [
"[email protected]"
] | |
d00aff5342ad67d05ddcc359c61eaa74c2524d49 | d654590ad9962cf5a039ed9da7ae892edb01bd2e | /test-spark/src/main/java/fr/an/tests/testspark/SparkAppMain.java | b1f90603f46a60b93f1116ecc522ded7d68a1afb | [] | no_license | Arnaud-Nauwynck/test-snippets | d3a314f61bddaeb6e6a5ed3fafd1932c72637f1d | a088bc1252bc677fbc70ee630da15b0a625d4a46 | refs/heads/master | 2023-07-19T15:04:38.067591 | 2023-07-09T14:55:50 | 2023-07-09T14:55:50 | 6,697,535 | 9 | 19 | null | 2023-03-02T00:25:17 | 2012-11-15T00:52:21 | JavaScript | UTF-8 | Java | false | false | 6,888 | java | package fr.an.tests.testspark;
import java.util.List;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.spark.SparkConf;
import org.apache.spark.SparkContext;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.sql.SaveMode;
import org.apache.spark.sql.SparkSession;
import fr.an.tests.testspark.util.LsUtils;
import lombok.extern.slf4j.Slf4j;
import scala.collection.Seq;
@Slf4j
public class SparkAppMain {
private String appName = "SparkApp";
private String master = "local[*]";
private String baseDir = "D:/arn/hadoop/rootfs";
private String baseInputDir = "/inputDir1";
private String baseOutputDir = "/outputDir1";
// private String baseInputDir = "/inputDir2";
// private String baseOutputDir = "/outputDir2";
// private String baseInputDir = "/inputDir3";
// private String baseOutputDir = "/outputDir3";
private int numPartitions = 2;
private boolean skipWriteChecksumFiles = true;
SparkSession spark;
SparkContext sc; // = spark.sparkContext();
JavaSparkContext jsc; // = JavaSparkContext.fromSparkContext(sc);
Configuration hadoopConf; // = jsc.hadoopConfiguration();
FileSystem hadoopFs; // = FileSystem.get(hadoopConf);
public static void main(String[] args) {
SparkAppMain app = new SparkAppMain();
try {
app.run();
System.out.println("Finished");
} catch(Exception ex) {
System.err.println("Failed, exiting");
ex.printStackTrace(System.err);
}
}
private void run() throws Exception {
SparkConf sparkConf = new SparkConf()
.setAppName(appName)
.setMaster(master)
;
this.spark = SparkSession.builder()
.config(sparkConf)
.getOrCreate();
try {
this.sc = spark.sparkContext();
this.jsc = JavaSparkContext.fromSparkContext(sc);
this.hadoopConf = jsc.hadoopConfiguration();
this.hadoopFs = FileSystem.get(hadoopConf);
// do not generate the "_SUCCESS" files..
this.hadoopConf.set("mapreduce.fileoutputcommitter.marksuccessfuljobs", "false");
// do not generate the ".crc" files.. (only on LocalFileSystem??)
if (skipWriteChecksumFiles) {
// hadoopFs.setVerifyChecksum(false); ... when disabled ... Failed!!
hadoopFs.setWriteChecksum(false);
}
checkDirThenRecursiveConcatFilesForDir(spark);
} finally {
spark.stop();
}
}
// --------------------------------------------------------------------------------------------
private void checkDirThenRecursiveConcatFilesForDir(SparkSession spark) throws Exception {
Path inputPath = new Path(baseDir + "/" + baseInputDir);
Path outputPath = new Path(baseDir + "/" + baseOutputDir);
FileStatus inputDirFileStatus = hadoopFs.getFileStatus(inputPath); // FileNotFoundException if not exist
if (! inputDirFileStatus.isDirectory()) {
log.error("inputDir '" + baseInputDir + "' is not a directory");
}
FileStatus outputDirFileStatus = hadoopFs.getFileStatus(outputPath); // FileNotFoundException if not exist
if (! outputDirFileStatus.isDirectory()) {
log.error("outputDir '" + baseOutputDir + "' is not a directory");
}
recursiveConcatFilesForDir(inputPath, outputPath);
}
private void recursiveConcatFilesForDir(Path inputDirPath, Path outputDirPath) throws Exception {
FileStatus[] childLs = hadoopFs.listStatus(inputDirPath);
List<FileStatus> childDirs = LsUtils.filter(childLs, f -> f.isDirectory());
List<FileStatus> childFiles = LsUtils.filter(childLs, f -> f.isFile() && !f.getPath().getName().startsWith("."));
if (childDirs != null && !childDirs.isEmpty()) {
for(FileStatus childDir: childDirs) {
log.info("recurse sub dir:" + childDir);
Path inputChildPath = childDir.getPath();
String childName = inputChildPath.getName();
Path outputChildPath = new Path(outputDirPath, childName);
if(!hadoopFs.exists(outputChildPath)) {
hadoopFs.mkdirs(outputChildPath);
}
// *** recurse ***
recursiveConcatFilesForDir(inputChildPath, outputChildPath);
}
}
if (childFiles != null && !childFiles.isEmpty()) {
log.info("detected " + childFiles.size() + " files in dir");
// concat all parquet files
{ List<FileStatus> parquetChildFiles = LsUtils.filter(childFiles, f -> f.getPath().getName().endsWith(".parquet"));
if (! parquetChildFiles.isEmpty()) {
log.info("detected " + parquetChildFiles.size() + " parquet files in dir: " + parquetChildFiles);
List<Path> inputParquetPaths = LsUtils.map(parquetChildFiles, f -> f.getPath());
concatFiles(inputParquetPaths, outputDirPath, "parquet", "parquet");
boolean debugForCompareTest = false;
if (debugForCompareTest) {
Path outputOrcDirPath = new Path(outputDirPath.getParent(), outputDirPath.getName() +"-orc");
concatFiles(inputParquetPaths, outputOrcDirPath, "parquet", "orc");
}
}
}
// concat all orc files
{ List<FileStatus> orcChildFiles = LsUtils.filter(childFiles, f -> f.getPath().getName().endsWith(".orc"));
if (! orcChildFiles.isEmpty()) {
log.info("detected " + orcChildFiles.size() + " orc files in dir: " + orcChildFiles);
List<Path> inputOrcPaths = LsUtils.map(orcChildFiles, f -> f.getPath());
concatFiles(inputOrcPaths, outputDirPath, "orc", "orc");
boolean debugForCompareTest = false;
if (debugForCompareTest) {
Path outputParquetDirPath = new Path(outputDirPath.getParent(), outputDirPath.getName() +"-parquet");
concatFiles(inputOrcPaths, outputParquetDirPath, "orc", "parquet");
}
}
}
}
}
private void concatFiles(List<Path> inputPaths,
Path outputParentDirPath,
String inputFormat, String outputFormat
) {
List<String> inputPathUris = LsUtils.map(inputPaths, f -> f.toUri().toString());
Seq<String> scalaInputPaths = LsUtils.toScalaList(inputPathUris);
String outputDir = outputParentDirPath.toUri().toString();
log.info("spark write " + outputFormat + " to dir: '" + outputDir + "' "
+ "coalesce " + numPartitions
+ " from " + inputFormat + " files: " + inputPathUris);
long startTime = System.currentTimeMillis();
spark.read()
.option("mergeSchema", true) // useless if all file have same schema..
.format(inputFormat)
.load(scalaInputPaths)
.coalesce(numPartitions)
.write()
// .option("spark.sql.parquet.compression.codec", "snappy") // default
.mode(SaveMode.Overwrite)
.format(outputFormat)
.save(outputDir);
long millis = System.currentTimeMillis() - startTime;
log.info(".. done write " + outputFormat + " to dir: '" + outputDir + "' .. took " + millis + " ms");
}
}
| [
"[email protected]"
] | |
3f2615c11905fc6fda1c1d97bcb95e00f99a9428 | ca60b73c198bc80e9ab2621915b4725545a601a4 | /net.solarnetwork.node.datum.samplefilter/src/net/solarnetwork/node/datum/samplefilter/SamplesTransformerSupport.java | 1ae538fbb7a9e1e0309304b8b9d6f052f0641092 | [] | no_license | kblincoe/solarnetwork-node_SE701 | c35c141073dc97a6839224cc0bdfd7e804962dc4 | 55fb9facbcbaa70f1f03c2068771cd2047fd20f2 | refs/heads/master | 2021-04-28T15:56:25.611546 | 2018-03-27T09:30:22 | 2018-03-27T09:30:22 | 122,001,168 | 0 | 4 | null | 2018-04-03T07:36:56 | 2018-02-18T23:41:54 | Java | UTF-8 | Java | false | false | 12,564 | java | /* ==================================================================
* SamplesTransformerSupport.java - 8/08/2017 3:22:32 PM
*
* Copyright 2017 SolarNetwork.net Dev Team
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307 USA
* ==================================================================
*/
package net.solarnetwork.node.datum.samplefilter;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.MessageSource;
import net.solarnetwork.domain.GeneralDatumSamples;
import net.solarnetwork.node.dao.SettingDao;
import net.solarnetwork.node.domain.Datum;
import net.solarnetwork.node.support.KeyValuePair;
/**
* Support class for sample transformers.
*
* @author matt
* @version 1.0
*/
public class SamplesTransformerSupport {
/** The default value for the {@code settingCacheSecs} property. */
public static final int DEFAULT_SETTING_CACHE_SECS = 15;
/**
* A setting key template, takes a single string parameter (the datum source
* ID).
*/
public static final String SETTING_KEY_TEMPLATE = "%s/valueCaptured";
/**
* The default value for the UID property.
*/
public static final String DEFAULT_UID = "Default";
/**
* A global cache for helping with transformers that require persistence.
*/
protected static final ConcurrentMap<String, ConcurrentMap<String, String>> SETTING_CACHE = new ConcurrentHashMap<String, ConcurrentMap<String, String>>(
4);
private String uid;
private String groupUID;
private Pattern sourceId;
private SettingDao settingDao;
private MessageSource messageSource;
private int settingCacheSecs;
private final AtomicLong settingCacheExpiry = new AtomicLong(0);
/** A class-level logger. */
protected final Logger log = LoggerFactory.getLogger(getClass());
/**
* Clear the internal setting cache.
*/
public static void clearSettingCache() {
SETTING_CACHE.clear();
}
public SamplesTransformerSupport() {
super();
setUid(DEFAULT_UID);
setSettingCacheSecs(DEFAULT_SETTING_CACHE_SECS);
}
/**
* Get the source ID regex.
*
* @return the regex
*/
protected Pattern getSourceIdPattern() {
return sourceId;
}
/**
* Copy a samples object.
*
* <p>
* This method copies the {@code samples} instance and the
* {@code instantaneous}, {@code accumulating}, {@code status}, and
* {@code tags} collection instances.
* </p>
*
* @param samples
* the samples to copy
* @return the copied samples instance
*/
public static GeneralDatumSamples copy(GeneralDatumSamples samples) {
GeneralDatumSamples copy = new GeneralDatumSamples(
samples.getInstantaneous() != null
? new LinkedHashMap<String, Number>(samples.getInstantaneous()) : null,
samples.getAccumulating() != null
? new LinkedHashMap<String, Number>(samples.getAccumulating()) : null,
samples.getStatus() != null ? new LinkedHashMap<String, Object>(samples.getStatus())
: null);
copy.setTags(samples.getTags() != null ? new LinkedHashSet<String>(samples.getTags()) : null);
return copy;
}
/**
* Test if any regular expression in a set matches a string value.
*
* @param pats
* the regular expressions to use
* @param value
* the value to test
* @param emptyPatternMatches
* {@literal true} if a {@literal null} regular expression is treated
* as a match (thus matching any value)
* @return {@literal true} if at least one regular expression matches
* {@code value}
*/
public static boolean matchesAny(final Pattern[] pats, final String value,
final boolean emptyPatternMatches) {
if ( pats == null || pats.length < 1 || value == null ) {
return true;
}
for ( Pattern pat : pats ) {
if ( pat == null ) {
if ( emptyPatternMatches ) {
return true;
}
continue;
}
if ( pat.matcher(value).find() ) {
return true;
}
}
return false;
}
/**
* Test if any configuration in a set matches a string value.
*
* @param pats
* the regular expressions to use
* @param value
* the value to test
* @param emptyPatternMatches
* {@literal true} if a {@literal null} regular expression is treated
* as a match (thus matching any value)
* @return the first config that matches, or {@literal null} if none do
*/
public static DatumPropertyFilterConfig findMatch(final DatumPropertyFilterConfig[] configs,
final String value, final boolean emptyPatternMatches) {
if ( configs == null || configs.length < 1 || value == null ) {
return null;
}
for ( DatumPropertyFilterConfig config : configs ) {
final Pattern pat = (config != null ? config.getNamePattern() : null);
if ( pat == null ) {
if ( emptyPatternMatches ) {
return config;
}
continue;
}
if ( pat.matcher(value).find() ) {
return config;
}
}
return null;
}
/**
* Test if a property should be limited based on a configuration test.
*
* @param config
* the configuration to test
* @param lastSeenKey
* the key to use for the last seen date
* @param lastSeenMap
* a map of string keys to string values, where the values are
* hex-encoded epoch date values (long)
* @param now
* the date of the property
* @return {@literal true} if the property should be limited
*/
protected boolean shouldLimitByFrequency(DatumPropertyFilterConfig config, final String lastSeenKey,
final ConcurrentMap<String, String> lastSeenMap, final long now) {
boolean limit = false;
if ( config.getFrequency() != null && config.getFrequency().intValue() > 0 ) {
final long offset = config.getFrequency() * 1000L;
String lastSaveSetting = lastSeenMap.get(lastSeenKey);
long lastSaveTime = (lastSaveSetting != null ? Long.valueOf(lastSaveSetting, 16) : 0);
if ( lastSaveTime > 0 && lastSaveTime + offset > now ) {
if ( log.isDebugEnabled() ) {
log.debug("Property {} was seen in the past {}s ({}s ago); filtering", lastSeenKey,
offset, (now - lastSaveTime) / 1000.0);
}
limit = true;
}
}
return limit;
}
/**
* Get a setting key value based on the configured {@code uid}.
*
* @return a setting key to use, never {@literal null}
*/
protected String settingKey() {
final String uid = getUid();
return String.format(SETTING_KEY_TEMPLATE, (uid == null ? DEFAULT_UID : uid));
}
/**
* Load all available settings for a given key.
*
* <p>
* This method caches the results for at most {@code settingCacheSecs}
* seconds.
* </p>
*
* @param key
* the key to load
* @return the settings, mapped into a {@code ConcurrentMap} using the
* setting {@code type} for keys and the setting {@code value} for
* the associated values
*/
protected ConcurrentMap<String, String> loadSettings(String key) {
ConcurrentMap<String, String> result = SETTING_CACHE.get(key);
if ( result == null ) {
SETTING_CACHE.putIfAbsent(key, new ConcurrentHashMap<String, String>(16));
result = SETTING_CACHE.get(key);
}
final long expiry = settingCacheExpiry.get();
if ( expiry > System.currentTimeMillis() ) {
return result;
}
SettingDao dao = getSettingDao();
if ( dao != null ) {
List<KeyValuePair> pairs = dao.getSettings(key);
if ( pairs != null && !pairs.isEmpty() ) {
for ( KeyValuePair pair : pairs ) {
result.put(pair.getKey(), pair.getValue());
}
}
}
settingCacheExpiry.compareAndSet(expiry, System.currentTimeMillis() + settingCacheSecs * 1000L);
return result;
}
/**
* Compile a set of regular expression strings.
*
* <p>
* The returned array will be the same length as {@code expressions} and the
* compiled {@link Pattern} objects in the same order. If any expression
* fails to compile, a warning log will be emitted and a {@literal null}
* value will be returned for that expression.
* </p>
*
* @param expressions
* the expressions to compile
* @return the regular expressions
*/
protected Pattern[] patterns(String[] expressions) {
Pattern[] pats = null;
if ( expressions != null ) {
final int len = expressions.length;
pats = new Pattern[len];
for ( int i = 0; i < len; i++ ) {
if ( expressions[i] == null || expressions[i].length() < 1 ) {
continue;
}
try {
pats[i] = Pattern.compile(expressions[i], Pattern.CASE_INSENSITIVE);
} catch ( PatternSyntaxException e ) {
log.warn("Error compiling includePatterns regex [{}]", expressions[i], e);
}
}
}
return pats;
}
/**
* Get the source ID pattern.
*
* @return The pattern.
*/
public String getSourceId() {
return (sourceId != null ? sourceId.pattern() : null);
}
/**
* Set a source ID pattern to match samples against.
*
* Samples will only be considered for filtering if
* {@link Datum#getSourceId()} matches this pattern.
*
* The {@code sourceIdPattern} must be a valid {@link Pattern} regular
* expression. The expression will be allowed to match anywhere in
* {@link Datum#getSourceId()} values, so if the pattern must match the full
* value only then use pattern positional expressions like {@code ^} and
* {@code $}.
*
* @param sourceIdPattern
* The source ID regex to match. Syntax errors in the pattern will be
* ignored and a {@code null} value will be set instead.
*/
public void setSourceId(String sourceIdPattern) {
try {
this.sourceId = (sourceIdPattern != null
? Pattern.compile(sourceIdPattern, Pattern.CASE_INSENSITIVE) : null);
} catch ( PatternSyntaxException e ) {
log.warn("Error compiling regex [{}]", sourceIdPattern, e);
this.sourceId = null;
}
}
/**
* Alias for the {@link #getUid()} method.
*
* @return the UID
*/
public String getUID() {
return getUid();
}
/**
* Get the UID value.
*
* @return the UID value
*/
public String getUid() {
return this.uid;
}
/**
* Set the UID value.
*
* @param uid
* the uid to set
*/
public void setUid(String uid) {
this.uid = uid;
}
/**
* Get the group UID.
*
* @return the group UID
*/
public String getGroupUID() {
return this.groupUID;
}
/**
* Set the group ID value.
*
* @param groupUID
* the groupUID to set
*/
public void setGroupUID(String groupUID) {
this.groupUID = groupUID;
}
/**
* Get a MessageSource to use.
*
* @return the meessage source
*/
public MessageSource getMessageSource() {
return messageSource;
}
/**
* Set the MessageSource to use.
*
* @param messageSource
* the messageSource to set
*/
public void setMessageSource(MessageSource messageSource) {
this.messageSource = messageSource;
}
/**
* Get the SettingDao to use.
*
* @return the DAO
*/
public SettingDao getSettingDao() {
return this.settingDao;
}
/**
* Set the {@link SettingDao} to use to persist "last seen" time stamps
* with.
*
* @param settingDao
* the DAO to set
*/
public void setSettingDao(SettingDao settingDao) {
this.settingDao = settingDao;
}
/**
* The maximum number of seconds to use cached {@link SettingDao} data when
* filtering datum.
*
* <p>
* An internal cache is used so that when iterating over sets of datum the
* settings don't need to be loaded from the database each time over a very
* short amount of time.
* </p>
*
* @param settingCacheSecs
* the settingCacheSecs to set
*/
public void setSettingCacheSecs(int settingCacheSecs) {
this.settingCacheSecs = settingCacheSecs;
}
}
| [
"[email protected]"
] | |
e6b945bcaa1cfe6b465bad9fca7ee6d2fdbcda9a | c45fe288f781c1aac3f26121ea8d779d7245e907 | /MyJavaFx/build/build/src/application/Main.java | 2ad045a3fe2590b38566720c71bd00bb1fb1bf91 | [] | no_license | atomms/MyJavaFX | 0748dc5fbcb5b1d04e739bb577712c91b7de4bf8 | 1965683dbe561e8943f7c4798f5f488e2d17198f | refs/heads/master | 2021-01-11T05:41:33.418977 | 2019-10-22T14:55:03 | 2019-10-22T14:55:03 | 71,534,519 | 1 | 4 | null | null | null | null | UTF-8 | Java | false | false | 2,425 | java | package application;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.ImageCursor;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.layout.AnchorPane;
import javafx.scene.text.Font;
import javafx.stage.Stage;
/**
*
* A <b>JavaFX</b> interface with a nice look and simple functionality
* @author ernesto
* @version 1.0
* @see OneController
*/
public class Main extends Application {
private AnchorPane rootLayout;
/**
* my Stage is public
*/
public Stage primaryStage;
/**
* sets the stage
*/
@Override
public void start(Stage primaryStage) {
try {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.primaryStage = primaryStage;
this.primaryStage.setTitle("AID School");
// this.primaryStage.setX(500);
// this.primaryStage.setY(500);
this.primaryStage.setX(screenSize.getWidth()/7);
this.primaryStage.setY(screenSize.getHeight()/7);
primaryStage.show();
initRootLayout();
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* loads the layout
*/
public void initRootLayout() {
try {
// Load root layout from fxml file.
FXMLLoader loader = new FXMLLoader();
loader.setLocation(Main.class.getResource("view/Layouts.fxml"));
rootLayout = (AnchorPane) loader.load();
// Show the scene containing the root layout.
Scene scene = new Scene(rootLayout, 640,480);
Image image = new Image("application/view/images/batman.png"); //pass in the image path
scene.setCursor(new ImageCursor(image));
// scene.setCursor(Cursor.CROSSHAIR); //Change cursor to crosshair
scene.getStylesheets().add(
getClass().getResource("application.css").toExternalForm());
// adding fonts
scene.getStylesheets().add("http://fonts.googleapis.com/css?family=Shadows+Into+Light");
Font.loadFont(getClass().getResourceAsStream("../resources/fonts/HipsterishFontNormal.ttf"), 20);
primaryStage.setMinWidth(600);
primaryStage.setMinHeight(400);
// primaryStage.sizeToScene();
primaryStage.setScene(scene);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* @param args launching
*/
public static void main(String[] args) {
launch(args);
}
}
| [
"[email protected]"
] | |
269a74d943aff5fd0980a7c7dba231c11f46b6ce | 75c8a3dab449a267123871662a6de90919df3acb | /app/src/main/java/com/zhouwei/helloapt/fixbug/HotFixDexUtils.java | 9db18c994dc13f8ef7f2d8f0f99022ab1b8294ab | [] | no_license | toberole/orm | d8cdfa445b3c74047611fa95b2024b18642f2cfa | 8f155dea7cd45da215f643214747943e76982f4d | refs/heads/master | 2021-09-07T16:43:44.486247 | 2018-02-26T07:00:45 | 2018-02-26T07:00:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,886 | java | package com.zhouwei.helloapt.fixbug;
import android.content.Context;
import java.io.File;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.util.HashSet;
import dalvik.system.DexClassLoader;
import dalvik.system.PathClassLoader;
/**
* Created by zhouwei on 2017/12/30.
* <p>
* 可用的
* dx --dex --output=C:\Users\Administrator\Desktop\dex\classes2.dex C:\Users\Administrator\Desktop\dex
* <p>
* C:\Users\Administrator\Desktop\dex\classes2.dex // 生成的dex的路径
* <p>
* C:\Users\Administrator\Desktop\dex // 修复之后的class的路径 注意只需要填写其所在目录的更目录即可
*/
public class HotFixDexUtils {
private static HashSet<File> loadedDex = new HashSet<File>();
static {
loadedDex.clear();
}
public static void loadFixDex(Context context) {
// android 系统4.1之后处于安全考虑,如果加载.dex文件,必须放到私有目录下 有些ROM没这些限制
// 获取到系统的odex 目录
File fileDir = context.getDir("odex", Context.MODE_PRIVATE);
File[] listFiles = fileDir.listFiles();
for (File file : listFiles) {
if (file.getName().endsWith(".dex")) {
// 存储该目录下的.dex文件(补丁)
loadedDex.add(file);
}
}
doDexInject(context, fileDir);
}
private static void doDexInject(Context context, File fileDir) {
// .dex 的加载需要一个临时目录
String optimizeDir = fileDir.getAbsolutePath() + File.separator + "opt_dex";
File fopt = new File(optimizeDir);
if (!fopt.exists())
fopt.mkdirs();
// 根据.dex 文件创建对应的DexClassLoader 类
for (File file : loadedDex) {
DexClassLoader classLoader = new DexClassLoader(file.getAbsolutePath(), fopt.getAbsolutePath(), null,
context.getClassLoader());
//注入
inject(classLoader, context);
}
}
private static void inject(DexClassLoader classLoader, Context context) {
// 获取到系统的DexClassLoader 类
PathClassLoader pathLoader = (PathClassLoader) context.getClassLoader();
try {
// 分别获取到补丁的dexElements和系统的dexElements
Object dexElements = combineArray(getDexElements(getPathList(classLoader)),
getDexElements(getPathList(pathLoader)));
// 获取到系统的pathList 对象
Object pathList = getPathList(pathLoader);
// 设置系统的dexElements 的值
setField(pathList, pathList.getClass(), "dexElements", dexElements);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 通过反射设置字段值
*/
private static void setField(Object obj, Class<?> cl, String field, Object value)
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field localField = cl.getDeclaredField(field);
localField.setAccessible(true);
localField.set(obj, value);
}
/**
* 通过反射获取 BaseDexClassLoader中的PathList对象
*/
private static Object getPathList(Object baseDexClassLoader)
throws IllegalArgumentException, NoSuchFieldException, IllegalAccessException, ClassNotFoundException {
return getField(baseDexClassLoader, Class.forName("dalvik.system.BaseDexClassLoader"), "pathList");
}
/**
* 通过反射获取指定字段的值
*/
private static Object getField(Object obj, Class<?> cl, String field)
throws NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
Field localField = cl.getDeclaredField(field);
localField.setAccessible(true);
return localField.get(obj);
}
/**
* 通过反射获取DexPathList中dexElements
*/
private static Object getDexElements(Object paramObject)
throws IllegalArgumentException, NoSuchFieldException, IllegalAccessException {
return getField(paramObject, paramObject.getClass(), "dexElements");
}
/**
* 合并两个数组
*
* @param arrayLhs
* @param arrayRhs
* @return
*/
private static Object combineArray(Object arrayLhs, Object arrayRhs) {
Class<?> localClass = arrayLhs.getClass().getComponentType();
int i = Array.getLength(arrayLhs);
int j = i + Array.getLength(arrayRhs);
Object result = Array.newInstance(localClass, j);
for (int k = 0; k < j; ++k) {
if (k < i) {
Array.set(result, k, Array.get(arrayLhs, k));
} else {
Array.set(result, k, Array.get(arrayRhs, k - i));
}
}
return result;
}
}
| [
"[email protected]"
] | |
f78ad2d9385a882094296ee338251bf951da8296 | 7786c93a94cb359a196d6a8a3a0ede4c7c936fa5 | /Lecture_Persistent_Data/PDJSON.java | c0649f018eefcd56b11eeec946a86b5cc47b46e0 | [] | no_license | junhaow1/comp2100-6442-2021.s2 | ad5ba2521eb0eb91d4cec6d3f8935ddef63528d5 | dca5cd7cdb848b949861d92b5e44d96962395e29 | refs/heads/master | 2023-08-25T08:52:05.314393 | 2021-10-18T08:23:23 | 2021-10-18T08:23:23 | 403,236,438 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,671 | java | import java.io.FileReader;
import java.io.FileWriter;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
public class PDJSON {
private List<PersonJSON> people;
public PDJSON() {
people = new ArrayList<PersonJSON>();
}
public void saveData(String filePath) {
//Gson gson = new Gson();
Gson gson = new GsonBuilder().setPrettyPrinting().create();
try(FileWriter fw = new FileWriter(filePath)){
gson.toJson(people, fw);
}catch(Exception e)
{
e.printStackTrace();
}
}
public List<PersonJSON> loadData(String filePath) {
Gson gson = new Gson();
JsonReader jsonReader = null;
final Type CUS_LIST_TYPE = new TypeToken<List<PersonJSON>>() {}.getType();
//or TypeToken.getParameterized(ArrayList.class, PersonJSON.class).getType();
try{
jsonReader = new JsonReader(new FileReader(filePath));
}catch (Exception e) {
e.printStackTrace();
}
return gson.fromJson(jsonReader, CUS_LIST_TYPE);
}
public static void main(String[] args) {
PDJSON pdj = new PDJSON();
pdj.people.add(new PersonJSON(1,"Bart", "Simpson", new AddressJSON("Springfield", "USA")));
pdj.people.add(new PersonJSON(2,"Homer", "Simpson", new AddressJSON("Springfield", "USA")));
pdj.people.add(new PersonJSON(3,"Mickey", "Mouse", new AddressJSON("Orlando", "USA")));
pdj.saveData("resources/listofpeople.json");
List<PersonJSON> lp = pdj.loadData("resources/listofpeople.json");
for(PersonJSON pj : lp)
{
System.out.println(pj.toString());
}
}
} | [
"[email protected]"
] | |
aaa888f3d67028920fc01b3388cd158abb267c03 | c99fe25de6da389289bab12e6a7bac9414a1a731 | /src/com/sphz/service/system/fhsms/impl/FhsmsService.java | c9c1fafd9fa33ed7071dfa4f9c13f4a4e7e991ab | [] | no_license | baqi250/sphz | 20cda52c2ce8720796a6d36bea8f70e5cef4851e | 6dacd747a72efea04a63be33c2804e72ea5583c3 | refs/heads/master | 2020-04-17T07:30:34.480048 | 2019-01-18T09:12:36 | 2019-01-18T09:12:36 | 166,372,860 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,097 | java | package com.sphz.service.system.fhsms.impl;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.sphz.dao.DaoSupport;
import com.sphz.entity.Page;
import com.sphz.service.system.fhsms.FhsmsManager;
import com.sphz.util.PageData;
/**
* 说明: 站内信
* 创建人:DK
* 创建时间:2016-01-17
* @version
*/
@Service("fhsmsService")
public class FhsmsService implements FhsmsManager{
@Resource(name = "daoSupport")
private DaoSupport dao;
/**新增
* @param pd
* @throws Exception
*/
@Override
public void save(PageData pd)throws Exception{
dao.save("FhsmsMapper.save", pd);
}
/**删除
* @param pd
* @throws Exception
*/
@Override
public void delete(PageData pd)throws Exception{
dao.delete("FhsmsMapper.delete", pd);
}
/**修改状态
* @param pd
* @throws Exception
*/
@Override
public void edit(PageData pd)throws Exception{
dao.update("FhsmsMapper.edit", pd);
}
/**列表
* @param page
* @throws Exception
*/
@Override
@SuppressWarnings("unchecked")
public List<PageData> list(Page page)throws Exception{
return (List<PageData>)dao.findForList("FhsmsMapper.datalistPage", page);
}
/**列表(全部)
* @param pd
* @throws Exception
*/
@Override
@SuppressWarnings("unchecked")
public List<PageData> listAll(PageData pd)throws Exception{
return (List<PageData>)dao.findForList("FhsmsMapper.listAll", pd);
}
/**通过id获取数据
* @param pd
* @throws Exception
*/
@Override
public PageData findById(PageData pd)throws Exception{
return (PageData)dao.findForObject("FhsmsMapper.findById", pd);
}
/**获取未读总数
* @param pd
* @throws Exception
*/
@Override
public PageData findFhsmsCount(String USERNAME)throws Exception{
return (PageData)dao.findForObject("FhsmsMapper.findFhsmsCount", USERNAME);
}
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
@Override
public void deleteAll(String[] ArrayDATA_IDS)throws Exception{
dao.delete("FhsmsMapper.deleteAll", ArrayDATA_IDS);
}
}
| [
"[email protected]"
] | |
6232d5f0110d4c341d335877828484f01499cdec | 09d0ddd512472a10bab82c912b66cbb13113fcbf | /TestApplications/TF-BETA-THERMATK-v5.7.1/DecompiledCode/Fernflower/src/main/java/org/telegram/messenger/_$$Lambda$MessagesStorage$mAd0DJIW27tlUDIOzW0wIDeqyuE.java | 7b68937e2d7ad43c0e2962741b607f7db41be33c | [] | no_license | sgros/activity_flow_plugin | bde2de3745d95e8097c053795c9e990c829a88f4 | 9e59f8b3adacf078946990db9c58f4965a5ccb48 | refs/heads/master | 2020-06-19T02:39:13.865609 | 2019-07-08T20:17:28 | 2019-07-08T20:17:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 691 | java | package org.telegram.messenger;
import java.util.ArrayList;
// $FF: synthetic class
public final class _$$Lambda$MessagesStorage$mAd0DJIW27tlUDIOzW0wIDeqyuE implements Runnable {
// $FF: synthetic field
private final MessagesStorage f$0;
// $FF: synthetic field
private final int f$1;
// $FF: synthetic field
private final ArrayList f$2;
// $FF: synthetic method
public _$$Lambda$MessagesStorage$mAd0DJIW27tlUDIOzW0wIDeqyuE(MessagesStorage var1, int var2, ArrayList var3) {
this.f$0 = var1;
this.f$1 = var2;
this.f$2 = var3;
}
public final void run() {
this.f$0.lambda$putChannelAdmins$69$MessagesStorage(this.f$1, this.f$2);
}
}
| [
"[email protected]"
] | |
0a08c9364b8d68386c123e1c485707cc3ce09704 | cfc90de4ed3c289708246c61b4cc70c2057a0459 | /src/main/java/com/example/vetclinica/repos/UserRepos.java | fb7bea4018afc1d5db922969507891df91a11913 | [] | no_license | DmitriyTavluy/VetcCinic | 69ab4d35e34f47ca4137291383782f4ffb86bf0d | 40dcda5a0a229320880a6ce0db423dce55f7a7ae | refs/heads/master | 2023-03-26T17:05:51.963583 | 2021-03-13T02:10:23 | 2021-03-13T02:10:23 | 347,249,309 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 297 | java | package com.example.vetclinica.repos;
import com.example.vetclinica.domain.User;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepos extends JpaRepository<User, Long> {
User findByUsername(String username);
User findByActivationCode(String code);
}
| [
"[email protected]"
] | |
8b4e20ca2ea9be7a13996c7ab4d98a0413e6caa0 | 495c838f2e22dc45cf362bb978af899b9e41894e | /src/com/developer/creational/objectPool/ObjectPool.java | 6d8230988973480ab9c04b71ce87b128ea5fead7 | [] | no_license | Jackson75063/patterns | 36550dad9520e8be6a9dc430e01fc428f10fab73 | 0ad186031d0e5450020d21fc2f018bd019397cf5 | refs/heads/master | 2023-04-07T17:35:00.551592 | 2021-04-07T20:19:44 | 2021-04-07T20:19:44 | 354,613,663 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 483 | java | package com.developer.creational.objectPool;
import java.util.Hashtable;
public abstract class ObjectPool<T> {
public Hashtable<T, Boolean> checkIn = new Hashtable<>();
public abstract T create();
public synchronized void checkOut(T t) {
checkIn.put(t, false);
}
public synchronized T checkIn() {
for (T t : checkIn.keySet()) {
if (checkIn.get(t)) {
return t;
}
}
return null;
}
}
| [
"[email protected]"
] | |
1a64ad33969a9699debfa4cf5f091cad5469618f | 95f46fe2c9c97b6b2ed2a1a4171d85bc83219838 | /src/main/java/com/zhouxh/antlr4/tool/sql/bean/consanguinity/CaseWhenColumnBean.java | 84e588c7ae91afe0d89e5a167fee4babd2cd8b52 | [] | no_license | zhouxinhai/antlr4-tools | dd5e38fa71a9f5f0b452d18206ee13c8aebb3201 | c31ec42ac0ed06b7a5b1f62bbd20e3242aa2814e | refs/heads/main | 2023-06-03T04:48:44.869085 | 2021-06-20T03:31:11 | 2021-06-20T03:31:11 | 376,670,240 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 945 | java | package com.zhouxh.antlr4.tool.sql.bean.consanguinity;
import java.util.ArrayList;
import java.util.List;
/**
* Create by Howard on 2018/10/24
*/
public class CaseWhenColumnBean {
public ColumnBean caseExpression;
public List<ColumnBean> whenClauses = new ArrayList<>();
public ColumnBean elseExpression;
public String toConsanguinityFormat(){
String caseExpression = this.caseExpression==null ? "": this.caseExpression.toConsanguinityFormat();
String strWhenClauses = "";
for(ColumnBean whenClauses :this.whenClauses){
strWhenClauses+= whenClauses.toConsanguinityFormat();
strWhenClauses+=" ";
}
String elseExpression = this.elseExpression==null ? "":"ELSE "+ this.elseExpression.toConsanguinityFormat()+" ";
return "(CASE "+ caseExpression
+ " " + strWhenClauses
+ elseExpression
+ "END)";
}
}
| [
"[email protected]"
] | |
b1f41a476b683f8525b15727271c98fba9b6d003 | be0d49a2d3c68c8315afd05d788bbcf860884946 | /src/main/java/main/config/world/WorldConfig.java | 8df27cc4e8a281771806b0300026f33ac45380ea | [] | no_license | KrystilizeNevaDies/Primordial | eac8df3226510d4fbb146d892f2acb9797cbb54d | d48a6efa7de69e5f11d75c8cdcd0e88931c57dbf | refs/heads/main | 2023-03-07T08:32:43.928125 | 2021-02-25T02:44:24 | 2021-02-25T02:44:24 | 337,794,696 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 399 | java | package main.config.world;
import java.util.Map;
import main.generation.biomes.BiomeConfig;
public interface WorldConfig {
/**
* Get a mapping containing all biomes and their configs.
*
* @return Map a map of all added BiomeConfigs indexed by their name
*/
public Map<String, BiomeConfig> getBiomeConfigs();
/**
* Gets the name of this world
*/
public String getWorldName();
}
| [
"[email protected]"
] | |
50d3c5a9c185912eed4c62259d37798e60ab2d96 | 220b75a82708a84613dc9a31285ab67550f02ae2 | /src/test/java/top/zzk0/aop/JdkDynamicAopProxyTest.java | 8cf63de840f20d2ea954707c35ceb10741d3f1f4 | [] | no_license | zzk0/tiny-spring | 1cb69a94c6a295edb1bac9ae1f3d6f366e385f8a | 3898582a6c9a72a3c6c7523fb06dabea862a6e4e | refs/heads/master | 2023-03-04T01:18:20.750797 | 2021-02-17T12:10:27 | 2021-02-17T12:10:27 | 339,924,143 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,327 | java | package top.zzk0.aop;
import org.junit.jupiter.api.Test;
import top.zzk0.aop.aspectj.AspectJExpressionPointCut;
import top.zzk0.aop.weave.AdvisedSupport;
import top.zzk0.aop.weave.JdkDynamicAopProxyFactory;
import top.zzk0.aop.weave.TargetSource;
import top.zzk0.bean.Animal;
import top.zzk0.bean.Bone;
import top.zzk0.bean.Dog;
class JdkDynamicAopProxyTest {
@Test
public void testAop() {
// 正常调用
Dog dog = new Dog();
dog.setName("wangcat");
Bone bone = new Bone();
bone.setOwner(dog);
bone.setType("pig");
dog.say();
// 动态代理
TargetSource targetSource = new TargetSource(dog, dog.getClass(), dog.getClass().getInterfaces());
AdvisedSupport advisedSupport = new AdvisedSupport();
advisedSupport.setTargetSource(targetSource);
advisedSupport.setMethodInterceptor(new TimerInterceptor());
AspectJExpressionPointCut pointCut = new AspectJExpressionPointCut();
pointCut.setExpression("execution(* top.zzk0.bean.*.say(..))");
advisedSupport.setMethodMatcher(pointCut.getMethodMatcher());
JdkDynamicAopProxyFactory proxy = new JdkDynamicAopProxyFactory(advisedSupport);
// 获取代理对象
Animal dog1 = (Animal)proxy.getProxy();
dog1.say();
}
} | [
"[email protected]"
] | |
3f670ac2e9d8942811267e74af331988f017063e | c7ad607a4f2088c9edd424d167c2042e4235aa25 | /shiro-spring/src/main/java/cn/v5cn/security/shiro_spring/action/ResourceAction.java | 8f095b24f8183dc55847f07a9c2cbbdd5f9f8a39 | [] | no_license | zyw/security-examples | eace339198ed2592f8cb0aecd0a165fe45cd8d88 | ac477fa850e92839b0cfff818a449eb7b6d05c00 | refs/heads/master | 2016-09-11T05:21:31.617926 | 2014-10-09T09:33:57 | 2014-10-09T09:33:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,919 | java | package cn.v5cn.security.shiro_spring.action;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.v5cn.security.shiro_spring.entity.Resource;
import cn.v5cn.security.shiro_spring.service.ResourceService;
import com.google.common.collect.ImmutableMap;
@Controller
public class ResourceAction {
@Autowired
private ResourceService resourceService;
@RequestMapping(value="/resource",method=RequestMethod.GET)
public String resourceList(ModelMap modelMap){
List<Resource> result = resourceService.findAll();
System.out.println(result);
modelMap.addAttribute("ress", result);
return "resource/resources";
}
@RequestMapping(value="/resource/{resId}",method=RequestMethod.GET)
public String editResPage(@PathVariable Long resId,ModelMap modelMap){
Resource parent = resourceService.findByResId(resId);
modelMap.addAttribute("parent", parent);
Resource resource = new Resource();
resource.setParent_Id(resId);
resource.setParent_Ids(parent.getParent_Ids()+parent.getId()+"/");
modelMap.addAttribute("resource", resource);
modelMap.addAttribute("op", "新增子节点");
return "resource/edit_res";
}
@ResponseBody
@RequestMapping(value="/resource",method=RequestMethod.POST)
public ImmutableMap<String,String> editResPost(Resource resource){
System.out.println(resource);
int result = resourceService.addRes(resource);
if(result > 0){
return ImmutableMap.of("state","1","message", "添加资源成功!");
}
return ImmutableMap.of("state","0","message", "添加资源失败!");
}
}
| [
"[email protected]"
] | |
509d9514af9c948b79d63f3f4a2e3805c24aea08 | 2c838d2814fc212796572df7aeca79a481ddf2db | /EJBWebApp/src/com/bank/ExtraSearchServlet.java | 084f9d6620a8997d0f6bf5a01d9d0538ab498b23 | [] | no_license | borjur/EJBJBoss | 962a5916611e9a5cd0469331502bf54841500be9 | ec50e5b73c470976df409783f0d51e7586ee7acf | refs/heads/master | 2020-04-06T11:32:08.437937 | 2014-06-17T18:06:38 | 2014-06-17T18:06:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,639 | java | package com.bank;
import java.io.IOException;
import java.util.List;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import simple.bank.TellerLocal;
import com.entity.BankAccount;
import com.entity.PhoneNumber;
/**
* Servlet Class
*
*/
public class ExtraSearchServlet extends HttpServlet {
public ExtraSearchServlet() {
super();
// TODO Auto-generated constructor stub
}
@EJB(beanName = "Teller")
TellerLocal teller;
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
String action = req.getParameter("todo");
if ("Phone Number Search".equals(action)) {
String idString = req.getParameter("id");
int id = new Integer(idString).intValue();
List<PhoneNumber> numbers = teller.findNumbersForOwner(id);
req.setAttribute("numbers", numbers);
}
if ("Account Search".equals(action)) {
String areacodeString = req.getParameter("areacode");
int areacode = new Integer(areacodeString).intValue();
List<BankAccount> accounts = teller
.findAccountsForAreaCode(areacode);
req.setAttribute("accounts", accounts);
}
if ("Telemarketers Click Here".equals(action)) {
String amountString = req.getParameter("amount");
int amount = new Integer(amountString).intValue();
List<PhoneNumber> phoneNumbers = teller
.findNumbersForAmount(amount);
req.setAttribute("phoneNumbers", phoneNumbers);
}
req.getRequestDispatcher("extradisplayresults.jsp").forward(req, resp);
}
}
| [
"[email protected]"
] | |
eacd29dfb929a8593abb507cbb2b475da2e70fbc | 57e0bb6df155a54545d9cee8f645a95f3db58fd2 | /projects/ikasabutskaya/calculator/src/main/java/by/it/ikasabutskaya/Parser.java | f0b9183b5c87581652a9670898066cafd25b7020 | [] | no_license | VitaliShchur/AT2019-03-12 | a73d3acd955bc08aac6ab609a7d40ad109edd4ef | 3297882ea206173ed39bc496dec04431fa957d0d | refs/heads/master | 2020-04-30T23:28:19.377985 | 2019-08-09T14:11:52 | 2019-08-09T14:11:52 | 177,144,769 | 0 | 0 | null | 2019-05-15T21:22:32 | 2019-03-22T13:26:43 | Java | UTF-8 | Java | false | false | 2,578 | java | package by.it.ikasabutskaya;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
class Parser {
private static final List<String> priority = new ArrayList<>(Arrays.asList("=,+,-,*,/".split(",")));
private List<String> operation = new ArrayList<>();
private List<String> operand;
private int getPosOperation(){
int level = -1, pos = -1, i = 0;
for (String op : operation) {
int currentLevel = priority.indexOf(op);
if(level<currentLevel) {
level = currentLevel;
pos = i;
}
i++;
}
return pos;
}
Var calc(String expression) throws CalcException {
String[] operands = expression.split(Patterns.OPERATION);
operand = new ArrayList<>(Arrays.asList(operands));
Pattern pattern = Pattern.compile(Patterns.OPERATION);
Matcher matcher = pattern.matcher(expression);
while (matcher.find()) {
operation.add(matcher.group());
}
Var res = null;
while (operation.size() > 0) {
int pos = getPosOperation();
String vl = operand.get(pos);
String op = operation.remove(pos);
String v2 = operand.remove(pos + 1);
res = operationCalc(vl, op, v2);
operand.set(pos, res.toString());
}
return res;
}
String excludeBracers(String expression) throws CalcException {
String res = expression, calculation;
while ((res.contains("(")) || (res.contains(")"))) {
Pattern pattern = Pattern.compile(Patterns.BRACES);
Matcher matcher = pattern.matcher(res);
while (matcher.find()) {
calculation = matcher.group().replace("(", "").replace(")", "");
res = res.replace(matcher.group(), calc(calculation).toString());
}
}
return res;
}
private Var operationCalc(String v1, String operation, String v2) throws CalcException {
Var two = Var.createVar(v2);
if (operation.equals("=")){
return Var.saveVar(v1, two);
}
Var one = Var.createVar(v1);
switch (operation) {
case "+": return one.add(two);
case "-": return one.sub(two);
case "*": return one.mul(two);
case "/": return one.div(two);
}
return null;
}
} | [
"[email protected]"
] | |
d0b482aa016cd441466f38aeb83dd44f477bb259 | 2cc374faa31379776f6383d97bdb85d106e8abb5 | /Acme-Canyoning/src/main/java/utilities/DatabaseConfig.java | 2bdfe28da4794ccf8ba985e36cf724f8f7c3cb85 | [] | no_license | rrodriguezos/Canyoning-1.0 | 313edf8b96d2b53c87f87993a70b92f13f1b87b9 | b347fbf85f4a62721d4ad7e83d2e8adc3df0e475 | refs/heads/master | 2021-01-12T05:35:12.981110 | 2017-01-03T12:00:48 | 2017-01-03T12:00:48 | 77,134,674 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 123 | java | package utilities;
public interface DatabaseConfig {
public final String PersistenceUnit = "Acme-Canyoning";
}
| [
"rafrodoso@b6ec5127-bec7-49a0-8482-abe0d3ac1936"
] | rafrodoso@b6ec5127-bec7-49a0-8482-abe0d3ac1936 |
b963382978ccb861a72ebab94883a47a323171de | f4030bf283b1f48f283ef035359749f9db25801e | /build/tmp/expandedArchives/forge-1.16.4-35.1.0_mapped_snapshot_20201028-1.16.3-sources.jar_c51f1a4d6ae306192d7f9edae1dccaf5/net/minecraft/command/arguments/AngleArgument.java | 4aa96ef200a4c76a902f8b60d9eaf1853a54e731 | [
"MIT"
] | permissive | Slightly-Useful-Inc/DankestMod | 803a1cb913ee16251d52d54053918ecca27cea48 | 01345585be6a26587a44cee341a99a5efe31cc51 | refs/heads/master | 2023-03-06T11:37:44.104046 | 2021-02-16T23:12:19 | 2021-02-16T23:12:19 | 316,117,727 | 2 | 3 | MIT | 2021-02-16T23:12:20 | 2020-11-26T03:54:33 | Java | UTF-8 | Java | false | false | 2,171 | java | package net.minecraft.command.arguments;
import com.mojang.brigadier.StringReader;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import java.util.Arrays;
import java.util.Collection;
import net.minecraft.command.CommandSource;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.text.TranslationTextComponent;
public class AngleArgument implements ArgumentType<AngleArgument.Result> {
private static final Collection<String> field_242990_b = Arrays.asList("0", "~", "~-5");
public static final SimpleCommandExceptionType field_242989_a = new SimpleCommandExceptionType(new TranslationTextComponent("argument.angle.incomplete"));
public static AngleArgument func_242991_a() {
return new AngleArgument();
}
public static float func_242992_a(CommandContext<CommandSource> p_242992_0_, String p_242992_1_) {
return p_242992_0_.getArgument(p_242992_1_, AngleArgument.Result.class).func_242995_a(p_242992_0_.getSource());
}
public AngleArgument.Result parse(StringReader p_parse_1_) throws CommandSyntaxException {
if (!p_parse_1_.canRead()) {
throw field_242989_a.createWithContext(p_parse_1_);
} else {
boolean flag = LocationPart.isRelative(p_parse_1_);
float f = p_parse_1_.canRead() && p_parse_1_.peek() != ' ' ? p_parse_1_.readFloat() : 0.0F;
return new AngleArgument.Result(f, flag);
}
}
public Collection<String> getExamples() {
return field_242990_b;
}
public static final class Result {
private final float field_242993_a;
private final boolean field_242994_b;
private Result(float p_i242044_1_, boolean p_i242044_2_) {
this.field_242993_a = p_i242044_1_;
this.field_242994_b = p_i242044_2_;
}
public float func_242995_a(CommandSource p_242995_1_) {
return MathHelper.wrapDegrees(this.field_242994_b ? this.field_242993_a + p_242995_1_.getRotation().y : this.field_242993_a);
}
}
}
| [
"[email protected]"
] | |
31c02160a7588c321649ecfabd92ee3e16bd4d09 | 1863f1b02d2960692ad7c9d916d40bf33e646212 | /corelibs/src/main/java/me/sonam/dev/corelibs/views/roundedimageview/RoundedImageView.java | 69e77c925a207c30c7b73b3fd47652bf0561768c | [] | no_license | lbhsot/FastAndroidDemo | f9e18791cd014a88f0aae026f71a7fb6c04b301e | e746491262f7484a1f1d21e56900ea1c28f22ede | refs/heads/master | 2021-01-16T23:21:34.125212 | 2017-03-13T03:38:17 | 2017-03-13T03:38:17 | 82,910,527 | 6 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,361 | java | /*
* Copyright (C) 2015 Vincent Mi
*
* 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 me.sonam.dev.corelibs.views.roundedimageview;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.ColorFilter;
import android.graphics.Shader;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.net.Uri;
import android.support.annotation.ColorRes;
import android.support.annotation.DimenRes;
import android.support.annotation.DrawableRes;
import android.util.AttributeSet;
import android.util.Log;
import android.widget.ImageView;
import me.sonam.dev.corelibs.views.roundedimageview.RoundedDrawable.Corner;
import me.sonam.dev.corelibs.R;
public class RoundedImageView extends ImageView {
// Constants for tile mode attributes
private static final int TILE_MODE_UNDEFINED = -2;
private static final int TILE_MODE_CLAMP = 0;
private static final int TILE_MODE_REPEAT = 1;
private static final int TILE_MODE_MIRROR = 2;
public static final String TAG = "RoundedImageView";
public static final float DEFAULT_RADIUS = 0f;
public static final float DEFAULT_BORDER_WIDTH = 0f;
public static final Shader.TileMode DEFAULT_TILE_MODE = Shader.TileMode.CLAMP;
private static final ScaleType[] SCALE_TYPES = {
ScaleType.MATRIX,
ScaleType.FIT_XY,
ScaleType.FIT_START,
ScaleType.FIT_CENTER,
ScaleType.FIT_END,
ScaleType.CENTER,
ScaleType.CENTER_CROP,
ScaleType.CENTER_INSIDE
};
private final float[] mCornerRadii =
new float[] { DEFAULT_RADIUS, DEFAULT_RADIUS, DEFAULT_RADIUS, DEFAULT_RADIUS };
private Drawable mBackgroundDrawable;
private ColorStateList mBorderColor =
ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
private float mBorderWidth = DEFAULT_BORDER_WIDTH;
private ColorFilter mColorFilter = null;
private boolean mColorMod = false;
private Drawable mDrawable;
private boolean mHasColorFilter = false;
private boolean mIsOval = false;
private boolean mMutateBackground = false;
private int mResource;
private ScaleType mScaleType = ScaleType.FIT_CENTER;
private Shader.TileMode mTileModeX = DEFAULT_TILE_MODE;
private Shader.TileMode mTileModeY = DEFAULT_TILE_MODE;
public RoundedImageView(Context context) {
super(context);
}
public RoundedImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public RoundedImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RoundedImageView, defStyle, 0);
int index = a.getInt(R.styleable.RoundedImageView_android_scaleType, -1);
if (index >= 0) {
setScaleType(SCALE_TYPES[index]);
} else {
// default scaletype to FIT_CENTER
setScaleType(ScaleType.FIT_CENTER);
}
float cornerRadiusOverride =
a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius, -1);
mCornerRadii[Corner.TOP_LEFT.ordinal()] =
a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius_top_left, -1);
mCornerRadii[Corner.TOP_RIGHT.ordinal()] =
a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius_top_right, -1);
mCornerRadii[Corner.BOTTOM_RIGHT.ordinal()] =
a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius_bottom_right, -1);
mCornerRadii[Corner.BOTTOM_LEFT.ordinal()] =
a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_corner_radius_bottom_left, -1);
boolean any = false;
for (int i = 0, len = mCornerRadii.length; i < len; i++) {
if (mCornerRadii[i] < 0) {
mCornerRadii[i] = 0f;
} else {
any = true;
}
}
if (!any) {
if (cornerRadiusOverride < 0) {
cornerRadiusOverride = DEFAULT_RADIUS;
}
for (int i = 0, len = mCornerRadii.length; i < len; i++) {
mCornerRadii[i] = cornerRadiusOverride;
}
}
mBorderWidth = a.getDimensionPixelSize(R.styleable.RoundedImageView_riv_border_width, -1);
if (mBorderWidth < 0) {
mBorderWidth = DEFAULT_BORDER_WIDTH;
}
mBorderColor = a.getColorStateList(R.styleable.RoundedImageView_riv_border_color);
if (mBorderColor == null) {
mBorderColor = ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
}
mMutateBackground = a.getBoolean(R.styleable.RoundedImageView_riv_mutate_background, false);
mIsOval = a.getBoolean(R.styleable.RoundedImageView_riv_oval, false);
final int tileMode = a.getInt(R.styleable.RoundedImageView_riv_tile_mode, TILE_MODE_UNDEFINED);
if (tileMode != TILE_MODE_UNDEFINED) {
setTileModeX(parseTileMode(tileMode));
setTileModeY(parseTileMode(tileMode));
}
final int tileModeX =
a.getInt(R.styleable.RoundedImageView_riv_tile_mode_x, TILE_MODE_UNDEFINED);
if (tileModeX != TILE_MODE_UNDEFINED) {
setTileModeX(parseTileMode(tileModeX));
}
final int tileModeY =
a.getInt(R.styleable.RoundedImageView_riv_tile_mode_y, TILE_MODE_UNDEFINED);
if (tileModeY != TILE_MODE_UNDEFINED) {
setTileModeY(parseTileMode(tileModeY));
}
updateDrawableAttrs();
updateBackgroundDrawableAttrs(true);
a.recycle();
}
private static Shader.TileMode parseTileMode(int tileMode) {
switch (tileMode) {
case TILE_MODE_CLAMP:
return Shader.TileMode.CLAMP;
case TILE_MODE_REPEAT:
return Shader.TileMode.REPEAT;
case TILE_MODE_MIRROR:
return Shader.TileMode.MIRROR;
default:
return null;
}
}
@Override
protected void drawableStateChanged() {
super.drawableStateChanged();
invalidate();
}
@Override
public ScaleType getScaleType() {
return mScaleType;
}
@Override
public void setScaleType(ScaleType scaleType) {
assert scaleType != null;
if (mScaleType != scaleType) {
mScaleType = scaleType;
switch (scaleType) {
case CENTER:
case CENTER_CROP:
case CENTER_INSIDE:
case FIT_CENTER:
case FIT_START:
case FIT_END:
case FIT_XY:
super.setScaleType(ScaleType.FIT_XY);
break;
default:
super.setScaleType(scaleType);
break;
}
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
}
@Override
public void setImageDrawable(Drawable drawable) {
mResource = 0;
mDrawable = RoundedDrawable.fromDrawable(drawable);
updateDrawableAttrs();
super.setImageDrawable(mDrawable);
}
@Override
public void setImageBitmap(Bitmap bm) {
mResource = 0;
mDrawable = RoundedDrawable.fromBitmap(bm);
updateDrawableAttrs();
super.setImageDrawable(mDrawable);
}
@Override
public void setImageResource(@DrawableRes int resId) {
if (mResource != resId) {
mResource = resId;
mDrawable = resolveResource();
updateDrawableAttrs();
super.setImageDrawable(mDrawable);
}
}
@Override public void setImageURI(Uri uri) {
super.setImageURI(uri);
setImageDrawable(getDrawable());
}
private Drawable resolveResource() {
Resources rsrc = getResources();
if (rsrc == null) { return null; }
Drawable d = null;
if (mResource != 0) {
try {
d = rsrc.getDrawable(mResource);
} catch (Exception e) {
Log.w(TAG, "Unable to find resource: " + mResource, e);
// Don't try again.
mResource = 0;
}
}
return RoundedDrawable.fromDrawable(d);
}
@Override
public void setBackground(Drawable background) {
setBackgroundDrawable(background);
}
private void updateDrawableAttrs() {
updateAttrs(mDrawable);
}
private void updateBackgroundDrawableAttrs(boolean convert) {
if (mMutateBackground) {
if (convert) {
mBackgroundDrawable = RoundedDrawable.fromDrawable(mBackgroundDrawable);
}
updateAttrs(mBackgroundDrawable);
}
}
@Override public void setColorFilter(ColorFilter cf) {
if (mColorFilter != cf) {
mColorFilter = cf;
mHasColorFilter = true;
mColorMod = true;
applyColorMod();
invalidate();
}
}
private void applyColorMod() {
// Only mutate and apply when modifications have occurred. This should
// not reset the mColorMod flag, since these filters need to be
// re-applied if the Drawable is changed.
if (mDrawable != null && mColorMod) {
mDrawable = mDrawable.mutate();
if (mHasColorFilter) {
mDrawable.setColorFilter(mColorFilter);
}
// TODO: support, eventually...
//mDrawable.setXfermode(mXfermode);
//mDrawable.setAlpha(mAlpha * mViewAlphaScale >> 8);
}
}
private void updateAttrs(Drawable drawable) {
if (drawable == null) { return; }
if (drawable instanceof RoundedDrawable) {
((RoundedDrawable) drawable)
.setScaleType(mScaleType)
.setBorderWidth(mBorderWidth)
.setBorderColor(mBorderColor)
.setOval(mIsOval)
.setTileModeX(mTileModeX)
.setTileModeY(mTileModeY);
if (mCornerRadii != null) {
((RoundedDrawable) drawable)
.setCornerRadius(
mCornerRadii[0], mCornerRadii[1], mCornerRadii[2], mCornerRadii[3]);
}
applyColorMod();
} else if (drawable instanceof LayerDrawable) {
// loop through layers to and set drawable attrs
LayerDrawable ld = ((LayerDrawable) drawable);
for (int i = 0, layers = ld.getNumberOfLayers(); i < layers; i++) {
updateAttrs(ld.getDrawable(i));
}
}
}
@Override
@Deprecated
public void setBackgroundDrawable(Drawable background) {
mBackgroundDrawable = background;
updateBackgroundDrawableAttrs(true);
super.setBackgroundDrawable(mBackgroundDrawable);
}
/**
* @return the corner radius.
*/
public float getCornerRadius() {
for (int i = 0; i < 4; i++) {
if (mCornerRadii[i] > 0) {
return mCornerRadii[i];
}
}
return 0;
}
/**
* Set all the corner radii from a dimension resource id.
*
* @param resId dimension resource id of radii.
*/
public void setCornerRadiusDimen(@DimenRes int resId) {
float radius = getResources().getDimension(resId);
setCornerRadius(radius, radius, radius, radius);
}
/**
* Set the corner radii of all corners in px.
*
* @param radius the radius.
*/
public void setCornerRadius(float radius) {
setCornerRadius(radius, radius, radius, radius);
}
/**
* Set the corner radii of each corner individually. Currently only one unique nonzero value is
* supported.
*
* @param topLeft radius of the top left corner in px.
* @param topRight radius of the top right corner in px.
* @param bottomRight radius of the bottom right corner in px.
* @param bottomLeft radius of the bottom left corner in px.
*/
public void setCornerRadius(float topLeft, float topRight, float bottomLeft, float bottomRight) {
if (mCornerRadii[Corner.TOP_LEFT.ordinal()] == topLeft
&& mCornerRadii[Corner.TOP_RIGHT.ordinal()] == topRight
&& mCornerRadii[Corner.BOTTOM_RIGHT.ordinal()] == bottomRight
&& mCornerRadii[Corner.BOTTOM_LEFT.ordinal()] == bottomLeft) {
return;
}
mCornerRadii[0] = topLeft;
mCornerRadii[1] = topRight;
mCornerRadii[2] = bottomLeft;
mCornerRadii[3] = bottomRight;
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
public float getBorderWidth() {
return mBorderWidth;
}
public void setBorderWidth(@DimenRes int resId) {
setBorderWidth(getResources().getDimension(resId));
}
public void setBorderWidth(float width) {
if (mBorderWidth == width) { return; }
mBorderWidth = width;
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
public int getBorderColor() {
return mBorderColor.getDefaultColor();
}
public void setBorderColor(@ColorRes int color) {
setBorderColor(ColorStateList.valueOf(color));
}
public ColorStateList getBorderColors() {
return mBorderColor;
}
public void setBorderColor(ColorStateList colors) {
if (mBorderColor.equals(colors)) { return; }
mBorderColor =
(colors != null) ? colors : ColorStateList.valueOf(RoundedDrawable.DEFAULT_BORDER_COLOR);
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
if (mBorderWidth > 0) {
invalidate();
}
}
public boolean isOval() {
return mIsOval;
}
public void setOval(boolean oval) {
mIsOval = oval;
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
public Shader.TileMode getTileModeX() {
return mTileModeX;
}
public void setTileModeX(Shader.TileMode tileModeX) {
if (this.mTileModeX == tileModeX) { return; }
this.mTileModeX = tileModeX;
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
public Shader.TileMode getTileModeY() {
return mTileModeY;
}
public void setTileModeY(Shader.TileMode tileModeY) {
if (this.mTileModeY == tileModeY) { return; }
this.mTileModeY = tileModeY;
updateDrawableAttrs();
updateBackgroundDrawableAttrs(false);
invalidate();
}
public boolean mutatesBackground() {
return mMutateBackground;
}
public void mutateBackground(boolean mutate) {
if (mMutateBackground == mutate) { return; }
mMutateBackground = mutate;
updateBackgroundDrawableAttrs(true);
invalidate();
}
}
| [
"[email protected]"
] | |
f0daf75213e05b702f654deb0f79a0e2abd8f90f | 753ea4570d3d3e13981e6f21df2a7e8977af1fb6 | /src/main/java/com/metin/medium/dockerspringbootpostgresql/repository/StudentRepository.java | 011508aa7346cdf684e9231d60245ebbba8f3d6a | [] | no_license | sj-1997/docker-springboot-postgresql | 27d714a321e0e521485cc17d67308e81e8e25708 | 76d497dfce333ec6eccfed9fa49b64d8e296cbf2 | refs/heads/main | 2023-05-05T03:38:09.063506 | 2021-05-23T18:24:06 | 2021-05-23T18:24:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 270 | java | package com.metin.medium.dockerspringbootpostgresql.repository;
import com.metin.medium.dockerspringbootpostgresql.model.Student;
import org.springframework.data.jpa.repository.JpaRepository;
public interface StudentRepository extends JpaRepository<Student, Long> { }
| [
"[email protected]"
] | |
1c85c2dc59edbd15939ead1db6a775a710ca519d | a4caca3249c2570197df9b3d1d4f99e743bc0898 | /src/main/java/Aio_Timer/ReadCompletionHandle.java | 8a50ec6266589ddaf833d8fa621629790735eb05 | [] | no_license | DyhYunhao/NettyQWZN | 70836c2b31089f8539e33c9a72170505388b670d | 2b1b8960a6124bbf2aefccaf7576ede5b2f6933c | refs/heads/master | 2022-10-27T03:07:56.527094 | 2019-08-05T09:33:55 | 2019-08-05T09:33:55 | 188,777,543 | 1 | 0 | null | 2022-10-04T23:51:50 | 2019-05-27T05:38:27 | Java | UTF-8 | Java | false | false | 2,406 | java | package Aio_Timer;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;
/**
* Created with IntelliJ IDEA.
* User: daiyunhao
* Date: 19-5-27
* Description:
*/
public class ReadCompletionHandle implements CompletionHandler<Integer, ByteBuffer> {
private AsynchronousSocketChannel channel;
public ReadCompletionHandle(AsynchronousSocketChannel channel) {
this.channel = channel;
}
@Override
public void completed(Integer result, ByteBuffer attachment) {
attachment.flip();
byte[] body = new byte[attachment.remaining()];
attachment.get(body);
try {
String req = new String(body, "UTF-8");
System.out.println("the time server receive order: " + req);
String currentTime = "QUERY TIME ORDER".equalsIgnoreCase(req) ?
new java.util.Date(System.currentTimeMillis()).toString() : "BAD ORDER";
doWrite(currentTime);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
private void doWrite(String currentTime){
if (currentTime != null && currentTime.trim().length() > 0){
byte[] bytes = (currentTime).getBytes();
ByteBuffer writeBuffer = ByteBuffer.allocate(bytes.length);
writeBuffer.put(bytes);
writeBuffer.flip();
channel.write(writeBuffer, writeBuffer, new CompletionHandler<Integer, ByteBuffer>() {
@Override
public void completed(Integer result, ByteBuffer attachment) {
if (attachment.hasRemaining()){
channel.write(attachment, attachment, this);
}
}
@Override
public void failed(Throwable exc, ByteBuffer attachment) {
try {
channel.close();
} catch (IOException e) {
e.printStackTrace();
}
}
});
}
}
@Override
public void failed(Throwable exc, ByteBuffer attachment) {
try {
this.channel.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
a48cd97433769ab64143bb002202ee4a7cfd08ef | 2e768183e327712b284e787085dcbd74b0ce6f39 | /src/main/java/com/chenerzhu/crawler/proxy/pool/job/crawler/ProxyListCrawlerJob.java | 4488a264b186b75fe74ee7917828b4d0897e8d2d | [] | no_license | waerly/proxy-pool | 3956c1edae54d75d3d4a325b299895cc813aa06f | d7f40deafd4854243cffd897748359ca86ac271e | refs/heads/master | 2023-04-22T04:06:55.151609 | 2021-04-22T03:53:17 | 2021-04-22T03:53:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,120 | java | package com.chenerzhu.crawler.proxy.pool.job.crawler;
import com.chenerzhu.crawler.proxy.pool.entity.ProxyIp;
import com.chenerzhu.crawler.proxy.pool.entity.WebPage;
import lombok.extern.slf4j.Slf4j;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import java.util.Date;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* @author vincent
* @create 2019-11-11
* https://list.proxylistplus.com/Fresh-HTTP-Proxy-List-1 Slow sometimes
**/
@Slf4j
public class ProxyListCrawlerJob extends AbstractCrawler {
public ProxyListCrawlerJob(ConcurrentLinkedQueue<ProxyIp> proxyIpQueue, String pageUrl) {
super(proxyIpQueue, pageUrl);
}
public ProxyListCrawlerJob(ConcurrentLinkedQueue<ProxyIp> proxyIpQueue, String pageUrl, int pageCount) {
super(proxyIpQueue, pageUrl, pageCount);
}
@Override
public void parsePage(WebPage webPage) {
Elements elements = webPage.getDocument().getElementsByTag("tr");
Element element;
ProxyIp proxyIp;
for (int i = 1; i < elements.size(); i++) {
try {
element = elements.get(i);
proxyIp = new ProxyIp();
proxyIp.setIp(element.child(1).text());
proxyIp.setPort(Integer.parseInt(element.child(2).text()));
proxyIp.setLocation(element.child(4).text());
proxyIp.setType(element.child(3).text());
proxyIp.setAvailable(true);
proxyIp.setCreateTime(new Date());
proxyIp.setLastValidateTime(new Date());
proxyIp.setValidateCount(0);
proxyIpQueue.offer(proxyIp);
} catch (Exception e) {
log.error("ProxyListCrawlerJob error:{0}",e);
}
}
}
public static void main(String[] args) {
ConcurrentLinkedQueue<ProxyIp> proxyIpQueue = new ConcurrentLinkedQueue<>();
ProxyListCrawlerJob proxyListCrawlerJob = new ProxyListCrawlerJob(proxyIpQueue, "https://list.proxylistplus.com/Fresh-HTTP-Proxy-List-1");
proxyListCrawlerJob.run();
}
} | [
"[email protected]"
] | |
928ed61fb99d56a2f45ca2fd12e31474aa94bc7f | a4e42a19be131785ba1db6e229a313f1e021d256 | /app/src/main/java/com/example/mylab/fbtest/AdapterTest.java | 024919eea1b168552c22108eec3de9a446b03447 | [] | no_license | abinsshaji/MyTestLab | a6f55f5766079a6c844fcc909fb2e42370dc286c | 383cc9970369f5c36a30275ec021c427c65c2b09 | refs/heads/master | 2020-03-19T01:16:36.129508 | 2018-05-31T05:09:40 | 2018-05-31T05:09:40 | 135,530,843 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | package com.example.mylab.fbtest;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by Azinova on 1/16/2018.
*/
public class AdapterTest extends RecyclerView.Adapter<AdapterTest.VData>{
@Override
public VData onCreateViewHolder(ViewGroup parent, int viewType) {
return null;
}
@Override
public void onBindViewHolder(VData holder, int position) {
}
@Override
public int getItemCount() {
return 0;
}
public class VData extends RecyclerView.ViewHolder {
public VData(View itemView) {
super(itemView);
}
}
}
| [
"[email protected]"
] | |
a4c0a13cb5ca94556b7538873ad5738dcddaef15 | 7931bec06485a6af5502fe13b712d5616c029854 | /StackPrintBottom.java | be334501d90911c33604e584a528e0b95881cb98 | [] | no_license | UIwarrior/Java-Stack-Queue | 58fc7ab0f2846993f432a22cd3fff277aac4e51f | fcd9e89070003f20233ede48785902aeacd00762 | refs/heads/master | 2022-12-03T23:57:43.019928 | 2020-08-29T07:01:05 | 2020-08-29T07:01:05 | 291,201,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,098 | java | import java.util.*;
// Method to print the fifth element from the bottom of the stack
public class StackPrintBottom {
public static void main(String args[]) {
Stack<Integer> stack = new Stack<>();
System.out.println("Enter total number of element ");
Scanner s = new Scanner(System.in);
int n = s.nextInt();
while (n-- > 0)
stack.push(s.nextInt());
int stackSize = stack.size();
printFifthElementFromStart(stack, stackSize);
}
// considering bottom most element of the stack as 0
static void printFifthElementFromStart(Stack<Integer> stack, int stackSize) {
// Write your code here
System.out.println("stack current"+stack);
if(stackSize < 5){
System.out.println("There are not enough elements in the stack");
}
else{
if(stackSize == 5){
System.out.println(stack.peek());
}
else{
stack.pop();
printFifthElementFromStart(stack, stack.size());
}
}
}
}
| [
"[email protected]"
] | |
1e0ac5df7f07447e52a9a7df46f6fbf38107c828 | a5d5384f8ae51cc867bc67d1ae902cff6728116c | /day5/encog/src/main/java/org/encog/app/quant/util/package-info.java | 1124b62a1677fc76eedf3817c0d403465a17f992 | [] | no_license | joshuajnoble/SecretLifeOfObjects | 66be3bca0559014f224b4dbe7030e7651c6b2805 | aae0f631860d3f01f1252e8a157bb3425c29596b | refs/heads/master | 2020-04-29T03:18:00.959777 | 2015-06-13T15:53:11 | 2015-06-13T15:53:11 | 35,483,832 | 6 | 2 | null | null | null | null | UTF-8 | Java | false | false | 908 | java | /*
* Encog(tm) Core v3.3 - Java Version
* http://www.heatonresearch.com/encog/
* https://github.com/encog/encog-java-core
* Copyright 2008-2014 Heaton Research, 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.
*
* For more information on Heaton Research copyrights, licenses
* and trademarks visit:
* http://www.heatonresearch.com/copyright
*/
package org.encog.app.quant.util;
| [
"[email protected]"
] | |
5d69ecb7cf92c372e73d0d9592d8793d73b68f67 | 8bc240351995ef683397658ba03ae7b061591944 | /PersonTableListener.java | 545e130f36be01c2dcc5682665655b94e110be93 | [] | no_license | NadyTech/Person-Identifiaction-informarmation- | 00abd6a59237db5da1a0eb44300add5881295df6 | 0bdcbe00d0956d60b35dd0217acc751bed83901c | refs/heads/master | 2020-07-02T04:26:12.773850 | 2019-08-09T07:35:12 | 2019-08-09T07:35:12 | 201,415,616 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 96 | java | package App;
public interface PersonTableListener {
public void rowdeleted(int row);
}
| [
"[email protected]"
] | |
d59ecc469e3f0e3bb1107b9c07593c1ecb1195c8 | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/elastic--elasticsearch/636bfe846648b77dfcaed8d46e2d5963b0bc3348/before/VersionedMap.java | 22c8970799111e482adcfb088d75fb1277ed26d0 | [] | 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 | 1,762 | java | /*
* Licensed to Elastic Search and Shay Banon under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. Elastic Search 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.elasticsearch.util.lucene.versioned;
import org.elasticsearch.util.concurrent.ThreadSafe;
/**
* A versioned map, allowing to put version numbers associated with specific
* keys.
* <p/>
* <p>Note. versions can be assumed to be >= 0.
*
* @author kimchy (Shay Banon)
*/
@ThreadSafe
public interface VersionedMap {
/**
* Returns <tt>true</tt> if the versionToCheck is smaller than the current version
* associated with the key. If there is no version associated with the key, then
* it should return <tt>true</tt> as well.
*/
boolean beforeVersion(int key, int versionToCheck);
/**
* Puts (and replaces if it exists) the current key with the provided version.
*/
void putVersion(int key, int version);
/**
* Puts the version with the key only if it is absent.
*/
void putVersionIfAbsent(int key, int version);
/**
* Clears the map.
*/
void clear();
} | [
"[email protected]"
] | |
7cbd546a3b77b048a5bb867442c43b0de2fb2c60 | 637a3c020917598a70a8430c60ae5ec82a7f4c8b | /SpringMyntra/src/main/java/company/myntra/service/LoginServiceImpl.java | 79572730fc4e514674b40ad394ba0722df1cb02b | [] | no_license | vishnu1646-hub/myntra-mini-project | d0e293c868355e34e65dcfd20e9508c1f9f5e25b | e4a9f8b147a99e6d79b66993e8aa8164603498f3 | refs/heads/main | 2023-05-08T23:10:56.914321 | 2021-05-31T05:02:17 | 2021-05-31T05:02:17 | 369,760,664 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 609 | java | package company.myntra.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import company.myntra.dao.*;
@Service("loginService")
public class LoginServiceImpl implements LoginService {
private LoginDAO loginDAO;
@Autowired
@Qualifier("loginDAO")
public void setLoginDAO(LoginDAO loginDAO) {
this.loginDAO = loginDAO;
}
@Override
public boolean checkLogin(String name, String password) {
return loginDAO.checkLogin(name, password);
}
}
| [
"maddy@LAPTOP-LFQHQP4A"
] | maddy@LAPTOP-LFQHQP4A |
22aa935fc17693bba83c04f59737e80e39f81217 | 4ea9c8eeb8902edca767972bc8df2c914efc78f9 | /StatelessJmsSender/src/java/com/hexa/service/JmsSendRemote.java | 79012f47cf5eefa65ba55de34906e31e59e42283 | [] | no_license | ssg1234/ejb | 89b26b8c2a5c120b2290d235802eeee578a6b4aa | db58f150449b89f64aed2c18e51d9b6a53ae7850 | refs/heads/master | 2020-03-07T10:15:28.685626 | 2018-03-30T12:58:49 | 2018-03-30T12:58:49 | 127,427,185 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 402 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.hexa.service;
import javax.ejb.Remote;
/**
*
* @author Hvuser
*/
@Remote
public interface JmsSendRemote {
public String sendMsg(String msg);
public String sendMsg2(Emp emp);
}
| [
"[email protected]"
] | |
9b1e7d8443e2bd48d32cf93f0315457762ea4996 | 157a808f8ea73012a47ba2a56c0b0a632b8bb108 | /src/main/java/com/tyyd/framework/dat/cmd/HttpCmd.java | 6d4a11320b0102fe1e743ed63dda0cef1c3653d3 | [] | no_license | wzh565715020/acws-dat | ff78a118b35b48207629fa27cc761163b38f7ccc | 3e5004f26b38e3afec9693a6da00c1b662d6af7e | refs/heads/master | 2020-04-09T22:34:24.681976 | 2019-03-11T02:40:00 | 2019-03-11T02:40:00 | 160,632,004 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,192 | java | package com.tyyd.framework.dat.cmd;
import com.tyyd.framework.dat.core.commons.utils.StringUtils;
import com.tyyd.framework.dat.core.commons.utils.WebUtils;
import com.tyyd.framework.dat.core.json.JSON;
import java.io.IOException;
import java.util.Map;
/**
* 可以实现子类,定制化返回值
*
*/
public class HttpCmd<Resp extends HttpCmdResponse> extends HttpCmdRequest {
/**
* 子类不要覆盖这个
*/
final public Resp doGet(String url) throws IOException {
Resp resp = null;
String result = null;
try {
result = WebUtils.doGet(url, null);
} catch (IOException e1) {
try {
resp = (Resp) getResponseClass().newInstance();
resp.setSuccess(false);
resp.setMsg("GET ERROR: url=" + url + ", errorMsg=" + e1.getMessage());
return resp;
} catch (InstantiationException e) {
throw new HttpCmdException(e);
} catch (IllegalAccessException e) {
throw new HttpCmdException(e);
}
}
if (StringUtils.isNotEmpty(result)) {
resp = JSON.parse(result, getResponseClass());
}
return resp;
}
protected Class<? extends HttpCmdResponse> getResponseClass() {
return HttpCmdResponse.class;
}
public Resp doPost(String url, Map<String, String> params) {
Resp resp = null;
String result = null;
try {
result = WebUtils.doPost(url, params, 3000, 30000);
} catch (IOException e1) {
try {
resp = (Resp) getResponseClass().newInstance();
resp.setSuccess(false);
resp.setMsg("POST ERROR: url=" + url + ", errorMsg=" + e1.getMessage());
return resp;
} catch (InstantiationException e) {
throw new HttpCmdException(e);
} catch (IllegalAccessException e) {
throw new HttpCmdException(e);
}
}
if (StringUtils.isNotEmpty(result)) {
resp = JSON.parse(result, getResponseClass());
}
return resp;
}
}
| [
"[email protected]"
] | |
a7d5067c4cea4bf28984eeb2b6d4c7829ae759d1 | 837e4607cb5fa609c7eb3ea5b0e3b67336adc77e | /백준_ 1874번_스택 수열.java | 4863e87fec7c614eab0a92c631ae2c5dd8f45c34 | [] | no_license | sujin1515/Algorithm-SW-study | 6a1b501095aa72f2a3446a3220acf681ba1199b2 | 5cb1199444d136318ef026bbeafa67f4f8d7f65b | refs/heads/master | 2020-04-26T16:15:37.088378 | 2019-08-07T03:56:25 | 2019-08-07T03:56:25 | 173,672,742 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,019 | java | import java.io.*;
public class Main{
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder(); // String 연산 시간을 줄이기 위해
int n = Integer.parseInt(br.readLine()); // 입력할 숫자 갯수
int k; // 입력한 값
int max = 0; // stack안 큰 값
int top = 0; // stack의 최상단값
int[] stack = new int[n];
while(n-- > 0){ // 입력받은 값의 수가 0보다 클 때 까지
k = Integer.parseInt(br.readLine());
if(k > max){
for(int i=max+1; i<=k; i++){
stack[top++] = i;
sb.append("+\n"); // push
}
max = k;
}else if(stack[top-1] != k) { // 종료조건(오름차순push에 의해 최상단의 값= k여야함. 아닐경우, 종료)
System.out.println("NO");
return; // 아예 메소드를 종료.
}
// 무조건 한번은 pop을 하기 때문에
top--;
sb.append("-\n"); // pop
}
System.out.println(sb);
}
| [
"[email protected]"
] | |
1c7f7d07c24f456479f2f6066d3bf53a1c651345 | 79e5ba06aecf62b1d51ea99055156814a9e5fc57 | /src/test/java/com/designpattern/abstractPattern/sample1/FactoryMock.java | f53dbb9332c884facf8fcd00ce1cac609862c35c | [] | no_license | dydrb141/design-pattern | fb64afd5a450c31ca507cf399cae5fae22d4b271 | 8d587e2bcf60d4cf6f36641e1fa4a3e75cb95aa4 | refs/heads/master | 2020-04-22T19:54:12.457707 | 2019-11-01T13:47:50 | 2019-11-01T13:47:50 | 170,623,108 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 268 | java | package com.designpattern.abstractPattern.sample1;
public class FactoryMock implements AbstractFactory {
@Override
public ProductA createProductA() {
return new ProductAMock();
}
@Override
public ProductB createProductB() {
return new ProductBMock();
}
}
| [
"[email protected]"
] | |
baf58cf2dac478610e966e27d4824decae02c6da | b4285ae0315ae635dc46dc1f1e62383187ccfc17 | /src/main/java/com/isb/og/security/wsdl/facseg/VerifyCredentialResponse.java | 05acb720794a572ffda5979412eeca7afc09dd18 | [
"Unlicense"
] | permissive | ajzamoraj/OfertaGuiadaVector | 7509b20b18347f71f3a734a7f39210a3c2653fe4 | 48cb301c8db1fe84955214681b0a5d6594162ace | refs/heads/master | 2021-01-23T10:09:09.088586 | 2017-06-01T09:40:21 | 2017-06-01T09:40:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,279 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, vhudson-jaxb-ri-2.1-2
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2017.05.30 at 02:13:32 PM CEST
//
package com.isb.og.security.wsdl.facseg;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "")
@XmlRootElement(name = "verifyCredentialResponse", namespace = "http://www.isban.es/webservices/TECHNICAL_FACADES/Security/F_facseg_security/intranet/ACFACSEGSecurity/v1")
public class VerifyCredentialResponse {
}
| [
"[email protected]"
] | |
999ab4ada389a915c003f390f7c7a9e142d4f7ee | 863acb02a064a0fc66811688a67ce3511f1b81af | /sources/com/google/android/gms/internal/ads/zzdso.java | 6a058467cf2d551790d2b5d098b72819cd85e037 | [
"MIT"
] | permissive | Game-Designing/Custom-Football-Game | 98d33eb0c04ca2c48620aa4a763b91bc9c1b7915 | 47283462b2066ad5c53b3c901182e7ae62a34fc8 | refs/heads/master | 2020-08-04T00:02:04.876780 | 2019-10-06T06:55:08 | 2019-10-06T06:55:08 | 211,914,568 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,304 | java | package com.google.android.gms.internal.ads;
import java.io.IOException;
public final class zzdso extends zzdrr<zzdso> {
/* renamed from: c */
public Integer f28239c = null;
/* renamed from: d */
public String f28240d = null;
/* renamed from: e */
public byte[] f28241e = null;
/* renamed from: a */
public final void mo31670a(zzdrp zzdrp) throws IOException {
Integer num = this.f28239c;
if (num != null) {
zzdrp.mo31669c(1, num.intValue());
}
String str = this.f28240d;
if (str != null) {
zzdrp.mo31664a(2, str);
}
byte[] bArr = this.f28241e;
if (bArr != null) {
zzdrp.mo31666a(3, bArr);
}
super.mo31670a(zzdrp);
}
/* access modifiers changed from: protected */
/* renamed from: c */
public final int mo31672c() {
int c = super.mo31672c();
Integer num = this.f28239c;
if (num != null) {
c += zzdrp.m29990a(1, num.intValue());
}
String str = this.f28240d;
if (str != null) {
c += zzdrp.m29998b(2, str);
}
byte[] bArr = this.f28241e;
if (bArr != null) {
return c + zzdrp.m29999b(3, bArr);
}
return c;
}
}
| [
"[email protected]"
] | |
d96f2f2fe6310679df7435364c0e89cd9100ef81 | 7b40d383ff3c5d51c6bebf4d327c3c564eb81801 | /src/android/support/v4/view/ViewGroupCompat$ViewGroupCompatImpl.java | bda682c28931a000d23bfe2d9775265e36c16e51 | [] | no_license | reverseengineeringer/com.yik.yak | d5de3a0aea7763b43fd5e735d34759f956667990 | 76717e41dab0b179aa27f423fc559bbfb70e5311 | refs/heads/master | 2021-01-20T09:41:04.877038 | 2015-07-16T16:44:44 | 2015-07-16T16:44:44 | 38,577,543 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,004 | java | package android.support.v4.view;
import android.view.View;
import android.view.ViewGroup;
import android.view.accessibility.AccessibilityEvent;
abstract interface ViewGroupCompat$ViewGroupCompatImpl
{
public abstract int getLayoutMode(ViewGroup paramViewGroup);
public abstract int getNestedScrollAxes(ViewGroup paramViewGroup);
public abstract boolean isTransitionGroup(ViewGroup paramViewGroup);
public abstract boolean onRequestSendAccessibilityEvent(ViewGroup paramViewGroup, View paramView, AccessibilityEvent paramAccessibilityEvent);
public abstract void setLayoutMode(ViewGroup paramViewGroup, int paramInt);
public abstract void setMotionEventSplittingEnabled(ViewGroup paramViewGroup, boolean paramBoolean);
public abstract void setTransitionGroup(ViewGroup paramViewGroup, boolean paramBoolean);
}
/* Location:
* Qualified Name: android.support.v4.view.ViewGroupCompat.ViewGroupCompatImpl
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
0bbfecf12fb25fae18662339e0e9184b34ad59ab | 112d8d1221ec749ec9372cf81d19f1bbc052f69d | /HackerRank/src/amit/diu/NumberOfRent.java | 99585260e82971269289366a8800a57fb8fa9590 | [] | no_license | amit39766/workspace | 31ff8ffbe56b1f46bede668cb83b7b0d1a73463d | 7b4bf6a8efd2c5d56eeb22c6478ebf7d2b18e8be | refs/heads/master | 2021-01-11T18:51:10.494970 | 2017-01-21T10:57:55 | 2017-01-21T10:57:55 | 79,639,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 998 | java | package amit.diu;
import java.util.*;
public class NumberOfRent {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
int N,D,K;
N=sc.nextInt();
D=sc.nextInt();
K=sc.nextInt();
ArrayList<ArrayList<Integer>> al=new ArrayList<>();
Set<Integer> mst=new HashSet<>();
//int cons[]=new int[K];
for(int d=1;d<=D;d++){
mst.add(d);
}
for(int n=0;n<N;n++){
ArrayList<Integer> l=new ArrayList<>();
l.add(sc.nextInt());
l.add(sc.nextInt());
al.add(l);
}
for(int k=0;k<K;k++){
Set<Integer> st=new HashSet<>(mst);
int cons=sc.nextInt();
int maxday=0;
for(int i=0;i<al.size();i++){
int temp=0;
Set<Integer> set=new HashSet<>();
for(int j=al.get(i).get(0);j<=al.get(i).get(1);j++){
set.add(j);
temp++;
}
if(temp>=cons){
if(st.containsAll(set)){
maxday+=temp;
st.removeAll(set);
}
}
}
System.out.println(maxday);
}
}
}
| [
"[email protected]"
] | |
d5c964eedc3f9d4fc2143d561ecb236becbd250f | 35d97f0df3415d6d40a3a60c7419c6d0a181f4d9 | /lib_base/src/main/java/org/wcy/android/live/LoadInterface.java | 4d5d56efb0f232b13bf694f41a1dd18d3cb18b1d | [] | no_license | ChaoYongAtom/applibrary | f5e552f98a906393dc2096b22921fcaa3561fbdf | 3955a765641d68f16c9881322361135c1d312ffa | refs/heads/master | 2021-05-10T12:05:01.994686 | 2020-03-15T14:03:45 | 2020-03-15T14:03:45 | 118,430,158 | 4 | 1 | null | null | null | null | UTF-8 | Java | false | false | 266 | java | package org.wcy.android.live;
public interface LoadInterface {
void dataObserver();
void showSuccess(int state, String msg);
void showLoading();
void showError(int state, String msg);
String getClassName();
String getStateEventKey();
}
| [
"[email protected]"
] | |
0a44392c18d982ec26aff01950c63eded0054d34 | ea2149988e0cefcdff849d2a8767b0d4e4dcc3b3 | /vendor/haocheng/proprietary/3rd-party/apk_and_code/blackview/DK_AWCamera/feature/mode/hctfacebeauty/src/com/mediatek/camera/feature/mode/hctfacebeauty/device/IHctFaceBeautyDeviceController.java | fb28fcb4d0f72c68ec271ff1356295139f8c231c | [
"Apache-2.0"
] | permissive | sam1017/CameraFramework | 28ac2d4f2d0d62185255bb2bea2eedb3aa190804 | 9391f3b1bfbeaa51000df8e2df6ff7086178dfbc | refs/heads/master | 2023-06-16T10:48:29.520119 | 2021-07-06T03:15:13 | 2021-07-06T03:15:13 | 383,324,836 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,805 | java | /*
* Copyright Statement:
*
* This software/firmware and related documentation ("MediaTek Software") are
* protected under relevant copyright laws. The information contained herein is
* confidential and proprietary to MediaTek Inc. and/or its licensors. Without
* the prior written permission of MediaTek inc. and/or its licensors, any
* reproduction, modification, use or disclosure of MediaTek Software, and
* information contained herein, in whole or in part, shall be strictly
* prohibited.
*
* MediaTek Inc. (C) 2016. All rights reserved.
*
* BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
* THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
* RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
* ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
* WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
* NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
* RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
* INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
* TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
* RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
* OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
* SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
* RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
* STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
* ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
* RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
* MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
* CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
*
* The following software/firmware and/or related documentation ("MediaTek
* Software") have been modified by MediaTek Inc. All revisions are subject to
* any receiver's applicable license agreements with MediaTek Inc.
*/
package com.mediatek.camera.feature.mode.hctfacebeauty.device;
import android.graphics.ImageFormat;
import android.net.Uri;
import com.mediatek.camera.feature.mode.hctfacebeauty.HctFaceBeautyDeviceInfo;
import com.mediatek.camera.common.utils.Size;
import javax.annotation.Nonnull;
/**
* Define the interaction apis between {@link HctFaceBeautyMode} and Camera Device,
* include {@link CameraProxy} and {@link Camera2Proxy}.
*
* This make photo mode no need to care the implementation of camera device,
* photo mode control flow should compatible {@link CameraProxy} and {@link Camera2Proxy}
*/
public interface IHctFaceBeautyDeviceController {
/**
* Used for wrapping data callback.
*/
class DataCallbackInfo {
public byte[] data;
public boolean needUpdateThumbnail;
public boolean needRestartPreview;
public int mBufferFormat = ImageFormat.JPEG;
public int imageWidth;
public int imageHeight;
}
/**
* This interface is used to callback uri to mode.
*/
interface CaptureImageSavedCallback {
/**
* After saved image notify mode.
* @param saved uri.
*/
void onFinishSaved(Uri uri);
}
/**
* This interface is used to callback jpeg data to mode.
*/
interface CaptureDataCallback {
/**
* Notify jpeg data is generated.
* @param dataCallbackInfo data callback info.
*/
void onDataReceived(DataCallbackInfo dataCallbackInfo);
/**
* When post view callback will notify.
* @param data post view data.
*/
void onPostViewCallback(byte[] data);
}
/**
* This callback to notify device state.
*/
interface DeviceCallback {
/**
* Notified when camera opened done with camera id.
* @param cameraId the camera is opened.
*/
void onCameraOpened(String cameraId);
/**
* Notified before do close camera.
*/
void beforeCloseCamera();
/**
* Notified call stop preview immediately.
*/
void afterStopPreview();
/**
* When preview data is received,will fired this function.
* @param data the preview data.
* @param format the preview format.
*/
void onPreviewCallback(byte[] data, int format);
void onCaptureCallback();
}
/**
* This callback is used for notify camera is opened,you can use it for get parameters..
*/
interface PreviewSizeCallback {
/**
* When camera is opened will be called.
* @param previewSize current preview size.
*/
void onPreviewSizeReady(Size previewSize);
}
/**
* should update device manager when mode resume, before open camera.
*/
void queryCameraDeviceManager();
/**
* open camera with specified camera id.
* @param info the camera info which will be opened.
*/
void openCamera(HctFaceBeautyDeviceInfo info);
/**
* update preview surface.
* @param surfaceObject surface holder instance.
*/
void updatePreviewSurface(Object surfaceObject);
/**
* Set a callback for device.
* @param callback the device callback.
*/
void setDeviceCallback(DeviceCallback callback);
/**
* For API1 will directly call start preview.
* For API2 will first create capture session and then set repeating requests.
*/
void startPreview();
/**
* For API1 will directly call stop preview.
* For API2 will call session's abort captures.
*/
void stopPreview();
/**
* For API1 will directly call takePicture.
* For API2 will call STILL_CAPTURE capture.
*
* @param callback jpeg data callback.
*/
void takePicture(@Nonnull IHctFaceBeautyDeviceController.CaptureDataCallback callback);
/**
* update current GSensor orientation.the value will be 0/90/180/270;
* @param orientation current GSensor orientation.
*/
void updateGSensorOrientation(int orientation);
/**
* close camera.
* @param sync whether need sync call.
*/
void closeCamera(boolean sync);
/**
* abort capture and close session;
*/
void closeSession();
/**
* Get the preview size with target ratio.
* @param targetRatio current ratio.
* @return current preview size.
*/
Size getPreviewSize(double targetRatio);
/**
* Set a camera opened callback.
* @param callback camera opened callback.
*/
void setPreviewSizeReadyCallback(PreviewSizeCallback callback);
/**
* Set the new picture size.
* @param size current picture size.
*/
void setPictureSize(Size size);
/**
* Check whether can take picture or not.
* @return true means can take picture; otherwise can not take picture.
*/
boolean isReadyForCapture();
/**
* When don't need the device controller need destroy the device controller.
* such as handler.
*/
void destroyDeviceController();
/**
* Set ZSD status
*/
void setZSDStatus(String value);
/**
* Set image format
*/
void setFormat(String value);
void setSavedDataCallback(CaptureImageSavedCallback callback);
void setBeautyParameter(int smooth,int lighten,int ruddy,int slender);
} | [
"[email protected]"
] | |
f5a559b8861287b343157d71f7a543d19c0b7092 | ada12b5583dd3799cfbfe2b5fb240dadf1763686 | /Maximum element in each row/Main.java | caa6d88c61df8b6611e6e90caac8597ea41b3d5a | [] | no_license | Shweta-xyz/Playground | d7a33ba5d530076e5d76087a3c8f202fac8a3961 | c9a894577a7fc105c69d4976f8fcd0cf62101246 | refs/heads/master | 2022-08-21T05:17:03.829064 | 2020-05-28T15:33:12 | 2020-05-28T15:33:12 | 264,888,685 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 288 | java | #include<iostream>
using namespace std;
int main()
{
int m,n,i,j;
cin>>m>>n;
int a[m][n];
for(i=0;i<m;i++)
{for(j=0;j<n;j++)
cin>>a[i][j];
}
for(i=0;i<m;i++)
{int max=0;
for(j=0;j<n;j++)
{
if(a[i][j]>max)
max=a[i][j];
}
cout<<max<<endl;
}
} | [
"[email protected]"
] | |
aeafe3a67e176a35f642f163ffc161d26af06dc7 | 3950af22f175dbbf2c40bfb3ad51c7788a1ec536 | /core/src/main/java/com/google/leafcoin/protocols/channels/PaymentChannelClient.java | cf2e6064a2d41db5d0121ce4e41eb3fa7eeb5c59 | [
"Apache-2.0"
] | permissive | leafcoin/leafcoinj-alice | 9a58cc7287615948e280b6c9f8ef181472aa8127 | da78435f8f8c27ebf4f68b1c854e53f86deec240 | refs/heads/master | 2016-09-06T18:43:44.491689 | 2014-03-30T12:30:16 | 2014-03-30T12:30:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,054 | java | package com.google.leafcoin.protocols.channels;
import com.google.leafcoin.core.*;
import com.google.leafcoin.protocols.channels.PaymentChannelCloseException.CloseReason;
import com.google.leafcoin.utils.Threading;
import com.google.common.annotations.VisibleForTesting;
import com.google.protobuf.ByteString;
import net.jcip.annotations.GuardedBy;
import org.bitcoin.paymentchannel.Protos;
import org.slf4j.LoggerFactory;
import java.math.BigInteger;
import java.util.concurrent.locks.ReentrantLock;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
/**
* <p>A class which handles most of the complexity of creating a payment channel connection by providing a
* simple in/out interface which is provided with protobufs from the server and which generates protobufs which should
* be sent to the server.</p>
*
* <p>Does all required verification of server messages and properly stores state objects in the wallet-attached
* {@link StoredPaymentChannelClientStates} so that they are automatically closed when necessary and refund
* transactions are not lost if the application crashes before it unlocks.</p>
*
* <p>Though this interface is largely designed with stateful protocols (eg simple TCP connections) in mind, it is also
* possible to use it with stateless protocols (eg sending protobufs when required over HTTP headers). In this case, the
* "connection" translates roughly into the server-client relationship. See the javadocs for specific functions for more
* details.</p>
*/
public class PaymentChannelClient {
private static final org.slf4j.Logger log = LoggerFactory.getLogger(PaymentChannelClient.class);
protected final ReentrantLock lock = Threading.lock("channelclient");
/**
* Implements the connection between this client and the server, providing an interface which allows messages to be
* sent to the server, requests for the connection to the server to be closed, and a callback which occurs when the
* channel is fully open.
*/
public interface ClientConnection {
/**
* <p>Requests that the given message be sent to the server. There are no blocking requirements for this method,
* however the order of messages must be preserved.</p>
*
* <p>If the send fails, no exception should be thrown, however
* {@link PaymentChannelClient#connectionClosed()} should be called immediately. In the case of messages which
* are a part of initialization, initialization will simply fail and the refund transaction will be broadcasted
* when it unlocks (if necessary). In the case of a payment message, the payment will be lost however if the
* channel is resumed it will begin again from the channel value <i>after</i> the failed payment.</p>
*
* <p>Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy</p>
*/
public void sendToServer(Protos.TwoWayChannelMessage msg);
/**
* <p>Requests that the connection to the server be closed. For stateless protocols, note that after this call,
* no more messages should be received from the server and this object is no longer usable. A
* {@link PaymentChannelClient#connectionClosed()} event should be generated immediately after this call.</p>
*
* <p>Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy</p>
*
* @param reason The reason for the closure, see the individual values for more details.
* It is usually safe to ignore this and treat any value below
* {@link CloseReason#CLIENT_REQUESTED_CLOSE} as "unrecoverable error" and all others as
* "try again once and see if it works then"
*/
public void destroyConnection(CloseReason reason);
/**
* <p>Indicates the channel has been successfully opened and
* {@link PaymentChannelClient#incrementPayment(java.math.BigInteger)} may be called at will.</p>
*
* <p>Called while holding a lock on the {@link PaymentChannelClient} object - be careful about reentrancy</p>
*/
public void channelOpen();
}
@GuardedBy("lock") private final ClientConnection conn;
// Used to keep track of whether or not the "socket" ie connection is open and we can generate messages
@VisibleForTesting @GuardedBy("lock") boolean connectionOpen = false;
// The state object used to step through initialization and pay the server
@GuardedBy("lock") private PaymentChannelClientState state;
// The step we are at in initialization, this is partially duplicated in the state object
private enum InitStep {
WAITING_FOR_CONNECTION_OPEN,
WAITING_FOR_VERSION_NEGOTIATION,
WAITING_FOR_INITIATE,
WAITING_FOR_REFUND_RETURN,
WAITING_FOR_CHANNEL_OPEN,
CHANNEL_OPEN
}
@GuardedBy("lock") private InitStep step = InitStep.WAITING_FOR_CONNECTION_OPEN;
// Will either hold the StoredClientChannel of this channel or null after connectionOpen
private StoredClientChannel storedChannel;
// An arbitrary hash which identifies this channel (specified by the API user)
private final Sha256Hash serverId;
// The wallet associated with this channel
private final Wallet wallet;
// Information used during channel initialization to send to the server or check what the server sends to us
private final ECKey myKey;
private final BigInteger maxValue;
/**
* <p>The maximum amount of time for which we will accept the server locking up our funds for the multisig
* contract.</p>
*
* <p>Note that though this is not final, it is in all caps because it should generally not be modified unless you
* have some guarantee that the server will not request at least this (channels will fail if this is too small).</p>
*
* <p>24 hours is the default as it is expected that clients limit risk exposure by limiting channel size instead of
* limiting lock time when dealing with potentially malicious servers.</p>
*/
public long MAX_TIME_WINDOW = 24*60*60;
/**
* Constructs a new channel manager which waits for {@link PaymentChannelClient#connectionOpen()} before acting.
*
* @param wallet The wallet which will be paid from, and where completed transactions will be committed.
* Must already have a {@link StoredPaymentChannelClientStates} object in its extensions set.
* @param myKey A freshly generated keypair used for the multisig contract and refund output.
* @param maxValue The maximum value the server is allowed to request that we lock into this channel until the
* refund transaction unlocks. Note that if there is a previously open channel, the refund
* transaction used in this channel may be larger than maxValue. Thus, maxValue is not a method for
* limiting the amount payable through this channel.
* @param serverId An arbitrary hash representing this channel. This must uniquely identify the server. If an
* existing stored channel exists in the wallet's {@link StoredPaymentChannelClientStates}, then an
* attempt will be made to resume that channel.
* @param conn A callback listener which represents the connection to the server (forwards messages we generate to
* the server)
*/
public PaymentChannelClient(Wallet wallet, ECKey myKey, BigInteger maxValue, Sha256Hash serverId, ClientConnection conn) {
this.wallet = checkNotNull(wallet);
this.myKey = checkNotNull(myKey);
this.maxValue = checkNotNull(maxValue);
this.serverId = checkNotNull(serverId);
this.conn = checkNotNull(conn);
}
@GuardedBy("lock")
private void receiveInitiate(Protos.Initiate initiate, BigInteger contractValue) throws VerificationException, ValueOutOfRangeException {
log.info("Got INITIATE message, providing refund transaction");
state = new PaymentChannelClientState(wallet, myKey,
new ECKey(null, initiate.getMultisigKey().toByteArray()),
contractValue, initiate.getExpireTimeSecs());
state.initiate();
step = InitStep.WAITING_FOR_REFUND_RETURN;
Protos.ProvideRefund.Builder provideRefundBuilder = Protos.ProvideRefund.newBuilder()
.setMultisigKey(ByteString.copyFrom(myKey.getPubKey()))
.setTx(ByteString.copyFrom(state.getIncompleteRefundTransaction().bitcoinSerialize()));
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setProvideRefund(provideRefundBuilder)
.setType(Protos.TwoWayChannelMessage.MessageType.PROVIDE_REFUND)
.build());
}
@GuardedBy("lock")
private void receiveRefund(Protos.TwoWayChannelMessage msg) throws VerificationException {
checkState(step == InitStep.WAITING_FOR_REFUND_RETURN && msg.hasReturnRefund());
log.info("Got RETURN_REFUND message, providing signed contract");
Protos.ReturnRefund returnedRefund = msg.getReturnRefund();
state.provideRefundSignature(returnedRefund.getSignature().toByteArray());
step = InitStep.WAITING_FOR_CHANNEL_OPEN;
// Before we can send the server the contract (ie send it to the network), we must ensure that our refund
// transaction is safely in the wallet - thus we store it (this also keeps it up-to-date when we pay)
state.storeChannelInWallet(serverId);
Protos.ProvideContract.Builder provideContractBuilder = Protos.ProvideContract.newBuilder()
.setTx(ByteString.copyFrom(state.getMultisigContract().bitcoinSerialize()));
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setProvideContract(provideContractBuilder)
.setType(Protos.TwoWayChannelMessage.MessageType.PROVIDE_CONTRACT)
.build());
}
@GuardedBy("lock")
private void receiveChannelOpen() throws VerificationException {
checkState(step == InitStep.WAITING_FOR_CHANNEL_OPEN || (step == InitStep.WAITING_FOR_INITIATE && storedChannel != null), step);
log.info("Got CHANNEL_OPEN message, ready to pay");
if (step == InitStep.WAITING_FOR_INITIATE)
state = new PaymentChannelClientState(storedChannel, wallet);
step = InitStep.CHANNEL_OPEN;
// channelOpen should disable timeouts, but
// TODO accomodate high latency between PROVIDE_CONTRACT and here
conn.channelOpen();
}
/**
* Called when a message is received from the server. Processes the given message and generates events based on its
* content.
*/
public void receiveMessage(Protos.TwoWayChannelMessage msg) {
lock.lock();
try {
checkState(connectionOpen);
// If we generate an error, we set errorBuilder and closeReason and break, otherwise we return
Protos.Error.Builder errorBuilder;
CloseReason closeReason;
try {
switch (msg.getType()) {
case SERVER_VERSION:
checkState(step == InitStep.WAITING_FOR_VERSION_NEGOTIATION && msg.hasServerVersion());
// Server might send back a major version lower than our own if they want to fallback to a lower version
// We can't handle that, so we just close the channel
if (msg.getServerVersion().getMajor() != 0) {
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.NO_ACCEPTABLE_VERSION);
closeReason = CloseReason.NO_ACCEPTABLE_VERSION;
break;
}
log.info("Got version handshake, awaiting INITIATE or resume CHANNEL_OPEN");
step = InitStep.WAITING_FOR_INITIATE;
return;
case INITIATE:
checkState(step == InitStep.WAITING_FOR_INITIATE && msg.hasInitiate());
Protos.Initiate initiate = msg.getInitiate();
checkState(initiate.getExpireTimeSecs() > 0 && initiate.getMinAcceptedChannelSize() >= 0);
if (initiate.getExpireTimeSecs() > Utils.now().getTime()/1000 + MAX_TIME_WINDOW) {
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.TIME_WINDOW_TOO_LARGE);
closeReason = CloseReason.TIME_WINDOW_TOO_LARGE;
break;
}
BigInteger minChannelSize = BigInteger.valueOf(initiate.getMinAcceptedChannelSize());
if (maxValue.compareTo(minChannelSize) < 0) {
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.CHANNEL_VALUE_TOO_LARGE);
closeReason = CloseReason.SERVER_REQUESTED_TOO_MUCH_VALUE;
break;
}
receiveInitiate(initiate, maxValue);
return;
case RETURN_REFUND:
receiveRefund(msg);
return;
case CHANNEL_OPEN:
receiveChannelOpen();
return;
case CLOSE:
conn.destroyConnection(CloseReason.SERVER_REQUESTED_CLOSE);
return;
case ERROR:
checkState(msg.hasError());
log.error("Server sent ERROR {} with explanation {}", msg.getError().getCode().name(),
msg.getError().hasExplanation() ? msg.getError().getExplanation() : "");
conn.destroyConnection(CloseReason.REMOTE_SENT_ERROR);
return;
default:
log.error("Got unknown message type or type that doesn't apply to clients.");
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.SYNTAX_ERROR);
closeReason = CloseReason.REMOTE_SENT_INVALID_MESSAGE;
break;
}
} catch (VerificationException e) {
log.error("Caught verification exception handling message from server", e);
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.BAD_TRANSACTION)
.setExplanation(e.getMessage());
closeReason = CloseReason.REMOTE_SENT_INVALID_MESSAGE;
} catch (ValueOutOfRangeException e) {
log.error("Caught value out of range exception handling message from server", e);
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.BAD_TRANSACTION)
.setExplanation(e.getMessage());
closeReason = CloseReason.REMOTE_SENT_INVALID_MESSAGE;
} catch (IllegalStateException e) {
log.error("Caught illegal state exception handling message from server", e);
errorBuilder = Protos.Error.newBuilder()
.setCode(Protos.Error.ErrorCode.SYNTAX_ERROR);
closeReason = CloseReason.REMOTE_SENT_INVALID_MESSAGE;
}
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setError(errorBuilder)
.setType(Protos.TwoWayChannelMessage.MessageType.ERROR)
.build());
conn.destroyConnection(closeReason);
} finally {
lock.unlock();
}
}
/**
* <p>Called when the connection terminates. Notifies the {@link StoredClientChannel} object that we can attempt to
* resume this channel in the future and stops generating messages for the server.</p>
*
* <p>For stateless protocols, this translates to a client not using the channel for the immediate future, but
* intending to reopen the channel later. There is likely little reason to use this in a stateless protocol.</p>
*
* <p>Note that this <b>MUST</b> still be called even after either
* {@link ClientConnection#destroyConnection(CloseReason)} or
* {@link PaymentChannelClient#close()} is called to actually handle the connection close logic.</p>
*/
public void connectionClosed() {
lock.lock();
try {
connectionOpen = false;
if (state != null)
state.disconnectFromChannel();
} finally {
lock.unlock();
}
}
/**
* <p>Closes the connection, notifying the server it should close the channel by broadcasting the most recent payment
* transaction.</p>
*
* <p>Note that this only generates a CLOSE message for the server and calls
* {@link ClientConnection#destroyConnection(CloseReason)} to close the connection, it does not
* actually handle connection close logic, and {@link PaymentChannelClient#connectionClosed()} must still be called
* after the connection fully closes.</p>
*
* @throws IllegalStateException If the connection is not currently open (ie the CLOSE message cannot be sent)
*/
public void close() throws IllegalStateException {
lock.lock();
try {
checkState(connectionOpen);
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setType(Protos.TwoWayChannelMessage.MessageType.CLOSE)
.build());
conn.destroyConnection(CloseReason.CLIENT_REQUESTED_CLOSE);
} finally {
lock.unlock();
}
}
/**
* <p>Called to indicate the connection has been opened and messages can now be generated for the server.</p>
*
* <p>Attempts to find a channel to resume and generates a CLIENT_VERSION message for the server based on the
* result.</p>
*/
public void connectionOpen() {
lock.lock();
try {
connectionOpen = true;
StoredPaymentChannelClientStates channels = (StoredPaymentChannelClientStates) wallet.getExtensions().get(StoredPaymentChannelClientStates.EXTENSION_ID);
if (channels != null)
storedChannel = channels.getUsableChannelForServerID(serverId);
step = InitStep.WAITING_FOR_VERSION_NEGOTIATION;
Protos.ClientVersion.Builder versionNegotiationBuilder = Protos.ClientVersion.newBuilder()
.setMajor(0).setMinor(1);
if (storedChannel != null) {
versionNegotiationBuilder.setPreviousChannelContractHash(ByteString.copyFrom(storedChannel.contract.getHash().getBytes()));
log.info("Begun version handshake, attempting to reopen channel with contract hash {}", storedChannel.contract.getHash());
} else
log.info("Begun version handshake creating new channel");
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setType(Protos.TwoWayChannelMessage.MessageType.CLIENT_VERSION)
.setClientVersion(versionNegotiationBuilder)
.build());
} finally {
lock.unlock();
}
}
/**
* <p>Gets the {@link PaymentChannelClientState} object which stores the current state of the connection with the
* server.</p>
*
* <p>Note that if you call any methods which update state directly the server will not be notified and channel
* initialization logic in the connection may fail unexpectedly.</p>
*/
public PaymentChannelClientState state() {
lock.lock();
try {
return state;
} finally {
lock.unlock();
}
}
/**
* Increments the total value which we pay the server.
*
* @param size How many satoshis to increment the payment by (note: not the new total).
* @throws ValueOutOfRangeException If the size is negative or would pay more than this channel's total value
* ({@link PaymentChannelClientConnection#state()}.getTotalValue())
* @throws IllegalStateException If the channel has been closed or is not yet open
* (see {@link PaymentChannelClientConnection#getChannelOpenFuture()} for the second)
*/
public void incrementPayment(BigInteger size) throws ValueOutOfRangeException, IllegalStateException {
lock.lock();
try {
if (state() == null || !connectionOpen || step != InitStep.CHANNEL_OPEN)
throw new IllegalStateException("Channel is not fully initialized/has already been closed");
byte[] signature = state().incrementPaymentBy(size);
Protos.UpdatePayment.Builder updatePaymentBuilder = Protos.UpdatePayment.newBuilder()
.setSignature(ByteString.copyFrom(signature))
.setClientChangeValue(state.getValueRefunded().longValue());
conn.sendToServer(Protos.TwoWayChannelMessage.newBuilder()
.setUpdatePayment(updatePaymentBuilder)
.setType(Protos.TwoWayChannelMessage.MessageType.UPDATE_PAYMENT)
.build());
} finally {
lock.unlock();
}
}
}
| [
"root@ubuntu.(none)"
] | root@ubuntu.(none) |
faab0057985e8273fb79478e2d3a81a088ea3387 | b5ecc6a5c43f6ad969c6bc6db1a7e4065590f1fa | /src/offer/Demo15.java | 91d91c4d518c43d33fb9fb29244c0f96e70aae10 | [] | no_license | tongji4m3/LeetCode | a05eda76a7e9485bd65c3b2c8c0ced1634d3ab13 | 7c9c05df1555bdf86482d5a353098ad0361b1780 | refs/heads/master | 2021-06-17T23:12:59.431409 | 2021-02-27T08:19:56 | 2021-02-27T08:19:56 | 176,051,933 | 4 | 0 | null | 2020-08-31T04:20:02 | 2019-03-17T03:29:28 | Java | UTF-8 | Java | false | false | 207 | java | package offer;
public class Demo15 {
public int NumberOf1(int n) {
int count = 0;
while (n != 0) {
n &= (n - 1);
count++;
}
return count;
}
}
| [
"[email protected]"
] | |
7bc8733a7dd39d37dff561365a63a995271b35ae | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/25/25_7dccc6406965c2dbfb126272e35ea689d4c39768/ListWithDetailsModel/25_7dccc6406965c2dbfb126272e35ea689d4c39768_ListWithDetailsModel_t.java | 766d127c39bc2b6dca54256dc250e8b6ec8424cf | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 4,771 | java | package org.ovirt.engine.ui.uicommonweb.models;
import java.util.Collections;
import org.ovirt.engine.core.compat.*;
import org.ovirt.engine.ui.uicompat.*;
import org.ovirt.engine.core.common.businessentities.*;
import org.ovirt.engine.core.common.vdscommands.*;
import org.ovirt.engine.core.common.queries.*;
import org.ovirt.engine.core.common.action.*;
import org.ovirt.engine.ui.frontend.*;
import org.ovirt.engine.ui.uicommonweb.*;
import org.ovirt.engine.ui.uicommonweb.models.*;
import org.ovirt.engine.core.common.*;
import org.ovirt.engine.ui.uicommonweb.models.hosts.*;
import org.ovirt.engine.core.common.businessentities.*;
import org.ovirt.engine.ui.uicommonweb.*;
@SuppressWarnings("unused")
public class ListWithDetailsModel extends SearchableListModel
{
private java.util.List<EntityModel> detailModels;
public java.util.List<EntityModel> getDetailModels()
{
return detailModels;
}
public void setDetailModels(java.util.List<EntityModel> value)
{
if (detailModels != value)
{
detailModels = value;
OnPropertyChanged(new PropertyChangedEventArgs("DetailModels"));
}
}
private EntityModel activeDetailModel;
public EntityModel getActiveDetailModel()
{
return activeDetailModel;
}
public void setActiveDetailModel(EntityModel value)
{
if (activeDetailModel != value)
{
ActiveDetailModelChanging(value, getActiveDetailModel());
activeDetailModel = value;
ActiveDetailModelChanged();
OnPropertyChanged(new PropertyChangedEventArgs("ActiveDetailModel"));
}
}
public ListWithDetailsModel()
{
InitDetailModels();
}
protected void InitDetailModels()
{
}
protected void UpdateDetailsAvailability()
{
}
private void ActiveDetailModelChanging(EntityModel newValue, EntityModel oldValue)
{
//Make sure we had set an entity property of details model.
if (oldValue != null)
{
oldValue.setEntity(null);
if (oldValue instanceof SearchableListModel)
{
((SearchableListModel)oldValue).EnsureAsyncSearchStopped();
}
}
if (newValue != null)
{
newValue.setEntity(ProvideDetailModelEntity(getSelectedItem()));
}
}
protected Object ProvideDetailModelEntity(Object selectedItem)
{
return selectedItem;
}
@Override
protected void OnSelectedItemChanged()
{
super.OnSelectedItemChanged();
if (getSelectedItem() != null)
{
//Try to choose default (first) detail model.
UpdateDetailsAvailability();
if (getDetailModels() != null)
{
if ((getActiveDetailModel() != null && !getActiveDetailModel().getIsAvailable()) || getActiveDetailModel() == null)
{
//ActiveDetailModel = DetailModels.FirstOrDefault(AvailabilityDecorator.GetIsAvailable);
EntityModel model = null;
for (EntityModel item : getDetailModels())
{
if (item.getIsAvailable())
{
model = item;
break;
}
}
setActiveDetailModel(model);
}
}
//if (DetailModels != null && ActiveDetailModel == null)
//{
// ActiveDetailModel = DetailModels.FirstOrDefault();
//}
}
else
{
//If selected item become null, make sure we stop all activity on an active detail model.
if (getActiveDetailModel() != null && getActiveDetailModel() instanceof SearchableListModel)
{
((SearchableListModel)getActiveDetailModel()).EnsureAsyncSearchStopped();
}
}
// Synchronize selected item with the entity of an active details model.
// if (ActiveDetailModel != null)
// {
// ActiveDetailModel.Entity = ProvideDetailModelEntity(SelectedItem);
// }
// Synchronize all detail models.
// TODO: synchronize only the active detail model after changing current gwt sub-tab presenters beahivour
// (currently the presenters activate all detail models instead of activating only the active detail model).
if (getSelectedItem() != null)
{
for (EntityModel detailModel : getDetailModels())
{
if (detailModel instanceof HostInterfaceListModel)
{
((HostInterfaceListModel)detailModel).setEntity((VDS)ProvideDetailModelEntity(getSelectedItem()));
continue;
}
detailModel.setEntity(ProvideDetailModelEntity(getSelectedItem()));
}
}
}
protected void ActiveDetailModelChanged()
{
}
@Override
public void EnsureAsyncSearchStopped()
{
super.EnsureAsyncSearchStopped();
if (getDetailModels() != null)
{
//Stop search on all list models.
for (EntityModel model : getDetailModels())
{
if (model instanceof SearchableListModel)
{
SearchableListModel listModel = (SearchableListModel)model;
listModel.EnsureAsyncSearchStopped();
}
}
}
}
}
| [
"[email protected]"
] | |
ac0d42d1a7d2f6c73ae347764a8a336d04d2a7cc | 0af8b92686a58eb0b64e319b22411432aca7a8f3 | /large-multiproject/project55/src/test/java/org/gradle/test/performance55_1/Test55_39.java | 77a8ab7c408d74bd59e5ffde494975d28fc54405 | [] | no_license | gradle/performance-comparisons | b0d38db37c326e0ce271abebdb3c91769b860799 | e53dc7182fafcf9fedf07920cbbea8b40ee4eef4 | refs/heads/master | 2023-08-14T19:24:39.164276 | 2022-11-24T05:18:33 | 2022-11-24T05:18:33 | 80,121,268 | 17 | 15 | null | 2022-09-30T08:04:35 | 2017-01-26T14:25:33 | null | UTF-8 | Java | false | false | 289 | java | package org.gradle.test.performance55_1;
import static org.junit.Assert.*;
public class Test55_39 {
private final Production55_39 production = new Production55_39("value");
@org.junit.Test
public void test() {
assertEquals(production.getProperty(), "value");
}
} | [
"[email protected]"
] | |
644f9ec65db237438895a54ae92e9f8cdb429c01 | d3034d8c27d96144651827a7b1b5e80daf10fd6a | /amap-data-cp-theater/src/main/java/com/amap/data/save/alimama/AlimamaSave.java | 41d1322e646d59c57204ee2ac30caf89f3597ffc | [] | no_license | javaxiaomangren/amap-data-cp | 5274b724dca9d95f3c3c55c1fc765ebbfdb583c6 | d3924a1765eb1e3d635338962c621fbd60e34223 | refs/heads/master | 2021-01-10T22:12:44.724500 | 2014-01-07T09:41:22 | 2014-01-07T09:41:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,277 | java | /**
* 2013-5-23
*/
package com.amap.data.save.alimama;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import com.amap.data.save.Save;
import com.amap.data.save.SaveHelper;
import com.mongodb.util.JSON;
public class AlimamaSave extends Save{
@Override
public void init(String cp) {
}
//只有有效可订餐时,才拼装from和idDictionaries,否则只拼装from信息
@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
protected String getCombineJson(Object poiid, List<Map> ids, String cp,
boolean hasDeep) {
LinkedHashMap combineMap = new LinkedHashMap();
combineMap.put("poiid", poiid);
//获取深度信息
Map deep = getNewestDeep(combineMap, ids, cp);
Object id = deep.get("id");
Map result = new HashMap();
result.put("cp", cp);
result.put("id", id);
result.put("update_flag", deep.get(update_flag));
combineMap.put("from", SaveHelper.getFrom(result, cp));
if(assertValid(deep)){
//深度有效的话,才拼装idDictionaries
combineMap = combineidDictionaries(combineMap, cp);
//深度有效的情况下,拼装spec字段13.08.01:xuena add
combineMap = getSpecMap(combineMap, deep, cp);
}
return JSON.serialize(combineMap);
}
/**
* 拼装spec字段
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
private LinkedHashMap getSpecMap(LinkedHashMap combineMap, Map deep, String cp){
Object deepinfo = deep.get("deep");
if(deepinfo == null || deepinfo.equals("")){
return combineMap;
}
Map deepMap = SaveHelper.transferToSmall((Map) JSON.parse(deepinfo.toString()));
Map spec = (Map) JSON.parse(deepMap.get("spec").toString());
combineMap.put("spec", spec);
return combineMap;
}
@SuppressWarnings("rawtypes")
@Override
protected Map getValidDeep(List<Map> deeps){
//首先判断是否存在都有效的深度信息
Object assertDeep = assertValidDeep(deeps);
Map newestDeep = deeps.get(0);
if(assertDeep != null){
//存在有效的深度信息,选择最新的有效深度
newestDeep = (Map) assertDeep;
for(Map deep : deeps){
if(assertValid(deep) && deep.get("updatetime")
.toString()
.compareToIgnoreCase(
newestDeep.get("updatetime").toString()) > 0){
newestDeep = deep;
}
}
}else{
for (Map deep : deeps) {
if (deep.get("updatetime")
.toString()
.compareToIgnoreCase(
newestDeep.get("updatetime").toString()) > 0) {
newestDeep = deep;
}
}
}
return newestDeep;
}
//判断是否存在都有效的深度信息
@SuppressWarnings("rawtypes")
private Object assertValidDeep(List<Map> deeps){
for(Map deep : deeps){
if(assertValid(deep)){
return deep;
}
}
return null;
}
@SuppressWarnings("rawtypes")
private boolean assertValid(Map deep){
Object deepinfo = deep.get("deep");
if(deepinfo == null || deepinfo.equals("")){
return false;
}
Map deepMap = SaveHelper.transferToSmall((Map) JSON.parse(deepinfo.toString()));
Object status = deepMap.get("status");
if(status != null && ("-1").equals(status+"")){
return false;
}
return true;
}
} | [
"[email protected]"
] | |
61d06e28a0e6a6144560afa42377290c287eac4d | 36db620fa30cc93da851651f63ca468523a7dbb4 | /app/models/Moh.java | f4b23b93c8950addaf4279d550dbc3a8b5f898ad | [
"Apache-2.0"
] | permissive | chandero/mybc_backend | a3c046b816e128def7f5c1925fa2ff3f89cf1681 | 7141dbc283c24ff30dd46905ff14a4e15e6399f6 | refs/heads/master | 2021-09-05T17:34:20.315198 | 2018-01-29T23:15:39 | 2018-01-29T23:15:39 | 110,253,334 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 341 | java | package models;
import dtos.MohDto;
public class Moh {
public Long moh_id;
public String moh_nombre;
public String moh_archivo;
public static MohDto createDto(Moh moh) {
MohDto dto = new MohDto();
dto.moh_id = moh.moh_id;
dto.moh_nombre = moh.moh_nombre;
dto.moh_archivo = moh.moh_archivo;
return dto;
}
}
| [
"[email protected]"
] | |
8fa4630a18b3fc2abfed53d73388531e5738374a | b0a22f0a6b82aea822489b8e9a8ad547fb800c84 | /src/main/java/com/sleepwalker/dingdong/analyze/ttmj/TTMeiJuMovieAnalyzeService.java | 5c210f93e8f3ceb4c272a50aaccdea32d2bec203 | [] | no_license | SleepWalkers/DingDong | 94318396192ef1af05bbd287c2716f39f758bbc7 | 0ec5a25775c1044ea4253cc83d1eae972eb7aa82 | refs/heads/master | 2020-05-27T21:16:44.777544 | 2018-11-27T13:38:15 | 2018-11-27T13:38:15 | 83,640,463 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 808 | java | package com.sleepwalker.dingdong.analyze.ttmj;
import java.util.List;
import org.apache.http.NameValuePair;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.springframework.stereotype.Service;
import com.sleepwalker.dingdong.video.model.VideoSource.VideoType;
import com.sleepwalker.utils.HttpClientUtil;
@Service("ttMeiJuMovieAnalyzeService")
public class TTMeiJuMovieAnalyzeService extends TTMeiJuAnalyzeService {
private static final VideoType VIDEO_TYPE = VideoType.TTMJ_MOVIE;
@Override
protected Document getDocument(String url, List<NameValuePair> nameValuePairs) {
String result = HttpClientUtil.get(url, nameValuePairs);
return Jsoup.parse(result);
}
@Override
protected VideoType getVideoType() {
return VIDEO_TYPE;
}
}
| [
"[email protected]"
] | |
75d0eef4a2a7b034a7f97b4bfc0531cafde590e4 | aa4527f224a135ed02447a028af6f0179cd12e0f | /WordCounter.java | 8540692d8e98dd6b4878d840839b6657ef74982f | [] | no_license | Ankitmandal1/Hactoberfest2021 | 3d5416c0721f3f3b6d4c5fccb8164e8d0d9c6833 | 7169b9b3293e5687889578938e267dfcd28e0167 | refs/heads/main | 2023-09-04T01:12:19.753420 | 2021-10-31T05:12:58 | 2021-10-31T05:12:58 | 423,058,444 | 1 | 0 | null | 2021-10-31T05:07:59 | 2021-10-31T05:07:58 | null | UTF-8 | Java | false | false | 977 | java | import java.util.*;
public class WordCounter
{
public static void main(String[] args)
{
int count=0; // Word Counter for String
Scanner ob=new Scanner(System.in); // A standard input stream
System.out.print("Enter a String : ");
String s = ob.nextLine(); // Accepts the String
char[] ch = new char[s.length()]; // Create an array to store String characters
for(int i=0; i<s.length(); i++)
{
ch[i]= s.charAt(i); //Stores the String characters one by one
if( ((i>0) && (ch[i]!=' ') && (ch[i-1]==' ')) || ((ch[0]!=' ') && (i==0)) )
count++;
}
System.out.println("Number of Word(s) : " + count);
}
}
/*
Problem Statement - Write a Program to find the Number of Words in a String
Time Complexity = O(n)
Output :-
Enter a String : Hello, I am under the water, please help me.
Number of Word(s) : 9
*/
| [
"[email protected]"
] | |
de8239359341ec5a16bebed6eb3592afb567410d | 2d2da5bdc6161571a29912accc49ce8f934ae117 | /src/net/meisen/dissertation/impl/cache/MapDbDataRecordSerializer.java | a3c14af910d538b524ddd358f2b25026c1835d75 | [
"BSD-3-Clause"
] | permissive | pmeisen/dis-timeintervaldataanalyzer | 8be05e6e485a667b97b9814297a535f9575323d9 | 9c97c7d19b2125ca148529e85f2175751e7d2aa4 | refs/heads/master | 2021-01-18T22:06:38.850928 | 2017-03-29T22:15:29 | 2017-03-29T22:15:29 | 14,424,470 | 6 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,378 | java | package net.meisen.dissertation.impl.cache;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import net.meisen.dissertation.jdbc.protocol.DataType;
import net.meisen.dissertation.model.data.TidaModel;
/**
* Serializer used to serialize the values of a record. The serialization is
* mainly based on {@code DataType#write(DataOutput, Object)} and
* deserialization is based on {@code DataType#read(DataInput)}.
*
* @author pmeisen
*
*/
public class MapDbDataRecordSerializer implements
IModelDependendMapDbSerializer<Object[]> {
private static final long serialVersionUID = 1L;
private transient DataType[] types;
@Override
public void init(final BaseMapDbCache<?, ?> cache, final TidaModel model) {
types = ((MapDbDataRecordCache) cache).getDataTypes();
}
@Override
public int fixedSize() {
return -1;
}
@Override
public void serialize(final DataOutput out, final Object[] value)
throws IOException {
for (int i = 0; i < types.length; i++) {
final DataType type = types[i];
type.write(out, value[i]);
}
}
@Override
public Object[] deserialize(final DataInput in, final int available)
throws IOException {
final Object[] values = new Object[types.length];
for (int i = 0; i < types.length; i++) {
final DataType type = types[i];
values[i] = type.read(in);
}
return values;
}
}
| [
"[email protected]"
] | |
5e7320bf4465bd81470d3855b50b1ccfe56e0820 | e76328acc1471aad5bd81db83dd705db40d2088e | /src/main/java/io/vertx/blog/first/Whisky.java | 0a96b6817ee1737d301def9b8d253723566cfad2 | [
"Apache-2.0"
] | permissive | mikeChenIntern/exampleVertx | 355ccebef28e11b8b0f08af6ed4a30b14737dfc8 | 2f9a9ef638a193aa9e01327fcabdb4aebfd81c4a | refs/heads/master | 2020-03-19T02:31:55.132934 | 2018-05-31T22:59:59 | 2018-05-31T22:59:59 | 135,636,576 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 809 | java | package io.vertx.blog.first;
import java.util.concurrent.atomic.AtomicInteger;
public class Whisky {
private static final AtomicInteger COUNTER = new AtomicInteger();
private final int id;
private String name;
private String origin;
public Whisky(String name, String origin) {
this.id = COUNTER.getAndIncrement();
this.name = name;
this.origin = origin;
}
public Whisky() {
this.id = COUNTER.getAndIncrement();
}
public String getName() {
return name;
}
public String getOrigin() {
return origin;
}
public int getId() {
return id;
}
public void setName(String name) {
this.name = name;
}
public void setOrigin(String origin) {
this.origin = origin;
}
} | [
"[email protected]"
] | |
f5f164ad104eeb4134919bd790cb5bf2b7980a54 | ec5506e24a196b1c153b6fbc42578661548c66b2 | /bankcardCertifacate/ffv/src/com/common/frame/dao/.svn/text-base/RoleDAO.java.svn-base | 0cfe2891dfeed59d8ab88b15ce15d74fa2375ba4 | [] | no_license | whhzkr/bankcardCertificate | e9429e2aca045b711e69c48d41465c2d8d42e603 | fa3d64969a6c1221cbca0080b705e0adfd5b52b6 | refs/heads/master | 2021-05-21T08:08:46.470215 | 2018-01-19T08:52:15 | 2018-01-19T08:52:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | package com.common.frame.dao;
import org.springframework.stereotype.Repository;
import com.common.base.dao.CommonDAO;
import com.common.frame.model.Role;
/**
* @className:RoleDAO.java
* @classDescription:角色操作DAO
* @author:longzy
* @createTime:2010-7-7
*/
@Repository
public class RoleDAO extends CommonDAO<Role>{
}
| [
"[email protected]"
] | ||
69e23d5ac5c75bde16b29da7ab154dcd468d6204 | 6a2d46325bdf31b195b76c83aa500c35dd4a1ac2 | /extensions/geode-modules/src/test/java/org/apache/geode/modules/util/ClassLoaderObjectInputStreamTest.java | a6400c7348d5b9ed4b71497144232084b1bd6012 | [
"Apache-2.0",
"LicenseRef-scancode-unknown",
"ISC",
"BSD-3-Clause",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause",
"MIT"
] | permissive | ymahajan/geode | b7047fc47e3281f45694172abb25249218c9d799 | 76c498385995a9aabefd7523f057e32dd9d4a8fa | refs/heads/develop | 2021-06-25T18:13:16.511965 | 2017-04-17T21:53:00 | 2017-04-19T16:38:02 | 88,777,707 | 0 | 0 | Apache-2.0 | 2021-06-14T23:21:37 | 2017-04-19T18:29:29 | Java | UTF-8 | Java | false | false | 5,848 | 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.geode.modules.util;
import static org.assertj.core.api.Assertions.*;
import org.apache.bcel.Constants;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.generic.ClassGen;
import org.apache.geode.internal.ClassPathLoader;
import org.apache.geode.test.junit.categories.UnitTest;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.rules.TestName;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.net.URL;
import java.util.Enumeration;
import java.util.Vector;
@Category(UnitTest.class)
@SuppressWarnings("unused")
public class ClassLoaderObjectInputStreamTest {
private ClassLoader originalTCCL;
private ClassLoader newTCCL;
private String classToLoad;
private Object instanceOfTCCLClass;
@Rule
public TestName testName = new TestName();
@Before
public void setUp() throws Exception {
this.originalTCCL = Thread.currentThread().getContextClassLoader();
this.newTCCL = new GeneratingClassLoader();
this.classToLoad = "com.nowhere." + getClass().getSimpleName() + "_" + testName.getMethodName();
this.instanceOfTCCLClass = createInstanceOfTCCLClass();
}
@After
public void unsetTCCL() throws Exception {
Thread.currentThread().setContextClassLoader(this.originalTCCL);
}
@Test
public void resolveClassFromTCCLThrowsIfTCCLDisabled() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this.instanceOfTCCLClass);
oos.close();
ObjectInputStream ois = new ClassLoaderObjectInputStream(
new ByteArrayInputStream(baos.toByteArray()), getClass().getClassLoader());
assertThatThrownBy(() -> ois.readObject()).isExactlyInstanceOf(ClassNotFoundException.class);
}
@Test
public void resolveClassFindsClassFromTCCLIfTCCLEnabled() throws Exception {
Thread.currentThread().setContextClassLoader(this.newTCCL);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject(this.instanceOfTCCLClass);
oos.close();
ObjectInputStream ois = new ClassLoaderObjectInputStream(
new ByteArrayInputStream(baos.toByteArray()), getClass().getClassLoader());
Object objectFromTCCL = ois.readObject();
assertThat(objectFromTCCL).isNotNull();
assertThat(objectFromTCCL.getClass()).isNotNull();
assertThat(objectFromTCCL.getClass().getName()).isEqualTo(this.classToLoad);
}
private Object createInstanceOfTCCLClass()
throws ClassNotFoundException, IllegalAccessException, InstantiationException {
Class<?> clazz = Class.forName(this.classToLoad, false, this.newTCCL);
return clazz.newInstance();
}
/**
* Custom class loader which uses BCEL to always dynamically generate a class for any class name
* it tries to load.
*/
private static class GeneratingClassLoader extends ClassLoader {
/**
* Currently unused but potentially useful for some future test. This causes this loader to only
* generate a class that the parent could not find.
*
* @param parent the parent class loader to check with first
*/
public GeneratingClassLoader(ClassLoader parent) {
super(parent);
}
/**
* Specifies no parent to ensure that this loader generates the named class.
*/
public GeneratingClassLoader() {
super(null); // no parent
}
@Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
ClassGen cg = new ClassGen(name, Object.class.getName(), "<generated>",
Constants.ACC_PUBLIC | Constants.ACC_SUPER, new String[] {Serializable.class.getName()});
cg.addEmptyConstructor(Constants.ACC_PUBLIC);
JavaClass jClazz = cg.getJavaClass();
byte[] bytes = jClazz.getBytes();
return defineClass(jClazz.getClassName(), bytes, 0, bytes.length);
}
@Override
protected URL findResource(String name) {
URL url = null;
try {
url = getTempFile().getAbsoluteFile().toURI().toURL();
System.out.println("GeneratingClassLoader#findResource returning " + url);
} catch (IOException e) {
throw new Error(e);
}
return url;
}
@Override
protected Enumeration<URL> findResources(String name) throws IOException {
URL url;
try {
url = getTempFile().getAbsoluteFile().toURI().toURL();
System.out.println("GeneratingClassLoader#findResources returning " + url);
} catch (IOException e) {
throw new Error(e);
}
Vector<URL> urls = new Vector<URL>();
urls.add(url);
return urls.elements();
}
protected File getTempFile() {
return null;
}
}
}
| [
"[email protected]"
] | |
63981d1ffa3b2ea881af656ee4fdb9f4bcf4b721 | 78c23878f06b3f9baf9333e8f5e229ee22652cb7 | /PatientCareApp/app/src/main/java/com/example/zem/patientcareapp/CheckoutModule/SummaryAdapter.java | b396ac85fc8cd8bfffae6675758be852d1a93cb8 | [] | no_license | lourdrivera123/ECEmarketing | 547706ce5961f02b2814aa06685d050c8e560c88 | 31e84e19c2d6040082748a9642db90007c4207e0 | refs/heads/master | 2020-04-05T00:17:26.062359 | 2016-02-01T04:45:25 | 2016-02-01T04:45:25 | 34,659,840 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,566 | java | package com.example.zem.patientcareapp.CheckoutModule;
import android.app.Activity;
import android.content.Context;
import android.graphics.Paint;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.zem.patientcareapp.R;
import org.w3c.dom.Text;
import java.util.ArrayList;
import java.util.HashMap;
/**
* Created by Zem on 11/19/2015.
*/
public class SummaryAdapter extends BaseAdapter {
private Context context;
private ArrayList<HashMap<String, String>> hashOfOrders;
public SummaryAdapter(Context context, ArrayList<HashMap<String, String>> hashOfOrders){
this.context = context;
this.hashOfOrders = hashOfOrders;
}
@Override
public int getCount() {
return hashOfOrders.size();
}
@Override
public Object getItem(int position) {
return hashOfOrders.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater mInflater = (LayoutInflater)
context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
convertView = mInflater.inflate(R.layout.basket_summary_item, null);
}
TextView medicine_name = (TextView) convertView.findViewById(R.id.medicine_name);
TextView qty_price = (TextView) convertView.findViewById(R.id.qty_price);
TextView item_subtotal = (TextView) convertView.findViewById(R.id.item_subtotal);
TextView item_subtotal_discounted = (TextView) convertView.findViewById(R.id.item_subtotal_discounted);
medicine_name.setText(hashOfOrders.get(position).get("name"));
qty_price.setText("\u20B1 "+hashOfOrders.get(position).get("price") + "x" + hashOfOrders.get(position).get("quantity"));
item_subtotal.setText("\u20B1 "+hashOfOrders.get(position).get("item_subtotal"));
String promo_type= hashOfOrders.get(position).get("promo_type");
double item_subtotal_value = Double.parseDouble(hashOfOrders.get(position).get("item_subtotal"));
double peso_discount = Double.parseDouble(hashOfOrders.get(position).get("peso_discount"));
double percentage_discount = Double.parseDouble(hashOfOrders.get(position).get("percentage_discount"));
int promo_free_product_qty = Integer.parseInt(hashOfOrders.get(position).get("promo_free_product_qty"));
if(promo_type.equals("peso_discount") ){
item_subtotal_discounted.setVisibility(View.VISIBLE);
item_subtotal_discounted.setText(new StringBuilder().append("\u20B1 ").append(item_subtotal_value - peso_discount).toString());
item_subtotal.setPaintFlags(item_subtotal.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else if(promo_type.equals("percentage_discount")) {
item_subtotal_discounted.setVisibility(View.VISIBLE);
item_subtotal_discounted.setText(new StringBuilder().append("\u20B1 ").append(item_subtotal_value - percentage_discount+""));
item_subtotal.setPaintFlags(item_subtotal.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else if(promo_type.equals("free_gift")) {
item_subtotal_discounted.setVisibility(View.VISIBLE);
item_subtotal_discounted.setText(promo_free_product_qty+" free item/s");
}
return convertView;
}
}
| [
"[email protected]"
] | |
7f66a5f8ba54e83b752f5c44f79ecbc9b29bb4e8 | de1f9688dfdee4530eff3ada14a80f8402d9d8a1 | /e-tongji/src/main/java/com/ysd/wr/job/SyncJob.java | 13ab679fa0d23132e4b91277c3e9774e1cf69e59 | [] | no_license | housedong/Blog_Microservice | f25887257ad6c93c5306395e3b5fbc7d55acadf5 | d8a8a0a5a4172489d50192e29b179e25b2bb132d | refs/heads/master | 2023-01-01T10:27:17.929987 | 2020-10-28T08:22:35 | 2020-10-28T08:22:35 | 307,947,881 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,398 | java | //package com.ysd.wr.job;
//
//import java.util.List;
//
//import org.quartz.JobExecutionContext;
//import org.quartz.JobExecutionException;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.quartz.QuartzJobBean;
//
//import com.ysd.wr.bean.Article;
//import com.ysd.wr.controller.TongjiController;
//import com.ysd.wr.mapper.TongjiMapper;
//import com.ysd.wr.service.ArticleServiceClient;
//
//
//public class SyncJob extends QuartzJobBean {
//
// private static final Logger logger = LoggerFactory.getLogger(TongjiController.class);
//
// @Autowired
// private ArticleServiceClient client;
//
// //保存当前用户的全部文章PageView数据并且相加(在TongjiController实现)
// @Override
// protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
// logger.info("开始同步");
// try {
// List<Article> articleList = this.client.getArticleByState(uid);
// int sumPageView = 0 ;
// for (Article article : articleList){
// sumPageView=sumPageView+article.getPageView();
// }
//
// logger.info("开始同步sumPageView="+sumPageView);
//
// }catch(Exception e) {
// logger.error(e.getMessage(),e);
// }
// logger.info("结束同步");
// }
//}
| [
"[email protected]"
] | |
cde22de99f11c2f5b2190cf15f25d7d96c58afbc | fff9503baaf1ca6b043718758c312aeed790fa2c | /src/main/java/com/bootdo/common/utils/AdvertiserShiroUtils.java | 0d8d23656792f70f957f847557fb91aa6d93c55c | [] | no_license | songlijun1995/ts-manage-consumer | db20bc6720cc7823393b8e9e17ee52eeff9d71ba | 3c01cb19045e5b09727f602165c4c392de5ec99f | refs/heads/master | 2020-03-18T02:30:27.678085 | 2018-05-21T00:07:01 | 2018-05-21T00:07:01 | 134,193,838 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,170 | java | package com.bootdo.common.utils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;
import com.bootdo.advertiser.domain.Advertiser;
import java.lang.reflect.InvocationTargetException;
import java.security.Principal;
import java.util.Collection;
import java.util.List;
public class AdvertiserShiroUtils {
@Autowired
private static SessionDAO sessionDAO;
public static Subject getSubjct() {
return SecurityUtils.getSubject();
}
public static Advertiser getUser() {
Object object = getSubjct().getPrincipal();
return (Advertiser)object;
}
public static Long getUserId() {
return getUser().getUserId();
}
public static void logout() {
getSubjct().logout();
}
public static List<Principal> getPrinciples() {
List<Principal> principals = null;
Collection<Session> sessions = sessionDAO.getActiveSessions();
return principals;
}
}
| [
"Administrator@Z258H7FRH70R1WT"
] | Administrator@Z258H7FRH70R1WT |
cf8b025dc146076f26537c9cfc7cd7979306f421 | 8ee42a114608a9f8479eaa0e1cba5579fe9c2e73 | /src/test/generated-java/com/keba/demo/repository/RoleGenerator.java | 31e5fc56623f3d293ce67a0f66ce2cbf4aa3d26e | [] | no_license | alexp82/myproject | 6414387b33da2b51fe65a00cf9111b3154e09625 | 827e11879f5fdaf9f2841d059ae44c9d4cb30f19 | refs/heads/master | 2016-09-03T06:41:59.139841 | 2014-07-15T14:39:05 | 2014-07-15T14:39:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 974 | java | /*
* (c) Copyright 2005-2014 JAXIO, http://www.jaxio.com
* Source code generated by Celerio, a Jaxio product
* Want to purchase Celerio ? email us at [email protected]
* Follow us on twitter: @springfuse
* Documentation: http://www.jaxio.com/documentation/celerio/
* Template pack-backend-jpa:src/test/java/service/ModelGenerator.e.vm.java
*/
package com.keba.demo.repository;
import javax.inject.Named;
import javax.inject.Singleton;
import com.keba.demo.domain.Role;
import com.keba.demo.util.ValueGenerator;
/**
* Helper class to create transient entities instance for testing purposes.
* Simple properties are pre-filled with random values.
*/
@Named
@Singleton
public class RoleGenerator {
/**
* Returns a new Role instance filled with random values.
*/
public Role getRole() {
Role role = new Role();
// simple attributes follows
role.setRoleName(ValueGenerator.getUniqueString(100));
return role;
}
} | [
"[email protected]"
] | |
5dd659a95b3292af6c2a7063ff9bb965c8fc4c2b | 17a02b071db6cd101f058dbe983a6f8ee9ace726 | /my-srping-4/src/main/java/com/yangzheng/springframework/beans/factory/support/CgliSubclassingInstantiationStrategy.java | 1d10c8b63f938fda523bd465ea03df7ab279679c | [] | no_license | yangzheng0/my-spring | eb331c52350d87da8b8dd35615912ef6e308983d | b6f1ca79d0e10d58385e70671c8a9ef31ede2fc0 | refs/heads/master | 2023-07-30T16:52:58.204717 | 2021-09-17T09:34:03 | 2021-09-17T09:34:03 | 407,475,894 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,029 | java | package com.yangzheng.springframework.beans.factory.support;
import com.yangzheng.springframework.beans.BeansException;
import com.yangzheng.springframework.beans.factory.config.BeanDefinition;
import net.sf.cglib.proxy.Enhancer;
import net.sf.cglib.proxy.NoOp;
import java.lang.reflect.Constructor;
/**
* @author yangzheng
* @description
* @date 2021/9/15 01516:35
*/
public class CgliSubclassingInstantiationStrategy implements InstantiationStrategy{
@Override
public Object instantiate(BeanDefinition beanDefinition, String beanName, Constructor ctor, Object[] args) throws BeansException {
Enhancer enhancer = new Enhancer();
enhancer.setSuperclass(beanDefinition.getBeanClass());
enhancer.setCallback(new NoOp() {
@Override
public int hashCode() {
return super.hashCode();
}
});
if(null == ctor) {
return enhancer.create();
}
return enhancer.create(ctor.getParameterTypes(),args);
}
}
| [
"[email protected]"
] | |
8ab3cd67691302c489c190453341530604d15a1d | 0272383b270f11aa445aa99573493fb6379711b1 | /src/main/java/common/HeartBeat.java | b17129ca2b3629b599e3c382cbd78b5540624fa0 | [] | no_license | sa-akhavani/multiplayer-snake | c1d151694e8aa5b61f75379c6bc88e03d4a8c4e1 | 6c2ae75c37125d31ec113c91f28980566d3974b4 | refs/heads/master | 2021-01-20T12:10:49.442228 | 2018-08-24T11:26:35 | 2018-08-24T11:26:35 | 81,947,934 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package common;
/**
* Created by ali on 2/20/17.
*/
public class HeartBeat {
private String username;
private String message;
public HeartBeat(String username, String message) {
this.username = username;
this.message = message;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
| [
"[email protected]"
] |
Subsets and Splits