blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 332 | content_id stringlengths 40 40 | detected_licenses listlengths 0 50 | license_type stringclasses 2
values | repo_name stringlengths 7 115 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringclasses 557
values | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 77.7k | fork_events_count int64 0 48k | gha_license_id stringclasses 17
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 82
values | src_encoding stringclasses 28
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 7 5.41M | extension stringclasses 11
values | content stringlengths 7 5.41M | authors listlengths 1 1 | author stringlengths 0 161 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
aba58aeef32270b158e3f9fcfafd2a3b68bc6397 | 8be4f581a5006022bcae73d6c54b829f8b94bfaa | /src/main/java/com/epamtraining/dao/implementations/Query.java | 25b928680cbd3dc3435dde27ee536dbcb069a6c3 | [] | no_license | ObsidianSky/electives-system | c1a43337a94e6bf74c7cb9d56559f792c049a9a6 | 411ae18bb9c0354b1e8a98fe2b6090d6773de1e1 | refs/heads/master | 2021-01-11T20:11:57.897034 | 2017-01-15T22:17:22 | 2017-01-15T22:17:22 | 79,062,945 | 0 | 1 | null | 2017-01-15T22:11:38 | 2017-01-15T22:11:38 | null | UTF-8 | Java | false | false | 701 | java | package com.epamtraining.dao.implementations;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
/**
* @autor Sergey Bondarenko
*/
public final class Query {
public Query() {
}
static void close(ResultSet resultSet, Statement statement, Connection connection) {
try {
if (resultSet != null) {
resultSet.close();
}
if (statement != null) {
statement.close();
}
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
| [
"qopy@i.ua"
] | qopy@i.ua |
b4a5b1fd5e8b912748893a3dc3aa8607de4ad851 | 99644509c958775f6f4ec3382e576c4157229a0b | /src/test/java/MyTest.java | 27f9c7d1e6eb9cdd19c153740e10c2df21d3384c | [] | no_license | rusuo/apiTest | 6dc2bd2df4864461b89d66b320df082371482751 | 621ceeb951c85cefd25e3c506fea7caa2bbf0486 | refs/heads/master | 2021-07-10T08:07:59.965936 | 2019-08-27T20:19:56 | 2019-08-27T20:19:56 | 204,768,560 | 0 | 0 | null | 2020-10-13T15:37:41 | 2019-08-27T18:47:34 | Java | UTF-8 | Java | false | false | 2,185 | java | import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.junit.Test;
import static io.restassured.RestAssured.given;
public class MyTest {
private static String payload = "{\"isbn\":\"11111\",\"title\":\"automation\",\"author\":{\"firstname\":\"oana\",\"lastname\":\"rusu\"}}";
private static String emptyPayload = "{}";
private static String incorrectPayload = "{\"description\":\"wrong\",\"title\":\"this is not correct\"}";
@Test
public void test_verifyPostRequestCorrectPayload() {
RestAssured.baseURI = "https://glacial-chamber-83122.herokuapp.com";
given()
.contentType(ContentType.JSON)
.body(payload)
.post("/api/books")
.then()
.statusCode(200);
}
@Test
public void test_verifyPostRequestIncorrectPayload() {
RestAssured.baseURI = "https://glacial-chamber-83122.herokuapp.com";
given()
.contentType(ContentType.JSON)
.body(incorrectPayload)
.post("/api/books")
.then()
.statusCode(200);
}
@Test
public void test_verifyPostRequestEmptyPayload() {
RestAssured.baseURI = "https://glacial-chamber-83122.herokuapp.com";
given()
.contentType(ContentType.JSON)
.body(emptyPayload)
.post("/api/books")
.then()
.statusCode(200);
}
@Test
public void test_verifyPostRequestWrongContentType() {
RestAssured.baseURI = "https://glacial-chamber-83122.herokuapp.com";
given()
.contentType(ContentType.TEXT)
.body(payload)
.post("/api/books")
.then()
.statusCode(200);
}
@Test
public void test_verifyPostRequestIncorrectEndpoint() {
RestAssured.baseURI = "https://glacial-chamber-83122.herokuapp.com";
given()
.contentType(ContentType.JSON)
.body(payload)
.post("/api/book")
.then()
.statusCode(404);
}
} | [
"oana.rusu.qa@gmail.com"
] | oana.rusu.qa@gmail.com |
2ef1d6dceb493f8d476dcb38541ddf70947a26ba | ea2c8b6372d9f92a2413c5a5b9c870d716cc4454 | /Java_33_Method/src/com/biz/classes/service/parents/Animal.java | ef940802b500e023523b8016e710ebd97e74b0cf | [] | no_license | jeongseongjong/Java | a94a06658d163238b0a677f038a9d011936dd5ae | 000cba06496ba9256371446f864906f3dd7e7e7f | refs/heads/master | 2020-07-18T14:12:57.284921 | 2019-10-22T13:26:35 | 2019-10-22T13:26:35 | 206,259,780 | 3 | 2 | null | null | null | null | UTF-8 | Java | false | false | 197 | java | package com.biz.classes.service.parents;
public class Animal {
protected String name;
public Animal() {
this.name = "동물의 왕";
}
public String getName() {
return this.name;
}
}
| [
"jjong9950@naver.com"
] | jjong9950@naver.com |
3a37fa9e72cc5f0e355c9c8cf92d3d9c66977ab5 | 758553470c04f5e5760b812635c38a891c50cf71 | /lib/src/main/java/me/zlv/utils/StringUtils.java | 7303c974a2416a692017d242927f22649c4a0ad1 | [
"MIT"
] | permissive | alvminvm/utils | 70df80291a586efca95b685e08235071cc294b04 | f44ac72512e2873bc1051e53ad382dd75bc1d01e | refs/heads/master | 2021-06-18T01:02:32.370858 | 2017-05-14T08:01:21 | 2017-05-14T08:01:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 391 | java | package me.zlv.utils;
import android.text.TextUtils;
/**
* 字符串工具类
* Created by jeremyhe on 2017/5/6.
*/
public class StringUtils {
private StringUtils() {
// do nothing
}
public static boolean isEmpty(String s) {
return TextUtils.isEmpty(s);
}
public static boolean isNotEmpty(String s) {
return !TextUtils.isEmpty(s);
}
}
| [
"hezhenlv@maimairen.com"
] | hezhenlv@maimairen.com |
9d7a612a91d9ec2f3f7714195646dfa10357a67c | 5573f3619f8a22f76bb761e7989f54826a0a79d6 | /src/main/java/com/chatbot/web/test/LegacySerializer.java | 8c70eaf748ae16418163259568ec62e02f55d1d4 | [] | no_license | aluaaw/chatbot | 42ad166dbd1beeb65219749c18d5eb08cf96cbe9 | 244b08fe2a9c284c8bcbbe1d5ee243f5b46333d8 | refs/heads/master | 2022-12-10T02:23:12.653067 | 2020-09-06T21:38:36 | 2020-09-06T21:38:36 | 267,743,368 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,283 | java | /*
package com.chatbot.web.test;
import com.chatbot.web.domains.Chat;
import com.chatbot.web.domains.ChatHistory;
import com.chatbot.web.domains.Exam;
import com.chatbot.web.mappers.ChatHistoryMapper;
import com.chatbot.web.mappers.ChatMapper;
import com.chatbot.web.mappers.ExamMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;
@Service
public class LegacySerializer {
@Autowired Chat chat;
@Autowired ChatHistory chatHistory;
@Autowired Exam exam;
@Autowired ChatMapper chatMapper;
@Autowired ChatHistoryMapper chatHistoryMapper;
@Autowired ExamMapper examMapper;
private JSONObject obj, arrObj, innerObj, middleObj, outsideObj, mostInnerObj, mostInnerObj1, getMostInnerObj2,
innerObj1, innerObj2, innerObj3, innerObj4, innerObj5, innerObj6, innerObj7, innerObj8, innerObj9;
private JSONArray arr, arr1, arr2;
private ObjectMapper mapper;
private JSONParser parser;
public Map<String, Object> commonSer(Map<String, Object> jsonParams) throws JsonProcessingException {
mapper = new ObjectMapper();
String jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonParams);
parser = new JSONParser();
SimpleDateFormat sDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
obj = new JSONObject();
arrObj = new JSONObject();
arr = new JSONArray();
innerObj = new JSONObject();
mostInnerObj = new JSONObject();
try {
JSONObject objJson = (JSONObject) parser.parse(jsonStr);
//userInfo
JSONObject userRequest = (JSONObject) objJson.get("userRequest");
String chatBody = (String) userRequest.get("utterance");
String userInfo = userRequest.toString();
//block name
JSONObject action = (JSONObject) objJson.get("action");
String block = (String) action.get("name");
//date
String uDate = sDate.format(new Date()); //날짜 지정
Date toDate = sDate.parse(uDate);
chat.setChatBody(chatBody);
System.out.println(block);
//fomat
if(block.contains("start")){
}else if(block.contains("exit")){
}
//insert, update 조건문
chatMapper.insertData(chat);
chatHistory.setChatId(chat.getId());
System.out.println(chat.getId());
chatHistory.setChatKind("C");
chatHistory.setUserInfo(userInfo);
chatHistory.setChatBody(chatBody);
chatHistoryMapper.insertData(chatHistory);
mostInnerObj.put("text", "챗봇이 종료됩니다. 감사합니다.");
innerObj.put("simpleText", mostInnerObj);
arr.add(innerObj);
arrObj.put("outputs", arr);
obj.put("template", arrObj);
obj.put("version", "2.0");
} catch (Exception e) {
e.printStackTrace();
}
return obj;
}
public Map<String, Object> subjectCodeSer() throws JsonProcessingException {
obj = new JSONObject();
arrObj = new JSONObject();
arr = new JSONArray();
innerObj = new JSONObject();
mostInnerObj = new JSONObject();
arr1 = new JSONArray();
arrObj = new JSONObject();
innerObj1 = new JSONObject();
innerObj2 = new JSONObject();
innerObj3 = new JSONObject();
innerObj4 = new JSONObject();
innerObj5 = new JSONObject();
innerObj6 = new JSONObject();
innerObj7 = new JSONObject();
innerObj8 = new JSONObject();
innerObj9 = new JSONObject();
mostInnerObj1 = new JSONObject(); //block
// for(int i=0; i < 8; ++i) {
// innerObj1.put("action", "message");
// innerObj1.put("label", subjects);
// innerObj1.put("messageText", subjects);
// arr1.add(innerObj1);
// }
innerObj1.put("action", "message");
innerObj1.put("label", "국어");
innerObj1.put("messageText", "국어");
arr1.add(innerObj1);
innerObj2.put("action", "message");
innerObj2.put("label", "영어");
innerObj2.put("messageText", "영어");
arr1.add(innerObj2);
innerObj3.put("action", "message");
innerObj3.put("label", "수학");
innerObj3.put("messageText", "수학");
arr1.add(innerObj3);
innerObj4.put("action", "message");
innerObj4.put("label", "생활과 윤리");
innerObj4.put("messageText", "생활과 윤리");
arr1.add(innerObj4);
innerObj5.put("action", "message");
innerObj5.put("label", "지리");
innerObj5.put("messageText", "지리");
arr1.add(innerObj5);
innerObj6.put("action", "message");
innerObj6.put("label", "경제");
innerObj6.put("messageText", "경제");
arr1.add(innerObj6);
innerObj7.put("action", "message");
innerObj7.put("label", "물리");
innerObj7.put("messageText", "물리");
arr1.add(innerObj7);
innerObj8.put("action", "message");
innerObj8.put("label", "생명과학");
innerObj8.put("messageText", "생명과학");
arr1.add(innerObj8);
innerObj9.put("action", "message");
innerObj9.put("label", "지구과학");
innerObj9.put("messageText", "지구과학");
arr1.add(innerObj9);
arrObj.put("quickReplies", arr1);
mostInnerObj.put("text", "과목명을 선택해주세요.");
innerObj.put("simpleText", mostInnerObj);
arr.add(innerObj);
arrObj.put("outputs", arr);
obj.put("template", arrObj);
obj.put("version", "2.0");
chatHistory.setChatKind("B");
chatHistory.setChatBody("과목명을 선택해주세요.");
chatHistoryMapper.insertData(chatHistory);
return obj;
}
public Map<String, Object> examAnalysisSer() {
obj = new JSONObject();
arrObj = new JSONObject();
arr = new JSONArray();
outsideObj = new JSONObject();
middleObj = new JSONObject();
innerObj = new JSONObject();
mostInnerObj = new JSONObject();
getMostInnerObj2 = new JSONObject();
arr1 = new JSONArray();
arr2 = new JSONArray();
innerObj1 = new JSONObject();
mostInnerObj1 = new JSONObject();
obj.put("version", "2.0");
obj.put("template", arrObj);
arrObj.put("outputs", arr);
arr.add(outsideObj);
outsideObj.put("carousel", middleObj);
middleObj.put("type", "basicCard");
middleObj.put("items", arr1);
arr1.add(innerObj);
innerObj.put("title", "[시험문제 번호]\n[시험문제 질문]");
innerObj.put("description", "정답: [시험문제 정답]\n선택한 답: [오답]\n[시험문제 내용]");
innerObj.put("thumbnail", mostInnerObj);
mostInnerObj.put("imageUrl", "https://cdn.pixabay.com/photo/2014/06/03/19/38/road-sign-361513_1280.jpg");
innerObj.put("buttons", arr2);
arr2.add(mostInnerObj1);
arr2.add(getMostInnerObj2);
mostInnerObj1.put("messageText", "처음으로");
mostInnerObj1.put("label", "처음으로");
mostInnerObj1.put("action", "message");
getMostInnerObj2.put("messageText", "챗봇종료");
getMostInnerObj2.put("label", "챗봇종료");
getMostInnerObj2.put("action", "message");
return obj;
}
public void chatDataParser(Map<String, Object> jsonParams) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonParams);
JSONParser parser = new JSONParser();
SimpleDateFormat sDate = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); //날짜 포맷 지정
try {
JSONObject obj = (JSONObject) parser.parse(jsonStr);
JSONObject userRequest = (JSONObject) obj.get("userRequest");
String chatBody = (String) userRequest.get("utterance");
// JSONObject block = (JSONObject) userRequest.get("block");
// String name = (String) block.get("name"); //block's name
String userInfo = userRequest.toString();
String uDate = sDate.format(new Date()); //날짜 지정
Date toDate = sDate.parse(uDate);
chat.setChatBody(chatBody);
//update 로직 변경
if(chat.getInsertDate() != null){
chatMapper.insertData(chat);
}else{
chat.setCheckDate(uDate);
chatMapper.updateData(chat);
}
chatHistory.setChatId(chat.getId());
System.out.println(chat.getId());
chatHistory.setChatKind("C");
chatHistory.setUserInfo(userInfo);
chatHistory.setChatBody(chatBody);
chatHistoryMapper.insertData(chatHistory);
} catch (ParseException | java.text.ParseException e) {
e.printStackTrace();
}
}
public void examAnalysisParser(Map<String, Object> jsonData) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String jsonStr = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonData);
JSONParser parser = new JSONParser();
try {
JSONObject obj = (JSONObject) parser.parse(jsonStr);
JSONObject userRequest = (JSONObject) obj.get("userRequest");
String subjectCode = (String) userRequest.get("utterance");
// System.out.println("subjectCode: " + subjectCode);
} catch (Exception e) {
e.printStackTrace();
}
}
}
*/ | [
"ylua.aw@gmail.com"
] | ylua.aw@gmail.com |
e4fc188bf004cb5fb78e51400027562379e68af6 | bad62ee6d1fde0692082c998be832bf8fea6e08c | /src/main/java/br/com/evtm/RecomendadorBuilder.java | deb75979e06f22333ee6bd01018e47cde69c6f0b | [] | no_license | LPHolanda/Recomendador-Mahout | 8330ccd59cf8793003e5956dfd14eb8460187f1f | b51dde94c8be1245d707ad7c8a8afc47c45fd4de | refs/heads/master | 2021-07-08T18:23:38.715252 | 2019-08-24T20:14:17 | 2019-08-24T20:14:17 | 202,941,690 | 1 | 0 | null | 2020-10-13T15:24:38 | 2019-08-17T23:55:51 | JavaScript | UTF-8 | Java | false | false | 1,206 | java | package br.com.evtm;
import org.apache.mahout.cf.taste.common.TasteException;
import org.apache.mahout.cf.taste.eval.RecommenderBuilder;
import org.apache.mahout.cf.taste.impl.neighborhood.ThresholdUserNeighborhood;
import org.apache.mahout.cf.taste.impl.recommender.GenericUserBasedRecommender;
import org.apache.mahout.cf.taste.impl.similarity.PearsonCorrelationSimilarity;
import org.apache.mahout.cf.taste.model.DataModel;
import org.apache.mahout.cf.taste.neighborhood.UserNeighborhood;
import org.apache.mahout.cf.taste.recommender.Recommender;
import org.apache.mahout.cf.taste.recommender.UserBasedRecommender;
import org.apache.mahout.cf.taste.similarity.UserSimilarity;
public class RecomendadorBuilder implements RecommenderBuilder{
public Recommender buildRecommender(DataModel model) throws TasteException {
UserSimilarity similarity = new PearsonCorrelationSimilarity(model);
UserNeighborhood neighborhood = new ThresholdUserNeighborhood(0.1, similarity, model);
// UserNeighborhood neighborhood = new NearestNUserNeighborhood(5, similarity, model);
UserBasedRecommender recommender = new GenericUserBasedRecommender(model, neighborhood, similarity);
return recommender;
}
}
| [
"leandropholanda@Outlook.com"
] | leandropholanda@Outlook.com |
2baf6815e6e39f4dca7f0ee9a1ba200ab6d46c35 | 507a7e712ba288af4d4f9c085b144888d7882210 | /Proyecto_I_CarlosGutierrez_JavierAmador/WebBankingSystem/src/java/Data/exceptions/RollbackFailureException.java | 35283935b22eafa6023b1ba0db6e50ff97adaf20 | [] | no_license | Java64x/Proyecto-1-Progra-4---Web-Bancaria-Server- | 1714cfc46d1ac3451d64806a06bd93fcfef9cdce | 7a2e08e02133f9dac1e3bfba79c2bcf988b3ff98 | refs/heads/master | 2021-02-16T10:46:06.210868 | 2020-03-04T22:13:47 | 2020-03-04T22:13:47 | 244,996,654 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 288 | java | package Data.exceptions;
public class RollbackFailureException extends Exception {
public RollbackFailureException(String message, Throwable cause) {
super(message, cause);
}
public RollbackFailureException(String message) {
super(message);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
fc85ecceade0f514bb291af2396e32ea1dcabb80 | 3ef48a3131e422095bc1c25cdcb9f5cc6dd22b77 | /src/main/java/QAanand/MavenJava/SeleniumTest.java | f099f9ebd7d59798c277e45fc3c6f23027faf872 | [] | no_license | beinganandsingh/GitDemo | 77ffe9280b15e6368ec898674878473c05895733 | 439ef89030a907916d8a627b8eae660b1c2056d9 | refs/heads/master | 2023-07-18T05:09:08.229592 | 2021-08-30T17:29:14 | 2021-08-30T17:29:14 | 401,389,620 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 262 | java | package QAanand.MavenJava;
import org.testng.annotations.Test;
public class SeleniumTest {
@Test
public void BrowserAutomation()
{
System.out.println("BrowserAutomation");
}
@Test
public void elementsUI()
{
System.out.println("elementsUI");
}
}
| [
"anandsingh0028@gmail.com"
] | anandsingh0028@gmail.com |
99c4825f88929fed5c033a5811e9af74c2e14005 | 89e2182a3b5152bc0aef445af6002cdab5b41e6c | /TankWar2.2/src/TankClient.java | a1466ee5185cebb35745e47ddc763ccfe03f261d | [] | no_license | zhibolau/TankWarLocal | 17967ae30e206006d0f61c7a6b2b272da9a6e123 | e318e4823f90fe6f5517712bc11e45e829e7fe8f | refs/heads/master | 2021-01-17T16:44:06.210307 | 2016-07-20T07:10:20 | 2016-07-20T07:10:20 | 62,966,219 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,648 | java | import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.List;
/**
* Created by zhiboliu on 16-7-9.
*/
//0.1 create the game window
//0.2 close window and not make window resizable
//0.3 draw tank
//0.4 make tank move, we can use a thread to paint tank every second.
//0.4_1 deal with tank glare using double buffer: 用一个虚拟图片全部加载完刷新的坦克 然后再整体显示在屏幕上
//0.5 set game screen size constant to do better changes in future 维护扩展改变
// 0.6 use keyboard to control tank
//0.7 deals with tank class, 若想要建立100个坦克 若无类会很麻烦 每次加属性 每次都要修改 那是面向过程 我们要面向对象 所以需要一个坦克类
//0.8 add tank 8 moving directions
//0.9 problem appears, as long as we press the direction before, it will always be true
// use key Released func
//1.0 added missile
//1.1 press control, missile appears
// now missile is not fired from center from tank
// missile can also be fired when tank stops, now is not the case 1.2 deal with this
// so we need to define a new field for tank 炮筒
//1.3 fire multiple missiles, now only one is fired, when u click second time, that missile comes back.....
//1.4 deal with missiles outside of the canvas or hit enemy, we should remove it from list
// also deal with tank is outside the canvas
//1.5 draw an enemy tank
//1.6 USE FIRE kill enemyTank
//1.7 add explosive class
//also know where the explosive should be
//1.8 add multiple enemy tanks
// u can also fire at enemy tanks
//1.9 make enemy tanks move and can fire at u
//as long as enemy tanks's direction is not stop, it will move
// we can set enemy tank direction to be random as it move each step
//now the tank change direction so quick, not usual, we should make it more normal
//let it more like 5 steps then change dir
//make enemy tank fire at you
//2.0 add walls, missile hit wall, missile disappear, tank hit wall, tank move
// randomly not hitting wall
//2.1 enemy tank cannot go throgh each other
// 2.2 super missile with letter A
public class TankClient extends Frame{//extends Frame so u can draw a canvas
public static final int GAME_WIDTH = 1600;
public static final int GAME_HEIGHT = 1200;
// int x = 50, y = 50;//tank's beginning position
Tank myTank = new Tank(50, 50, true, Tank.Direction.STOP, this);// we wanna initialize missile when control is clicked
// so we need tankClient to do that, therefore we add this in myTank constructor
Wall w1 = new Wall(300,200,30,150,this), w2 = new Wall(500,100,300,20,this);
//we need a list to store multiple enemyTanks
//Tank enemyTank = new Tank(100, 100, false, this);
List<Tank> tanks = new ArrayList<Tank>();
List<Explode> explodes = new ArrayList<Explode>();
List<Missile> missiles = new ArrayList<Missile>();// List 出错 是因为awt中也有list so 明确引入 arrayList和list
// Missile m = null;// missile should be initialized when control is clicked 1.3 deal with only one missile can be fired
Image offScreenImage = null;// repaint -> update -> paint so in update, we need to put image to offScreenImage
@Override
public void update(Graphics g) {
if(offScreenImage == null){
offScreenImage = this.createImage(GAME_WIDTH, GAME_HEIGHT);
}
//offScreenImage has a drawing pen, we get pen first then draw on offScreenPage
Graphics gOffScreenImage = offScreenImage.getGraphics();
//each time i draw, i draw the background to avoid tank to be a line on screen
Color c = gOffScreenImage.getColor();
gOffScreenImage.setColor(Color.GREEN);
gOffScreenImage.fillRect(0, 0, GAME_WIDTH, GAME_HEIGHT);
gOffScreenImage.setColor(c);
paint(gOffScreenImage);
//now we need to use pen from g of the real screen to draw
g.drawImage(offScreenImage, 0, 0, null);// 0,0 is left up corner position
}
public void lauchFrame(){
for(int i = 0; i < 10; i++){
tanks.add(new Tank(50 + 40 * (i + 1), 50, false, Tank.Direction.D, this));
}
this.setLocation(400, 300);
this.setSize(GAME_WIDTH, GAME_HEIGHT);
this.setTitle("Tank War game is locally running. ");
this.addWindowListener(new WindowAdapter() {//匿名类
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
this.setResizable(false);//不让改变窗口大小
this.setBackground(Color.GREEN);
this.addKeyListener(new KeyMonitor());
setVisible(true);
new Thread(new PaintThread()).start();
}
public static void main(String[] args){
TankClient tc = new TankClient();
tc.lauchFrame();
}
@Override
public void paint(Graphics g) {//we cannot add new enemy tanks here as we call paint every 50ms
//code is moved to tank class to use 面向对象
// //g 有前景色 可以取出来 然后设置成你想要的颜色
// Color c = g.getColor();
// g.setColor(Color.RED);
// g.fillOval(x, y, 30, 30);// draw the circle tank, we wanna make tank move, so we need its position to change
// g.setColor(c);//set the color back to the original one
//
// //y += 5; //test if thread can move the tank
g.drawString("missiles count: " + missiles.size(),10, 50);
g.drawString("explosive count: " + explodes.size(),10, 70);
g.drawString("enemy tanks count: " + tanks.size(),10, 90);
for(int i = 0; i < missiles.size(); i++){
Missile m = missiles.get(i);
//m.hitTank(enemyTank);
m.hitTanks(tanks);
m.hitTank(myTank);
m.hitWall(w1);//so missile cannot go through wall
m.hitWall(w2);
m.draw(g);
// if(!m.isLive()){
// missiles.remove(m); //method 2 use thread to clean missiles outside the canvas,
// // method 3: use tankCLient reference in missile
// }
// else{
// m.draw(g);
// }
}
//e.draw(g); for test when we only have one explode
for(int i = 0; i < explodes.size(); i++){
Explode e = explodes.get(i);
e.draw(g);
}
for(int i = 0; i < tanks.size(); i++){
Tank t = tanks.get(i);
t.collidesWithWall(w1);//tank cannot go through wall
t.collidesWithWall(w2);
t.collidesWithTanks(tanks);
t.draw(g);// now we cannot draw tank, because we do not add any tank into that list
}
myTank.draw(g);
//enemyTank.draw(g);
w1.draw(g);
w2.draw(g);
}
//this thread only works for tank to make tank move, so we can use internal class
private class PaintThread implements Runnable{
//internal class can call external class's method, external class surrounds internal class
@Override
public void run() {
while(true){
repaint();// repaint belong to external class, repaint will call paint
try {
Thread.sleep(50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
//implements KeyListener 实现接口不好 里面你不关心的方法全得重写 所以用继承
private class KeyMonitor extends KeyAdapter{
@Override
public void keyPressed(KeyEvent e) {
//System.out.println("ok"); // test if key montior is added
//code is moved to tank class to use 面向对象
// int key = e.getKeyCode();//用这个code来查看按了哪个按键
// switch (key){
// case KeyEvent.VK_RIGHT :
// x += 5;
// break;
// case KeyEvent.VK_LEFT :
// x -= 5;
// break;
// case KeyEvent.VK_UP :
// y -= 5;
// break;
// case KeyEvent.VK_DOWN :
// y += 5;
// break;
// }
myTank.keyPressed(e);
}
@Override
public void keyReleased(KeyEvent e) {
myTank.keyReleased(e);
}
}
}
// we use double buffer to deal with tank glare in 0.4_1 | [
"zhibolau@gmail.com"
] | zhibolau@gmail.com |
f4432c56917695862a3ca6c15a5ad59a7039c84a | e2cad850ce8c490de4add7559ddfcd8dafba332f | /gmall0105/gmall-api/src/main/java/com/atguigu/gmall/service/SkuService.java | 1cfd5e28d1f1e004d050d9b17cb0d71bc83779bb | [] | no_license | chaihongpeng/gmall0105 | 207b646a06902b10589fc55ce7807b7559f38702 | 3cc28810c172523457760a2d852dd46927eac3b4 | refs/heads/master | 2022-09-19T23:06:44.422634 | 2020-04-07T09:28:17 | 2020-04-07T09:28:17 | 253,715,400 | 1 | 0 | null | 2022-09-01T23:23:01 | 2020-04-07T07:12:01 | CSS | UTF-8 | Java | false | false | 333 | java | package com.atguigu.gmall.service;
import com.atguigu.gmall.bean.PmsSkuInfo;
import java.util.List;
public interface SkuService {
PmsSkuInfo getSkuById(String skuId);
List<PmsSkuInfo> getSkuSaleAttrValueListBySpu(String productId);
PmsSkuInfo getSkuByIdFromCache(String skuId);
List<PmsSkuInfo> getAllSku();
}
| [
"chai_hongpeng@163.com"
] | chai_hongpeng@163.com |
79cec603576e15a81cf3d1845b3f69b0a3cf5d12 | b3f4fc5cc0a521299a1ae16d8d69bb006c4b5dce | /src/main/java/com/lghimfus/app/RCProject/services/SippSpecsService.java | 1c30a0c05518a3d6cc84bc04c107868b529c037c | [] | no_license | lghimfus/RCProject | 4c42e2ac33ef533a583b7062719569af514beb35 | 75a72959b72734121418761de5733be51be54f0b | refs/heads/master | 2022-12-01T07:01:27.540170 | 2020-03-05T08:51:07 | 2020-03-05T08:51:07 | 108,900,528 | 1 | 1 | null | 2022-11-16T09:21:13 | 2017-10-30T19:46:03 | Java | UTF-8 | Java | false | false | 5,564 | java | package com.lghimfus.app.RCProject.services;
import java.io.IOException;
import java.util.Map;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.lghimfus.app.RCProject.models.SippSpecs;
import com.lghimfus.app.RCProject.models.Vehicle;
import com.lghimfus.app.RCProject.models.SippSpecs.LetterSpecsWrapper;
/**
* This class consists of methods that handles requests related to a car's SIPP.
*
* @author lghimfus
*
*/
public class SippSpecsService{
private final static String CAR_TYPES_PATH = "json/car_types.json";
private final static String DOOR_TYPES_PATH = "json/door_types.json";
private final static String TRANSMISSION_TYPES_PATH = "json/transmission_types.json";
private final static String FUEL_AC_TYPES_PATH = "json/fuel_ac_types.json";
private static final int CAR_TYPE_POS = 0;
private static final int DOOR_TYPE_POS = 1;
private static final int TRANSMISSION_TYPE_POS = 2;
private static final int FUEL_AC_TYPE_POS = 3;
// Holds all the data about SIPP specifications.
private SippSpecs sippSpecsTable;
public SippSpecsService() {
sippJsonToJava();
}
/**
* @return a SippSpecs container with all the SIPP data.
*/
public SippSpecs getSippSpecs() {
return this.sippSpecsTable;
}
/**
* @param v is the vehicle.
* @return the type of a vehicle.
*/
public String getCarType(Vehicle v) {
Character sippLetter = v.getSipp().charAt(CAR_TYPE_POS);
// If the SIPP letter is recognized return its value.
if(sippSpecsTable.getCarTypesMap().containsKey(sippLetter)){
return sippSpecsTable.getCarTypesMap().get(sippLetter).getValue();
}
return "unknown";
}
/**
* @param v is the vehicle.
* @return the doors type of a vehicle.
*/
public String getDoorsType(Vehicle v) {
Character sippLetter = v.getSipp().charAt(DOOR_TYPE_POS);
// If the SIPP letter is recognized return its value.
if(sippSpecsTable.getDoorTypesMap().containsKey(sippLetter))
return sippSpecsTable.getDoorTypesMap().get(sippLetter).getValue();
return "unknown";
}
/**
* @param v is the vehicle.
* @return the transmission type of a vehicle.
*/
public String getTransmissionType(Vehicle v) {
Character sippLetter = v.getSipp().charAt(TRANSMISSION_TYPE_POS);
// If the SIPP letter is recognized return its value.
if(sippSpecsTable.getTransmissionTypesMap().containsKey(sippLetter))
return sippSpecsTable.getTransmissionTypesMap().get(sippLetter).getValue();
return "unknown";
}
/**
* @param v is the vehicle.
* @return the fuel type of a vehicle.
*/
public String getFuelType(Vehicle v) {
Character sippLetter = v.getSipp().charAt(FUEL_AC_TYPE_POS);
// If the SIPP letter is recognized return its value.
if(sippSpecsTable.getFuelAcMap().containsKey(sippLetter))
return sippSpecsTable.getFuelAcMap().get(sippLetter).getValue().split("/")[0];
return "unknown";
}
/**
* @param v is the vehicle.
* @return the air conditioning type of a vehicle.
*/
public String getAcType(Vehicle v) {
Character sippLetter = v.getSipp().charAt(FUEL_AC_TYPE_POS);
// If the SIPP letter is recognized return its value.
if(sippSpecsTable.getFuelAcMap().containsKey(sippLetter))
return sippSpecsTable.getFuelAcMap().get(sippLetter).getValue().split("/")[1];
return "unknown";
}
/**
* Calculates the SIPP score of a vehicle.
*
* @param v is the vehicle.
* @return the SIPP score of a vehicle.
*/
public int getSippScore(Vehicle v) {
int score = 0;
Character sippLetter;
sippLetter = v.getSipp().charAt(TRANSMISSION_TYPE_POS);
// If the SIPP letter is recognized add up its corresponding score.
if(sippSpecsTable.getTransmissionTypesMap().containsKey(sippLetter))
score += sippSpecsTable.getTransmissionTypesMap().get(sippLetter).getScore();
sippLetter = v.getSipp().charAt(FUEL_AC_TYPE_POS);
// If the SIPP letter is recognized add up its corresponding score.
if(sippSpecsTable.getFuelAcMap().containsKey(sippLetter))
score += sippSpecsTable.getFuelAcMap().get(sippLetter).getScore();
return score;
}
/**
* Gets the SIPP from corresponding JSON files and deserializes it.
* Each letter is mapped to its corresponding specifications (value and score
* wrapped in a LetterSpecs class).
*/
public void sippJsonToJava() {
ObjectMapper mapper = new ObjectMapper();
sippSpecsTable = new SippSpecs();
try {
ClassLoader classloader = getClass().getClassLoader();
sippSpecsTable.setCarTypesMap(
mapper.readValue(classloader.getResourceAsStream(CAR_TYPES_PATH),
new TypeReference<Map<Character, LetterSpecsWrapper>>(){}));
sippSpecsTable.setDoorTypesMap(
mapper.readValue(classloader.getResourceAsStream(DOOR_TYPES_PATH),
new TypeReference<Map<Character, LetterSpecsWrapper>>(){}));
sippSpecsTable.setTransmissionTypesMap(
mapper.readValue(classloader.getResourceAsStream(TRANSMISSION_TYPES_PATH),
new TypeReference<Map<Character, LetterSpecsWrapper>>(){}));
sippSpecsTable.setFuelAcMap(
mapper.readValue(classloader.getResourceAsStream(FUEL_AC_TYPES_PATH),
new TypeReference<Map<Character, LetterSpecsWrapper>>(){}));
}
catch (IOException e) { e.printStackTrace(); }
}
}
| [
"lucian-iulian.ghimfus@student.manchester.ac.uk"
] | lucian-iulian.ghimfus@student.manchester.ac.uk |
f2a1f103873d0d350435ce895626e31062f9f046 | 31457f419496b3da756ffb23104a8bc8a7c18586 | /src/main/java/pl/wsz/users/Entry/EntryDAO.java | 2cfc6c119557227d367f93b7a7649f7ef374a20c | [] | no_license | WuangMai/WSZ_Edukacja_guestBook | ef04726bf4d83f822889c6f9034b75a3ff2efaad | 00d60e4f3104ff199009d494c3f6bf6e4d51d794 | refs/heads/main | 2023-05-06T08:47:25.425359 | 2021-05-27T22:25:56 | 2021-05-27T22:25:56 | 354,305,920 | 0 | 0 | null | 2021-05-06T02:24:08 | 2021-04-03T13:59:52 | CSS | UTF-8 | Java | false | false | 3,229 | java | package pl.wsz.users.Entry;
import pl.wsz.users.User;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
public class EntryDAO {
private static final String READ_ENTRIES_QUERY = "SELECT * FROM book";
private static final String CREATE_ENTRY_QUERY = "INSERT INTO book (user_id, content, added) VALUES (?,?,NOW())";
private static final String GET_USER_NAME_BY_ID_QUERY = "SELECT * FROM users WHERE id = ?";
private final String DBurl = "jdbc:mysql://localhost:3306/guest_book";
private final String DBuser = "root";
private final String DBpass = "coderslab";
public Entry create(Entry entry) {
try (Connection conn = DriverManager.getConnection(DBurl, DBuser, DBpass)) {
PreparedStatement statement = conn.prepareStatement(CREATE_ENTRY_QUERY,
PreparedStatement.RETURN_GENERATED_KEYS);
statement.setInt(1, entry.getUserId());
statement.setString(2, entry.getContent());
statement.executeUpdate();
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
entry.setId(rs.getInt(1));
}
statement.close();
rs.close();
return entry;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public List<Entry> readAll() {
List<Entry> entryList = new ArrayList<>();
try (Connection conn = DriverManager.getConnection(DBurl, DBuser, DBpass);
PreparedStatement statement = conn.prepareStatement(READ_ENTRIES_QUERY);
ResultSet rs = statement.executeQuery()) {
while (rs.next()) {
Entry entry = new Entry();
entry.setId(rs.getInt("id"));
entry.setUserId(rs.getInt("user_id"));
entry.setContent(rs.getString("content"));
entry.setAddedTime(rs.getString("added"));
entryList.add(entry);
}
} catch (Exception e) {
e.printStackTrace();
}
return entryList;
}
public User getUserNameByID(int id) {
User user = new User();
try (Connection conn = DriverManager.getConnection(DBurl, DBuser, DBpass);
PreparedStatement statement = conn.prepareStatement(GET_USER_NAME_BY_ID_QUERY)) {
statement.setInt(1, id);
ResultSet rs = statement.executeQuery();
while (rs.next()) {
user.setId((rs.getInt("id")));
user.setUserId(rs.getString("user_id"));
user.setName(rs.getString("name"));
user.setSurname(rs.getString("surname"));
user.setNick(rs.getString("nick"));
user.setEmail(rs.getString("email"));
user.setPassword(rs.getString("password"));
user.setPhone(rs.getString("phone"));
}
statement.close();
rs.close();
return user;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}
| [
"wuangmai@gmail.com"
] | wuangmai@gmail.com |
c2582265f0fa7711781aa568ef6ef350e04b3448 | 69dabadd3ad8805b6a27d453476f7e814afc2842 | /src/main/java/Main.java | e1596b1a250dc3a75a62967dee8ae3f2eea2ce69 | [] | no_license | sun5lower/My_2nd_java | bb7d57aabfb4bb3f9e2bed0be6720339e80e5abb | 5be71662d2c8cb5be9988d9780476bf2d67c92ad | refs/heads/master | 2023-03-08T11:26:25.607269 | 2021-03-01T14:33:48 | 2021-03-01T14:33:48 | 342,619,767 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 148 | java | package main.java;
public class Main {
public static void main(String[] args) {
System.out.println("Welcome to Java Class!");
}
}
| [
"dlegrange3@gmail.com"
] | dlegrange3@gmail.com |
97b0e21cb51cbca62b4e021a959a4417bc1b6865 | 3374f62c624c1e133ffcdd340713a50303cb7c6d | /core/unittestsupport/src/main/java/org/apache/isis/core/unittestsupport/bidir/Instantiators.java | d2ea382e826447f722e6f9cc2050cc1d0c4e87d4 | [
"Apache-2.0"
] | permissive | DalavanCloud/isis | 83b6d6437a3ca3b7e0442ed1b8b5dbc3ae67ef1e | 2af2ef3e2edcb807d742f089839e0571d8132bd9 | refs/heads/master | 2020-04-29T10:08:49.816838 | 2019-02-11T23:35:56 | 2019-02-11T23:35:56 | 176,051,163 | 1 | 0 | Apache-2.0 | 2019-03-17T03:19:31 | 2019-03-17T03:19:31 | null | UTF-8 | Java | false | false | 958 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.isis.core.unittestsupport.bidir;
interface Instantiators {
public abstract Object newInstance(Class<?> entityType);
} | [
"danhaywood@apache.org"
] | danhaywood@apache.org |
264ebefd5b90eab337f0bdd174abf25ce73500ec | 116b75d747d184cdb061fd168e702254c1808ba7 | /src/common/src/main/java/com/alipay/hulu/common/injector/provider/Provider.java | 82623eb49f10981f66b82ce2ac2d65538b17ee94 | [
"Apache-2.0",
"BSD-2-Clause",
"LGPL-2.1-only",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-warranty-disclaimer",
"BSD-3-Clause",
"MIT",
"LGPL-2.1-or-later"
] | permissive | guochenhome/SoloPi | c26f492b37f320484a5d8f45d1237cdbb27353a7 | 6145bb1944293600d89db5f80bdb4b35f43442c2 | refs/heads/master | 2020-07-17T07:46:36.153379 | 2019-09-03T03:12:51 | 2019-09-03T03:12:51 | 283,125,980 | 1 | 0 | Apache-2.0 | 2020-07-28T06:48:13 | 2020-07-28T06:48:13 | null | UTF-8 | Java | false | false | 1,732 | java | /*
* Copyright (C) 2015-present, Ant Financial Services Group
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alipay.hulu.common.injector.provider;
import com.alipay.hulu.common.injector.param.SubscribeParamEnum;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* 依赖注入方法注解
*/
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface Provider {
/**
* 参数名称,可提供的参数列表 <br/>
* {@link SubscribeParamEnum#APP} 应用名称,类型 {@link String} <br/>
* {@link SubscribeParamEnum#UID} 应用UID,类型 {@link Integer} <br/>
* {@link SubscribeParamEnum#PID} 应用PID,类型 {@link Integer} <br/>
* {@link SubscribeParamEnum#EXTRA} 是否显示额外信息,类型 {@link Boolean} <br/>
* {@link SubscribeParamEnum#PUID} ps获取的UID,类型 {@link String} <br/>
*/
Param[] value() default {};
long updatePeriod() default 1000;
boolean lazy() default true;
boolean force() default false;
}
| [
"ruikai.qrk@alibaba-inc.com"
] | ruikai.qrk@alibaba-inc.com |
6eb0ba0c01bddbffce3d768fc44b2e46f4484ae7 | 5e3235edf3de262f4d10b9e9e1fcc3bd13d6b8b1 | /Code Snippet Repository/Spring/Spring6773.java | 30d166ef3158b3263ed74c87ac2b2ef53bd729d4 | [] | no_license | saber13812002/DeepCRM | 3336a244d4852a364800af3181e03e868cf6f9f5 | be3e5e50e34a042d5ba7259ff5ff75c08ab32bb9 | refs/heads/master | 2023-03-16T00:08:06.473699 | 2018-04-18T05:29:50 | 2018-04-18T05:29:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 682 | java | @SuppressWarnings("")
protected void invokeListener(Session session, Message message) throws JMSException {
Object listener = getMessageListener();
if (listener instanceof SessionAwareMessageListener) {
doInvokeListener((SessionAwareMessageListener) listener, session, message);
}
else if (listener instanceof MessageListener) {
doInvokeListener((MessageListener) listener, message);
}
else if (listener != null) {
throw new IllegalArgumentException(
"Only MessageListener and SessionAwareMessageListener supported: " + listener);
}
else {
throw new IllegalStateException("No message listener specified - see property 'messageListener'");
}
}
| [
"Qing.Mi@my.cityu.edu.hk"
] | Qing.Mi@my.cityu.edu.hk |
e916d3541b494bd8b247a26b643b6217eb8300ec | ea7476f4edf8daea6faf18ca7414a96f97a2d2d9 | /src/main/java/com/hackerank/customer/config/AuthenticationEntryPoint.java | 2cfc0b026dde7bc73a9c1dac87ae0ba26ad22760 | [] | no_license | hemasatyakumarp/customer-ms | 271ab5d36c3a083a050b3d6293df21c33d19d1f9 | e55b56a9adbe06a6520f9bccc83af1da3ef0671c | refs/heads/master | 2020-04-22T12:52:43.172160 | 2019-02-12T20:22:56 | 2019-02-12T20:22:56 | 169,899,906 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,115 | java | package com.hackerank.customer.config;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.www.BasicAuthenticationEntryPoint;
import org.springframework.stereotype.Component;
@Component
public class AuthenticationEntryPoint extends BasicAuthenticationEntryPoint {
@Override
public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException authEx)
throws IOException, ServletException {
response.addHeader("WWW-Authenticate", "Basic realm=" +getRealmName());
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
PrintWriter writer = response.getWriter();
writer.println("HTTP Status 401 - " + authEx.getMessage());
}
@Override
public void afterPropertiesSet() throws Exception {
setRealmName("hackerrank");
super.afterPropertiesSet();
}
} | [
"satya@localhost.localdomain"
] | satya@localhost.localdomain |
f2f6efa341431958981fdec1f282c65a78938d7a | 7a54d0289de8047eded9c31ec8bc3cfeb8f6f768 | /src/fatworm/query/MemoryGroupContainer.java | 9e2cc69daae3b77333b155f959d57be41e6a5f3e | [] | no_license | kirakira/fatworm | ed641a82c924ba2024c4c60c0f12e171e4caae4c | 63d8f4f99f67bd774b9deb1671139893f1880569 | refs/heads/master | 2020-04-04T05:07:19.530626 | 2012-12-19T07:54:56 | 2012-12-19T07:54:56 | 2,385,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,955 | java | package fatworm.query;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map;
import java.util.Set;
import fatworm.dataentity.DataEntity;
import fatworm.functioncalculator.FuncValue;
public class MemoryGroupContainer extends GroupContainer {
Map<DataEntity, FuncValue[]> funcValues;
LinkedList<DataEntity[]> resultValues;
DataEntity[] current;
Iterator<DataEntity[]> iter;
public MemoryGroupContainer(String key, Set<String> funcNameSet) {
super(key, funcNameSet);
funcValues = new HashMap<DataEntity, FuncValue[]>();
}
@Override
public void update(Scan scan) {
DataEntity pointer = scan.getColumn(key);
if (pointer.isNull())
return;
FuncValue[] result = funcValues.get(pointer);
if (result == null) {
result = new FuncValue[funcNameList.length];
for (int i = 0; i < result.length; i++)
result[i] = new FuncValue();
funcValues.put(pointer, result);
}
for (int i = 0; i < result.length; i++) {
calculator[i].update(result[i], scan.getColumn(variableList[i]));
}
}
public void finish() {
resultValues = new LinkedList<DataEntity[]>();
for (DataEntity key: funcValues.keySet()) {
FuncValue[] raw = funcValues.get(key);
DataEntity[] result = new DataEntity[raw.length + 1];
for (int i = 0; i < raw.length; i++)
result[i] = calculator[i].getResult(raw[i]);
result[result.length - 1] = key;
resultValues.add(result);
}
}
@Override
public DataEntity getFunctionValue(String func) {
for (int i = 0; i < funcNameList.length; i++) {
if (funcNameList[i].equals(func))
return current[i];
}
return null;
}
@Override
public DataEntity getKeyValue() {
return current[current.length - 1];
}
@Override
public boolean next() {
if (iter.hasNext()) {
current = iter.next();
return true;
}
return false;
}
@Override
public void beforeFirst() {
iter = resultValues.iterator();
current = null;
}
}
| [
"ghost.gold@gmail.com"
] | ghost.gold@gmail.com |
7cf0c14b8bb556cd6dd61a381c79327b66c9dfba | 754283419c5a275a4f1aaec39c1b241e0571084f | /sqlinjection-app/src/com/techlab/test/NoInjectionTest.java | e49aa50b65a376dd455673edf9b4a6d41c9ee3e5 | [] | no_license | GayatriHushe/Swabhav-JDBC | ad7f8a4fed47f470bd1c580648ae8defa16aa7a5 | b588fff285a99cbee550567d5d9219390f6b3fe5 | refs/heads/master | 2023-07-02T09:38:09.543532 | 2021-07-26T08:36:44 | 2021-07-26T08:36:44 | 388,923,292 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package com.techlab.test;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Scanner;
import com.mysql.jdbc.PreparedStatement;
public class NoInjectionTest {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost:4040/swabhav?"+"user=root&password=root");
PreparedStatement ps = (PreparedStatement) con.prepareStatement("SELECT EMPNO,ENAME FROM EMP1 WHERE EMPNO=?;");
Scanner sc=new Scanner(System.in);
System.out.println("Enter empNo : ");
String empNo=sc.nextLine();
sc.close();
System.out.println();
System.out.println("Displaying EMP table from SWABHAV : ");
ps.setString(1, empNo);
ResultSet rs=ps.executeQuery();
while(rs.next())
System.out.println(rs.getInt(1)+" "+rs.getString(2));
rs.close();
ps.close();
if(!con.isClosed())
con.close();
}
}
| [
"gayatrihushe@gmail.com"
] | gayatrihushe@gmail.com |
2c482fd278aeb5ec821d90d10ec8337dec8917dc | f1326d1feddd10f146fc103129fe0378f35a454d | /Practica/PatronesDeDisenio/src/patronesDeDisenio/Cuadrado.java | 1412268618fae5e45b597908c234c56b9c4e0d72 | [] | no_license | escurragonzalez/PrograAvanzada | de6b181f46f72d8c277030a58650f7f5b8bffca6 | e9113ab64af0b1cefca39cbbcb5891d9a6cfc7c1 | refs/heads/master | 2021-01-17T16:03:18.358067 | 2016-07-20T15:50:11 | 2016-07-20T15:50:13 | 56,399,951 | 0 | 3 | null | 2016-04-25T00:38:11 | 2016-04-16T18:40:30 | Java | UTF-8 | Java | false | false | 331 | java | package patronesDeDisenio;
public class Cuadrado implements Figura{
private double lado;
public Cuadrado(){
lado=1;
}
public double getLado() {
return lado;
}
public void setLado(double lado) {
this.lado = lado;
}
@Override
public double calcularArea() {
return (Math.pow(this.lado, 2));
}
} | [
"enzojaviergustavoalmiron@gmail.com"
] | enzojaviergustavoalmiron@gmail.com |
4cda8f2d017fc94e928651dc169e6e7452ed6546 | f33868a3b63416338cda31d1b18c5d0d54657b01 | /src/main/java/WorldQLFB/StandardEvents/Record.java | 8d740fed73c264a2feaddc116cc85a0122d5bafb | [
"MIT"
] | permissive | Jojo1542/mammoth | 39add6abd5d5d22f15d51de87ba63fe33c2a427f | 20917236ca3b9e6fedd517cc529451c8006a4700 | refs/heads/master | 2023-08-05T12:54:21.401251 | 2021-09-25T11:20:44 | 2021-09-25T11:20:44 | 410,249,212 | 0 | 0 | MIT | 2021-09-25T11:01:34 | 2021-09-25T11:01:33 | null | UTF-8 | Java | false | false | 2,931 | java | // automatically generated by the FlatBuffers compiler, do not modify
package WorldQLFB.StandardEvents;
import java.nio.*;
import java.lang.*;
import java.util.*;
import com.google.flatbuffers.*;
@SuppressWarnings("unused")
public final class Record extends Table {
public static void ValidateVersion() { Constants.FLATBUFFERS_2_0_0(); }
public static Record getRootAsRecord(ByteBuffer _bb) { return getRootAsRecord(_bb, new Record()); }
public static Record getRootAsRecord(ByteBuffer _bb, Record obj) { _bb.order(ByteOrder.LITTLE_ENDIAN); return (obj.__assign(_bb.getInt(_bb.position()) + _bb.position(), _bb)); }
public void __init(int _i, ByteBuffer _bb) { __reset(_i, _bb); }
public Record __assign(int _i, ByteBuffer _bb) { __init(_i, _bb); return this; }
public WorldQLFB.StandardEvents.Vec3 position() { return position(new WorldQLFB.StandardEvents.Vec3()); }
public WorldQLFB.StandardEvents.Vec3 position(WorldQLFB.StandardEvents.Vec3 obj) { int o = __offset(4); return o != 0 ? obj.__assign(o + bb_pos, bb) : null; }
public String data() { int o = __offset(6); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer dataAsByteBuffer() { return __vector_as_bytebuffer(6, 1); }
public ByteBuffer dataInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 6, 1); }
public String metadata() { int o = __offset(8); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer metadataAsByteBuffer() { return __vector_as_bytebuffer(8, 1); }
public ByteBuffer metadataInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 8, 1); }
public String jsondata() { int o = __offset(10); return o != 0 ? __string(o + bb_pos) : null; }
public ByteBuffer jsondataAsByteBuffer() { return __vector_as_bytebuffer(10, 1); }
public ByteBuffer jsondataInByteBuffer(ByteBuffer _bb) { return __vector_in_bytebuffer(_bb, 10, 1); }
public static void startRecord(FlatBufferBuilder builder) { builder.startTable(4); }
public static void addPosition(FlatBufferBuilder builder, int positionOffset) { builder.addStruct(0, positionOffset, 0); }
public static void addData(FlatBufferBuilder builder, int dataOffset) { builder.addOffset(1, dataOffset, 0); }
public static void addMetadata(FlatBufferBuilder builder, int metadataOffset) { builder.addOffset(2, metadataOffset, 0); }
public static void addJsondata(FlatBufferBuilder builder, int jsondataOffset) { builder.addOffset(3, jsondataOffset, 0); }
public static int endRecord(FlatBufferBuilder builder) {
int o = builder.endTable();
return o;
}
public static final class Vector extends BaseVector {
public Vector __assign(int _vector, int _element_size, ByteBuffer _bb) { __reset(_vector, _element_size, _bb); return this; }
public Record get(int j) { return get(new Record(), j); }
public Record get(Record obj, int j) { return obj.__assign(__indirect(__element(j), bb), bb); }
}
}
| [
"jacksonroberts25@gmail.com"
] | jacksonroberts25@gmail.com |
1381174883259d23c613cd0f3552aa38d157dd0d | 9d9e3e15ac08b41751c3900f4507dd5ce69bfbe9 | /src/test/java/com/example/repository/CityRepositoryTest.java | d27b153cc5267418c2d5ac04407b13b5ad3bc9d1 | [] | no_license | nto2/chap03 | 448d33363f99514bb41d46de411433063d915be7 | 1829fe6cdb8e850c324ea598c89eab3d898a7945 | refs/heads/master | 2021-06-28T21:25:44.223375 | 2017-09-14T08:39:59 | 2017-09-14T08:39:59 | 103,481,622 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 923 | java | package com.example.repository;
import static org.junit.Assert.*;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Example;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import com.example.domain.City;
@RunWith(SpringRunner.class)
@SpringBootTest
@ActiveProfiles("mysql")
public class CityRepositoryTest {
@Inject
CityRepository cityRepository;
@Test
public void findAll() {
cityRepository.findAll().forEach(e -> {
System.out.println(e);
});
System.out.println("count = " + cityRepository.count());
City city = new City();
city.setCountrycode("KOR");
Example<City> example = Example.of(city);
cityRepository.findAll(example).forEach(e -> {
System.out.println(e);
});
}
}
| [
"nto2@naver.com"
] | nto2@naver.com |
1839a88459348cb1c25c7b895dcc5b7cbad5fa81 | 20d85e8c5c73f2f632795f91edf69a2f9fc3b3a2 | /bagofword/src/utils.java | e7e8ac29539a512e5498f798fb8a6d40dc66e30c | [] | no_license | AUGxhub/opencvsparkscala | c1681c223479a3a59570779ed1346b4ca63f06fd | 742f7b48f362c81945e264e7ace0060e065b3248 | refs/heads/master | 2021-01-17T07:14:23.962022 | 2016-05-23T05:56:20 | 2016-05-23T05:56:20 | 54,766,034 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 4,179 | java | import org.opencv.core.CvType;
import org.opencv.core.Mat;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* Created by augta on 2016/3/31.
*/
public class utils {
/*
* 获取文件夹下所有文件路径 不包括子文件夹的路径
*/
public static List<String> getFileNames(String directory) {
File fd = null;
fd = new File(directory);
File[] files = fd.listFiles();//获取所有文件
List<String> list = new ArrayList<String>();
for (File file : files) {
if (file.isDirectory()) {
//如果是当前路径是个文件夹 则循环读取文件夹下所有的文件
getFileNames(file.getAbsolutePath());
} else {
list.add(file.toString());
}
}
return list;
}
/*
* 把矩阵 MAT 按照尾部追加的方式 添加到外部存贮文件中
* 这样可以在第二次以后处理时 使用前一次的结果 加速程序运行
*/
public static boolean saveMatrix(String filename, Mat matrix, String matrixName) throws IOException {
//对Mat进行预处理 去掉回车字符
String temp = matrix.dump();
String matStr = null;
for (int i = 0; i < temp.length(); i++) {
char item = temp.charAt(i);
if (item == '\n') i++;
else {
matStr += temp.charAt(i);
}
}
matStr = matStr.substring(4);//去掉初始化时的 null字符们
//matStr 形如[1, 0, 0, 0, 0,0; 0, 0, 0, 1, 0, 0]
//CvType 一律使用CV_8UC3 即三通道RGB
//打开文件描述符
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename, true), "UTF-8"));
bw.write(matrixName + "matrix" + matrix.cols() + "matrix" + matrix.rows() + "matrix" + matStr + "matrix" + "\n\r");
bw.flush();
bw.close();
return false;
}
/*
* 从外部存贮文件中读入mat矩阵
*/
public static Mat readMatrix(String filename, String matrixName) {
Mat matrix = null;
int rows = 0, cols = 0;//矩阵的行列数
String line = "";
String[] args = null;
try {
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "UTF-8"));
while ((line = br.readLine()) != null) {
args = line.split("matrix");
if (matrixName == args[0]) {
cols = Integer.getInteger(args[1]);
rows = Integer.getInteger(args[2]);
line = args[3];
line = line.substring(1, line.length() - 1);//去头和尾部的[]
matrix = new Mat(rows, cols, CvType.CV_8UC3);
matrix.put(rows, cols, line);
}
}
br.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return matrix;
}
//模块测试
public static void main(String args[]) {
String test = "Mat [ " +
"rows()" + "*" + "cols()" + "*" + "CvType.typeToString(type())" +
", isCont=" + "isContinuous()" + ", isSubmat=" + "isSubmatrix()" +
", nativeObj=0x" + "Long.toHexString(nativeObj)" +
", dataAddr=0x" + "Long.toHexString(dataAddr())" +
" ]";
}
/*
*把string 转化为mat格式
* Mat toString 格式化的内容
* "Mat [ " +
rows() + "*" + cols() + "*" + CvType.typeToString(type()) +
", isCont=" + isContinuous() + ", isSubmat=" + isSubmatrix() +
", nativeObj=0x" + Long.toHexString(nativeObj) +
", dataAddr=0x" + Long.toHexString(dataAddr()) +
" ]";
*/
private Mat toMat(String str) {
Mat result = null;
int roww, cols = 0;
return result;
}
}
| [
"augtab@hotmail.com"
] | augtab@hotmail.com |
21489969ab6bbcb5e85e2a07d146a845622175f4 | a2af0860d1965811064959931f38d5f14024b327 | /src/main/java/me/fabian/source/org/omg/DynamicAny/DynValueCommon.java | c2a1002083b9e4acc706a5f7636cde09582755b5 | [] | no_license | fabian4/jdk-source-learning | ea4c99091ceee55055cad963d21acb5e41a51123 | 2e9709b618c7aef238c4b93a5cbaff2946c3799f | refs/heads/master | 2023-08-15T20:05:20.813459 | 2021-10-02T07:37:45 | 2021-10-02T07:37:45 | 408,130,996 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 584 | java | package org.omg.DynamicAny;
/**
* org/omg/DynamicAny/DynValueCommon.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from c:/cygwin64/tmp/build/source/java-1.8.0-openjdk/tmp/jdk8u/corba/src/share/classes/org/omg/DynamicAny/DynamicAny.idl
* Monday, January 11, 2021 12:18:58 PM PST
*/
/**
* DynValueCommon provides operations supported by both the DynValue and DynValueBox interfaces.
*/
public interface DynValueCommon extends DynValueCommonOperations, org.omg.DynamicAny.DynAny, org.omg.CORBA.portable.IDLEntity
{
} // interface DynValueCommon
| [
"fabian4@163.com"
] | fabian4@163.com |
a692b46a546a0d351da50f5a3a6f4e07cc0089ff | 0f2ea4c3f4014f87fa6eaf5d09785403c9735d28 | /app/src/main/java/com/byacht/overlook/zhihu/entity/ZhihuDetailNews.java | 7c9564cc08ca8e3f2b5880d495edb33b7a7a7bae | [] | no_license | Byacht/Overlook | 269d63dbc6bd7e371331d93c572299ed85be741a | 92949204df567cf75fb3e8585b70ac689aac330d | refs/heads/master | 2021-01-15T18:40:46.832705 | 2017-09-22T15:14:20 | 2017-09-22T15:14:20 | 99,796,001 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 1,274 | java | package com.byacht.overlook.zhihu.entity;
import com.google.gson.annotations.SerializedName;
/**
* Created by dn on 2017/8/6.
*/
public class ZhihuDetailNews {
@SerializedName("body")
private String body;
@SerializedName("title")
private String title;
@SerializedName("image")
private String image;
@SerializedName("share_url")
private String mShareUrl;
@SerializedName("css")
private String[] css;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
private String id;
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getShareUrl() {
return mShareUrl;
}
public void setShareUrl(String shareUrl) {
this.mShareUrl = shareUrl;
}
public String[] getCss() {
return css;
}
public void setCss(String[] css) {
this.css = css;
}
}
| [
"374984629@qq.com"
] | 374984629@qq.com |
b8c555fa8e4c449f839256943e25406794edb587 | dac20fbbcf8fada29da07be33542b53dd4f3723f | /plugins/IFMLEditor/src/IFML/Mobile/MobileDeviceScreen.java | a754fbb7745df0b4384b44a9f2b58fb474e05cbd | [
"MIT"
] | permissive | mobileIFML/ifml-editor | 9e3b2f17106007059b523c60f29ce35512703d6f | 5ccb4bf4582cb5c066ab60ec71c8a5d41720236b | refs/heads/master | 2021-01-21T03:25:33.643430 | 2014-10-07T08:51:41 | 2014-10-07T08:51:41 | 23,663,355 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,080 | java | /**
*/
package IFML.Mobile;
import IFML.Core.NamedElement;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Device Screen</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link IFML.Mobile.MobileDeviceScreen#getHeigt <em>Heigt</em>}</li>
* <li>{@link IFML.Mobile.MobileDeviceScreen#getWidth <em>Width</em>}</li>
* <li>{@link IFML.Mobile.MobileDeviceScreen#getDensity <em>Density</em>}</li>
* </ul>
* </p>
*
* @see IFML.Mobile.MobilePackage#getMobileDeviceScreen()
* @model
* @generated
*/
public interface MobileDeviceScreen extends NamedElement {
/**
* Returns the value of the '<em><b>Heigt</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Heigt</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Heigt</em>' attribute.
* @see #setHeigt(float)
* @see IFML.Mobile.MobilePackage#getMobileDeviceScreen_Heigt()
* @model
* @generated
*/
float getHeigt();
/**
* Sets the value of the '{@link IFML.Mobile.MobileDeviceScreen#getHeigt <em>Heigt</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Heigt</em>' attribute.
* @see #getHeigt()
* @generated
*/
void setHeigt(float value);
/**
* Returns the value of the '<em><b>Width</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Width</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Width</em>' attribute.
* @see #setWidth(float)
* @see IFML.Mobile.MobilePackage#getMobileDeviceScreen_Width()
* @model
* @generated
*/
float getWidth();
/**
* Sets the value of the '{@link IFML.Mobile.MobileDeviceScreen#getWidth <em>Width</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Width</em>' attribute.
* @see #getWidth()
* @generated
*/
void setWidth(float value);
/**
* Returns the value of the '<em><b>Density</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Density</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Density</em>' attribute.
* @see #setDensity(float)
* @see IFML.Mobile.MobilePackage#getMobileDeviceScreen_Density()
* @model
* @generated
*/
float getDensity();
/**
* Sets the value of the '{@link IFML.Mobile.MobileDeviceScreen#getDensity <em>Density</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Density</em>' attribute.
* @see #getDensity()
* @generated
*/
void setDensity(float value);
} // MobileDeviceScreen
| [
"eric.umuhoza@gmail.com"
] | eric.umuhoza@gmail.com |
5ed10ba0ac5f5b443d4cf1791adbbba4a777cee5 | 406e2aec501192279f726176578f8bdda308a514 | /Module 4/01_Spring overview/exercise/converter/src/main/java/com/money/service/MoneyService.java | 455f68e1477b9ea4f82a4db7c9acea8b2cf2af32 | [] | no_license | minhtuan94/C1120G1-LE-HOANG-MINH-TUAN | 3eb85d26ae513053706c6884b6dc83aaec53b571 | 75d35c42fce96f9670e4a96f172aa93c4f7bde52 | refs/heads/main | 2023-04-22T04:39:33.975302 | 2021-05-12T18:25:52 | 2021-05-12T18:25:52 | 351,976,331 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 176 | java | package com.money.service;
//Đầu tiên tạo interface trong service để tạo sự phụ thuộc
public interface MoneyService {
double money(double a, double b);
}
| [
"minhhoangtuan21@gmail.com"
] | minhhoangtuan21@gmail.com |
f608a7c2cfadaa5d2138d713485faec01fdd0e68 | 2876bfaafb020ddf15ab01d03c26e552c9edd572 | /src/main/java/com/demooracle/controller/bean/CreateUserData.java | 4e25f67708e8055718dc49028c7603f9ee2250d4 | [] | no_license | LuisBonfa/demo-oracle-microweb | 56187a8d24d6fb0ee70aafc5ce825bbf5228b989 | 9b97b9a273299251f4b2e8bc6ca8bef47439d58a | refs/heads/master | 2020-06-13T17:07:04.073883 | 2019-07-01T18:46:04 | 2019-07-01T18:46:04 | 194,725,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,411 | java | package com.demooracle.controller.bean;
import net.sf.oval.constraint.EqualToField;
import net.sf.oval.constraint.Length;
import net.sf.oval.constraint.NotEmpty;
import net.sf.oval.constraint.NotNull;
public class CreateUserData {
/**
* User name.
*/
@NotNull
@NotEmpty
@Length(min = 5, max = 128)
private String name;
/**
* The user alias, or social name:
*/
@NotNull
@NotEmpty
private String alias;
/**
* The password
*/
@NotNull
@NotEmpty
@Length(min = 5, max = 64)
private String password;
/**
* The password confirmation
*/
@NotNull
@NotEmpty
@Length(min = 5, max = 64)
@EqualToField("password")
private String passwordConfirmation;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAlias() {
return alias;
}
public void setAlias(String alias) {
this.alias = alias;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getPasswordConfirmation() {
return passwordConfirmation;
}
public void setPasswordConfirmation(String passwordConfirmation) {
this.passwordConfirmation = passwordConfirmation;
}
}
| [
"luis.araujo01@fatec.sp.gov.br"
] | luis.araujo01@fatec.sp.gov.br |
261cdaf70f17bfcb631e1e5e416992b58423268f | 90dcce2dcb936945bca5d8e79c2eb8008a596d7d | /app/src/main/java/tk/wasdennnoch/androidn_ify/extracted/settingslib/UsageGraph.java | 71ae0a06fd37e96bef4af0f689731354c948ef5a | [
"Apache-2.0"
] | permissive | Freenore/AndroidN-ify | 270c293fe8188924f56bd1f92247b050047e50a3 | 706a751891fb6059d330b0615b574dbe82904d90 | refs/heads/master | 2021-06-05T08:18:12.082118 | 2016-09-12T15:55:35 | 2016-09-12T15:55:35 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,913 | java | /*
* Copyright (C) 2016 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package tk.wasdennnoch.androidn_ify.extracted.settingslib;
import android.annotation.Nullable;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.CornerPathEffect;
import android.graphics.DashPathEffect;
import android.graphics.LinearGradient;
import android.graphics.Paint;
import android.graphics.Paint.Cap;
import android.graphics.Paint.Join;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Shader.TileMode;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.SparseIntArray;
import android.util.TypedValue;
import android.view.View;
import tk.wasdennnoch.androidn_ify.R;
import tk.wasdennnoch.androidn_ify.utils.ResourceUtils;
@SuppressWarnings({"deprecation", "BooleanMethodIsAlwaysInverted", "SameParameterValue", "SuspiciousNameCombination"})
public class UsageGraph extends View {
private static final int PATH_DELIM = -1;
private final Paint mLinePaint;
private final Paint mFillPaint;
private final Paint mDottedPaint;
private final Drawable mDivider;
private final Drawable mTintedDivider;
private final int mDividerSize;
private final Path mPath = new Path();
// Paths in coordinates they are passed in.
private final SparseIntArray mPaths = new SparseIntArray();
// Paths in local coordinates for drawing.
private final SparseIntArray mLocalPaths = new SparseIntArray();
private final int mCornerRadius;
private int mAccentColor;
private boolean mShowProjection;
private boolean mProjectUp;
private float mMaxX = 100;
private float mMaxY = 100;
private float mMiddleDividerLoc = .5f;
private int mMiddleDividerTint = -1;
private int mTopDividerTint = -1;
public UsageGraph(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
//final Resources resources = context.getResources();
Resources res = ResourceUtils.getInstance(context).getResources();
mLinePaint = new Paint();
mLinePaint.setStyle(Style.STROKE);
mLinePaint.setStrokeCap(Cap.ROUND);
mLinePaint.setStrokeJoin(Join.ROUND);
mLinePaint.setAntiAlias(true);
mCornerRadius = res.getDimensionPixelSize(R.dimen.usage_graph_line_corner_radius);
mLinePaint.setPathEffect(new CornerPathEffect(mCornerRadius));
mLinePaint.setStrokeWidth(res.getDimensionPixelSize(R.dimen.usage_graph_line_width));
mFillPaint = new Paint(mLinePaint);
mFillPaint.setStyle(Style.FILL);
mDottedPaint = new Paint(mLinePaint);
mDottedPaint.setStyle(Style.STROKE);
float dots = res.getDimensionPixelSize(R.dimen.usage_graph_dot_size);
float interval = res.getDimensionPixelSize(R.dimen.usage_graph_dot_interval);
mDottedPaint.setStrokeWidth(dots * 3);
mDottedPaint.setPathEffect(new DashPathEffect(new float[] {dots, interval}, 0));
mDottedPaint.setColor(res.getColor(R.color.usage_graph_dots));
TypedValue v = new TypedValue();
context.getTheme().resolveAttribute(com.android.internal.R.attr.listDivider, v, true);
mDivider = context.getDrawable(v.resourceId);
mTintedDivider = context.getDrawable(v.resourceId);
mDividerSize = res.getDimensionPixelSize(R.dimen.usage_graph_divider_size);
}
void clearPaths() {
mPaths.clear();
}
void setMax(int maxX, int maxY) {
mMaxX = maxX;
mMaxY = maxY;
}
void setDividerLoc(int height) {
mMiddleDividerLoc = 1 - height / mMaxY;
}
void setDividerColors(int middleColor, int topColor) {
mMiddleDividerTint = middleColor;
mTopDividerTint = topColor;
}
public void addPath(SparseIntArray points) {
for (int i = 0; i < points.size(); i++) {
mPaths.put(points.keyAt(i), points.valueAt(i));
}
mPaths.put(points.keyAt(points.size() - 1) + 1, PATH_DELIM);
calculateLocalPaths();
postInvalidate();
}
void setAccentColor(int color) {
mAccentColor = color;
mLinePaint.setColor(mAccentColor);
updateGradient();
postInvalidate();
}
void setShowProjection(boolean showProjection, boolean projectUp) {
mShowProjection = showProjection;
mProjectUp = projectUp;
postInvalidate();
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
updateGradient();
calculateLocalPaths();
}
private void calculateLocalPaths() {
if (getWidth() == 0) return;
mLocalPaths.clear();
int pendingXLoc = 0;
int pendingYLoc = PATH_DELIM;
for (int i = 0; i < mPaths.size(); i++) {
int x = mPaths.keyAt(i);
int y = mPaths.valueAt(i);
if (y == PATH_DELIM) {
if (i == mPaths.size() - 1 && pendingYLoc != PATH_DELIM) {
// Connect to the end of the graph.
mLocalPaths.put(pendingXLoc, pendingYLoc);
}
// Clear out any pending points.
pendingYLoc = PATH_DELIM;
mLocalPaths.put(pendingXLoc + 1, PATH_DELIM);
} else {
final int lx = getX(x);
final int ly = getY(y);
pendingXLoc = lx;
if (mLocalPaths.size() > 0) {
int lastX = mLocalPaths.keyAt(mLocalPaths.size() - 1);
int lastY = mLocalPaths.valueAt(mLocalPaths.size() - 1);
if (lastY != PATH_DELIM && !hasDiff(lastX, lx) && !hasDiff(lastY, ly)) {
pendingYLoc = ly;
continue;
}
}
mLocalPaths.put(lx, ly);
}
}
}
private boolean hasDiff(int x1, int x2) {
return Math.abs(x2 - x1) >= mCornerRadius;
}
private int getX(float x) {
return (int) (x / mMaxX * getWidth());
}
private int getY(float y) {
return (int) (getHeight() * (1 - (y / mMaxY)));
}
private void updateGradient() {
mFillPaint.setShader(new LinearGradient(0, 0, 0, getHeight(),
getColor(mAccentColor, .2f), 0, TileMode.CLAMP));
}
private int getColor(int color, float alphaScale) {
return (color & (((int) (0xff * alphaScale) << 24) | 0xffffff));
}
@Override
protected void onDraw(Canvas canvas) {
// Draw lines across the top, middle, and bottom.
if (mMiddleDividerLoc != 0) {
drawDivider(0, canvas, mTopDividerTint);
}
drawDivider((int) ((canvas.getHeight() - mDividerSize) * mMiddleDividerLoc), canvas,
mMiddleDividerTint);
drawDivider(canvas.getHeight() - mDividerSize, canvas, -1);
if (mLocalPaths.size() == 0) {
return;
}
if (mShowProjection) {
drawProjection(canvas);
}
drawFilledPath(canvas);
drawLinePath(canvas);
}
private void drawProjection(Canvas canvas) {
mPath.reset();
int x = mLocalPaths.keyAt(mLocalPaths.size() - 2);
int y = mLocalPaths.valueAt(mLocalPaths.size() - 2);
mPath.moveTo(x, y);
mPath.lineTo(canvas.getWidth(), mProjectUp ? 0 : canvas.getHeight());
canvas.drawPath(mPath, mDottedPaint);
}
private void drawLinePath(Canvas canvas) {
mPath.reset();
mPath.moveTo(mLocalPaths.keyAt(0), mLocalPaths.valueAt(0));
for (int i = 1; i < mLocalPaths.size(); i++) {
int x = mLocalPaths.keyAt(i);
int y = mLocalPaths.valueAt(i);
if (y == PATH_DELIM) {
if (++i < mLocalPaths.size()) {
mPath.moveTo(mLocalPaths.keyAt(i), mLocalPaths.valueAt(i));
}
} else {
mPath.lineTo(x, y);
}
}
canvas.drawPath(mPath, mLinePaint);
}
private void drawFilledPath(Canvas canvas) {
mPath.reset();
float lastStartX = mLocalPaths.keyAt(0);
mPath.moveTo(mLocalPaths.keyAt(0), mLocalPaths.valueAt(0));
for (int i = 1; i < mLocalPaths.size(); i++) {
int x = mLocalPaths.keyAt(i);
int y = mLocalPaths.valueAt(i);
if (y == PATH_DELIM) {
mPath.lineTo(mLocalPaths.keyAt(i - 1), getHeight());
mPath.lineTo(lastStartX, getHeight());
mPath.close();
if (++i < mLocalPaths.size()) {
lastStartX = mLocalPaths.keyAt(i);
mPath.moveTo(mLocalPaths.keyAt(i), mLocalPaths.valueAt(i));
}
} else {
mPath.lineTo(x, y);
}
}
canvas.drawPath(mPath, mFillPaint);
}
private void drawDivider(int y, Canvas canvas, int tintColor) {
Drawable d = mDivider;
if (tintColor != -1) {
mTintedDivider.setTint(tintColor);
d = mTintedDivider;
}
d.setBounds(0, y, canvas.getWidth(), y + mDividerSize);
d.draw(canvas);
}
} | [
"leiter04@gmail.com"
] | leiter04@gmail.com |
5768293df655be6163ea8432510236445a8ac5e4 | a6a22e397eb9ce16b6466d9740cff4ea661cd530 | /src/main/java/com/vcc/recipe/recipe/service/impl/MealService.java | cf1237b126bebb33fc4b247c4d969ed753d29f26 | [
"MIT"
] | permissive | vcc1235/recipe | 2e2a0f901eeb51ef433e5241ac06eb39c9c9b1ae | a739e93b85cd126047fedc972e4a78e9385adbdb | refs/heads/master | 2022-06-21T13:11:59.884491 | 2019-09-09T11:03:11 | 2019-09-09T11:03:11 | 207,289,069 | 0 | 0 | MIT | 2022-06-17T02:26:51 | 2019-09-09T11:01:56 | Java | UTF-8 | Java | false | false | 4,512 | java | package com.vcc.recipe.recipe.service.impl;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.vcc.recipe.common.AbstractService;
import com.vcc.recipe.common.IOperations;
import com.vcc.recipe.recipe.mapper.IMealMapper;
import com.vcc.recipe.recipe.domain.Meal;
import com.vcc.recipe.recipe.service.IMealService;
import com.vcc.recipe.config.RecipyConfig;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
/**
*
* @author 吴彬 的 autoWeb 自动代码 网址 www.wubin9.com
* @data 2019年08月23日 22:53:10
* 此文件由 www.wubin9.com 网站的自动代码 autoWeb 自动生成。
* 可以根据需求随意修改,如果需要帮助,请联系 吴彬
* 联系方式:QQ 810978593 微信 wubin0830bingo 邮箱 wubin5922@dingtalk.com
*/
@Service("mealService")
public class MealService extends AbstractService<Meal> implements IMealService {
public MealService() {
this.setTableName("meal");
}
@Resource
private IMealMapper mealMapper;
@Override
protected IOperations<Meal> getMapper() {
return mealMapper;
}
@Override
public void setTableName(String tableName){
this.tableName = tableName;
}
@Override
public List<Meal> getMealList(Integer page, Integer pageSize) {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
linkedHashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
List<Meal> mealList = this.getList( linkedHashMap, page, pageSize );
return mealList;
}
@Override
public Integer getMealCount() {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
linkedHashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
int count = this.getCount( linkedHashMap, null );
return count;
}
@Override
public int addMeal(String name, String type) {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
linkedHashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
linkedHashMap.put( "meal_name = '"+name+"'"," and " );
linkedHashMap.put( "meal_type = '"+type+"'"," and " );
Meal one = this.getOne( linkedHashMap );
if (one != null){
return 0 ;
}
Meal meal = new Meal();
meal.setMealName( name );
meal.setMealType( type );
this.insert( meal );
if (meal.getMealId()>0){
return 1 ;
}else {
return -1 ;
}
}
@Override
public Meal getOneMeal(int mealId) {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
linkedHashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
linkedHashMap.put( "meal_id = '"+mealId+"'"," and ");
Meal meal = this.getOne( linkedHashMap );
return meal ;
}
@Override
public int updateMeal(int mealId, String name, String type) {
LinkedHashMap<String, String> hashMap = new LinkedHashMap<>();
hashMap.put( "meal_id = '"+mealId+"'","");
hashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'"," and ");
Meal meal = this.getOne( hashMap );
if (meal == null){ /// 不存在这个分类
return 0 ;
}
meal.setMealType( type );
meal.setMealName( name );
List<Meal> mealList = new ArrayList<>( );
mealList.add( meal );
return this.update( mealList ); /// 更新
}
@Override
public int deleteMeal(int mealId) {
LinkedHashMap<String, String> hashMap = new LinkedHashMap<>();
hashMap.put( "meal_id = '"+mealId+"'","");
Meal meal = this.getOne( hashMap );
if (meal == null){ /// 不存在这个分类
return 0 ;
}
meal.setTbStatus( RecipyConfig.TB_DELETE );
List<Meal> list = new ArrayList<>();
list.add( meal );
return this.update( list );
}
@Override
public List<Meal> searchMealList(String keyword) {
LinkedHashMap<String, String> linkedHashMap = new LinkedHashMap<>();
linkedHashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
linkedHashMap.put( "meal_type like '%"+keyword+"%'","and (");
linkedHashMap.put( "meal_name like '%"+keyword+"%')","or");
List<Meal> mealList = this.getAllList( linkedHashMap );
return mealList ;
}
/************************************* Api ************************************/
@Override
public List<Meal> getMealList(String type) {
LinkedHashMap<String, String> hashMap = new LinkedHashMap<>();
hashMap.put( RecipyConfig.TB_STATUS+"='"+RecipyConfig.TB_NORMAL+"'","");
hashMap.put( "meal_type = '"+type+"'"," and " );
List<Meal> allList = this.getAllList( hashMap );
return allList;
}
}
| [
"1041497818@qq.com"
] | 1041497818@qq.com |
53ee7904edc963b084b4e84fc0cd92b7eb46a1af | 1cc2e9074b60f3e7e2f2ed7642b478486db2a42e | /src/main/java/com/example/spring/boot/web/controller/BlogController.java | 2be7d2888dcd9a67ccb887806e263459ea961b08 | [] | no_license | Nisum-WSI/sample-spring5Reactive-mongoDB | 6f5468570756cccea9d32af7397a81bcabf6f275 | 42f7e77ec636136ada84bcf0bd4b367158fcf168 | refs/heads/master | 2020-03-22T03:13:37.275169 | 2018-11-06T08:48:51 | 2018-11-06T08:48:51 | 139,420,076 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,334 | java | package com.example.spring.boot.web.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.example.spring.boot.dao.entity.Blog;
import com.example.spring.boot.service.BlogService;
import lombok.extern.slf4j.Slf4j;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@Slf4j
@RestController
@RequestMapping("/api/v1/blog")
public class BlogController {
@Autowired
private BlogService blogService;
@GetMapping
public Flux<Blog> findAll() {
//log.debug("findAll Blog");
return blogService.findAll();
}
@GetMapping("/findbyTitle")
public Flux<Blog> findByTitle(@RequestParam String blogTitle) {
//log.debug("findByTitle Blog with blogTitle : {}", blogTitle);
return blogService.findByTitle(blogTitle);
}
@GetMapping("/{id}")
public Mono<Blog> findOne(@PathVariable String id) {
//log.debug("findOne Blog with id : {}", id);
return blogService.findOne(id);
}
@PostMapping
@ResponseStatus(HttpStatus.CREATED)
public Mono<Blog> create(@RequestBody Blog blog) {
//log.debug("create Blog with blog : {}", blog);
return blogService.createBlog(blog);
}
@DeleteMapping("/{id}")
public Mono<Boolean> delete(@PathVariable String id) {
//log.debug("delete Blog with id : {}", id);
return blogService.delete(id);
}
@PutMapping("/{id}")
public Mono<Blog> updateBlog(@RequestBody Blog blog, @PathVariable String id) {
//log.debug("updateBlog Blog with id : {} and blog : {}", id, blog);
return blogService.updateBlog(blog, id);
}
}
| [
"vjchaitanya@gmail.com"
] | vjchaitanya@gmail.com |
fa4071c7d95a2c6e27b308e94e8c06cd38872b79 | 4dc1b766005c902c5e353f695bebe352edc63a62 | /molgenis-observ/src/main/generated-sources/org/molgenis/protocol/excel/WorkflowElementParameterExcelReader.java | 3126db87a5847abdfb16677d482d0884ae03782f | [] | no_license | mswertz/molgenis-maven-experimental | 89e4e9b11a8b4b64dc7a186aacc69e796a011b65 | 577702028c2f93e81351d54624ee07be79359b77 | refs/heads/master | 2020-06-02T12:35:26.359066 | 2013-01-02T10:34:44 | 2013-01-02T10:34:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,900 | java |
/* File: observ/model/WorkflowElementParameter.java
* Copyright: GBIC 2000-2012, all rights reserved
* Date: October 11, 2012
*
* generator: org.molgenis.generators.excel.ExcelReaderGen 4.0.0-testing
*
*
* THIS FILE HAS BEEN GENERATED, PLEASE DO NOT EDIT!
*/
package org.molgenis.protocol.excel;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import jxl.Cell;
import jxl.Sheet;
import org.apache.log4j.Logger;
import org.molgenis.framework.db.Database;
import org.molgenis.framework.db.DatabaseException;
import org.molgenis.framework.db.Database.DatabaseAction;
import org.molgenis.util.CsvWriter;
import org.molgenis.util.SimpleTuple;
import org.molgenis.util.Tuple;
import org.molgenis.protocol.WorkflowElementParameter;
import org.molgenis.protocol.csv.WorkflowElementParameterCsvReader;
/**
* Reads WorkflowElementParameter from Excel file.
*/
public class WorkflowElementParameterExcelReader
{
public static final transient Logger logger = Logger.getLogger(WorkflowElementParameterExcelReader.class);
/**
* Imports WorkflowElementParameter from a workbook sheet.
*/
public int importSheet(final Database db, Sheet sheet, final Tuple defaults, final DatabaseAction dbAction, final String missingValue) throws DatabaseException, IOException, Exception
{
File tmpWorkflowElementParameter = new File(System.getProperty("java.io.tmpdir") + File.separator + "tmpWorkflowElementParameter.txt");
if(tmpWorkflowElementParameter.exists()){
boolean deleteSuccess = tmpWorkflowElementParameter.delete();
if(!deleteSuccess){
throw new Exception("Deletion of tmp file 'tmpWorkflowElementParameter.txt' failed, cannot proceed.");
}
}
boolean createSuccess = tmpWorkflowElementParameter.createNewFile();
if(!createSuccess){
throw new Exception("Creation of tmp file 'tmpWorkflowElementParameter.txt' failed, cannot proceed.");
}
boolean fileHasHeaders = writeSheetToFile(sheet, tmpWorkflowElementParameter);
if(fileHasHeaders){
int count = new WorkflowElementParameterCsvReader().importCsv(db, tmpWorkflowElementParameter, defaults, dbAction, missingValue);
tmpWorkflowElementParameter.delete();
return count;
}else{
tmpWorkflowElementParameter.delete();
return 0;
}
}
public List<String> getNonEmptyHeaders(Sheet sheet){
List<String> headers = new ArrayList<String>();
Cell[] headerCells = sheet.getRow(0); //assume headers are on first line
for(int i = 0; i < headerCells.length; i++){
if(!headerCells[i].getContents().equals("")){
headers.add(headerCells[i].getContents());
}
}
return headers;
}
private boolean writeSheetToFile(Sheet sheet, File file) throws FileNotFoundException{
List<String> headers = new ArrayList<String>();
Cell[] headerCells = sheet.getRow(0); //assume headers are on first line
if(headerCells.length == 0){
return false;
}
ArrayList<Integer> namelessHeaderLocations = new ArrayList<Integer>(); //allow for empty columns, also column order does not matter
for(int i = 0; i < headerCells.length; i++){
if(!headerCells[i].getContents().equals("")){
headers.add(headerCells[i].getContents());
}else{
headers.add("nameless"+i);
namelessHeaderLocations.add(i);
}
}
PrintWriter pw = new PrintWriter(file);
CsvWriter cw = new CsvWriter(pw, headers);
cw.setMissingValue("");
cw.writeHeader();
for(int rowIndex = 1; rowIndex < sheet.getRows(); rowIndex++){
Tuple t = new SimpleTuple();
int colIndex = 0;
for(Cell c : sheet.getRow(rowIndex)){
if(!namelessHeaderLocations.contains(colIndex) && colIndex < headers.size() && c.getContents() != null){
t.set(headers.get(colIndex), c.getContents());
}
colIndex++;
}
cw.writeRow(t);
}
cw.close();
return true;
}
} | [
"m.a.swertz@rug.nl"
] | m.a.swertz@rug.nl |
085304b2288bb8b6ad8f09c334202c13040c9f53 | 0f140d04df02519e3f02c60fb4014e01e4c4f10c | /app/src/main/java/com/nozom/darrabny/adapter/notificationAdapter.java | 277310fc96917064136b396061290874997e3851 | [] | no_license | abdoawd/darrabny | 3efb34a676239753379fb6856ae165dad4b02759 | c1f077be47dee6eb736527c923f573c3dd310322 | refs/heads/master | 2020-04-02T19:36:02.371087 | 2016-06-04T20:41:52 | 2016-06-04T20:41:52 | 60,429,203 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,202 | java | package com.nozom.darrabny.adapter;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import com.nozom.darrabny.R;
import com.nozom.darrabny.main.Comment;
import com.nozom.darrabny.main.Constants;
import com.nozom.darrabny.student.View_training;
import com.nozom.darrabny.student.requestStatus;
import java.util.List;
/**
* Created by abdelgawad on 23/04/16.
*/
public class notificationAdapter extends BaseAdapter {
private List<Comment> comments;
private Context context;
private static LayoutInflater inflater = null;
public notificationAdapter(List<Comment> comments, Context context) {
this.comments = comments;
this.context = context;
inflater = (LayoutInflater) context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return comments.size();
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
View vi = convertView;
final CustomCompanyAdapter.ViewHolder holder;
if (convertView == null) {
/****** Inflate tabitem.xml file for each row ( Defined below ) *******/
vi = inflater.inflate(R.layout.train_item, null);
/****** View Holder Object to contain tabitem.xml file elements ******/
holder = new CustomCompanyAdapter.ViewHolder();
holder.name = (TextView) vi.findViewById(R.id.view_train_name);
holder.requests = (TextView) vi.findViewById(R.id.view_train_requests);
holder.type = (TextView) vi.findViewById(R.id.view_train_type);
/************ Set holder with LayoutInflater ************/
vi.setTag(holder);
} else
holder = (CustomCompanyAdapter.ViewHolder) vi.getTag();
if (comments.size() <= 0) {
holder.name.setText(Constants.NODATA);
} else {
/***** Get each Model object from Arraylist ********/
/************ Set Model values in Holder elements ***********/
holder.name.setText(comments.get(position).getTraining().getName());
holder.requests.setText(comments.get(position).getStatus());
holder.type.setText(comments.get(position).getUser().getEmail());
vi.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent i = new Intent(context.getApplicationContext(), requestStatus.class);
i.putExtra("status", comments.get(position).getStatus());
i.putExtra("id", comments.get(position).getId());
context.startActivity(i);
}
});
}
return vi;
}
}
| [
"awadabdo@gmail.com.git"
] | awadabdo@gmail.com.git |
dd0fae3d60901b46ad5f29eb6644764e02f5df92 | 8f39e073261112e6e3047fbdb34a6a210487780e | /hzz_core/src/main/java/com/saili/hzz/tag/core/easyui/UserSelectTag.java | 012bb0204ed68d6a9059f5470486d450ea6e55ae | [] | no_license | fisher-hub/hzz | 4c88846a8d6168027c490331c94a686ccfe08b46 | 0be1569e517c865cf265d6ff0908cf8e1b1b6973 | refs/heads/master | 2020-12-10T06:49:48.892278 | 2019-11-05T01:10:18 | 2019-11-05T01:10:18 | 233,527,357 | 1 | 1 | null | 2020-01-13T06:32:55 | 2020-01-13T06:32:54 | null | UTF-8 | Java | false | false | 6,194 | java | package com.saili.hzz.tag.core.easyui;
import org.apache.commons.lang.StringUtils;
import com.saili.hzz.core.util.MutiLangUtil;
import com.saili.hzz.core.util.oConvertUtils;
import javax.servlet.jsp.JspTagException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import java.io.IOException;
/**
*
* 用户选择弹出组件
*
* @author: wangkun
* @date: 日期:2015-3-27
* @version 1.0
*/
public class UserSelectTag extends TagSupport {
private static final long serialVersionUID = 1;
private String title; //标题
private String selectedNamesInputId; // 用于显示已选择用户的用户名 input的id
private String selectedIdsInputId; // 用于记录已选择用户的用户id input的id
private boolean hasLabel = false; //是否显示lable,默认不显示
private String userNamesDefalutVal; //用户名默认值
private String userIdsDefalutVal; //用户ID默认值
private String readonly = "readonly"; // 只读属性
private String inputWidth; //输入框宽度
private String windowWidth; //弹出窗口宽度
private String windowHeight; //弹出窗口高度
private String callback;//自定义回掉函数
public String getUserIdsDefalutVal() {
return userIdsDefalutVal;
}
public void setUserIdsDefalutVal(String userIdsDefalutVal) {
this.userIdsDefalutVal = userIdsDefalutVal;
}
public String getSelectedIdsInputId() {
return selectedIdsInputId;
}
public void setSelectedIdsInputId(String selectedIdsInputId) {
this.selectedIdsInputId = selectedIdsInputId;
}
public boolean isHasLabel() {
return hasLabel;
}
public void setHasLabel(boolean hasLabel) {
this.hasLabel = hasLabel;
}
public String getReadonly() {
return readonly;
}
public void setReadonly(String readonly) {
this.readonly = readonly;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getSelectedNamesInputId() {
return selectedNamesInputId;
}
public void setSelectedNamesInputId(String _selectedNamesInputId) {
this.selectedNamesInputId = _selectedNamesInputId;
}
public String getInputWidth() {
return inputWidth;
}
public void setInputWidth(String inputWidth) {
this.inputWidth = inputWidth;
}
public String getWindowWidth() {
return windowWidth;
}
public void setWindowWidth(String windowWidth) {
this.windowWidth = windowWidth;
}
public String getWindowHeight() {
return windowHeight;
}
public void setWindowHeight(String windowHeight) {
this.windowHeight = windowHeight;
}
public String getUserNamesDefalutVal() {
return userNamesDefalutVal;
}
public void setUserNamesDefalutVal(String userNamesDefalutVal) {
this.userNamesDefalutVal = userNamesDefalutVal;
}
public String getCallback() {
if(oConvertUtils.isEmpty(callback)){
callback = "callbackUserSelect";
}
return callback;
}
public void setCallback(String callback) {
this.callback = callback;
}
public int doStartTag() throws JspTagException {
return EVAL_PAGE;
}
public int doEndTag() throws JspTagException {
JspWriter out = null;
try {
out = this.pageContext.getOut();
out.print(end().toString());
out.flush();
} catch (IOException e) {
e.printStackTrace();
}finally{
try {
out.clear();
out.close();
} catch (Exception e2) {
}
}
return EVAL_PAGE;
}
public StringBuffer end() {
StringBuffer sb = new StringBuffer();
if (StringUtils.isBlank(selectedNamesInputId)) {
selectedNamesInputId = "userNames"; // 默认id
}
if(StringUtils.isBlank(title)){
title = "用户名称";
}
if(StringUtils.isBlank(inputWidth)){
inputWidth = "150px";
}
if(StringUtils.isBlank(windowWidth)){
windowWidth = "400px";
}
if(StringUtils.isBlank(windowHeight)){
windowHeight = "350px";
}
if(hasLabel && oConvertUtils.isNotEmpty(title)){
sb.append(title + ":");
}
sb.append("<input class=\"inuptxt\" readonly=\""+readonly+"\" type=\"text\" id=\"" + selectedNamesInputId + "\" name=\"" + selectedNamesInputId + "\" style=\"width: "+inputWidth+"\" onclick=\"openUserSelect()\" ");
if(StringUtils.isNotBlank(userNamesDefalutVal)){
sb.append(" value=\""+userNamesDefalutVal+"\"");
}
sb.append(" />");
if(oConvertUtils.isNotEmpty(selectedIdsInputId)){
sb.append("<input class=\"inuptxt\" id=\"" + selectedIdsInputId + "\" name=\"" + selectedIdsInputId + "\" type=\"hidden\" ");
if(StringUtils.isNotBlank(userIdsDefalutVal)){
sb.append(" value=\""+userIdsDefalutVal+"\"");
}
sb.append("/>");
}
String commonConfirm = MutiLangUtil.getLang("common.confirm");
String commonCancel = MutiLangUtil.getLang("common.cancel");
sb.append("<script type=\"text/javascript\">");
sb.append("function openUserSelect() {");
sb.append(" $.dialog({content: 'url:userController.do?userSelect', zIndex: getzIndex(), title: '" + title + "', lock: true, width: '" + windowWidth + "', height: '" + windowHeight + "', opacity: 0.4, button: [");
sb.append(" {name: '" + commonConfirm + "', callback: "+getCallback()+", focus: true},");
sb.append(" {name: '" + commonCancel + "', callback: function (){}}");
sb.append(" ]});");
sb.append("}");
sb.append("function callbackUserSelect() {");
sb.append("var iframe = this.iframe.contentWindow;");
sb.append("var rowsData = iframe.$('#userList1').datagrid('getSelections');");
sb.append("if (!rowsData || rowsData.length==0) {");
sb.append("tip('<t:mutiLang langKey=\"common.please.select.edit.item\"/>');");
sb.append("return;");
sb.append("}");
sb.append(" var ids='',names='';");
sb.append("for(i=0;i<rowsData.length;i++){");
sb.append(" var node = rowsData[i];");
sb.append(" ids += node.id+',';");
sb.append(" names += node.realName+',';");
sb.append("}");
sb.append("$('#" + selectedNamesInputId + "').val(names);");
sb.append("$('#" + selectedNamesInputId + "').blur();");
if(oConvertUtils.isNotEmpty(selectedIdsInputId)){
sb.append("$('#" + selectedIdsInputId + "').val(ids);");
}
sb.append("}");
sb.append("</script>");
return sb;
}
}
| [
"whuab_mc@163.com"
] | whuab_mc@163.com |
ccdec75dbdf187012f91bf98707f46fec5f5040d | 2c7bbc8139c4695180852ed29b229bb5a0f038d7 | /com/facebook/imagepipeline/memory/PoolParams.java | e9c3186508fa348a0c650cd3f221913b81cfb68a | [] | no_license | suliyu/evolucionNetflix | 6126cae17d1f7ea0bc769ee4669e64f3792cdd2f | ac767b81e72ca5ad636ec0d471595bca7331384a | refs/heads/master | 2020-04-27T05:55:47.314928 | 2017-05-08T17:08:22 | 2017-05-08T17:08:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,142 | java | //
// Decompiled by Procyon v0.5.30
//
package com.facebook.imagepipeline.memory;
import com.facebook.common.internal.Preconditions;
import android.util.SparseIntArray;
public class PoolParams
{
public final SparseIntArray bucketSizes;
public final int maxBucketSize;
public final int maxNumThreads;
public final int maxSizeHardCap;
public final int maxSizeSoftCap;
public final int minBucketSize;
public PoolParams(final int n, final int n2, final SparseIntArray sparseIntArray) {
this(n, n2, sparseIntArray, 0, Integer.MAX_VALUE, -1);
}
public PoolParams(final int maxSizeSoftCap, final int maxSizeHardCap, final SparseIntArray bucketSizes, final int minBucketSize, final int maxBucketSize, final int maxNumThreads) {
Preconditions.checkState(maxSizeSoftCap >= 0 && maxSizeHardCap >= maxSizeSoftCap);
this.maxSizeSoftCap = maxSizeSoftCap;
this.maxSizeHardCap = maxSizeHardCap;
this.bucketSizes = bucketSizes;
this.minBucketSize = minBucketSize;
this.maxBucketSize = maxBucketSize;
this.maxNumThreads = maxNumThreads;
}
}
| [
"sy.velasquez10@uniandes.edu.co"
] | sy.velasquez10@uniandes.edu.co |
e68c7fd4ae498a47eeab49737c4fa20d85091bda | 0331485971a8fe4effb3f765ba0ca524603518ed | /src/leson1/task2/Save.java | 72c8065d748b45bcdc747bc4b89f591d9a4284a3 | [] | no_license | AndriBunko/JavaPro_homeWork | 892cc2a25885de31c3e14c03eadb2166a7b09a8a | d60e03784c2a6a60689400d0928152d46f8a6855 | refs/heads/master | 2021-06-22T20:06:49.688639 | 2017-08-15T09:09:24 | 2017-08-15T09:09:24 | 100,252,147 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 335 | java | package leson1.task2;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by Andrew on 14.08.2017.
*/
@Target(value= ElementType.METHOD)
@Retention(value = RetentionPolicy.RUNTIME)
public @interface Save {
}
| [
"andr1bunk02@gmail.com"
] | andr1bunk02@gmail.com |
dddff950f295fbb88fe24483038398506e9e81fe | f97ba375da68423d12255fa8231365104867d9b0 | /study-notes/lang-collection/java/14-正则表达式/src/com/coderZsq/Main.java | 7d160ecee065ac850f166d34109683d4f2c8c3cf | [
"MIT"
] | permissive | lei720/coderZsq.practice.server | 7a728612e69c44e0877c0153c828b50d8ea7fa7c | 4ddf9842cd088d4a0c2780ac22d41d7e6229164b | refs/heads/master | 2023-07-16T11:21:26.942849 | 2021-09-08T04:38:07 | 2021-09-08T04:38:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,751 | java | package com.coderZsq;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class Main {
public static void main(String[] args) {
/*
* 字符串的合法验证
* 在开发中,经常会对一些字符串进行合法验证
* 6-18个字符,可使用字母、数字、下划线,需以字母开头
* */
/*
* 自己编写验证逻辑
* */
{
// 必须是6-18个字符 false
System.out.println(validate("12345"));
// 必须以字母开头 false
System.out.println(validate("123456"));
// true
System.out.println(validate("vv123_456"));
// 必须由字母, 数字, 下划线组成 false
System.out.println(validate("vv123+/?456"));
}
/*
* 使用正则表达式
*
* [a-zA-Z]\w{5,17}是一个正则表达式
* 用非常精简的语法取代了复杂的验证逻辑
* 极大地提高了开发效率
*
* 正则表达式的英文
* Regex Expression
*
* 正则表达式是一种通用的技术,适用于绝大多数流行编程语言
*
* // JavaScript中的正则表达式
* const regex = /[a-zA-Z]\w{5,17}/;
* regex.test('12345') // false
* regex.test('123456') // false
* regex.test('vv123_456') // true
* regex.test('vv123+/?456') // false
* */
{
String regex = "[a-zA-Z]\\w{5,17}";
"12345".matches(regex); // false
"123456".matches(regex); // false
"vv123_456".matches(regex); // true
"vv123+/?456".matches(regex); // false
}
/*
* 单字符匹配
*
* 语法 含义
* [abc] a、b、c
* [^abc] 除了 a、b、c 以外的任意字符
* [a-zA-Z] 从a到z、从A到Z
* [a-d[m-p]] [a-dm-p](并集)
* [a-z&&[def]] d、e、f(交集)
* [a-z&&[^bc]] [ad-z](差集,从 [a-z] 中减去 [bc])
* [a-z&&[^m-p]] [a-lq-z](差集,从 [a-z] 中减去 [m-p])
* */
/*
* 单字符匹配
* */
{
// 等价于[b|c|r]at, (b|c|r)at
String regex = "[bcr]at";
"bat".matches(regex); // true
"cat".matches(regex); // true
"rat".matches(regex); // true
"hat".matches(regex); // false
}
{
String regex = "[^bcr]at";
"bat".matches(regex); // false
"cat".matches(regex); // false
"rat".matches(regex); // false
"hat".matches(regex); // true
}
{
String regex = "foo[1-5]";
"foo3".matches(regex); // true
"foo6".matches(regex); // false
}
{
String regex = "foo[^1-5]";
"foo3".matches(regex); // false
"foo6".matches(regex); // true
}
{
String regex = "foo1-5";
"foo1-5".matches(regex); // true
"foo1".matches(regex); // false
"foo5".matches(regex); // false
}
{
String regex = "[0-4[6-8]]";
"5".matches(regex); // false
"7".matches(regex); // true
"9".matches(regex); // false
}
{
String regex = "[0-9&&[^345]]";
"2".matches(regex); // true
"3".matches(regex); // false
"4".matches(regex); // false
"5".matches(regex); // false
"6".matches(regex); // true
}
{
String regex = "[0-9&&[345]]";
"2".matches(regex); // false
"3".matches(regex); // true
"4".matches(regex); // true
"5".matches(regex); // true
"6".matches(regex); // false
}
/*
* 预定义字符
* 语法 含义
* . 任意字符
* \d [0-9](数字)
* \D [^0-9](非数字)
* \s [ \t\n\f\r](空白)
* \S [^\s](非空白)
* \w [a-zA-Z_0-9](单词)
* \W [^\w](非单词)
* 以 1 个反斜杠(\)开头的字符会被当做转义字符处理
* 因此,为了在正则表达式中完整地表示预定义字符,需要以 2 个反斜杠开头,比如"\\d"
* */
/*
* 预定义字符
* */
{
String regex = ".";
"@".matches(regex); // true
"c".matches(regex); // true
"6".matches(regex); // true
".".matches(regex); // true
}
{
String regex = "\\.";
"@".matches(regex); // false
"c".matches(regex); // false
"6".matches(regex); // false
".".matches(regex); // true
}
{
String regex = "\\[123\\]";
"1".matches(regex); // false
"2".matches(regex); // false
"3".matches(regex); // false
"[123]".matches(regex); // true
}
{
String regex = "\\d";
"c".matches(regex); // false
"6".matches(regex); // true
}
{
String regex = "\\D";
"c".matches(regex); // true
"6".matches(regex); // false
}
{
String regex = "\\s";
"\t".matches(regex); // true
"\n".matches(regex); // true
"\f".matches(regex); // true
"\r".matches(regex); // true
" ".matches(regex); // true
"6".matches(regex); // false
}
{
String regex = "\\S";
"\t".matches(regex); // false
"\n".matches(regex); // false
"\f".matches(regex); // false
"\r".matches(regex); // false
" ".matches(regex); // false
"6".matches(regex); // true
}
{
String regex = "\\w";
"_".matches(regex); // true
"c".matches(regex); // true
"6".matches(regex); // true
"+".matches(regex); // false
}
{
String regex = "\\W";
"_".matches(regex); // false
"c".matches(regex); // false
"6".matches(regex); // false
"+".matches(regex); // true
}
/*
* 量词(Quantifier)
*
* 贪婪(Greedy) 勉强(Reluctant) 独占(Possessive) 含义
* X{n} X{n}? X{n}+ X出现n次
* X{n,m} X{n,m}? X{n,m}+ X出现n到m次
* X{n,} X{n,}? X{n,}+ X出现至少n次
* X? X?? X?+ X{0,1}(X 出现 0 次或者 1 次)
* X* X*? X*+ X{0,}(X 出现任意次)
* X+ X+? X++ X{1,}(X 至少出现 1 次)
* */
/*
* 量词 - 示例
* */
{
String regex = "6{3}";
"66".matches(regex); // false
"666".matches(regex); // true
"6666".matches(regex); // false
}
{
String regex = "6{2,4}";
"6".matches(regex); // false
"66".matches(regex); // true
"666".matches(regex); // true
"6666".matches(regex); // true
"66666".matches(regex); // false
}
{
String regex = "6{2,}";
"6".matches(regex); // false
"66".matches(regex); // true
"666".matches(regex); // true
"6666".matches(regex); // true
"66666".matches(regex); // true
}
{
String regex = "6?";
"".matches(regex); // true
"6".matches(regex); // true
"66".matches(regex); // false
}
{
String regex = "6*";
"".matches(regex); // true
"6".matches(regex); // true
"66".matches(regex); // true
}
{
String regex = "6+";
"".matches(regex); // false
"6".matches(regex); // true
"66".matches(regex); // true
}
/*
* Pattern、Matcher
*
* String 的 matches 方法底层用到了 Pattern、Matcher 两个类
* */
// java.lang.String
// public boolean matches(String regex) {
// return Pattern.matches(regex, this);
// }
// java.util.regex.Pattern
// public static boolean matches(String regex, CharSequence input) {
// Pattern p = Pattern.compile(regex);
// Matcher m = p.matcher(input);
// return m.matches();
// }
/*
* Matcher常用方法
* */
// 如果整个input与regex匹配, 就返回true
// public boolean matches();
// 如果从input中找到了与regex匹配的子序列, 就返回true
// 如果匹配成功, 可以通过start, end, group方法获取更多信息
// 每次的查找范围会先删除此前已经查找过的范围
// public boolean find();
// 返回上一次匹配成功的开始索引
// public int start();
// 返回上一次匹配成功的结束索引
// public int end();
// 返回上一次匹配成功的input子序列
// public String group();
/*
* Matcher - 示例
* */
{
String regex = "123";
findAll(regex, "123");
// "123", [0, 3)
findAll(regex, "6_123_123_123_7");
// "123", [2, 5)
// "123", [6, 9)
// "123", [10, 13)
}
{
String regex = "[abc]{3}";
findAll(regex, "abccabaaaccbbbc");
// "abc", [0, 3)
// "cab", [3, 6)
// "aaa", [6, 9)
// "ccb", [9, 12)
// "bbc", [12, 15)
}
{
String regex = "\\d{2}";
findAll(regex, "0_12_345_67_8");
// "12", [2, 4)
// "34", [5, 7)
// "67", [9, 11)
}
{
String input = "";
findAll("a?", input);
// "", [0, 0)
findAll("a*", input);
// "", [0, 0)
findAll("a+", input);
// No match.
}
{
String input = "a";
findAll("a?", input);
// "a", [0, 1)
// "", [1, 1)
findAll("a*", input);
// "a", [0, 1)
// "", [1, 1)
findAll("a+", input);
// "a", [0, 1)
}
{
String input = "abbaaa";
findAll("a?", input);
// "a", [0, 1)
// "", [1, 1)
// "", [2, 2)
// "a", [3, 4)
// "a", [4, 5)
// "a", [5, 6)
// "", [6, 6)
findAll("a*", input);
// "a", [0, 1)
// "", [1, 1)
// "", [2, 2)
// "aaa", [3, 6)
// "", [6, 6)
findAll("a+", input);
// "a", [0, 1)
// "aaa", [3, 6)
}
/*
* Matcher – 贪婪、勉强、独占的区别
*
* 贪婪
* 先吞掉整个 input 进行匹配
* 若匹配失败,则吐出最后一个字符
* 然后再次尝试匹配,重复此过程,直到匹配成功
*
* 勉强
* 先吞掉 input 的第一个字符进行匹配
* 若匹配失败,则再吞掉下一个字符
* 然后再次尝试匹配,重复此过程,直到匹配成功
*
* 独占
* 吞掉整个 input 进行唯一的一次匹配
* */
{
String input = "afooaaaaaafooa";
findAll(".*foo", input);
// "afooaaaaaafoo", [0, 13)
findAll(".*?foo", input);
// "afoo", [0, 4)
// "aaaaaafoo", [4, 13)
findAll(".*+foo", input);
// No match.
}
/*
* 捕获组(Capturing Group)
* */
{
String regex1 = "dog{3}";
"doggg".matches(regex1);
String regex2 = "[dog]{3}";
"ddd".matches(regex2); // true
"ooo".matches(regex2); // true
"ggg".matches(regex2); // true
"dog".matches(regex2); // true
"gog".matches(regex2); // true
"gdo".matches(regex2); // true
String regex3 = "(dog){3}";
"dogdogdog".matches(regex3); // true
}
/*
* 捕获组 – 反向引用(Backreference)
*
* 反向引用(Backreference)
* 可以使用反斜杠(\)+ 组编号(从 1 开始)来引用组的内容
*
* ((A)(B(C))) 一共有 4 个组
* 编号1:((A)(B(C)))
* 编号2:(A)
* 编号3:(B(C))
* 编号4:(C)
* */
{
String regex = "(\\d\\d)\\1";
"1212".matches(regex); // true
"1234".matches(regex); // false
}
{
String regex = "([a-z]{2})([A-Z]{2})\\2\\1";
"coderZsqPKPKcoderZsq".matches(regex); // true
"coderZsqPKcoderZsqPK".matches(regex); // false
}
{
String regex = "((I)( Love( You)))\\3{2}";
"I Love You Love You Love You".matches(regex);
}
/*
* 边界匹配符( Boundary Matcher)
*
* 语法 含义
* \b 单词边界
* \B 非单词边界
* ^ 一行的开头
* $ 一行的结尾
* \A 输入的开头
* \z 输入的结尾
* \Z 输入的结尾(结尾可以有终止符)
* \G 上一次匹配的结尾
* */
/*
* 一些概念
*
* 终止符(Final Terminator、Line Terminator)
* \r(回车符)、\n(换行符)、\r\n(回车换行符)
*
* 输入:整个字符串
*
* 一行:以终止符(或整个输入的结尾)结束的字符串片段
* 如果输入是
* 那么 3 个 dog 都是一行
* */
/*
* 边界匹配符 - 单词边界
* */
{
String regex = "\\bdog\\b";
findAll(regex, "This is a dog.");
// "dog", [10, 13)
findAll(regex, "This is a doggie.");
// No match.
findAll(regex, "dog is cute");
// "dog", [0, 3)
findAll(regex, "I love cat,dog,pig.");
// "dog", [11, 14)
}
{
String regex = "\\bdog\\B";
findAll(regex, "This is a dog.");
// No match.
findAll(regex, "This is a doggie.");
// "dog", [10, 13)
findAll(regex, "dog is cute");
// No match.
findAll(regex, "I love cat,dog,pig.");
// No match.
}
/*
* 边界匹配符 - 示例
* */
{
String regex = "^dog$";
findAll(regex, "dog");
// "dog", [0, 3)
findAll(regex, " dog");
// No match.
}
{
findAll("\\s*dog$", " dog");
// " dog", [0, 9)
findAll("^dog\\w*", "dogblahblah");
// "dogblahblah", [0, 11)
}
{
String regex = "\\Gdog";
findAll(regex, "dog");
// "dog", [0, 3)
findAll(regex, "dog dog");
// "dog", [0, 3)
findAll(regex, "dogdog");
// "dog", [0, 3)
// "dog", [3, 6)
}
/*
* 常用模式
* 模式 含义 等价的正则写法
* DOTALL 单行模式(.可以匹配任意字符,包括终止符) (?s)
* MULTILINE 多行模式(^、$ 才能真正匹配一行的开头和结尾) (?m)
* CASE_INSENSITIVE 不区分大小写 (?i)
* */
/*
* 常用模式 - CASE_INSENSITIVE
* */
{
String regex = "dog";
String input = "Dog_dog_DOG";
findAll(regex, input);
// "dog", [4, 7)
findAll(regex, input, Pattern.CASE_INSENSITIVE);
// "Dog", [0, 3)
// "dog", [4, 7)
// "DOG", [8, 11)
findAll("(?i)dog", input);
// "Dog", [0, 3)
// "dog", [4, 7)
// "DOG", [8, 11)
}
/*
* 常用模式 - DOTALL, MULTILINE
* */
{
String regex = "^dog$";
String input = "dog\ndog\rdog";
findAll(regex, input);
// No match.
findAll(regex, input, Pattern.DOTALL);
// No match.
findAll(regex, input, Pattern.MULTILINE);
// "dog", [0, 3)
// "dog", [4, 7)
// "dog", [8, 11)
findAll(regex, input, Pattern.DOTALL | Pattern.MULTILINE);
// "dog", [0, 3)
// "dog", [4, 7)
// "dog", [8, 11)
}
/*
* 边界匹配符 - \A, \z
* */
{
String regex = "\\Adog\\z";
findAll(regex, "dog");
// "dog", [0, 3)
findAll(regex, "dog\n");
// No match.
findAll(regex, "dog\ndog\rdog");
// No match.
findAll(regex, "dog\ndog\rdog", Pattern.MULTILINE);
// No match.
}
/*
* 边界匹配符 - \A, \Z
* */
{
String regex = "\\Adog\\Z";
findAll(regex, "dog");
// "dog", [0, 3)
findAll(regex, "dog\n");
// "dog", [0, 3)
findAll(regex, "dog\ndog\rdog");
// No match.
findAll(regex, "dog\ndog\rdog", Pattern.MULTILINE);
// No match.
}
/*
* 常用正则表达式
*
* 正则表达式在线测试
* https://c.runoob.com/front-end/854
*
* 需求 正则表达式
* 18 位身份证号码 \d{17}[\dXx]
* 中文字符 [\u4e00-\u9fa5]
*
* */
/*
* String 类与正则表达式
*
* String 类中接收正则表达式作为参数的常用方法有
* */
// public String replaceAll(String regex, String replacement)
// public String replaceFirst(String regex, String replacement)
// public String[] split(String regex)
/*
* 练习 – 替换字符串中的单词
*
* 将单词 row 换成单词 line
* */
{
String s1 = "The row we are looking for is row 8.";
// The line we are looking for is line 8.
String s2 = s1.replace("row", "line");
// The line we are looking for is line 8.
String s3 = s1.replaceAll("\\brow\\b", "line");
}
{
String s1 = "Tomorrow I will wear in brown standing in row 10.";
// Tomorline I will wear in brown standing in line 10.
String s2 = s1.replace("row", "line");
// Tomorrow I will wear in brown standing in line 10.
String s3 = s1.replaceAll("\\brow\\b", "line");
}
/*
* 练习 – 替换字符串的数字
* 将所有连续的数字替换为 **
* */
{
String s1 = "ab12c3d456efg7h89i1011jk12lmn";
// ab**c**d**efg**h**i**jk**lmn
String s2 = s1.replaceAll("\\d+", "**");
}
/*
* 练习 – 利用数字分隔字符串
* */
{
String s1 = "ab12c3d456efg7h89i1011jk12lmn";
// [ab, c, d, efg, h, i, jk, lmn]
String[] strs = s1.split("\\d+");
}
/*
* 练习 – 提取重叠的字母、数字
* */
{
String input = "aa11+bb23-coderZsq33*dd44/5566%ff77";
String regex = "([a-z])\\1(\\d)\\2";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find()) {
// a d f
System.out.println(m.group(1));
// 1 4 7
System.out.println(m.group(2));
}
}
{
String input = "aa12+bb34-coderZsq56*dd78/9900";
String regex = "[a-z]{2}\\d(\\d)";
Pattern p = Pattern.compile(regex);
Matcher m = p.matcher(input);
while (m.find()) {
// 2 4 6 8
System.out.println(m.group(1));
}
}
}
public static boolean validate(String email) {
// 验证逻辑...
if (email == null) {
System.out.println("不能为空");
return false;
}
char[] chars = email.toCharArray();
if (chars.length < 6 || chars.length > 18) {
System.out.println("必须是6-18个字符");
return false;
}
if (!isLetter(chars[0])) {
System.out.println("必须以字母开头");
return false;
}
for (int i = 1; i < chars.length; i++) {
char c = chars[i];
if (isLetter(c) || isDigit(c) || c == '_') continue;
System.out.println("必须由字母, 数字, 下划线组成");
return false;
}
return true;
}
private static boolean isLetter(char c) {
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
private static boolean isDigit(char c) {
return c >= '0' && c <= '9';
}
/*
* 找出所有匹配的子序列
* */
public static void findAll(String regex, String input) {
findAll(regex, input, 0);
}
public static void findAll(String regex, String input, int flags) {
if (regex == null || input == null) return;
Pattern p = Pattern.compile(regex, flags);
Matcher m = p.matcher(input);
boolean found = false;
while (m.find()) {
found = true;
System.out.format("\"%s\", [%d, %d)%n", m.group(), m.start(), m.end());
}
if (!found) {
System.out.println("No match.");
}
}
}
| [
"a13701777868@yahoo.com"
] | a13701777868@yahoo.com |
13427639190d797d5648eb65972813408d18bbd4 | 088000ae324f147ef4c778261cd996cac7b99e0c | /gateway/src/test/java/com/joao/normando/gateway/GatewayApplicationTests.java | 7664cecc1a6fca50ab1adcd6e0c8b2be6f7f7c67 | [] | no_license | Joao-Normando/SpringCloud | 2308a97e6f09467f0224f97f194bb492dafc3203 | d449e42934e4f3552e6375137297e7f2f5acefeb | refs/heads/master | 2023-07-30T12:10:12.546936 | 2021-09-19T20:43:30 | 2021-09-19T20:43:30 | 408,129,875 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 218 | java | package com.joao.normando.gateway;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class GatewayApplicationTests {
@Test
void contextLoads() {
}
}
| [
"joao.normando@maisunifacisa.com.br"
] | joao.normando@maisunifacisa.com.br |
64ba4ec59f31f75adf0f5fe823a660b8f1d64aed | 4c336ffcdaa9147382ca2e82a88ea8bfef7f172b | /src/main/java/com/zhiyou/struts2demo/action/HelloAction.java | 79fa3a1047c8d4cd4f41e20d925d10f2f46e8adc | [] | no_license | fwm001/struts2demo | 85f274575c1bb00912917b31eb96d20e37ba8b4e | 25207ec4090a71856045d69c523f333d7842c7ef | refs/heads/master | 2021-06-28T14:51:50.616753 | 2017-09-19T10:00:02 | 2017-09-19T10:00:02 | 104,057,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 528 | java | package com.zhiyou.struts2demo.action;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class HelloAction extends ActionSupport {
@Override
public String execute() throws Exception {
// HttpServletRequest request = ServletActionContext.getRequest();
// HttpServletResponse response = ServletActionContext.getResponse();
// HttpSession session = request.getSession();
// ServletContext application = ServletActionContext.getServletContext();
return "test";
}
}
| [
"'769313728@qq.com'"
] | '769313728@qq.com' |
d4c97eafe3c9edca4e32cb04083cd36cbc87981f | 4fff4285330949b773e0b615484fb9c4562ff2cd | /vc-biz/vc-biz-command-inf/src/main/java/com/ccclubs/command/dto/RenewOrderReplySInput.java | bb609d77aa62f856edaff95b889d8d7d8d2c270e | [
"Apache-2.0"
] | permissive | soldiers1989/project-2 | de21398f32f0e468e752381b99167223420728d5 | dc670d7ba700887d951287ec7ff4a7db90ad9f8f | refs/heads/master | 2020-03-29T08:48:58.549798 | 2018-07-24T03:28:08 | 2018-07-24T03:28:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,428 | java | package com.ccclubs.command.dto;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
/**
* 订单续订应答成功
*
* @author jianghaiyang
* @create 2017-06-30
**/
public class RenewOrderReplySInput extends CommonInput implements Serializable {
@NotNull(message = "车辆vin码必填")
private String vin;
@NotNull(message = "订单号必填")
private Long orderId;
@NotNull(message = "续订后的截止时间(yyyy-MM-dd HH:mm:ss)必填")
@Pattern(regexp = "^(\\d{4})-([0-1]\\d)-([0-3]\\d)\\s([0-5]\\d):([0-5]\\d):([0-5]\\d)$",message = "日期格式匹配不正确(yyyy-MM-dd HH:mm:ss)")
private String renewEndTime;
public String getVin() {
return vin;
}
public void setVin(String vin) {
this.vin = vin;
}
public Long getOrderId() {
return orderId;
}
public void setOrderId(Long orderId) {
this.orderId = orderId;
}
public String getRenewEndTime() {
return renewEndTime;
}
public void setRenewEndTime(String renewEndTime) {
this.renewEndTime = renewEndTime;
}
@Override
public String toString() {
return "RenewOrderReplySInput{" +
"vin='" + vin + '\'' +
", orderId=" + orderId +
", renewEndTime='" + renewEndTime + '\'' +
'}';
}
}
| [
"niuge@ccclubs.com"
] | niuge@ccclubs.com |
256a35b1a94ff80830b357a7baa14a4a3e3f2c50 | d7ad0367373a0ed28393c5fe2c9451cbdc0e7997 | /backend/src/main/java/com/example/Hossam/myapplication/backend/MyBean.java | b80ce43370d245fa62fef72fe8a8bfa2d14f2f09 | [] | no_license | Hossam01/Build-it-Bigger | 7373132f452d47ff26a8f5ab88c4660a4d9e3887 | 527f5e15c51f147e0c642c2749bde27da259f168 | refs/heads/master | 2021-01-01T06:13:04.426130 | 2017-09-20T20:59:28 | 2017-09-20T20:59:28 | 97,381,214 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 305 | java | package com.example.Hossam.myapplication.backend;
/**
* The object model for the data we are sending through endpoints
*/
public class MyBean {
private String myData;
public String getData() {
return myData;
}
public void setData(String data) {
myData = data;
}
} | [
"analizer61@gmail.com"
] | analizer61@gmail.com |
47387058ccdfaf8ba5faff9d17cbd87430a8a29d | 0c7a9f750b5c2c1818f34c25bf1df5328fd4adac | /src/test/java/book/chapter09/chaining/tests/LoginTests.java | 1799629b6fd1a93f87a858ffe3259ef7cc30be97 | [] | no_license | roydekleijn/testshop | efa7962511d6ab21941e76e49fdb5505ae271f5c | 67ddf5f94b05c18349adfeaf1c838e6d42b0bae6 | refs/heads/master | 2020-04-18T01:46:14.608522 | 2013-08-28T14:23:30 | 2013-08-28T14:23:30 | 10,765,686 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 588 | java | package book.chapter09.chaining.tests;
import org.openqa.selenium.By;
import java.util.concurrent.TimeUnit;
import book.chapter09.chaining.pages.HomePage;
import org.testng.annotations.Test;
public class LoginTests extends DriverBase {
@Test
public void join() {
driver.manage().timeouts().pageLoadTimeout(30, TimeUnit.SECONDS);
driver.findElement(By.cssSelector("body")).click();
/*
HomePage homePage = new HomePage(driver);
homePage.clickSigninLink().setUsername("Test")
.setPassword("Case").submitForm();
*/
}
}
| [
"rdekleijn@xmsnet.nl"
] | rdekleijn@xmsnet.nl |
43f0820ecb60e5e72615cbd3ff3fbac953cfed98 | 4a3ef9ef33e83051f02292f7fee213d41e4a0ce5 | /templates/src/main/java/domain/Example.java | 838704e940db10e7cc4043806e789c1aaf4fc2df | [
"MIT"
] | permissive | pagesoma/msa-starter | d46b0675848f39263a809c86fa0ce2f5505479a8 | 0c387844188ddc246d02c79530a41fc6356369ff | refs/heads/master | 2023-02-18T23:49:29.389007 | 2021-01-22T03:09:21 | 2021-01-22T03:09:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,298 | java | package {{packageName}}.domain;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.ToString;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import java.io.Serializable;
import java.time.Instant;
import java.util.UUID;
@Entity
@Table(name = "examples")
@EntityListeners(AuditingEntityListener.class)
@Getter
@ToString
@EqualsAndHashCode(of = "id")
public class Example implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String title;
@CreatedDate
private Instant createdAt;
@LastModifiedDate
private Instant updatedAt;
@CreatedBy
private String createdBy;
@LastModifiedBy
private String updatedBy;
protected Example() {}
private Example(String title) {
this.title = title;
}
public static Example newInstance(String title) {
return new Example(title);
}
public void changeTitle(String newTitle) {
this.title = newTitle;
}
}
| [
"juwonkim@me.com"
] | juwonkim@me.com |
66c6d92441257d45390ff03bd43bff5aa14e986e | 5b360e5ca590f629a3969bf351e5478da995fd56 | /sem4Project-war/src/java/hmt/ManageBillOrder.java | ceda37db65477b8142103bbeb29f7560bd01a923 | [] | no_license | huahoangduycusc/eproject-sem-4-last-one | 74fefd455d0f554b4f2caea17e1ee959db8d4926 | ffa24a3e6972fbc5a900a8035a9c864346db13a8 | refs/heads/master | 2023-07-11T02:15:59.823024 | 2021-08-15T08:56:53 | 2021-08-15T08:56:53 | 387,443,115 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,966 | 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 hmt;
import java.io.IOException;
import java.io.PrintWriter;
import java.time.LocalDate;
import java.time.YearMonth;
import javax.ejb.EJB;
import javax.servlet.RequestDispatcher;
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 sessionbean.OrdersFacadeLocal;
/**
*
* @author hmtua
*/
@WebServlet("/ManageBillOrder")
public class ManageBillOrder extends HttpServlet {
@EJB
private OrdersFacadeLocal ordersFacade;
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// nhan requet truy xuat thoi gian
String dateStart = request.getParameter("start");
String dateEnd = request.getParameter("end");
//nhaanh gai tri reuy xuat
String retun = request.getParameter("date");
LocalDate start = YearMonth.now().atDay(1);
LocalDate end = YearMonth.now().atEndOfMonth();
LocalDate d1 = java.time.LocalDate.now();
// lay de truy xuat ket qua chi tiet
SuLy suLy = new SuLy();
//indix
if (retun.equals("hientai")) {
//tra ve thong tin order
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/index.jsp");
requestDispatcher.forward(request, response);
} else if (retun.equals("hientaidate")) {
//tra ve thong tin order
request.setAttribute("order", ordersFacade.sumOrrder(start.toString(), d1.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/indexByDate.jsp");
requestDispatcher.forward(request, response);
} else if (retun.equals("chidinh")) {
String s = request.getParameter("start");
String e = request.getParameter("end");
//tra ve thong tin order
request.setAttribute("order", ordersFacade.sumOrrder(s.toString(), e.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/indexByDate.jsp");
requestDispatcher.forward(request, response);
}
//detail
if (retun.equals("details")) {
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/details.jsp");
requestDispatcher.forward(request, response);
}
if (retun.indexOf("detailsAll") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(start.toString(), d1.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/all.jsp");
requestDispatcher.forward(request, response);
} else if (retun.indexOf("CoutomsAll") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(dateStart, dateEnd));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/all.jsp");
requestDispatcher.forward(request, response);
}
if (retun.indexOf("detailsPaid") != -1) {
System.out.println("vao detail ");
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(start.toString(), d1.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/paid.jsp");
requestDispatcher.forward(request, response);
} else if (retun.indexOf("CoutomsPaid") != -1) {
System.out.println("vao custome");
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(dateStart, dateEnd));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/paid.jsp");
requestDispatcher.forward(request, response);
}
if (retun.indexOf("detailsUnpaid") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(start.toString(), d1.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/unpaid.jsp");
requestDispatcher.forward(request, response);
} else if (retun.indexOf("CoutomsUnpaid") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(dateStart, dateEnd));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/unpaid.jsp");
requestDispatcher.forward(request, response);
}
if (retun.indexOf("detailsCanceled") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(start.toString(), d1.toString()));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/canceled.jsp");
requestDispatcher.forward(request, response);
} else if (retun.indexOf("CoutomsCanceled") != -1) {
request.setAttribute("informationOrderDate", ordersFacade.nformationOrder(dateStart, dateEnd));
RequestDispatcher requestDispatcher = request.getRequestDispatcher("musics/manage/billorder/canceled.jsp");
requestDispatcher.forward(request, response);
}
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
} | [
"huahoangduy.389@gmail.com"
] | huahoangduy.389@gmail.com |
77b2f76a17d55b78ca1da80aafd9e7e5ac970b1f | 1c0fa98cfa725e6f0bbb29792a2ebaeb955bde6b | /fanyi/src/main/java/com/fypool/repository/QualityRepository.java | 4d90cf380d9742ecaee14bf98d22473c19a59521 | [] | no_license | mack-wang/project | 043a17d97b747352d2d20ab8143188a26872cfaf | c7eec8ba9b87d24272511abb519754067e6e65e3 | refs/heads/master | 2021-09-01T06:59:51.084085 | 2017-12-25T14:34:40 | 2017-12-25T14:34:40 | 115,329,425 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | package com.fypool.repository;
import com.fypool.model.LanguageGroup;
import com.fypool.model.Quality;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
/**
* Generated by Spring Data Generator on 11/10/2017
*/
@Repository
public interface QualityRepository extends JpaRepository<Quality, Integer> {
}
| [
"641212003@qq.com"
] | 641212003@qq.com |
452ae54efa437b693cfe6b95b090d8c21a58f582 | 752dcf67d93c81d43de52406e8022d56d46a4c01 | /produits/src/main/java/com/isetn/produits/service/ProduitServiceImpl.java | 0a53efd8d4f5fcecfea2c8e878289e1d14ca7449 | [] | no_license | nadhemBelHadj/TP7_SpringBootCRUD | b310f4e43887e360da72d18cac729dc15656fb3c | 3e79780c13d035e6e82f2bb5f61942902e8144a2 | refs/heads/master | 2020-09-03T13:37:27.415047 | 2019-11-07T14:43:52 | 2019-11-07T14:43:52 | 219,475,806 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 953 | java | package com.isetn.produits.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.isetn.produits.entities.Produit;
import com.isetn.produits.repos.ProduitRepository;
@Service
public class ProduitServiceImpl implements ProduitService {
@Autowired
ProduitRepository produitRepository;
@Override
public Produit saveProduit(Produit p) {
return produitRepository.save(p);
}
@Override
public Produit updateProduit(Produit p) {
return produitRepository.save(p);
}
@Override
public void deleteProduit(Produit p) {
produitRepository.delete(p);
}
@Override
public Produit getProduit(Long id) {
return produitRepository.findById(id).orElse(null);
}
@Override
public List<Produit> getAllProduits() {
List<Produit> prods = produitRepository.findAll();
return prods;
}
}
| [
"noreply@github.com"
] | noreply@github.com |
511eb5b2f5d6d73f080ab0b6fd9639b849d36e39 | 0747bb8c80c8f27daed25caeda018ae65e1ab5d0 | /Atividade 3 - ListaDuplamenteLigada/src/controller/AlunoControle.java | 7df3745bd7e7bc3ed6b086ed48294ca5eda12ee9 | [] | no_license | rodrigommrtz/Estrutura-de-Dados | c42d84d745f0ff8927cc9cc150bc4815b72ad613 | 3d7331466aaa718d73dc4f025193940fe2ca3a87 | refs/heads/master | 2022-12-30T02:54:15.348028 | 2020-10-20T18:07:24 | 2020-10-20T18:07:24 | 294,117,022 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 3,581 | java | package controller;
public class AlunoControle {
public Alunos inicio;
public Alunos fim;
int contador;
public AlunoControle (){
this.contador = 0;
this.inicio = null;
this.fim = null;
}
public void addInicio(int id, String curso, String area, int semestre, String nome, String periodo) {
if(this.contador == 0){
Alunos aluno = new Alunos();
aluno.setId(id);
aluno.setCurso(curso);
aluno.setArea(area);
aluno.setSemestre(semestre);
aluno.setNome(nome);
aluno.setPeriodo(periodo);
aluno.setApontador(inicio);
this.inicio = aluno;
this.contador++;
} else {
Alunos aluno = new Alunos();
aluno.setId(id);
aluno.setCurso(curso);
aluno.setArea(area);
aluno.setSemestre(semestre);
aluno.setNome(nome);
aluno.setPeriodo(periodo);
aluno.setApontador(inicio);
inicio = aluno;
this.contador++;
}
}
public void addFinal(int id, String curso, String area, int semestre, String nome, String periodo) {
Alunos aluno = new Alunos();
aluno.setId(id);
aluno.setCurso(curso);
aluno.setArea(area);
aluno.setSemestre(semestre);
aluno.setNome(nome);
aluno.setPeriodo(periodo);
aluno.setApontador(inicio);
if(this.contador == 0) {
aluno.setApontador(fim);
this.inicio = aluno;
this.fim = aluno;
} else {
fim.setApontador(aluno);
inicio = aluno;
}
this.contador++;
}
public void addMeio(int posicao, int id, String curso, String area, int semestre, String nome, String periodo) {
Alunos aluno = new Alunos();
aluno.setId(id);
aluno.setCurso(curso);
aluno.setArea(area);
aluno.setSemestre(semestre);
aluno.setNome(nome);
aluno.setPeriodo(periodo);
Alunos busca = this.inicio;
if (posicao < 0 || posicao >= contador) {
System.out.println("Posição não disponível - DADOS NÃO INSERIDOS");
}else {
for (int i = 0; i<posicao-1; i++) {
busca = busca.getApontador();
}
aluno.setApontador(busca);
busca.setApontador(aluno);
busca = aluno;
System.out.println("Dado inserido na posicao "+ posicao +" da lista");
this.contador++;
}
}
public void removeInicio() {
if (this.contador == 0) {
System.out.println("Nao ha elementos para serem removidos");
} else {
Alunos lista = inicio;
inicio = inicio.getApontador();
lista.setApontador(null);
this.contador--;
}
}
public void removeFinal() {
if(this.contador ==0) {
System.out.println("nao ha alunos");
} else {
Alunos lista = inicio;
while (lista.getApontador() != null) {
lista = lista.getApontador();
}
lista.setApontador(null);
this.contador--;
}
}
public void removeMeio(int posicao) {
if (this.contador == 0){
System.out.println("Não há alunos para serem excluídos");
} else {
Alunos aluno = inicio;
for (int i =0; i<posicao; i++){
try {
aluno = aluno.getApontador();
aluno.setApontador(null);
System.out.println("Dado retirado da posicao "+ posicao +" da lista");
this.contador--;
} catch (Exception erro) {
System.out.println("posição não disponível");
{
}
}
}
}
}
public void listar() {
if(this.contador == 0) {
System.out.println("Não há elementos na lista");
} else {
Alunos lista = this.inicio;
for (int i=0; i<=this.contador-1; i++) {
System.out.println("Aluno: " +lista.getNome() + " Id: " +lista.getId() + " Curso: " +lista.getCurso()
+ " Área: " +lista.getArea() + " Semestre: " +lista.getSemestre() + " Período: " +lista.getPeriodo());
lista = lista.getApontador();
}
}
}
}
| [
"rodrigomrtz@gmail.com"
] | rodrigomrtz@gmail.com |
c0ef55388057116f7f9207a01ed138283278c959 | 5779f53201c36091d14f5cf216a4a4d7f457c294 | /src/main/java/com/projektpo/wiorektrepka/budget/service/CodeEventService.java | 1a560e4db2e670e68cd99f7709206d0a329e9a7b | [] | no_license | mTrepka/budget | a59148831867b107e5c643be3627009e61ca5d52 | 4f4037ac42b26038ca2b97b7b53ab1cbfabb21ab | refs/heads/master | 2023-01-23T14:36:19.463778 | 2019-10-01T11:19:54 | 2019-10-01T11:19:54 | 177,457,893 | 0 | 0 | null | 2023-01-07T06:13:49 | 2019-03-24T19:13:56 | Java | UTF-8 | Java | false | false | 270 | java | package com.projektpo.wiorektrepka.budget.service;
import com.projektpo.wiorektrepka.budget.domain.CodeEvent;
public interface CodeEventService {
void saveCode(CodeEvent codeEvent);
boolean validCode(CodeEvent codeEvent);
void removeCode(CodeEvent codeEvent);
}
| [
"qurppy@gmail.com"
] | qurppy@gmail.com |
ceeffe2439bf54313857346ecba5beb983d271b8 | 8a38bc7a1061cfb01cd581da9958033ccbdee654 | /dhis-2/dhis-support/dhis-support-hibernate/src/main/java/org/hisp/dhis/hibernate/dialect/DhisH2Dialect.java | e7baa7992462d89d43432ed7fc694c4580349d81 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | abyot/eotcnor | e4432448c91ca8a761fcb3088ecb52d97d0931e5 | 7220fd9f830a7a718c1231aa383589986f6ac5b9 | refs/heads/main | 2022-11-05T14:48:38.028658 | 2022-10-28T10:07:33 | 2022-10-28T10:07:33 | 120,287,850 | 0 | 0 | null | 2018-02-05T11:02:05 | 2018-02-05T10:10:22 | null | UTF-8 | Java | false | false | 3,911 | java | /*
* Copyright (c) 2004-2021, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.hibernate.dialect;
import java.sql.Types;
import org.hibernate.boot.model.TypeContributions;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.dialect.function.StandardSQLFunction;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.StandardBasicTypes;
import org.hisp.dhis.hibernate.jsonb.type.JsonBinaryType;
import org.hisp.dhis.hibernate.jsonb.type.JsonbFunctions;
/**
* @author Lars Helge Overland
*/
public class DhisH2Dialect extends H2Dialect
{
public DhisH2Dialect()
{
registerColumnType( Types.JAVA_OBJECT, "text" );
registerColumnType( Types.JAVA_OBJECT, "jsonb" );
registerColumnType( Types.OTHER, "uuid" );
registerFunction( JsonbFunctions.EXTRACT_PATH,
new StandardSQLFunction( JsonbFunctions.EXTRACT_PATH, StandardBasicTypes.STRING ) );
registerFunction( JsonbFunctions.EXTRACT_PATH_TEXT,
new StandardSQLFunction( JsonbFunctions.EXTRACT_PATH_TEXT, StandardBasicTypes.STRING ) );
registerFunction( JsonbFunctions.HAS_USER_GROUP_IDS,
new StandardSQLFunction( JsonbFunctions.HAS_USER_GROUP_IDS, StandardBasicTypes.BOOLEAN ) );
registerFunction( JsonbFunctions.CHECK_USER_GROUPS_ACCESS,
new StandardSQLFunction( JsonbFunctions.CHECK_USER_GROUPS_ACCESS, StandardBasicTypes.BOOLEAN ) );
registerFunction( JsonbFunctions.HAS_USER_ID,
new StandardSQLFunction( JsonbFunctions.HAS_USER_ID, StandardBasicTypes.BOOLEAN ) );
registerFunction( JsonbFunctions.CHECK_USER_ACCESS,
new StandardSQLFunction( JsonbFunctions.CHECK_USER_ACCESS, StandardBasicTypes.BOOLEAN ) );
}
@Override
public String getDropSequenceString( String sequenceName )
{
// Adding the "if exists" clause to avoid warnings
return "drop sequence if exists " + sequenceName;
}
@Override
public boolean dropConstraints()
{
// No need to drop constraints before dropping tables, leads to error
// messages
return false;
}
@Override
public void contributeTypes( TypeContributions typeContributions, ServiceRegistry serviceRegistry )
{
super.contributeTypes( typeContributions, serviceRegistry );
typeContributions.contributeType( new JsonBinaryType(), "jsonb" );
}
}
| [
"abyota@gmail.com"
] | abyota@gmail.com |
37ece7027d285738afaf443d47a53d721214af39 | ef9d6c671fe9002794e487439a1b4d8f64753854 | /datastructures/src/stack/palindrome/CheckPalindrome.java | 01717f4f8dbdba764ee08a51d9df2a8a5fb1cfdb | [] | no_license | uhsnarpgupta/Hackerrank | cfe8e6d46fcae54ca5d5d637711fa1a0fede45ed | f5497c3aa46e1b3d06e33fe73001f42de9fd5125 | refs/heads/master | 2020-03-25T06:30:42.310374 | 2019-08-09T11:31:40 | 2019-08-09T11:31:40 | 143,506,628 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 874 | java | package stack.palindrome;
import java.util.LinkedList;
public class CheckPalindrome {
public static void main(String[] args) {
String input = "I did, Did I?";
//input.concat("as");
String processedInput = input.replaceAll("[^a-zA-Z]||\\s", "").toLowerCase();
char[] charArray = processedInput.toCharArray();
LinkedList<Character> list = new LinkedList<>();
char[] newArray = new char[charArray.length];
for (int i = 0; i < charArray.length; i++) {
if (((Character) charArray[i]).equals(list.peek())) {
list.pop();
} else {
list.push(charArray[i]);
}
}
if (list.isEmpty()) {
System.out.println("input is a palindrome ");
} else {
System.out.println("input isn't a palindrome ");
}
}
}
| [
"uhsnarpggupta@gmail.com"
] | uhsnarpggupta@gmail.com |
9e58c293960147e3b58d4ce08c482aa2475fc76c | 0904d440c2751a593c75f0e79f0fc64d63c19d7d | /trabalhoCrud/src/br/senai/sc/ti2014n1/cleber/bi/dao/UserDao.java | e4474b09e0ff4516af906bbc2c02024e11d348bc | [] | no_license | cleberwebsite/TrabalhoCrud | 50e8242426283ad5a90ed14d437899357625d0fa | 6e6929f1bcc57ac0b55d7a4ac2a44cfd4c67d1c1 | refs/heads/master | 2021-01-10T13:06:01.924554 | 2015-11-02T23:43:41 | 2015-11-02T23:43:41 | 43,333,218 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,883 | java | package br.senai.sc.ti2014n1.cleber.bi.dao;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import br.senai.sc.ti2014n1.cleber.bi.model.dominio.User;
public class UserDao extends Dao {
private static final String SELECT_EMAIL = "SELECT * FROM user WHERE email = ?";
private final String INSERT = "INSERT INTO user (nome, email, senha) values (?,?,?)";
private final String UPDATE = "UPDATE user SET nome = ?, email = ?, senha = ? WHERE id = ?";
private final String DELETE = "DELETE FROM user WHERE id = ?";
private final String SELECT = "SELECT * FROM user";
private final String SELECT_ID = "SELECT * FROM user WHERE id = ?";
public void salvar(User user) throws Exception {
if (user.getId() == 0) {
inserir(user);
} else {
alterar(user);
}
}
private void inserir(User user) throws Exception {
try {
PreparedStatement ps = getConnection().prepareStatement(INSERT);
ps.setString(1, user.getNome());
ps.setString(2, user.getEmail());
ps.setString(3, user.getSenha());
ps.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Erro ao tentar salvar o usuário");
}
}
public void alterar(User user) {
try {
PreparedStatement ps = getConnection().prepareStatement(UPDATE);
ps.setString(1, user.getNome());
ps.setString(2, user.getEmail());
ps.setString(3, user.getSenha());
ps.setLong(4, user.getId());
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Erro ao executar o update: " + e);
}
}
public void excluir(Long id) throws Exception {
try {
PreparedStatement ps = getConnection().prepareStatement(DELETE);
ps.setLong(1, id);
ps.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Erro a executar o delete: " + e);
throw new Exception("Erro ao tentar excluir");
}
}
public List<User> listarTodos() {
List<User> users = new ArrayList<User>();
try {
PreparedStatement ps = getConnection().prepareStatement(SELECT);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
User user = new User();
user.setNome(rs.getString("nome"));
user.setEmail(rs.getString("email"));
user.setSenha(rs.getString("senha"));
user.setId(rs.getLong("id"));
users.add(user);
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Erro ao executar o select de user: " + e);
}
return users;
}
private User parseUser(ResultSet rs) throws SQLException {
User user = new User();
user.setNome(rs.getString("nome"));
user.setEmail(rs.getString("email"));
user.setId(rs.getLong("id"));
user.setSenha(rs.getString("senha"));
return user;
}
public User buscarPorId(Long id) {
try {
PreparedStatement ps = getConnection().prepareStatement(SELECT_ID);
ps.setLong(1, id);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
User user = new User();
user.setNome(rs.getString("nome"));
user.setEmail(rs.getString("email"));
user.setSenha(rs.getString("senha"));
user.setId(rs.getLong("id"));
return user;
}
} catch (SQLException e) {
e.printStackTrace();
System.out.println("Erro ao executar o select de user: " + e);
}
return null;
}
public User buscaPorEmail(String email) {
try {
PreparedStatement preparedStatement = getConnection()
.prepareStatement(SELECT_EMAIL);
preparedStatement.setString(1, email);
ResultSet resultSet = preparedStatement.executeQuery();
if (resultSet.next()) {
return parseUser(resultSet);
}
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
| [
"cleberwebsite@gmail.com"
] | cleberwebsite@gmail.com |
b5e75adac01fefc5fecb33e350f24f4403cdd3fd | caf8c12b4c7a5587761c35b9ff7c34b8650e39cf | /ejbModule/view/Menu.java | 0a5f3fc29d67df670b63e354e6cb072dc2365c91 | [] | no_license | iviLen/VAVA_parfemy | deac9a04023b70b1c628df9a4670fb7b07d3f323 | cea9b33b9955f575616410046a6670828c00510f | refs/heads/master | 2020-05-20T05:44:38.147426 | 2019-05-07T15:05:36 | 2019-05-07T15:05:36 | 185,413,936 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,629 | java | package view;
import java.awt.EventQueue;
import java.awt.Image;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.Color;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JPanel;
import java.awt.Font;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import controller.Controller;
import javax.swing.SwingConstants;
/*
* Trieda Menu, ktora sa zobrazi hned po spusteni aplikacie.
* Je v nej mozne zmenit farbu a jazyk aplikacie.
* Farba pozadia je primarne nastavena na ruzovu a jazyk aplikacie na slovensky.
* Vzdy sa kontroluje jazyk a farba pozadia, ktoru si pouzivatel zvolil a podla toho sa zobrazi.
*/
public class Menu {
public JFrame frame;
private Controller control = Controller.getInstance();
int farba;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Menu window = new Menu();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public Menu() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.getContentPane().setBackground(new Color(245,245,245));
frame.setBounds(100, 100, 949, 592);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JLabel obrazocek = new JLabel("");
obrazocek.setBounds(417, 52, 511, 494);
obrazocek.setBackground(Color.WHITE);
Image img = new ImageIcon(this.getClass().getResource("/vonavka.png")).getImage();
frame.getContentPane().setLayout(null);
obrazocek.setIcon(new ImageIcon(img));
frame.getContentPane().add(obrazocek);
JPanel panel = new JPanel();
panel.setBounds(70, 142, 232, 359);
if(control.getFarba() == 1)
panel.setBackground(new Color(204, 255, 204));
else if(control.getFarba() == 2)
panel.setBackground(new Color(250,226,232));
frame.getContentPane().add(panel);
panel.setLayout(null);
//Tlacidlo pomocou ktoreho sa pouzivatel presmeruje na obrazovku moje parfemy
JButton btnNewButton = new JButton();
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
MojeParfemy moje = new MojeParfemy(control);
moje.setVisible(true);
}
});
btnNewButton.setFont(new Font("Gabriola", Font.PLAIN, 25));
btnNewButton.setBounds(19, 41, 196, 65);
panel.add(btnNewButton);
btnNewButton.setBackground(new Color(245,245,245));
btnNewButton.setOpaque(true);
btnNewButton.setBorderPainted(false);
//Tlacidlo pomocou ktoreho sa pouzivatel presmeruje na obrazovku moj wishlist
JButton btnNewButton_1 = new JButton();
btnNewButton_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
MojWishlist wishlist = new MojWishlist(control);
wishlist.setVisible(true);
}
});
btnNewButton_1.setFont(new Font("Gabriola", Font.PLAIN, 25));
btnNewButton_1.setBounds(19, 147, 196, 65);
panel.add(btnNewButton_1);
btnNewButton_1.setBackground(new Color(245,245,245));
btnNewButton_1.setOpaque(true);
btnNewButton_1.setBorderPainted(false);
//Tlacidlo pomocou ktoreho sa pouzivatel presmeruje na obrazovku zoznam parfemov
JButton btnNewButton_2 = new JButton();
btnNewButton_2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
frame.dispose();
ZoznamParfemov zoznam = new ZoznamParfemov(control);
zoznam.setVisible(true);
}
});
btnNewButton_2.setFont(new Font("Gabriola", Font.PLAIN, 25));
btnNewButton_2.setBounds(19, 253, 196, 65);
panel.add(btnNewButton_2);
btnNewButton_2.setBackground(new Color(245,245,245));
btnNewButton_2.setOpaque(true);
btnNewButton_2.setBorderPainted(false);
JLabel lblNewLabel = new JLabel();
lblNewLabel.setBounds(70, 36, 252, 78);
lblNewLabel.setFont(new Font("Gabriola", Font.PLAIN, 60));
frame.getContentPane().add(lblNewLabel);
//Tlacidlo, ktore nastavi farbu aplikacie na zelenu
JButton btnNewButton_3 = new JButton("");
btnNewButton_3.setBounds(872, 13, 34, 25);
btnNewButton_3.setBackground(new Color(204, 255, 204));
btnNewButton_3.setContentAreaFilled(false);
btnNewButton_3.setOpaque(true);
btnNewButton_3.setBorderPainted(false);
btnNewButton_3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
control.setFarba(1);
panel.setBackground(new Color(204, 255, 204));
}
});
frame.getContentPane().add(btnNewButton_3);
//Tlacidlo, ktore nastavi farbu aplikacie na ruzovu
JButton btnNewButton_4 = new JButton("");
btnNewButton_4.setBounds(826, 13, 34, 25);
btnNewButton_4.setBackground(new Color(250,226,232));
btnNewButton_4.setContentAreaFilled(false);
btnNewButton_4.setOpaque(true);
btnNewButton_4.setBorderPainted(false);
btnNewButton_4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
control.setFarba(2);
panel.setBackground(new Color(250,226,232));
}
});
frame.getContentPane().add(btnNewButton_4);
//Tlacidlo, ktore nastavi jazyk aplikacie na SK
JButton btnSk = new JButton("SK");
btnSk.setFont(new Font("Tahoma", Font.PLAIN, 11));
btnSk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
control.setJazyk(1);
btnNewButton.setText("Moje parfémy");
btnNewButton_1.setText("Môj wishlist");
btnNewButton_2.setText("Zoznam parfémov");
lblNewLabel.setText("Parfémy");
}
});
btnSk.setHorizontalAlignment(SwingConstants.LEFT);
btnSk.setBounds(708, 13, 47, 25);
frame.getContentPane().add(btnSk);
//Tlacidlo, ktore nastavi jazyk aplikacie na EN
JButton btnEn = new JButton("EN");
btnEn.setFont(new Font("Tahoma", Font.PLAIN, 11));
btnEn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
control.setJazyk(2);
btnNewButton.setText("My perfumes");
btnNewButton_1.setText("My wishlist");
btnNewButton_2.setText("List of perfumes");
lblNewLabel.setText("Perfumes");
}
});
btnEn.setHorizontalAlignment(SwingConstants.LEFT);
btnEn.setBounds(767, 13, 47, 25);
frame.getContentPane().add(btnEn);
if(control.getJazyk() == 1)
{
btnNewButton.setText("Moje parfémy");
btnNewButton_1.setText("Môj wishlist");
btnNewButton_2.setText("Zoznam parfémov");
lblNewLabel.setText("Parfémy");
}
else
{
btnNewButton.setText("My perfumes");
btnNewButton_1.setText("My wishlist");
btnNewButton_2.setText("List of perfumes");
lblNewLabel.setText("Perfumes");
}
}
}
| [
"i.lenkeyova@gmail.com"
] | i.lenkeyova@gmail.com |
2993927d5f4d7a53c98ae3c6c58e3051ff5f8285 | 09fda2339fe3bf9b718c0081ce0d6dcaa569c0fd | /shared-kernel/src/main/java/emt/proekt/eshop/sharedkernel/domain/base/ValueObject.java | e421b66499659bbd03329f5d8a61a33874b1b84f | [] | no_license | stefanikostic/eshop | 218d25f8c08b96744caeaf16fc65572b20d978ba | 664b098a9776ab3b415b8ffedacb52bece135938 | refs/heads/master | 2023-06-20T03:42:14.543133 | 2021-07-20T18:12:51 | 2021-07-20T18:12:51 | 302,281,492 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 106 | java | package emt.proekt.eshop.sharedkernel.domain.base;
public interface ValueObject extends DomainObject {
}
| [
"stefani.kostic@pelagus-it.com"
] | stefani.kostic@pelagus-it.com |
aebaa94c881efa6a6728a86b402e32a664efeae4 | a4b832dafbac1d05c0425357a8374cb152f8645f | /app/src/main/java/com/jk/parkingproject/ParkingSharedPrefs.java | 3a5cb63d90c602c9b1ed8061810132aeef468228 | [] | no_license | gerin-puig/Parking_Android | 2cbfa5fe769e0e71fda2b32908dcb49dd5ef1544 | 418b70d3489b99540d3e75ea0e8cece47847bb18 | refs/heads/master | 2023-06-25T13:20:45.502466 | 2021-07-24T17:44:10 | 2021-07-24T17:44:10 | 372,995,541 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,778 | java | package com.jk.parkingproject;
import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.util.Pair;
/**
* Gerin Puig - 101343659
* Rajdeep Dodiya - 101320088
*/
public class ParkingSharedPrefs {
private SharedPreferences shared;
private SharedPreferences.Editor editor;
private final String CURRENT_USER = "currentUser";
private final String EMAIL = "email";
private final String PASSWORD = "password";
private final String REMEMBER = "remember";
public ParkingSharedPrefs(Context context) {
shared = PreferenceManager.getDefaultSharedPreferences(context);
editor = shared.edit();
}
public void setCurrentUser(String email){
editor.putString(CURRENT_USER, email);
editor.commit();
}
public String getCurrentUser(){
String currentUser = shared.getString(CURRENT_USER, "empty");
return currentUser;
}
public boolean getIsRemembered(){
return shared.getBoolean(REMEMBER, false);
}
public Pair<String, String> getInfo(){
return new Pair<>(shared.getString(EMAIL, ""), shared.getString(PASSWORD, ""));
}
public void setPassword(String password){
editor.putString(PASSWORD, password);
editor.commit();
}
public void saveUserInfo(String email, String password, Boolean remember){
editor.putString(EMAIL, email);
editor.putString(PASSWORD, password);
editor.putBoolean(REMEMBER, remember);
editor.commit();
}
public void userLogout(){
editor.remove(CURRENT_USER);
editor.remove(EMAIL);
editor.remove(PASSWORD);
editor.remove(REMEMBER);
editor.commit();
}
}
| [
"69816174+gerin-puig@users.noreply.github.com"
] | 69816174+gerin-puig@users.noreply.github.com |
508a8f28b1be98a270fbd279e0572429ddbdae30 | 306fccccf281be75dfb86528f90904e55b8d1477 | /ziksana-app/zdomain/src/main/java/com/ziksana/domain/assessment/LinkReason.java | 17d88945f2de58b720380b7ffe84bca3318c74ed | [] | no_license | dharanimishra/DD-ZJPlatform | 5556372a052a0b7119b9ac745c22731a5c8fbc65 | 8d89b24739a14805a1b42929240c9c35806ce208 | refs/heads/master | 2021-01-13T14:19:47.743771 | 2013-07-05T17:56:54 | 2013-07-05T17:56:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 903 | java | package com.ziksana.domain.assessment;
public enum LinkReason {
// TODO: retrieve the ids from the static data service
HIGHER_PROFICIENCY (1, "Higher Proficiency"),
ADDITIONAL_CARDS (2, "Additional Cards"),
CURIOSITY (3, "Curiosity");
private final int id;
private final String name;
private LinkReason(int id, String name) {
this.id = id;
this.name = name;
}
public int getID() {
return id;
}
public String getName() {
return name;
}
public static LinkReason getAssignmentLinkReason(int ID) throws NoSuchMethodException{
for (LinkReason linkReason : LinkReason.values()) {
if (linkReason.getID() == ID) {
return linkReason;
}
}
throw new NoSuchMethodException("Link Reason ID [" + ID + "] not found");
}
public String toString() {
return "Link Reason [" + getName() + "] ID [" + getID() + "]";
}
}
| [
"arrvind.rathod@vtgindia.com"
] | arrvind.rathod@vtgindia.com |
ebe5d0b483b87a69860cad88ce73dc23a9250854 | 567c5521b242a80ed845f538eda02bf82b96f6c8 | /android/app/src/main/java/com/fbtrndemoapp/MainApplication.java | 8e13bde2b4f7dd874673e08f6f3f5cb0c7621410 | [
"MIT"
] | permissive | Andrulko/fbt-rn-demo-app | 771ba7a14fc844e3dbb1e1b789a6d3328dd90cc1 | e78445ee7f2723a9972bc429a3886b7ec59c491e | refs/heads/master | 2022-12-14T11:00:47.710397 | 2020-08-26T20:16:08 | 2020-08-26T20:16:08 | 291,993,687 | 0 | 0 | MIT | 2020-09-01T12:36:51 | 2020-09-01T12:36:50 | null | UTF-8 | Java | false | false | 2,357 | java | /*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.fbtrndemoapp;
import android.app.Application;
import android.content.Context;
import com.facebook.react.PackageList;
import com.facebook.react.ReactApplication;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.soloader.SoLoader;
import java.lang.reflect.InvocationTargetException;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost =
new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
return packages;
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
initializeFlipper(this); // Remove this line if you don't want Flipper enabled
}
/**
* Loads Flipper in React Native templates.
*
* @param context
*/
private static void initializeFlipper(Context context) {
if (BuildConfig.DEBUG) {
try {
/*
We use reflection here to pick up the class that initializes Flipper,
since Flipper library is not available in release mode
*/
Class<?> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
}
| [
"4749436+dalmendray@users.noreply.github.com"
] | 4749436+dalmendray@users.noreply.github.com |
4e717f404a74610827c34d4f1ea3fe2d4e1ead66 | b294cf427ad02c31249dc9df2c29958e788d517c | /YIYA_MS/src/com/yiya/service/SysMenuBtnService.java | 0f60883727334ea7200becbce3a94f337710518c | [] | no_license | dongren88/dongren | dd10b87d6756d8a6c0a575070b83465de4ab256a | 7eacdd02852411574526a9802d95b7954e3d370d | refs/heads/master | 2020-09-23T15:02:32.513054 | 2019-12-03T08:53:37 | 2019-12-03T08:53:37 | 225,526,428 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,171 | java | package com.yiya.service;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yiya.mapper.SysMenuBtnMapper;
/**
*
* <br>
* <b>功能:</b>SysMenuBtnService<br>
* <b>作者:</b>罗泽军<br>
* <b>日期:</b> Dec 9, 2011 <br>
* <b>版权所有:<b>版权所有(C) 2011,WWW.VOWO.COM<br>
*/
@Service("sysMenuBtnService")
public class SysMenuBtnService<T> extends BaseService<T> {
private final static Logger log= Logger.getLogger(SysMenuBtnService.class);
public List<T> queryByAll(){
return getMapper().queryByAll();
}
public List<T> queryByMenuid(Integer menuid){
return getMapper().queryByMenuid(menuid);
}
public List<T> queryByMenuUrl(String url){
return getMapper().queryByMenuUrl(url);
}
public void deleteByMenuid(Integer menuid){
getMapper().deleteByMenuid(menuid);
}
public List<T> getMenuBtnByUser(Integer userid){
return getMapper().getMenuBtnByUser(userid);
}
@Autowired
private SysMenuBtnMapper<T> mapper;
public SysMenuBtnMapper<T> getMapper() {
return mapper;
}
}
| [
"13510750629@139.com"
] | 13510750629@139.com |
b8737e8e0e1422583db6ae0683e5b2e1e827d3cd | d1e8d5288ccda2d67f24a59fea17ec95436d69e8 | /Java/Aulas/dia3/D3Exercicio1.java | 68d73efe8f4d1af4d56d02a2bcab98811874f23f | [] | no_license | MatheusBMilani/JavaGen | 6d06be99a02d945e6314e918d7512f7efd27dd55 | d250908acf2a15ab902eeaefd270a52b8cf27b16 | refs/heads/main | 2023-08-30T05:56:44.468981 | 2021-09-10T15:29:18 | 2021-09-10T15:29:18 | 388,224,547 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 201 | java | public class Lista3Exercicio1 {
public static void main(String[] args) {
for (int i = 1000; i < 2000; i++) {
if (i % 11 == 5) {
System.out.println("i é: " + i);
}
}
}
} | [
"noreply@github.com"
] | noreply@github.com |
8af3bc773fb640c6db6cd14e937e8225eb383db3 | 1995e5fd4956bb9f3c7f83a4850b7c70fc81c0c8 | /app/src/main/java/com/formation/appli/bruxellesparcourbd/ui/Game/ResultFragment.java | b41ddfdf8e47b5ae2658435125adc8fa05b62c15 | [] | no_license | Jeremyvdm/Mobile_developper_training | d21d3b9fafc5a6354524cbceaea4034a9d72ed39 | dd5fcff67efdde71fcec034f0f9e7c7a0e4e9476 | refs/heads/master | 2020-12-02T19:21:35.202899 | 2017-07-14T13:50:58 | 2017-07-14T13:50:58 | 96,327,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,559 | java | package com.formation.appli.bruxellesparcourbd.ui.Game;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import com.formation.appli.bruxellesparcourbd.R;
public class ResultFragment extends Fragment implements View.OnClickListener{
private ImageView ivResultFresque;
private TextView tvResultFresque;
private Button btnResultFresque;
private Bundle bundleResult;
private String result;
public ResultFragment() {
// Required empty public constructor
}
//region Singleton
private static ResultFragment instance;
public static ResultFragment getInstance() {
if (instance == null) {
instance = new ResultFragment();
}
return instance;
}
//endregion
//region Communication
public interface ResultFragmentCallback {
void onClickResult();
}
private ResultFragmentCallback callback;
public void setCallback(ResultFragmentCallback callback) {
this.callback = callback;
}
//endregion
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_result, container, false);
v = initFragment(v);
return v;
}
private View initFragment(View v){
bundleResult = this.getArguments();
ivResultFresque = (ImageView) v.findViewById(R.id.iv_play_result_frag);
tvResultFresque = (TextView) v.findViewById(R.id.tv_play_result_frag);
btnResultFresque = (Button) v.findViewById(R.id.btn_play_result_frag_suivant);
result = bundleResult.getString(GameActivity.FRESQUE_RESULT);
if(result.equals("bravo")){
ivResultFresque.setImageResource(R.drawable.bravo);
tvResultFresque.setText(R.string.tv_game_result_frag_bravo);
}else{
ivResultFresque.setImageResource(R.drawable.rate);
tvResultFresque.setText(R.string.tv_game_result_frag_perdu);
}
ivResultFresque.setAdjustViewBounds(true);
btnResultFresque.setOnClickListener(this);
return v;
}
@Override
public void onClick(View view) {
if(callback!=null){
callback.onClickResult();
}
}
}
| [
"jeremyvdm@gmail.com"
] | jeremyvdm@gmail.com |
db879174cb3964e4a3f424f0cffa87fcdfa3cc43 | e7cb182b976f0fc567dc86eff31d7c901de09248 | /src/main/java/com/zuoyang/singleton/SingletonApplication.java | 7bdc3c8d834e58f6b40376b8de0ba15e3a14f76f | [] | no_license | dxf1998/singleton | 68910ed4079fa8b6fe391f91a18369427009f1e7 | cf3d4606d1ef424d3a33c6a2964217d2cd27345d | refs/heads/master | 2022-02-12T17:36:43.951831 | 2019-07-22T14:06:44 | 2019-07-22T14:06:44 | 198,235,199 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 332 | java | package com.zuoyang.singleton;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SingletonApplication {
public static void main(String[] args) {
SpringApplication.run(SingletonApplication.class, args);
}
}
| [
"zuoyangyuzhong@gmail.com"
] | zuoyangyuzhong@gmail.com |
7c2bb0da8d5afea6c4c5cec9eeecae8af1ab332f | 1c7d2d5cc03112ae3fc1351c0c544faf2132c03f | /android/support/v7/app/AppCompatDialogFragment.java | b6a2cc6a8d5d9ece8e823f883e924d38cdb529e0 | [] | no_license | RishikReddy2408/OS_Hack_1.0.1 | e49eff837ae4f9a03fee9f56c5a3041a3e58dce4 | 23352a6ec7ee17e23a1f5bc0b85ae07f0c3aeeb6 | refs/heads/master | 2020-08-21T13:05:23.391312 | 2019-10-20T05:51:15 | 2019-10-20T05:51:15 | 216,165,741 | 6 | 3 | null | null | null | null | UTF-8 | Java | false | false | 897 | java | package android.support.v7.app;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.package_7.DialogFragment;
import android.support.v4.package_7.Fragment;
import android.view.Window;
public class AppCompatDialogFragment
extends DialogFragment
{
public AppCompatDialogFragment() {}
public Dialog onCreateDialog(Bundle paramBundle)
{
return new AppCompatDialog(getContext(), getTheme());
}
public void setupDialog(Dialog paramDialog, int paramInt)
{
if ((paramDialog instanceof AppCompatDialog))
{
AppCompatDialog localAppCompatDialog = (AppCompatDialog)paramDialog;
switch (paramInt)
{
default:
return;
case 3:
paramDialog.getWindow().addFlags(24);
}
localAppCompatDialog.supportRequestWindowFeature(1);
return;
}
super.setupDialog(paramDialog, paramInt);
}
}
| [
"rishik.s.m.reddy@gmail.com"
] | rishik.s.m.reddy@gmail.com |
6b133f11756448dac6adb37cad1a0752ae23cfa5 | 9f7488e2d48546e9564f6f47cc3e6dd22b1c1b3c | /Array Debugging/src/com/EducacionIt/JSEweb/Clase2/App.java | 18a73d61fcdf95380bdc6bba2a0d41ce668dac85 | [] | no_license | alexdeassis7/JavaStandardWebProgrammingEduIT2019 | 7a51fc7b46038ac16eece796795982b36e5dde00 | 7a555f136dddbda3a3ef44c854cbe66b7836cc7e | refs/heads/master | 2020-07-08T13:04:34.858417 | 2020-02-07T01:06:36 | 2020-02-07T01:06:36 | 203,681,456 | 0 | 0 | null | null | null | null | WINDOWS-1250 | Java | false | false | 1,671 | java | package com.EducacionIt.JSEweb.Clase2;
import javax.swing.JOptionPane;
public class App {
public static void main(String[] args) {
int n1 = Integer.parseInt(JOptionPane.showInputDialog("ingrese un numero"));
int n2 = Integer.parseInt(JOptionPane.showInputDialog("ingrese un numero"));
int resultado = n1 / n2;
JOptionPane.showMessageDialog(null, "resultado de dividir " +n1 + "/ "+ n2 +" ="+ resultado);
//solicitamos datos al usuario para dimensionar la matriz
int CantidadDeElementos = Integer
.parseInt(JOptionPane.showInputDialog("cuantos numeros aleatorios deseas generar"));
//creamos la matriz dinamicamente
int num_aleatorios[] = new int[CantidadDeElementos];
//cargamos la matriz de numeros aleatorios
for (int i = 0; i < num_aleatorios.length; i++) {
//ESTE ES EL ERROR A DEBUGEAR
//num_aleatorios[i] = (int) Math.random() * 100;
//Solución
//num_aleatorios[i] = (int) (Math.random() * 100);
num_aleatorios[i] = (int) Math.random() * 100;//en esta linea agregar un break point
}
System.out.println("mostramos el array ");
for (int i = 0; i < num_aleatorios.length; i++) {
System.out.println(num_aleatorios[i]);
}
System.out.println("Fin del array ");
int array[][] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } };
array[1][1] = 0;
for (int x=0; x < array.length; x++) {
for (int y=0; y < array[x].length; y++) {
System.out.println (array[x][y]);
}
}
}
}
| [
"noreply@github.com"
] | noreply@github.com |
b70edb4dc93e16b5ddaed5991e4f7ddcb592a02f | 560b0fe26827a16eb6ffd16f5b5e3e28844158ba | /java/webserver/src/core/constants/ConstantsServer.java | 221ea28be9cc7b8a9bbf943737cb993640dbdc97 | [] | no_license | timprepscius/mailiverse | 855e76b4d685305e426e6db9f97d15d8e86cf4c3 | 9c7fe87d9723aa81015598a29b4fe1bb61e226ac | refs/heads/master | 2021-01-15T14:29:07.506168 | 2014-01-19T20:11:13 | 2014-01-19T20:11:13 | 11,405,168 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 56 | java | ../../../../core/src/core/constants/ConstantsServer.java | [
"tprepscius"
] | tprepscius |
320c05a6aca70652251ad469e45e3494fcf73600 | 83183bebaddfe95aff6395aa53fa95bfa38b9ce3 | /redisson/src/main/java/org/redisson/api/RRingBuffer.java | 783ec7dada2217eb71ba116c37e61ab11894a459 | [
"Apache-2.0",
"LicenseRef-scancode-dco-1.1"
] | permissive | 1448152236/redisson | 04aeb944400adb2e6fe7d61fa372d01512a38691 | ff9d7c3f957fd5b63db5409949b3ccf259c3c981 | refs/heads/master | 2022-11-27T01:43:40.915469 | 2020-08-05T04:50:34 | 2020-08-05T04:50:34 | 285,321,101 | 1 | 0 | Apache-2.0 | 2020-08-05T14:55:03 | 2020-08-05T14:55:03 | null | UTF-8 | Java | false | false | 1,573 | java | /**
* Copyright (c) 2013-2020 Nikita Koksharov
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.redisson.api;
/**
* RingBuffer based queue evicts elements from the head if queue capacity became full.
* <p>
* The head element removed if new element added and queue is full.
* <p>
* Must be initialized with capacity size {@link #trySetCapacity(int)} before usage.
*
* @author Nikita Koksharov
*
* @param <V> value type
*/
public interface RRingBuffer<V> extends RQueue<V>, RRingBufferAsync<V> {
/**
* Sets queue capacity only if it is not set before.
*
* @param capacity - queue capacity
* @return <code>true</code> if capacity set successfully
* <code>false</code> if capacity already set
*/
boolean trySetCapacity(int capacity);
/**
* Returns remaining capacity of this queue
*
* @return remaining capacity
*/
int remainingCapacity();
/**
* Returns capacity of this queue
*
* @return queue capacity
*/
int capacity();
}
| [
"nkoksharov@redisson.pro"
] | nkoksharov@redisson.pro |
ba0688e061bb782999eb62894bd2235ab7704e6f | ba4ee4fe1a39e215736f35920cfacf7ed460d909 | /CPSC 233/Assignment-5/TimeController.java | 1c54c08530bf484fd789450f60d44692e21198c1 | [] | no_license | MarcFichtel/School | d4dd55c894bda99e81d0c370faff5c4c55fa23bf | 17c3fc33763e0fcd3d61b1e8d94bf67714db961f | refs/heads/master | 2020-04-06T03:49:42.734672 | 2019-07-21T22:07:36 | 2019-07-21T22:07:36 | 50,586,283 | 3 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,112 | java | package GreenhouseSimulator;
/**
* @author Marc-Andre Fichtel
* -- Assignment 5
* -- Course: CPSC 233
* -- University of Calgary
* -- Tutorial 05
* -- Instructor: Edwin Chan
* -- Class keeps track of simulation time and updates display thereof
*/
// TODO Nice-to-have: Make a getTime() method which LogController can use
public class TimeController extends Thread {
/**
* ui: The application's GUI
*/
private GUI ui;
/**
* runTime: The simulation's run time
*/
private int runTime = 0;
/**
* Constructor assigns given values
* @param ui: The application's GUI
*/
public TimeController (GUI ui) {
this.ui = ui;
}
/**
* Update run time every second while simulation is running
*/
@Override
public void run() {
// Only update time when simulation is not paused
while (Controller.getSimInProgress()) {
// Use try/catch to cover any possible error exceptions
try {
// Increment runTime every second
runTime++;
// Convert runTime integer to a string
int hours = 0;
int minutes = 0;
String runTimeString = "";
hours = (runTime/60 - runTime/60/60);
minutes = (runTime%60);
// Adjust time display to show two digit zeros
if (minutes < 10 && hours > 10) {
runTimeString = hours + ":0" + minutes + ":00";
} else if (minutes > 10 && hours < 10) {
runTimeString = "0" + hours + ":" + minutes + ":00";
} else if (minutes > 10 && hours > 10) {
runTimeString = hours + ":" + minutes + ":00";
} else {
runTimeString = "0" + hours + ":0" + minutes + ":00";
}
// Display new run time in ui
ui.setRunTime(runTimeString);
// Wait a second before updating time again
Thread.sleep(1000);
// If simulation is paused, keep threads looping until it is resumed
// TODO check if there's a better way to do this
for (;;) {
if (!Controller.getSimPaused()) {
break;
}
Thread.sleep(1000);
}
// In case of errors, let user know something went wrong
} catch (Exception ex) {
}
}
}
}
| [
"marc.a.fichtel@gmail.com"
] | marc.a.fichtel@gmail.com |
205282a3abecce0959c6845986dc599eb6ff054a | b19c0678e32b7f28803973a3f85c0bbf5d3f401a | /markymark-contentful/src/test/java/com/m2mobi/markymarkcontentful/rules/inline/ItalicRuleTest.java | c4217821123ef2f530f770678d3d26273b7524f6 | [
"MIT"
] | permissive | tpgmeligmeyling/MarkyMark-Android | de7d59ceb9e29e3536dfcd8a53a637a400271dbd | 0532871968e2fb5bc5d27457cbd667ce6936b01f | refs/heads/master | 2022-12-18T23:24:00.909599 | 2018-03-20T15:34:05 | 2018-03-20T15:34:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 701 | java | /*
* Copyright (C) M2mobi BV - All Rights Reserved
*/
package com.m2mobi.markymarkcontentful.rules.inline;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
/**
* Tests for {@link ItalicRule}
*/
public class ItalicRuleTest {
private ItalicRule mItalicRule = null;
@Before
public void init() {
mItalicRule = new ItalicRule();
}
@Test
public void shouldCreateItalicString() {
assertEquals("text", mItalicRule.toMarkDownString("*text*").getContent());
}
@Test
public void shouldNotCreateItalicString() {
assertNotEquals("text", mItalicRule.toMarkDownString("$$text$$").getContent());
}
} | [
"n.masdorp@m2mobi.com"
] | n.masdorp@m2mobi.com |
21165605e2cd16cd6276286ddbbbfd3695eea1d8 | 03dd2ed2d3b9326fb237b7d1c53c0ba37851421c | /mooc-java-programming-i/mavenproject1/src/main/java/Berechnung.java | 10360464fa085d5eed656041f4254b667000dbfb | [] | no_license | Dennis-V1/master | c6c6a5d6667e74d314db919db5b6960d678a8189 | edb4fe0595f18f6f725878ec179281435fff1fc2 | refs/heads/main | 2023-06-18T19:44:36.983737 | 2021-07-20T06:27:01 | 2021-07-20T06:27:01 | 348,995,738 | 0 | 0 | null | 2021-03-25T13:01:18 | 2021-03-18T08:27:44 | JavaScript | UTF-8 | Java | false | false | 2,578 | java | import java.util.Scanner;
import java.io.File;
import java.io.FileWriter;
import java.util.ArrayList;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.ArrayList;
public class Berechnung {
int anzahlen;
double preis;
double netto = 1.19;
double gesamtpreis;
double nachlass;
int gesamtMenge;
File artikelFile = new File("Artikel.txt");
ArrayList<Artikel> artikelListe = new ArrayList<>();
int menge1;
String bez;
int id;
String [] parts;
public void Berechnen(){
}
public void readArticleFromFile(String fileLine) throws FileNotFoundException{
Scanner scanner = new Scanner(artikelFile);
while (scanner.hasNextLine()){
String line =scanner.nextLine();
Artikel art = getArticleFromLine(line);
artikelListe.add(art);
}
}
public Artikel getArticleFromLine(String fileLine){
parts = fileLine.split(",");
id = Integer.parseInt(parts[0]);
bez = parts[1];
preis = Double.valueOf(parts[2]);
menge1 = Integer.parseInt(parts[3]);
Artikel art = new Artikel(id , bez , preis , menge1);
return art;
}
public void rechnungBerechnenUndAusgeben(ArrayList<Artikel> i){
int gesamtMenge = 0;
double gesamtpreisNachlass;
nachlass = 0.03;
System.out.println("Sie Kaufen: ");
for (Artikel art : i){
gesamtMenge = gesamtMenge + art.getanzahlKaufen();
if(art.getanzahlKaufen() > 0){
System.out.println(art.bez + " " + art.anzahlKaufen);
}
}
for (Iterator<Artikel> artikel = artikelListe.iterator(); artikel.hasNext();) {
gesamtpreis = (Artikel.getpreis(preis) * netto) * anzahlen;
//??? cannot find symbol symbol: method getpreis(double) location: class Artikel
}
if(gesamtMenge > 3){
gesamtpreisNachlass = gesamtpreis - (gesamtpreis * nachlass);
System.out.println("Ihr zu zahlender Preis ist " + gesamtpreisNachlass + "€");
}else{
System.out.println("Ihr zu zahlender Preis ist " + gesamtpreis + "€");
}
}
public void ausgabeRechnunug(){
for(Artikel a : artikelListe){
System.out.println(a);
//soll mir anzeigen was in meiner Artikelliste ist. https://stackoverflow.com/questions/2047003/print-arraylist-element/46814414
}
}
}
| [
"71431080+Dennis-V1@users.noreply.github.com"
] | 71431080+Dennis-V1@users.noreply.github.com |
350162faad500e2c4ebcf6a0f4fc3d5916c14fad | bc1f47b685eea2af782ab1ed8520b69b307149a0 | /myicpc-service-schedule/src/main/java/com/myicpc/service/schedule/receiver/ScheduleNotificationReceiver.java | d5b7e4375c4598da021369b9fe23373876f53619 | [] | no_license | designreuse/myicpc | 914f0aabdb8508b09ff23fa1a2bbf09fd3298097 | 88beb2cd1b3b56d9203e55364b4579e4442bfa8a | refs/heads/master | 2021-04-26T16:42:01.106394 | 2016-01-31T17:20:33 | 2016-01-31T17:20:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,580 | java | package com.myicpc.service.schedule.receiver;
import com.myicpc.dto.jms.JMSEvent;
import com.myicpc.model.contest.Contest;
import com.myicpc.repository.contest.ContestRepository;
import com.myicpc.service.schedule.ScheduleMngmService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Receives JMS messages related to schedule
* <p/>
* It invokes methods to process the coming messages
*
* @author Roman Smetana
*/
@Service
public class ScheduleNotificationReceiver {
@Autowired
private ScheduleMngmService scheduleMngmService;
@Autowired
private ContestRepository contestRepository;
/**
* Listens to JMS queue {@code ScheduleNotificationQueue}
*
* @param jmsEvent incoming message
*/
@JmsListener(destination = "java:/jms/queue/ScheduleNotificationQueue")
@Transactional
public void processQuestEvent(JMSEvent jmsEvent) {
if (jmsEvent == null) {
return;
}
Contest contest = contestRepository.findOne(jmsEvent.getContestId());
if (contest == null) {
return;
}
switch (jmsEvent.getEventType()) {
case SCHEDULE_OPEN_EVENT:
processNewOpenEvent(contest);
break;
}
}
private void processNewOpenEvent(Contest contest) {
scheduleMngmService.createNonPublishedEventNotifications(contest);
}
}
| [
"smetarom@gmail.com"
] | smetarom@gmail.com |
5da862aafc20f145a316435df706f60666a8dae8 | a193cfff36701a35919f7eed46776aeb002773a8 | /Zombie.java | 2e2c81905553932ee180dddc2be096976f67182c | [] | no_license | VinnyTsoi/Java-Interface-Practice-Monster-Class | 5345eedcb9f39ad723583127bf833bddd028e46f | 674b4cca0e10c043f9e9aa1f47361506e22891be | refs/heads/master | 2020-04-15T03:15:49.679915 | 2019-01-06T20:47:11 | 2019-01-06T20:47:11 | 164,342,319 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,583 | java | import java.util.ArrayList;
import java.util.List;
/**
* Created by Vinny Tsoi on 06/01/2019
*/
public class Zombie implements ISaveable {
private String name;
private int strength;
private String weapon;
public Zombie(String name, int strength, String weapon) {
this.name = name;
this.strength = strength;
this.weapon = weapon;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getStrength() {
return strength;
}
public void setStrength(int strength) {
this.strength = strength;
}
public String getWeapon() {
return weapon;
}
public void setWeapon(String weapon) {
this.weapon = weapon;
}
@Override
public String toString() {
return "\nZombie{" +
"name='" + name + '\'' +
", strength='" + strength + '\'' +
", weapon=" + weapon +
'}';
}
@Override
public List<String> write() {
List<String> values = new ArrayList<>();
values.add(0, this.name);
values.add(1, "" + this.strength);
values.add(2, this.weapon);
return values;
}
@Override
public void read(List<String> savedValues) {
if(savedValues != null && savedValues.size() > 0){
this.name = savedValues.get(0);
this.strength = Integer.parseInt(savedValues.get(1));
this.weapon = savedValues.get(2);
}
}
} //class | [
"29221913+VinnyTsoi@users.noreply.github.com"
] | 29221913+VinnyTsoi@users.noreply.github.com |
1707e1bf8dba4cf7a92b074f5aaee8a7b6cea600 | 68b801a185c1e9a9f29e1c9850c644183e26ca0d | /src/main/java/array/problems/Problem006.java | 16e62d3e3e978af2702441b820a50e7c3b4163c3 | [] | no_license | avishekgurung/algo | c081f8fbd11d22eed87d17a6db7e6f5aa52c0706 | c63f86634d94bb4b74dbb17f4b51129bcc7b7e17 | refs/heads/master | 2021-08-03T00:08:25.868723 | 2021-07-27T05:43:07 | 2021-07-27T05:43:07 | 155,651,748 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,203 | java | package array.problems;
public class Problem006 {
public static int gallopSearch(int arr[]) {
int i=1;
while ( true ) { //Not using size of an array as it may take long to calculate it internally.
if(arr[i] == 0) break;
i = i * 2;
}
while(arr[i] != 1) {
i--;
}
return i + 1;
}
public static void main(String[] args) {
int arr[] = new int[]{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
,0,0,0,0,0,0,0,0,0,0,0,0};
System.out.println(gallopSearch(arr));
}
}
/**
* To make it more efficient.
* Lets say that the list is really long. While galloping, we found 0 at index 5000. But the first
* 0 is at 2500. Here we have to traverse 2500 backwards to get the first index of zero. To improve
* the performance, we can always not the last value of i. When we find 0, then the first 0 would
* lie between last value of i and current value of i. We can now use binary search to find the
* first value of 0. The complexity decreases by log. So before, it would take 2500 and now it
* will take log(2500)
*
*/
| [
"avishek@mediaiqdigital.com"
] | avishek@mediaiqdigital.com |
396af7c262c26198127f7344190669754536e4c9 | 24a3fca98e909b9a62433856f2616de5d45f075a | /Java Sessions/src/Selenium2/BootstrapDropDownHandle.java | 5250f35c712841b3f2badc6d6cf5ac2cd0989246 | [] | no_license | swamyshiva143/JavaSessions | 754dafd32e044b6cc8a9f5e40b3a571641ef0629 | 20a7ee7282d995906aeac1ec454ef96b8d1a71ad | refs/heads/master | 2023-04-01T06:29:38.256112 | 2021-04-09T09:01:10 | 2021-04-09T09:01:10 | 331,869,001 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,487 | java | package Selenium2;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class BootstrapDropDownHandle {
public static void main(String[] args) throws InterruptedException {
System.setProperty("webdriver.chrome.driver", "D:\\Swamyshiva\\swamyshiva\\chromedriver\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().deleteAllCookies();
driver.manage().timeouts().pageLoadTimeout(40, TimeUnit.SECONDS);
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.get("https://www.jquery-az.com/boots/demo.php?ex=63.0_2");
Thread.sleep(5000);
driver.findElement(By.xpath("//button[@class='multiselect dropdown-toggle btn btn-default']")).click();
List<WebElement> list= driver.findElements(By.xpath("//ul[contains(@class,'multiselect')]//li//a//label"));
System.out.println(list.size());
Thread.sleep(10000);
// //selecting all the checkboxes/options;
// for(int i=0; i<list.size();i++) {
// System.out.println(list.get(i).getText());
// list.get(i).click();
//
// }
//selecting individual option
for(int i=0; i<list.size();i++) {
System.out.println(list.get(i).getText());
if(list.get(i).getText().contains("Java")) {
list.get(i).click();
break;
}
}
}
}
| [
"Swamyshiva@google.com"
] | Swamyshiva@google.com |
ebd979c4f445b92b1facc054dab543df964d06e7 | 09d7cb798182f8118ab01439958d7f7a07d969c6 | /HaftaiciAksam/17.10.2017/NotDefteriUygulamasi/main/java/com/serifgungor/notdefteriuygulamasi/NotEkleActivity.java | fd3c091b2e7779bf0ae8cb3bf96f59a1d77d7675 | [] | no_license | hamiozturk/AndroidCourseTutorials | 0583b10660a0fc4773cddd63a6cb6edf21a2a672 | fe915c9d78c06ad4622cb9de4c9fe0447eb8e8b6 | refs/heads/master | 2021-04-26T03:38:18.380212 | 2017-10-23T04:14:17 | 2017-10-23T04:14:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,280 | java | package com.serifgungor.notdefteriuygulamasi;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
public class NotEkleActivity extends AppCompatActivity {
public int notEkle(
String dbName,
String baslik,
String tarih,
String not
){
SQLiteDatabase db = openOrCreateDatabase(dbName,MODE_PRIVATE,null);
db.execSQL("Create Table if not exists Notlar(id INTEGER PRIMARY KEY, Baslik varchar, Tarih varchar, Icerik varchar)");
// eğer yoksa Notlar isimli tablo oluştur
db.execSQL("insert into Notlar values(NULL,'"+baslik+"','"+tarih+"','"+not+"')");
//Notlar tablosuna veri ekle
Cursor c = db.rawQuery("Select last_insert_rowid()",null);
c.moveToFirst();
int id = c.getInt(0);
return id;
}
EditText etBaslik,etTarih,etNot;
Button btnNotEkle;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_not_ekle);
etBaslik = (EditText)findViewById(R.id.etBaslik);
etNot = (EditText)findViewById(R.id.etIcerik);
etTarih = (EditText)findViewById(R.id.etTarih);
btnNotEkle = (Button)findViewById(R.id.btnNotEkle);
btnNotEkle.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int id = notEkle(
"myDB",
etBaslik.getText().toString(),
etTarih.getText().toString(),
etNot.getText().toString()
);
Not not = new Not(id,etBaslik.getText().toString(),etTarih.getText().toString(),etNot.getText().toString());
Intent intent=new Intent();
intent.putExtra("not",not);
setResult(10,intent);
finish();
}
});
}
}
| [
"noreply@github.com"
] | noreply@github.com |
1009b1569940d9e89145ae8645a5e5cae67eaaa9 | 921a4c87528aaa7993e70d98405f22e972d7a9b9 | /src/test/java/one/digitalinnovation/personapi/DemoapiApplicationTests.java | 5200264b6d60a3bf8a3650c19ed6c90445a136c5 | [] | no_license | ltsuga/Person-pi | 7d168cbd37bac00c465c7a4fa988a62234e49021 | 798a65108924fa58de25fd5cc9f7ee737d86634b | refs/heads/master | 2023-07-18T07:23:27.312133 | 2021-09-07T01:09:21 | 2021-09-07T01:09:21 | 403,799,637 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 224 | java | package one.digitalinnovation.personapi;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DemoapiApplicationTests {
@Test
void contextLoads() {
}
}
| [
"ltsuga@gmail.com"
] | ltsuga@gmail.com |
ee509374b602dbdf5dd3104016bc043598c2e8d0 | 9bc02fd3c81aa69f64fb76d600844380eca7c524 | /src/main/java/com/liuyun/constantpool/ConstantDoubleInfo.java | 7e2b286eacf89fadca8a2dff15d1599b3b7baa18 | [] | no_license | neighbWang/ClassAnalyzer | 734a13264c197cd9ffca517287fc1d789c5b800d | 5027fac5ecc8d96cf2aae11763b4eace100798a4 | refs/heads/master | 2020-03-23T12:37:12.837161 | 2018-03-26T01:14:53 | 2018-03-26T01:14:53 | 141,570,871 | 1 | 0 | null | 2018-07-19T11:36:52 | 2018-07-19T11:36:52 | null | UTF-8 | Java | false | false | 585 | java | package com.liuyun.constantpool;
import com.liuyun.basictype.U8;
import java.io.InputStream;
public class ConstantDoubleInfo extends ConstantPoolInfo {
private double bytesValue;
public ConstantDoubleInfo(byte tag) {
setTag(tag);
}
@Override
public void read(InputStream inputStream) {
U8 bytesValuesU8 = U8.read(inputStream);
this.bytesValue = bytesValuesU8.getValue();
}
@Override
public String toString() {
return "ConstantDoubleInfo{" +
"bytesValue=" + bytesValue +
'}';
}
}
| [
"yun.liu01@hand-china.com"
] | yun.liu01@hand-china.com |
1ad05e69c8a2f854a0e4b4bf719607a79936beae | 99073462e9ffa6785fe09295ab4a5eff20c60316 | /app/src/main/java/com/szOCR/camera/ViewfinderView.java | bd9ceb5d055d81e75882b6fcd48a58246ecf8cc0 | [
"MIT"
] | permissive | hcxxiaomo/ChCarAppNew_as | bb632e8f7efd933d2958b47d979fd956baeb6705 | a3b32c8d1cdb7606610fd597e7d6dc054e886c7d | refs/heads/master | 2021-08-30T01:32:33.816587 | 2017-11-29T09:18:15 | 2017-11-29T09:18:15 | 107,877,076 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,622 | java | package com.szOCR.camera;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PointF;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.util.FloatMath;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import com.carOCR.activity.ScanActivity;
import com.szOCR.general.CGlobal;
import com.xiaomo.chcarappnew.R;
/**
* This view is overlaid on top of the camera preview. It adds the viewfinder rectangle and partial
* transparency outside it, as well as the laser scanner animation and result points.
*
*/
public final class ViewfinderView extends View implements OnTouchListener
{
private static final int[] SCANNER_ALPHA = {0, 64, 128, 192, 255, 192, 128, 64};
private static final long ANIMATION_DELAY = 500L;//100L;
private static final int OPAQUE = 0xFF;
private final Paint paint;
private Bitmap resultBitmap;
private final int maskColor;
private final int laserColor;
private int scannerAlpha;
public int m_top = 0;
public int m_height = 0;
private float delta;
private long stTime;
public Activity mActivity;
float fOriginalDis = 0;
int nZoomValue = 0;
// This constructor is used when the class is built from an XML resource.
public ViewfinderView(Context context, AttributeSet attrs)
{
super(context, attrs);
// Initialize these once for performance rather than calling them every time in onDraw().
paint = new Paint();
Resources resources = getResources();
maskColor = resources.getColor(R.color.viewfinder_frame);
laserColor = resources.getColor(R.color.viewfinder_laser);
scannerAlpha = 0;
delta = 1.0F;
delta = getResources().getDisplayMetrics().density / 1.5F;
stTime = System.currentTimeMillis();
mActivity = (Activity)context;
setOnTouchListener(this);
}
public ViewfinderView(Context context) {
super(context);
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
Resources resources = getResources();
maskColor = 0x60000000;//resources.getColor(viewfinder_mask);
//resultColor = 0xb0000000;//resources.getColor(R.color.result_view);
laserColor = 0xffcc0000;//resources.getColor(R.color.viewfinder_laser);
//resultPointColor = 0xc0ffbd21;//resources.getColor(R.color.possible_result_points);
scannerAlpha = 0;
delta = 1.0F;
delta = getResources().getDisplayMetrics().density / 1.5F;
stTime = System.currentTimeMillis();
mActivity = (Activity)context;
setOnTouchListener(this);
}
@Override
public void onDraw(Canvas canvas)
{
//Rect frame = new Rect(50,50,320,320);//CameraManager.get().getFramingRect());
Rect frame = new Rect(CGlobal.g_scrCropRect);
//
// int nTopMargin = 0;
// int nLeftMargin = 0;
//
// if (CGlobal.g_scanActivity.mCameraPreview != null)
// {
// int nWidth = canvas.getWidth();
// int nHeight = canvas.getHeight();
//
// Rect cameraView = new Rect(0,0,0,0);
// CGlobal.g_scanActivity.mCameraPreview.getGlobalVisibleRect(cameraView);
// int nCameraWidth = cameraView.width();
// int nCameraHeight = cameraView.height();
//
// nTopMargin = (nHeight - nCameraHeight) / 2;
// nLeftMargin = (nWidth - nCameraWidth) / 2;
//
// }
//
// frame.top += (nTopMargin - 30);
// frame.bottom += (nTopMargin - 30);
//
// frame.left += nLeftMargin;
// frame.right += nLeftMargin;
//
if (isPortrait())
{
frame.top -= frame.height() / 12;
frame.bottom -= frame.height() / 12;
}
else
{
frame.left -= frame.width() / 12;
frame.right -= frame.width() / 12;
}
if (frame == null)
{
return;
}
int width = canvas.getWidth();
int height = canvas.getHeight();
// Draw the exterior (i.e. outside the framing rect) darkened
//paint.setColor(resultBitmap != null ? resultColor : maskColor);
paint.setColor(0x11111111);//22222222);//55555555);//77777777);
//paint.setAlpha(OPAQUE);
paint.setAlpha(200);
//
// canvas.drawRect(0, 0, width, frame.top, paint);
// canvas.drawRect(0, frame.top, frame.left, frame.bottom + 1, paint);
// canvas.drawRect(frame.right + 1, frame.top, width, frame.bottom + 1, paint);
// canvas.drawRect(0, frame.bottom + 1, width, height, paint);
//
if (resultBitmap != null) {
// Draw the opaque result bitmap over the scanning rectangle
paint.setAlpha(OPAQUE);
canvas.drawBitmap(resultBitmap, frame.left, frame.top, paint);
} else {
// Draw a two pixel solid black border inside the framing rect
// paint.setColor(Color.WHITE);//frameColor);
// canvas.drawRect(frame.left, frame.top, frame.right + 1, frame.top + 2, paint);
// canvas.drawRect(frame.left, frame.top + 2, frame.left + 2, frame.bottom - 1, paint);
// canvas.drawRect(frame.right - 1, frame.top, frame.right + 1, frame.bottom - 1, paint);
// canvas.drawRect(frame.left, frame.bottom - 1, frame.right + 1, frame.bottom + 1, paint);
int corner, margin;
corner = (frame.bottom - frame.top) / 8;
//paint.setStyle(android.graphics.Paint.Style.FILL_AND_STROKE);//FILL);
if(CGlobal.g_bAutoFocused == false)
paint.setColor(Color.RED);
else
paint.setColor(Color.GREEN);
//paint.setColor(-0xFF0100);
paint.setColor(Color.GREEN);
Rect inFrame = new Rect(frame);
margin = (frame.bottom - frame.top) / 6;
inFrame.left = inFrame.left + margin;
inFrame.top = inFrame.top + margin;
inFrame.right = inFrame.right - margin;
inFrame.bottom = inFrame.bottom - margin;
// canvas.drawRect(createRect(inFrame.left, inFrame.top, inFrame.left + corner, inFrame.top), paint);
// canvas.drawRect(createRect(inFrame.left, inFrame.top, inFrame.left, inFrame.top + corner), paint);
// canvas.drawRect(createRect(inFrame.right, inFrame.top, inFrame.right - corner, inFrame.top), paint);
// canvas.drawRect(createRect(inFrame.right, inFrame.top, inFrame.right, inFrame.top + corner), paint);
// canvas.drawRect(createRect(inFrame.left, inFrame.bottom, inFrame.left + corner, inFrame.bottom), paint);
// canvas.drawRect(createRect(inFrame.left, inFrame.bottom, inFrame.left, inFrame.bottom - corner), paint);
// canvas.drawRect(createRect(inFrame.right, inFrame.bottom, inFrame.right - corner, inFrame.bottom), paint);
// canvas.drawRect(createRect(inFrame.right, inFrame.bottom, inFrame.right, inFrame.bottom - corner), paint);
// Draw a red "laser scanner" line through the middle to show decoding is active
// paint.setColor(laserColor);
// paint.setAlpha(SCANNER_ALPHA[scannerAlpha]);
// scannerAlpha = (scannerAlpha + 1) % SCANNER_ALPHA.length;
// int middle = frame.height() / 2 + frame.top;
// canvas.drawRect(frame.left + 2, middle - 1, frame.right - 1, middle + 2, paint);
// Request another update at the animation interval, but only repaint the laser line,
// not the entire viewfinder mask.
postInvalidateDelayed(ANIMATION_DELAY, frame.left, frame.top, frame.right, frame.bottom);
}
}
private Rect createRect(int left, int top, int right, int bottom)
{
int offset = (int)(2F * delta);
Rect rect = new Rect();
rect.left = Math.min(left, right) - offset;
rect.right = Math.max(left, right) + offset;
rect.top = Math.min(top, bottom) - offset;
rect.bottom = Math.max(top, bottom) + offset;
return rect;
}
public boolean isPortrait() {
return (mActivity.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
}
public void drawViewfinder()
{
resultBitmap = null;
invalidate();
}
public boolean onTouch(View v, MotionEvent event)
{
int i1;
int i2;
if (event.getPointerCount() >= 3 || event.getPointerCount() < 2)
{
return true;
}
switch (event.getAction() & MotionEvent.ACTION_MASK)
{
case MotionEvent.ACTION_DOWN: // first finger down only
fOriginalDis = 0;
break;
case MotionEvent.ACTION_UP: // first finger lifted
{
fOriginalDis = 0;
ScanActivity parentAct = (ScanActivity)mActivity;
parentAct.mZoomValue = nZoomValue;
CGlobal.g_nCameraZoomFactor = nZoomValue;
break;
}
case MotionEvent.ACTION_POINTER_UP: // second finger lifted
{
fOriginalDis = 0;
ScanActivity parentAct = (ScanActivity)mActivity;
parentAct.mZoomValue = nZoomValue;
CGlobal.g_nCameraZoomFactor = nZoomValue;
break;
}
case MotionEvent.ACTION_POINTER_DOWN: // first and second finger down
fOriginalDis = distance(event);
break;
case MotionEvent.ACTION_MOVE:
{
ScanActivity parentAct = (ScanActivity)mActivity;
if (parentAct != null)
{
if (fOriginalDis <= 0)
break;
float fDis = distance(event) - fOriginalDis;
nZoomValue = (int)(parentAct.mZoomValue + (parentAct.mZoomMax * fDis / 1000));
if (nZoomValue < 0)
nZoomValue = 0;
if (nZoomValue > parentAct.mZoomMax)
nZoomValue = parentAct.mZoomMax;
parentAct.mCameraPreview.setCameraZoomIndex(nZoomValue);
}
break;
}
}
// invalidate();
return true;
}
private float distance(MotionEvent event){
float x = event.getX(0) - event.getX(1);
float y = event.getY(0) - event.getY(1);
return (float) Math.sqrt(x * x + y * y);
}
private PointF middle( MotionEvent event) {
float x = event.getX(0) + event.getX(1);
float y = event.getY(0) + event.getY(1);
return new PointF(x / 2, y / 2);
}
}
| [
"hcxxiaomo@163.com"
] | hcxxiaomo@163.com |
36f8993d874ec586fff4d1f3bdcd0362bb28f0ee | 82375f21398033e72627093966b2066dae148b25 | /collectors/deploy/blade/src/main/java/com/capitalone/dashboard/model/SplunkEvent.java | 3f291df13cc7784748c0fbf4c25beef7a1276165 | [
"Apache-2.0"
] | permissive | pk277/Hygieia-WFN | 92b05556bf547c619cab7fa9f0535796d48a7fff | 9233dafca3c3ad0ac6c94813e8f322eac3c89f07 | refs/heads/master | 2021-01-25T09:44:12.227554 | 2017-12-20T13:40:06 | 2017-12-20T13:40:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,082 | java | package com.capitalone.dashboard.model;
import java.util.List;
public class SplunkEvent {
private String host;
private String pod;
private List<String> components;
private String lastDeploymentTime;
private String deploymentStatus;
private String deploymentId;
public String getDeploymentId(){
return deploymentId;
}
public void setDeploymentId(String deploymentId){
this.deploymentId = deploymentId;
}
public void setHost(String host){
this.host=host;
}
public void setPod(String pod){
this.pod=pod;
}
public void setComponents(List<String> components){
this.components=components;
}
public void setLastDeploymentTime(String lastDeploymentTime){
this.lastDeploymentTime=lastDeploymentTime;
}
public void setdeploymentStatus(String deploymentStatus){
this.deploymentStatus=deploymentStatus;
}
public String getHost(){
return host;
}
public String getPod(){
return pod;
}
public List<String> getComponents(){
return components;
}
public String getLastDeploymentTime(){
return lastDeploymentTime;
}
public String getDeploymentStatus(){
return deploymentStatus;
}
}
| [
"VenkataHarish.Kasibhotla@ADP.com"
] | VenkataHarish.Kasibhotla@ADP.com |
7e0699fc1af03e46d661509ecd7a3ed90ef0e777 | 56fa77ca4779b001e9d28caa35126434bbdfad30 | /Hardware_Orders/BallBearingTest.java | 86b87107d225c40a1bff42e5745e43bd9dd436ac | [] | no_license | Zachary51/PDP | 6bdfe8719abf93ce3e750a5ef3e00c12a4b388eb | c0bce3b4bec79dd858e1155a919f3d5775b05d63 | refs/heads/master | 2020-03-29T21:26:54.389430 | 2018-10-17T20:47:45 | 2018-10-17T20:47:45 | 150,367,285 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,315 | java | package edu.neu.ccs.cs5010.assignment2;
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* This test is used to test all the methods in BallBearing class
*/
public class BallBearingTest {
private BallBearing ballBearingMetric;
private RotaryShaft fits;
private RotaryShaft unfits;
private BallBearing ballBearingOpen;
private BallBearing ballBearingSealed;
@Before
public void setUp() throws Exception {
this.ballBearingMetric = new BallBearing("BallBearing", "5972K323", new Price(754),
SealType.SHIELDED, new Fraction(8, 0,1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
this.fits = new RotaryShaft("RotaryShaft", "1482K25", new Price(4009),
false, new Fraction(2000, 0, 1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC);
this.unfits = new RotaryShaft("RotaryShaft", "1482K49", new Price(1755),
false, new Fraction(200, 0, 1), new Fraction(30, 0, 1),
SystemOfMeasurement.METRIC);
this.ballBearingOpen = new BallBearing("BallBearing", "5972K91", new Price(432),
SealType.OPEN, new Fraction(7, 0, 1), new Fraction(8, 0, 1),
SystemOfMeasurement.STANDARD, true);
this.ballBearingSealed = new BallBearing("BallBearing", "5972K225", new Price(2026),
SealType.SEALED, new Fraction(6, 0, 1), new Fraction(7, 0 , 1),
SystemOfMeasurement.METRIC, true);
}
/**
* Test the getSealType method when the seal type is shielded, open and sealed
*/
@Test
public void getSealType() {
Assert.assertEquals(SealType.SHIELDED, this.ballBearingMetric.getSealType());
Assert.assertEquals(SealType.OPEN, this.ballBearingOpen.getSealType());
Assert.assertEquals(SealType.SEALED, this.ballBearingSealed.getSealType());
}
/**
* Test the getWidth method by comparing all three parts in the width
*/
@Test
public void getWidth() {
Assert.assertEquals(8, this.ballBearingMetric.getWidth().getIntegerPart());
Assert.assertEquals(0, this.ballBearingMetric.getWidth().getNumerator());
Assert.assertEquals(1, this.ballBearingMetric.getWidth().getDenominator());
}
/**
* Test the getSystemOfMeasurement method when the system of measurement is metric and standard
*/
@Test
public void getSystemOfMeasurement() {
Assert.assertEquals(SystemOfMeasurement.METRIC, this.ballBearingMetric.getSystemOfMeasurement());
Assert.assertEquals(SystemOfMeasurement.STANDARD, this.ballBearingOpen.getSystemOfMeasurement());
}
/**
* Test the fitsShaft method when the rotary object fits the item
*/
@Test
public void fitsShaft() {
Assert.assertEquals(true, this.ballBearingMetric.fitsShaft(fits));
}
/**
* Test the fitsShaft method when the rotary object unfits the item
*/
@Test
public void unfitsShaft(){
Assert.assertEquals(false, this.ballBearingMetric.fitsShaft(unfits));
}
/**
* Test the getCategory method
*/
@Test
public void getCategory() {
Assert.assertEquals("BallBearing", this.ballBearingMetric.getCategory());
}
/**
* Test the getSKUNumber method
*/
@Test
public void getSKUNumber() {
Assert.assertEquals("5972K323", this.ballBearingMetric.getSKUNumber());
}
/**
* Test the getPrice method by comparing dollars amount and cents amount
*/
@Test
public void getPrice() {
Assert.assertEquals(7, this.ballBearingMetric.getPrice().getDollars());
Assert.assertEquals(54, this.ballBearingMetric.getPrice().getCents());
}
/**
* Test the isShaftMounted method
*/
@Test
public void isShaftMounted() {
Assert.assertEquals(true, this.ballBearingMetric.isShaftMounted());
Assert.assertEquals(false, this.fits.isShaftMounted());
}
/**
* Test the updatePrice method
*/
@Test
public void updatePrice() {
this.ballBearingMetric.updatePrice(756);
Assert.assertEquals(7, this.ballBearingMetric.getPrice().getDollars());
Assert.assertEquals(56, this.ballBearingMetric.getPrice().getCents());
}
/**
* All the following tests are testing the exception case when inputs are not valid
*/
@Test(expected = IllegalArgumentException.class)
public void nullCategory(){
BallBearing nullCategory = new BallBearing(null, "5972K323", new Price(754),
SealType.SHIELDED, new Fraction(8, 0,1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
nullCategory.getCategory();
}
@Test(expected = IllegalArgumentException.class)
public void emptyCategory() {
BallBearing emptyCategory = new BallBearing("", "5972K323", new Price(754),
SealType.SHIELDED, new Fraction(8, 0, 1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
emptyCategory.getCategory();
}
@Test(expected = IllegalArgumentException.class)
public void nullSKUNumber(){
BallBearing nullSKUNumber = new BallBearing("RotaryShaft", null, new Price(754),
SealType.SHIELDED, new Fraction(8, 0,1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
nullSKUNumber.getCategory();
}
@Test(expected = IllegalArgumentException.class)
public void emptySKUNumber() {
BallBearing emptySKUNumber = new BallBearing("RotaryShaft", "", new Price(754),
SealType.SHIELDED, new Fraction(8, 0, 1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
emptySKUNumber.getCategory();
}
@Test(expected = IllegalArgumentException.class)
public void nullPrice(){
BallBearing nullPrice = new BallBearing("RotaryShaft", "5972K323", null,
SealType.SHIELDED, new Fraction(8, 0, 1), new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
nullPrice.getPrice();
}
@Test(expected = IllegalArgumentException.class)
public void nullWidth(){
BallBearing nullWidth = new BallBearing("RotaryShaft", "5972K323", new Price(754),
SealType.SHIELDED,null, new Fraction(12, 0, 1),
SystemOfMeasurement.METRIC, true);
nullWidth.getWidth();
}
@Test(expected = IllegalArgumentException.class)
public void nullDiameter(){
BallBearing nullDiameter = new BallBearing("RotaryShaft", "5972K323", new Price(754),
SealType.SHIELDED,new Fraction(8, 0, 1), null,
SystemOfMeasurement.METRIC, true);
}
} | [
"zaricwong51@gmail.com"
] | zaricwong51@gmail.com |
fe78cab8786abe976875581625e6421722052e0c | 789ea5be5e636730f6d467a2d2b1c6f9bb55e878 | /VCUtils/src/main/java/net/vaultcraft/vcutils/uncommon/FireworkEffectPlayer.java | 3d3a341646b9be0f8b1bb72ca83dff47e47eddd0 | [] | no_license | VaultCraft/VCParent | 7903e7c297988e377d9a95c66be02b9c7ab955a0 | cae42e620edbf654dc0e81b3fc832b17d5295ab2 | refs/heads/master | 2021-01-10T14:34:19.985161 | 2015-02-22T03:51:18 | 2015-02-22T03:51:18 | 31,283,014 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,246 | java | package net.vaultcraft.vcutils.uncommon;
import net.minecraft.server.v1_7_R4.EntityFireworks;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityStatus;
import net.minecraft.server.v1_7_R4.World;
import net.vaultcraft.vcutils.VCUtils;
import org.bukkit.Bukkit;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.FireworkMeta;
public class FireworkEffectPlayer extends EntityFireworks {
Player[] players = null;
public FireworkEffectPlayer(World world, Player... p) {
super(world);
players = p;
this.a(0.25F, 0.25F);
}
boolean gone = false;
@Override
public void h() {
if (gone) {
return;
}
if (!this.world.isStatic) {
gone = true;
if (players != null) {
if (players.length > 0) {
for (Player player : players) {
(((CraftPlayer) player).getHandle()).playerConnection.sendPacket(new PacketPlayOutEntityStatus(this, (byte) 17));
}
this.die();
return;
}
}
world.broadcastEntityEffect(this, (byte) 17);
this.die();
}
}
public static void playFirework(org.bukkit.World world, Location location, FireworkEffect effect) {
try {
FireworkEffectPlayer firework = new FireworkEffectPlayer(((CraftWorld) location.getWorld()).getHandle(), Bukkit.getOnlinePlayers().toArray(new Player[0]));
FireworkMeta meta = ((Firework) firework.getBukkitEntity()).getFireworkMeta();
meta.addEffect(effect);
((Firework) firework.getBukkitEntity()).setFireworkMeta(meta);
firework.setPosition(location.getX(), location.getY(), location.getZ());
if ((((CraftWorld) location.getWorld()).getHandle()).addEntity(firework)) {
firework.setInvisible(true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
} | [
"connor@hollasch.net"
] | connor@hollasch.net |
e80739410f5fa731056d46718e2c97a56fb24100 | 4e081e0b140cbc8ff8fef9cbd7c546a432e819a7 | /chess1.2/test/chess/junit/PiecesTest.java | 130dc3c812f44236951784c6fd5148207a8093a4 | [] | no_license | zheXiLiu/Chess_Library | 2668175a59011e16623c1f420102f41841d8e3ba | c90842381809cd58119ace819c1e68b30ceff346 | refs/heads/master | 2021-01-10T21:08:52.249094 | 2013-02-13T10:40:01 | 2013-02-13T10:40:01 | 8,175,803 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 6,014 | java | package chess.junit;
import static org.junit.Assert.*;
import java.util.ArrayList;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
public class PiecesTest {
private static final int BLACK = 1, WHITE = -1;
private static final int ROW = 8, COL = 8;
private static final int originX = 0, originY = 0;
private static final int centerX = ROW/2, centerY = COL/2;
private static final int edgeX = originX, edgeY = originY+1;
private static Board safeBoard; // A game that is not ending
private static Board unsafeBoard; // Checkmate Condition
private static Board evenBoard;// Stalemate Condition
static Piece bKing,bQueen,wQueen2,bKnight1,bKnight2, bRock1,bRock2,bBishop1,bBishop2,wClown,wChance;
static Piece [] bPawns;
static Piece wKing,wQueen,wKnight1,wKnight2, wRock1,wRock2, wBishop1,wBishop2;
static Piece [] wPawns;
@BeforeClass
/* Set up two boards and several pieces for test
* safe board has plenty of legal moves
* unsafe board is in check condition and has no legal move
* */
public static void setUpBeforeClass() throws Exception
{
safeBoard = new Board(ROW,COL);
unsafeBoard = new Board(ROW,COL);
evenBoard = new Board(ROW,COL);
bKing = new King(BLACK,"bk");
bQueen = new Queen(BLACK, "bQ");
bBishop1 = new Bishop(BLACK, "bB");
bBishop2 = new Bishop(BLACK, "bB");
bRock1 = new Rook(BLACK, "bR");
bRock2 = new Rook(BLACK, "bR");
bKnight1 = new Knight(BLACK, "bH");
bKnight2 = new Knight(BLACK, "bH");
bPawns = new Pawn[COL];
for (int i = 0; i < COL;i++)
bPawns[i] = new Pawn(BLACK,"bP");
wKing = new King (WHITE, "wk");
wQueen = new Queen (WHITE,"wQ");
wQueen2 = new Queen (WHITE,"wQ");
wBishop1 = new Bishop(WHITE, "wB");
wBishop2 = new Bishop(WHITE, "wB");
wRock1 = new Rook(WHITE, "wR");
wRock2 = new Rook(WHITE, "wR");
wKnight1 = new Knight(WHITE, "wH");
wKnight2 = new Knight(WHITE, "wH");
wPawns = new Pawn[COL];
wClown = new Clown(WHITE, "wL");
wChance = new Chancellor(WHITE, "wC");
for (int i = 0; i < COL;i++)
wPawns[i] = new Pawn(WHITE,"wP");
safeBoard.resetBoard();
Piece [][] board1 = new Piece[][] {
{null, null, null, null, bKing, null, bKnight2, null},
{null, null, null, bBishop1, null, null, null, bPawns[7]},
{bPawns[0], null, null, null, null, bPawns[5], bRock2, null},
{null, bPawns[1],null, bPawns[3],null, null, null, null},
{null, wPawns[1],wPawns[2],null, null, null, null, null},
{wPawns[0], null, null, null, null, wKnight2, null, wRock2},
{null, null, null, null ,null, wPawns[5], wPawns[6],null},
{wKing, wBishop1, null, wQueen, null, null, null, null}
};
safeBoard.setWholeBoard(board1);
Piece [][]board2 = new Piece [][]
{
{null, null, null, null, bKing, null, null, null },
{null, null, null, null, null, null, wPawns[4], null },
{wRock1, null, wKnight1, null, wQueen2, null, null, null },
{null,null,null,null,null,null,null,null},
{bRock1,null,null,null,null,null,null,wBishop2},
{null,null,null,null,null,null,null,null},
{wPawns[3], bQueen, null, null,null,null,null,null},
{wKing, null, null, bKnight1,null,null,null,null},
};
unsafeBoard.setWholeBoard(board2);
safeBoard.update();
unsafeBoard.update();
}
@Test
public void testUpdateReachable()
{
wKing.updateReachable(safeBoard);
assertEquals(wKing.getReachableList().size() ,2);
wQueen.updateReachable(safeBoard);
assertEquals(wQueen.getReachableList().size(),13);
wPawns[6].updateReachable(safeBoard);
assertEquals(wPawns[6].getReachableList().size(),2);
bBishop1.updateReachable(safeBoard);
assertEquals(bBishop1.getReachableList().size(),6);
bKnight2.updateReachable(safeBoard);
assertEquals(bKnight2.getReachableList().size(),2);
bRock2.updateReachable(safeBoard);
assertEquals(bRock2.getReachableList().size(), 6);
Board blank = new Board(8,8);
blank.place_init(wClown, 4, 4);
wClown.updateReachable(blank);
assertEquals(wClown.getReachableList().size(),8);
blank.place_init(wChance, 0, 0);
wChance.updateReachable(blank);
assertEquals(wChance.getReachableList().size(),16);
}
@Test
public void testGetOpponentAttackRange()
{
ArrayList<Square> list = bKing.getOpponentAttackRange(safeBoard);
assertTrue(bKing.listContains(new Square(7,7,null), list));
assertEquals(list.size(),42);
list= wKing.getOpponentAttackRange(unsafeBoard);
assertTrue(bKing.listContains(new Square(7,0,null), list));
assertEquals(list.size(),41);
}
@Test
public void testGetKingByPlayer() {
Square whiteKing = wQueen.getKingByPlayer(WHITE);
Square blackKing = wKing.getKingByPlayer(BLACK);
assertEquals(whiteKing.x, 7);
assertEquals(whiteKing.y, 0);
assertEquals(blackKing.x, 0);
assertEquals(blackKing.y, 4);
}
@Test
public void testGetAllMoveable()
{
ArrayList<Square> list = bKing. getAllMoveable (safeBoard, bKing);
assertEquals(list.size(), 25);
list = wKing. getAllMoveable (safeBoard, wKing);
assertEquals(list.size(), 42);
list = bKing. getAllMoveable (unsafeBoard, bKing);
assertEquals(list.size(), 0);
list = wKing. getAllMoveable (unsafeBoard, wKing);
assertEquals(list.size(), 0);
wKing.printLegalMove(safeBoard);
}
@Test
public void testGetLegalPieces()
{
bKing. getAllMoveable (safeBoard, bKing);
ArrayList<Square> list = bKing.getLegalPieces (safeBoard);
assertEquals(list.size(), 9);
wKing. getAllMoveable (safeBoard, wKing);
list = wKing.getLegalPieces (safeBoard);
assertEquals(list.size(), 8);
wKing. getAllMoveable (unsafeBoard, wKing);
list = wKing.getLegalPieces (unsafeBoard);
assertEquals(list.size(), 0);
}
@Test
public void testIsInCheck()
{
boolean inCheck = wKing.isInCheck(safeBoard);
assertFalse(inCheck);
inCheck = bKing.isInCheck(unsafeBoard);
assertTrue(inCheck);
}
}
| [
"zhexiliu19@gmail.com"
] | zhexiliu19@gmail.com |
d7aebda2cd4e37df89517750b60d9cc3286183e1 | d504953982545d676579f1a71a464b5cd55ebbb4 | /src/edu/buffalo/cse/irf14/index/IndexReader.java | 83076d6ca785f511a46e6ab61e25fef6ca4c6f95 | [] | no_license | pumamaheswaran/news-indexer | 28a74683f2ce695f6275b2764f70be3afe16c7cb | 2654a0e73c4009cd8d41fa9edffcaf35b09ed942 | refs/heads/master | 2021-01-18T22:51:14.951813 | 2016-05-03T22:19:40 | 2016-05-03T22:19:40 | 29,117,158 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,672 | java | /**
*
*/
package edu.buffalo.cse.irf14.index;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
/**
* @author nikhillo
* Class that emulates reading data back from a written index
*/
public class IndexReader {
private IndexType indexType = null;
private String indexDir;
//Index File Names
private static final String categoryIndexFileName = "CategoryIndex.ser";
private static final String authorIndexFileName = "AuthorIndex.ser";
private static final String termIndexFileName = "TermIndex.ser";
private static final String placeIndexFileName = "PlaceIndex.ser";
private static final String idfIndexFileName = "IDFIndex.ser";
//private static final String tfIndexFileName = "TFIndex.ser";
private static final String docLengthIndexFileName = "docLengthIndex.ser";
private static final String positionalIndexFileName = "PositionalIndex.ser";
//Dictionary File Names
private static final String categoryDictionaryFileName = "CategoryDictionary.ser";
private static final String authorDictionaryFileName = "AuthorDictionary.ser";
private static final String documentDictionaryFileName = "DocumentDictionary.ser";
private static final String placeDictionaryFileName = "PlaceDictionary.ser";
private static final String termDictionaryFileName = "TermDictionary.ser";
//DataStructures for Dictionary
DualTreeMap<String,Integer> categoryDictionary = null;
DualTreeMap<String,Integer> documentDictionary = null;
DualTreeMap<String,Integer> placeDictionary = null;
DualTreeMap<String,Integer> termDictionary = null;
DualTreeMap<String,Integer> authorDictionary = null;
//Datastructures for Index
TreeMap<Integer,HashMap<Integer,Integer>> categoryIndex = null;
TreeMap<Integer,HashMap<Integer,Integer>> placeIndex = null;
TreeMap<Integer,HashMap<Integer,Integer>> termIndex = null;
TreeMap<Integer,ArrayList<Integer>> authorIndex = null;
HashMap<Integer,HashMap<Integer,ArrayList<Integer>>> positionalIndex = null;
//HashMap<Integer,HashMap<Integer,Integer>> tfindex = null;
HashMap<Integer,Float> idfIndex = null;
HashMap<Integer,Integer> docLengthIndex = null;
/**
* Default constructor
* @param indexDir : The root directory from which the index is to be read.
* This will be exactly the same directory as passed on IndexWriter. In case
* you make subdirectories etc., you will have to handle it accordingly.
* @param type The {@link IndexType} to read from
*/
public IndexReader(String indexDir, IndexType type) {
this.indexDir = indexDir;
this.indexType = type;
loadFiles();
}
/**
* Get total number of terms from the "key" dictionary associated with this
* index. A postings list is always created against the "key" dictionary
* @return The total number of terms
*/
public int getTotalKeyTerms() {
int i = 0;
if(indexType == IndexType.AUTHOR)
{
i = authorDictionary.size();
}
else
if(indexType == IndexType.CATEGORY)
{
i = categoryDictionary.size();
}
else
if(indexType == IndexType.PLACE)
{
i = placeDictionary.size();
}
else
if(indexType == IndexType.TERM)
{
i = termDictionary.size();
}
return i;
}
/**
* Get total number of terms from the "value" dictionary associated with this
* index. A postings list is always created with the "value" dictionary
* @return The total number of terms
*/
public int getTotalValueTerms() {
return documentDictionary.size();
}
/**
* Method to get the postings for a given term. You can assume that
* the raw string that is used to query would be passed through the same
* Analyzer as the original field would have been.
* @param term : The "analyzed" term to get postings for
* @return A Map containing the corresponding fileid as the key and the
* number of occurrences as values if the given term was found, null otherwise.
*/
public Map<String, Integer> getPostings(String term) {
Map<String, Integer> docList = null;
if(indexType == IndexType.AUTHOR)
{
Integer authorID = authorDictionary.getForwardReference(term);
if(authorID!=null)
{
ArrayList<Integer> list = authorIndex.get(authorID);
if(list!=null)
{
docList = new HashMap<String,Integer>();
for(Integer i : list)
{
String fileName = documentDictionary.getBackWardReference(i);
Integer in = 1;
docList.put(fileName, in);
}
}
}
}
else
if(indexType == IndexType.CATEGORY)
{
Integer termID = categoryDictionary.getForwardReference(term);
if(termID!=null)
{
HashMap<Integer,Integer> map = categoryIndex.get(termID);
if(map!=null)
{
docList = new HashMap<String,Integer>();
Set<Integer> keySet = map.keySet();
for(Integer i : keySet)
{
String docName = documentDictionary.getBackWardReference(i);
Integer occurances = map.get(i);
docList.put(docName, occurances);
}
}
}
}
else
if(indexType == IndexType.PLACE)
{
Integer termID = placeDictionary.getForwardReference(term);
if(termID!=null)
{
HashMap<Integer,Integer> map = placeIndex.get(termID);
if(map!=null)
{
docList = new HashMap<String,Integer>();
Set<Integer> keySet = map.keySet();
for(Integer i : keySet)
{
String docName = documentDictionary.getBackWardReference(i);
Integer occurances = map.get(i);
docList.put(docName, occurances);
}
}
}
}
else
if(indexType == IndexType.TERM)
{
Integer termID = termDictionary.getForwardReference(term);
if(termID!=null)
{
HashMap<Integer,Integer> map = termIndex.get(termID);
if(map!=null)
{
docList = new HashMap<String,Integer>();
Set<Integer> keySet = map.keySet();
for(Integer i : keySet)
{
String docName = documentDictionary.getBackWardReference(i);
Integer occurances = map.get(i);
docList.put(docName, occurances);
}
}
}
}
return docList;
}
/**
* Method to get the top k terms from the index in terms of the total number
* of occurrences.
* @param k : The number of terms to fetch
* @return : An ordered list of results. Must be <=k fr valid k values
* null for invalid k values
*/
public List<String> getTopK(int k) {
TreeMap<Integer,Integer> list = new TreeMap<Integer,Integer>(Collections.reverseOrder());
List<String> returnList = new ArrayList<String>();
for(Integer i : termIndex.keySet())
{
HashMap<Integer,Integer> map = termIndex.get(i);
Integer in = 0;
for(Integer j : map.keySet())
{
in = in + (map.get(j)==null?0:map.get(j));
}
list.put(in, i);
}
int count = 0;
for(Integer i : list.keySet())
{
if(count == k)
{
break;
}
Integer termID = list.get(i);
String term = termDictionary.getBackWardReference(termID);
returnList.add(term);
count++;
}
return returnList;
}
/**
* Method to implement a simple boolean AND query on the given index
* @param terms The ordered set of terms to AND, similar to getPostings()
* the terms would be passed through the necessary Analyzer.
* @return A Map (if all terms are found) containing FileId as the key
* and number of occurrences as the value, the number of occurrences
* would be the sum of occurrences for each participating term. return null
* if the given term list returns no results
* BONUS ONLY
*/
public Map<String, Integer> query(String...terms) {
ArrayList<Integer> docList = null;
Map<String,Integer> returnMap = null;
for(String s : terms)
{
Map<String, Integer> map = getPostings(s);
if(returnMap==null)
{
returnMap = map;
}
else
{
returnMap = mergeTwoLists(returnMap,map);
}
}
return returnMap;
}
private Map<String,Integer> mergeTwoLists(Map<String,Integer> a , Map<String,Integer> b)
{
Set<String> set1 = a.keySet();
Set<String> set2 = b.keySet();
Map<String,Integer> map = new HashMap<String,Integer>();
ArrayList<String> list1 = new ArrayList<String>(set1);
ArrayList<String> list2 = new ArrayList<String>(set2);
list1.retainAll(list2);
for(String s : list1)
{
Integer i = a.get(s) + b.get(s);
map.put(s, i);
}
if(map.size() == 0)
return null;
return map;
}
private Object loadingHelper(String filename) throws IOException, ClassNotFoundException
{
File file = new File(filename);
Object obj = null;
if(file.exists())
{
FileInputStream f = new FileInputStream(file);
ObjectInputStream o = new ObjectInputStream(f);
obj = o.readObject();
o.close();
f.close();
}
return obj;
}
public void loadFiles() {
try {
categoryIndex = (TreeMap<Integer, HashMap<Integer, Integer>>) loadingHelper(indexDir+File.separator+categoryIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
termIndex = (TreeMap<Integer, HashMap<Integer, Integer>>) loadingHelper(indexDir+File.separator+termIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
placeIndex = (TreeMap<Integer, HashMap<Integer, Integer>>) loadingHelper(indexDir+File.separator+placeIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
authorIndex = (TreeMap<Integer, ArrayList<Integer>>) loadingHelper(indexDir+File.separator+authorIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
positionalIndex = (HashMap<Integer, HashMap<Integer, ArrayList<Integer>>>) loadingHelper(indexDir+File.separator+positionalIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
idfIndex = (HashMap<Integer, Float>) loadingHelper(indexDir+File.separator+idfIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
docLengthIndex = (HashMap<Integer, Integer>) loadingHelper(indexDir+File.separator+docLengthIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
/*try {
tfIndex = (HashMap<String,HashMap<String,Integer>>) loadingHelper(indexDir+File.separator+tfIndexFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}*/
try {
categoryDictionary = (DualTreeMap<String, Integer>) loadingHelper(indexDir+File.separator+categoryDictionaryFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
authorDictionary = (DualTreeMap<String, Integer>) loadingHelper(indexDir+File.separator+authorDictionaryFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
placeDictionary = (DualTreeMap<String, Integer>) loadingHelper(indexDir+File.separator+placeDictionaryFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
documentDictionary = (DualTreeMap<String, Integer>) loadingHelper(indexDir+File.separator+documentDictionaryFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
termDictionary = (DualTreeMap<String, Integer>) loadingHelper(indexDir+File.separator+termDictionaryFileName);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void setIndexType(IndexType indexType) {
this.indexType = indexType;
}
public Integer getTermID(String term){
Integer id = termDictionary.getForwardReference(term);
return id;
}
public Integer getDocID(String doc){
Integer id = documentDictionary.getForwardReference(doc);
return id;
}
public Float getIDF(Integer termID){
if(idfIndex.get(termID)==null)
return (float)0;
else
{
Float idf = idfIndex.get(termID);
return idf;
}
}
public int getTermFrequency(Integer termID, Integer DocID){
int freq = 0;
try {
HashMap<Integer,Integer> docList = null;
docList = termIndex.get(termID);
freq = docList.get(DocID);
}
catch(NullPointerException e)
{
freq = 0;
}
return freq;
}
public int getDocLength(Integer DocID){
int docLength = docLengthIndex.get(DocID);
return docLength;
}
public double getAvgDocLength(){
long sum = 0;
for(Map.Entry<Integer, Integer> doc: docLengthIndex.entrySet())
{
sum = sum + doc.getValue();
}
int N = documentDictionary.size();
double avg = sum/N;
return avg;
}
public List<Integer> getPositionWithinDocument(Integer documentID , Integer termID)
{
HashMap<Integer, ArrayList<Integer>> map = positionalIndex.get(termID);
return map==null?null:map.get(documentID);
}
}
| [
"pravin.mahesh@gmail.com"
] | pravin.mahesh@gmail.com |
fe1b760a63aa5a8a66f44fb666b35cf882366403 | a3bd502db9010c43d50e2a255326fa9400bcf780 | /app/src/main/java/m/google/ordenpedidosserver/model/Food.java | 67c1c977a284f6f4ee0e77d87b936ac02fb6e8f6 | [] | no_license | JoseTeque/OrdenPedidosServer | 6e95659971eebe593b717d632d4f6a0c8bd2bddb | ab51a84f4e81db4bda33cb555d99a4e005ba08f1 | refs/heads/master | 2020-05-04T23:59:23.648335 | 2019-04-04T19:22:34 | 2019-04-04T19:22:34 | 179,562,751 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,434 | java | package m.google.ordenpedidosserver.model;
public class Food {
private String name;
private String image;
private String description;
private String price;
private String discount;
private String menuId;
public Food() {
}
public Food(String name, String image, String description, String price, String discount, String menuId) {
this.name = name;
this.image = image;
this.description = description;
this.price = price;
this.discount = discount;
this.menuId = menuId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getImage() {
return image;
}
public void setImage(String image) {
this.image = image;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getPrice() {
return price;
}
public void setPrice(String price) {
this.price = price;
}
public String getDiscount() {
return discount;
}
public void setDiscount(String discount) {
this.discount = discount;
}
public String getMenuId() {
return menuId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
}
| [
"jrguerra.180490@gmail.com"
] | jrguerra.180490@gmail.com |
2efe6e1959bf3eba76d9a8c9f5cd0f2fc3f5f60c | 44e7adc9a1c5c0a1116097ac99c2a51692d4c986 | /aws-java-sdk-rekognition/src/main/java/com/amazonaws/services/rekognition/model/transform/SearchFacesByImageResultJsonUnmarshaller.java | 3728e16a67ffd2a311e24ef39c60788039cccf14 | [
"Apache-2.0"
] | permissive | QiAnXinCodeSafe/aws-sdk-java | f93bc97c289984e41527ae5bba97bebd6554ddbe | 8251e0a3d910da4f63f1b102b171a3abf212099e | refs/heads/master | 2023-01-28T14:28:05.239019 | 2020-12-03T22:09:01 | 2020-12-03T22:09:01 | 318,460,751 | 1 | 0 | Apache-2.0 | 2020-12-04T10:06:51 | 2020-12-04T09:05:03 | null | UTF-8 | Java | false | false | 3,753 | java | /*
* Copyright 2015-2020 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.rekognition.model.transform;
import java.math.*;
import javax.annotation.Generated;
import com.amazonaws.services.rekognition.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* SearchFacesByImageResult JSON Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class SearchFacesByImageResultJsonUnmarshaller implements Unmarshaller<SearchFacesByImageResult, JsonUnmarshallerContext> {
public SearchFacesByImageResult unmarshall(JsonUnmarshallerContext context) throws Exception {
SearchFacesByImageResult searchFacesByImageResult = new SearchFacesByImageResult();
int originalDepth = context.getCurrentDepth();
String currentParentElement = context.getCurrentParentElement();
int targetDepth = originalDepth + 1;
JsonToken token = context.getCurrentToken();
if (token == null)
token = context.nextToken();
if (token == VALUE_NULL) {
return searchFacesByImageResult;
}
while (true) {
if (token == null)
break;
if (token == FIELD_NAME || token == START_OBJECT) {
if (context.testExpression("SearchedFaceBoundingBox", targetDepth)) {
context.nextToken();
searchFacesByImageResult.setSearchedFaceBoundingBox(BoundingBoxJsonUnmarshaller.getInstance().unmarshall(context));
}
if (context.testExpression("SearchedFaceConfidence", targetDepth)) {
context.nextToken();
searchFacesByImageResult.setSearchedFaceConfidence(context.getUnmarshaller(Float.class).unmarshall(context));
}
if (context.testExpression("FaceMatches", targetDepth)) {
context.nextToken();
searchFacesByImageResult.setFaceMatches(new ListUnmarshaller<FaceMatch>(FaceMatchJsonUnmarshaller.getInstance())
.unmarshall(context));
}
if (context.testExpression("FaceModelVersion", targetDepth)) {
context.nextToken();
searchFacesByImageResult.setFaceModelVersion(context.getUnmarshaller(String.class).unmarshall(context));
}
} else if (token == END_ARRAY || token == END_OBJECT) {
if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
if (context.getCurrentDepth() <= originalDepth)
break;
}
}
token = context.nextToken();
}
return searchFacesByImageResult;
}
private static SearchFacesByImageResultJsonUnmarshaller instance;
public static SearchFacesByImageResultJsonUnmarshaller getInstance() {
if (instance == null)
instance = new SearchFacesByImageResultJsonUnmarshaller();
return instance;
}
}
| [
""
] | |
2708176bf69150b31c4baf643f735e901c449a5b | 5e30f7a5873193ee7039732486347b49670436e5 | /src/com/lumagaizen/minecraftshop/STATIC.java | cb513d257f0eead1314d0e0c59f5409a160c7147 | [] | no_license | blong43/css490 | 05853973205ff968e131261f6a6208ef4f030980 | 856cf5b3ffc84b08348ef8a54b2b1b1dc9d8359c | refs/heads/master | 2021-01-10T14:13:01.345710 | 2016-02-11T07:11:27 | 2016-02-11T07:11:27 | 51,499,321 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,211 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.lumagaizen.minecraftshop;
import com.lumagaizen.minecraftshop.model.ShopUser;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* This class contains non-web-related static functions that help with the
* program. Hash methods are common here.
* @author Taylor
*/
public class STATIC
{
//<editor-fold defaultstate="collapsed" desc="Sha256">
public static String Sha256(String plainText)
{
if (plainText == null)
{
plainText = "";
}
try
{
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.update(plainText.getBytes("UTF-8")); // Change this to "UTF-16" if needed
byte[] digest = md.digest();
return bytesToHex(digest);
}
catch (UnsupportedEncodingException ex)
{
Logger.getLogger(ShopUser.class.getName()).log(Level.SEVERE, null, ex);
}
catch (NoSuchAlgorithmException ex)
{
Logger.getLogger(ShopUser.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="md5">
public static String md5(String plainText)
{
if (plainText == null)
{
plainText = "";
}
try
{
MessageDigest md = MessageDigest.getInstance("md5");
md.update(plainText.getBytes("UTF-8")); // Change this to "UTF-16" if needed
byte[] digest = md.digest();
return bytesToHex(digest);
}
catch (UnsupportedEncodingException ex)
{
Logger.getLogger(ShopUser.class.getName()).log(Level.SEVERE, null, ex);
}
catch (NoSuchAlgorithmException ex)
{
Logger.getLogger(ShopUser.class.getName()).log(Level.SEVERE, null, ex);
}
return "";
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="bytesToHex">
public static String bytesToHex(byte[] oBytes)
{
StringBuilder sb = new StringBuilder();
for (byte b : oBytes)
{
sb.append(String.format("%02X", b));
}
return sb.toString();
}
//</editor-fold>
}
| [
"blongthao43@gmail.com"
] | blongthao43@gmail.com |
d8b6b27eecc1f0d4b6310edf37d35f046f184678 | 307ab11f64fa9d030c74d27c72cf2a3c7653cd19 | /afw/src/mikeheke/tadpole/frm/bds/entity/BdsXmlData.java | 4cc2777c1e6c800d31622b1203bd3b377a4f1885 | [] | no_license | mikeheke/tadpolehe | 309001fb45e81afb338d1f9889928253369fae4e | fc80aa79b8f59b2be668a930ee8827b33f8bcf8f | refs/heads/master | 2016-09-06T19:18:17.437124 | 2015-05-12T15:03:41 | 2015-05-12T15:03:41 | 34,115,841 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,538 | java | package mikeheke.tadpole.frm.bds.entity;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import mikeheke.tadpole.frm.base.util.AppConstant;
import mikeheke.tadpole.frm.base.vo.UniqueKey;
import mikeheke.tadpole.frm.bds.util.BdsXmlUntil;
import org.apache.commons.lang.StringUtils;
import org.jdom.Document;
import org.jdom.Element;
/**
* 本地基础数据表实体类
*
*/
@Entity
@Table(name = "MSTB_BDS_XML_DATA", schema =AppConstant.APP_DEAULT_SCHEMA)
public class BdsXmlData implements java.io.Serializable {
private static final long serialVersionUID = -6210010763031944561L;
//自动生成ID
@Id
//@GenericGenerator(name="systemUUID",strategy="uuid")
//@GeneratedValue(generator="systemUUID")
@Column(name = "BDS_XML_DATA_ID")
private String bdsXmlDataId;
//编码
@Column(name = "CODE")
@UniqueKey
private String code;
//显示名称
@Column(name = "DISPLAYNAME")
private String displayname;
//英文名
@Column(name = "DISPLAYNAME_EN")
private String displaynameEn;
//繁体中文名
@Column(name = "DISPLAYNAME_TC")
private String displaynameTc;
//数据xml
//@Column(name = "BDS_DATA")
@Column(name = "BDS_DATA_STR") //20150428
private String bdsData;
//备注
@Column(name = "REMARK")
private String remark;
//使用状态
@Column(name = "STATE")
private Integer state;
@Column(name="RECORD_STATE")
@UniqueKey
private Integer recordState = AppConstant.START;
@Column(name="UPDATED_TIME")
@Temporal(TemporalType.TIMESTAMP)
private Date updatedTime;
@Column(name="UPDATED_USER_ID")
private String updatedUserId;
@Column(name="CREATED_TIME",updatable=false)
@Temporal(TemporalType.TIMESTAMP)
private Date createdTime;
@Column(name="CREATED_USER_ID",updatable=false)
private String createdUserId;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "BDS_SCHEMAINFOR_ID")
@UniqueKey
private BdsSchemaInfor bdsSchemaInfor;
//add by Mike He 20150425
//存储xml数据 key:nodeName value:nodeText
//也包含了: code,displayname,displaynameEn...值在里面
@Transient //表示该属性并非一个到数据库表的字段的映射,ORM框架将忽略该属性.
private Map<String,String> bdsDataMap;
public String getBdsXmlDataId() {
return this.bdsXmlDataId;
}
public void setBdsXmlDataId(String bdsXmlDataId) {
this.bdsXmlDataId = bdsXmlDataId;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public String getDisplayname() {
return this.displayname;
}
public void setDisplayname(String displayname) {
this.displayname = displayname;
}
public String getDisplaynameEn() {
return this.displaynameEn;
}
public void setDisplaynameEn(String displaynameEn) {
this.displaynameEn = displaynameEn;
}
public String getDisplaynameTc() {
return this.displaynameTc;
}
public void setDisplaynameTc(String displaynameTc) {
this.displaynameTc = displaynameTc;
}
public String getBdsData() {
return bdsData;
}
public void setBdsData(String bdsData) {
this.bdsData = bdsData;
}
public String getRemark() {
return this.remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public Integer getState() {
return this.state;
}
public void setState(Integer state) {
this.state = state;
}
public Integer getRecordState() {
return this.recordState;
}
public void setRecordState(Integer recordState) {
this.recordState = recordState;
}
public String getCreatedUserId() {
return this.createdUserId;
}
public void setCreatedUserId(String createdUserId) {
this.createdUserId = createdUserId;
}
public Date getCreatedTime() {
return this.createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public String getUpdatedUserId() {
return this.updatedUserId;
}
public void setUpdatedUserId(String updatedUserId) {
this.updatedUserId = updatedUserId;
}
public Date getUpdatedTime() {
return this.updatedTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
public BdsSchemaInfor getBdsSchemaInfor() {
return bdsSchemaInfor;
}
public void setBdsSchemaInfor(BdsSchemaInfor bdsSchemaInfor) {
this.bdsSchemaInfor = bdsSchemaInfor;
}
public Map<String, String> getBdsDataMap() {
bdsDataMap = new HashMap<String, String>();
bdsDataMap.put("code", this.code);
bdsDataMap.put("displayname", this.displayname);
bdsDataMap.put("displaynameEn", this.displaynameEn);
bdsDataMap.put("displaynameTc", this.displaynameTc);
if (StringUtils.isBlank(this.bdsData) && this.bdsData.trim().length() < 10) {//空值不处理
return bdsDataMap;
}
//解析xml data to map
Document doc = BdsXmlUntil.getDocument(this.bdsData);
Element root = doc.getRootElement();
List<Element> eleList = root.getChildren();
for (Element e: eleList) {
String colName = e.getName();
String colVal = e.getText();
bdsDataMap.put(colName, colVal);
}
return bdsDataMap;
}
public void setBdsDataMap(Map<String, String> bdsDataMap) {
this.bdsDataMap = bdsDataMap;
}
} | [
"ke_he@163.com"
] | ke_he@163.com |
3fe9096a85358c9440753cb331cd64bf9927128a | ecc661f2a8b336e976041073310316559238aceb | /06022016/AndroidPlayground/android/support/v4/app/NotificationCompatIceCreamSandwich.java | fb7b16686a44ea580a51601bd4264d395d3e0442 | [] | no_license | dinghu/Zhong-Lin | a0030b575ef5cfbc74bc741563115abdb9a468d6 | 81e9f97c4108f2dbcc6069fca01fd2213f3ceb22 | refs/heads/master | 2021-01-13T04:58:48.163719 | 2016-07-01T23:21:23 | 2016-07-01T23:21:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,901 | java | package android.support.v4.app;
import android.app.Notification;
import android.app.Notification.Builder;
import android.app.PendingIntent;
import android.content.Context;
import android.graphics.Bitmap;
import android.widget.RemoteViews;
class NotificationCompatIceCreamSandwich
{
public static class Builder
implements NotificationBuilderWithBuilderAccessor
{
private Notification.Builder b;
public Builder(Context paramContext, Notification paramNotification, CharSequence paramCharSequence1, CharSequence paramCharSequence2, CharSequence paramCharSequence3, RemoteViews paramRemoteViews, int paramInt1, PendingIntent paramPendingIntent1, PendingIntent paramPendingIntent2, Bitmap paramBitmap, int paramInt2, int paramInt3, boolean paramBoolean)
{
paramContext = new Notification.Builder(paramContext).setWhen(paramNotification.when).setSmallIcon(paramNotification.icon, paramNotification.iconLevel).setContent(paramNotification.contentView).setTicker(paramNotification.tickerText, paramRemoteViews).setSound(paramNotification.sound, paramNotification.audioStreamType).setVibrate(paramNotification.vibrate).setLights(paramNotification.ledARGB, paramNotification.ledOnMS, paramNotification.ledOffMS);
if ((paramNotification.flags & 0x2) != 0)
{
bool = true;
paramContext = paramContext.setOngoing(bool);
if ((paramNotification.flags & 0x8) == 0) {
break label224;
}
bool = true;
label112:
paramContext = paramContext.setOnlyAlertOnce(bool);
if ((paramNotification.flags & 0x10) == 0) {
break label230;
}
bool = true;
label132:
paramContext = paramContext.setAutoCancel(bool).setDefaults(paramNotification.defaults).setContentTitle(paramCharSequence1).setContentText(paramCharSequence2).setContentInfo(paramCharSequence3).setContentIntent(paramPendingIntent1).setDeleteIntent(paramNotification.deleteIntent);
if ((paramNotification.flags & 0x80) == 0) {
break label236;
}
}
label224:
label230:
label236:
for (boolean bool = true;; bool = false)
{
this.b = paramContext.setFullScreenIntent(paramPendingIntent2, bool).setLargeIcon(paramBitmap).setNumber(paramInt1).setProgress(paramInt2, paramInt3, paramBoolean);
return;
bool = false;
break;
bool = false;
break label112;
bool = false;
break label132;
}
}
public Notification build()
{
return this.b.getNotification();
}
public Notification.Builder getBuilder()
{
return this.b;
}
}
}
/* Location: C:\playground\dex2jar-2.0\dex2jar-2.0\classes-dex2jar.jar!\android\support\v4\app\NotificationCompatIceCreamSandwich.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"zhonglin@alien"
] | zhonglin@alien |
d35a48a22b2aec875ed60c6fe24387507762c630 | e8cb87e15fdff0304377faad456e7092da8a48b2 | /Useful Algorithms/Two Pointers Method/TwoSum.java | 45f2f7128a74e3f197ee86e67f969bed6aa5736b | [] | no_license | tomerlieber/Competitive-Programming | d87954290739b6aa3b957ad97c999e7e1e00c6a9 | 469c0c4d3e1c0d6e5ee0f17780ad51c8325f12c0 | refs/heads/master | 2023-03-03T20:25:47.110907 | 2021-02-16T14:02:25 | 2021-02-16T14:02:25 | 296,715,137 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,056 | java | import java.util.Arrays;
// Given an array of n numbers and a target sum x, find two array values such that their sum is x,
// or report that no such values exist.
public class TwoSum {
// Time complexity = O(nlogn) because of the sorting
public static void main(String[] args) {
int[] nums = {1, 4, 5, 6, 7, 9, 9, 10};
int target = 20;
Arrays.sort(nums);
int pointer1 = 0;
int pointer2 = nums.length - 1;
boolean isFound = false;
while (pointer1 < pointer2) {
int currentSum = nums[pointer1] + nums[pointer2];
if (currentSum == target) {
isFound = true;
break;
}
else if (currentSum < target) {
pointer1++;
}
else {
pointer2--;
}
}
if (isFound) {
System.out.print(nums[pointer1] + " and " + nums[pointer2]);
}
else {
System.out.print("There is no sub array");
}
}
}
| [
"tomerlieber@gmail.com"
] | tomerlieber@gmail.com |
99ea528b6cb040358e79c73b79773d181333ce52 | bc0e7d8c28a7d6d277580bc421c6a29f4a60ab08 | /spring-cloud-kubernetes-examples/kubernetes-reload-example/src/main/java/org/springframework/qq414831974/kubernetes/examples/App.java | 66953cc96b9e6982f2f667de69be395d4bcbc25e | [
"LicenseRef-scancode-generic-cla",
"Apache-2.0"
] | permissive | qq414831974/spring-cloud-kubernetes | f805407e36785f8490715334056ca413d102f1af | b0ada0f6eee3bdfa8259ece8e190ab9d7734b8d8 | refs/heads/master | 2020-12-02T04:26:44.790013 | 2020-01-06T10:35:40 | 2020-01-06T10:35:40 | 230,887,322 | 0 | 0 | Apache-2.0 | 2020-09-09T19:45:36 | 2019-12-30T09:30:27 | Java | UTF-8 | Java | false | false | 1,024 | java | /*
* Copyright 2013-2019 the original author 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.qq414831974.kubernetes.examples;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@SpringBootApplication
@EnableScheduling
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
| [
"fun5xxx@gmail.com"
] | fun5xxx@gmail.com |
2e2a8ee4542cb56f2a0c9ff751ea997cf0414386 | 81b3984cce8eab7e04a5b0b6bcef593bc0181e5a | /android/CarLife/app/src/main/java/com/baidu/carlife/logic/p088a/C1685c.java | 107bbc6d18b7884b22169b17a37920b79e664652 | [] | no_license | ausdruck/Demo | 20ee124734d3a56b99b8a8e38466f2adc28024d6 | e11f8844f4852cec901ba784ce93fcbb4200edc6 | refs/heads/master | 2020-04-10T03:49:24.198527 | 2018-07-27T10:14:56 | 2018-07-27T10:14:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,666 | java | package com.baidu.carlife.logic.p088a;
import com.baidu.carlife.model.MusicSongModel;
/* compiled from: DataChecker */
/* renamed from: com.baidu.carlife.logic.a.c */
public class C1685c {
/* renamed from: a */
private static final String f5180a = "600000";
/* renamed from: b */
private static final int f5181b = 2;
/* compiled from: DataChecker */
/* renamed from: com.baidu.carlife.logic.a.c$a */
private static class C1684a {
/* renamed from: a */
private static final C1685c f5179a = new C1685c();
private C1684a() {
}
}
private C1685c() {
}
/* renamed from: a */
public static C1685c m6142a() {
return C1684a.f5179a;
}
/* renamed from: a */
public MusicSongModel m6144a(MusicSongModel model) {
if (m6143c(model)) {
return null;
}
if (model.m7377r() < 0) {
model.m7348b(2);
}
if (!m6145a(model.m7364h())) {
return model;
}
model.m7365h(f5180a);
return model;
}
/* renamed from: b */
public MusicSongModel m6146b(MusicSongModel model) {
if (model == null) {
return null;
}
if (m6145a(model.m7342a()) || m6145a(model.m7347b())) {
return null;
}
return model;
}
/* renamed from: a */
public boolean m6145a(String input) {
return input == null || input.isEmpty();
}
/* renamed from: c */
private boolean m6143c(MusicSongModel model) {
return model == null || m6145a(model.m7342a()) || m6145a(model.m7371l()) || model.m7375p() < 0;
}
}
| [
"objectyan@gmail.com"
] | objectyan@gmail.com |
b590960b2b5501b92cc31d8656b1546ab0ddaf92 | bf6d309a60e876e01ad396de2c8418330da722a2 | /src/main/java/spring/MemberRowMapper.java | 5b8fe1c8fdace7d0ed1dd29677b98f48a6cb2ce7 | [] | no_license | demyank88/spring5ex | bd8337cf3383bdcbede4de457c3298e2597120ed | 539487921f9cda719b9279a7879d82685f57e00f | refs/heads/master | 2020-12-27T17:18:01.985257 | 2019-03-12T06:18:21 | 2019-03-12T06:18:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 553 | java | package spring;
import org.springframework.jdbc.core.RowMapper;
import java.sql.ResultSet;
import java.sql.SQLException;
public class MemberRowMapper implements RowMapper<Member> {
@Override
public Member mapRow(ResultSet rs, int rowNum) throws SQLException {
Member member = new Member(
rs.getString("email"),
rs.getString("password"),
rs.getString("name"),
rs.getTimestamp("regdate").toLocalDateTime()
);
member.setId(rs.getLong("id"));
return member;
}
}
| [
"juwonkim@me.com"
] | juwonkim@me.com |
18da4b35268a590e619de4a0aebb28bb7f728263 | bc61d06840f45eb7ce5d0b70903c02af8d5d7d5b | /src/main/java/com/kebo/springjpa/po/User.java | 248826efd7e12ca73db41803402193f0d3691d41 | [] | no_license | w227895/springjpa | 39bb3be9ee4ba15550776872ce2aedc9934e41ce | 5dc8620f25c197f192e1147e3eca7c6fd5688aba | refs/heads/master | 2020-09-11T00:32:32.299923 | 2019-11-29T08:04:37 | 2019-11-29T08:04:37 | 221,881,055 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,750 | java | package com.kebo.springjpa.po;
import javax.persistence.*;
/**
* @description:
* @Author: kb
* @Date: 2019-11-15 11:27
*/
@Entity
@Table(name = "user")
public class User {
@Id
private String userOid;
private String userName;
private String userPass;
private String userRole;
private String userTime;
public String getUserOid() {
return userOid;
}
public void setUserOid(String userOid) {
this.userOid = userOid;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getUserPass() {
return userPass;
}
public void setUserPass(String userPass) {
this.userPass = userPass;
}
public String getUserRole() {
return userRole;
}
public void setUserRole(String userRole) {
this.userRole = userRole;
}
public String getUserTime() {
return userTime;
}
public void setUserTime(String userTime) {
this.userTime = userTime;
}
public User(String userOid, String userName, String userPass, String userRole, String userTime) {
this.userOid = userOid;
this.userName = userName;
this.userPass = userPass;
this.userRole = userRole;
this.userTime = userTime;
}
public User() {
}
@Override
public String toString() {
return "User{" +
"userOid='" + userOid + '\'' +
", userName='" + userName + '\'' +
", userPass='" + userPass + '\'' +
", userRole='" + userRole + '\'' +
", userTime='" + userTime + '\'' +
'}';
}
}
| [
"249183617@qq.com"
] | 249183617@qq.com |
7e97eab465c9afe376d2d1096e687324e392ec5f | 983d8d01fee002e685e43b2dd2d01510cf23abe6 | /qvcsosdb/src/main/java/com/qvcsos/server/DatabaseManager.java | f5ad4884805a0816a88760607f2dd5bde8976838 | [
"Apache-2.0"
] | permissive | jimv39/qvcsos | 5b509ef957761efc63f10b56e4573b72d5f4da44 | f40337fb4d2a8f63c81df4c946c6c21adfcb27bd | refs/heads/develop | 2023-08-31T09:15:20.388518 | 2023-08-29T20:11:16 | 2023-08-29T20:11:16 | 17,339,971 | 5 | 5 | Apache-2.0 | 2023-06-28T23:55:42 | 2014-03-02T15:08:49 | Java | UTF-8 | Java | false | false | 7,301 | java | /*
* Copyright 2021-2022 Jim Voris.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.qvcsos.server;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A database manager used for connections to a Postgres database.
*
* @author Jim Voris
*/
public final class DatabaseManager implements DatabaseManagerInterface {
/**
* Create our logger object.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(DatabaseManager.class);
/**
* Our singleton databaseManager instance
*/
private static final DatabaseManager DATABASE_MANAGER = new DatabaseManager();
/**
* The control connection to the database
*/
private Connection controlConnection = null;
/**
* Thread local storage for database connections
*/
private final ThreadLocal<Connection> threadLocalConnection = new ThreadLocal<>();
/**
* Flag we use to indicate whether we are initialized
*/
private boolean initializedFlag;
private String databaseUrl;
private String username;
private String password;
private String schemaName;
/**
* Private constructor, so no one else can make a PostgresDatabaseManager
* object.
*/
private DatabaseManager() {
}
/**
* Get the one and only database manager.
*
* @return the singleton database manager.
*/
public static DatabaseManager getInstance() {
return DATABASE_MANAGER;
}
/**
* Set the username. We use this for unit tests only.
* @param uname the user name for the test database.
*/
public void setUsername(String uname) {
this.username = uname;
}
/**
* Set the password. We use this for unit tests only.
* @param pword the password for the test database.
*/
public void setPassword(String pword) {
this.password = pword;
}
/**
* Set the db URL. We use this for unit tests only.
* @param url the URL for the test database.
*/
public void setUrl(String url) {
this.databaseUrl = url;
}
@Override
public String getSchemaName() {
// Guarantee that we have initialized the schema name.
initializeDatabase();
return this.schemaName;
}
/**
* Set the schema name. We use this for testing.
* @param name the name of the schema.
*/
public void setSchemaName(String name) {
this.schemaName = name;
}
@Override
public synchronized void closeConnection() throws SQLException {
Connection thisThreadsDbConnection = threadLocalConnection.get();
if (thisThreadsDbConnection != null) {
thisThreadsDbConnection.close();
threadLocalConnection.set(null);
LOGGER.info("Thread [{}]: closed database connection.", Thread.currentThread().getName());
}
}
@Override
public synchronized Connection getConnection() throws SQLException {
Connection connection;
// Make sure the database is initialized.
initializeDatabase();
connection = threadLocalConnection.get();
if (connection == null) {
connection = DriverManager.getConnection(databaseUrl, username, password);
connection.setAutoCommit(true);
threadLocalConnection.set(connection);
LOGGER.info("Thread [{}]: got database connection.", Thread.currentThread().getName());
} else {
LOGGER.trace("Thread [{}]: reuse thread's database connection.", Thread.currentThread().getName());
}
return connection;
}
@Override
public synchronized void initializeDatabase() {
if (!isInitializedFlag()) {
try {
initializeConnectionProperties();
controlConnection = DriverManager.getConnection(databaseUrl, username, password);
setInitializedFlag(true);
LOGGER.info("Connected to Postgres!");
} catch (SQLException e) {
LOGGER.warn("Failed to connect to Postgres!", e);
throw new RuntimeException(e);
}
}
}
public synchronized void initializeToMigrationDatabase() {
try {
initializeMigrationConnectionProperties();
controlConnection = DriverManager.getConnection(databaseUrl, username, password);
setInitializedFlag(true);
LOGGER.info("Connected to Postgres!");
} catch (SQLException e) {
LOGGER.warn("Failed to connect to Postgres!", e);
throw new RuntimeException(e);
}
}
@Override
public synchronized void shutdownDatabase() {
if (controlConnection != null) {
try {
// Close any connection on the current thread...
closeConnection();
// Close the 'control' connection.
controlConnection.close();
controlConnection = null;
} catch (SQLException e) {
LOGGER.info(e.getLocalizedMessage(), e);
}
}
setInitializedFlag(false);
}
/**
* Get the initializedFlag value;
*
* @return the initializedFlag
*/
private synchronized boolean isInitializedFlag() {
return initializedFlag;
}
/**
* Set the initializedFlag value.
*
* @param flag the initializedFlag to set
*/
private synchronized void setInitializedFlag(boolean flag) {
this.initializedFlag = flag;
}
/**
* Read the database connection properties from the postgresql.properties file. If that file is not found, create it, and populate it with our default values.
* The user can manually edit the result to define the connection properties that they need for their postgresql server.
*/
private void initializeConnectionProperties() {
DatabaseConnectionProperties connectionProperties = DatabaseConnectionProperties.getInstance();
setUrl(connectionProperties.getConnectionUrl());
setUsername(connectionProperties.getUsername());
setPassword(connectionProperties.getPassword());
setSchemaName(connectionProperties.getSchema());
}
private void initializeMigrationConnectionProperties() {
MigrationDatabaseConnectionProperties connectionProperties = MigrationDatabaseConnectionProperties.getInstance();
setUrl(connectionProperties.getConnectionUrl());
setUsername(connectionProperties.getUsername());
setPassword(connectionProperties.getPassword());
setSchemaName(connectionProperties.getSchema());
}
}
| [
"5863537+jimv39@users.noreply.github.com"
] | 5863537+jimv39@users.noreply.github.com |
9e8d1d60fa4d5c742638105eae64aad02f006050 | 089b6e7923161b1aec4af8d0f9384a137b8d66af | /VideoYukleme/src/MediaPlayer.java | 06684f1b7704a2f3b1934f6c15205eb44a302b1c | [] | no_license | mertsaner/LearningKitforBeginners-Java | 69f07370751d82dcd4475f375005d044e4d47e48 | 1cab733fc0b84996fac5d9fc5fc4d4f33a78dcff | refs/heads/master | 2022-04-12T00:08:03.672894 | 2019-04-18T14:00:16 | 2019-04-18T14:00:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,856 | java |
import java.awt.BorderLayout;
import java.awt.Component;
import java.net.MalformedURLException;
import java.net.URL;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
public class MediaPlayer extends javax.swing.JFrame {
public MediaPlayer(URL mediauUrl) {
initComponents();
setLayout(new BorderLayout());
try {
Player mediaPlayer = Manager.createRealizedPlayer(new MediaLocator(mediauUrl));
Component video = mediaPlayer.getVisualComponent();
Component control = mediaPlayer.getControlPanelComponent();
if (video != null) {
add(video, BorderLayout.CENTER); // place the video component in the panel
}
add(control, BorderLayout.SOUTH); // place the control in panel
mediaPlayer.start();
} catch (Exception e) {
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
JFileChooser fileChooser = new JFileChooser();
fileChooser.showOpenDialog(null);
URL mediaUrl = null;
try {
mediaUrl = fileChooser.getSelectedFile().toURI().toURL();
} catch (MalformedURLException ex) {
System.out.println(ex);
}
JFrame mediaTest = new JFrame("Video Oynatıcı");
mediaTest.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
MediaPlayer mediaPanel = new MediaPlayer(mediaUrl);
mediaTest.add(mediaPanel);
mediaTest.setSize(800, 700); // set the size of the player
mediaTest.setLocationRelativeTo(null);
mediaTest.setVisible(true);
}
}
| [
"noreply@github.com"
] | noreply@github.com |
88ef0ef84531a8edc7e828483ef5685d70a09540 | d43110fb91a8af7621b7d37b2d2bfd82d835e427 | /lab_05/src/com/company/Employee.java | 6ebbd9f9ec0da2f9aa4b815669d1093a7415080b | [] | no_license | simplycodepix/java_labs | 566dc4f9656b864cb4ede6b2e95eb0b7d9ab7297 | f9f7f70038252388023f87e92662cd2037061a2d | refs/heads/master | 2022-09-26T11:04:16.586857 | 2020-06-01T21:49:58 | 2020-06-01T21:49:58 | 263,314,822 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,378 | java | package com.company;
public class Employee {
private int id;
private String firstName;
private String lastName;
private double salary;
private Manager manager;
public Employee(int id, String firstName, String lastName) {
this.setId(id);
this.setName(firstName, lastName);
this.setSalary(1000);
}
public void setName(String firstName, String lastName) {
this.firstName = firstName;
this.lastName = lastName;
}
public String getName() {
return this.firstName + " " + this.lastName;
}
public void setId(int id) {
this.id = id;
}
public int getId() {
return id;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public void setManager(Manager manager) {
this.manager = manager;
}
public String getManagerName() {
if (this.manager == null) return "Nomanager";
return this.manager.getName();
}
public String getTopManager() {
if (this.manager == null) return this.getName();
return this.manager.getTopManager();
}
public String toString() {
return "ID: " + this.getId() + " Name: " + this.getName() + " Salary: " + this.getSalary() + " Manager: " + this.getManagerName();
}
}
| [
"simplycodepix@gmail.com"
] | simplycodepix@gmail.com |
6a318c091c0bdb7b9bbb18f118aee2dba2425f4c | 0ff7ce4765c2418428cc494a7b0a7c1b057be544 | /android/app/src/main/java/com/poloniexticker/MainActivity.java | c867ff03176148d295479a0a87c8220f010c6bba | [] | no_license | sergeyzhukov/PoloniexTicker | 81d72108f9d75c556435a3dcfe21dc814151476b | 19f03868dc8247374cfea7a865245e257dd91c97 | refs/heads/master | 2020-03-30T16:11:07.032201 | 2018-11-08T06:55:32 | 2018-11-08T06:55:32 | 151,396,930 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 373 | java | package com.poloniexticker;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript.
* This is used to schedule rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "PoloniexTicker";
}
}
| [
"sergey@szhukov.com"
] | sergey@szhukov.com |
8c994783cb68f9ac8f4a2b72dcbc020cde068b32 | 72745cbb9cc0fba746cdc2177fb1818001fc4689 | /app/src/main/java/com/funtube/ui/Activities/RequestActivity.java | 324b7e1760629e04db5535bea04a56d2055c3f54 | [] | no_license | SheriffOladejo/FunTube | 46cb88c4c5c3b986bf38a7fc58fec7a338f637e7 | c69f32d65e85a75538716d1fc6c83e6e60990c95 | refs/heads/master | 2022-09-12T18:29:58.475915 | 2020-06-03T09:06:25 | 2020-06-03T09:06:25 | 269,046,814 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,810 | java | package com.funtube.ui.Activities;
import android.app.ProgressDialog;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import androidx.appcompat.widget.Toolbar;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import com.funtube.Provider.PrefManager;
import com.funtube.R;
import com.funtube.api.apiClient;
import com.funtube.api.apiRest;
import com.funtube.model.ApiResponse;
import es.dmoral.toasty.Toasty;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
public class RequestActivity extends AppCompatActivity {
private Spinner spinner;
private EditText payments_details_input_input;
private Button send_button;
private ProgressDialog register_progress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_request);
initView();
initAction();
}
@Override
public void onBackPressed(){
super.onBackPressed();
overridePendingTransition(R.anim.back_enter, R.anim.back_exit);
return;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
super.onBackPressed();
overridePendingTransition(R.anim.back_enter, R.anim.back_exit);
return true;
}
return super.onOptionsItemSelected(item);
}
private void initView() {
Toolbar toolbar = (Toolbar)findViewById(R.id.toolbar);
toolbar.setTitle(getResources().getString(R.string.request_withdrawal));
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
send_button = (Button) findViewById(R.id.send_button);
spinner = (Spinner) findViewById(R.id.spinner_payments_methode);
payments_details_input_input = (EditText) findViewById(R.id.payments_details_input_input);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.payments_methodes, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
public void initAction(){
this.send_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (payments_details_input_input.getText().toString().trim().length()<5){
Toasty.error(getApplicationContext(),getResources().getString(R.string.error_short_value)).show();
return;
}
requestWithdrawal();
}
});
}
private void requestWithdrawal() {
register_progress = new ProgressDialog(RequestActivity.this);
register_progress.setCancelable(true);
register_progress.setMessage(getResources().getString(R.string.operation_progress));
register_progress.show();
PrefManager prefManager= new PrefManager(getApplicationContext());
Integer id_user = 0;
String key_user= "";
if (prefManager.getString("LOGGED").toString().equals("TRUE")) {
id_user= Integer.parseInt(prefManager.getString("ID_USER"));
key_user= prefManager.getString("TOKEN_USER");
}
Retrofit retrofit = apiClient.getClient();
apiRest service = retrofit.create(apiRest.class);
Call<ApiResponse> call = service.requestWithdrawal(id_user,key_user,spinner.getSelectedItem().toString(),payments_details_input_input.getText().toString().trim());
call.enqueue(new Callback<ApiResponse>() {
@Override
public void onResponse(Call<ApiResponse> call, Response<ApiResponse> response) {
apiClient.FormatData(RequestActivity.this,response);
if (response.isSuccessful()){
if (response.body().getCode().equals(200)){
Toasty.success(getApplicationContext(),response.body().getMessage(),Toast.LENGTH_LONG).show();
}else{
Toasty.error(getApplicationContext(),response.body().getMessage(),Toast.LENGTH_LONG).show();
}
}
register_progress.dismiss();
}
@Override
public void onFailure(Call<ApiResponse> call, Throwable t) {
register_progress.dismiss();
}
});
}
}
| [
"sherifffoladejo@gmail.com"
] | sherifffoladejo@gmail.com |
16c27e81aa7512f5a16163e50dd5b770b0b24f53 | d7f9e862f9e5cc0da273c1a8f0870702892c61de | /Service/src/com/nosliw/application/HAPUserContextInfo.java | fcc797dc40c50bb34d97d069f774aff6ec6644e5 | [] | no_license | forbestwn/Projects | 11c75b71607fd7012d96b977290372f1d8c77cb0 | 53230474097045701e403daf2b1e8bf866f4faf4 | refs/heads/master | 2021-01-21T04:40:31.899406 | 2016-06-30T13:07:58 | 2016-06-30T13:07:58 | 55,388,485 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 217 | java | package com.nosliw.application;
public class HAPUserContextInfo {
private String m_id = "default";
public HAPUserContextInfo(String id){
this.m_id = id;
}
public String getId(){
return this.m_id;
}
}
| [
"ningwangjobsearch@gmail.com"
] | ningwangjobsearch@gmail.com |
242448b5fdde885aa65813d2ceece50ff3ae2a0d | 96f316186577b65a4f48df6d59c2fb8d422248b1 | /src/main/java/lk/sachith/kerberos/Sftp.java | 7956727c4c1a18e5488c62c26b061fe9ec57b108 | [] | no_license | swsachith/jCraftTutorials | 2cb5355504c4668281005285240dd15ff2219dbd | 4c62b76bc4c03b2ef11619f56281c69f151e8fe0 | refs/heads/master | 2021-01-19T14:58:55.819689 | 2014-04-23T15:31:59 | 2014-04-23T15:31:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 22,586 | java | package lk.sachith.kerberos;
/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/**
* This program will demonstrate the sftp protocol support.
* $ CLASSPATH=.:../build javac Sftp.java
* $ CLASSPATH=.:../build java Sftp
* You will be asked username, host and passwd.
* If everything works fine, you will get a prompt 'sftp>'.
* 'help' command will show available command.
* In current implementation, the destination path for 'get' and 'put'
* commands must be a file, not a directory.
*
*/
import com.jcraft.jsch.*;
import java.awt.*;
import javax.swing.*;
public class Sftp{
public static void main(String[] arg){
try{
JSch jsch=new JSch();
String host=null;
if(arg.length>0){
host=arg[0];
}
else{
host=JOptionPane.showInputDialog("Enter username@hostname",
System.getProperty("user.name")+
"@localhost");
}
String user=host.substring(0, host.indexOf('@'));
host=host.substring(host.indexOf('@')+1);
int port=22;
Session session=jsch.getSession(user, host, port);
// username and password will be given via UserInfo interface.
UserInfo ui=new MyUserInfo();
session.setUserInfo(ui);
session.connect();
Channel channel=session.openChannel("sftp");
channel.connect();
ChannelSftp c=(ChannelSftp)channel;
java.io.InputStream in=System.in;
java.io.PrintStream out=System.out;
java.util.Vector cmds=new java.util.Vector();
byte[] buf=new byte[1024];
int i;
String str;
int level=0;
while(true){
out.print("sftp> ");
cmds.removeAllElements();
i=in.read(buf, 0, 1024);
if(i<=0)break;
i--;
if(i>0 && buf[i-1]==0x0d)i--;
//str=new String(buf, 0, i);
//System.out.println("|"+str+"|");
int s=0;
for(int ii=0; ii<i; ii++){
if(buf[ii]==' '){
if(ii-s>0){ cmds.addElement(new String(buf, s, ii-s)); }
while(ii<i){if(buf[ii]!=' ')break; ii++;}
s=ii;
}
}
if(s<i){ cmds.addElement(new String(buf, s, i-s)); }
if(cmds.size()==0)continue;
String cmd=(String)cmds.elementAt(0);
if(cmd.equals("quit")){
c.quit();
break;
}
if(cmd.equals("exit")){
c.exit();
break;
}
if(cmd.equals("rekey")){
session.rekey();
continue;
}
if(cmd.equals("compression")){
if(cmds.size()<2){
out.println("compression level: "+level);
continue;
}
try{
level=Integer.parseInt((String)cmds.elementAt(1));
if(level==0){
session.setConfig("compression.s2c", "none");
session.setConfig("compression.c2s", "none");
}
else{
session.setConfig("compression.s2c", "zlib@openssh.com,zlib,none");
session.setConfig("compression.c2s", "zlib@openssh.com,zlib,none");
}
}
catch(Exception e){}
session.rekey();
continue;
}
if(cmd.equals("cd") || cmd.equals("lcd")){
if(cmds.size()<2) continue;
String path=(String)cmds.elementAt(1);
try{
if(cmd.equals("cd")) c.cd(path);
else c.lcd(path);
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("rm") || cmd.equals("rmdir") || cmd.equals("mkdir")){
if(cmds.size()<2) continue;
String path=(String)cmds.elementAt(1);
try{
if(cmd.equals("rm")) c.rm(path);
else if(cmd.equals("rmdir")) c.rmdir(path);
else c.mkdir(path);
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("chgrp") || cmd.equals("chown") || cmd.equals("chmod")){
if(cmds.size()!=3) continue;
String path=(String)cmds.elementAt(2);
int foo=0;
if(cmd.equals("chmod")){
byte[] bar=((String)cmds.elementAt(1)).getBytes();
int k;
for(int j=0; j<bar.length; j++){
k=bar[j];
if(k<'0'||k>'7'){foo=-1; break;}
foo<<=3;
foo|=(k-'0');
}
if(foo==-1)continue;
}
else{
try{foo=Integer.parseInt((String)cmds.elementAt(1));}
catch(Exception e){continue;}
}
try{
if(cmd.equals("chgrp")){ c.chgrp(foo, path); }
else if(cmd.equals("chown")){ c.chown(foo, path); }
else if(cmd.equals("chmod")){ c.chmod(foo, path); }
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("pwd") || cmd.equals("lpwd")){
str=(cmd.equals("pwd")?"Remote":"Local");
str+=" working directory: ";
if(cmd.equals("pwd")) str+=c.pwd();
else str+=c.lpwd();
out.println(str);
continue;
}
if(cmd.equals("ls") || cmd.equals("dir")){
String path=".";
if(cmds.size()==2) path=(String)cmds.elementAt(1);
try{
java.util.Vector vv=c.ls(path);
if(vv!=null){
for(int ii=0; ii<vv.size(); ii++){
// out.println(vv.elementAt(ii).toString());
Object obj=vv.elementAt(ii);
if(obj instanceof com.jcraft.jsch.ChannelSftp.LsEntry){
out.println(((com.jcraft.jsch.ChannelSftp.LsEntry)obj).getLongname());
}
}
}
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("lls") || cmd.equals("ldir")){
String path=".";
if(cmds.size()==2) path=(String)cmds.elementAt(1);
try{
java.io.File file=new java.io.File(path);
if(!file.exists()){
out.println(path+": No such file or directory");
continue;
}
if(file.isDirectory()){
String[] list=file.list();
for(int ii=0; ii<list.length; ii++){
out.println(list[ii]);
}
continue;
}
out.println(path);
}
catch(Exception e){
System.out.println(e);
}
continue;
}
if(cmd.equals("get") ||
cmd.equals("get-resume") || cmd.equals("get-append") ||
cmd.equals("put") ||
cmd.equals("put-resume") || cmd.equals("put-append")
){
if(cmds.size()!=2 && cmds.size()!=3) continue;
String p1=(String)cmds.elementAt(1);
// String p2=p1;
String p2=".";
if(cmds.size()==3)p2=(String)cmds.elementAt(2);
try{
SftpProgressMonitor monitor=new MyProgressMonitor();
if(cmd.startsWith("get")){
int mode=ChannelSftp.OVERWRITE;
if(cmd.equals("get-resume")){ mode=ChannelSftp.RESUME; }
else if(cmd.equals("get-append")){ mode=ChannelSftp.APPEND; }
c.get(p1, p2, monitor, mode);
}
else{
int mode=ChannelSftp.OVERWRITE;
if(cmd.equals("put-resume")){ mode=ChannelSftp.RESUME; }
else if(cmd.equals("put-append")){ mode=ChannelSftp.APPEND; }
c.put(p1, p2, monitor, mode);
}
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("ln") || cmd.equals("symlink") ||
cmd.equals("rename") || cmd.equals("hardlink")){
if(cmds.size()!=3) continue;
String p1=(String)cmds.elementAt(1);
String p2=(String)cmds.elementAt(2);
try{
if(cmd.equals("hardlink")){ c.hardlink(p1, p2); }
else if(cmd.equals("rename")) c.rename(p1, p2);
else c.symlink(p1, p2);
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("df")){
if(cmds.size()>2) continue;
String p1 = cmds.size()==1 ? ".": (String)cmds.elementAt(1);
SftpStatVFS stat = c.statVFS(p1);
long size = stat.getSize();
long used = stat.getUsed();
long avail = stat.getAvailForNonRoot();
long root_avail = stat.getAvail();
long capacity = stat.getCapacity();
System.out.println("Size: "+size);
System.out.println("Used: "+used);
System.out.println("Avail: "+avail);
System.out.println("(root): "+root_avail);
System.out.println("%Capacity: "+capacity);
continue;
}
if(cmd.equals("stat") || cmd.equals("lstat")){
if(cmds.size()!=2) continue;
String p1=(String)cmds.elementAt(1);
SftpATTRS attrs=null;
try{
if(cmd.equals("stat")) attrs=c.stat(p1);
else attrs=c.lstat(p1);
}
catch(SftpException e){
System.out.println(e.toString());
}
if(attrs!=null){
out.println(attrs);
}
else{
}
continue;
}
if(cmd.equals("readlink")){
if(cmds.size()!=2) continue;
String p1=(String)cmds.elementAt(1);
String filename=null;
try{
filename=c.readlink(p1);
out.println(filename);
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("realpath")){
if(cmds.size()!=2) continue;
String p1=(String)cmds.elementAt(1);
String filename=null;
try{
filename=c.realpath(p1);
out.println(filename);
}
catch(SftpException e){
System.out.println(e.toString());
}
continue;
}
if(cmd.equals("version")){
out.println("SFTP protocol version "+c.version());
continue;
}
if(cmd.equals("help") || cmd.equals("?")){
out.println(help);
continue;
}
out.println("unimplemented command: "+cmd);
}
session.disconnect();
}
catch(Exception e){
System.out.println(e);
}
System.exit(0);
}
public static class MyUserInfo implements UserInfo, UIKeyboardInteractive{
public String getPassword(){ return passwd; }
public boolean promptYesNo(String str){
Object[] options={ "yes", "no" };
int foo=JOptionPane.showOptionDialog(null,
str,
"Warning",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
return foo==0;
}
String passwd;
JTextField passwordField=(JTextField)new JPasswordField(20);
public String getPassphrase(){ return null; }
public boolean promptPassphrase(String message){ return true; }
public boolean promptPassword(String message){
Object[] ob={passwordField};
int result=
JOptionPane.showConfirmDialog(null, ob, message,
JOptionPane.OK_CANCEL_OPTION);
if(result==JOptionPane.OK_OPTION){
passwd=passwordField.getText();
return true;
}
else{ return false; }
}
public void showMessage(String message){
JOptionPane.showMessageDialog(null, message);
}
final GridBagConstraints gbc =
new GridBagConstraints(0,0,1,1,1,1,
GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets(0,0,0,0),0,0);
private Container panel;
public String[] promptKeyboardInteractive(String destination,
String name,
String instruction,
String[] prompt,
boolean[] echo){
panel = new JPanel();
panel.setLayout(new GridBagLayout());
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridx = 0;
panel.add(new JLabel(instruction), gbc);
gbc.gridy++;
gbc.gridwidth = GridBagConstraints.RELATIVE;
JTextField[] texts=new JTextField[prompt.length];
for(int i=0; i<prompt.length; i++){
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 0;
gbc.weightx = 1;
panel.add(new JLabel(prompt[i]),gbc);
gbc.gridx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weighty = 1;
if(echo[i]){
texts[i]=new JTextField(20);
}
else{
texts[i]=new JPasswordField(20);
}
panel.add(texts[i], gbc);
gbc.gridy++;
}
if(JOptionPane.showConfirmDialog(null, panel,
destination+": "+name,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE)
==JOptionPane.OK_OPTION){
String[] response=new String[prompt.length];
for(int i=0; i<prompt.length; i++){
response[i]=texts[i].getText();
}
return response;
}
else{
return null; // cancel
}
}
}
/*
public static class MyProgressMonitor implements com.jcraft.jsch.ProgressMonitor{
JProgressBar progressBar;
JFrame frame;
long count=0;
long max=0;
public void init(String info, long max){
this.max=max;
if(frame==null){
frame=new JFrame();
frame.setSize(200, 20);
progressBar = new JProgressBar();
}
count=0;
frame.setTitle(info);
progressBar.setMaximum((int)max);
progressBar.setMinimum((int)0);
progressBar.setValue((int)count);
progressBar.setStringPainted(true);
JPanel p=new JPanel();
p.add(progressBar);
frame.getContentPane().add(progressBar);
frame.setVisible(true);
System.out.println("!info:"+info+", max="+max+" "+progressBar);
}
public void count(long count){
this.count+=count;
System.out.println("count: "+count);
progressBar.setValue((int)this.count);
}
public void end(){
System.out.println("end");
progressBar.setValue((int)this.max);
frame.setVisible(false);
}
}
*/
public static class MyProgressMonitor implements SftpProgressMonitor{
ProgressMonitor monitor;
long count=0;
long max=0;
public void init(int op, String src, String dest, long max){
this.max=max;
monitor=new ProgressMonitor(null,
((op==SftpProgressMonitor.PUT)?
"put" : "get")+": "+src,
"", 0, (int)max);
count=0;
percent=-1;
monitor.setProgress((int)this.count);
monitor.setMillisToDecideToPopup(1000);
}
private long percent=-1;
public boolean count(long count){
this.count+=count;
if(percent>=this.count*100/max){ return true; }
percent=this.count*100/max;
monitor.setNote("Completed "+this.count+"("+percent+"%) out of "+max+".");
monitor.setProgress((int)this.count);
return !(monitor.isCanceled());
}
public void end(){
monitor.close();
}
}
private static String help =
" Available commands:\n"+
" * means unimplemented command.\n"+
"cd path Change remote directory to 'path'\n"+
"lcd path Change local directory to 'path'\n"+
"chgrp grp path Change group of file 'path' to 'grp'\n"+
"chmod mode path Change permissions of file 'path' to 'mode'\n"+
"chown own path Change owner of file 'path' to 'own'\n"+
"df [path] Display statistics for current directory or\n"+
" filesystem containing 'path'\n"+
"help Display this help text\n"+
"get remote-path [local-path] Download file\n"+
"get-resume remote-path [local-path] Resume to download file.\n"+
"get-append remote-path [local-path] Append remote file to local file\n"+
"hardlink oldpath newpath Hardlink remote file\n"+
"*lls [ls-options [path]] Display local directory listing\n"+
"ln oldpath newpath Symlink remote file\n"+
"*lmkdir path Create local directory\n"+
"lpwd Print local working directory\n"+
"ls [path] Display remote directory listing\n"+
"*lumask umask Set local umask to 'umask'\n"+
"mkdir path Create remote directory\n"+
"put local-path [remote-path] Upload file\n"+
"put-resume local-path [remote-path] Resume to upload file\n"+
"put-append local-path [remote-path] Append local file to remote file.\n"+
"pwd Display remote working directory\n"+
"stat path Display info about path\n"+
"exit Quit sftp\n"+
"quit Quit sftp\n"+
"rename oldpath newpath Rename remote file\n"+
"rmdir path Remove remote directory\n"+
"rm path Delete remote file\n"+
"symlink oldpath newpath Symlink remote file\n"+
"readlink path Check the target of a symbolic link\n"+
"realpath path Canonicalize the path\n"+
"rekey Key re-exchanging\n"+
"compression level Packet compression will be enabled\n"+
"version Show SFTP version\n"+
"? Synonym for help";
} | [
"swsachith@gmail.com"
] | swsachith@gmail.com |
22b16abdac4c5d70bae54158285fb6497fba5203 | 90f76f0bf501cc1b8a78b01362c0ea7b825f4f1e | /src/test/java/runnerTest/webPages/ElementUtil.java | 4b926d2cee0f470f24c87de5482b8d539c52c17c | [] | no_license | ademkaragoz/BDDC4Cucumber_2020 | 7fd1e0032af4b5d5ae890f4db4ab53abfd8b2214 | 502d0686c67c632db021104b5e8904964d1a768f | refs/heads/master | 2022-11-26T10:32:58.549297 | 2020-08-06T04:32:19 | 2020-08-06T04:32:19 | 285,473,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,368 | java | package runnerTest.webPages;
import org.apache.commons.io.FileUtils;
import org.openqa.selenium.*;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.FluentWait;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.Wait;
import utils.BasePage;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
public class ElementUtil {
/**
* Fluentwait method which is used for elements
* @param locator
* @return
*/
public static WebElement webAction(final By locator){
Wait<WebDriver> wait = new FluentWait<WebDriver>(BasePage.get())
.withTimeout(Duration.ofSeconds(15))
.pollingEvery(Duration.ofSeconds(1))
.ignoring(NoSuchElementException.class)
.ignoring(StaleElementReferenceException.class)
.ignoring(ElementClickInterceptedException.class)
.withMessage(
"Webdriver waited for 15 seconds but still could not find the element therefore TimeOutException has been thrown"
);
return wait.until(new Function<WebDriver, WebElement>(){
public WebElement apply(WebDriver driver){
return driver.findElement(locator);
}
});
}
/**
* ClickOn method is used click the element
* @param locator
*/
public void clickOn(By locator){
webAction(locator).click();
}
/**
* SendKeys method
* @param locator
* @param value
*/
public void sendValue(By locator, String value) {
try{
webAction(locator).sendKeys(value);
}catch (Exception e){
System.out.println("Some exception occured while sending value" + locator);
}
}
/**
* GetText method
* @param locator
* @return
*/
public String getTextFromElement(By locator){
return webAction(locator).getText();
}
/**
* clear method
* @param locator
*/
public void clear(By locator){
webAction(locator).clear();
}
/**
* isDisplayed Method
* @param locator
* @return
*/
public boolean isElementDisplayed(By locator){
return webAction(locator).isDisplayed();
}
/**
* isSelected Method
* @param locator
* @return
*/
public boolean isElementSelected(By locator){
return webAction(locator).isSelected();
}
/**
* isEnabled Method
* @param locator
* @return
*/
public boolean isElementEnabled(By locator){
return webAction(locator).isEnabled();
}
/**
* findElements method
* It is used multiple locators
* @param locator
* @return
*/
public List<WebElement> webElements(By locator){
return BasePage.get().findElements(locator);
}
/**
* DropDown Select Text Method
* @param locator
* @param dropDownText
*/
public void selectFromDropDownText(By locator, String dropDownText){
WebElement text = webAction(locator);
Select selectText = new Select(text);
selectText.selectByVisibleText(dropDownText);
}
/**
* DropDown Select Index Method
* @param locator
* @param dropDownIndex
*/
public void selectFromDropDownIndex(By locator, int dropDownIndex){
WebElement index = webAction(locator);
Select selectIndex = new Select(index);
selectIndex.selectByIndex(dropDownIndex);
}
/**
* ScrollDown method using scrollIntoView
* @param locator
*/
public void scrollByElement(By locator){
WebElement scrollElement = webAction(locator);
JavascriptExecutor js = (JavascriptExecutor) BasePage.get();
js.executeScript("argument[0].scrollIntoView;", scrollElement);
}
/**
* ScrollDown method using pixel
* @param xPixel
* @param yPixel
*/
public void scrollByPixel(String xPixel, String yPixel){
String str = "window.scrollBy("+ xPixel +", "+ yPixel +")";
JavascriptExecutor js = (JavascriptExecutor) BasePage.get();
js.executeScript(str);
}
/**
* MoveToElement Actions class
* @param locator
*/
public void moveToElement(By locator){
Actions actions = new Actions(BasePage.get());
actions.moveToElement(webAction(locator)).build().perform();
}
/**
* GetScreenShot method
* If test is failed use this method under the hook after
* @param name
* @return
*/
public String getScreenShot(String name){
SimpleDateFormat df = new SimpleDateFormat("-yyyy-MM-dd-HH-mm");
String date = df.format(new Date());
TakesScreenshot ts = (TakesScreenshot) BasePage.get();
File source = ts.getScreenshotAs((OutputType.FILE));
String target = System.getProperty("user.dir") + "/test-output/Screenshots/"+ name + date + ".png";
File finalDestination = new File(target);
try{
FileUtils.copyFile(source, finalDestination);
}catch (IOException e){
e.printStackTrace();
}
return target;
}
}
| [
"adembombay@gmail.com"
] | adembombay@gmail.com |
066b93691e995fa37c0258211e768293cc1ec395 | 3dd4cd0aa188c779cfb129e3cc90186aacd0b089 | /src/main/java/ru/job4j/math/MathFunction.java | f07b468620cb01911d4daab6b20868ad68fb50fd | [] | no_license | viktoryboykova/job4j_elementary | cd26c9d00010ef8ad67aa33f4349249c72a814fa | bef208e287914d3b56063a441fec11a67cf9f3c3 | refs/heads/master | 2023-09-01T10:48:32.442617 | 2021-10-03T19:00:55 | 2021-10-03T19:00:55 | 409,619,625 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 468 | java | package ru.job4j.math;
public class MathFunction {
public static double summa(double first, double second) {
return first + second;
}
public static double umnozhenie(double first, double second) {
return first * second;
}
public static double raznost(double first, double second) {
return first - second;
}
public static double delenie(double first, double second) {
return first / second;
}
}
| [
"viktoryboykova@list.ru"
] | viktoryboykova@list.ru |
fcfdf3f3051c308bda763f2b15da6f7fc23e4bd8 | 3bbb1bc9f0a95d5c7c70c07bfd156c21409d8fa5 | /video-list-service/src/main/java/com/video/list/domain/VideoData.java | 373592dfe49aa0dc6e09b826d8789de6f03fe762 | [] | no_license | janakec19/video-service | a44cfee2ea7a0c3ef2402bb0c5ce67cdcd6ffbd5 | 18642e5a3ea791b12def9a396c31ee55fbbe348f | refs/heads/master | 2022-04-19T00:43:43.060019 | 2020-04-17T06:06:38 | 2020-04-17T06:06:38 | 256,140,261 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 412 | java | package com.video.list.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class VideoData implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String name;
private String description;
private String views;
private Date uploadedDate;
private String createdBy;
private String group;
}
| [
"janakec19@gmail.com"
] | janakec19@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.