blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 7
332
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
50
| license_type
stringclasses 2
values | repo_name
stringlengths 7
115
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringclasses 557
values | visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
684M
⌀ | star_events_count
int64 0
77.7k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 17
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 82
values | src_encoding
stringclasses 28
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 7
5.41M
| extension
stringclasses 11
values | content
stringlengths 7
5.41M
| authors
sequencelengths 1
1
| author
stringlengths 0
161
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eea78d3c032d5c2da59fcde515f6a69c7cb4bf4f | c81c54090e27238446cb6b42564528a7c591599e | /app/src/main/java/com/example/user/jenga/Architects.java | fe1c4a8b737164ae5b5cf8079630f25c5c62f507 | [] | no_license | KingMaina/Jenga | d334ec3a37f72d6e405585254779dd94d8786a32 | 29a2a9b28aa6acafdc1074f800a646d36ba08d2c | refs/heads/master | 2020-03-26T11:12:05.863320 | 2018-08-18T06:30:16 | 2018-08-18T06:30:16 | 144,832,864 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,316 | java | package com.example.user.jenga;
/**
* Created by user on 15/08/2018.
*/
class Architects {
int imageArchitect;
String nameArchitect,locationArchitect,phoneNumberArchitect;
public Architects(int imageArchitect, String nameArchitect, String locationArchitect, String phoneNumberArchitect) {
this.imageArchitect = imageArchitect;
this.nameArchitect = nameArchitect;
this.locationArchitect = locationArchitect;
this.phoneNumberArchitect = phoneNumberArchitect;
}
public int getImageArchitect() {
return imageArchitect;
}
public void setImageArchitect(int imageArchitect) {
this.imageArchitect = imageArchitect;
}
public String getNameArchitect() {
return nameArchitect;
}
public void setNameArchitect(String nameArchitect) {
this.nameArchitect = nameArchitect;
}
public String getLocationArchitect() {
return locationArchitect;
}
public void setLocationArchitect(String locationArchitect) {
this.locationArchitect = locationArchitect;
}
public String getPhoneNumberArchitect() {
return phoneNumberArchitect;
}
public void setPhoneNumberArchitect(String phoneNumberArchitect) {
this.phoneNumberArchitect = phoneNumberArchitect;
}
}
| [
"[email protected]"
] | |
28cb3657cab3664760b38e6e62f8ba9ff9332e23 | ba4900510f039dcdb944e5da23fca5032daa2185 | /Kafka/OrderServiceApi/src/main/java/edu/miu/mwa/lab12/OrderService.java | 4ff61b12ba60b4842fb7f154f9cebae4bdfcf7d6 | [] | no_license | nghianghesi/miu.swa | 1a2121b85081f965582092f917d44bc39cfb8359 | 4f7044aad5a672b467c03b3092050eae154ad00c | refs/heads/master | 2021-04-07T09:49:33.391551 | 2020-05-16T18:14:22 | 2020-05-16T18:14:22 | 248,665,931 | 0 | 0 | null | 2020-04-22T22:29:32 | 2020-03-20T04:13:04 | Java | UTF-8 | Java | false | false | 1,378 | java | package edu.miu.mwa.lab12;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.kafka.support.KafkaHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Service;
@Service
public class OrderService {
@Autowired
KafkaTemplate<UUID, String> kafkaTemplate;
private final String ORDER_CREATED_TOPIC = "ORDER_CREATED";
public UUID placeOrder(String message) {
UUID messageid = UUID.randomUUID();
System.out.println("Processing Order " + message);
kafkaTemplate.send(ORDER_CREATED_TOPIC, messageid, message);
return messageid;
}
@KafkaListener(topics = "OUT_OF_STOCK_TOPIC")
public void outofstock(@Payload String message,
@Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) UUID messageid)
{
System.out.println("Out of stock, canceling order " + messageid + " " + message);
}
@KafkaListener(topics = "ORDER_DELIVERIED")
public void deliveried(@Payload String message,
@Header(KafkaHeaders.RECEIVED_MESSAGE_KEY) UUID messageid)
{
System.out.println("Order proceeded " + messageid + " " + message);
}
}
| [
"nghianghesi@slave-node"
] | nghianghesi@slave-node |
cb93b537a5c456aeadde7804b007a95896765e03 | bcda5a5238e879e58665d343e3a6221fad0bdb55 | /src/fighter/CharacterIcon.java | 529ad37f210e0c1b24b6764a231fbc2505a606f0 | [] | no_license | Perzivial/2DFighter | 3d97458ff7fccaf0aefb3942126f9af4678509b2 | 1c39ea959b4bc8f41861b16b05b8e667011b3247 | refs/heads/master | 2021-01-17T14:35:46.843418 | 2016-10-29T23:44:42 | 2016-10-29T23:44:42 | 68,543,961 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 771 | java | package fighter;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
public class CharacterIcon {
Character keyBoard;
Character controller;
Rectangle interactRect;
BufferedImage img;
boolean isChoosingKeyBoard = true;
boolean isAiController = false;
ArrayList<Character> characters;
Game mygame;
int x;
int y;
public CharacterIcon(int row, ArrayList<Character> chars, Game gameinstance) {
// interactRect = new Rectangle(x,y,100,100);
switch (row) {
case (0):
y = 100;
break;
case (1):
y = 150;
break;
}
characters = chars;
mygame = gameinstance;
}
public void draw(Graphics g) {
g.drawImage(img, x, y, 100, 100, null);
}
public void addCharacter() {
}
}
| [
"[email protected]"
] | |
8b920f6cf874b5099080669bdda7667abb5b210c | 753ee90d0a03be075f9131b71042fe02e2d14efa | /src/main/java/ch/mapirium/server/pointdata/rest/gateway/PublicIdGroup.java | ea3d4fb7f2bd203bbc5cca33d8655678b5812adc | [
"Apache-2.0"
] | permissive | Mapirium/PointDataService | a4c1875e81ca8d76d7ff055906436bced07bad6f | 113354698cd8bbbdaba2a233477de057c8089a36 | refs/heads/master | 2021-01-13T07:50:05.389796 | 2017-09-18T16:57:09 | 2017-09-18T16:57:09 | 71,699,359 | 0 | 0 | null | 2017-09-18T16:58:16 | 2016-10-23T11:45:49 | Java | UTF-8 | Java | false | false | 399 | java | package ch.mapirium.server.pointdata.rest.gateway;
/**
* Gruppe, zu welcher der öffentlicher Schlüssel gehört. Dieser definiert das Prefix innerhalb der ID
*/
public enum PublicIdGroup {
FieldData("FI"),
PointData("PO");
private String prefix;
PublicIdGroup(String prefix) {
this.prefix = prefix;
}
public String getPrefix() {
return prefix;
}
}
| [
"[email protected]"
] | |
4e4f0655a37069b83ba715ecaafc7b58ca59542a | c0b665d51d44adac3cdb7c5559998a47548910b6 | /app/src/main/java/ru/windt/thecounter/MainActivity.java | 8f1829f5c5be016befdcb8d069c16620c7e6b04c | [] | no_license | ewindt/TheCounter | 9a7d94a6add01cc0f681e52ab07b6c99f30c85a4 | a8aa71650428feee6e415f2c7048739cc02dbae2 | refs/heads/master | 2016-09-13T06:43:27.662580 | 2016-05-22T14:39:59 | 2016-05-22T14:39:59 | 59,416,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,687 | java | package ru.windt.thecounter;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Button;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import java.lang.annotation.Target;
public class MainActivity extends AppCompatActivity {
private Button btnCount;
private TextView lblText;
private TableRow tableLayout;
public static final String NEW_NAME = "nameNewCounter";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
//btnCount = (Button) findViewById(R.id.button);
//lblText = (TextView) findViewById(R.id.textView);
tableLayout = (TableRow) findViewById(R.layout.content_main);
Intent intent = getIntent();
String nameNewCounter = intent.getStringExtra(NEW_NAME);
// создаем Layout -> button -> textView в TableRow
//lblText.setText(nameNewCounter);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
public void btnClick(View v) {
//int newCount = Integer.parseInt((String)btnCount.getText())+1;
//lblText.setText(Integer.toString(newCount));
}
public void onClickCreate(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
Intent intent = new Intent(this, CreateCounterActivity.class);
startActivity(intent);
}
}
| [
"[email protected]"
] | |
fb0eb4109817e209d39ef351c3f4fe176b69611f | 2fd9d77d529e9b90fd077d0aa5ed2889525129e3 | /DecompiledViberSrc/app/src/main/java/com/yandex/mobile/ads/impl/fs.java | 1312de3270f3c04738ea0ebdb7037cf68e540521 | [] | no_license | cga2351/code | 703f5d49dc3be45eafc4521e931f8d9d270e8a92 | 4e35fb567d359c252c2feca1e21b3a2a386f2bdb | refs/heads/master | 2021-07-08T15:11:06.299852 | 2021-05-06T13:22:21 | 2021-05-06T13:22:21 | 60,314,071 | 1 | 3 | null | null | null | null | UTF-8 | Java | false | false | 556 | java | package com.yandex.mobile.ads.impl;
import com.yandex.mobile.ads.AdRequestError;
public abstract interface fs
{
public abstract void a();
public abstract void a(AdRequestError paramAdRequestError);
public abstract void b();
public abstract void c();
public abstract void d();
public abstract void e();
public abstract void f();
}
/* Location: E:\Study\Tools\apktool2_2\dex2jar-0.0.9.15\classes_viber_4_dex2jar.jar
* Qualified Name: com.yandex.mobile.ads.impl.fs
* JD-Core Version: 0.6.2
*/ | [
"[email protected]"
] | |
156b871f2979dbd04f69bd9489f89cb0bcbc4d4a | 07ddfdc4bb8ac78cf8bf757f71a9a1915bc4768e | /cad-catalogo/src/main/java/com/seguritech/controller/CatalogoController.java | 4981af5e072e03103ef6ddd7aebec483b3bae99d | [] | no_license | jbucio/spring-cloud-config | 2f1109ff4591c1800f714c6189b083ffe32634f2 | 13a112f7d9a431e34e65c378528be6d3e6fd8013 | refs/heads/master | 2020-03-07T20:21:46.158651 | 2018-04-02T04:09:58 | 2018-04-02T04:09:58 | 127,695,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,708 | java | package com.seguritech.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.seguritech.model.Catalogo;
import com.seguritech.service.CatalogoService;
@RestController
public class CatalogoController {
@Autowired
private CatalogoService catalogoServiceImpl;
@RequestMapping(path="/catalogo",method=RequestMethod.POST,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Catalogo>> addCatalogo(@RequestBody Catalogo catalogo) {
catalogoServiceImpl.addCatalogo(catalogo);
return new ResponseEntity<List<Catalogo>>(HttpStatus.OK);
}
@RequestMapping(path="/catalogo",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE,consumes=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Catalogo>> updateCatalogo(@RequestBody Catalogo catalogo) {
catalogoServiceImpl.updateCatalogo(catalogo);
return new ResponseEntity<List<Catalogo>>(HttpStatus.OK);
}
@RequestMapping(path="/catalogo",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Catalogo>> getAllCatalogo() {
List<Catalogo> list = catalogoServiceImpl.getAllCatalogo();
if (list.isEmpty()) {
return new ResponseEntity<List<Catalogo>>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<List<Catalogo>>(list, HttpStatus.OK);
}
@RequestMapping(path="/catalogo/{id}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Catalogo> getCatalogoById(@PathVariable("id") long id) {
Catalogo catalogo = catalogoServiceImpl.getCatalogoById(id).get();
if (catalogo == null) {
return new ResponseEntity<Catalogo>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<Catalogo>(catalogo, HttpStatus.OK);
}
@RequestMapping(path="/catalogo/tabla/{id}",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Catalogo>> getCatalogoByIdTabla(@PathVariable("id") long id) {
List<Catalogo> list = catalogoServiceImpl.getCatalogoByIdTabla(id);
if (list.isEmpty()) {
return new ResponseEntity<List<Catalogo>>(HttpStatus.NO_CONTENT);
}
return new ResponseEntity<List<Catalogo>>(list, HttpStatus.OK);
}
}
| [
"[email protected]"
] | |
07ecd3d6d1b7f36276c62a584f0c3dad7c78def3 | 8b552d86df1022e6ca92464f587257393caa4b2b | /fastcampus-java-admin/src/main/java/com/example/study/model/network/Header.java | 1a9137fad319dbea6e559cd025fee82d7294f4cf | [] | no_license | jh-dev-study/online-lecture | 360e352e30dfb4545e08910d1cff6878e4d532fd | 5903ddb871c6bd5d00e536276f8976391cc65899 | refs/heads/main | 2023-04-08T23:02:52.035937 | 2021-04-10T15:00:50 | 2021-04-10T15:00:50 | 327,896,997 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,510 | java | package com.example.study.model.network;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.time.LocalDateTime;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Header<T> {
// API 통신 시간
// camelCase -> snake_case
// 계속해서 설정해주기엔 번거러우므로, application.properties 파일에 같이 설정
@JsonProperty("transaction_time")
private LocalDateTime transactionTime;
// API 응답 코드
private String resultCode;
// API 부가 설명
private String description;
private T data;
// OK
public static <T> Header<T> OK() {
return Header.<T>builder()
.transactionTime(LocalDateTime.now())
.resultCode("OK")
.description("OK")
.build();
}
// DATA OK
public static <T> Header<T> OK(T data) {
return Header.<T>builder()
.transactionTime(LocalDateTime.now())
.resultCode("OK")
.description("OK")
.data(data)
.build();
}
// ERROR
// DATA OK
public static <T> Header<T> ERROR(String description) {
return Header.<T>builder()
.transactionTime(LocalDateTime.now())
.resultCode("OK")
.description(description)
.build();
}
}
| [
"[email protected]"
] | |
ad0967a046a578724804690ac73a7f1560136023 | 2b853bd798014618bc7a74987caed6af268e904f | /src/main/java/com/echo/jzofferimpl/Convert.java | 14a09e89903325e514661c4dc4f99289fee56421 | [] | no_license | wucongyou/jzoffer-impl | d88afeac678b1775ba5cac23542b49b44564139f | 4e7e8fc81741fb6d8d7329e03a843c79ccff9844 | refs/heads/master | 2021-01-19T05:46:53.658503 | 2016-07-19T01:50:46 | 2016-07-19T01:50:46 | 63,647,957 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 996 | java | package com.echo.jzofferimpl;
/**
* 二叉搜索树与双向链表
*
* 题目描述
*
* 输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。
*/
public class Convert {
public TreeNode convert(TreeNode pRootOfTree) {
TreeNode pLastNodeInList = convert(pRootOfTree, null);
TreeNode pHead = pLastNodeInList;
while (pLastNodeInList != null && pHead.left != null) {
pHead = pHead.left;
}
return pHead;
}
public TreeNode convert(TreeNode root, TreeNode pLastNodeInList) {
if (root == null)
return pLastNodeInList;
if (root.left != null) {
pLastNodeInList = convert(root.left, pLastNodeInList);
}
root.left = pLastNodeInList;
if (pLastNodeInList != null) {
pLastNodeInList.right = root;
}
pLastNodeInList = root;
if (root.right != null) {
pLastNodeInList = convert(root.right, pLastNodeInList);
}
return pLastNodeInList;
}
}
| [
"[email protected]"
] | |
1c515fe9b212fae83f29736be0d743a5c8cd5b9d | d3d3c8c5ca2eb1f36448e475f43af9b11c2f0ffd | /src/main/java/org/sonar/plugins/clojure/language/JsonProfile.java | 4b20885b017dfbcffa87d8319e4ec64629114604 | [
"MIT"
] | permissive | fsantiag/sonar-clojure | 2d0761daf55539d4413c88bfbd58f0717aa90f84 | 8935e2291d21d57922006bab2f7fdd82d08e415e | refs/heads/master | 2022-05-26T00:16:11.567372 | 2022-02-01T14:19:02 | 2022-02-01T14:19:02 | 129,534,767 | 56 | 24 | MIT | 2022-09-25T02:37:18 | 2018-04-14T16:30:18 | Java | UTF-8 | Java | false | false | 211 | java | package org.sonar.plugins.clojure.language;
import java.util.List;
public class JsonProfile {
private List<String> ruleKeys;
public List<String> getRuleKeys() {
return this.ruleKeys;
}
}
| [
"[email protected]"
] | |
4e5b461f33ef38e727b2ab74cfd13c02d0e6feb7 | 54a505461a868a60728f812e852ecf7e46dfa4e1 | /src/test/java/ru/javawebinar/topjava/SpringMain.java | 0ecdfcc8e688d782249e622b1e401d769bb94201 | [] | no_license | iizdebski/W6 | a930d413afe7382b3e6a099da416fa886df3a59d | c0acf28b8a1524c3c19ed97029d07ba15846731b | refs/heads/master | 2022-09-20T04:52:01.101397 | 2019-10-12T10:43:00 | 2019-10-12T10:43:00 | 214,629,631 | 0 | 0 | null | 2022-09-08T01:02:58 | 2019-10-12T10:43:38 | Java | UTF-8 | Java | false | false | 1,851 | java | package ru.javawebinar.topjava;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
import ru.javawebinar.topjava.model.Role;
import ru.javawebinar.topjava.model.User;
import ru.javawebinar.topjava.to.MealTo;
import ru.javawebinar.topjava.web.meal.MealRestController;
import ru.javawebinar.topjava.web.user.AdminRestController;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.util.Arrays;
import java.util.List;
public class SpringMain {
public static void main(String[] args) {
// java 7 automatic resource management
try (GenericXmlApplicationContext appCtx = new GenericXmlApplicationContext()) {
appCtx.getEnvironment().setActiveProfiles(Profiles.getActiveDbProfile(), Profiles.REPOSITORY_IMPLEMENTATION);
appCtx.load("spring/spring-app.xml", "spring/inmemory.xml");
appCtx.refresh();
System.out.println("Bean definition names: " + Arrays.toString(appCtx.getBeanDefinitionNames()));
AdminRestController adminUserController = appCtx.getBean(AdminRestController.class);
adminUserController.create(new User(null, "userName", "[email protected]", "password", Role.ROLE_ADMIN));
System.out.println();
MealRestController mealController = appCtx.getBean(MealRestController.class);
List<MealTo> filteredMealsWithExcess =
mealController.getBetween(
LocalDate.of(2015, Month.MAY, 30), LocalTime.of(7, 0),
LocalDate.of(2015, Month.MAY, 31), LocalTime.of(11, 0));
filteredMealsWithExcess.forEach(System.out::println);
}
}
} | [
"[email protected]"
] | |
b80b2ef0e37209f199c376fe17f64165828cc330 | 19c59e2163ac4ff5cbfc1b1ea80a75d4dc0d4d20 | /src/ocajp/q085/Test.java | 56afe124533c39f63821f9c2375e2622ae180f59 | [] | no_license | camioljoyce/exam.ocajp | 15a4064cbccb2cbc40c3c81e9753b3f89fc3f789 | e621f458a054bd652364e80b593f8e3a06801075 | refs/heads/master | 2022-12-19T12:50:10.477901 | 2020-09-24T23:30:42 | 2020-09-24T23:30:42 | 298,417,566 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 619 | java | package ocajp.q085;
public class Test {
public static void main(String[] args) {
// TODO Auto-generated method stub
// Which statement is true about the switch statement?
// A. It must contain the default section.
// IT Certification Guaranteed, The Easy Way!
// 74
// B. The break statement, at the end of each case block, is mandatory.
// C. Its case label literals can be changed at runtime.
// D. Its expression must evaluate to a single value.
System.out.println("D");
}
}
| [
"[email protected]"
] | |
7257f7971baec053c1cadf4653310038d18a778b | c3c3f67f8e3218267cef9662d90963f17be07bbb | /src/main/java/ntou/cs/springboot/proposition/QuestionClass/QuestionsAndAnswers.java | 495c3308f756fb79d7f3da1e9c41d3733271973c | [] | no_license | thomas205327/propositionHW | dc34d0cdb0153670161492eaff69c40534616dbb | 99501baa512865f3ca427e5208b8748a961691d0 | refs/heads/master | 2022-11-08T11:53:19.759070 | 2020-06-23T13:42:30 | 2020-06-23T13:42:30 | 272,940,665 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,300 | java | package ntou.cs.springboot.proposition.QuestionClass;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "questionsandanswers")
public class QuestionsAndAnswers {
private String question;
private String answer;
private String img;
private String grade;
private String subject;
private String id;
public String getId() { return id; }
public void setId(String temp) { id = temp; }
public String getGrade(){
return grade;
}
public void setGrade(String temp){
grade = temp;
}
public String getSubject(){
return subject;
}
public void setSubject(String temp){
subject = temp;
}
public String getQuestion(){
return question;
}
public void setQuestion(String temp){
question = temp;
}
public String getAnswer(){
return answer;
}
public void setAnswer(String temp){
answer = temp;
}
public String getImg(){
return img;
}
public void setImg(String temp){
img = temp;
}
@Override
public String toString() {
return "選擇題 [question=" + question + "" +
", answer="+answer+", grade="+grade+", subject="+subject+", id="+id+"]";
}
}
| [
"[email protected]"
] | |
c7b8ff6ccb77c743c655ee472c4d740ce7c3c22f | 25dfe9881c8034676e23fc48a5549866ac895f14 | /src/main/java/model/UnusedName.java | de8426f2e35afa610ffdc7850957ff8f57d09886 | [] | no_license | pavmoroz/ChatRooms | e699bf1a6083cf9311f58fa1bd77ce98ed073eb4 | f29d8d2bbe78bbc07249aa55a2384564a87430b2 | refs/heads/master | 2022-06-13T19:29:27.227062 | 2020-02-02T13:59:30 | 2020-02-02T13:59:30 | 233,876,534 | 0 | 0 | null | 2022-05-20T21:21:57 | 2020-01-14T15:47:05 | Java | UTF-8 | Java | false | false | 403 | java | package model;
import java.time.LocalDateTime;
public class UnusedName {
private String name;
private LocalDateTime timeOfCreation;
public UnusedName(String name) {
this.name = name;
timeOfCreation = LocalDateTime.now();
}
public String getName() {
return name;
}
public LocalDateTime getTimeOfCreation() {
return timeOfCreation;
}
}
| [
"[email protected]"
] | |
cb17a623d2173dca7e137be46784951f8e448742 | d33574802593c6bb49d44c69fc51391f7dc054af | /ShipLinx/src/main/java/com/meritconinc/mmr/model/datagrid/DataGridNavigation.java | d0be459f3bb2c78248d1c207fac1fcae6da605d7 | [] | no_license | mouadaarab/solushipalertmanagement | 96734a0ff238452531be7f4d12abac84b88de214 | eb4cf67a7fbf54760edd99dc51efa12d74fa058e | refs/heads/master | 2021-12-06T06:09:15.559467 | 2015-10-06T09:00:54 | 2015-10-06T09:00:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 207 | java | package com.meritconinc.mmr.model.datagrid;
public interface DataGridNavigation {
public String goToPage() throws Exception;
public String goToPage(int pageNumber) throws Exception;
}
| [
"[email protected]"
] | |
b5bee1cbc2578c48b8ddcffa24030243437233ee | 4bb6197bb86b89901b916e452ebf862dc1d3bfac | /annotations-configuration/src/main/java/ru/bogdanium/kevin/App.java | b814159221f4751d6963fbaadd7ca436a3e41415 | [] | no_license | DenisBogdanov/spring-examples | 611d0b0eb2ccd5342a86c4b544157a5330369e56 | f5270082db87fd7669d406c346c1ea7084949dd4 | refs/heads/master | 2021-09-29T13:43:02.949639 | 2018-11-24T23:14:32 | 2018-11-24T23:14:32 | 124,791,084 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 464 | java | package ru.bogdanium.kevin;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("kevin-application-context.xml");
BeanA beanA = context.getBean("beanA", BeanA.class);
System.out.println(beanA.getBeanB().getMyProperty());
}
}
| [
"[email protected]"
] | |
29d37732864b5cbee8c24b71618b345f83a2e16d | 401d2ed96357366efc59a23be85ef3534eea0a98 | /ylangfx-core/src/main/java/net/smackem/ylang/runtime/BoolVal.java | fa01ad6babf618ed9ffb3c37fb8f70530f2cd016 | [
"MIT"
] | permissive | smackem/ylangfx | 5b59c2a9cf25149e8c123d6a800540d44bd4e023 | 1cf583ad92b688df7bc2483a764f2f697a76211b | refs/heads/master | 2023-07-23T02:38:44.973058 | 2021-03-31T21:37:03 | 2021-04-02T14:49:07 | 221,549,226 | 2 | 0 | MIT | 2023-07-05T20:45:11 | 2019-11-13T20:50:39 | Java | UTF-8 | Java | false | false | 1,096 | java | package net.smackem.ylang.runtime;
public class BoolVal extends Value {
private final boolean value;
public static final BoolVal TRUE = new BoolVal(true);
public static final BoolVal FALSE = new BoolVal(false);
private BoolVal(boolean value) {
super(ValueType.BOOLEAN);
this.value = value;
}
public static BoolVal of(boolean value) {
return value ? TRUE : FALSE;
}
public boolean value() {
return this.value;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
final BoolVal that = (BoolVal) o;
return this.value == that.value;
}
@Override
public int hashCode() {
return this.value ? 1 : 0;
}
@Override
public String toString() {
return "BoolVal{" +
"value=" + value +
'}';
}
@Override
public String toLangString() {
return String.valueOf(this.value);
}
}
| [
"[email protected]"
] | |
773b5577d43e62284bd972e99841ee3ec423b8b9 | 017e51bb421f34d8a554507e4747ff51eed86222 | /test/LambdaKata/UpperCaseTest.java | eb7741c113e6ab2e4b8f122ff050fa6b2dec2a76 | [] | no_license | MarioSamperi75/JAVASprint5 | 0e8d11f26b27c337a8bd815ed75eb3498474b5c3 | 7d700e910e46d19fb6ac5077e8ea2351605a7c7b | refs/heads/master | 2020-11-28T13:18:56.503377 | 2019-11-25T09:41:27 | 2019-11-25T09:41:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 875 | java | package LambdaKata;
import org.junit.Test;
import java.util.List;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertEquals;
/*
Convert elements of a collection to upper case.
*/
public class UpperCaseTest {
@Test
public void transformShouldConvertCollectionElementsToUpperCase() {
List<String> collection = asList("My", "name", "is", "John", "Doe");
List<String> expected = asList("MY", "NAME", "IS", "JOHN", "DOE");
List<String> result = UpperCase.transform(collection);
assertEquals(result.size(), 5);
assertEquals(result.get(0), expected.get(0));
assertEquals(result.get(1), expected.get(1));
assertEquals(result.get(2), expected.get(2));
assertEquals(result.get(3), expected.get(3));
assertEquals(result.get(4), expected.get(4));
}
}
| [
"[email protected]"
] | |
7ee3c4a7b74b4c11e6739655c55d5a2977a45d47 | e7ee311e20b40c87bf6d23a53a1d7b11fd29d2c3 | /src/chosun/ciis/hd/yadjm/ds/HD_YADJM_5201_LDataSet.java | 4f7c67fe7fcdef5b1394b77fab8a4afeea8d2d6c | [] | no_license | nosmoon/misdevteam | 4e3695ef7bbdcd231bb84d7d8d7df54a23ff0a60 | 1829d5bd489eb6dd307ca244f0e183a31a1de773 | refs/heads/master | 2020-04-15T15:57:05.480056 | 2019-01-10T01:12:01 | 2019-01-10T01:12:01 | 164,812,547 | 1 | 0 | null | null | null | null | UHC | Java | false | false | 3,334 | java | /***************************************************************************************************
* 파일명 : .java
* 기능 : 독자우대-구독신청
* 작성일자 : 2007-05-22
* 작성자 : 김대섭
***************************************************************************************************/
/***************************************************************************************************
* 수정내역 :
* 수정자 :
* 수정일자 :
* 백업 :
***************************************************************************************************/
package chosun.ciis.hd.yadjm.ds;
import java.sql.*;
import java.util.*;
import somo.framework.db.*;
import somo.framework.util.*;
import chosun.ciis.hd.yadjm.dm.*;
import chosun.ciis.hd.yadjm.rec.*;
/**
*
*/
public class HD_YADJM_5201_LDataSet extends somo.framework.db.BaseDataSet implements java.io.Serializable{
public ArrayList curlist = new ArrayList();
public String errcode;
public String errmsg;
public HD_YADJM_5201_LDataSet(){}
public HD_YADJM_5201_LDataSet(String errcode, String errmsg){
this.errcode = errcode;
this.errmsg = errmsg;
}
public void setErrcode(String errcode){
this.errcode = errcode;
}
public void setErrmsg(String errmsg){
this.errmsg = errmsg;
}
public String getErrcode(){
return this.errcode;
}
public String getErrmsg(){
return this.errmsg;
}
public void getValues(CallableStatement cstmt) throws SQLException{
this.errcode = Util.checkString(cstmt.getString(1));
this.errmsg = Util.checkString(cstmt.getString(2));
if(!"".equals(this.errcode)){
return;
}
ResultSet rset0 = (ResultSet) cstmt.getObject(6);
while(rset0.next()){
HD_YADJM_5201_LCURLISTRecord rec = new HD_YADJM_5201_LCURLISTRecord();
rec.tmp1 = Util.checkString(rset0.getString("tmp1"));
rec.tmp2 = Util.checkString(rset0.getString("tmp2"));
this.curlist.add(rec);
}
}
}/*----------------------------------------------------------------------------------------------------
Web Tier에서 DataSet 객체 관련 코드 작성시 사용하십시오.
<%
HD_YADJM_5201_LDataSet ds = (HD_YADJM_5201_LDataSet)request.getAttribute("ds");
%>
Web Tier에서 Record 객체 관련 코드 작성시 사용하십시오.
<%
for(int i=0; i<ds.curlist.size(); i++){
HD_YADJM_5201_LCURLISTRecord curlistRec = (HD_YADJM_5201_LCURLISTRecord)ds.curlist.get(i);%>
HTML 코드들....
<%}%>
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
Web Tier에서 DataSet 객체의 <%= %> 작성시 사용하십시오.
<%= ds.getErrcode()%>
<%= ds.getErrmsg()%>
<%= ds.getCurlist()%>
----------------------------------------------------------------------------------------------------*/
/*----------------------------------------------------------------------------------------------------
Web Tier에서 Record 객체의 <%= %> 작성시 사용하십시오.
<%= curlistRec.tmp1%>
<%= curlistRec.tmp2%>
----------------------------------------------------------------------------------------------------*/
/* 작성시간 : Fri Jan 22 16:03:01 KST 2010 */ | [
"[email protected]"
] | |
128e071c6249bcf1730759cfa2055f10bccae2ab | 2fa8d9c044d9c337599da0042a1fa534259e8ee0 | /src/main/java/com/insigma/tickserver/WRFDataWriter.java | 576be4cb7e5d95ba0802f1712401ba7838e90e64 | [] | no_license | yegaofei/TestHbase | b8682832d42e3752c215ed7966f8043e6c1b7756 | e5c2ecfc8e9a31ba05d6629bafd101ad6605f9e1 | refs/heads/master | 2020-05-17T04:24:22.501865 | 2013-06-03T08:40:45 | 2013-06-03T08:40:45 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,095 | java | package com.insigma.tickserver;
import java.io.IOException;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.util.Bytes;
/**
*
* @author insigmaus12
* @version V1.0 Create Time: Apr 27, 2013
*/
public class WRFDataWriter implements Runnable {
static final byte[] COLUMN_DWPRESIGNATURE = Bytes.toBytes("d");
static final byte[] COLUMN_RECORDTYPE = Bytes.toBytes("r");
static final byte[] COLUMN_UNUSED = Bytes.toBytes("u");
static final byte[] COLUMN_RECORDLENGTH = Bytes.toBytes("re");
static final byte[] COLUMN_SEQUENCE = Bytes.toBytes("s");
static final byte[] COLUMN_SYMBOL = Bytes.toBytes("sy");
static final byte[] COLUMN_DWPOSTSIGNATURE = Bytes.toBytes("dw");
/* TickDataType TickData */
static final byte[] COLUMN_FLAGS = Bytes.toBytes("f");
static final byte[] COLUMN_SEQUENCESERIES = Bytes.toBytes("ss");
static final byte[] COLUMN_CATEGORY = Bytes.toBytes("c");
static final byte[] COLUMN_SUBCATEGORY = Bytes.toBytes("sc");
static final byte[] COLUMN_LINEID = Bytes.toBytes("l");
static final byte[] COLUMN_AUTHCODE = Bytes.toBytes("a");
static final byte[] COLUMN_EXCHANGETIME = Bytes.toBytes("e");
static final byte[] COLUMN_BEACON = Bytes.toBytes("b");
static final byte[] COLUMN_VWAP = Bytes.toBytes("v");
static final byte[] COLUMN_SEQUENCENUMBER = Bytes.toBytes("sn");
static final byte[] COLUMN_SECQUALIFIERS = Bytes.toBytes("sq");
/* PriceDataType Trade */
static final byte[] COLUMN_TRADE_VALUE = Bytes.toBytes("tv");
static final byte[] COLUMN_TRADE_SIZE = Bytes.toBytes("ts");
static final byte[] COLUMN_TRADE_UCUMVOLUME = Bytes.toBytes("tu");
static final byte[] COLUMN_TRADE_FLAGS = Bytes.toBytes("tf");
static final byte[] COLUMN_TRADE_QUALIFIERS = Bytes.toBytes("tq");
static final byte[] COLUMN_TRADE_VOLQUALIFIERS = Bytes.toBytes("to");
static final byte[] COLUMN_TRADE_EXCHANGE = Bytes.toBytes("te");
/* PriceDataType Bid */
static final byte[] COLUMN_BID_VALUE = Bytes.toBytes("bv");
static final byte[] COLUMN_BID_SIZE = Bytes.toBytes("bs");
static final byte[] COLUMN_BID_UCUMVOLUME = Bytes.toBytes("bu");
static final byte[] COLUMN_BID_FLAGS = Bytes.toBytes("bf");
static final byte[] COLUMN_BID_QUALIFIERS = Bytes.toBytes("bq");
static final byte[] COLUMN_BID_VOLQUALIFIERS = Bytes.toBytes("bo");
static final byte[] COLUMN_BID_EXCHANGE = Bytes.toBytes("be");
/* PriceDataType Ask */
static final byte[] COLUMN_ASK_VALUE = Bytes.toBytes("av");
static final byte[] COLUMN_ASK_SIZE = Bytes.toBytes("as");
static final byte[] COLUMN_ASK_UCUMVOLUME = Bytes.toBytes("au");
static final byte[] COLUMN_ASK_FLAGS = Bytes.toBytes("af");
static final byte[] COLUMN_ASK_QUALIFIERS = Bytes.toBytes("aq");
static final byte[] COLUMN_ASK_VOLQUALIFIERS = Bytes.toBytes("ao");
static final byte[] COLUMN_ASK_EXCHANGE = Bytes.toBytes("ae");
public static final byte[] FAMILY_NAME = Bytes.toBytes("cf");
private HTable wrfDataTable;
private static final String WRF_TABLE_NAME = "WinROSFlowRecord";
private boolean flushCommits = true;
private volatile Configuration conf;
private CountDownLatch countDownLatch = null;
private FeedPlayback playback = null;
public WRFDataWriter(String flowrecords) {
super();
playback = new FeedPlayback(flowrecords);
}
public void run() {
try {
initTables();
wrfDataWrite();
testTakedown();
} catch (Exception e1) {
e1.printStackTrace();
} finally {
if (this.countDownLatch != null) {
this.countDownLatch.countDown();
}
}
}
private void wrfDataWrite() throws IOException {
WinROSFlowRecord record = null;
playback.open();
long total = 0;
List<Put> putList = new LinkedList<Put>();
long putHeapSize = 0;
long startTime = System.currentTimeMillis();
while ((record = playback.next()) != null) {
total++; //totally we have 31843557
byte[] key = RegionInfo.keyGenerate(total);
Put put = new Put(key);
put.add(FAMILY_NAME, COLUMN_DWPRESIGNATURE, Bytes.toBytes(record.dwPostSignature));
put.add(FAMILY_NAME, COLUMN_RECORDTYPE, Bytes.toBytes(record.RecordType));
put.add(FAMILY_NAME, COLUMN_UNUSED, Bytes.toBytes(record.Unused));
put.add(FAMILY_NAME, COLUMN_RECORDLENGTH, Bytes.toBytes(record.RecordLength));
put.add(FAMILY_NAME, COLUMN_SEQUENCE, Bytes.toBytes(record.Sequence));
put.add(FAMILY_NAME, COLUMN_SYMBOL, Bytes.toBytes(record.Symbol.trim()));
/*
* put.add(FAMILY_NAME, COLUMN_DWPOSTSIGNATURE,
* Bytes.toBytes(record.dwPostSignature)); put.add(FAMILY_NAME,
* COLUMN_FLAGS, Bytes.toBytes(record.TickData.Flags));
* put.add(FAMILY_NAME, COLUMN_SEQUENCESERIES,
* Bytes.toBytes(record.TickData.SequenceSeries));
*
* put.add(FAMILY_NAME, COLUMN_CATEGORY,
* Bytes.toBytes(record.TickData.Category)); put.add(FAMILY_NAME,
* COLUMN_SUBCATEGORY, Bytes.toBytes(record.TickData.SubCategory));
* put.add(FAMILY_NAME, COLUMN_LINEID,
* Bytes.toBytes(record.TickData.LineID)); put.add(FAMILY_NAME,
* COLUMN_AUTHCODE, Bytes.toBytes(record.TickData.AuthCode));
*/
put.add(FAMILY_NAME, COLUMN_EXCHANGETIME, Bytes.toBytes(record.TickData.ExchangeTime));
put.add(FAMILY_NAME, COLUMN_BEACON, Bytes.toBytes(record.TickData.Beacon));
/*
* put.add(FAMILY_NAME, COLUMN_VWAP,
* Bytes.toBytes(record.TickData.VWap)); put.add(FAMILY_NAME,
* COLUMN_SECQUALIFIERS, record.TickData.SecQualifiers);
*
*
*
* put.add(FAMILY_NAME, COLUMN_TRADE_VALUE,
* Bytes.toBytes(record.TickData.Trade.value)); put.add(FAMILY_NAME,
* COLUMN_TRADE_SIZE, Bytes.toBytes(record.TickData.Trade.size));
* put.add(FAMILY_NAME, COLUMN_TRADE_UCUMVOLUME,
* Bytes.toBytes(record.TickData.Trade.ucumvolume));
* put.add(FAMILY_NAME, COLUMN_TRADE_FLAGS,
* Bytes.toBytes(record.TickData.Trade.flags)); put.add(FAMILY_NAME,
* COLUMN_TRADE_QUALIFIERS, record.TickData.Trade.qualifiers);
* put.add(FAMILY_NAME, COLUMN_TRADE_VOLQUALIFIERS,
* record.TickData.Trade.volqualifiers); put.add(FAMILY_NAME,
* COLUMN_TRADE_EXCHANGE, record.TickData.Trade.exchange);
*
* put.add(FAMILY_NAME, COLUMN_BID_VALUE,
* Bytes.toBytes(record.TickData.Bid.value)); put.add(FAMILY_NAME,
* COLUMN_BID_SIZE, Bytes.toBytes(record.TickData.Bid.size));
* put.add(FAMILY_NAME, COLUMN_BID_UCUMVOLUME,
* Bytes.toBytes(record.TickData.Bid.ucumvolume));
* put.add(FAMILY_NAME, COLUMN_BID_FLAGS,
* Bytes.toBytes(record.TickData.Bid.flags)); put.add(FAMILY_NAME,
* COLUMN_BID_QUALIFIERS, record.TickData.Bid.qualifiers);
* put.add(FAMILY_NAME, COLUMN_BID_VOLQUALIFIERS,
* record.TickData.Bid.volqualifiers); put.add(FAMILY_NAME,
* COLUMN_BID_EXCHANGE, record.TickData.Bid.exchange);
*
* put.add(FAMILY_NAME, COLUMN_ASK_VALUE,
* Bytes.toBytes(record.TickData.Ask.value)); put.add(FAMILY_NAME,
* COLUMN_ASK_SIZE, Bytes.toBytes(record.TickData.Ask.size));
* put.add(FAMILY_NAME, COLUMN_ASK_UCUMVOLUME,
* Bytes.toBytes(record.TickData.Ask.ucumvolume));
* put.add(FAMILY_NAME, COLUMN_ASK_FLAGS,
* Bytes.toBytes(record.TickData.Ask.flags)); put.add(FAMILY_NAME,
* COLUMN_ASK_QUALIFIERS, record.TickData.Ask.qualifiers);
* put.add(FAMILY_NAME, COLUMN_ASK_VOLQUALIFIERS,
* record.TickData.Ask.volqualifiers); put.add(FAMILY_NAME,
* COLUMN_ASK_EXCHANGE, record.TickData.Ask.exchange);
*/
put.setWriteToWAL(false);
putHeapSize += put.heapSize();
putList.add(put);
if (total % 1000 == 0) {
this.wrfDataTable.put(putList);
putList = new LinkedList<Put>();
this.wrfDataTable.flushCommits();
// putHeapSize = 0 ;
}
// if (total == 1843557) {
// break;
// }
}
if (putList.size() > 0) {
this.wrfDataTable.put(putList);
}
long spendTime = System.currentTimeMillis() - startTime;
// The file size is 5810 MB
// double performance = 5810d / (double)spendTime * 1000;
double performance = ((double) putHeapSize / 1024d / 1024d) / (double) spendTime * 1000;
System.out.println("Writing performance is : " + performance + " MB per second");
}
private void initTables() throws IOException {
this.wrfDataTable = new HTable(conf, WRF_TABLE_NAME);
//this.wrfDataTable.setWriteBufferSize(HTABLE_BUFFER_SIZE);
this.wrfDataTable.setAutoFlush(false);
}
public CountDownLatch getCountDownLatch() {
return countDownLatch;
}
public void setCountDownLatch(CountDownLatch countDownLatch) {
this.countDownLatch = countDownLatch;
}
public Configuration getConf() {
return conf;
}
public void setConf(Configuration conf) {
this.conf = conf;
}
private void testTakedown() throws IOException {
if (flushCommits) {
this.wrfDataTable.flushCommits();
}
this.wrfDataTable.close();
}
}
| [
"[email protected]"
] | |
cc9615a07a2a836773efe23ea58fa7cc038f7a89 | f18c0f83ac0e7616f8b92052e7fcec1dd47dbe38 | /serviciosProfes/serviciosProfes-ejb/src/main/java/co/edu/unicundi/repo/impl/IAutorLectorRepoImpl.java | 4b3ce4c167117c457bd7b25d699522abfc6aa10b | [
"MIT"
] | permissive | jjrangel09/ServiciosLibreria | b8dedee6a0dc8c5927ee8ea0ac9ff36023c73603 | 1501cde63ae3412b6c5485b82d70d98ff1ff6a26 | refs/heads/main | 2023-03-16T03:36:07.675454 | 2021-03-04T17:57:35 | 2021-03-04T17:57:35 | 344,560,339 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,913 | 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 co.edu.unicundi.repo.impl;
import co.edu.unicundi.entity.AutorLector;
import co.edu.unicundi.repo.IAutorLectorRepo;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
/**
*
* @author Juan José Rangel <your.name at your.org>
*/
@Stateless
public class IAutorLectorRepoImpl implements IAutorLectorRepo {
@PersistenceContext(unitName = "co.edu.unicundi_serviciosProfes-ejb_ejb_1.0-SNAPSHOTPU")
private EntityManager entity;
@Override
public void guardar(AutorLector autorLector) {
entity.persist(autorLector);
}
@Override
public List<AutorLector> listarAutorLector(Integer idAutor) {
this.entity.getEntityManagerFactory().getCache().evictAll();
TypedQuery<AutorLector> listaAutorLector = this.entity.createNamedQuery("AutorLector.listarLectorPorAutor", AutorLector.class);
listaAutorLector.setParameter("idAutor", idAutor);
return listaAutorLector.getResultList();
}
@Override
public List<AutorLector> listarLectorAutor(Integer idLector) {
this.entity.getEntityManagerFactory().getCache().evictAll();
TypedQuery<AutorLector> listaAutorLector = this.entity.createNamedQuery("AutorLector.listarAutorPorLector", AutorLector.class);
listaAutorLector.setParameter("idLector", idLector);
return listaAutorLector.getResultList();
}
@Override
public List<AutorLector> listarAutorLector() {
TypedQuery<AutorLector> listaAutorLector = this.entity.createNamedQuery("AutorLector.listarTodo", AutorLector.class);
return listaAutorLector.getResultList();
}
}
| [
"[email protected]"
] | |
8f48ec8f42ff1a5c134ef6b4b0824a925583aa4f | 2e1c5e3f00f73f13df9da3f3857ab6c62dc9a72c | /src/java/entities/Religion.java | 15c3aaedad58c448fc8f8a970ed9d328b6ecfbe5 | [] | no_license | muhammadsafar/CV-Online-MII | 2a0d9240c341f1b8bbec1f25cde113d3fd8cc113 | 283c85caef5874d02c14b148d74c66a2163f7700 | refs/heads/master | 2020-03-26T04:38:05.623115 | 2018-08-27T04:49:21 | 2018-08-27T04:49:21 | 144,513,780 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,780 | 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 entities;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
*
* @author Dayinta Warih Wulandari
*/
@Entity
@Table(name = "RELIGION")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Religion.findAll", query = "SELECT r FROM Religion r")
, @NamedQuery(name = "Religion.findById", query = "SELECT r FROM Religion r WHERE r.id = :id")
, @NamedQuery(name = "Religion.findByReligion", query = "SELECT r FROM Religion r WHERE r.religion = :religion")})
public class Religion implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Column(name = "ID")
private Short id;
@Column(name = "RELIGION")
private String religion;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "religionId")
private List<AppDev> appDevList;
public Religion() {
}
public Religion(Short id) {
this.id = id;
}
public Religion(Short id, String religion) {
this.id = id;
this.religion = religion;
}
public Short getId() {
return id;
}
public void setId(Short id) {
this.id = id;
}
public String getReligion() {
return religion;
}
public void setReligion(String religion) {
this.religion = religion;
}
@XmlTransient
public List<AppDev> getAppDevList() {
return appDevList;
}
public void setAppDevList(List<AppDev> appDevList) {
this.appDevList = appDevList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Religion)) {
return false;
}
Religion other = (Religion) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "entities.Religion[ id=" + id + " ]";
}
}
| [
"[email protected]"
] | |
439a7ad5467966a18659173e6386358f078fb361 | f15a3b47be3dffd2758cc0cb73e4d34c5c3520ab | /service/src/androidTest/java/mji/tapia/com/service/ExampleInstrumentedTest.java | a00d1d245b986161c9c5889de6f831fe601ae6a3 | [] | no_license | otakutronic/Okurakobe | 794451cd8958e96ffdd38275befc57be1806542b | 74ae5c368d2a032d15d47fd236b142c7fe83fb1b | refs/heads/master | 2020-03-21T20:04:55.645211 | 2018-07-20T03:46:11 | 2018-07-20T03:46:11 | 138,985,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 751 | java | package mji.tapia.com.service;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("mji.tapia.com.service.test", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
356477bdf715e950472d988ae66718f46cfb0ad5 | 76b738b2b55a4155b43026457b33ad3bf43f98e9 | /app/src/main/java/ng/sterling/footballfixtures/ui/BaseActivity.java | 041852d242618d5ff9ca3d19cb4953634a9918dc | [] | no_license | uncle-tee/Football-Data-App | bb0dfc7d7885346932c6a9bb88f8feab6070a5a1 | 61f9da1d1f7beef69febcd6cb2a5c0a3a6f4e98d | refs/heads/master | 2020-07-05T23:44:14.503687 | 2019-09-11T08:46:32 | 2019-09-11T08:46:32 | 202,820,214 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 588 | java | package ng.sterling.footballfixtures.ui;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import dagger.android.support.DaggerAppCompatActivity;
/**
* Author: Oluwatobi Adenekan
* date: 13/08/2019
**/
public abstract class BaseActivity extends DaggerAppCompatActivity {
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Override
public boolean onSupportNavigateUp() {
finish();
return true;
}
}
| [
"[email protected]"
] | |
fe51debba1b4d2d11ed21542574b86f888fa0e21 | 5ff25f82a52cbc6f5cc968d5ce0445c4e78f7f2e | /src/test/unit/java/com/sdl/selenium/web/table/TableCellTest.java | 0ff6ba4573cdcfd508d4c3fd6dd64755d884cacd | [] | no_license | zevnull/Testy | 26221348b9b1cef97db076da82968553c4b54b2b | 8b9340bf4209bc1d2f1624a43863c1e4e62bfce9 | refs/heads/master | 2021-01-17T11:16:49.331145 | 2015-11-27T22:26:38 | 2015-11-27T22:26:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,023 | java | package com.sdl.selenium.web.table;
import com.sdl.selenium.extjs3.ExtJsComponent;
import com.sdl.selenium.web.SearchType;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
public class TableCellTest {
public static ExtJsComponent container = new ExtJsComponent("container");
public static Table table = new Table().setId("ID");
public static TableRow tableRow = new TableRow(table, "Text", SearchType.EQUALS);
@DataProvider
public static Object[][] testConstructorPathDataProvider() {
return new Object[][]{
{new TableCell(), "//td"},
{new TableCell(tableRow, 1), "//table[@id='ID']//tr[(.='Text' or count(*//text()[.='Text']) > 0)]//td[1]"},
{new TableCell(3, "Text", SearchType.EQUALS), "//td[3][(.='Text' or count(*//text()[.='Text']) > 0)]"},
{new TableCell(3, "Text", SearchType.CONTAINS), "//td[3][(contains(.,'Text') or count(*//text()[contains(.,'Text')]) > 0)]"},
{new TableCell(tableRow, 3, "Text", SearchType.EQUALS), "//table[@id='ID']//tr[(.='Text' or count(*//text()[.='Text']) > 0)]//td[3][(.='Text' or count(*//text()[.='Text']) > 0)]"},
{new TableCell(1, "Text", SearchType.DEEP_CHILD_NODE).setTag("th"), "//th[1][(contains(.,'Text') or count(*//text()[contains(.,'Text')]) > 0)]"},
{new TableCell(1, "Text", SearchType.DEEP_CHILD_NODE).setTag("td"), "//td[1][(contains(.,'Text') or count(*//text()[contains(.,'Text')]) > 0)]"},
{new TableCell(1, "Text", SearchType.DEEP_CHILD_NODE, SearchType.EQUALS), "//td[1][(.='Text' or count(*//text()[.='Text']) > 0)]"},
};
}
@Test(dataProvider = "testConstructorPathDataProvider")
public void getPathSelectorCorrectlyFromConstructors(TableCell tableCell, String expectedXpath) {
Assert.assertEquals(tableCell.getXPath(), expectedXpath);
}
}
| [
"[email protected]"
] | |
1eb9bd37db70ecd519a943c5a1479b6e31e2b647 | 6be00faaf4647f69dcd9b66c71f539fe4617b794 | /app/src/main/java/com/payu/payuapp/BuyStocks.java | 65413abdb0f970a5a6b9b0b5efcc8ec4129447ec | [
"MIT"
] | permissive | aman95/PayUApp | c42862bb4f66bb264f28ed87b5e1f66f73a516f9 | 0c85be5dc71f364a9216d51cebe79990acfafa3e | refs/heads/master | 2020-12-14T08:48:42.065502 | 2015-05-10T05:58:44 | 2015-05-10T05:58:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,472 | java | package com.payu.payuapp;
import android.content.Intent;
import android.support.v4.app.NavUtils;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
public class BuyStocks extends ActionBarActivity {
protected List<FeedItem> feedItems = new ArrayList<>();
protected StockAdapter adapter;
private Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_notifications);
//Setting up AppBar
toolbar = (Toolbar)findViewById(R.id.app_bar);
setSupportActionBar(toolbar);
//Setting up Navigation Drawer
Navigation_Drawer drawer_fragment = (Navigation_Drawer) getSupportFragmentManager().findFragmentById(R.id.fragment_Navigation_Drawer);
drawer_fragment.setUp(R.id.fragment_Navigation_Drawer, (DrawerLayout) findViewById(R.id.drawerLayout_Dashboard), toolbar);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_notifications, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onBackPressed() {
super.onBackPressed();
NavUtils.navigateUpFromSameTask(this);
}
public void changeToLeaderboard(View view) {
Intent i = new Intent(this,Leaderboard.class);
startActivity(i);
finish();
}
public void changeToPortfolio(View view) {
Intent i = new Intent(this,BuyStocks.class);
startActivity(i);
finish();
}
public void changeToNotifications(View view) {
Navigation_Drawer.closeDrawer();
}
}
| [
"[email protected]"
] | |
b5280c4b2660c30bb938b788566b95bba10679f6 | b6c11cfeda34199862138c683f33b14ea1cf7e84 | /Parser/Parser.java | 1aacd9571aa3fc17e5e08bc42cdf95603f88dd5f | [] | no_license | Jiangwei-shi/ICSI-311-Lexer | 49fa72ab1742d92ee6de7b9fcc8f321e0f03d54c | 0692cf28ce03fe3cd69500e747941bc57bd474dd | refs/heads/main | 2023-03-29T04:10:46.500127 | 2021-04-04T12:48:43 | 2021-04-04T12:48:43 | 342,054,176 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,532 | java | package lexer;
/*
* author Jiangwei Shi
*/
import java.util.ArrayList;
import java.util.List;
import lexer.MathOpNode.Mathoptype;
public class Parser {
//Pass list of Token and return a Node
public Node parser(List<Token> s) throws getException
{
Node result = Statements(s);//pass the list into Expression
return result;
}
//Statements method
Node Statements(List<Token> s) throws getException
{
Node left ;
List<Node> Nodelist = new ArrayList<>();
while(s.size() != 0 && s.get(0).getType() != Token.TokenType.EndOfLine)
{
Node right = null;
right = Statement(s);
Nodelist.add(right);
}
left =new StatementsNode(Nodelist);
return left;
}
//statement method , Print , Data , Read , identifier , Expression
Node Statement(List<Token> s) throws getException
{
Node right;
if (MatchAndRemove(Token.TokenType.Print,s) != null) //if it is print or String
{
right = PrintStatement(s);
}
else if (MatchAndRemove(Token.TokenType.Data,s) != null)
{
right = Datestatement(s);
}
else if (MatchAndRemove(Token.TokenType.Read,s) != null)
{
right = readstatement(s);
}
else if (MatchAndRemove(Token.TokenType.Input,s) != null)
{
right = Inputstatement(s);
}
else if (MatchAndRemove(Token.TokenType.GOSUB,s) != null)
{
right = GOSUBStatement(s);
}
else if (MatchAndRemove(Token.TokenType.FOR,s) != null)
{
right = FORStatement(s);
}
else if (MatchAndRemove(Token.TokenType.NEXT,s) != null)
{
right = NextStatement(s);
}
else if (MatchAndRemove(Token.TokenType.RETURN,s) != null)
{
right = RETURNStatement(s);
}
else if (MatchAndRemove(Token.TokenType.IF,s) != null)
{
right = IFStatement(s);
}
else if (s.get(0).getType() == Token.TokenType.RANDOM || s.get(0).getType() == Token.TokenType.LEFT$
|| s.get(0).getType() == Token.TokenType.RIGHT$ || s.get(0).getType() == Token.TokenType.MID$
|| s.get(0).getType() == Token.TokenType.NUM$ || s.get(0).getType() == Token.TokenType.VAL
|| s.get(0).getType() == Token.TokenType.VAL$)
{
right = FunctionStatement(s);
}
else if (s.get(0).getType() == Token.TokenType.label)
{
right = LabeledStatement(s);
}
else if (s.get(0).getType() == Token.TokenType.identifier)
{
right = Assignment(s);
}
else
{
right = Expression(s);
}
return right;
}
Node FunctionStatement(List<Token> s) throws getException {
Node Function = null;
Token functionname;
functionname =s.get(0);
s.remove(0);
List<Token> functionList = new ArrayList<>();
List<Node> FunctionList = new ArrayList<>();
if(MatchAndRemove(Token.TokenType.lparen, s) != null)
{
while(MatchAndRemove(Token.TokenType.rparen, s) == null) //if is lparen
{
while(MatchAndRemove(Token.TokenType.comma,s)==null && s.get(0).getType() != Token.TokenType.rparen)//if not comma and not Endofline, Then enter the while loop
{
functionList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
functionList.add(end);
FunctionList.add(Expression(functionList));
functionList.removeAll(functionList);
}
Function = new FunctionNode(functionname , FunctionList);
// TODO Auto-generated method stub
return Function;
}
else
throw new getException("the right type should be functionname ( entity , entity )");
}
Node IFStatement(List<Token> s) throws getException {
Node left = null;
Token right = null;
Node IFnode = null;
List<Token> TokenList = new ArrayList<>();
// TODO Auto-generated method stub
while(MatchAndRemove(Token.TokenType.THEN,s)==null)
{
while(s.get(0).getType() != Token.TokenType.THEN)//if not THEN, Then enter the while loop
{
TokenList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
TokenList.add(end);
left = BooleanOperationstatement(TokenList);
TokenList.removeAll(TokenList);
}
right = s.get(0);
s.remove(0);
IFnode = new IfNode(left,right);
return IFnode;
}
Node BooleanOperationstatement(List<Token> s) throws getException {
Node left = null;
Token operation;
Node right = null;
Node BooleanOperation;
List<Token> leftexpression = new ArrayList<>();
List<Token> rightexpression = new ArrayList<>();
while(s.get(0).getType() != Token.TokenType.lessthan && s.get(0).getType() != Token.TokenType.greaterthan
&& s.get(0).getType() != Token.TokenType.lessthanequals && s.get(0).getType() != Token.TokenType.greaterthanequals
&& s.get(0).getType() != Token.TokenType.Notequals && s.get(0).getType() != Token.TokenType.equals)
{
while(s.get(0).getType() != Token.TokenType.lessthan && s.get(0).getType() != Token.TokenType.greaterthan
&& s.get(0).getType() != Token.TokenType.lessthanequals && s.get(0).getType() != Token.TokenType.greaterthanequals
&& s.get(0).getType() != Token.TokenType.Notequals && s.get(0).getType() != Token.TokenType.equals)//if not THEN, Then enter the while loop
{
leftexpression.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
leftexpression.add(end);
left = Expression(leftexpression);
}
operation = s.get(0);
s.remove(0);
while(s.get(0).getType() != Token.TokenType.EndOfLine)
{
while(s.get(0).getType() != Token.TokenType.EndOfLine)//if not THEN, Then enter the while loop
{
rightexpression.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
rightexpression.add(end);
right = Expression(rightexpression);
}
BooleanOperation = new BooleanOperationNode(left, operation ,right);
return BooleanOperation;
}
//For loop method
Node FORStatement(List<Token> s) throws getException {
Node left ;
Node startvalue;
Node endvalue;
Node Stepvalue;
Node ForNode;
left = factor(s);
if(MatchAndRemove(Token.TokenType.equals, s) != null)
{
startvalue = factor(s);
if(MatchAndRemove(Token.TokenType.To, s) != null)
{
endvalue = factor(s);
if(MatchAndRemove(Token.TokenType.STEP, s) != null)
{
Stepvalue = factor(s);
ForNode = new ForNode(left,startvalue,endvalue,Stepvalue);
return ForNode;
}
else
{
ForNode = new ForNode(left,startvalue,endvalue);
return ForNode;
}
}
}
return null;
}
//return method
Node RETURNStatement(List<Token> s) throws getException
{
Node right;
if(s.get(0).getType()==Token.TokenType.EndOfLine)
{
right = new ReturnNode(s);
return right;
}
else
throw new getException("RETURN is alone, You couldn't add anything after it");
}
//Hold list of Token and return a Node ***under Input case hold list of variables and string
Node Inputstatement(List<Token> s) throws getException
{
Node left = null;
List<Node> listhold = new ArrayList<>();
listhold = Inputlist(s);
left = new InputNode(listhold); //pass Node list and return a Node
return left;
}
//Hold list of Token and return a Node list ***under Input case hold list of variables and string
List<Node> Inputlist(List<Token> s) throws getException {
List<Token> TokenList = new ArrayList<>();
List<Node> DataList = new ArrayList<>();
while(s.size() != 0 &&s.get(0).getType() != Token.TokenType.number)
{
while(MatchAndRemove(Token.TokenType.comma,s)==null && MatchAndRemove(Token.TokenType.EndOfLine,s)==null)//if not comma and not Endofline, Then enter the while loop
{
TokenList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
TokenList.add(end);
DataList.add(Expression(TokenList));
TokenList.removeAll(TokenList);
}
return DataList ;
}
//Hold list of Token and return a Node ***under read case hold list of variables
Node readstatement(List<Token> s) throws getException
{
if(s.get(0).getType() == Token.TokenType.identifier)
{
Node left = null;
List<Node> listhold = new ArrayList<>();
listhold = readlist(s);
left = new ReadNode(listhold); //pass Node list and return a Node
return left;
}
else
return null;
}
//Hold list of Token and return a Node list ***under read case hold list of variables
List<Node> readlist(List<Token> s) throws getException {
List<Token> TokenList = new ArrayList<>();
List<Node> DataList = new ArrayList<>();
while(s.size() != 0 && s.get(0).getType() == Token.TokenType.identifier)
{
while(MatchAndRemove(Token.TokenType.comma,s)==null && MatchAndRemove(Token.TokenType.EndOfLine,s)==null)//if not comma and not Endofline, Then enter the while loop
{
TokenList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
TokenList.add(end);
DataList.add(Expression(TokenList));
TokenList.removeAll(TokenList);
}
return DataList ;
}
//Hold list of Token and return a Node ***under Data case hold list of STRING, IntegerNode and FloatNode.
Node Datestatement(List<Token> s) throws getException
{
Node left = null;
List<Node> listhold = new ArrayList<>();
listhold = Datelist(s);
left = new DataNode(listhold); //pass Node list and return a Node
return left;
}
//Hold list of Token and return a Node list ***under Data case hold list of STRING, IntegerNode and FloatNode.
List<Node> Datelist(List<Token> s) throws getException {
List<Token> TokenList = new ArrayList<>();
List<Node> DataList = new ArrayList<>();
while(s.size() != 0 && s.get(0).getType() != Token.TokenType.identifier)
{
while(MatchAndRemove(Token.TokenType.comma,s)==null && MatchAndRemove(Token.TokenType.EndOfLine,s)==null)//if not comma and not Endofline, Then enter the while loop
{
TokenList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
TokenList.add(end);
DataList.add(Expression(TokenList));
TokenList.removeAll(TokenList);
}
return DataList ;
}
//Hold list of Token and return a Node ***under Print case
Node PrintStatement(List<Token> s) throws getException
{
Node left = null;
List<Node> listhold = new ArrayList<>();
listhold =printList(s);
left = new PrintNode(listhold); //pass Node list and return a Node
return left;
}
//Hold list of Token and return a Node list ***under Data case
List<Node> printList(List<Token> s) throws getException
{
List<Token> TokenList = new ArrayList<>();
List<Node> printList = new ArrayList<>();
while(s.size()!= 0)
{
while(MatchAndRemove(Token.TokenType.comma,s)==null && MatchAndRemove(Token.TokenType.EndOfLine,s)==null)//if not comma and not Endofline, Then enter the while loop
{
TokenList.add(s.get(0));
s.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
TokenList.add(end);
printList.add(Assignment(TokenList));
TokenList.removeAll(TokenList);
}
return printList ;
}
//label
Node LabeledStatement(List<Token> s1) throws getException
{
String left;
Node right;
Node labeledStatementNode;
left = s1.get(0).getValue();
s1.remove(0);
right = Assignment(s1);
labeledStatementNode = new LabeledStatementNode(left, right);
return labeledStatementNode;
}
//GOSUB
Node GOSUBStatement(List<Token> s1) throws getException
{
Node left;
Node right;
if(s1.get(0).getType() == Token.TokenType.identifier)
{
left = factor(s1);
right = new GosubNode(left);
return right;
}
else
throw new getException("GOSUB requires a single IDENTIFIER");
}
//NEXT
Node NextStatement(List<Token> s1) throws getException
{
Node left;
Node right;
if(s1.get(0).getType() == Token.TokenType.identifier)
{
left = factor(s1);
right = new NextNode(left);
return right;
}
else
throw new getException("Next requires a single IDENTIFIER");
}
//pass an identifier and Token list
Node Assignment(List<Token> s1) throws getException
{
Node left;
Node right;
Node Assignment;
if(s1.get(1).getType() == Token.TokenType.equals)
{
left = factor(s1);
s1.remove(0);
right = Expression(s1);
Assignment = new AssignmentNode(Mathoptype.equal, left, right);
return Assignment;
}
else
return Expression(s1);
}
//+,-Expression
Node Expression(List<Token> a) throws getException //deal with +,-
{
Node left;
Node right;
Node MathOpNode;
left = term(a); //recursion
if(MatchAndRemove(Token.TokenType.plus,a) != null)//if is plus match it and remove it
{
right =Expression(a);
MathOpNode = new MathOpNode(Mathoptype.Add, left, right);
return MathOpNode;
}
else if (MatchAndRemove(Token.TokenType.minus,a) != null)//if is minus match it and remove it
{
right =Expression(a);
MathOpNode = new MathOpNode(Mathoptype.Subtract, left, right);
return MathOpNode;
}
return left;
}
//*,term
Node term(List<Token> b) throws getException
{
Node left;
Node right;
Node MathOpNode;
left = factor(b); //recursion
if(MatchAndRemove(Token.TokenType.times,b) != null)//if is times match it and remove it
{
right =term(b);
MathOpNode = new MathOpNode(Mathoptype.Multyply, left, right);
return MathOpNode;
}
else if (MatchAndRemove(Token.TokenType.divide,b) != null)//if is divide match it and remove it
{
right =term(b);
MathOpNode = new MathOpNode(Mathoptype.Divide, left, right);
return MathOpNode;
}
return left;
}
//factor
Node factor(List<Token> c) throws getException
{
Token hold = MatchAndRemove(Token.TokenType.number,c);////if is number match it and remove it
if (hold != null)
{
if(hold.getValue().indexOf(".")>0)
{
FloatNode floatnode =new FloatNode(hold.getValue());
return floatnode;
}
else
{
IntegerNode intnode = new IntegerNode(hold.getValue());
return intnode;
}
}
else if (c.get(0).getType() == Token.TokenType.identifier)
{
VariableNode variablenode =new VariableNode(c.get(0).getValue());
c.remove(0);
return variablenode;
}
else if (c.get(0).getType() == Token.TokenType.string)
{
StringNode stringNode =new StringNode(c.get(0).getValue());
c.remove(0);
return stringNode;
}
else if (MatchAndRemove(Token.TokenType.lparen,c) != null )
{
List<Token> parenfunction = new ArrayList<>();
while(MatchAndRemove(Token.TokenType.rparen,c)==null)
{
parenfunction.add(c.get(0));
c.remove(0);
}
Token end = new Token(Token.TokenType.EndOfLine);
parenfunction.add(end);
return Expression(parenfunction);
}
else
throw new getException("The first letter in the list should be number");
}
//match and remove method
public Token MatchAndRemove(Token.TokenType type,List<Token> d )
{
if(d.get(0).getType() == type )
{
Token hold = new Token(type);
hold = d.get(0);
d.remove(0);
return hold;
}
return null;
}
}
| [
"[email protected]"
] | |
0e3113c1f53317ea1872fc62e5ac182820ff1574 | a3d74d5ae223c3aea3a2709b63b7ee4a14956ff7 | /src/com/company/Solution_14.java | a7f89de1ff4444cdbdf0e31f2494786a05275f34 | [
"Apache-2.0"
] | permissive | about608504/LeetCode | 56aed4e8fbe80059a5f83de4aa06b9bb0a22aa59 | 4520da8ee351b3e8c40a02953a1c4de150fdfeb2 | refs/heads/master | 2021-04-30T03:31:38.673737 | 2018-05-10T11:00:06 | 2018-05-10T11:00:06 | 121,518,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 649 | java | package com.company;
import java.util.Arrays;
public class Solution_14 {
public String longestComminPrefix(String[] strs) {
StringBuilder result = new StringBuilder();
if (strs.length > 0) {
Arrays.sort(strs);
char [] a = strs[0].toCharArray();
char[] b = strs[strs.length - 1].toCharArray();
for (int i = 0; i < a.length; i++) {
if (b.length > i && b[i] == a[i]) {
result.append(b[i]);
} else {
return result.toString();
}
}
}
return result.toString();
}
}
| [
"[email protected]"
] | |
506ed0f5a07f34b668cc902b86308d78c8d1ef3c | 7fa2add67683630c84d89a074644fa54d8168ef0 | /src/GeneraNumeros.java | 4bf050dcf2a9614d30e68fd78617cf719c491bdd | [] | no_license | sea21/Multithreading | 4f164e228bbf00558a88153d9eec8a145dff57d8 | 34fd6dbf7c69914f2cc2e0ea0adb3dd93e2e341e | refs/heads/master | 2021-01-10T04:07:19.839945 | 2015-11-24T20:50:25 | 2015-11-24T20:50:25 | 46,640,102 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 369 | java |
public class GeneraNumeros {
public int num() {
int numero = (int)Math.floor(Math.random()*(1-10)+10);
return numero;
}
public String numero(){
String numero = "";
for (int i = 0; i < 10; i++) {
numero = numero + num();
}
return numero;
}
public int asientos() {
int numero = (int)Math.floor(Math.random()*(1-6)+6);
return numero;
}
}
| [
"[email protected]"
] | |
f4045e1aea05b3f03c921655ac2f46291062244f | ccc68ecf1a76e14ec4f465a5f9e588650bfbf28c | /showcase-quarkus-eventsourcing/src/main/java/io/github/joht/showcase/quarkuseventsourcing/query/model/account/AccountQueryHandler.java | 2d7edd2fc71ad66397759e10a81346ce461fb6ae | [
"Apache-2.0"
] | permissive | JohT/showcase-quarkus-eventsourcing | f289bda5917297a8a75a5dca8689274383fa2d8a | d8c4101ff72c07340aa233fbc1fe0f3eedc8d21f | refs/heads/master | 2023-08-30T21:09:32.803586 | 2023-08-15T11:48:47 | 2023-08-15T11:48:47 | 208,556,644 | 55 | 12 | null | 2023-09-13T04:48:40 | 2019-09-15T07:15:52 | Java | UTF-8 | Java | false | false | 709 | java | package io.github.joht.showcase.quarkuseventsourcing.query.model.account;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import io.github.joht.showcase.quarkuseventsourcing.message.common.Nickname;
import io.github.joht.showcase.quarkuseventsourcing.message.query.account.AccountNicknameQuery;
import io.github.joht.showcase.quarkuseventsourcing.messaging.query.boundary.QueryModelQueryHandler;
@ApplicationScoped
public class AccountQueryHandler {
@Inject
AccountRepository repository;
@QueryModelQueryHandler
public Nickname getAccountNickname(AccountNicknameQuery query) {
return repository.read(new AccountEntityKey(query.getAccountId())).getNickname();
}
} | [
"[email protected]"
] | |
7ce01c0a67432b5e11d43a14495b26469aa5e8cd | 57ef99d2161f63ce3f967d71036ae6bd04580e8f | /AHS/src/ahs/StartView.java | 9dc813896dbcdb2957c4d72d24335540aa09b2a8 | [] | no_license | fnjav/D0007N | cda4ce03d00134003e4e5520c872c0b78d2cf2a8 | a01069700296e6ae960bbe0e490c8bace0f5f80f | refs/heads/master | 2021-05-31T22:53:33.386308 | 2016-05-23T18:01:17 | 2016-05-23T18:01:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,746 | java | package ahs;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import org.w3c.dom.Document;
import java.io.*;
/**
* Start AppView, should be removed
* @author Filip
*/
public class StartView implements ActionListener{
private AppView appView;
private JFrame frame;
private JLabel jL1, jL2;
private JButton jB1, jB2;
private final JPanel jPanel = new JPanel();
private SpringLayout layout;
private Container contentPane;
public StartView(){
appView = new AppView();
frame = new JFrame("Welcome");
frame.setSize(200,100);
// frame.setPreferredSize(new Dimension(333, 410));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
contentPane = frame.getContentPane();
layout = new SpringLayout();
contentPane.setLayout(layout);
jL1 = new JLabel("Leader");
//jL2 = new JLabel("Leader");
//jB1 = new JButton("Employee");
//jB1.addActionListener(this);
jB2 = new JButton("Leader");
jB2.addActionListener(this);
//jPanel.add(jL1);
//jPanel.add(jL2);
//jPanel.add(jB1);
jPanel.add(jB2);
frame.add(jPanel);
frame.setVisible(false);
appView.run();
}// slut på konstruktor
public void actionPerformed(ActionEvent e) {
String a = e.getActionCommand();
if(a.equals("Employee")){
}
if(a.equals("Leader")){
frame.setVisible(false);
appView.run();
}
}
} | [
"[email protected]"
] | |
9bda40a008e0ad7e0f33625110133f496694d082 | 6b108548cbc3e272c7e1b61221782221947dcd24 | /src/test/java/com/mjy/cyber/GameOfLifeTest.java | ad3abb6b29fdc7e0b5bb88271f6c0334753f0bbe | [] | no_license | lh-1/cyber-dojo | 997be67710ba385a27c4694a193401aa5d4201cd | e94a80c2a18fccff2d7e76b3f07dd4ef21ad0a7d | refs/heads/master | 2020-03-26T23:21:08.892544 | 2018-10-24T10:14:28 | 2018-10-24T10:14:28 | 145,534,044 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,027 | java | package com.mjy.cyber;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
public class GameOfLifeTest {
@Test
public void gameOfLife() {
// given
GameOfLife gameOfLife = new GameOfLife();
gameOfLife.setHeight(4);
gameOfLife.setLength(8);
gameOfLife.setPointAlive(1, 4);
gameOfLife.setPointAlive(2, 3);
gameOfLife.setPointAlive(2, 4);
// when
List<int[][]> boardList = gameOfLife.findAllBoardList();
// then
int[] line0 = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
int[] line1 = new int[]{0, 0, 0, 1, 1, 0, 0, 0};
int[] line2 = new int[]{0, 0, 0, 1, 1, 0, 0, 0};
int[] line3 = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
Assert.assertEquals(1, boardList.size());
Assert.assertTrue(Arrays.equals(line0, boardList.get(0)[0]));
Assert.assertTrue(Arrays.equals(line1, boardList.get(0)[1]));
Assert.assertTrue(Arrays.equals(line2, boardList.get(0)[2]));
Assert.assertTrue(Arrays.equals(line3, boardList.get(0)[3]));
}
@Test
public void gameOfLife2() {
// given
GameOfLife gameOfLife = new GameOfLife();
gameOfLife.setHeight(4);
gameOfLife.setLength(4);
gameOfLife.setPointAlive(1, 2);
gameOfLife.setPointAlive(2, 1);
gameOfLife.setPointAlive(2, 2);
// when
List<int[][]> boardList = gameOfLife.findAllBoardList();
// then
int[] line0 = new int[]{0, 0, 0, 0};
int[] line1 = new int[]{0, 1, 1, 0};
int[] line2 = new int[]{0, 1, 1, 0};
int[] line3 = new int[]{0, 0, 0, 0};
Assert.assertEquals(1, boardList.size());
Assert.assertTrue(Arrays.equals(line0, boardList.get(0)[0]));
Assert.assertTrue(Arrays.equals(line1, boardList.get(0)[1]));
Assert.assertTrue(Arrays.equals(line2, boardList.get(0)[2]));
Assert.assertTrue(Arrays.equals(line3, boardList.get(0)[3]));
}
}
| [
"[email protected]"
] | |
5d16cfb3624ff6bc68117b749276379efac0c7d1 | 50fbcf75dddd24101b4ff71021ef4caf895f8c13 | /src/main/java/fei/stuba/bp/rigo/preteky/online/repo/ClubRepositoryOnline.java | 9209f4c05fcfeba5a8dee224387bde7a7622300c | [] | no_license | PeterGigaByte/local_race | 7c3bfdb9e569462cca9b4e5a48451cf227ec1888 | 6700910ff39fabf37373f1938c083203136ddea8 | refs/heads/master | 2023-05-28T21:48:08.728242 | 2021-06-03T21:11:40 | 2021-06-03T21:11:40 | 366,658,233 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 379 | java | package fei.stuba.bp.rigo.preteky.online.repo;
import fei.stuba.bp.rigo.preteky.models.sql.Club;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
public interface ClubRepositoryOnline extends JpaRepository<Club, Integer>, JpaSpecificationExecutor<Club> {
Club findClubById(Integer id);
} | [
"[email protected]"
] | |
20dd9b93f96d413cefa4857cc3e1fb9c24d98c07 | a9f8f7105e51f90f8b3844989608da2efdff8800 | /app/src/main/java/com/caircb/rcbtracegadere/generics/AppMyActivity.java | d76c0467bb1b852489c7448d01c8adc1bf3e4c00 | [] | no_license | AnabelyFernandezT/App-Registro-Desechos | bcad635ec608f20218c08290954482ea791c0a75 | 89055edc81516b9b6ef740495db6a7ec34c4c99b | refs/heads/main | 2023-05-30T06:57:00.650160 | 2021-06-11T00:20:54 | 2021-06-11T00:20:54 | 375,860,427 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,090 | java | package com.caircb.rcbtracegadere.generics;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.app.ProgressDialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.database.Cursor;
import android.device.ScanManager;
import android.device.scanner.configuration.PropertyID;
import android.media.AudioManager;
import android.media.SoundPool;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.SimpleCursorAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentTransaction;
import com.caircb.rcbtracegadere.MyApp;
import com.caircb.rcbtracegadere.database.AppDatabase;
import com.caircb.rcbtracegadere.dialogs.DialogBuilder;
import com.caircb.rcbtracegadere.R;
import com.caircb.rcbtracegadere.ScanManager.IOnScannerEvent;
import com.caircb.rcbtracegadere.helpers.MySession;
import com.caircb.rcbtracegadere.utils.ApplicationService;
import com.caircb.rcbtracegadere.utils.Utils;
;
public class AppMyActivity extends Activity {
public AppDatabase dbHelper;
public Cursor cursor;
AlertDialog.Builder messageBox;
public ProgressDialog dialog;
public Fragment fragment;
private ProgressDialog pausingDialog;
private int[] to1 = new int[]{android.R.id.text1};
private SimpleCursorAdapter adapter1;
private Spinner defaulSpiner;
//private MyReceiver receiver;
public EditText Barcode;
private final static String SCAN_ACTION = ScanManager.ACTION_DECODE;
private ScanManager mScanManager;
private SoundPool soundpool = null;
private int soundid;
public void showToast(String mensaje) {
Toast.makeText(this, mensaje, Toast.LENGTH_SHORT).show();
}
private BroadcastReceiver mScanReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
soundpool.play(soundid, 1, 1, 0, 0, 1);
byte[] barcode = intent.getByteArrayExtra(ScanManager.DECODE_DATA_TAG);
int barcodelen = intent.getIntExtra(ScanManager.BARCODE_LENGTH_TAG, 0);
String barcodeStr = new String(barcode, 0, barcodelen);
if(barcodeStr!=null && fragment!=null && barcodeStr.length()>0){
barcodeStr =barcodeStr.replaceAll(System.getProperty("line.separator"), "");
if(fragment instanceof OnBarcodeListener){
((OnBarcodeListener)fragment).reciveData(barcodeStr);
}
}
}
};
public ProgressDialog ProgressDialog(){
if(dialog!=null) {if(dialog.isShowing())dialog.dismiss();dialog=null;}
dialog = new ProgressDialog(this);
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.setCancelable(false);
return dialog;
}
public void messageBox(String method, String message)
{
messageBox = new AlertDialog.Builder(this);
messageBox.setTitle(method);
messageBox.setMessage(message);
messageBox.setCancelable(false);
messageBox.setNeutralButton("OK", null);
messageBox.show();
}
public void messageBox(String message)
{
messageBox = new AlertDialog.Builder(this);
messageBox.setTitle("INFO");
messageBox.setMessage(message);
messageBox.setCancelable(false);
messageBox.setNeutralButton("OK", null);
messageBox.show();
}
public void hideKeyboard() {
// Check if no view has focus:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
}
public void toggleKeyBoardEvent(){
((InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE))
.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
}
public void hideKeyBoardEvent(TextView txt){
((InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(txt.getWindowToken(), 0);
}
public void setupActionBar() {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
public int getIndex(Cursor cursor, String myString)
{
int index = 0,i=0;
if (cursor.moveToFirst()) {
do {
i++;
if(cursor.getString(4).trim().equals(myString.trim())){
index=i;
}
} while ( index==0 && cursor.moveToNext());
}
return index;
}
private void scanBarcode(String data){
if(Barcode!=null){
Barcode.setText(data);
Barcode.setSelection(Barcode.getText().length());
}
}
private void initListenerScan() {
mScanManager = new ScanManager();
mScanManager.openScanner();
mScanManager.switchOutputMode( 0);
soundpool = new SoundPool(1, AudioManager.STREAM_NOTIFICATION, 100); // MODE_RINGTONE
soundid = soundpool.load("/etc/Scan_new.ogg", 1);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
/*
receiver = new MyReceiver(mHandler);
IntentFilter filter = new IntentFilter();
filter.addAction("com.android.server.scannerservice.broadcast");
registerReceiver(receiver, filter);
mBoundReceiver=true;
*/
}
@Override
protected void onPause() {
super.onPause();
if (mScanManager != null) {
mScanManager.stopDecode();
}
unregisterReceiver(mScanReceiver);
}
@Override
protected void onDestroy() {
Barcode=null;
MySession.setDestroy(true);
super.onDestroy();
}
@Override
protected void onStop() {
MySession.setStop(true);
super.onStop();
}
@Override
protected void onResume() {
super.onResume();
initListenerScan();
IntentFilter filter = new IntentFilter();
int[] idbuf = new int[]{PropertyID.WEDGE_INTENT_ACTION_NAME, PropertyID.WEDGE_INTENT_DATA_STRING_TAG};
String[] value_buf = mScanManager.getParameterString(idbuf);
if (value_buf != null && value_buf[0] != null && !value_buf[0].equals("")) {
filter.addAction(value_buf[0]);
} else {
filter.addAction(SCAN_ACTION);
}
registerReceiver(mScanReceiver, filter);
}
@Override
protected void onStart() {
startService(new Intent(getBaseContext(), ApplicationService.class));
MySession.setStop(false);
if(MySession.isDestroy()){
MySession.setDestroy(false);
}
super.onStart();
}
}
| [
"[email protected]"
] | |
5c4375e203bf691f30f1e9e15cae0f376a2935f5 | 7b2c9afb8233f880f82273273e46fdbc263363e1 | /FCSPos/app/src/main/java/com/fcs/fcspos/ui/fragments/UpHoseFragment.java | 2ba521e5198736a3f6c16ce070cfe8924433ff52 | [] | no_license | helbertboca/FCSPos | be1f27bb6866f89428ecde5da85e8b1bc6a097fa | 25fa5c9b11729e93a539c1b148fc6db41030550f | refs/heads/master | 2020-12-29T23:40:56.754615 | 2020-04-06T20:45:09 | 2020-04-06T20:45:09 | 238,780,386 | 0 | 1 | null | 2020-03-18T21:34:08 | 2020-02-06T20:40:25 | Java | UTF-8 | Java | false | false | 2,156 | java | package com.fcs.fcspos.ui.fragments;
import android.app.Activity;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.fcs.fcspos.R;
import com.fcs.fcspos.io.AppMfcProtocol;
import com.fcs.fcspos.model.SaleOption;
/**
* A simple {@link Fragment} subclass.
*/
public class UpHoseFragment extends Fragment {
private SaleOption saleOption;
private AppMfcProtocol appMfcProtocol;
public UpHoseFragment(AppMfcProtocol appMfcProtocol){
this.appMfcProtocol = appMfcProtocol;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
HoseThread hoseThread = new HoseThread(27);
hoseThread.start();
return inflater.inflate(R.layout.fragment_up_hose, container, false);
}
//----------------------------------------------------------------------------------------------
class HoseThread extends Thread {
private long minPrime;
private boolean correctHose=false;
HoseThread(long minPrime) {
this.minPrime = minPrime;
}
public void run() {
short count=0;
do {
appMfcProtocol.machineCommunication(true);
if(appMfcProtocol.isCorrectHose()){
correctHose=true;
break;
}
count++;
if(count>minPrime){
correctHose=false;
break;
}
} while (appMfcProtocol.getEstado() == appMfcProtocol.getDispenser().getCod_LISTO() ||
appMfcProtocol.getEstado() == appMfcProtocol.getDispenser().getCod_ESPERA());
saleOption.correctHose(correctHose);
}
}
//----------------------------------------------------------------------------------------------
@Override
public void onAttach(Activity activity){
super.onAttach(activity);
saleOption = (SaleOption) activity;
}
}
| [
"[email protected]"
] | |
83061504bcf5245f492e350b3781ef1c2cad4eff | 2c1c69ceb3fab13e38bfcc6b728e26bdbeede4bf | /mobile/src/main/java/de/smarthome_blogger/smarthome/adapters/RoomAdapter.java | 48e001ea48171624080e32fdbb94b4b8514a29a9 | [] | no_license | smarthomeblogger/Smarthome-App | e3e60045e0098509b22cdf86011f011335c3234d | adb639662cdc7aff3f1c60776d07ec84d0904ced | refs/heads/master | 2021-01-24T13:01:14.052809 | 2017-06-22T08:21:25 | 2017-06-22T08:21:25 | 50,129,872 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,436 | java | package de.smarthome_blogger.smarthome.adapters;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
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.CompoundButton;
import android.widget.ImageView;
import android.widget.Switch;
import android.widget.TextView;
import java.util.ArrayList;
import de.smarthome_blogger.smarthome.R;
import de.smarthome_blogger.smarthome.items.RoomItem;
import de.smarthome_blogger.smarthome.system.Icons;
import de.smarthome_blogger.smarthome.system.RoomControl;
/**
* Created by Sascha on 18.04.2017.
*/
public class RoomAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>{
final int VIEW_TYPE_SWITCH = 0;
final int VIEW_TYPE_SENSOR = 1;
final int VIEW_TYPE_HEATING = 2;
final int VIEW_TYPE_SCENE = 3;
int lastPosition = -1;
boolean setState = false;
ArrayList<RoomItem> roomItems;
Activity activity;
Context context;
View view;
public RoomAdapter(ArrayList<RoomItem> roomItems, Activity activity, Context context, View view){
this.roomItems = roomItems;
this.activity = activity;
this.context = context;
this.view = view;
}
/**
* Gibt die RoomItems zurück
* @return
*/
public ArrayList<RoomItem> getRoomItems(){
return roomItems;
}
/**
* Gibt die Activity zurück
* @return
*/
public Activity getActivity(){
return activity;
}
@Override
public int getItemCount(){
return roomItems.size();
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int i){
if(holder instanceof SwitchViewHolder){
final RoomItem ri = roomItems.get(i);
final SwitchViewHolder switchViewHolder = (SwitchViewHolder) holder;
switchViewHolder.name.setText(ri.getName());
switchViewHolder.icon.setImageResource(Icons.getDeviceIcon(ri.getIcon()));
setState = true;
switchViewHolder.switchView.setChecked(ri.getValue().equals("true"));
setState = false;
switchViewHolder.switchView.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if(!setState){
setState = true;
switchViewHolder.switchView.setChecked(!switchViewHolder.switchView.isChecked());
setState = false;
}
}
});
switchViewHolder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
setState = true;
RoomControl.setModes(view, activity, ri, i, !switchViewHolder.switchView.isChecked(),
new RoomControl.OnAdapterNotifyListener() {
@Override
public void onNotify(int i) {
notifyItemChanged(i);
}
});
switchViewHolder.switchView.setChecked(!switchViewHolder.switchView.isChecked());
setState = false;
}
});
setAnimation(((SwitchViewHolder) holder).container, i);
}
else if(holder instanceof SensorViewHolder){
final RoomItem ri = roomItems.get(i);
final SensorViewHolder sensorViewHolder = (SensorViewHolder) holder;
sensorViewHolder.icon.setImageResource(Icons.getValueIcon(ri.getIcon()));
sensorViewHolder.value.setText(ri.getValue());
sensorViewHolder.name.setText(ri.getName());
sensorViewHolder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RoomControl.showOverview(activity, ri, ri.getRoom());
}
});
}
else if(holder instanceof HeatingViewHolder){
final RoomItem ri = roomItems.get(i);
final HeatingViewHolder heatingViewHolder = (HeatingViewHolder) holder;
heatingViewHolder.icon.setImageResource(Icons.getDeviceIcon(ri.getIcon()));
heatingViewHolder.value.setText(ri.getValue());
heatingViewHolder.name.setText(ri.getName());
heatingViewHolder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RoomControl.openHeatingDialog();
}
});
}
else if(holder instanceof SceneViewHolder){
final RoomItem ri = roomItems.get(i);
final SceneViewHolder sceneViewHolder = (SceneViewHolder) holder;
sceneViewHolder.icon.setImageResource(Icons.getSystemInfoIcon(ri.getName()));
sceneViewHolder.name.setText(ri.getName());
sceneViewHolder.container.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
RoomControl.openSceneMenu();
}
});
}
}
public void setAnimation(View viewToAnimate, int position){
if(position > lastPosition){
Animation animation = AnimationUtils.loadAnimation(context, R.anim.recycler_animation);
viewToAnimate.startAnimation(animation);
lastPosition = position;
}
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType){
View itemView;
switch(viewType){
case VIEW_TYPE_SWITCH:
itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.switch_item, viewGroup, false);
return new SwitchViewHolder(itemView);
case VIEW_TYPE_HEATING:
itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.value_item, viewGroup, false);
return new HeatingViewHolder(itemView);
case VIEW_TYPE_SCENE:
itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.value_item, viewGroup, false);
return new SceneViewHolder(itemView);
case VIEW_TYPE_SENSOR:
itemView = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.value_item, viewGroup, false);
return new SensorViewHolder(itemView);
}
return null;
}
@Override
public int getItemViewType(int position){
if(roomItems.get(position).getType().equals("switch")){
return VIEW_TYPE_SWITCH;
}
else if(roomItems.get(position).getType().equals("sensor")){
return VIEW_TYPE_SENSOR;
}
else if(roomItems.get(position).getType().equals("scene")){
return VIEW_TYPE_SCENE;
}
else if(roomItems.get(position).getType().equals("heating")){
return VIEW_TYPE_HEATING;
}
return VIEW_TYPE_SENSOR;
}
public class SwitchViewHolder extends RecyclerView.ViewHolder{
protected TextView name;
protected ImageView icon;
protected Switch switchView;
protected View container;
public SwitchViewHolder(View v){
super(v);
container = v.findViewById(R.id.container);
name = (TextView) v.findViewById(R.id.name);
icon = (ImageView) v.findViewById(R.id.icon);
switchView = (Switch) v.findViewById(R.id.switch_view);
}
}
public class SensorViewHolder extends RecyclerView.ViewHolder{
protected TextView value, name;
protected ImageView icon;
protected View container;
public SensorViewHolder(View v){
super(v);
container = v.findViewById(R.id.container);
value = (TextView) v.findViewById(R.id.value);
name = (TextView) v.findViewById(R.id.name);
icon = (ImageView) v.findViewById(R.id.icon);
}
}
public class HeatingViewHolder extends RecyclerView.ViewHolder{
protected TextView value, name;
protected ImageView icon;
protected View container;
public HeatingViewHolder(View v){
super(v);
container = v.findViewById(R.id.container);
value = (TextView) v.findViewById(R.id.value);
name = (TextView) v.findViewById(R.id.name);
icon = (ImageView) v.findViewById(R.id.icon);
}
}
public class SceneViewHolder extends RecyclerView.ViewHolder{
protected TextView name;
protected ImageView icon;
protected View container;
public SceneViewHolder(View v){
super(v);
container = v.findViewById(R.id.container);
name = (TextView) v.findViewById(R.id.name);
v.findViewById(R.id.value).setVisibility(View.GONE);
icon = (ImageView) v.findViewById(R.id.icon);
}
}
}
| [
"[email protected]"
] | |
a03e0b0b5d24c0f025caa3599b5661f4c7b59243 | 644277e4b4aa6b3a9932931081bb524c53688937 | /Java/Examples/srpggame(0.5)/src/loon/srpg/field/SRPGMoveStack.java | 9df1ec924020fd073fcf902cab483c2490f1435b | [
"Apache-2.0"
] | permissive | cping/LGame | 25e905281e31f4ca9e60ddbf7e192d130c8fa886 | 9b003a2e3e8a485c1b039b1ba15971dc17eb3f3c | refs/heads/master | 2023-08-31T23:23:10.921734 | 2023-08-30T10:16:12 | 2023-08-30T10:16:12 | 6,753,822 | 470 | 163 | Apache-2.0 | 2022-02-16T06:29:56 | 2012-11-19T02:05:03 | Java | UTF-8 | Java | false | false | 3,732 | java | /**
* Copyright 2008 - 2011
*
* 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.
*
* @project loonframework
* @author chenpeng
* @email:[email protected]
* @version 0.1
*/
package loon.srpg.field;
import loon.Screen;
import loon.srpg.SRPGType;
import loon.srpg.actor.SRPGActor;
import loon.utils.CollectionUtils;
public class SRPGMoveStack {
private int pos_x;
private int pos_y;
private int[] directions;
private int[] speed;
private boolean[] show;
private boolean[] change;
private int default_speed;
private boolean default_show;
private boolean default_change;
public SRPGMoveStack(int x, int y) {
this.pos_x = x;
this.pos_y = y;
this.setDefault();
this.directions = new int[0];
this.speed = new int[0];
this.show = new boolean[0];
this.change = new boolean[0];
}
private void setDefault() {
this.default_speed = 10;
this.default_show = true;
this.default_change = true;
}
public void setDefaultSpeed(int i) {
this.default_speed = i;
}
public void setDefaultShow(boolean flag) {
this.default_show = flag;
}
public void setDefaultChange(boolean flag) {
this.default_change = flag;
}
public void setDefault(int i, boolean flag, boolean flag1) {
this.setDefaultSpeed(i);
this.setDefaultShow(flag);
this.setDefaultChange(flag1);
}
public void removeStack() {
if (size() <= 0) {
return;
}
this.directions = CollectionUtils.copyOf(directions,
directions.length - 1);
this.speed = CollectionUtils.copyOf(speed, speed.length - 1);
this.show = CollectionUtils.copyOf(show, show.length - 1);
this.change = CollectionUtils.copyOf(change, change.length - 1);
}
public void addStack(int i) {
addStack(i, default_speed, default_show, default_change);
}
public void addStack(int d, int s, boolean isShow, boolean isChange) {
int size = directions.length;
this.directions = (int[]) CollectionUtils.expand(directions, 1);
this.speed = (int[]) CollectionUtils.expand(speed, 1);
this.show = (boolean[]) CollectionUtils.expand(show, 1);
this.change = (boolean[]) CollectionUtils.expand(change, 1);
this.directions[size] = d;
this.speed[size] = s;
this.show[size] = isShow;
this.change[size] = isChange;
switch (d) {
case SRPGType.MOVE_UP:
pos_y--;
break;
case SRPGType.MOVE_DOWN:
pos_y++;
break;
case SRPGType.MOVE_LEFT:
pos_x--;
break;
case SRPGType.MOVE_RIGHT:
pos_x++;
break;
}
}
public int size() {
return directions.length;
}
public int[] getVector() {
return directions;
}
public int[] getSpeed() {
return speed;
}
public boolean[] getShow() {
return show;
}
public boolean[] getChange() {
return change;
}
public int getPosX() {
return pos_x;
}
public int getPosY() {
return pos_y;
}
public void moveActor(SRPGActor actor, Screen screen) {
boolean flag = actor.isAnimation();
int size = directions.length;
for (int i = 0; i < size; i++) {
int d = directions[i];
boolean isShow = show[i];
boolean isChange = change[i];
actor.setAnimation(isShow);
if (isChange) {
actor.setDirection(d);
}
actor.moveActorOnly(directions[i], speed[i]);
actor.waitMove(screen);
}
actor.setAnimation(flag);
}
}
| [
"[email protected]"
] | |
07bfb4a6773097a94cce7bd75dc25fb81b690d39 | 516f2ebfbadce79a633d49072e05e51404679fd1 | /src/com/stmungo/client/service/ServiceAsync.java | b679236e771a23244b229b8b1ff5a611f9b3c533 | [] | no_license | StuartArmit/StMungoWebApp | 92d2249a3c657ad3701dd2e0d4094f207d20124f | fb823b2eeda5c5e22ef276765739f8cc2a52d975 | refs/heads/master | 2022-12-14T05:05:12.568118 | 2020-09-15T13:49:13 | 2020-09-15T13:49:13 | 295,741,456 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 927 | java | package com.stmungo.client.service;
import com.google.gwt.user.client.rpc.AsyncCallback;
//Using Remote Procedure Calls to make Asyncronous callbacks between
//server and client side ensures the browser doensn't hang due to multithreading
public interface ServiceAsync {
void getTranslatorMain(String text, AsyncCallback callback);
void getValidatorMain(String vText, AsyncCallback callback);
void getTranslatorRole(String text, AsyncCallback callback);
void getValidatorRole(String vText, AsyncCallback callback);
void getTranslatorProtocol(String text, AsyncCallback callback);
void getValidatorProtocol(String vText, AsyncCallback callback);
void getTranslatorChoice(String text, AsyncCallback callback);
void getValidatorChoice(String vText, AsyncCallback callback);
void getTranslatorTypestate(String text, AsyncCallback callback);
void getValidatorTypestate(String vText, AsyncCallback callback);
} | [
"[email protected]"
] | |
080a5833e5318155868cbaae19c15c3d3b5bea5e | 9d5e4332e4325039b13aacb02655135fc343a1cd | /src/two/two_3/ExampleQuick3_inserttion.java | 2710a31a507076bb7aa1ffb5321c7be5c187a753 | [] | no_license | yangdong125845/algs4_1 | f633beb35ce7a8e309fad6c5eccbde219ba2fadc | 9ece7e676bd058111f886da9b2328fdadd93e5bf | refs/heads/master | 2021-12-01T01:10:08.935114 | 2021-11-09T09:39:06 | 2021-11-09T09:39:06 | 206,907,956 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,669 | java | package two.two_3;
import edu.princeton.cs.algs4.In;
import edu.princeton.cs.algs4.StdOut;
import edu.princeton.cs.algs4.StdRandom;
//消除连个边界,lo边界本来就不需要,hi边界把最大元素发在a.length-1就好了
public class ExampleQuick3_inserttion {
private static int CUTOFF = 15;
public static void sort(Comparable[] a) {
StdRandom.shuffle(a); //消除对输入的依赖
int temp = 0;
for (int i = 1; i < a.length; i++) {
if (less(a[temp], a[i])) temp = i;
}
exch(a, temp, a.length - 1);
sort(a, 0, a.length - 1);
}
private static void sort(Comparable[] a, int lo, int hi) {
if (hi - lo < CUTOFF) {
insertionSort(a, lo, hi);
return;
}
//将数组a[lo..hi]排序
if (hi <= lo) return;
int j = partition(a, lo, hi); //切分
sort(a, lo, j - 1); //将左半部分a[lo..j-1] 排序
sort(a, j + 1, hi); //将右半部分a[j+1..hi]排序
}
private static int partition(Comparable[] a, int lo, int hi) {
//将数组切分为a[lo..i-1],a[i],a[i+1..hi]
int i = lo, j = hi + 1; //左右扫描指针
Comparable v = a[lo];
while (true) {
//扫描左右,检查扫描是都结束并交换元素
while (less(a[++i], v)) ;
while (less(v, a[--j])) ;
if (i >= j) break;
exch(a, i, j);
}
exch(a, lo, j); //将 v= a[j] 放入正确的位置
return j; //a[lo..j-1] <=a[j] <=a[j+1..hi] 达成
}
public static void insertionSort(Comparable[] a, int lo, int hi) {
for (int i = lo; i < hi; i++) {
for (int j = i; j > lo && less(a[j], a[j - 1]); j--) {
exch(a, j, j - 1);
}
}
}
private static boolean less(Comparable v, Comparable w) {
return v.compareTo(w) < 0;
}
private static void exch(Comparable[] a, int i, int j) {
Comparable t = a[i];
a[i] = a[j];
a[j] = t;
}
private static void show(Comparable[] a) {
for (int i = 0; i < a.length; i++) {
StdOut.print(a[i] + " ");
}
StdOut.println();
}
public static boolean isSorted(Comparable[] a) {
for (int i = 1; i < a.length; i++) {
if (less(a[i], a[i - 1])) return false;
}
return true;
}
public static void main(String[] args) {
//从标准输入读取字符串,将它们排序并输出
String[] a = In.readStrings();
sort(a);
assert isSorted(a);
show(a);
}
}
| [
"[email protected]"
] | |
e995512412425f6a9eb0ace58ea951b5b994cf9f | a04b311bec74403e65770c3242547085232891a4 | /src/main/java/com/sapphireims/dto/UserWalletDto.java | 65ed019d784872d5b624aba63390e971a7687af5 | [] | no_license | lokesh5049/FoodDelivery | c3f24df6d3ea61f89b60c0fe444fc471b0137eab | 55323046983806d5454e5f94b2bcd7fd43c280d2 | refs/heads/master | 2022-12-21T21:55:20.688047 | 2019-06-05T08:48:55 | 2019-06-05T08:48:55 | 188,972,159 | 1 | 1 | null | 2022-12-15T23:28:36 | 2019-05-28T06:57:56 | HTML | UTF-8 | Java | false | false | 1,934 | java | /**
* Java class
*
*/
package com.sapphireims.dto;
/**
* @author lokesh.yadav
*
* @since Jan 24, 2019
*/
public class UserWalletDto {
private int id;
private String userid;
private String date;
private double amount;
private String cardNo;
private String cvvno;
private String expirydate;
/**
* @return the id
*/
public int getId() {
return id;
}
/**
* @param id the id to set
*/
public void setId(int id) {
this.id = id;
}
/**
* @return the userid
*/
public String getUserid() {
return userid;
}
/**
* @param userid the userid to set
*/
public void setUserid(String userid) {
this.userid = userid;
}
/**
* @return the date
*/
public String getDate() {
return date;
}
/**
* @param date the date to set
*/
public void setDate(String date) {
this.date = date;
}
/**
* @return the amount
*/
public double getAmount() {
return amount;
}
/**
* @param amount the amount to set
*/
public void setAmount(double amount) {
this.amount = amount;
}
/**
* @return the cardNo
*/
public String getCardNo() {
return cardNo;
}
/**
* @param cardNo the cardNo to set
*/
public void setCardNo(String cardNo) {
this.cardNo = cardNo;
}
/**
* @return the cvvno
*/
public String getCvvno() {
return cvvno;
}
/**
* @param cvvno the cvvno to set
*/
public void setCvvno(String cvvno) {
this.cvvno = cvvno;
}
/**
* @return the expirydate
*/
public String getExpirydate() {
return expirydate;
}
/**
* @param expirydate the expirydate to set
*/
public void setExpirydate(String expirydate) {
this.expirydate = expirydate;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "UserWalletDto [id=" + id + ", userid=" + userid + ", date=" + date + ", amount=" + amount + ", cardNo="
+ cardNo + ", cvvno=" + cvvno + ", expirydate=" + expirydate + "]";
}
}
| [
"[email protected]"
] | |
d81167c6b66d2b2cdf559497467819b44f383351 | 37d9e078236328d72f9cebe61b4d519f057b414f | /hutool-core/src/test/java/cn/hutool/core/img/ImgUtilTest.java | 14f4458c1e63aca8589ab4343f7bce05324da1b6 | [
"LicenseRef-scancode-mulanpsl-1.0-en",
"MulanPSL-1.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | amuran-com/hutool-parent | 9922ac59458d182e8f8845dae375f8163b0487bd | 82619827286329c4309068dfa7c28419e979587c | refs/heads/master | 2022-12-09T13:16:51.094639 | 2019-12-24T14:23:41 | 2019-12-24T14:23:41 | 229,954,785 | 0 | 0 | NOASSERTION | 2022-12-06T00:44:29 | 2019-12-24T14:22:35 | Java | UTF-8 | Java | false | false | 2,608 | java | package cn.hutool.core.img;
import java.awt.Color;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.junit.Ignore;
import org.junit.Test;
import cn.hutool.core.io.FileUtil;
public class ImgUtilTest {
@Test
@Ignore
public void scaleTest() {
ImgUtil.scale(FileUtil.file("e:/pic/test.jpg"), FileUtil.file("e:/pic/test_result.jpg"), 0.8f);
}
@Test
@Ignore
public void scalePngTest() {
ImgUtil.scale(FileUtil.file("f:/test/test.png"), FileUtil.file("f:/test/test_result.png"), 0.5f);
}
@Test
@Ignore
public void scaleByWidthAndHeightTest() {
ImgUtil.scale(FileUtil.file("f:/test/aaa.jpg"), FileUtil.file("f:/test/aaa_result.jpg"), 100, 400, Color.BLUE);
}
@Test
@Ignore
public void cutTest() {
ImgUtil.cut(FileUtil.file("d:/face.jpg"), FileUtil.file("d:/face_result.jpg"), new Rectangle(200, 200, 100, 100));
}
@Test
@Ignore
public void rotateTest() throws IOException {
Image image = ImgUtil.rotate(ImageIO.read(FileUtil.file("e:/pic/366466.jpg")), 180);
ImgUtil.write(image, FileUtil.file("e:/pic/result.png"));
}
@Test
@Ignore
public void flipTest() throws IOException {
ImgUtil.flip(FileUtil.file("d:/logo.png"), FileUtil.file("d:/result.png"));
}
@Test
@Ignore
public void pressImgTest() {
ImgUtil.pressImage(FileUtil.file("d:/picTest/1.jpg"), FileUtil.file("d:/picTest/dest.jpg"), ImgUtil.read(FileUtil.file("d:/picTest/1432613.jpg")), 0, 0, 0.1f);
}
@Test
@Ignore
public void pressTextTest() {
ImgUtil.pressText(//
FileUtil.file("e:/pic/face.jpg"), //
FileUtil.file("e:/pic/test2_result.png"), //
"版权所有", Color.WHITE, //
new Font("黑体", Font.BOLD, 100), //
0, //
0, //
0.8f);
}
@Test
@Ignore
public void sliceByRowsAndColsTest() {
ImgUtil.sliceByRowsAndCols(FileUtil.file("e:/pic/1.png"), FileUtil.file("e:/pic/dest"), 10, 10);
}
@Test
@Ignore
public void convertTest() {
ImgUtil.convert(FileUtil.file("e:/test2.png"), FileUtil.file("e:/test2Convert.jpg"));
}
@Test
@Ignore
public void writeTest() {
ImgUtil.write(ImgUtil.read("e:/test2.png"), FileUtil.file("e:/test2Write.jpg"));
}
@Test
@Ignore
public void compressTest() {
ImgUtil.compress(FileUtil.file("e:/pic/1111.png"), FileUtil.file("e:/pic/1111_target.jpg"), 0.8f);
}
@Test
@Ignore
public void copyTest() {
BufferedImage image = ImgUtil.copyImage(ImgUtil.read("f:/pic/test.png"), BufferedImage.TYPE_INT_RGB);
ImgUtil.write(image, FileUtil.file("f:/pic/test_dest.jpg"));
}
}
| [
"[email protected]"
] | |
ea161e020598f4908d356d6006d74a38b68c3c97 | 1e6320501696ab38829edcd690c66e84214eb655 | /src/test/java/Calculatortest.java | a2fc19f96677de19598172d9198ec40e3652d396 | [] | no_license | Magdalena35/Kalkulator | 1446c753906135c72efb8c8bbfb2e991469b6bce | 3385ea89c987fd25f93c7a8abe36eda08c03a98c | refs/heads/master | 2021-08-28T16:59:05.402348 | 2017-12-12T21:03:55 | 2017-12-12T21:03:55 | 113,229,687 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 694 | java | import com.kodilla.testing.calculator.Calculator;
public class Calculatortest {
public int add(int a, int b){
return (a+b);
}
public int subtract(int a, int b){
return (a-b);
}
public static void main(String [] args){
Calculator calculator =new Calculator();
int result = calculator.add(4, 2);
int result2 = calculator.subtract(4, 2);
if (result == 6) System.out.println("Test ok");
else {
System.out.println("Not ok");
}
if (result2 ==2) System.out.println("Test ok");
else {
System.out.println("Not ok");
}
}
}
| [
"[email protected]"
] | |
a60047ddb22212322343214c5204cec5d5308178 | 3ec98f0a09da836d28926056eba66b9b34008f95 | /RepoSearch_starter/app/src/main/java/com/raywenderlich/reposearch/MainActivity.java | 94981399689cc0a6dfad17784fe2d2d92be64f97 | [] | no_license | daynamic/Android_Latest_Components | 74010b85ea32971a27b03c239605f4bbbaab636d | 2074408618ff663f44312bcc35ec8246d11ba7b2 | refs/heads/master | 2020-05-24T07:44:49.901736 | 2019-05-13T05:13:28 | 2019-05-13T05:13:28 | 84,836,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,966 | java | /*
* Copyright (c) 2016 Razeware LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.raywenderlich.reposearch;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import java.io.IOException;
import java.util.ArrayList;
import okhttp3.OkHttpClient;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class MainActivity extends AppCompatActivity implements DownloadCompleteListener{
ListFragment mListFragment;
ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (findViewById(R.id.fragment_container) != null) {
if (savedInstanceState != null) {
return;
}
if (isNetworkConnected()) {
mProgressDialog = new ProgressDialog(this);
mProgressDialog.setMessage("Please wait...");
mProgressDialog.setCancelable(false);
mProgressDialog.show();
startDownload();
} else {
new AlertDialog.Builder(this)
.setTitle("No Internet Connection")
.setMessage("It looks like your internet connection is off. Please turn it " +
"on and try again")
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).setIcon(android.R.drawable.ic_dialog_alert).show();
}
}
}
private boolean isWifiConnected() {
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();
return networkInfo != null && (ConnectivityManager.TYPE_WIFI == networkInfo.getType()) && networkInfo.isConnected();
}
private boolean isNetworkConnected() {
ConnectivityManager connMgr = (ConnectivityManager)
getSystemService(Context.CONNECTIVITY_SERVICE); // 1
NetworkInfo networkInfo = connMgr.getActiveNetworkInfo(); // 2
return networkInfo != null && networkInfo.isConnected(); // 3
}
private void showListFragment(ArrayList<Repository> repositories) {
mListFragment = ListFragment.newInstance(repositories);
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, mListFragment).
commit();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
return id == R.id.action_settings || super.onOptionsItemSelected(item);
}
private void startDownload() {
/**
* Normal Request
* */
//new DownloadRepoTask(this).execute("https://api.github.com/repositories");
/**
* OkHttp network request......
* */
// makeRequestWithOkHttp("https://api.github.com/repositories");
/**
* Mkaing netowrk request with Volley
* */
// makeRequestWithVolley("https://api.github.com/repositories");
/**
* Making network request through Retrofit
* */
makeRetrofitCalls();
}
@Override
public void downloadComplete(ArrayList<Repository> repositories) {
showListFragment(repositories);
if (mProgressDialog != null) {
mProgressDialog.hide();
}
}
/*
* OkHttp network request......
*
* */
private void makeRequestWithOkHttp(String url) {
OkHttpClient client = new OkHttpClient(); // 1
okhttp3.Request request = new okhttp3.Request.Builder().url(url).build(); // 2
client.newCall(request).enqueue(new okhttp3.Callback() { // 3
@Override
public void onFailure(okhttp3.Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(okhttp3.Call call, okhttp3.Response response)
throws IOException {
final String result = response.body().string(); // 4
MainActivity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
downloadComplete(Util.retrieveRepositoriesFromResponse(result)); // 5
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
});
}
/**
*
* Making network request with Volley
* */
private void makeRequestWithVolley(String url) {
RequestQueue queue = Volley.newRequestQueue(this); // 1
StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
new com.android.volley.Response.Listener<String>() { // 2
@Override
public void onResponse(String response) {
try {
downloadComplete(Util.retrieveRepositoriesFromResponse(response)); // 3
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new com.android.volley.Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
queue.add(stringRequest); // 4
}
/**
* Making Network call thorugh Retrofit
* */
private void makeRetrofitCalls() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.github.com") // 1
.addConverterFactory(GsonConverterFactory.create()) // 2
.build();
RetrofitAPI retrofitAPI = retrofit.create(RetrofitAPI.class); // 3
Call<ArrayList<Repository>> call = retrofitAPI.retrieveRepositories(); // 4
call.enqueue(new Callback<ArrayList<Repository>>() { // 5
@Override
public void onResponse(Call<ArrayList<Repository>> call,
Response<ArrayList<Repository>> response) {
downloadComplete(response.body()); // 6
}
@Override
public void onFailure(Call<ArrayList<Repository>> call, Throwable t) {
Toast.makeText(MainActivity.this, t.getLocalizedMessage(), Toast.LENGTH_SHORT).show();
}
});
}
}
| [
"[email protected]"
] | |
e5945308203e47438cb5bf92136e627ed866f8b4 | afdfabe6d69e55086cdc59f9c6a9df158c73e7f8 | /src/main/java/com/tw/Service.java | f10d24529459560bf3762a8d969cf2d3f59f1c40 | [] | no_license | 313183373/student-grade-command-pattern-java-2019-1-8-2-59-10-727 | f1248c85a62137136d0559b4514dd0255a6750aa | 830b4b665cacdde2cf451e0c2c05745ff03c4d33 | refs/heads/master | 2020-05-03T00:27:20.309882 | 2019-03-30T09:34:47 | 2019-03-30T09:34:47 | 178,310,204 | 0 | 0 | null | 2019-03-29T01:34:38 | 2019-03-29T01:34:37 | null | UTF-8 | Java | false | false | 582 | java | package com.tw;
public interface Service {
String buildInputPrompt(boolean isFirst);
Object getUserInput();
boolean isValidCommand(Object command);
void handleCommand(Object command);
default void main() {
System.out.println(buildInputPrompt(true));
Object command = getUserInput();
if (!isValidCommand(command)) {
do {
System.out.println(buildInputPrompt(false));
command = getUserInput();
} while (!isValidCommand(command));
}
handleCommand(command);
}
}
| [
"[email protected]"
] | |
1ce602bc70d3fd1f33e182aaaddaa0ae78b32af7 | f615a74900b9e963023f04df99c55b25c1d28b66 | /krishi_seva/app/src/main/java/com/example/deepaks/krishiseva/view/signup/SignUpActivity.java | 7ed6be9109c9d222b6d7fe4f70b5cb2c2c67b7ec | [] | no_license | deepaksharma1992/Android-Nanodegree-Capstone-Project-Code | 87803e1f6b565f5f657ce606c729d7a5356db813 | 46db069559150fcfcf9e583cd0c5abdd8f112f89 | refs/heads/master | 2020-04-05T06:56:46.134719 | 2018-11-15T06:16:50 | 2018-11-15T06:16:50 | 156,657,755 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,551 | java | package com.example.deepaks.krishiseva.view.signup;
import android.annotation.TargetApi;
import android.content.DialogInterface;
import android.content.IntentSender;
import android.content.pm.PackageManager;
import android.location.Location;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import com.example.deepaks.krishiseva.R;
import com.example.deepaks.krishiseva.bean.User;
import com.example.deepaks.krishiseva.util.DatabaseUserUtils;
import com.example.deepaks.krishiseva.util.DialogUtils;
import com.example.deepaks.krishiseva.util.GlobalUtils;
import com.example.deepaks.krishiseva.util.LocationUtils;
import com.example.deepaks.krishiseva.util.MessageUtils;
import com.example.deepaks.krishiseva.util.SignUpListener;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.ResultCallback;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.location.LocationListener;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.location.LocationSettingsRequest;
import com.google.android.gms.location.LocationSettingsResult;
import com.google.android.gms.location.LocationSettingsStatusCodes;
import com.google.android.gms.location.places.AutocompleteFilter;
import com.google.android.gms.location.places.Place;
import com.google.android.gms.location.places.ui.PlaceAutocompleteFragment;
import com.google.android.gms.location.places.ui.PlaceSelectionListener;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
import static android.Manifest.permission.ACCESS_FINE_LOCATION;
public class SignUpActivity extends AppCompatActivity implements SignUpListener, GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener, LocationListener {
@BindView(R.id.et_username)
EditText mUsernameEt;
@BindView(R.id.et_email)
EditText mEmailEt;
@BindView(R.id.et_password)
EditText mPasswordEt;
@BindView(R.id.et_confirm_password)
EditText mConfirmPasswordEt;
@BindView(R.id.et_phone)
EditText mPhoneEt;
@BindView(R.id.tv_location_address)
TextView mLocationAddressText;
private String mLocationString;
private PlaceAutocompleteFragment placeAutocompleteFragment;
private GoogleApiClient mGoogleApiClient;
private static final int PLAY_SERVICES_RESOLUTION_REQUEST = 9000;
private LocationRequest mLocationRequest;
private long UPDATE_INTERVAL = 60000; /* 60 secs */
private long FASTEST_INTERVAL = 60000; /* 60 secs */
private ArrayList<String> permissionsToRequest;
private ArrayList<String> permissionsRejected = new ArrayList<>();
private ArrayList<String> permissions = new ArrayList<>();
private static final String TAG = SignUpActivity.class.getSimpleName();
private final static int ALL_PERMISSIONS_RESULT = 101;
private Location mLocation;
@Override
public void getAllUsers(List<User> userList) {
boolean isExist = false;
for (User user : userList) {
if (user.getEmail().equalsIgnoreCase(mEmailEt.getEditableText().toString())) {
isExist = true;
break;
}
}
if (!isExist) {
DatabaseUserUtils.insertUser(new User(mUsernameEt.getEditableText().toString().trim()
, mEmailEt.getEditableText().toString().trim()
, mPasswordEt.getEditableText().toString().trim()
, mPhoneEt.getEditableText().toString().trim()
, mLocationString));
finish();
MessageUtils.showToastMessage(this, getString(R.string.sign_up_success_message));
} else {
MessageUtils.showToastMessage(this, getString(R.string.user_already_exist));
}
DialogUtils.dismissProgressDialog();
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sign_up);
setUpActivityComponents();
setUpPlacesFragment();
}
private void setUpPlacesFragment() {
placeAutocompleteFragment = (PlaceAutocompleteFragment) getFragmentManager()
.findFragmentById(R.id.place_fragment);
AutocompleteFilter autocompleteFilter =
new AutocompleteFilter.Builder()
.setTypeFilter(AutocompleteFilter.TYPE_FILTER_ADDRESS).build();
placeAutocompleteFragment.setFilter(autocompleteFilter);
placeAutocompleteFragment.setHint(getString(R.string.search_location));
placeAutocompleteFragment.setOnPlaceSelectedListener(new PlaceSelectionListener() {
@Override
public void onPlaceSelected(Place place) {
mLocationString = place.getName().toString();
mLocationAddressText.setText(mLocationString);
}
@Override
public void onError(Status status) {
Toast.makeText(getApplicationContext()
, status.toString(), Toast.LENGTH_SHORT).show();
}
});
}
/**
* @author deepaks
* @description method to initialize the
*/
private void setUpActivityComponents() {
ButterKnife.bind(this);
permissions.add(ACCESS_FINE_LOCATION);
permissions.add(ACCESS_COARSE_LOCATION);
permissionsToRequest = findUnAskedPermissions(permissions);
}
@OnClick(R.id.btn_sign_up)
void signUpSelected() {
if (validateSignUp()) {
DialogUtils.showProgressDialog(this, getString(R.string.loading_message));
DatabaseUserUtils.getAllUserList(this);
}
}
/**
* @return the boolean flag of validation of sign up screen
* @author deepaks
* @description method to check the validation on the sign up screen
*/
private boolean validateSignUp() {
if (TextUtils.isEmpty(mUsernameEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_username_label));
return false;
} else if (TextUtils.isEmpty(mEmailEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_email_label));
return false;
} else if (GlobalUtils.isValidEmail(mEmailEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_valid_email_message));
return false;
} else if (TextUtils.isEmpty(mPhoneEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_phone_label));
return false;
} else if (!GlobalUtils.isValidPhoneNumber(mPhoneEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_valid_phone_message));
return false;
} else if (TextUtils.isEmpty(mPasswordEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_password_label));
return false;
} else if (TextUtils.isEmpty(mConfirmPasswordEt.getEditableText().toString())) {
MessageUtils.showToastMessage(this, getString(R.string.enter_conifirm_passowrd_label));
return false;
} else if (!mPasswordEt.getEditableText().toString().equals(
mConfirmPasswordEt.getEditableText().toString()
)) {
MessageUtils.showToastMessage(this, getString(R.string.password_mismatch_message));
return false;
} else if (mLocationString == null && TextUtils.isEmpty(mLocationString)) {
MessageUtils.showToastMessage(this, getString(R.string.select_loction));
return false;
}
return true;
}
@OnClick(R.id.tv_login)
void loginClicked() {
finish();
}
@OnClick(R.id.iv_detect_location)
void detectLocationListener() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(LocationServices.API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.build();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (permissionsToRequest.size() > 0)
requestPermissions(permissionsToRequest.toArray(new String[permissionsToRequest.size()]), ALL_PERMISSIONS_RESULT);
}
mGoogleApiClient.connect();
}
private ArrayList<String> findUnAskedPermissions(ArrayList<String> wanted) {
ArrayList<String> result = new ArrayList<String>();
for (String perm : wanted) {
if (!hasPermission(perm)) {
result.add(perm);
}
}
return result;
}
@Override
public void onConnected(@Nullable Bundle bundle) {
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
if (mLocation != null) {
mLocationString = LocationUtils.getAddress(this, mLocation.getLatitude()
, mLocation.getLongitude());
mLocationAddressText.setText(mLocationString);
} else {
MessageUtils.showToastMessage(this, getString(R.string.failed_to_detect_location));
}
startLocationUpdates();
}
@Override
public void onConnectionSuspended(int i) {
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
}
@Override
public void onLocationChanged(Location location) {
if (location != null) {
mLocationString = LocationUtils.getAddress(this, location.getLatitude()
, location.getLongitude());
mLocationAddressText.setText(mLocationString = LocationUtils.getAddress(this
, location.getLatitude()
, location.getLongitude()));
} else {
MessageUtils.showToastMessage(this, getString(R.string.failed_to_detect_location));
}
}
protected void startLocationUpdates() {
mLocationRequest = new LocationRequest();
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationRequest.setInterval(UPDATE_INTERVAL);
mLocationRequest.setFastestInterval(FASTEST_INTERVAL);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(getApplicationContext(), getString(R.string.enable_permission_label)
, Toast.LENGTH_LONG).show();
}
LocationSettingsRequest.Builder settingsBuilder = new LocationSettingsRequest.Builder()
.addLocationRequest(mLocationRequest);
settingsBuilder.setAlwaysShow(true);
PendingResult<LocationSettingsResult> result =
LocationServices.SettingsApi.checkLocationSettings(mGoogleApiClient, settingsBuilder.build());
result.setResultCallback(new ResultCallback<LocationSettingsResult>() {
@Override
public void onResult(LocationSettingsResult result) {
final Status status = result.getStatus();
switch (status.getStatusCode()) {
case LocationSettingsStatusCodes.SUCCESS:
Log.i(TAG, "All location settings are satisfied.");
break;
case LocationSettingsStatusCodes.RESOLUTION_REQUIRED:
Log.i(TAG, "Location settings are not satisfied. Show the user a dialog to upgrade location settings ");
try {
// Show the dialog by calling startResolutionForResult(), and check the result
// in onActivityResult().
status.startResolutionForResult(SignUpActivity.this, 101);
} catch (IntentSender.SendIntentException e) {
Log.i(TAG, "PendingIntent unable to execute request.");
}
break;
case LocationSettingsStatusCodes.SETTINGS_CHANGE_UNAVAILABLE:
Log.i(TAG, "Location settings are inadequate, and cannot be fixed here. Dialog not created.");
break;
}
}
});
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient, mLocationRequest, this);
}
private boolean hasPermission(String permission) {
if (canMakeSmores()) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
return (checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED);
}
}
return true;
}
private boolean canMakeSmores() {
return (Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP_MR1);
}
@TargetApi(Build.VERSION_CODES.M)
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case ALL_PERMISSIONS_RESULT:
for (String perms : permissionsToRequest) {
if (!hasPermission(perms)) {
permissionsRejected.add(perms);
}
}
if (permissionsRejected.size() > 0) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (shouldShowRequestPermissionRationale(permissionsRejected.get(0))) {
showMessageOKCancel(getString(R.string.permission_message),
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
requestPermissions(permissionsRejected.toArray(new String[permissionsRejected.size()]), ALL_PERMISSIONS_RESULT);
}
}
});
return;
}
}
} else {
startLocationUpdates();
}
break;
}
}
private void showMessageOKCancel(String message, DialogInterface.OnClickListener okListener) {
new AlertDialog.Builder(this)
.setMessage(message)
.setPositiveButton(getString(R.string.ok_label), okListener)
.setNegativeButton(getString(R.string.cancel_label), null)
.create()
.show();
}
@Override
protected void onDestroy() {
super.onDestroy();
stopLocationUpdates();
}
public void stopLocationUpdates() {
if (mGoogleApiClient != null) {
if (mGoogleApiClient.isConnected()) {
LocationServices.FusedLocationApi
.removeLocationUpdates(mGoogleApiClient, this);
mGoogleApiClient.disconnect();
}
}
}
}
| [
"[email protected]"
] | |
7e1443f9dc2cb440b7c82825b9879c6b9471be81 | 9f3d0f514857336faf99beeffc9d8e1534c76612 | /Hazard.java | 481454f3c8612deb2fb7a034523a35757fb864b1 | [] | no_license | Bekmyrzapro/car_simulator | e3a73999e552d1864754e1a5477986c86d0f2464 | 00941f43eb9d015d662bd9f83b54e77f795af8de | refs/heads/main | 2023-08-30T08:09:39.917248 | 2021-11-16T06:21:58 | 2021-11-16T06:21:58 | 428,537,317 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,695 | java | package aj;
import java.time.*;
import javafx.animation.*;
import javafx.scene.layout.*;
public class Hazard {
public static final int RESP_TIME = 3;
private Pane objectHazard;
private AnimationTimer timer;
private double xStart = 0;
private double yStart = 0;
private double xEnd = 0;
private double yEnd = 0;
private double x = 0;
private double y = 0;
private double xStep = 0;
private double yStep = 0;
private Instant startAt;
private Instant clickedAt;
private boolean isHit = false;
private MainController controller;
private int carIndex = -1;
public Hazard(MainController controller, Pane objectHazard, double xStart, double yStart, double xEnd, double yEnd) {
this.controller = controller;
this.objectHazard = objectHazard;
this.xStart = xStart;
this.yStart = yStart;
this.xEnd = xEnd;
this.yEnd = yEnd;
xStep = (xEnd - xStart) / 20;
yStep = (yEnd - yStart) / 20;
x = xStart;
y = yStart;
timer = new AnimationTimer() {
private long startTime ;
private long previous;
@Override
public void start() {
startAt = Instant.now();
startTime = System.currentTimeMillis();
super.start();
}
@Override
public void handle(long stamp) {
long current = System.currentTimeMillis();
if (current > previous + MainController.FPS) {
long elapsed = (current - startTime) / 1000;
controller.hazardFrames(elapsed);
if (elapsed >= RESP_TIME) {
finishHazard();
}
hazardFrames();
previous = current;
}
}
};
}
public Pane getHazardObject() {
return this.objectHazard;
}
public void setIsHit(boolean isHit) {
this.isHit = isHit;
}
public boolean isHit() {
return this.isHit;
}
public void setCarIndex(int index) {
this.carIndex = index;
}
public int getCarIndex() {
return this.carIndex;
}
public void setClickTimeAt(Instant instant) {
this.clickedAt = instant;
}
public Instant getStartTime() {
return this.startAt;
}
public Instant getClickedTime() {
return this.clickedAt;
}
public void startHazard() {
timer.start();
if (objectHazard != null && objectHazard instanceof Car) {
// police hazard
((Car) objectHazard).animation.play();
}
controller.hazardStarted();
}
private void hazardFrames() {
if (objectHazard == null) {
return;
}
if (Math.abs(x - xEnd) > 0.01) {
x = x + xStep;
y = y + yStep;
objectHazard.setLayoutX(x);
objectHazard.setLayoutY(y);
}
}
public void finishHazard() {
timer.stop();
// put the object outside of canvas
if (objectHazard != null) {
objectHazard.setLayoutX(- 3 * Car.CAR_SCALE);
}
controller.hazardFinished();
}
}
| [
"[email protected]"
] | |
15fa6ab242bf16595f52adbd6c4e743c19a3ca64 | 028fd80f9ea743db83fe35d958f6624d5c31b6aa | /src/com/mostc/pftt/scenario/APCScenario.java | b6fb7faf626eb201367e1d1abb67edb420ce3f30 | [
"BSD-3-Clause"
] | permissive | hollyhuiLi/PFTT2-1 | 1ca303d08afde7a73a9233c6db17222d8075fcb4 | 3ffd21bc672b8a20703d935d86dd4261870308f9 | refs/heads/master | 2020-06-30T08:32:26.641229 | 2012-10-22T22:30:12 | 2012-10-22T22:30:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 690 | java | package com.mostc.pftt.scenario;
import com.mostc.pftt.host.Host;
import com.mostc.pftt.model.phpt.PhpBuild;
import com.mostc.pftt.model.phpt.PhpIni;
/** tests the APC code cache (NOT IMPLEMENTED)
*
* @author Matt Ficken
*
*/
public class APCScenario extends AbstractCodeCacheScenario {
public void prepare(Host host, PhpBuild build, PhpIni ini) {
ini.putSingle("apc.enable", 1);
ini.putSingle("apc.enable_cli", 1); // important: or APC won't actually be enabled
// add php_apc.dll (or apc.so) extension
ini.addExtension(host, build, "apc");
}
@Override
public String getName() {
return "APC";
}
@Override
public boolean isImplemented() {
return true;
}
}
| [
"[email protected]"
] | |
9bf84332fc71baf48388b93d455100d15734ad25 | 80b8f82dbef65fa813a1262736a6b0ac9350a88c | /lisn/src/main/java/audio/lisn/service/DownloadService.java | 57e80ef906197b1c20bd5214d47fccc545c25ba7 | [] | no_license | ruwank/Lisn-Android | 85d665e59af9d9a0fc5e709295fba3aa56f97f1e | ee6ad3835208e330f80d288ce6a728045f6b88ec | refs/heads/master | 2020-04-15T14:32:29.942298 | 2018-01-22T15:22:12 | 2018-01-22T15:22:12 | 54,086,091 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,088 | java | package audio.lisn.service;
import android.app.IntentService;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.os.ResultReceiver;
import java.io.BufferedInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import audio.lisn.R;
import audio.lisn.app.AppController;
import audio.lisn.util.Log;
/**
* Created by Admin on 12/31/15.
*/
public class DownloadService extends IntentService {
public static final int UPDATE_PROGRESS = 8344;
public DownloadService() {
super("DownloadService");
}
@Override
protected void onHandleIntent(Intent intent) {
String filePart=intent.getStringExtra("filePart");
String book_id=intent.getStringExtra("book_id");
String dirPath=intent.getStringExtra("dirPath");
String urlToDownload = getResources().getString(R.string.book_download_url);
String urlParameters = "userid="+ AppController.getInstance().getUserId()+"&bookid="+book_id+"&chapid="+filePart;
ResultReceiver receiver = (ResultReceiver) intent.getParcelableExtra("receiver");
try {
File rootPath = new File(dirPath);
if (!rootPath.exists()) {
rootPath.mkdirs();
}
URL url = new URL(urlToDownload);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("POST");
DataOutputStream printout = new DataOutputStream(connection.getOutputStream ());
printout.writeBytes(urlParameters.toString());
printout.flush ();
printout.close ();
connection.connect();
// this will be useful so that you can show a typical 0-100% progress bar
int fileLength = connection.getContentLength();
// download the file
InputStream input = new BufferedInputStream(connection.getInputStream());
//OutputStream output = new FileOutputStream("/sdcard/BarcodeScanner-debug.apk");
OutputStream output = new FileOutputStream(dirPath + "/" + filePart
+ ".lisn");// change extension
byte data[] = new byte[1024];
long total = 0;
int count;
while ((count = input.read(data)) != -1) {
total += count;
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();
} catch (IOException e) {
Log.v("DownloadService", "DownloadService: " + e.getMessage());
e.printStackTrace();
}
Log.v("DownloadService","DownloadService: "+book_id);
Bundle resultData = new Bundle();
resultData.putString("file_name", filePart);
resultData.putString("result", "OK");
receiver.send(UPDATE_PROGRESS, resultData);
}
}
| [
"[email protected]"
] | |
d6ee15581189cf40a43c80f4c84a4cebe01e876b | 8ef553adcae8338c0ffe2350f187e8b37743c3ec | /app/src/main/java/com/example/mindbenders/PatientContact.java | 2fbb428a132a11cd0e82f3167665d1460b186ac2 | [] | no_license | Sanjay-Sivakumar/mindbenders | 07fb9762f3bacce411b24a6052781c1f8b745ac6 | f2caa1304099027e6089b23a795c9ae87a657350 | refs/heads/master | 2023-01-31T17:58:46.547670 | 2020-12-18T09:16:47 | 2020-12-18T09:16:47 | 320,323,176 | 0 | 0 | null | 2020-12-18T09:16:48 | 2020-12-10T16:08:37 | Java | UTF-8 | Java | false | false | 2,170 | java | package com.example.mindbenders;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.ArrayList;
import java.util.List;
public class PatientContact extends AppCompatActivity {
public ListView listViewBusestime;
List<Appointmentpatient> busestime;
DatabaseReference databaseBustime;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_patient_contact);
databaseBustime = FirebaseDatabase.getInstance().getReference("PatientContactDetails");
listViewBusestime = (ListView) findViewById(R.id.listViewappoints);
busestime = new ArrayList<>();
}
@Override
protected void onStart() {
super.onStart();
//attaching value event listener
databaseBustime.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//clearing the previous artist list
busestime.clear();
//iterating through all the nodes
for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
//getting artist
Appointmentpatient busno = postSnapshot.getValue(Appointmentpatient.class);
//adding artist to the list
busestime.add(busno);
}
//creating adapter
Appointmentpatientlist BustimeAdapter = new Appointmentpatientlist(PatientContact.this, busestime);
//attaching adapter to the listview
listViewBusestime.setAdapter(BustimeAdapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
} | [
"[email protected]"
] | |
220935e065aaa93063a9d9c772e4ef392042bfc7 | 49433263dddaa834b7be5e21a591db5176775fbb | /SpringCore/SpringCoreDemo/src/main/java/com/techstack/spring/lifecycle/defaultinitializationanddestroy/MainForBeanLifeCycleDestructionCallbackExample.java | 8aaef52fd6bfafe3336421ef71bfb789fd3f369e | [] | no_license | andrewsselvaraj/spring-boot-demo | 120f3427fdf5be89e017729b1c0d09b2b28ebbb1 | a13741d8c4e7b603aa6eaf0f6013d20808637143 | refs/heads/master | 2022-09-10T05:49:30.078730 | 2020-06-03T16:20:22 | 2020-06-03T16:20:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 845 | java | package com.techstack.spring.lifecycle.defaultinitializationanddestroy;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
* @author KARTHIKEYAN N
*
*/
public class MainForBeanLifeCycleDestructionCallbackExample {
public static void main(String[] args) {
/**
* The ConfigurableApplicationContext.close will close the application context,
* releasing all resources and destroying all cached singleton beans.
*/
ConfigurableApplicationContext context;
context = new ClassPathXmlApplicationContext("depinjection_defaultInitializationAndDestruction.xml");
Account account = context.getBean(Account.class);
Customer customer = context.getBean(Customer.class);
context.close();
}
}
| [
"[email protected]"
] | |
22c2302dbc5ff2c6e0f50279effa9abe8849259b | 3f430dc7e0e3e8811f6a923dfaff9b5aabce252f | /Loop Pattern Example 3/src/com/example/Main.java | d63b3430ec8ed4347829c057feffc11a573d0283 | [] | no_license | JaimeCosico/SDA-Exercises | aa8f65be76857fe06ff7a3d5d38e46267ab79835 | eb9b375805a6d9a687e6c01a1bcea9c6c956a98f | refs/heads/master | 2023-04-17T22:46:34.994566 | 2021-04-04T14:38:55 | 2021-04-04T14:38:55 | 365,396,441 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 258 | java | package com.example;
public class Main {
public static void main(String[] args) {
for(int x=1;x<5;x++){
for(int y=1;y<=x;y++){
System.out.print("*");
}
System.out.println();
}
}
}
| [
"[email protected]"
] | |
ee7c5aaed2a61d6bf7fa205570689e3402651d41 | 502286c49670731fbf37223e3e29c3094512fe83 | /Challenge4.java | 8cafa92dc5e5532555558322e709f6a98fb2603a | [] | no_license | sonnyhuddart/Challenge-4 | b66132e20a8d81455d8bbdb8ce791c031d2aabf4 | f221c52cc4603098c18b24b171ca8c6823506423 | refs/heads/master | 2021-01-14T13:50:10.862234 | 2016-09-21T10:32:41 | 2016-09-21T10:32:41 | 68,806,516 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package challenge.pkg4;
import java.util.Scanner;
public class Challenge4 {
public static void main(String[] args) {
Scanner myScanner = new Scanner(System.in);
System.out.println("Please enter a number?");
int num = myScanner.nextInt();
if (num>100) {
System.out.println("Your number is larger than 100");
}else{
System.out.println("Your number is below 100");
}
}
} | [
"[email protected]"
] | |
067d7094a9a66330bb5edacc89a7332b3e49d1e2 | 8d6aae22e5729575c400140ae72b4b1a6fd851be | /src/accounts/db/inst/TRNonDB.java | ab444a71a1084dfa650f7c7b82390b699e7535c8 | [] | no_license | praveensiddu/accounts | e31bf867563aeb6975c5841d4b6b2e37b5c2032e | 303b6f8bbbc32fe93e7eec8ed8b8e11a36dd6b30 | refs/heads/master | 2021-07-19T11:44:45.892176 | 2021-02-22T01:57:33 | 2021-02-22T01:57:33 | 36,769,247 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 355 | java | package accounts.db.inst;
import javax.persistence.Entity;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import accounts.db.TR;
@Entity
@Table(name = "TRNonDB")
@NamedQueries({ @NamedQuery(name = "TRNonDB.getList", query = "SELECT e FROM TRNonDB e") })
public class TRNonDB extends TR
{
}
| [
"[email protected]"
] | |
bd36193fb6691ba1a9973d376fc9338b7bbd74ae | 664576d1fd37a4a07d0646fe9100bd3810d4bb9a | /riftwalk/src/main/java/com/uab/riftwalk/position/helper/HpReducer.java | c063108657eeb180c837821d05d693be876a08da | [] | no_license | mashiuruab/riftwalk | b58d7977fbb02e01f43fcf3b34ebf4ae5349fc6c | ccd36e180561cca46da76d18e76057be0c5bb3f1 | refs/heads/master | 2021-08-24T09:03:29.045393 | 2017-12-08T23:36:05 | 2017-12-08T23:36:05 | 108,746,703 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 538 | java | package com.uab.riftwalk.position.helper;
import org.apache.hadoop.io.DoubleWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import java.io.IOException;
public class HpReducer extends Reducer<Text, DoubleWritable, Text, DoubleWritable> {
@Override
protected void reduce(Text key, Iterable<DoubleWritable> values, Context context)
throws IOException, InterruptedException {
for (DoubleWritable value : values) {
context.write(key, value);
}
}
}
| [
"[email protected]"
] | |
aa4a02bb6daba7486b6a636383911d5b3cc74adb | 2fbe033a9c82ed00ba39a0269102430b80989686 | /app/src/main/java/tasu/myapplication/MapsActivity.java | fa97d8deeb6b3c536992b6da6ba8298d9a65054a | [] | no_license | swarnaBD2112/Location-based-places-finder | 74457880f03812adcb221ad1518e7be6cefe5e31 | 2b3179603cb95d3892f1fa825cb276870bd89179 | refs/heads/master | 2020-03-28T09:44:13.467407 | 2018-08-08T07:44:05 | 2018-08-08T07:44:05 | 148,056,175 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,000 | java | package tasu.myapplication;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.support.v4.app.FragmentActivity;
import android.os.Bundle;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import org.json.JSONObject;
import android.app.Dialog;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.Toast;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.maps.CameraUpdateFactory;
public class MapsActivity extends FragmentActivity implements LocationListener{
GoogleMap mGoogleMap;
Spinner mSprPlaceType;
String[] mPlaceType=null;
String[] mPlaceTypeName=null;
double mLatitude=0;
double mLongitude=0;
/*
public void showMenuDrawer(View v) {
Intent intent2 = new Intent(getApplicationContext(), DrawerActivity.class);
startActivity(intent2);
}*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
mPlaceType = getResources().getStringArray(R.array.place_type);
mPlaceTypeName = getResources().getStringArray(R.array.place_type_name);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_dropdown_item, mPlaceTypeName);
mSprPlaceType = (Spinner) findViewById(R.id.spr_place_type);
mSprPlaceType.setAdapter(adapter);
Button btnMenu;
btnMenu = (Button)findViewById(R.id.btn_menu_drawer);
btnMenu.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(getApplicationContext(), DrawerActivity.class);
startActivity(i);
}
});
Button btnFind;
btnFind = ( Button ) findViewById(R.id.btn_find);
int status = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getBaseContext());
if(status!=ConnectionResult.SUCCESS){
int requestCode = 10;
Dialog dialog = GooglePlayServicesUtil.getErrorDialog(status, this, requestCode);
dialog.show();
}else {
SupportMapFragment fragment = ( SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mGoogleMap = fragment.getMap();
LocationManager locationManager = (LocationManager) getSystemService(LOCATION_SERVICE);
Criteria criteria = new Criteria();
String provider = locationManager.getBestProvider(criteria, true);
// Getting Current Location From GPS
Location location = locationManager.getLastKnownLocation(provider);
if(location!=null){
onLocationChanged(location);
}
locationManager.requestLocationUpdates(provider, 20000, 0, this);
btnFind.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int selectedPosition = mSprPlaceType.getSelectedItemPosition();
String type = mPlaceType[selectedPosition];
final SharedPreferences mSharedPreference = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
String range = (mSharedPreference.getString("range", "5000"));
;
if (range == null) range = "5000";
String data = "Distance: " + range + "\nPlaces: ";
if (mSharedPreference.getBoolean("c1", false) == true) data += "Doctor ";
if (mSharedPreference.getBoolean("c2", false) == true) data += "Hospital ";
if (mSharedPreference.getBoolean("c3", false) == true) data += "Restaurant ";
if (mSharedPreference.getBoolean("c4", false) == true) data += "Museum ";
if (mSharedPreference.getBoolean("c5", false) == true) data += "Stadium ";
if (mSharedPreference.getBoolean("c6", false) == true) data += "Library ";
if (mSharedPreference.getBoolean("c7", false) == true) data += "Zoo";
Toast tasu = Toast.makeText(getApplicationContext(), data, Toast.LENGTH_LONG);
tasu.show();
StringBuilder sb = new StringBuilder("https://maps.googleapis.com/maps/api/place/nearbysearch/json?");
sb.append("location=" + mLatitude + "," + mLongitude);
sb.append("&radius=" + range);
//sb.append("&types="+type);
sb.append("&types=");
if (data.contains("Doctor")) sb.append("|doctor");
if (data.contains("Hospital")) sb.append("|hospital");
if (data.contains("Restaurant")) sb.append("|restaurant");
if (data.contains("Museum")) sb.append("|museum");
if (data.contains("Stadium")) sb.append("|stadium");
if (data.contains("Library")) sb.append("|library");
if (data.contains("Zoo")) sb.append("|zoo");
sb.append("&sensor=true");
sb.append("&key=AIzaSyDwq3T-OK9nXByWLgkewAQnK3EeIkG6D7Q\n");
// Creating a new non-ui thread task to download json data
PlacesTask placesTask = new PlacesTask();
// Invokes the "doInBackground()" method of the class PlaceTask
placesTask.execute(sb.toString());
}
});
mGoogleMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(Marker marker) {
String name = marker.getTitle();
String vicinity = marker.getSnippet();
LatLng position = marker.getPosition();
/*
Toast.makeText(getApplicationContext(),
name + " \n" + vicinity + " \n" + position, Toast.LENGTH_SHORT)
.show();
*/
Intent info = new Intent(getApplicationContext(), InfoActivity.class);
info.putExtra("name", name);
info.putExtra("vicinity", vicinity);
info.putExtra("latitude", position.latitude);
info.putExtra("longitude", position.longitude);
startActivity(info);
}
});
//mGoogleMap.getUiSettings().setCompassEnabled(true);
mGoogleMap.getUiSettings().setMapToolbarEnabled(false);
mGoogleMap.setMyLocationEnabled(true);
mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(12));
}
}
/** A method to download json data from url */
private String downloadUrl(String strUrl) throws IOException{
String data = "";
InputStream iStream = null;
HttpURLConnection urlConnection = null;
try{
URL url = new URL(strUrl);
// Creating an http connection to communicate with url
urlConnection = (HttpURLConnection) url.openConnection();
// Connecting to url
urlConnection.connect();
// Reading data from url
iStream = urlConnection.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader(iStream));
StringBuffer sb = new StringBuffer();
String line = "";
while( ( line = br.readLine()) != null){
sb.append(line);
}
data = sb.toString();
br.close();
}catch(Exception e){
Log.d("error downloading url", e.toString());
}finally{
iStream.close();
urlConnection.disconnect();
}
return data;
}
/** A class, to download Google Places */
private class PlacesTask extends AsyncTask<String, Integer, String>{
String data = null;
// Invoked by execute() method of this object
@Override
protected String doInBackground(String... url) {
try{
data = downloadUrl(url[0]);
}catch(Exception e){
Log.d("Background Task",e.toString());
}
return data;
}
// Executed after the complete execution of doInBackground() method
@Override
protected void onPostExecute(String result){
ParserTask parserTask = new ParserTask();
// Start parsing the Google places in JSON format
// Invokes the "doInBackground()" method of the class ParseTask
parserTask.execute(result);
}
}
private class ParserTask extends AsyncTask<String, Integer, List<HashMap<String,String>>>{
JSONObject jObject;
// Invoked by execute() method of this object
@Override
protected List<HashMap<String,String>> doInBackground(String... jsonData) {
List<HashMap<String, String>> places = null;
JSONParser placeJsonParser = new JSONParser();
try{
jObject = new JSONObject(jsonData[0]);
/** Getting the parsed data as a List construct */
places = placeJsonParser.parse(jObject);
}catch(Exception e){
Log.d("Exception",e.toString());
}
return places;
}
// Executed after the complete execution of doInBackground() method
@Override
protected void onPostExecute(List<HashMap<String,String>> list){
// Clears all the existing markers
mGoogleMap.clear();
for(int i=0;i<list.size();i++){
// Creating a marker
MarkerOptions markerOptions = new MarkerOptions();
// Getting a place from the places list
HashMap<String, String> hmPlace = list.get(i);
// Getting latitude of the place
double lat = Double.parseDouble(hmPlace.get("lat"));
// Getting longitude of the place
double lng = Double.parseDouble(hmPlace.get("lng"));
// Getting name
String name = hmPlace.get("place_name");
// Getting vicinity
String vicinity = hmPlace.get("vicinity");
LatLng latLng = new LatLng(lat, lng);
// Setting the position for the marker
markerOptions.position(latLng);
// Setting the title for the marker.
//This will be displayed on taping the marker
markerOptions.title(name);
markerOptions.snippet(vicinity);
String types = hmPlace.get("types");
if(types.contains("doctor")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.doctor));
else if(types.contains("hospital")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.hospital));
else if(types.contains("restaurant")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.restaurant));
else if(types.contains("museum")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.museum));
else if(types.contains("stadium")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.stadium));
else if(types.contains("library")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.library));
else if(types.contains("zoo")) markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.zoo));
// Placing a marker on the touched position
mGoogleMap.addMarker(markerOptions);
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
//getMenuInflater().inflate(R.menu.activity_maps, menu);
return true;
}
@Override
public void onLocationChanged(Location location) {
mLatitude = location.getLatitude();
mLongitude = location.getLongitude();
LatLng latLng = new LatLng(mLatitude, mLongitude);
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
//mGoogleMap.animateCamera(CameraUpdateFactory.zoomTo(12));
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
} | [
"[email protected]"
] | |
99edaad3be43ec0351d7e472c1e6f06191d7b616 | dfff6c1e7e86c2afe4f9746495f68e1e13184f42 | /jpropeller/src/org/jpropeller/view/table/impl/IndexTableModel.java | f62a91c2fbb00b37f48804e48deeb3c2266700fb | [] | no_license | woutertierens/test | 68736a968ce4933f4a3017ba5022e657c328d474 | ebe5b50393534b2b34c688ca4f30b21bf7fee37d | refs/heads/master | 2021-01-01T16:50:19.528887 | 2014-09-29T14:00:01 | 2014-09-29T14:00:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,172 | java | package org.jpropeller.view.table.impl;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import org.jpropeller.properties.Prop;
import org.jpropeller.properties.change.Change;
import org.jpropeller.properties.change.ChangeListener;
import org.jpropeller.properties.change.Changeable;
import org.jpropeller.system.Props;
import org.jpropeller.view.table.FiringTableModel;
import org.jpropeller.view.update.Updatable;
import org.jpropeller.view.update.UpdateManager;
/**
* A {@link TableModel} that displays a single
* column, with {@link Boolean} values, where only
* the row with index matching a {@link Prop}
* of {@link Integer} value is true, all others are
* false.
*
* When a row is set to true, the {@link Prop} value
* is set to that row index.
* When a row is set to false, either
* the {@link Prop} value is set to -1 for no selection,
* or nothing happens, depending on configuration.
*
* This allows for a composite table to include this {@link TableModel}
* for the purposes of editing a choice
* of a row of the composite table - this is distinct from selection
* of that row, which works differently (and possibly alongside
* this row view).
*
* The column could be displayed as a checkbox or even a radio
* button style circle, according to preference.
*
*/
public class IndexTableModel extends AbstractTableModel implements FiringTableModel, ChangeListener, Updatable{
private final Prop<Integer> value;
private final Prop<Integer> size;
private final Prop<Boolean> locked;
private final String columnName;
//Track whether we have had a complete change since last firing of table model change
private boolean completeChange = false;
private UpdateManager updateManager;
private AtomicBoolean isFiring = new AtomicBoolean(false);
private final boolean editable;
private final boolean allowClearing;
/**
* Create an {@link IndexTableModel}
* @param value The integer value of the selected row.
* @param size The total number of rows. Note that if this has a
* null or negative value, size 0 will be used instead.
* @param locked When this {@link Prop} has value {@link Boolean#TRUE},
* no editing is allowed on the value. Null {@link Prop}
* is treated as unlocked (false).
* @param columnName The name of the single column
* @param editable True to accept editing, which will modify value
* @param allowClearing If true, editing a "true" row (the one corresponding to value)
* to false will clear the value back to -1 (for "no selection").
* If false, cannot clear the value, it will only ever be set
* to a row index from 0 to (table row count - 1).
*/
public IndexTableModel(Prop<Integer> value, Prop<Integer> size, Prop<Boolean> locked, String columnName, boolean editable, boolean allowClearing) {
super();
this.value = value;
this.size = size;
this.locked = locked;
this.columnName = columnName;
this.editable = editable;
this.allowClearing = allowClearing;
updateManager = Props.getPropSystem().getUpdateManager();
updateManager.registerUpdatable(this);
value.features().addListener(this);
size.features().addListener(this);
}
//Single boolean column
@Override
public int getColumnCount() {
return 1;
}
@Override
public Class<?> getColumnClass(int columnIndex) {
return Boolean.class;
}
@Override
public String getColumnName(int columnIndex) {
return columnName;
}
@Override
public int getRowCount() {
Integer s = size.get();
if (s == null || s < 0) {
return 0;
} else {
return s;
}
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
Integer v = value.get();
if (v == null) {
return false;
} else {
return (rowIndex == v.intValue());
}
}
@Override
public boolean isCellEditable(int rowIndex, int columnIndex) {
//Not editable if locked
if (Props.isTrue(locked)) {
return false;
}
return editable;
}
@Override
public void setValueAt(Object newValue, int rowIndex, int columnIndex) {
//Shouldn't happen, but skip editing anyway
if (!editable) {
return;
}
//Not editable if locked
if (Props.isTrue(locked)) {
return;
}
if (newValue instanceof Boolean) {
//Setting a row to true changes the value to that row's index.
if (((Boolean) newValue).booleanValue()) {
value.set(rowIndex);
//Setting a row to false can optionally clear the value to -1
} else {
if (allowClearing && new Integer(rowIndex).equals(value.get())) {
value.set(rowIndex);
}
}
}
}
@Override
public void change(List<Changeable> initial, Map<Changeable, Change> changes) {
boolean newChangeIsComplete = false;
boolean newChange = false;
//If the value prop has changed, we have at least a non-complete change
if (changes.containsKey(value)) {
newChange = true;
}
//If the size prop has changed, we have a complete change
if (changes.containsKey(size)) {
newChange = true;
newChangeIsComplete = true;
}
if (newChange) {
handleChange(newChangeIsComplete);
}
}
private synchronized void handleChange(boolean newChangeIsComplete) {
//Track whether we have had a complete change since last firing
if (newChangeIsComplete) {
completeChange = true;
}
//Ask for an update
updateManager.updateRequiredBy(this);
}
public synchronized void update() {
//TODO We use an AtomicBoolean here - probably not necessary since the
//value will only ever be checked from the swing thread
isFiring.set(true);
//Fire appropriate change
if (completeChange) {
fireTableDataChanged();
} else {
fireTableRowsUpdated(0, getRowCount()-1);
}
isFiring.set(false);
//We now haven't had a complete change since the last firing
completeChange = false;
}
@Override
public boolean isFiring() {
return isFiring.get();
}
@Override
public void dispose() {
updateManager.deregisterUpdatable(this);
value.features().removeListener(this);
size.features().removeListener(this);
}
}
| [
"trepidacious@e3993962-97ac-11dd-8f69-eb63e1080c9a"
] | trepidacious@e3993962-97ac-11dd-8f69-eb63e1080c9a |
e0d882e918c73b52885707850c75e6850e223269 | e738c3bcff04bb09d3d26d5929e65cf0f521756c | /src/main/java/br/com/mrsistemas/_03/classes/_01_ExemploDeMetodos.java | 5846175c32155aefbfee24348ebd830cb761b8c5 | [] | no_license | marcondesmacaneiro/sistemajava | 95d173c43ba286622602dc2d10d1a13db038fb61 | f3600c84fb96593589a9d72e024fb32bc30e49d4 | refs/heads/master | 2020-09-25T21:34:17.341362 | 2016-09-02T01:02:24 | 2016-09-02T01:02:24 | 67,177,382 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 349 | java | package br.com.mrsistemas._03.classes;
/**
*
* @author marcondes
*/
public class _01_ExemploDeMetodos {
void imprime() {
System.out.println("Este método não retorna nada.");
}
int calculaFrete() {
return 19;
}
String getNome() {
return "Esse método retorna uma String";
}
}
| [
"[email protected]"
] | |
6c3e081389f9549030f8ff9475d49f6738e4803d | 14ba89d545d118d09ffaa232939810f97b60f7b6 | /spring-kata/src/main/java/io/erenkaya/oacar/_9_chapter/dynamic_class/domain/CarRepositoryImpl.java | 12671bf316fd7d440171c80580e6cd08ff622e25 | [] | no_license | ErenKaya/code-practices | dc48ec896d50af6b9dfa88764b7bcba93f8c6d88 | c21373e6c5a79fd535d1e84270de335f02f9d65a | refs/heads/master | 2022-10-17T22:04:30.331438 | 2022-10-10T03:29:07 | 2022-10-10T03:29:07 | 132,752,781 | 5 | 1 | null | 2022-08-01T10:45:05 | 2018-05-09T12:21:17 | Java | UTF-8 | Java | false | false | 755 | java | package io.erenkaya.oacar._9_chapter.dynamic_class.domain;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import io.erenkaya.oacar.domain.Car;
import io.erenkaya.oacar.domain.CarRepository;
public class CarRepositoryImpl implements CarRepository {
private List<Car> carList = new ArrayList<Car>();
public CarRepositoryImpl() {
super();
carList.add(new Car("Kuga", "Ford"));
carList.add(new Car("Egea", "Fiat"));
}
@Override
public Car getCustomerByModel(String name) {
Optional<Car> car = carList.stream().filter(c -> c.getModel().equals(name)).findFirst();
if (car.isPresent()) {
return car.get();
} else {
return null;
}
}
@Override
public void save(Car car) {
carList.add(car);
}
}
| [
"[email protected]"
] | |
09d3bdd1f117f86c60a74578a294a8d0fe0dc3c6 | 9a926a22cec0c6e26da8d16a325af07778bb6e0c | /MakeupProject/src/com/hqyj/bean/Division.java | f2e2c738642b0e9a679858ad8ba3f27e09ef89f3 | [] | no_license | GhostZXY/MakeupProjec | ff6a5aa43b1eeed73318628befc4f1f8eb8f053d | 48616ae397e9581ef830421b9ee6170b18ecabf6 | refs/heads/master | 2023-07-14T15:04:42.922178 | 2021-09-01T06:10:48 | 2021-09-01T06:10:48 | 399,994,475 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 358 | java |
package com.hqyj.bean;
public class Division {
private int d_id;
private String d_name;
public int getD_id() {
return d_id;
}
public void setD_id(int d_id) {
this.d_id = d_id;
}
public String getD_name() {
return d_name;
}
public void setD_name(String d_name) {
this.d_name = d_name;
}
}
| [
"[email protected]"
] | |
c6e96d8dbfd6d2e927a502f4956d7cbfd2f7f5aa | f6af9d57459aab8bedd58b3594d27fb1db5e0a70 | /src/test/java/de/gzockoll/selenium/util/LocalDriverFactory.java | 431575f01e6e818202024cace309d5a7188af8d2 | [] | no_license | MehrCurry/SeleniumExample | 46fd6188728ecb5236c73241de8e7d43ef2b89ca | 67faa9694c790cb33043242a50ee9e4ee08233ab | refs/heads/master | 2021-01-15T17:07:03.230112 | 2012-10-01T04:40:05 | 2012-10-01T04:40:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 486 | java | package de.gzockoll.selenium.util;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
public class LocalDriverFactory implements DriverFactory {
@Override
public WebDriver getDriver(String browser, DesiredCapabilities cap) {
if ("firefox".equalsIgnoreCase(browser))
return new FirefoxDriver(cap);
throw new IllegalArgumentException("Unsupported driver name: "
+ browser);
}
}
| [
"[email protected]"
] | |
5dd7bf663d0d100983ee589b73659e9ae9103a7a | 824b00d59e4f4e76f5f0321c146dacd7b3396759 | /src/main/java/cn/abtion/blog/dto/request/UserRegisterRequest.java | 6ecffc8e3b2fa335ed538a2af2be0e797482dae8 | [
"Apache-2.0"
] | permissive | gitabtion/abtion-tech-blog | a710095f4a6ccb8f063e63d0b7a142b1d28abc08 | 13ece2c5bc00252ec14281036eaf19d583abddff | refs/heads/master | 2020-03-20T21:37:25.014909 | 2018-07-03T13:37:03 | 2018-07-03T13:37:03 | 137,750,861 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 943 | java | package cn.abtion.blog.dto.request;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
/**
* @author abtion
* @since 2018/6/20 14:07
* email [email protected]
*/
public class UserRegisterRequest {
@NotBlank
private String name;
@NotBlank
private String password;
private int sex;
private String signature;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
}
| [
"[email protected]"
] | |
c82ea58924929c244e335a78eb020150f07c011e | e12f5a24d81b4daa5cbf22c9b6e02f3a7df63716 | /src/com/dao/SohuDao.java | c2cf597f2f3a30caa2e94737cfed4779cf769336 | [] | no_license | hksgithub/crm_market | 352c6ef77533a94b0f9ceede5c0b548757f0884d | 721a73f283fa809eb0e02b5e43858eb9dd1acd1d | refs/heads/master | 2020-03-24T02:32:08.559779 | 2018-07-26T03:33:07 | 2018-07-26T03:33:07 | 142,380,049 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 315 | java | package com.dao;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Repository;
import com.entity.Sohu;
@Repository
public interface SohuDao extends BaseDao<Integer,Sohu>{
Object findWith(String day);
List<Sohu> selectDate(String start_date, String end_date);
}
| [
"[email protected]"
] | |
69b602c38b8a64dc59daf45b1c2b4c8e8c8e7870 | 55e7b7939144372bbb2bf11bededfe4cea7651dc | /src/main/java/com/bankwith/mint/dto/response/VerifyCardResponse.java | 095b25d12885e4e31ebb2012781b488550d5829b | [] | no_license | IamStepjay/BankWithMint | e3cc19b1253641be249bd1609bafce9d673cf349 | c539c82f395d44ed1b45453507817109ec60934c | refs/heads/master | 2023-01-05T16:50:34.560009 | 2020-11-01T21:07:12 | 2020-11-01T21:07:12 | 309,176,688 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 261 | java | package com.bankwith.mint.dto.response;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
@Data
public class VerifyCardResponse {
private String success;
@JsonProperty("payload")
private VerifyCardPayload verifyCardPayload;
}
| [
"[email protected]"
] | |
bbc6e26024b283a42c0f72cf05165fc1bb3daa95 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/MOCKITO-10b-7-3-FEMO-WeightedSum:TestLen:CallDiversity/org/mockito/internal/stubbing/defaultanswers/ReturnsDeepStubs_ESTest.java | c1ad1670eb9923b51bb0d8ff821ec7276a88d55e | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 583 | java | /*
* This file was automatically generated by EvoSuite
* Sat Apr 04 09:05:17 UTC 2020
*/
package org.mockito.internal.stubbing.defaultanswers;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class ReturnsDeepStubs_ESTest extends ReturnsDeepStubs_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"[email protected]"
] | |
30a45ac80db03aa2ce84a6a7be4552d728afc9fd | 33454689bc02677fa2de85d0d06fb4ed2b9dbcfd | /classB.java | f2cda0fc7c2fa06db696e2dee5c0779495325ee5 | [] | no_license | nadhifahlutfiyah/latsoalinherit2 | 058e0eeae929c5f83a3c1f9498fdced5db28c7b8 | cdd5cd41c9752c56def8bf8c3b18f06d11847715 | refs/heads/main | 2023-08-27T23:15:40.484638 | 2021-11-02T17:01:00 | 2021-11-02T17:01:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | 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 hierarchical;
/**
*
* @author LENOVO
*/
public class classB extends classA {
public void methodB() {
System.out.println("Jumlah Class B 31 siswa");
}
}
| [
"[email protected]"
] | |
ca830d03b49f24e826ba9485c748168242a09f94 | a7d243fb8c423aba4336a87bec9b5e337aa51f6a | /src/main/java/com/wxl/securitytest/common/utils/DateUtils.java | ef41c7156942ec79f9af5c8e9004adbd37cc5990 | [] | no_license | wakaka16/security-test | bd697d3d9cf644100d99d022e353db9ac910aead | e6513b488caab4da3bdf2915be625b0b87d34351 | refs/heads/master | 2020-04-14T20:36:47.069094 | 2019-05-22T09:54:30 | 2019-05-22T09:54:30 | 164,100,204 | 1 | 0 | null | 2019-05-22T06:53:14 | 2019-01-04T11:39:22 | Java | UTF-8 | Java | false | false | 18,050 | java | package com.wxl.securitytest.common.utils;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* 时间工具类
*
* @author cxj
*
*/
public class DateUtils {
private static final Log LOG = LogFactory.getLog(DateUtils.class);
/**
* yyy-MM-dd
*/
public static final String SHORT_DATE_FORMATE_ONE = "yyyy-MM-dd";
/**
* yyy/MM/dd
*/
public static final String SHORT_DATE_FORMATE_TWO = "yyyy/MM/dd";
/**
* yyyMMdd
*/
public static final String SHORT_DATE_FORMATE_FOUR = "yyyyMMdd";
/**
* yyyMM
*/
public static final String SHORT_DATE_FORMATE_THREE = "yyyyMM";
/**
* yyyy.MM.dd
*/
public static final String SHORT_DATE_FORMATE_FIVE = "yyyy.MM.dd";
/**
* 2009-05-19 12:47:28 yyyy-MM-dd HH:mm:ss
*/
public static final String DEFAULT_DATE_FORMATE = "yyyy-MM-dd HH:mm:ss";
public static final String SHORT_DATE_FORMAT_STR = "yyyy-MM-dd";
public static final String LONG_DATE_FORMAT_STR = "yyyy-MM-dd HH:mm:ss";
private static final DateFormat SHORT_DATE_FORMAT = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
public static final DateFormat LONG_DATE_FORMAT = new SimpleDateFormat(LONG_DATE_FORMAT_STR);
private static final String EARLY_TIME = "00:00:00";
private static final String LATE_TIME = "23:59:59";
private static final String MONTH_EARLY_TIME = "01 00:00:00";
/**
* 使用预设Format格式化Date成字符串
*
* @return String
*/
public static String format(Date date) {
return date == null ? "" : format(date, DEFAULT_DATE_FORMATE);
}
/**
* 使用参数Format格式化Date成字符串
*
* @return String
*/
public static String format(Date date, String pattern) {
return date == null ? "" : new SimpleDateFormat(pattern).format(date);
}
/**
* 字符串解析成 java.sql.Date 日期
*
* @author fengyuan
* @param shortDate
* @param format
* @return
*/
public static java.sql.Date parserShortDate(String shortDate, String format) {
DateFormat dateFormate = new SimpleDateFormat(format);
try {
Date date = dateFormate.parse(shortDate);
return new java.sql.Date(date.getTime());
} catch (ParseException e) {
LOG.error("parser java.sql.Date error", e);
return null;
}
}
/**
* 字符串解析成日期
*
* @author fengyuan
* @param dateStr
* @param format
* @return
*/
public static Date parserDate(String dateStr, String format) {
DateFormat dateFormate = new SimpleDateFormat(format);
try {
Date date = dateFormate.parse(dateStr);
return new Date(date.getTime());
} catch (ParseException e) {
throw new RuntimeException();
}
}
/**
* 增加时间的秒数
*
* @param date 要增加的日期
* @param second 增加的时间(以秒为单位)
* @return 增加时间后的日期
*/
public static Date addSecond(Date date, int second) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.SECOND, second);
return cal.getTime();
}
/**
* 根据TimeUnit增加指定日期的的时间
*
* @author fengyuan
* @param date 要增加的日期
* @param timeUnit 增加的日历字段(只能取 DAYS 到 MILLISECONDS 之间的枚举,否则报错)
* @param value 增加的值(当值为负数时表示减少)
* @return
*/
public static Date add(Date date, TimeUnit timeUnit, int value) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int field = 0;
if (timeUnit == TimeUnit.YEAR)
field = Calendar.YEAR;
else if (timeUnit == TimeUnit.DAYS)
field = Calendar.DAY_OF_YEAR;
else if (timeUnit == TimeUnit.HOURS)
field = Calendar.HOUR_OF_DAY;
else if (timeUnit == TimeUnit.MINUTES)
field = Calendar.MINUTE;
else if (timeUnit == TimeUnit.SECONDS)
field = Calendar.SECOND;
else if (timeUnit == TimeUnit.MILLISECONDS)
field = Calendar.MILLISECOND;
else
throw new RuntimeException("timeUnit error");
cal.add(field, value);
return cal.getTime();
}
/**
* 根据TimeUnit清除指定的日历字段
*
* @author fengyuan
* @param date 要清除的日期
* @param timeUnit 清除的日历字段(只能取 DAYS 到 MILLISECONDS 之间的枚举,否则报错)
* @return
*/
public static Date clear(Date date, TimeUnit timeUnit) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int field = 0;
if (timeUnit == TimeUnit.YEAR)
field = Calendar.YEAR;
else if (timeUnit == TimeUnit.DAYS)
field = Calendar.DAY_OF_YEAR;
else if (timeUnit == TimeUnit.HOURS)
field = Calendar.HOUR_OF_DAY;
else if (timeUnit == TimeUnit.MINUTES)
field = Calendar.MINUTE;
else if (timeUnit == TimeUnit.SECONDS)
field = Calendar.SECOND;
else if (timeUnit == TimeUnit.MILLISECONDS)
field = Calendar.MILLISECOND;
else
throw new RuntimeException("timeUnit error");
cal.clear(field);
return cal.getTime();
}
/**
* <br>
* 传入的日期减去天数后返回的日期</br>
*
* @param date 被减日期
* @param day 减去的天数
* @return 返回减去指定天数后的日期
*/
public static Date subtractDay(Date date, int day) {
Calendar cal = Calendar.getInstance();
cal.setTime(date);
int dayOfMonth = cal.get(Calendar.DAY_OF_MONTH);
dayOfMonth -= day;
cal.set(Calendar.DAY_OF_MONTH, dayOfMonth);
return cal.getTime();
}
/**
* <br>
* 第一个日期减去第二个日期后得到的天数</br>
* <br>
* 如果减去的后的天数有不满足一整天的,则不计入天数内</br>
*
* @param date 被减日期
* @param day 减去的日期
* @return 返回减去后的天数
*/
public static long subtractDay(Date date, Date other) {
return subtractSecond(date, other) / (24 * 60 * 60);
}
public static long subtractSecond(Date date, Date other) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
long dateTimeInMillis = calendar.getTimeInMillis();
Calendar otherCalendar = Calendar.getInstance();
otherCalendar.setTime(other);
long otherTimeInMillis = otherCalendar.getTimeInMillis();
return (dateTimeInMillis - otherTimeInMillis) / (1000);
}
/**
* 根据指定天数获得距离当前日期之前的日期(java.sql.date)
*
* @param day 距离当前日期之前的天数
* @return
*/
public static java.sql.Date getBeforTodayDate(int day) {
Date dateTime = new Date();
dateTime = DateUtils.subtractDay(dateTime, day);
return new java.sql.Date(dateTime.getTime());
}
/**
* 字符串解析成 java.sql.Time 时间
*
* @author fengyuan
* @param timeStr
* @param timeFormat
* @return
*/
public static java.sql.Time parserTime(String timeStr, String timeFormat) {
DateFormat dateFormate = new SimpleDateFormat(timeFormat);
try {
Date date = dateFormate.parse(timeStr);
return new java.sql.Time(date.getTime());
} catch (ParseException e) {
LOG.error("parser java.sql.Time error", e);
return null;
}
}
public static enum TimeUnit {
YEAR, DAYS, HOURS, MINUTES, SECONDS, MILLISECONDS;
}
/**
* 得到某个日期在这一天中时间最早的日期对象
*
* @param date
* @return
* @throws ParseException
*/
public static Date getEarlyInTheDay(Date date) {
DateFormat dateFormate = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
DateFormat LONG_DATE_FORMAT = new SimpleDateFormat(LONG_DATE_FORMAT_STR);
String dateString = dateFormate.format(date) + " " + EARLY_TIME;
try {
return LONG_DATE_FORMAT.parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 得到某个日期的中午时期对象
*
* @param date
* @return
*/
public static Date getNoonTheDay(Date date) {
DateFormat dateFormate = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
DateFormat LONG_DATE_FORMAT = new SimpleDateFormat(LONG_DATE_FORMAT_STR);
String dateString = dateFormate.format(date) + " " + "12:00:00";
try {
return LONG_DATE_FORMAT.parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 得到某个日期的指定时间
*
* @param date
* @param time time为 hh:mm:dd 格式
* @return
*/
public static Date getTimeTheDay(Date date, String time, String format) {
DateFormat dateFormate = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
String dateString = dateFormate.format(date) + " " + time;
try {
if (StringUtils.isBlank(format)) {
format = LONG_DATE_FORMAT_STR;
}
return new SimpleDateFormat(format).parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 得到某个日期在这一天中时间最早的日期对象(yyyy-MM-dd)
*
* @param date
* @return
* @throws ParseException
*/
public static Date getEarlyInTheDay2(Date date) {
DateFormat dateFormate = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
String dateString = dateFormate.format(date);
try {
return dateFormate.parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 得到某个日期在这一天中时间最晚的日期对象
*
* @param date
* @return
* @throws ParseException
*/
public static Date getLateInTheDay(Date date) {
DateFormat SHORT_DATE_FORMAT = new SimpleDateFormat(SHORT_DATE_FORMAT_STR);
DateFormat LONG_DATE_FORMAT = new SimpleDateFormat(LONG_DATE_FORMAT_STR);
String dateString = SHORT_DATE_FORMAT.format(date) + " " + LATE_TIME;
try {
return LONG_DATE_FORMAT.parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 得到某月中最早的时间
*
* @param date
* @return
*/
public static Date getEarlyInTheMonth(Date date) {
String dateString = SHORT_DATE_FORMAT.format(date);
dateString = dateString.substring(0, dateString.length() - 2);
dateString += MONTH_EARLY_TIME;
try {
return LONG_DATE_FORMAT.parse(dateString);
} catch (ParseException e) {
throw new RuntimeException("parser date error.", e);
}
}
/**
* 根据传入的两个日期获得日期的时间差<br/>
* 如果距离时间小于1分钟则返回的时间为秒<br/>
* 如果距离时间小于1小时则返回的时间为分<br/>
* 如果距离时间小于1天则返回的时间为小时<br/>
* 其它则去天数
*
* @author fengyuan
* @param date
* @return
*/
public static TimeOutEnum getDistanceTimeOut(Date beforeDate, Date aferDate) {
long beforeMilliseconds = beforeDate.getTime();
long aferMilliseconds = aferDate.getTime();
long distanceTime = aferMilliseconds - beforeMilliseconds;
distanceTime = Math.abs(distanceTime) / 1000;
long time = 0;
TimeOutEnum timeOut = null;
if (distanceTime - 60 < 0) {
time = distanceTime;
timeOut = TimeOutEnum.SECONDS;
} else if (distanceTime - (60 * 60) < 0) {
time = distanceTime / 60;
timeOut = TimeOutEnum.MINUTES;
} else if (distanceTime - (60 * 60 * 24) < 0) {
time = distanceTime / (60 * 60);
timeOut = TimeOutEnum.HOURS;
} else {
time = distanceTime / (60 * 60 * 24);
timeOut = TimeOutEnum.DAYS;
}
time = (aferMilliseconds - beforeMilliseconds > 0 ? time : 0 - time);
timeOut.setDistanceTimeOut(time);
return timeOut;
}
public static enum TimeOutEnum {
DAYS, HOURS, MINUTES, SECONDS;
private long distanceTimeOut;
public long getDistanceTimeOut() {
return this.distanceTimeOut;
}
private void setDistanceTimeOut(long distanceTimeOut) {
this.distanceTimeOut = distanceTimeOut;
}
public String getTimeOutString() {
String dateString = "";
switch (this) {
case SECONDS:
dateString = this.distanceTimeOut + "秒钟前";
break;
case MINUTES:
dateString = this.distanceTimeOut + "分钟前";
break;
case HOURS:
dateString = this.distanceTimeOut + "小时前";
break;
case DAYS:
dateString = this.distanceTimeOut + "天前";
break;
default:
break;
}
return dateString;
}
}
/**
* 页面显示调用
*
* @param createDate
* @return
*/
public static String getTimeOutString(Date createDate) {
Date beforeDate = new Date(createDate.getTime());
Date nowDate = new Date();
if (subtractDay(nowDate, beforeDate) > 3) {
return DateUtils.format(beforeDate, SHORT_DATE_FORMAT_STR);
}
return getDistanceTimeOut(beforeDate, nowDate).getTimeOutString();
}
/**
* 根据年龄计算出生日
*
* @author fengyuan
* @param age
* @return
*/
public static java.sql.Date getBirthday(int age) {
Date date = new Date();
date = add(date, TimeUnit.YEAR, -age);
return new java.sql.Date(date.getTime());
}
/**
* 根据生日获取年龄
*
* @param birthDay 生日
* @return
*/
public static int getAge(Date birthDay) {
Calendar cal = Calendar.getInstance();// 获取当前系统时间
if (cal.before(birthDay)) {// 如果出生日期大于当前时间,则抛出异常
throw new IllegalArgumentException("The birthDay is before Now.It's unbelievable!");
}
int yearNow = cal.get(Calendar.YEAR);// 取出系统当前时间的年、月、日部分
int monthNow = cal.get(Calendar.MONTH);
int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
cal.setTime(birthDay);// 将日期设置为出生日期
int yearBirth = cal.get(Calendar.YEAR);// 取出出生日期的年、月、日部分
int monthBirth = cal.get(Calendar.MONTH);
int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
int age = yearNow - yearBirth;// 当前年份与出生年份相减,初步计算年龄
if (monthNow <= monthBirth) {// 当前月份与出生日期的月份相比,如果月份小于出生月份,则年龄上减1,表示不满多少周岁
if (monthNow == monthBirth) {// 如果月份相等,在比较日期,如果当前日,小于出生日,也减1,表示不满多少周岁
if (dayOfMonthNow < dayOfMonthBirth) age--;
} else {
age--;
}
}
return age;
}
/**
* 获得2个时间差(分钟)
*
* @param end
* @param begin
* @return
*/
public static long betweenMin(Date end, Date begin) {
long between = 0;
try {
between = (end.getTime() - begin.getTime());// 得到两者的毫秒数
} catch (Exception ex) {
ex.printStackTrace();
}
long day = between / (24 * 60 * 60 * 1000);
long hour = (between / (60 * 60 * 1000) - day * 24);
long min = ((between / (60 * 1000)) - day * 24 * 60 - hour * 60);
return min;
}
/**
* 获得上月第一天
*
* @return
*/
public static Date getLastMonthFirstDate() {
GregorianCalendar c = (GregorianCalendar) Calendar.getInstance();
c.add(Calendar.MONTH, -1);
c.set(Calendar.DAY_OF_MONTH, 1);
return getEarlyInTheDay(c.getTime());
}
/**
* 获得上月最后一天
*
* @return
*/
public static Date getLastMonthEndDate() {
GregorianCalendar c = (GregorianCalendar) Calendar.getInstance();
c.set(Calendar.DAY_OF_MONTH, 1);
c.set(Calendar.DAY_OF_MONTH, -1);
return getLateInTheDay(c.getTime());
}
/**
* 获取起止时间区间内的所有时间集合
*
* @param beginDateStr
* @param endDateStr
* @param format
* @return
*/
public static List<String> getDateRange(String beginDateStr, String endDateStr, String format) {
List<String> dateRange = new ArrayList<String>();
Validate.notBlank(beginDateStr, "beginDateStr不能为空");
Validate.notBlank(endDateStr, "endDateStr不能为空");
Date beginDate = parserDate(beginDateStr, SHORT_DATE_FORMATE_ONE);
Date endDate = parserDate(endDateStr, SHORT_DATE_FORMATE_ONE);
Validate.isTrue(beginDate.before(endDate), "beginDateStr不能大于等于endDateStr");
// 把开始日期加入到结果集中
dateRange.add(format(beginDate, format));
// compareDate 用于比较的日期 第一次 把 beginDate赋值给它
Date compareDate = beginDate;
// 再拿比较日期和 结束日期比较
while (compareDate.before(endDate)) {
// 把比较日期加一天
compareDate = add(compareDate, TimeUnit.DAYS, 1);
dateRange.add(format(compareDate, format));
}
return dateRange;
}
public static List<Date> getDateRange(Date beginDate, Date endDate) {
List<Date> dateRange = new ArrayList<Date>();
Validate.notNull(beginDate, "beginDate不能为空");
Validate.notNull(endDate, "endDate不能为空");
Validate.isTrue(beginDate.before(endDate), "beginDate不能大于等于endDate");
// 把开始日期加入到结果集中
dateRange.add(beginDate);
// compareDate 用于比较的日期 第一次 把 beginDate赋值给它
Date compareDate = beginDate;
// 再拿比较日期和 结束日期比较
while (compareDate.before(endDate)) {
// 把比较日期加一天
compareDate = add(compareDate, TimeUnit.DAYS, 1);
dateRange.add(compareDate);
}
return dateRange;
}
}
| [
"[email protected]"
] | |
bd2a83dbec4017060d677ec34ac22e2a6573913c | ab366fff830099d38603651abf00882795079368 | /src/test/java/com/epam/tat18/pageobjects/GitMainPage.java | 6b0ff1a228346399d008f7a7f4af5183f9e1d2c4 | [] | no_license | oventrop/GitGrid | 0dd93bad4fd86f89a6eddf3003ca16e55a5878cd | e207c252b792f342b7bae134ccbb2cd4125cd646 | refs/heads/master | 2021-05-09T13:38:51.196852 | 2018-02-01T13:01:40 | 2018-02-01T13:01:40 | 119,039,804 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 585 | java | package com.epam.tat18.pageobjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.ui.ExpectedConditions;
public class GitMainPage extends AbstractPage {
public GitMainPage(WebDriver driver) {
super(driver);
}
@FindBy(xpath = "//*[text()='Sign in']")
private WebElement signInButton;
public GitLoginPage pressSignInButton() {
waitForElementVisibility(signInButton);
signInButton.click();
return new GitLoginPage(driver);
}
}
| [
"[email protected]"
] | |
dfbcab60fe6f83c130db3b5e5ea7a5fb45097b52 | fbbc5d67ddb0fea1ab75a7442a1fee9d9b78394c | /tests/io.sarl.lang.tests/src/test/java/io/sarl/lang/tests/bugs/to00999/Bug835.java | 1a07ff59dd12ece8a16774beee4ab8bf887305b2 | [
"Apache-2.0"
] | permissive | srodriguez/sarl | 1b3c893c7a1fcabd649379dfc0f7f10a5a990e1f | 669d66346a83d8953a19f372aa6b7f10a97814b8 | refs/heads/master | 2020-12-24T14:27:28.453678 | 2018-06-26T15:14:46 | 2018-06-26T15:14:46 | 32,932,277 | 2 | 0 | null | 2015-03-26T14:30:14 | 2015-03-26T14:30:14 | null | UTF-8 | Java | false | false | 3,419 | java | /*
* Copyright (C) 2014-2018 the original authors or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.sarl.lang.tests.bugs.to00999;
import static org.junit.Assert.*;
import java.util.ArrayList;
import com.google.inject.Inject;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.xtend.core.xtend.XtendClass;
import org.eclipse.xtext.common.types.JvmTypeReference;
import org.eclipse.xtext.common.types.TypesPackage;
import org.eclipse.xtext.testing.util.ParseHelper;
import org.eclipse.xtext.xbase.XbasePackage;
import org.eclipse.xtext.xbase.testing.CompilationTestHelper;
import org.eclipse.xtext.xbase.typesystem.util.CommonTypeComputationServices;
import org.eclipse.xtext.xbase.validation.UIStrings;
import org.eclipse.xtext.xtype.XtypePackage;
import org.junit.Test;
import io.sarl.lang.SARLVersion;
import io.sarl.lang.annotation.SarlSpecification;
import io.sarl.lang.sarl.SarlField;
import io.sarl.lang.sarl.SarlPackage;
import io.sarl.lang.sarl.SarlScript;
import io.sarl.lang.util.Utils;
import io.sarl.lang.validation.IssueCodes;
import io.sarl.tests.api.AbstractSarlTest;
import io.sarl.tests.api.AbstractSarlTest.Validator;
/** Testing class for issue: Compiler accepts "uses <SkillName>" the same as "uses <CapacityName>".
*
* <p>https://github.com/sarl/sarl/issues/835
*
* @author $Author: sgalland$
* @version $Name$ $Revision$ $Date$
* @mavengroupid $GroupId$
* @mavenartifactid $ArtifactId$
* @see "https://github.com/sarl/sarl/issues/835"
*/
@SuppressWarnings("all")
public class Bug835 extends AbstractSarlTest {
private static final String SNIPSET01 = multilineString(
"package ^skill.^capacity.bug",
"import io.sarl.core.Initialize",
"capacity SomeCapacity{",
" def someFunction",
"}",
"skill SomeSkill implements SomeCapacity{",
" def someFunction{",
" }",
"}",
"agent SomeAgent{",
" uses SomeSkill",
" on Initialize {",
" someFunction",
" }",
"}");
private static final String SNIPSET02 = multilineString(
"package ^skill.^capacity.bug",
"import io.sarl.core.Initialize",
"capacity SomeCapacity{",
" def someFunction",
"}",
"skill SomeSkill implements SomeCapacity{",
" def someFunction{",
" }",
"}",
"agent SomeAgent{",
" uses SomeCapacity",
" on Initialize {",
" someFunction",
" }",
"}");
@Test
public void parsing_01() throws Exception {
SarlScript mas = file(SNIPSET01);
final Validator validator = validate(mas);
validator.assertError(
TypesPackage.eINSTANCE.getJvmParameterizedTypeReference(),
IssueCodes.INVALID_CAPACITY_TYPE,
"Only capacities can be used after the keyword 'uses'");
}
@Test
public void parsing_02() throws Exception {
SarlScript mas = file(SNIPSET02);
final Validator validator = validate(mas);
validator.assertNoIssues();
}
}
| [
"[email protected]"
] | |
7791025c20b87f788ea722d02824a7bbb62fb8e4 | 2f25b5e6bb0166a4145e7d7cd85dffb58402a21d | /app/src/main/java/com/example/bkzhou/data/WeatherInfoModel.java | 8b31fe58cc861f102f4ca57768c8d9a14be72a4f | [] | no_license | ZbkSou/UtilVolley | fd0dfc07888263880949200ff295f3def618f241 | 352ef7c89855845bcfc4bbdc7a25ecdd50916bba | refs/heads/master | 2021-01-18T21:19:45.957951 | 2016-09-01T08:52:20 | 2016-09-01T08:52:20 | 54,626,761 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,578 | java | package com.example.bkzhou.data;
import android.content.Context;
import com.example.bkzhou.model.WeatherInfo;
import com.example.bkzhou.netapi.NetApi;
import com.example.bkzhou.network.NetError;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
/**
* Created by bkzhou on 16-4-23.
*/
public class WeatherInfoModel extends Model {
private String TAG = "WeatherInfoModel";
private String url ="http://www.weather.com.cn/data/sk/101010100.html";
private Context context;
public WeatherInfoModel(Context context) {
super(context);
this.context =context;
}
public void getWeather(final IModelResponse<WeatherInfo> response){
get(context, url, null, new NetApi.JsonResponse() {
@Override
public void onSuccess(JSONObject responseJson, JSONArray responseArray) {
Gson gson = new Gson();
// ArrayList<WeatherInfo> list = gson.fromJson(responseArray.toString(), new TypeToken<ArrayList<BrandPageComplete>>() {
// }.getType());
WeatherInfo weatherInfo = null;
try {
weatherInfo = gson.fromJson(responseJson.getString("weatherinfo"),WeatherInfo.class);
} catch (JSONException e) {
e.printStackTrace();
response.onError(e.getMessage());
}
response.onSuccess(weatherInfo,null);
}
@Override
public void onError(NetError error) {
response.onError(error.getMessage());
}
});
}
}
| [
"[email protected]"
] | |
e7b06fe541448255c45427e014cb40e77c9dbea8 | 24bc32e0a59c1def4fe5c42110e48e23c39bd288 | /LeetCode/src/Hard/ex864/Solution.java | d33f540fa5c821ecb2fdd005acc8ed16c97cd427 | [] | no_license | Sword-Is-Cat/LeetCode | 01e47108153d816947cad48f4b073a1743dd46c8 | 73b08b0945810fb4b976a2a5d3bc46cefbd923b6 | refs/heads/master | 2023-08-30T21:45:58.136842 | 2023-08-29T00:22:35 | 2023-08-29T00:22:35 | 253,831,514 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,917 | java | package Hard.ex864;
import java.util.ArrayDeque;
import java.util.Queue;
class Solution {
int[][] dir = { { 0, 1 }, { 0, -1 }, { 1, 0 }, { -1, 0 } };
char[][] board;
public int shortestPathAllKeys(String[] grid) {
// convert grid to char array
board = new char[grid.length][];
for (int i = 0; i < grid.length; i++) {
board[i] = grid[i].toCharArray();
}
// find start point and keys
int sRow = 0, sCol = 0, allKeys = 0;
for (int row = 0; row < board.length; row++) {
for (int col = 0; col < board[row].length; col++) {
char cell = board[row][col];
if (cell == '@') {
sRow = row;
sCol = col;
} else if (Character.isLowerCase(cell)) {
allKeys += 1 << cell - 'a';
}
}
}
// bfs
int move = 0, size = 0;
// state container [row, col, keys]
Queue<int[]> que = new ArrayDeque<>();
que.add(new int[] { sRow, sCol, 0 });
boolean[][][] visit = new boolean[board.length][board[0].length][allKeys];
visit[sRow][sCol][0] = true;
while (!que.isEmpty()) {
move++;
size = que.size();
while (size-- > 0) {
int[] state = que.poll();
for (int d = 0; d < dir.length; d++) {
int nRow = state[0] + dir[d][0], nCol = state[1] + dir[d][1], key = state[2];
if (isValid(nRow, nCol)) {
char nCell = board[nRow][nCol];
if (Character.isLowerCase(nCell)) {
if (((key >> nCell - 'a') & 1) == 0)
key += 1 << nCell - 'a';
} else if (Character.isUpperCase(nCell)) {
if (((key >> nCell - 'A') & 1) == 0)
continue;
}
if (key == allKeys)
return move;
if (!visit[nRow][nCol][key]) {
visit[nRow][nCol][key] = true;
que.add(new int[] { nRow, nCol, key });
}
}
}
}
}
return -1;
}
private boolean isValid(int row, int col) {
return 0 <= row && 0 <= col && row < board.length && col < board[row].length && board[row][col] != '#';
}
} | [
"[email protected]"
] | |
90863a9dfb53531f7bc2aca03b313d53bacd3bf8 | 67067deb2524c9ef96e3eab862eae011466cee03 | /src/Leet_430.java | 54ec8f11e66c85ad41e1e8e7a9e70ee294a678b5 | [] | no_license | tracysaber/LeetCode | 1b9a78e9fa129f570588ed3158e45e5f1f63892a | 71f944820d75037e94f6b4d2cf7f9d5b82bd63f4 | refs/heads/master | 2021-07-16T04:36:21.310574 | 2018-11-08T06:44:30 | 2018-11-08T06:44:30 | 104,552,990 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,144 | java | /**
* Created by tracysaber on 2018-7-25.
* You are given a doubly linked list which in addition to the next and previous pointers, it could have a child pointer, which may or may not point to a separate doubly linked list. These child lists may have one or more children of their own, and so on, to produce a multilevel data structure, as shown in the example below.
Flatten the list so that all the nodes appear in a single-level, doubly linked list. You are given the head of the first level of the list.
Example:
Input:
1---2---3---4---5---6--NULL
|
7---8---9---10--NULL
|
11--12--NULL
Output:
1-2-3-7-8-11-12-9-10-4-5-6-NULL
*/
class Node {
public int val;
public Node prev;
public Node next;
public Node child;
public Node() {}
public Node(int _val,Node _prev,Node _next,Node _child) {
val = _val;
prev = _prev;
next = _next;
child = _child;
}
};
public class Leet_430 {
public Node flat(Node h){
h.next = h.child;
h.child = null;
Node it = h.child;
while(it.next!=null){
if(it.child!=null){
Node tail = it.next;
flat(it).next = tail;
it = tail;
}
else{
it = it.next;
}
}
return it;
}
public Node flatten(Node head) {
Node it = head;
while(it!=null){
if(it.child!=null){
Node tail = it.next;
flat(it).next = tail;
it = tail;
}
else{
it = it.next;
}
}
return head;
}
public static void main(String args[]){
Node head = new Node(1,null,null,null);
head.next = new Node(2,null,null,null);
head.next.next = new Node(3,null,null,null);
head.next.next.next = new Node(6,null,null,null);
head.next.next.child = new Node(4,null,null,null);
Node it = head.next.next.child;
it.next = new Node(5,null,null,null);
new Leet_430().flatten(head);
System.out.println();
}
}
| [
"[email protected]"
] | |
6f98377eedb11f233a96c7f6984b46e2020bbac9 | db6cdeb44f05bcb565cd20e2e72d069e63011e76 | /clivia/miniataweb/src/main/java/com/scdeco/miniataweb/util/CliviaLocalDateTimeJsonSerializer.java | e5bf0bd80e973938cb8add91aa09a3e56aa86370 | [] | no_license | scdeco/clivia | 43351d9a03f8f5147147ad90cb7c9527b7f640fb | ea9fcb67488270fe2785e5bfb31944d346eeaa0c | refs/heads/master | 2021-01-23T14:21:22.636866 | 2017-02-17T22:43:19 | 2017-02-17T23:10:33 | 35,301,678 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 898 | java | package com.scdeco.miniataweb.util;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
public class CliviaLocalDateTimeJsonSerializer extends JsonSerializer<LocalDateTime> {
// private final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Override
public void serialize(LocalDateTime dateTime, JsonGenerator generator,
SerializerProvider provider) throws IOException,
JsonProcessingException {
String str = dateTime.format(DateTimeFormatter.ISO_LOCAL_DATE_TIME);
generator.writeString(str);
}
}
| [
"[email protected]"
] | |
5a326025e36b4f6ec7532d788ebd812d323190e3 | 0e06e096a9f95ab094b8078ea2cd310759af008b | /sources/com/google/android/gms/internal/drive/zzdp.java | 16487166a4cf7724d082821a2072e3c907079045 | [] | no_license | Manifold0/adcom_decompile | 4bc2907a057c73703cf141dc0749ed4c014ebe55 | fce3d59b59480abe91f90ba05b0df4eaadd849f7 | refs/heads/master | 2020-05-21T02:01:59.787840 | 2019-05-10T00:36:27 | 2019-05-10T00:36:27 | 185,856,424 | 1 | 2 | null | 2019-05-10T00:36:28 | 2019-05-09T19:04:28 | Java | UTF-8 | Java | false | false | 4,003 | java | package com.google.android.gms.internal.drive;
import com.google.android.gms.common.api.GoogleApiClient;
import com.google.android.gms.common.api.PendingResult;
import com.google.android.gms.common.api.Status;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.drive.Drive;
import com.google.android.gms.drive.DriveApi.MetadataBufferResult;
import com.google.android.gms.drive.DriveId;
import com.google.android.gms.drive.DriveResource;
import com.google.android.gms.drive.DriveResource.MetadataResult;
import com.google.android.gms.drive.MetadataChangeSet;
import com.google.android.gms.drive.events.ChangeListener;
import com.google.android.gms.drive.events.zzj;
import java.util.ArrayList;
import java.util.Set;
public class zzdp implements DriveResource {
protected final DriveId zzk;
public zzdp(DriveId driveId) {
this.zzk = driveId;
}
public PendingResult<Status> addChangeListener(GoogleApiClient googleApiClient, ChangeListener changeListener) {
return ((zzaw) googleApiClient.getClient(Drive.CLIENT_KEY)).zza(googleApiClient, this.zzk, changeListener);
}
public PendingResult<Status> addChangeSubscription(GoogleApiClient googleApiClient) {
zzaw zzaw = (zzaw) googleApiClient.getClient(Drive.CLIENT_KEY);
zzj zzj = new zzj(1, this.zzk);
Preconditions.checkArgument(zzj.zza(zzj.zzcy, zzj.zzk));
Preconditions.checkState(zzaw.isConnected(), "Client must be connected");
if (zzaw.zzea) {
return googleApiClient.execute(new zzaz(zzaw, googleApiClient, zzj));
}
throw new IllegalStateException("Application must define an exported DriveEventService subclass in AndroidManifest.xml to add event subscriptions");
}
public PendingResult<Status> delete(GoogleApiClient googleApiClient) {
return googleApiClient.execute(new zzdu(this, googleApiClient));
}
public DriveId getDriveId() {
return this.zzk;
}
public PendingResult<MetadataResult> getMetadata(GoogleApiClient googleApiClient) {
return googleApiClient.enqueue(new zzdq(this, googleApiClient, false));
}
public PendingResult<MetadataBufferResult> listParents(GoogleApiClient googleApiClient) {
return googleApiClient.enqueue(new zzdr(this, googleApiClient));
}
public PendingResult<Status> removeChangeListener(GoogleApiClient googleApiClient, ChangeListener changeListener) {
return ((zzaw) googleApiClient.getClient(Drive.CLIENT_KEY)).zzb(googleApiClient, this.zzk, changeListener);
}
public PendingResult<Status> removeChangeSubscription(GoogleApiClient googleApiClient) {
zzaw zzaw = (zzaw) googleApiClient.getClient(Drive.CLIENT_KEY);
DriveId driveId = this.zzk;
Preconditions.checkArgument(zzj.zza(1, driveId));
Preconditions.checkState(zzaw.isConnected(), "Client must be connected");
return googleApiClient.execute(new zzba(zzaw, googleApiClient, driveId, 1));
}
public PendingResult<Status> setParents(GoogleApiClient googleApiClient, Set<DriveId> set) {
if (set != null) {
return googleApiClient.execute(new zzds(this, googleApiClient, new ArrayList(set)));
}
throw new IllegalArgumentException("ParentIds must be provided.");
}
public PendingResult<Status> trash(GoogleApiClient googleApiClient) {
return googleApiClient.execute(new zzdv(this, googleApiClient));
}
public PendingResult<Status> untrash(GoogleApiClient googleApiClient) {
return googleApiClient.execute(new zzdw(this, googleApiClient));
}
public PendingResult<MetadataResult> updateMetadata(GoogleApiClient googleApiClient, MetadataChangeSet metadataChangeSet) {
if (metadataChangeSet != null) {
return googleApiClient.execute(new zzdt(this, googleApiClient, metadataChangeSet));
}
throw new IllegalArgumentException("ChangeSet must be provided.");
}
}
| [
"[email protected]"
] | |
688d19637ff0547e8bef675c608acc72b0cef17c | 51de3ea6616feb708169fc246dab6c8636c491f5 | /result/com.beust.jcommander.internal.Maps/traditional_mutants/java.util.Map_newHashMap(T)/ASRS_4/Maps.java | 6a32a422ebb93ef4d5f43bf34b88b0bdc600ea6a | [
"Apache-2.0"
] | permissive | ps073006/main_mujava | ab442a597b514cc8491b8b5bd551e8e90e0aa5c6 | c62f68d78c65d91f9dbf5a9a72df152cdda05a9d | refs/heads/master | 2021-01-10T04:37:47.416163 | 2016-01-19T19:36:28 | 2016-01-19T19:36:28 | 49,980,696 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 722 | java | // This is a mutant program.
// Author : ysma
package com.beust.jcommander.internal;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
public class Maps
{
public static <K,V> java.util.Map<K,V> newHashMap()
{
return new java.util.HashMap<K,V>();
}
public static <K,V> java.util.Map<K,V> newLinkedHashMap()
{
return new java.util.LinkedHashMap<K,V>();
}
public static <T> java.util.Map<T,T> newHashMap( T... parameters )
{
java.util.Map<T,T> result = Maps.newHashMap();
for (int i = 0; i < parameters.length; i %= 2) {
result.put( parameters[i], parameters[i + 1] );
}
return result;
}
}
| [
"[email protected]"
] | |
3bc28338b393f1a30bd8544400a5bfede64086b5 | 6fad13624c1de9e8f9cfff576a4f83e4839daa54 | /src/main/java/com/krayemsecond/coronasupportsite/repository/ShopCategoryRepository.java | 926fa05c598405a3d8e79dbcaea2cc4c4e8ba29b | [] | no_license | Samkray21/Corona-Virus-Website-Backend | 319434d891f64837b39f184201bf9cfd4619e6a0 | df6626d2ae3e6ad7b16765ff20dcc6e6c67df48b | refs/heads/main | 2023-01-05T03:28:45.367241 | 2020-10-27T23:40:02 | 2020-10-27T23:40:02 | 307,842,010 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 549 | java | package com.krayemsecond.coronasupportsite.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import com.krayemsecond.coronasupportsite.entity.ShopCategory;
import org.springframework.web.bind.annotation.CrossOrigin;
@CrossOrigin("https://corona-support-site.herokuapp.com")
@RepositoryRestResource(collectionResourceRel="shopCategory", path="shop-category")
public interface ShopCategoryRepository extends JpaRepository<ShopCategory, Long> {
}
| [
"[email protected]"
] | |
4063cc0f53f2ca9a9a28ff235ea4161ece689391 | b2bfc8f492d0cb9e258b7c697373851eb6a4aad1 | /src/test/java/Dike_Booking/service/Flight_service_Test.java | 2be10637a48550ffb6792082442c8ce75e5f15f5 | [] | no_license | subaruwrx/Mycloud | bf3b10b6176245efce02ca65f5dd35cb4be753a4 | 677cfc1af4b987b88b9d7aca24d210a93208a412 | refs/heads/master | 2021-01-10T03:04:37.288500 | 2015-09-27T02:04:12 | 2015-09-27T02:04:12 | 43,230,894 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,718 | java | package Dike_Booking.service;
import Dike_Booking.App;
import Dike_Booking.Service.Event_Service;
import Dike_Booking.Service.Flight_Service;
import Dike_Booking.config_factory.FilghtFactory;
import Dike_Booking.domain.Flight;
import Dike_Booking.repository.FlightRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.test.context.web.WebAppConfiguration;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* Created by student on 2015/05/21.
*/
@SpringApplicationConfiguration(classes= App.class)
@WebAppConfiguration
public class Flight_service_Test extends AbstractTestNGSpringContextTests {
private Integer flight_id;
@Autowired
private Flight_Service service;
@Autowired
public FlightRepository repo;
@Test
public void create() throws Exception {
Map<String,String> values = new HashMap<String,String>();
values.put("from_location","Port elizabeth");
values.put("to_location","Cape town");
values.put("departure_time","8:00");
values.put("arrival_time","15:00");
Flight flight = FilghtFactory
.createFlight(values);
repo.save(flight);
flight_id = flight.getFlight_id();
Assert.assertNotNull(flight.getFlight_id());
}
@Test
public void testEventinfo() throws Exception {
List<Flight> flight=service.getFlights();
org.testng.Assert.assertTrue(flight.size() == 2);
}
}
| [
"[email protected]"
] | |
094054b6f23bbf39324aaf6e40ec0ff0c9487f86 | 245adf54c314db7f95fc571ea7e041784c1f0d8e | /src/main/java/com/simciv/Screens/CityManager/Resources.java | 1d832f0e323b95d07ffb06c0c8dcb2feb2fba3a9 | [] | no_license | Lytecyde/com.simciv | 9d5961f4665672fe7a26f48ee7e8ef42b9929577 | 3f4636a41f21b0309d527083d005de763bc94b9e | refs/heads/master | 2020-03-10T02:40:39.246694 | 2018-07-12T08:18:44 | 2018-07-12T08:18:44 | 129,142,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 68 | java | package com.simciv.Screens.CityManager;
public class Resources {
}
| [
"[email protected]"
] | |
c530d76ed85deb74ad9a454564a44a3b6a62e46d | 50725bf65a28899565f46971414be62453db5b78 | /AirJoy/app/src/main/java/com/android/airjoy/app/pcscreen/ScreenSocket.java | e8d524f6577a356927d2e7c9dbd92a661fece7d2 | [] | no_license | AddBean/Android-Airjoy | 786d525110a0f2c736bb1b2fa72623ff77290008 | e1fc49157063c28244e3bea7bc6f053e5e1e9740 | refs/heads/master | 2021-01-14T11:48:34.244592 | 2016-09-20T04:00:05 | 2016-09-20T04:00:05 | 68,672,282 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,279 | java | package com.android.airjoy.app.pcscreen;
import com.addbean.autils.utils.ALog;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
/**
* ��Ļsocket�ࣻ
*
* @author �ֶ�
*/
public class ScreenSocket {
private String ip;
private int port;
private Socket socket = null;
DataOutputStream out = null;
DataInputStream getDownloadStream = null;
public ScreenSocket(String ip, int port) {
this.ip = ip;
this.port = port;
}
public void createConnection() {
try {
closeSocket();
socket = new Socket(ip, port);
ALog.e("成功建立连接:"+ip+":"+port);
} catch (UnknownHostException e) {
e.printStackTrace();
closeSocket();
} catch (IOException e) {
e.printStackTrace();
closeSocket();
} finally {
}
}
public void closeSocket(){
if (socket != null) {
try {
socket.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
public Socket getSocket() {
return socket;
}
public void sendFileInf() {
try {
if(socket==null)createConnection();
out = new DataOutputStream(socket.getOutputStream());
byte[] buffer = "SYNPCVIEW|jiadou|".getBytes();
out.write(buffer);
ALog.e("发送同步信息:"+"SYNPCVIEW|jiadou|");
return;
} catch (IOException e) {
e.printStackTrace();
if (out != null) {
try {
out.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
}
/* ��ȡ�����ļ���*/
public DataInputStream getDownloadStream() {
try {
getDownloadStream = new DataInputStream(new BufferedInputStream(
socket.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
if (getDownloadStream != null) {
try {
getDownloadStream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return getDownloadStream;
}
/* �رյ�ǰ����*/
public void shutDownConnection() {
try {
if (out != null) {
out.close();
}
if (getDownloadStream != null) {
getDownloadStream.close();
}
if (socket != null) {
socket.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
/* ���ֽ������ȡͼƬ��С */
public static int getLengthFromByte(byte[] lb) {
String s = new String(lb);
int imgLength = 0;
try {
imgLength = Integer.valueOf(s).intValue();
} catch (Exception error) {
return 0;
}
return imgLength;
}
}
| [
"[email protected]"
] | |
1b05b4a73e2500b2316083cfea1956c570f7a71b | e814e55a82d8c2f6cfa794e6331e47ec005ba265 | /src/main/java/com/example/myapplication/ui/fragment/taluk/taluk_detail/places/TalukPlacesFragmentViewModel.java | 71781ae1e8465caa30468d06d8a6faee225f6436 | [] | no_license | satishru/Haveri-Application-27032020 | 883a8a62313b93b5b850302e46eff85af39abf2d | 196b0d1b4523e29a28ad85a3e06ca3ebeb9ef0b4 | refs/heads/master | 2021-05-17T02:05:35.694229 | 2020-03-27T15:21:37 | 2020-03-27T15:21:37 | 250,568,345 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,306 | java | package com.example.myapplication.ui.fragment.taluk.taluk_detail.places;
import androidx.lifecycle.MutableLiveData;
import com.example.myapplication.data.DataManager;
import com.example.myapplication.data.model.api.response.haveri_data.Place;
import com.example.myapplication.data.model.api.response.haveri_data.Taluk;
import com.example.myapplication.ui.base.BaseViewModel;
import com.example.myapplication.utils.rx.SchedulerProvider;
import java.util.ArrayList;
import java.util.List;
public class TalukPlacesFragmentViewModel extends BaseViewModel<iTalukPlacesFragmentContract.iTalukPlacesFragmentNavigator>
implements iTalukPlacesFragmentContract.iTalukPlacesFragmentViewModel {
private final MutableLiveData<List<Place>> allPlaceList = new MutableLiveData<>();
public TalukPlacesFragmentViewModel(DataManager dataManager, SchedulerProvider schedulerProvider) {
super(dataManager, schedulerProvider);
}
@Override
public void setPlaceList(Taluk selectedTaluk) {
List<Place> placeList = new ArrayList<>();
if (selectedTaluk != null) {
placeList.addAll(selectedTaluk.getPlaces());
}
allPlaceList.setValue(placeList);
}
public MutableLiveData<List<Place>> getPlaceList() {
return allPlaceList;
}
}
| [
"[email protected]"
] | |
c8d0686b1a22d8e9407ff128e8d9b7e3927ded1c | 735d096119a4af841266316b4ad3af9ae3c92071 | /src/main/java/com/github/dakusui/processstreamer/exceptions/InternalException.java | 5373e1540929be145681d3dcf5de2dd0cdfe87dd | [
"MIT"
] | permissive | dakusui/processstreamer | b1d6f925529e38da7f786c1f60eadd8c7426b57a | c9dfd2ca2af72415943c96681468712b1dc263ef | refs/heads/master | 2022-06-04T14:37:32.851369 | 2022-05-11T00:25:17 | 2022-05-11T00:25:17 | 171,548,042 | 0 | 0 | MIT | 2022-05-10T23:47:16 | 2019-02-19T20:53:29 | Java | UTF-8 | Java | false | false | 273 | java | package com.github.dakusui.processstreamer.exceptions;
class InternalException extends CommandException {
InternalException(String message, Throwable throwable) {
super(message, throwable);
}
InternalException(Throwable throwable) {
super(throwable);
}
}
| [
"[email protected]"
] | |
e4ff39f830d52abe777f3125e86efad725c722f8 | 869bb55f283866d6447b4507d6f651f7b175f4d8 | /Avenida/app/src/main/java/com/app/ahgas_e9cd797/volley/CustomRequest.java | 0fcaeb38e997a3bc935da23e5da851eddf8ebfd5 | [] | no_license | saif0347/AppsGas | 1c45684beea52eb266cbb248d88f5dcafefda04e | 2acf52a5647ce57ab7e798e232fd5c324b36635b | refs/heads/master | 2023-04-06T02:48:55.230262 | 2021-04-13T23:02:32 | 2021-04-13T23:02:32 | 267,989,256 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,292 | java | package com.app.ahgas_e9cd797.volley;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.HttpHeaderParser;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.UnsupportedEncodingException;
import java.util.Map;
public class CustomRequest extends Request<JSONObject> {
private Listener<JSONObject> listener;
private ErrorListener errorListener;
private Map<String, String> params;
public CustomRequest(String url, Map<String, String> params, Listener<JSONObject> reponseListener, ErrorListener errorListener) {
super(Method.GET, url, errorListener);
this.listener = reponseListener;
this.errorListener = errorListener;
this.params = params;
}
public CustomRequest(int method, String url, Map<String, String> params, Listener<JSONObject> reponseListener, ErrorListener errorListener) {
super(method, url, errorListener);
this.listener = reponseListener;
this.errorListener = errorListener;
this.params = params;
}
protected Map<String, String> getParams() throws com.android.volley.AuthFailureError {
return params;
};
@Override
protected Response<JSONObject> parseNetworkResponse(NetworkResponse response) {
try {
String jsonString = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
return Response.success(new JSONObject(jsonString),
HttpHeaderParser.parseCacheHeaders(response));
} catch (UnsupportedEncodingException e) {
return Response.error(new ParseError(e));
} catch (JSONException je) {
return Response.error(new ParseError(je));
}
}
@Override
protected void deliverResponse(JSONObject response) {
listener.onResponse(response);
}
@Override
public void deliverError(VolleyError error) {
errorListener.onErrorResponse(error);
}
}
| [
"[email protected]"
] | |
5a24bfdde678d52cb4c0c2b685fcc082ef6b7b30 | ffa622b905167dc4e5f2e6438340d0e4995be12b | /Algs4Prt1KdTrees/src/RandomizedQueue.java | 377b8c3709e48775fb3162e88fd9d34460bb71b4 | [] | no_license | vskurikhin/Algs4Prt1 | b1c3c410dfb3e6822d9594b9febe4e04104ab6af | d02c6721c705355108d23d9bdacfe00723e2efcb | refs/heads/master | 2020-05-01T00:45:45.172416 | 2015-10-26T08:35:58 | 2015-10-26T08:35:58 | 177,176,633 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,211 | java | /* RandomizedQueue.java */
/* $Date$
* $Id$
* $Version: 0.1$
* $Revision: 1$
*/
/*
* 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.
*/
/*
*
* @author skurvikn
*/
import java.util.Iterator;
import java.util.NoSuchElementException;
// import java.lang.reflect.Array;
public class RandomizedQueue<Item> implements Iterable<Item> {
/* _if_ */
private final String delimeter = "=======";
private final static int MAX_INT_VAL = 536870912;
/* _endif_ */
private int iSize;
private static class Node<Item> {
private Item item;
/* _if_ */
private Node<Item> next;
private Node<Item> prev;
/* _endif_ */
}
private Node<Item> nodeFirst;
private Node<Item> nodeLast;
private Node<Item>[] arrNodes;
private int iArrNodesSize;
// construct an empty randomized queue
/* _if_
@SuppressWarnings("unchecked")
/* _endif_ */
public RandomizedQueue() {
nodeFirst = null;
nodeLast = null;
iSize = 0;
iArrNodesSize = 2;
arrNodes = (Node<Item>[]) new Node[iArrNodesSize];
}
// is the queue empty?
public boolean isEmpty() { return (null == nodeFirst); }
// return the number of items on the queue
public int size() { return iSize; }
// resize the underlying array
private void resize(int max) {
iArrNodesSize = max;
/* _if_ */
@SuppressWarnings("unchecked")
/* _endif_ */
Node<Item>[] arrTemp = (Node<Item>[]) new Node[max];
int j = 0;
for (int i = 0; i < arrNodes.length; ++i) {
arrTemp[j] = arrNodes[i];
if (null != arrTemp[j]) {
j++;
}
if (j == max)
break;
}
arrNodes = null;
arrNodes = arrTemp;
}
// add the item
public void enqueue(Item item) {
if (null == item) {
throw new java.lang.NullPointerException();
}
Node<Item> nodeTemp = nodeLast;
if (isEmpty()) {
nodeLast = new Node<Item>();
nodeFirst = nodeLast;
/* _if_ */
nodeLast.prev = null;
/* _endif_ */
} else {
nodeLast = new Node<Item>();
/* _if_ */
nodeLast.prev = nodeTemp;
nodeTemp.next = nodeLast;
/* _endif_ */
}
nodeLast.item = item;
/* _if_ */
nodeLast.next = null;
/* _endif_ */
if (arrNodes.length == iSize) {
resize(2*arrNodes.length);
}
arrNodes[iSize] = nodeLast;
iSize++;
}
private int selectRandom() {
int iRandom = StdRandom.uniform(iSize);
int i = iRandom;
int j = iRandom;
/* _if_ */
StdOut.printf("iSize = %d, iRandom = %d\n", iSize, iRandom);
/* _endif_ */
while (null == arrNodes[iRandom] && iSize > 0) {
if (i < (arrNodes.length - 1)) {
++i;
if (null != arrNodes[i]) {
iRandom = i;
break;
}
}
if (j > 0) {
--j;
if (null != arrNodes[j]) {
iRandom = j;
break;
}
}
}
return iRandom;
}
// remove and return a random item
public Item dequeue() {
if (isEmpty()) {
throw new NoSuchElementException("Queue underflow");
}
int iRandom = selectRandom();
/* _if_ */
StdOut.printf("iSize = %d, iRandom = %d\n", iSize, iRandom);
/* _endif_ */
Node<Item> nodeTemp = arrNodes[iRandom];
Item itemTemp = nodeTemp.item;
/* _if_ */
if (null != nodeTemp.next) {
nodeTemp.next.prev = nodeTemp.prev;
}
if (null != nodeTemp.prev) {
nodeTemp.prev.next = nodeTemp.next;
}
/* _endif_ */
if (iRandom >= 0) {
nodeTemp = null;
arrNodes[iRandom] = arrNodes[iSize - 1];
arrNodes[iSize - 1] = null;
}
iSize--;
if (iSize > 0 && iSize == arrNodes.length/4) {
resize(arrNodes.length/2);
}
if (0 == iSize) {
nodeFirst = null;
nodeLast = null;
}
return itemTemp;
}
// return (but do not remove) a random item
public Item sample() {
if (isEmpty()) {
throw new NoSuchElementException("Queue underflow");
}
int iRandom = selectRandom();
return arrNodes[iRandom].item;
}
// an iterator, doesn't implement remove() since it's optional
private class ListIterator<itrItem> implements Iterator<itrItem> {
private int index;
private int[] arrOrder;
private Node<itrItem>[] array;
public ListIterator(Node<itrItem>[] first) {
array = first;
index = 0;
if (iSize < 1) return;
arrOrder = new int[iSize];
for (int i = 0; i < iSize; ++i) {
arrOrder[i] = i;
}
StdRandom.shuffle(arrOrder);
}
public boolean hasNext() { return index < iSize; }
public void remove() { throw new UnsupportedOperationException(); }
public itrItem next() {
if (!hasNext()) throw new NoSuchElementException();
itrItem item = array[arrOrder[index++]].item;
return item;
}
}
// return an independent iterator over items in random order
public Iterator<Item> iterator() {
return new ListIterator<Item>(arrNodes);
}
/* _if_ */
public void printAllNodesDown() {
boolean whileTrigger = false;
Node<Item> e = nodeFirst;
while (e != null) {
StdOut.println(delimeter);
StdOut.printf("e.pntr: %b\n", e);
StdOut.printf("e.item: \"%s\"\n", e.item);
StdOut.printf("e.next: %s\n",
(null != e.next ? "linked" : "nolink"));
StdOut.printf("e.prev: %s\n",
(null != e.prev ? "linked" : "nolink"));
e = e.next;
whileTrigger = true;
}
if (whileTrigger) {
StdOut.println(delimeter);
}
}
/* _endif_ */
// unit testing
/* _if_ */
public static void main(String[] args) {
int upperBound = 16;
if (args.length > 0) {
upperBound = Integer.parseInt(args[0]);
}
int N = StdRandom.uniform(upperBound);
StdOut.println("==== UNIT TEST 0 Random ====");
StdOut.printf("N = %d\n", N);
RandomizedQueue<Integer> rq0 = new RandomizedQueue<Integer>();
for (int i = 0; i < N; ++i) {
int t = StdRandom.uniform(5);
switch (t) {
case 0: // enqueue(item)
StdOut.println("=== begin enqueue(item) ===");
int v = StdRandom.uniform(65535);
rq0.enqueue(v);
StdOut.printf(" rq.enqueue(%d)\n", v);
StdOut.println("=== end enqueue(item) ===");
break;
case 1: // ListIterator
StdOut.println("=== begin ListIterator ===");
for (Integer I : rq0) {
StdOut.printf(" rq Iterate: %d\n", I);
}
StdOut.println("=== end ListIterator ===");
break;
case 2: // dequeue()
StdOut.println("=== begin dequeue() ===");
StdOut.printf("rq.dequeue() = %d\n", rq0.dequeue());
StdOut.println("=== end dequeue() ===");
break;
case 3: // isEmpty()
StdOut.println("=== begin isEmpty() ===");
StdOut.printf(" rq.isEmpty() = %b\n", rq0.isEmpty());
StdOut.println("=== end isEmpty() ===");
break;
case 4: // size()
StdOut.println("=== begin size() ===");
StdOut.printf(" rq.size() = %d\n", rq0.size());
StdOut.println("=== end size() ===");
break;
}
}
StdOut.println("==== UNIT TEST 1 Stress ====");
RandomizedQueue<Integer> rq1 = new RandomizedQueue<Integer>();
StdOut.println("=== begin isEmpty() ===");
StdOut.printf(" rq.isEmpty() = %b\n", rq1.isEmpty());
StdOut.println("=== end isEmpty() ===");
StdOut.println("=== begin size() ===");
StdOut.printf(" rq.size() = %d\n", rq0.size());
StdOut.println("=== end size() ===");
StdOut.println("=== begin enqueue(item) ===");
for (int i = 1; i < MAX_INT_VAL; ++i) { // Integer.MAX_VALUE
int v = StdRandom.uniform(65535);
rq1.enqueue(v);
StdOut.printf(" rq.enqueue(%d)\n", v);
}
StdOut.println("=== end enqueue(item) ===");
StdOut.println("=== begin size() ===");
StdOut.printf(" rq.size() = %d\n", rq0.size());
StdOut.println("=== end size() ===");
StdOut.println("=== begin ListIterator ===");
for (Integer I : rq1) {
StdOut.printf(" rq Iterate: %d\n", I);
}
StdOut.println("=== end ListIterator ===");
StdOut.println("=== begin dequeue() ===");
for (int i = 0; i < MAX_INT_VAL; ++i) { // Integer.MAX_VALUE
StdOut.printf("rq.dequeue() = %d\n", rq1.dequeue());
}
StdOut.println("=== end dequeue() ===");
StdOut.println("=== begin size() ===");
StdOut.printf(" rq.size() = %d\n", rq0.size());
StdOut.println("=== end size() ===");
StdOut.println("=== begin isEmpty() ===");
StdOut.printf(" rq.isEmpty() = %b\n", rq1.isEmpty());
StdOut.println("=== end isEmpty() ===");
}
/* _endif_ */
}
/* vim: syntax=java:fileencoding=utf-8:fileformat=unix:tw=78:ts=4:sw=4:sts=4:et
*/
//EOF
| [
"[email protected]"
] | |
28224bfd7d2f62d76c43785a242836f4211d6edd | 544b823ac58facf7756085d15592305bb0cac3d7 | /src/main/java/com/learnjava/service/CheckoutService.java | 59d182e7d1557c477fb35be4e6e82bbb0d918e79 | [] | no_license | akshitk20/parallel-async-programming-java | 31ff0ea5a2a1dab122db90f8931fe6f4000ca390 | bb9b444f4f52e9fc7b4265518a9ec9e31e48f960 | refs/heads/master | 2023-06-24T19:48:59.557973 | 2021-07-22T18:50:18 | 2021-07-22T18:50:18 | 388,563,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,053 | java | package com.learnjava.service;
import com.learnjava.domain.checkout.Cart;
import com.learnjava.domain.checkout.CartItem;
import com.learnjava.domain.checkout.CheckoutResponse;
import com.learnjava.domain.checkout.CheckoutStatus;
import java.util.List;
import java.util.stream.Collectors;
import static com.learnjava.util.CommonUtil.*;
import static com.learnjava.util.LoggerUtil.log;
import static java.util.stream.Collectors.summingDouble;
public class CheckoutService {
private PriceValidatorService priceValidatorService;
public CheckoutService(PriceValidatorService priceValidatorService) {
this.priceValidatorService = priceValidatorService;
}
public CheckoutResponse checkOut(Cart cart){
startTimer();
List<CartItem> cartItems = cart.getCartItemList()
.parallelStream()
.map(cartItem -> {
boolean isPriceItemInvalid = priceValidatorService.isCartItemInvalid(cartItem);
cartItem.setExpired(isPriceItemInvalid);
return cartItem;
})
.filter(CartItem::isExpired)
.collect(Collectors.toList());
if(!cartItems.isEmpty()){
return new CheckoutResponse(CheckoutStatus.FAILURE,cartItems);
}
double price = calculateFinalPriceReduce(cart);
log("checkout price "+price);
timeTaken();
return new CheckoutResponse(CheckoutStatus.SUCCESS,price);
}
private double calculateFinalPrice(Cart cart) {
return cart.getCartItemList()
.parallelStream()
.map(cartItem -> cartItem.getQuantity() * cartItem.getRate())
.mapToDouble(Double::doubleValue)
.sum(); //sum the price
}
private double calculateFinalPriceReduce(Cart cart) {
return cart.getCartItemList()
.parallelStream()
.map(cartItem -> cartItem.getQuantity() * cartItem.getRate())
.reduce(0.0,(x,y) -> x+y);
}
}
| [
"[email protected]"
] | |
ab14b103e22d319603167b6e141e96040384d799 | 74b47b895b2f739612371f871c7f940502e7165b | /aws-java-sdk-elasticloadbalancing/src/main/java/com/amazonaws/services/elasticloadbalancing/waiters/InstanceInService.java | dd0505ee6a1534b53567afe4b9e379104f2f006e | [
"Apache-2.0"
] | permissive | baganda07/aws-sdk-java | fe1958ed679cd95b4c48f971393bf03eb5512799 | f19bdb30177106b5d6394223a40a382b87adf742 | refs/heads/master | 2022-11-09T21:55:43.857201 | 2022-10-24T21:08:19 | 2022-10-24T21:08:19 | 221,028,223 | 0 | 0 | Apache-2.0 | 2019-11-11T16:57:12 | 2019-11-11T16:57:11 | null | UTF-8 | Java | false | false | 3,755 | java | /*
* Copyright 2017-2022 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.amazonaws.services.elasticloadbalancing.waiters;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.annotation.SdkInternalApi;
import com.amazonaws.waiters.WaiterAcceptor;
import com.amazonaws.waiters.WaiterState;
import com.amazonaws.waiters.AcceptorPathMatcher;
import com.amazonaws.services.elasticloadbalancing.model.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.amazonaws.jmespath.*;
import java.io.IOException;
import javax.annotation.Generated;
@SdkInternalApi
@Generated("com.amazonaws:aws-java-sdk-code-generator")
class InstanceInService {
static class IsInServiceMatcher extends WaiterAcceptor<DescribeInstanceHealthResult> {
private static final JsonNode expectedResult;
static {
try {
expectedResult = ObjectMapperSingleton.getObjectMapper().readTree("\"InService\"");
} catch (IOException ioe) {
throw new RuntimeException(ioe);
}
}
private static final JmesPathExpression ast = new JmesPathProjection(new JmesPathFlatten(new JmesPathField("InstanceStates")), new JmesPathField(
"State"));
/**
* Takes the result and determines whether the state of the resource matches the expected state. To determine
* the current state of the resource, JmesPath expression is evaluated and compared against the expected result.
*
* @param result
* Corresponding result of the operation
* @return True if current state of the resource matches the expected state, False otherwise
*/
@Override
public boolean matches(DescribeInstanceHealthResult result) {
JsonNode queryNode = ObjectMapperSingleton.getObjectMapper().valueToTree(result);
JsonNode finalResult = ast.accept(new JmesPathEvaluationVisitor(), queryNode);
return AcceptorPathMatcher.pathAll(expectedResult, finalResult);
}
/**
* Represents the current waiter state in the case where resource state matches the expected state
*
* @return Corresponding state of the waiter
*/
@Override
public WaiterState getState() {
return WaiterState.SUCCESS;
}
}
static class IsInvalidInstanceMatcher extends WaiterAcceptor<DescribeInstanceHealthResult> {
/**
* Takes the response exception and determines whether this exception matches the expected exception, by
* comparing the respective error codes.
*
* @param e
* Response Exception
* @return True if it matches, False otherwise
*/
@Override
public boolean matches(AmazonServiceException e) {
return "InvalidInstance".equals(e.getErrorCode());
}
/**
* Represents the current waiter state in the case where resource state matches the expected state
*
* @return Corresponding state of the waiter
*/
@Override
public WaiterState getState() {
return WaiterState.RETRY;
}
}
}
| [
""
] | |
98e00733cd94051517edb42f918b335145625ff6 | e75be673baeeddee986ece49ef6e1c718a8e7a5d | /submissions/blizzard/Corpus/eclipse.jdt.ui/8198.java | e88c935612abd2420e1301a81b20f5d37b9ac074 | [
"MIT"
] | permissive | zhendong2050/fse18 | edbea132be9122b57e272a20c20fae2bb949e63e | f0f016140489961c9e3c2e837577f698c2d4cf44 | refs/heads/master | 2020-12-21T11:31:53.800358 | 2018-07-23T10:10:57 | 2018-07-23T10:10:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,799 | java | /*******************************************************************************
* Copyright (c) 2000, 2011 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.ui.actions;
import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICodeAssist;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
import org.eclipse.jdt.ui.JavaElementLabelProvider;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
public class SelectionConverter {
private static final IJavaElement[] EMPTY_RESULT = new IJavaElement[0];
private SelectionConverter() {
// no instance
}
/**
* Converts the selection provided by the given part into a structured selection. The following
* conversion rules are used:
* <ul>
* <li><code>part instanceof JavaEditor</code>: returns a structured selection using code
* resolve to convert the editor's text selection.</li>
* <li><code>part instanceof IWorkbenchPart</code>: returns the part's selection if it is a
* structured selection.</li>
* <li><code>default</code>: returns an empty structured selection.</li>
* </ul>
*
* @param part the part
* @return the selection
* @throws JavaModelException thrown when the type root can not be accessed
*/
public static IStructuredSelection getStructuredSelection(IWorkbenchPart part) throws JavaModelException {
if (part instanceof JavaEditor)
return new StructuredSelection(codeResolve((JavaEditor) part));
ISelectionProvider provider = part.getSite().getSelectionProvider();
if (provider != null) {
ISelection selection = provider.getSelection();
if (selection instanceof IStructuredSelection)
return (IStructuredSelection) selection;
}
return StructuredSelection.EMPTY;
}
/**
* Converts the given structured selection into an array of Java elements.
* An empty array is returned if one of the elements stored in the structured
* selection is not of type <code>IJavaElement</code>
* @param selection the selection
* @return the Java element contained in the selection
*/
public static IJavaElement[] getElements(IStructuredSelection selection) {
if (!selection.isEmpty()) {
IJavaElement[] result = new IJavaElement[selection.size()];
int i = 0;
for (Iterator<?> iter = selection.iterator(); iter.hasNext(); i++) {
Object element = iter.next();
if (!(element instanceof IJavaElement))
return EMPTY_RESULT;
result[i] = (IJavaElement) element;
}
return result;
}
return EMPTY_RESULT;
}
public static boolean canOperateOn(JavaEditor editor) {
if (editor == null)
return false;
return getInput(editor) != null;
}
public static IJavaElement[] codeResolveOrInputForked(JavaEditor editor) throws InvocationTargetException, InterruptedException {
ITypeRoot input = getInput(editor);
if (input == null)
return EMPTY_RESULT;
ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
IJavaElement[] result = performForkedCodeResolve(input, selection);
if (result.length == 0) {
result = new IJavaElement[] { input };
}
return result;
}
/**
* Perform a code resolve at the current selection of an editor
*
* @param editor the editor
* @return the resolved elements (only from primary working copies)
* @throws JavaModelException when the type root can not be accessed
*/
public static IJavaElement[] codeResolve(JavaEditor editor) throws JavaModelException {
return codeResolve(editor, true);
}
/**
* Perform a code resolve at the current selection of an editor
*
* @param editor the editor
* @param primaryOnly if <code>true</code> only primary working copies will be returned
* @return the resolved elements
* @throws JavaModelException thrown when the type root can not be accessed
* @since 3.2
*/
public static IJavaElement[] codeResolve(JavaEditor editor, boolean primaryOnly) throws JavaModelException {
ITypeRoot input = getInput(editor, primaryOnly);
if (input != null)
return codeResolve(input, (ITextSelection) editor.getSelectionProvider().getSelection());
return EMPTY_RESULT;
}
/**
* Perform a code resolve in a separate thread.
*
* @param editor the editor
* @param primaryOnly if <code>true</code> only primary working copies will be returned
* @return the resolved elements
* @throws InvocationTargetException which wraps any exception or error which occurs while
* running the runnable
* @throws InterruptedException propagated by the context if the runnable acknowledges
* cancelation by throwing this exception
* @since 3.2
*/
public static IJavaElement[] codeResolveForked(JavaEditor editor, boolean primaryOnly) throws InvocationTargetException, InterruptedException {
ITypeRoot input = getInput(editor, primaryOnly);
if (input != null)
return performForkedCodeResolve(input, (ITextSelection) editor.getSelectionProvider().getSelection());
return EMPTY_RESULT;
}
/**
* Returns the element surrounding the selection of the given editor.
*
* @param editor the editor
* @return the element surrounding the current selection (only from primary working copies), or <code>null</code> if none
* @throws JavaModelException if the Java type root does not exist or if an exception occurs
* while accessing its corresponding resource
*/
public static IJavaElement getElementAtOffset(JavaEditor editor) throws JavaModelException {
return getElementAtOffset(editor, true);
}
/**
* Returns the element surrounding the selection of the given editor.
*
* @param editor the editor
* @param primaryOnly if <code>true</code> only primary working copies will be returned
* @return the element surrounding the current selection, or <code>null</code> if none
* @throws JavaModelException if the Java type root does not exist or if an exception occurs
* while accessing its corresponding resource
* @since 3.2
*/
public static IJavaElement getElementAtOffset(JavaEditor editor, boolean primaryOnly) throws JavaModelException {
ITypeRoot input = getInput(editor, primaryOnly);
if (input != null)
return getElementAtOffset(input, (ITextSelection) editor.getSelectionProvider().getSelection());
return null;
}
public static IType getTypeAtOffset(JavaEditor editor) throws JavaModelException {
IJavaElement element = SelectionConverter.getElementAtOffset(editor);
IType type = (IType) element.getAncestor(IJavaElement.TYPE);
if (type == null) {
ICompilationUnit unit = SelectionConverter.getInputAsCompilationUnit(editor);
if (unit != null)
type = unit.findPrimaryType();
}
return type;
}
/**
* Returns the input element of the given editor.
*
* @param editor the Java editor
* @return the type root which is the editor input (only primary working copies), or <code>null</code> if none
*/
public static ITypeRoot getInput(JavaEditor editor) {
return getInput(editor, true);
}
/**
* Returns the input element of the given editor.
*
* @param editor the Java editor
* @param primaryOnly if <code>true</code> only primary working copies will be returned
* @return the type root which is the editor input, or <code>null</code> if none
* @since 3.2
*/
private static ITypeRoot getInput(JavaEditor editor, boolean primaryOnly) {
if (editor == null)
return null;
return EditorUtility.getEditorInputJavaElement(editor, primaryOnly);
}
public static ICompilationUnit getInputAsCompilationUnit(JavaEditor editor) {
Object editorInput = SelectionConverter.getInput(editor);
if (editorInput instanceof ICompilationUnit)
return (ICompilationUnit) editorInput;
return null;
}
public static IClassFile getInputAsClassFile(JavaEditor editor) {
Object editorInput = SelectionConverter.getInput(editor);
if (editorInput instanceof IClassFile)
return (IClassFile) editorInput;
return null;
}
private static IJavaElement[] performForkedCodeResolve(final ITypeRoot input, final ITextSelection selection) throws InvocationTargetException, InterruptedException {
final class CodeResolveRunnable implements IRunnableWithProgress {
IJavaElement[] result;
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
result = codeResolve(input, selection);
} catch (JavaModelException e) {
throw new InvocationTargetException(e);
}
}
}
CodeResolveRunnable runnable = new CodeResolveRunnable();
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(runnable);
return runnable.result;
}
public static IJavaElement[] codeResolve(IJavaElement input, ITextSelection selection) throws JavaModelException {
if (input instanceof ICodeAssist) {
if (input instanceof ICompilationUnit) {
JavaModelUtil.reconcile((ICompilationUnit) input);
}
IJavaElement[] elements = ((ICodeAssist) input).codeSelect(selection.getOffset() + selection.getLength(), 0);
if (elements.length > 0) {
return elements;
}
}
return EMPTY_RESULT;
}
public static IJavaElement getElementAtOffset(ITypeRoot input, ITextSelection selection) throws JavaModelException {
if (input instanceof ICompilationUnit) {
JavaModelUtil.reconcile((ICompilationUnit) input);
}
IJavaElement ref = input.getElementAt(selection.getOffset());
if (ref == null)
return input;
return ref;
}
public static IJavaElement resolveEnclosingElement(JavaEditor editor, ITextSelection selection) throws JavaModelException {
ITypeRoot input = getInput(editor);
if (input != null)
return resolveEnclosingElement(input, selection);
return null;
}
public static IJavaElement resolveEnclosingElement(IJavaElement input, ITextSelection selection) throws JavaModelException {
IJavaElement atOffset = null;
if (input instanceof ICompilationUnit) {
ICompilationUnit cunit = (ICompilationUnit) input;
JavaModelUtil.reconcile(cunit);
atOffset = cunit.getElementAt(selection.getOffset());
} else if (input instanceof IClassFile) {
IClassFile cfile = (IClassFile) input;
atOffset = cfile.getElementAt(selection.getOffset());
} else {
return null;
}
if (atOffset == null) {
return input;
} else {
int selectionEnd = selection.getOffset() + selection.getLength();
IJavaElement result = atOffset;
if (atOffset instanceof ISourceReference) {
ISourceRange range = ((ISourceReference) atOffset).getSourceRange();
while (range.getOffset() + range.getLength() < selectionEnd) {
result = result.getParent();
if (!(result instanceof ISourceReference)) {
result = input;
break;
}
range = ((ISourceReference) result).getSourceRange();
}
}
return result;
}
}
/**
* Shows a dialog for resolving an ambiguous Java element. Utility method that can be called by subclasses.
*
* @param elements the elements to select from
* @param shell the parent shell
* @param title the title of the selection dialog
* @param message the message of the selection dialog
* @return returns the selected element or <code>null</code> if the dialog has been cancelled
*/
public static IJavaElement selectJavaElement(IJavaElement[] elements, Shell shell, String title, String message) {
int nResults = elements.length;
if (nResults == 0)
return null;
if (nResults == 1)
return elements[0];
int flags = JavaElementLabelProvider.SHOW_DEFAULT | JavaElementLabelProvider.SHOW_QUALIFIED | JavaElementLabelProvider.SHOW_ROOT;
ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new JavaElementLabelProvider(flags));
dialog.setTitle(title);
dialog.setMessage(message);
dialog.setElements(elements);
if (dialog.open() == Window.OK) {
return (IJavaElement) dialog.getFirstResult();
}
return null;
}
}
| [
"[email protected]"
] | |
25474773359b0bf77d2027ef0623ed6e2d6df7f7 | 474cfcca46dab822e6c12f801cf5b78a15fd3d5a | /src/com/typeinformation/Person.java | 6efd80ea3fb6ba87815c4c16e2c8eed5c50e3c97 | [] | no_license | NaveenRaj88/ThinkJava | ae349b4c1dc4e9192af7d2a382082cd528fcb142 | f57657bb48e3136032a0595af25762a8f96d8179 | refs/heads/master | 2021-01-22T12:44:54.588009 | 2016-05-02T04:59:55 | 2016-05-02T04:59:55 | 48,285,623 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 120 | java | package com.typeinformation;
public class Person extends Individual {
public Person(String name) {
super(name);
}
} | [
"[email protected]"
] | |
58f7d825d8edb62df1f74ffc794c3341407b6cde | b03e000224095ddc8adb3b7ae252305b336d521b | /solutions/src/linkedList/CopyRandomList138.java | eeb7288c36849e8ac3c3a007a42aebfc8e19ce9b | [] | no_license | KCHENPENGFEI/leetcode-practice | ea567321538ccdd7c4461228b24de274d9fc1232 | 39a467abc5a8fd3a333cf1776d5739e18bf561b2 | refs/heads/master | 2022-12-29T02:36:02.086337 | 2020-10-14T01:43:48 | 2020-10-14T01:43:48 | 275,133,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,473 | java | package linkedList;
import java.util.HashMap;
import java.util.Map;
/**
* 复制带随机指针的链表
*
* 给定一个链表,每个节点包含一个额外增加的随机指针,该指针可以指向链表中的任何节点或空节点。
*
* 要求返回这个链表的 深拷贝。
*
* 我们用一个由 n 个节点组成的链表来表示输入/输出中的链表。每个节点用一个 [val, random_index] 表示:
*
* val:一个表示 Node.val 的整数。
* random_index:随机指针指向的节点索引(范围从 0 到 n-1);如果不指向任何节点,则为 null 。
*
* */
public class CopyRandomList138 {
public Node copyRandomList(Node head) {
if (head == null) {
return null;
}
Node pointer = head;
// 存储哈希表,将原始Node和新建的Node对应保存
Map<Node, Node> map = new HashMap<>();
while (pointer != null) {
map.put(pointer, new Node(pointer.val));
pointer = pointer.next;
}
pointer = head;
while (pointer != null) {
// 前半句是新建的node(当前pointer)的next指针,后半句是新建的node(下一个pointer)的next指针
map.get(pointer).next = map.get(pointer.next);
map.get(pointer).random = map.get(pointer.random);
pointer = pointer.next;
}
pointer = head;
return map.get(pointer);
}
}
| [
"[email protected]"
] | |
ca2e4b6c5e6dc0e19455a78611b6d010665a1861 | e588377a8982dd6bbc80c51934933c57d2f388ab | /src/main/java/com/vincentfazio/ui/survey/activity/CompanyDetailsSaveActivity.java | f18a1195ab17d542abff3951eeccd7f64668f7d2 | [] | no_license | fazdevils/gwt_prototype | fba529f71fe16ea9dcdad8083b4d09510ed108d9 | e046d640272a08a229b67ea2d96f1b3157b16859 | refs/heads/master | 2020-05-16T20:35:09.467583 | 2013-10-25T14:06:31 | 2013-10-25T14:06:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,109 | java | package com.vincentfazio.ui.survey.activity;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.vincentfazio.ui.activity.GwtActivity;
import com.vincentfazio.ui.bean.ErrorBean;
import com.vincentfazio.ui.bean.StatusBean;
import com.vincentfazio.ui.bean.CompanyDetailsBean;
import com.vincentfazio.ui.global.GwtGlobals;
import com.vincentfazio.ui.model.CompanyDetailsModel;
import com.vincentfazio.ui.survey.view.CompanyDetailsDisplay;
import com.vincentfazio.ui.view.ErrorDisplay;
import com.vincentfazio.ui.view.StatusDisplay;
public class CompanyDetailsSaveActivity extends GwtActivity {
private GwtGlobals globals;
private CompanyDetailsBean companyDetails;
public CompanyDetailsSaveActivity(GwtGlobals gwtGlobals, CompanyDetailsBean companyDetails) {
this.globals = gwtGlobals;
this.companyDetails = companyDetails;
}
@Override
public void start(AcceptsOneWidget panel, EventBus eventBus) {
CompanyDetailsModel model = (CompanyDetailsModel) globals.getModel(CompanyDetailsModel.class);
model.saveCompany(companyDetails,
new AsyncCallback<String>() {
public void onSuccess(String result) {
StatusDisplay statusDisplay = globals.getStatusDisplay();
statusDisplay.handleStatusUpdate(new StatusBean("Company Changes Saved"));
CompanyDetailsDisplay detailsDisplay = (CompanyDetailsDisplay) globals.getDisplay(CompanyDetailsDisplay.class);
detailsDisplay.setHasUnsavedChanges(false);
}
public void onFailure(Throwable caught) {
ErrorDisplay errorDisplay = globals.getErrorDisplay();
errorDisplay.handleError(new ErrorBean(caught.getMessage(), caught));
}
}
);
}
}
| [
"[email protected]"
] | |
e89d53daf50abcc1982734c8ce7f126c8d46b19d | 54409512544118c8113c3f6a8520dcd54adf3479 | /Reservation-app/src/main/java/ma/youcode/reservation/Services/TypeReservationService.java | 9d95b9074b2a7d26e8be66626c4a2f84ea409d1f | [] | no_license | kamal1-cloud/Application-Reservation-de-place | 548688faf055ded823ebd10d5f4bb719b416b7d8 | 1dd09b544f9d9154d7222af6f4e01271d2845138 | refs/heads/main | 2023-03-26T05:41:46.933514 | 2021-03-31T11:36:01 | 2021-03-31T11:36:01 | 345,319,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 773 | java | package ma.youcode.reservation.Services;
import ma.youcode.reservation.Repositories.TypeReservationRepository;
import ma.youcode.reservation.Models.TypereservationEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class TypeReservationService {
@Autowired
private TypeReservationRepository typeReservationRepository;
public void saveType(TypereservationEntity typereservationEntity) {
typeReservationRepository.save(typereservationEntity);
}
public void deleteType(Integer id) {
typeReservationRepository.deleteById(id);
}
public TypereservationEntity get(Integer id) {
return typeReservationRepository.findById(id).get();
}
}
| [
"[email protected]"
] | |
9b9106ae660af0177e021efffba218a9ac380286 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-13407-3-28-FEMO-WeightedSum:TestLen:CallDiversity/com/xpn/xwiki/store/XWikiCacheStore_ESTest.java | 7948f70e8422f1a006d8ace7c9fd1386a46d529a | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 556 | java | /*
* This file was automatically generated by EvoSuite
* Sun Apr 05 00:31:26 UTC 2020
*/
package com.xpn.xwiki.store;
import org.junit.Test;
import static org.junit.Assert.*;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class XWikiCacheStore_ESTest extends XWikiCacheStore_ESTest_scaffolding {
@Test
public void notGeneratedAnyTest() {
// EvoSuite did not generate any tests
}
}
| [
"[email protected]"
] | |
5fb79d56e887cb6268e7b964f6f2e2ce116a50f7 | 6f55435739d7dceb289e16dc86dbec56bbb2b3c7 | /src/main/java/edu/bu/met/cs665/CustomerOverHttps.java | 4af7705b5143202107e6ba240c730f2227db542b | [
"Apache-2.0"
] | permissive | alina-akram/Data-Conversion-Application-Java | 8f815c82911f043ae033867a5a6aa3e1119cc9d7 | 373a3c5abad32d9afa7348c0d307ab83270e2637 | refs/heads/master | 2022-12-28T15:28:08.880158 | 2020-08-04T03:38:20 | 2020-08-04T03:38:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | /**
* Alina Akram
* Course CS-665
* Summer 2
* Assignment #4
* Aug 3, 2020
*/
package edu.bu.met.cs665;
public class CustomerOverHttps implements CustomerDataOverHttps {
private CustomerDB httpsDB;
public CustomerOverHttps(CustomerDB h){
//constructor function
httpsDB = h; //initializing
}
@Override
public void printCustomer(CustomerId id) {
//Gets a customer based on ID and prints it
Customer toPrint = getCustomer_withHttps(id);
System.out.println(toPrint);
}
@Override
public Customer getCustomer_withHttps(CustomerId id) {
//DB method get old system customer based on id
Customer getHttps = httpsDB.getViaHttps(id);
return getHttps;
}
}
| [
"[email protected]"
] | |
a6ae3de84fea37f6cf12da76970fcd0c117b34f4 | 6ab3fef5c3af55f1e12301b17a0bd2f20eafe35f | /app/build/generated/source/buildConfig/androidTest/debug/com/espoir/broadcastrceiverdemo/test/BuildConfig.java | eb2feff2bc16da73baf734897e23ba07ba2a6d0f | [] | no_license | techespo/EspoSMSbroadcastReceiverSample | 761a506e2c026dec644d4387b4f8fb2a765787d2 | 5458eb8c70c04c9ab198865b1c7c437ec67a6491 | refs/heads/master | 2021-04-09T15:14:38.026194 | 2018-03-18T05:16:27 | 2018-03-18T05:16:27 | 125,694,439 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 477 | java | /**
* Automatically generated file. DO NOT MODIFY
*/
package com.espoir.broadcastrceiverdemo.test;
public final class BuildConfig {
public static final boolean DEBUG = Boolean.parseBoolean("true");
public static final String APPLICATION_ID = "com.espoir.broadcastrceiverdemo.test";
public static final String BUILD_TYPE = "debug";
public static final String FLAVOR = "";
public static final int VERSION_CODE = -1;
public static final String VERSION_NAME = "";
}
| [
"[email protected]"
] | |
6f34f69fff4352b88ab10ce5820a38f5e0581221 | e3b3a07496d67ad7e06cb61a84ab6bf54f114f20 | /satc-web/src/com/sat/sisat/coactiva/managed/RemateVehiculosManaged.java | e9131d1b2d1edfd3d22e0529c0a74c553cb81eb1 | [] | no_license | jelizvt/sisatc | 19ddea0112eb4a33bfa08db6ac56e4adfbc87df6 | ca0f8eb74feb3211c7b9cb586bbfa3952a966122 | refs/heads/master | 2022-12-07T21:20:34.181389 | 2020-08-19T15:30:32 | 2020-08-19T15:30:32 | 288,759,982 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,180 | java | package com.sat.sisat.coactiva.managed;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import com.sat.sisat.cobranzacoactiva.business.CobranzaCoactivaBoRemote;
import com.sat.sisat.common.util.BaseManaged;
import com.sat.sisat.common.util.Constante;
import com.sat.sisat.common.util.DateUtil;
import com.sat.sisat.common.util.FacesUtil;
import com.sat.sisat.exception.SisatException;
import com.sat.sisat.menus.business.MenuBoRemote;
import com.sat.sisat.menus.dto.SimpleMenuDTO;
import com.sat.sisat.papeletas.managed.BuscarPersonaPapeletasManaged;
import com.sat.sisat.persistence.entity.GnRemate;
import com.sat.sisat.vehicular.cns.ReusoFormCns;
import com.sat.sisat.vehicular.dto.BuscarPersonaDTO;
@ManagedBean
@ViewScoped
public class RemateVehiculosManaged extends BaseManaged {
/**
*
*/
private static final long serialVersionUID = 1L;
@EJB
CobranzaCoactivaBoRemote cobranzaCoactivaBo;
@EJB
MenuBoRemote menuBo;
private List<GnRemate> listRemate = new ArrayList<GnRemate>();
private GnRemate gnRemate = new GnRemate();
private Integer propietarioId;
private String placa;
private BigDecimal montoAdjudicado = null;
private java.util.Date fechaRemate;
private String sustento;
private BuscarPersonaDTO datosPropietario;
// INICIO PERMISOS PARA EL MODULO -=CRAMIREZ=-
private List<SimpleMenuDTO> listPermisosSubmenu = new ArrayList<SimpleMenuDTO>();
private boolean permisoAgregarRegistrar;
// FIN PERMISOS PARA EL MODULO
@PostConstruct
public void init() {
permisosMenu();
try {
listRemate = cobranzaCoactivaBo.getAllRemates();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void permisosMenu() {
try {
int submenuId = Constante.REMATE_DE_VEHICULOS;
int permisoAgregarRegistrarId = Constante.AGREGAR_REGISTRAR;
permisoAgregarRegistrar = false;
listPermisosSubmenu = menuBo.getAccesosSubmenuUsuario( getSessionManaged().getUsuarioLogIn().getUsuarioId() , submenuId);
Iterator<SimpleMenuDTO> menuIterar = listPermisosSubmenu.iterator();
while (menuIterar.hasNext()) {
SimpleMenuDTO lsm = menuIterar.next();
if(lsm.getItemId() == permisoAgregarRegistrarId) {
permisoAgregarRegistrar = true;
}
}
} catch (SisatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void nuevoRemate() {
setFechaRemate(null);
setMontoAdjudicado(null);
setPlaca(null);
setPropietarioId(null);
setSustento(null);
}
public boolean validarCampos() {
if (datosPropietario.getPersonaId() == 0) {
addErrorMessage(getMsg("Seleccione el Propietario. Click en Buscar."));
return false;
} else if (placa == null || placa.equals("")) {
addErrorMessage(getMsg("Ingrese Placa."));
return false;
} else if (montoAdjudicado == null) {
addErrorMessage(getMsg("Ingrese Monto Adjudicado."));
return false;
} else if (sustento == null) {
addErrorMessage(getMsg("Ingrese Sustento."));
return false;
} else if (fechaRemate == null) {
addErrorMessage(getMsg("Ingrese Fecha Remate."));
return false;
}
return true;
}
public void guardarRemates() {
try {
if (validarCampos()) {
gnRemate.setPropietarioId(datosPropietario.getPersonaId());
gnRemate.setPlaca(placa.toUpperCase());
gnRemate.setMontoAdjudicado(montoAdjudicado);
gnRemate.setFechaRemate(DateUtil
.dateToSqlTimestamp(getFechaRemate()));
gnRemate.setSustento(sustento);
gnRemate.setFechaRegistro(DateUtil.dateToSqlTimestamp(Calendar
.getInstance().getTime()));
cobranzaCoactivaBo.guardarRemate(gnRemate);
listRemate = cobranzaCoactivaBo.getAllRemates();
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setPersonaAsociadaConPapeleta() {
String destinoRefresh = FacesUtil.getRequestParameter("destinoRefresh");
BuscarPersonaPapeletasManaged buscarPersonaManaged = (BuscarPersonaPapeletasManaged) getManaged("buscarPersonaPapeletasManaged");
buscarPersonaManaged
.setPantallaUso(ReusoFormCns.BUSQU_PER_REMATE_VEHICULO);
buscarPersonaManaged.setDestinoRefresh(destinoRefresh);
}
public void copiaPersona(BuscarPersonaDTO persona) {
setDatosPropietario(persona);
}
public GnRemate getGnRemate() {
return gnRemate;
}
public void setGnRemate(GnRemate gnRemate) {
this.gnRemate = gnRemate;
}
public List<GnRemate> getListRemate() {
return listRemate;
}
public void setListRemate(List<GnRemate> listRemate) {
this.listRemate = listRemate;
}
public Integer getPropietarioId() {
return propietarioId;
}
public void setPropietarioId(Integer propietarioId) {
this.propietarioId = propietarioId;
}
public String getPlaca() {
return placa;
}
public void setPlaca(String placa) {
this.placa = placa;
}
public String getSustento() {
return sustento;
}
public void setSustento(String sustento) {
this.sustento = sustento;
}
public BigDecimal getMontoAdjudicado() {
return montoAdjudicado;
}
public void setMontoAdjudicado(BigDecimal montoAdjudicado) {
this.montoAdjudicado = montoAdjudicado;
}
public java.util.Date getFechaRemate() {
return fechaRemate;
}
public void setFechaRemate(java.util.Date fechaRemate) {
this.fechaRemate = fechaRemate;
}
public BuscarPersonaDTO getDatosPropietario() {
return datosPropietario;
}
public void setDatosPropietario(BuscarPersonaDTO datosPropietario) {
this.datosPropietario = datosPropietario;
}
public List<SimpleMenuDTO> getListPermisosSubmenu() {
return listPermisosSubmenu;
}
public void setListPermisosSubmenu(List<SimpleMenuDTO> listPermisosSubmenu) {
this.listPermisosSubmenu = listPermisosSubmenu;
}
public boolean isPermisoAgregarRegistrar() {
return permisoAgregarRegistrar;
}
public void setPermisoAgregarRegistrar(boolean permisoAgregarRegistrar) {
this.permisoAgregarRegistrar = permisoAgregarRegistrar;
}
}
| [
"[email protected]"
] | |
0964ad60a45835b941660f1408c13f4859a2f026 | c28787675af798c5cca3e0ddddd16d48578daffd | /app/src/main/java/com/nazmul/fbreader2/MainActivity.java | ad9697839c9d2bda5e036035f9e2ce291fc6a38b | [] | no_license | nazmulcse/Android-FBReader-SDK-Integration | 222f0b3e263a61c4095cbcda7d067ab0f4cfa8c8 | 3c49a841ee665bbbb662a6776a922c3c2a51bedb | refs/heads/master | 2023-08-26T10:31:36.420534 | 2021-11-13T16:51:34 | 2021-11-13T16:51:34 | 427,721,287 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,071 | java | package com.nazmul.fbreader2;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.Manifest;
import android.annotation.TargetApi;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private RecyclerView rvFiles;
private List<BookFile> bookFiles;
private static final int REQUEST_PERMISSION = 101;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rvFiles = findViewById(R.id.rv_files);
rvFiles.setLayoutManager(new LinearLayoutManager(this));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
checkPermission();
} else {
generateList();
}
rvFiles.setAdapter(new BooksAdapter(bookFiles, new BooksAdapter.BookListener() {
@Override public void onBookOpen(BookFile bookFile) {
Intent intent = new Intent(MainActivity.this, ReaderActivity.class);
intent.putExtra(ReaderActivity.EXTRA_PATH, bookFile.getPath());
startActivity(intent);
}
}));
}
@TargetApi(Build.VERSION_CODES.M) private void checkPermission() {
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
== PackageManager.PERMISSION_GRANTED) {
generateList();
} else {
ActivityCompat.requestPermissions(this,
new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, REQUEST_PERMISSION);
}
}
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
switch (requestCode) {
case REQUEST_PERMISSION: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
generateList();
}
break;
}
}
}
private void generateList() {
List<String> paths = new ArrayList<>();
String path = Environment.getExternalStorageDirectory().getAbsolutePath();
paths.add(path);
ListFilesTask listFilesTask = new ListFilesTask(paths);
listFilesTask.setListener(new ListFilesTask.ListFilesListener() {
@Override public void onTaskCompleted(List<File> files) {
if (!isFinishing()) {
bookFiles = new ArrayList<>();
for (File f : files) {
BookFile bookFile = new BookFile(f.getName(), f.getAbsolutePath());
if (!bookFiles.contains(bookFile)) bookFiles.add(bookFile);
}
Collections.sort(bookFiles, new Comparator<BookFile>() {
@Override public int compare(BookFile bookFile, BookFile t1) {
return bookFile.getFilename().compareToIgnoreCase(t1.getFilename());
}
});
rvFiles.setAdapter(new BooksAdapter(bookFiles, new BooksAdapter.BookListener() {
@Override public void onBookOpen(BookFile bookFile) {
}
}));
}
}
});
listFilesTask.execute();
}
static class ListFilesTask extends AsyncTask<Void, Void, List<File>> {
public interface ListFilesListener {
void onTaskCompleted(List<File> files);
}
private ListFilesListener listener;
private List<String> startPaths;
private List<File> files;
private boolean completed;
public ListFilesTask(List<String> startPaths) {
this.startPaths = new ArrayList<>(startPaths);
this.files = new ArrayList<>();
this.completed = false;
}
public void setListener(ListFilesListener listener) {
this.listener = listener;
if (completed && listener != null && files != null) {
listener.onTaskCompleted(files);
}
}
@Override protected List<File> doInBackground(Void... voids) {
List<File> fileList = new ArrayList<>();
for (String s : startPaths) {
searchFiles(fileList, new File(s));
}
return fileList;
}
@Override protected void onPostExecute(List<File> files) {
completed = true;
if (listener != null) {
listener.onTaskCompleted(files);
} else {
this.files = new ArrayList<>(files);
}
}
private void searchFiles(List<File> list, File dir) {
String epubPattern = ".epub";
String fb2Pattern = ".fb2";
File[] listFiles = dir.listFiles();
if (listFiles != null) {
for (File listFile : listFiles) {
if (listFile.isDirectory()) {
searchFiles(list, listFile);
} else {
if (listFile.getName().endsWith(epubPattern) || listFile.getName()
.endsWith(fb2Pattern)) {
list.add(listFile);
}
}
}
}
}
}
} | [
"[email protected]"
] | |
51268a8b36e3eb392f322213b245b2acfe27f6ec | bf033274ab2075dd10b27faa947a00966e4c41b6 | /Hausaufgaben/2021_01_12/src/Zeit.java | 174b8b62900255d1bc21288e71b6864cac2786f0 | [] | no_license | milantheiss/schule-1-2020-21 | 7c559ec8c54a43b89fdb506df170fca4124963a6 | f7902a3e164254cbc5d2a92036fc83add7e61065 | refs/heads/master | 2023-03-17T12:24:42.884460 | 2021-03-06T19:16:52 | 2021-03-06T19:16:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 42 | java | public class Zeit {
public int sec;
}
| [
"[email protected]"
] | |
4fc1faac263a74026c3570ee15abb096e62d5ddb | b521765a8aa9c017f74854e41e8a60552569fcc7 | /src/main/java/com/kmarzecki/communicator/model/friends/FriendshipResponse.java | 45b87599715a8eaec5076dfbf096bd41375cebfa | [] | no_license | kacper-marzecki/Communicator | df76dc84ce938f7f12015cad6ff6b6581a71bc3b | 6acb6d90cb6b3e866474f90ea926115b76315d26 | refs/heads/master | 2021-03-07T02:59:44.696738 | 2020-03-28T18:21:00 | 2020-03-28T18:21:00 | 246,241,797 | 1 | 0 | null | 2020-03-27T20:37:07 | 2020-03-10T08:05:19 | HTML | UTF-8 | Java | false | false | 608 | java | package com.kmarzecki.communicator.model.friends;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Value;
/**
* Response containing data about a friendship connection between users
*/
@Value
@AllArgsConstructor
@Builder
public class FriendshipResponse {
/**
* Friendship id
*/
Integer id;
/**
* User that initiated the friendship
*/
String requester;
/**
* The second user in the friendship
*/
String target;
/**
* Flag indicating that this friendship is one sided, and not yet confirmed
*/
boolean pending;
}
| [
"[email protected]"
] | |
c1cb4f1f8d545d53a020dd95d86f8106793d760d | d8916c1f7fd994dc8de9b5ac2613a96e5fbd60b4 | /node_modules/react-native-maps/android/src/main/java/com/AirMaps/AirMapFeature.java | 48c245098590e3aac45f3c803b7fa8ec27262672 | [
"MIT"
] | permissive | dingxizheng/sns-based-promotion-react-native | f5f9444ed234ecacf34864ca1d270440f43f8e4c | ef7196edbcaaac6c195f8640e05fabd222422c24 | refs/heads/master | 2020-04-09T04:20:24.247384 | 2016-05-02T18:17:39 | 2016-05-02T18:17:39 | 50,269,298 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 425 | java | package com.AirMaps;
import com.facebook.react.views.view.ReactViewGroup;
import com.google.android.gms.maps.GoogleMap;
import android.content.Context;
public abstract class AirMapFeature extends ReactViewGroup {
public AirMapFeature(Context context) { super(context); }
public abstract void addToMap(GoogleMap map);
public abstract void removeFromMap(GoogleMap map);
public abstract Object getFeature();
}
| [
"[email protected]"
] | |
84a396ba1150fd97f09c24e3d8eef03db8debafc | 05ccb7dfe802b259989328d8178a21349abfc9ca | /src/main/java/ua/goit/controller/projects/EnterNameServlet.java | bc637ffe1216d407bed753545f9198471dabfaa8 | [] | no_license | korolov-vv/ProjectManagementSystem | a8f971377f53544aefd484e48b27c381d53a1ed5 | 5785d98402f2c67fdb627507c45abc79824f7ef1 | refs/heads/master | 2023-06-27T20:24:47.523768 | 2021-07-27T01:22:12 | 2021-07-27T01:22:12 | 372,325,072 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 590 | java | package ua.goit.controller.projects;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/projects/enterName")
public class EnterNameServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
req.getRequestDispatcher("/view/projects/enterName.jsp").forward(req, resp);
}
}
| [
"[email protected]"
] | |
af3759e256f7a1de52374631c43072f410f9b50f | 552fb1a6b648829ebad3d8844c71f12ca503fbfc | /ihmc-avatar-interfaces/src/main/java/us/ihmc/avatar/posePlayback/PlaybackPoseSequenceReader.java | 547909fa6cfeb9c170e6fffeff8d7a30919a8884 | [
"Apache-2.0"
] | permissive | ihmcroboticsdocs/ihmc-open-robotics-software | 2c9ec35290e3d0a2fddd9f1bd32e2099edbbd85a | 1069551ff5bedf192081b6660528f74283cb25b2 | refs/heads/master | 2020-03-21T16:17:18.522806 | 2018-07-31T19:54:35 | 2018-07-31T19:54:35 | 138,761,699 | 0 | 0 | null | 2018-06-26T16:03:42 | 2018-06-26T16:03:42 | null | UTF-8 | Java | false | false | 4,574 | java | package us.ihmc.avatar.posePlayback;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.util.ArrayList;
import us.ihmc.robotModels.FullRobotModel;
import us.ihmc.robotics.screwTheory.InverseDynamicsJoint;
import us.ihmc.robotics.screwTheory.OneDoFJoint;
import us.ihmc.robotics.screwTheory.ScrewTools;
public class PlaybackPoseSequenceReader
{
public static void appendFromFile(PlaybackPoseSequence posePlaybackRobotPoseSequence, String fileName)
{
String fullFileName = PlaybackPoseSequenceWriter.directory + fileName;
File file = new File(fullFileName);
appendFromFile(posePlaybackRobotPoseSequence, file);
}
public static void appendFromFile(PlaybackPoseSequence posePlaybackRobotPoseSequence, InputStream selectedFile)
{
appendFromFile(posePlaybackRobotPoseSequence, new InputStreamReader(selectedFile));
}
public static void appendFromFile(PlaybackPoseSequence posePlaybackRobotPoseSequence, File selectedFile)
{
try
{
FileReader fr = new FileReader(selectedFile);
appendFromFile(posePlaybackRobotPoseSequence, fr);
fr.close();
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public static void appendFromFile(PlaybackPoseSequence posePlaybackRobotPoseSequence, Reader reader)
{
FullRobotModel fullRobotModel = posePlaybackRobotPoseSequence.getFullRobotModel();
try
{
BufferedReader br = new BufferedReader(reader);
String jointNamesOnOneLine = br.readLine();
String[] jointNamesArray = jointNamesOnOneLine.split("\\s+");
ArrayList<String> jointNames = new ArrayList<String>();
for (int i = 0; i < jointNamesArray.length; i++)
{
jointNames.add(jointNamesArray[i]);
}
if (!jointNames.get(0).equals("delayBeforePose"))
throw new RuntimeException("Expecting delayBeforePose on first line. Got " + jointNames.get(0));
jointNames.remove(0);
if (!jointNames.get(0).equals("poseDuration"))
throw new RuntimeException("Expecting poseDuration on first line. Got " + jointNames.get(0));
jointNames.remove(0);
OneDoFJoint[] allJoints = fullRobotModel.getOneDoFJoints();
jointNamesArray = new String[jointNames.size()];
jointNames.toArray(jointNamesArray);
InverseDynamicsJoint[] inverseDynamicsJoints = ScrewTools.findJointsWithNames(allJoints, jointNamesArray);
OneDoFJoint[] oneDoFJoints = ScrewTools.filterJoints(inverseDynamicsJoints, OneDoFJoint.class);
double[] jointAngles = new double[oneDoFJoints.length];
String textPose = br.readLine(); // read one line of text (one pose)
while (textPose != null) // check for end of file
{
String[] poseData = textPose.split("\\s+"); // separate each piece of data in one line
PlaybackPose robotPose;
if (oneDoFJoints.length + 2 != poseData.length)
throw new RuntimeException("oneDoFJoints.length + 2 != poseData.length");
double delay = Double.parseDouble(poseData[0]);
double duration = Double.parseDouble(poseData[1]);
for (int i = 0; i < oneDoFJoints.length; i++)
{
jointAngles[i] = Double.parseDouble(poseData[i + 2]);
}
robotPose = new PlaybackPose(oneDoFJoints, jointAngles, delay, duration);
posePlaybackRobotPoseSequence.addPose(robotPose);
textPose = br.readLine(); // read next pose
}
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static PlaybackPoseSequence readFromFile(FullRobotModel fullRobotModel, String fileName)
{
PlaybackPoseSequence ret = new PlaybackPoseSequence(fullRobotModel);
appendFromFile(ret, fileName);
return ret;
}
public static PlaybackPoseSequence readFromInputStream(FullRobotModel fullRobotModel, InputStream inputStream)
{
PlaybackPoseSequence ret = new PlaybackPoseSequence(fullRobotModel);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
appendFromFile(ret, inputStreamReader);
return ret;
}
}
| [
"[email protected]"
] | |
e082fa22c5e78fba331e14bf9b3ce1db22379f2d | d1ea5077c83cb2e93fe69e3d19a2e26efe894a0e | /src/main/java/com/rograndec/feijiayun/chain/common/constant/ModeOperation.java | 430dae30c4fe697bdac8c1cce43a78aba0e93504 | [] | no_license | Catfeeds/rog-backend | e89da5a3bf184e4636169e7492a97dfd0deef2a1 | 109670cfec6cbe326b751e93e49811f07045e531 | refs/heads/master | 2020-04-05T17:36:50.097728 | 2018-10-22T16:23:55 | 2018-10-22T16:23:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,108 | java | package com.rograndec.feijiayun.chain.common.constant;
/**
* 经营方式常量
* @ClassName: ModeOperation
* @Description: TODO(描述该类做什么)
* @author liuqun
* @version 1.0
* @date 2017年8月22日 下午4:29:22
*/
public enum ModeOperation {
PERSONAL_BUSINESS(0, "个人独自经营"),
PARTNERSHIP_BUSINESS(1, "合伙经营"),
LIMITED_LIABILITY_COMPANY(2, "有限责任公司"),
SHARE_LIMITED_LIABILITY_COMPANY(3, "股份有限责任公司");
private int code;
private String name;
private ModeOperation(int code, String name) {
this.code = code;
this.name = name;
}
public int getCode() {
return code;
}
public void setType(int code) {
this.code = code;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public static String getName(int code) {
for (ModeOperation c : ModeOperation.values()) {
if (c.getCode() == code) {
return c.getName();
}
}
return null;
}
}
| [
"[email protected]"
] |
Subsets and Splits