blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2 values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 689M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22 values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 131 values | src_encoding stringclasses 34 values | language stringclasses 1 value | is_vendor bool 1 class | is_generated bool 2 classes | length_bytes int64 3 9.45M | extension stringclasses 32 values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
25f72cc2270c64060e31a5d8be1490eb5f1b7bcf | 025ba23b1416c2fdf8846d74dc1dce0b299a7220 | /whoWantsToBeAMillionaire/src/main/java/finalProject/whoWantsToBeAMillionaire/components/DataLoader.java | a8dbfbfb1c4880d87b9f9d5a26a800215d539b53 | [] | no_license | stmccoy/who_wants_to_be_a_millionaire_final_project | 85009cab0b787593b9d96367b3a5107aff5af725 | 022c4fe37b8621890f89418bf7d6cd5f1eb0e545 | refs/heads/main | 2023-06-19T10:51:40.322497 | 2021-07-21T18:49:49 | 2021-07-21T18:49:49 | 381,329,098 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 119,882 | java | package finalProject.whoWantsToBeAMillionaire.components;
import finalProject.whoWantsToBeAMillionaire.models.Answer;
import finalProject.whoWantsToBeAMillionaire.models.Difficulty;
import finalProject.whoWantsToBeAMillionaire.models.Question;
import finalProject.whoWantsToBeAMillionaire.models.Round;
import finalProject.whoWantsToBeAMillionaire.repositories.AnswerRepository;
import finalProject.whoWantsToBeAMillionaire.repositories.QuestionRepository;
import finalProject.whoWantsToBeAMillionaire.repositories.RoundRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
@Component
public class DataLoader implements ApplicationRunner {
@Autowired
QuestionRepository questionRepository;
@Autowired
AnswerRepository answerRepository;
@Autowired
RoundRepository roundRepository;
@Override
public void run(ApplicationArguments args) throws Exception{
Question questionOne = new Question("Who Wrote Harry Potter", Difficulty.ZERO);
questionRepository.save(questionOne);
Answer q1AnswerOne = new Answer("J.K. Rowling", questionOne, true);
answerRepository.save(q1AnswerOne);
Answer q1AnswerTwo = new Answer("J.R.R. Tolkien", questionOne, false);
answerRepository.save(q1AnswerTwo);
Answer q1AnswerThree = new Answer("Terry Pratchett", questionOne, false);
answerRepository.save(q1AnswerThree);
Answer q1AnswerFour = new Answer("Daniel Radcliffe", questionOne, false);
answerRepository.save(q1AnswerFour);
Question questionTwo = new Question("Who discovered Penicillin", Difficulty.ZERO);
questionRepository.save(questionTwo);
Answer q2AnswerOne = new Answer("Alexander Flemming", questionTwo, true);
answerRepository.save(q2AnswerOne);
Answer q2AnswerTwo = new Answer("Marie Curie", questionTwo, false);
answerRepository.save(q2AnswerTwo);
Answer q2AnswerThree = new Answer("Alfred Nobel", questionTwo, false);
answerRepository.save(q2AnswerThree);
Answer q2AnswerFour = new Answer("Louis Pasteur", questionTwo, false);
answerRepository.save(q2AnswerFour);
Question questionThree = new Question("Kanye West at 2009 VMA's interrupted which celebrity?", Difficulty.ZERO);
questionRepository.save(questionThree);
Answer q3AnswerOne = new Answer("Taylor Swift", questionThree, true);
answerRepository.save(q3AnswerOne);
Answer q3AnswerTwo = new Answer("MF DOOM", questionThree, false);
answerRepository.save(q3AnswerTwo);
Answer q3AnswerThree = new Answer("Beyonce", questionThree, false);
answerRepository.save(q3AnswerThree);
Answer q3AnswerFour = new Answer("Beck", questionThree, false);
answerRepository.save(q3AnswerFour);
Question questionFour = new Question("What is the capital of Scotland?", Difficulty.ZERO);
questionRepository.save(questionFour);
Answer q4AnswerOne = new Answer("Edinburgh", questionFour, true);
answerRepository.save(q4AnswerOne);
Answer q4AnswerTwo = new Answer("Glasgow", questionFour, false);
answerRepository.save(q4AnswerTwo);
Answer q4AnswerThree = new Answer("Dundee", questionFour, false);
answerRepository.save(q4AnswerThree);
Answer q4AnswerFour = new Answer("London", questionFour, false);
answerRepository.save(q4AnswerFour);
Question questionFive = new Question("Which of these characters live in a pineapple under the sea", Difficulty.ZERO);
questionRepository.save(questionFive);
Answer q5AnswerOne = new Answer("SpongeBob SquarePants", questionFive, true);
answerRepository.save(q5AnswerOne);
Answer q5AnswerTwo = new Answer("Patrick Star", questionFive, false);
answerRepository.save(q5AnswerTwo);
Answer q5AnswerThree = new Answer("Squidward Tentacles", questionFive, false);
answerRepository.save(q5AnswerThree);
Answer q5AnswerFour = new Answer("Mr. Krabs", questionFive, false);
answerRepository.save(q5AnswerFour);
Question questionSix = new Question("Who painted the Mona Lisa?", Difficulty.ZERO);
questionRepository.save(questionSix);
Answer q6AnswerOne = new Answer("Leonardo da Vinci", questionSix, true);
answerRepository.save(q6AnswerOne);
Answer q6AnswerTwo = new Answer("Pablo Picasso", questionSix, false);
answerRepository.save(q6AnswerTwo);
Answer q6AnswerThree = new Answer("Claude Monet", questionSix, false);
answerRepository.save(q6AnswerThree);
Answer q6AnswerFour = new Answer("Vincent van Gogh", questionSix, false);
answerRepository.save(q6AnswerFour);
Question questionSeven = new Question("In what sport is a 'shuttlecock' used?", Difficulty.ZERO);
questionRepository.save(questionSeven);
Answer q7AnswerOne = new Answer("Badminton", questionSeven, true);
answerRepository.save(q7AnswerOne);
Answer q7AnswerTwo = new Answer("Table Tennis", questionSeven, false);
answerRepository.save(q7AnswerTwo);
Answer q7AnswerThree = new Answer("Rugby", questionSeven, false);
answerRepository.save(q7AnswerThree);
Answer q7AnswerFour = new Answer("Cricket", questionSeven, false);
answerRepository.save(q7AnswerFour);
Question questionEight = new Question("Who is the lead singer of the band Coldplay?", Difficulty.ZERO);
questionRepository.save(questionEight);
Answer q8AnswerOne = new Answer("Chris Martin", questionEight, true);
answerRepository.save(q8AnswerOne);
Answer q8AnswerTwo = new Answer("Chris Isaak", questionEight, false);
answerRepository.save(q8AnswerTwo);
Answer q8AnswerThree = new Answer("Chris Wallace", questionEight, false);
answerRepository.save(q8AnswerThree);
Answer q8AnswerFour = new Answer("Chris Connelly", questionEight, false);
answerRepository.save(q8AnswerFour);
Question questionNine = new Question("Alzheimer's disease primarily affects which part of the human body?", Difficulty.ZERO);
questionRepository.save(questionNine);
Answer q9AnswerOne = new Answer("Brain", questionNine, true);
answerRepository.save(q9AnswerOne);
Answer q9AnswerTwo = new Answer("Lungs", questionNine, false);
answerRepository.save(q9AnswerTwo);
Answer q9AnswerThree = new Answer("Skin", questionNine, false);
answerRepository.save(q9AnswerThree);
Answer q9AnswerFour = new Answer("Heart", questionNine, false);
answerRepository.save(q9AnswerFour);
Question questionTen = new Question("Which punk rock band released hit songs such as 'Californication', 'Can't Stop' and 'Under the Bridge'", Difficulty.ZERO);
questionRepository.save(questionTen);
Answer q10AnswerOne = new Answer("Red Hot Chilli Peppers", questionTen, true);
answerRepository.save(q10AnswerOne);
Answer q10AnswerTwo = new Answer("Green Day", questionTen, false);
answerRepository.save(q10AnswerTwo);
Answer q10AnswerThree = new Answer("Linkin Park", questionTen, false);
answerRepository.save(q10AnswerThree);
Answer q10AnswerFour = new Answer("Foo Fighters", questionTen, false);
answerRepository.save(q10AnswerFour);
Question questionEleven = new Question("In which city of America was the Fresh Prince of Bel-Air born and raised in?", Difficulty.ZERO);
questionRepository.save(questionEleven);
Answer q11AnswerOne = new Answer("Philadelphia", questionEleven, true);
answerRepository.save(q11AnswerOne);
Answer q11AnswerTwo = new Answer("LA", questionEleven, false);
answerRepository.save(q11AnswerTwo);
Answer q11AnswerThree = new Answer("New York", questionEleven, false);
answerRepository.save(q11AnswerThree);
Answer q11AnswerFour = new Answer("Dallas", questionEleven, false);
answerRepository.save(q11AnswerFour);
Question questionTwelve = new Question("Who was the villain of The Lion King?", Difficulty.ZERO);
questionRepository.save(questionTwelve);
Answer q12AnswerOne = new Answer("Scar", questionTwelve, true);
answerRepository.save(q12AnswerOne);
Answer q12AnswerTwo = new Answer("Fred", questionTwelve, false);
answerRepository.save(q12AnswerTwo);
Answer q12AnswerThree = new Answer("Jafar", questionTwelve, false);
answerRepository.save(q12AnswerThree);
Answer q12AnswerFour = new Answer("Vada", questionTwelve, false);
answerRepository.save(q12AnswerFour);
Question questionThirteen = new Question("Which former boy-band star released hit solo single 'Angels' in 1997?", Difficulty.ZERO);
questionRepository.save(questionThirteen);
Answer q13AnswerOne = new Answer("Robbie Williams", questionThirteen, true);
answerRepository.save(q13AnswerOne);
Answer q13AnswerTwo = new Answer("Justin Timberlake", questionThirteen, false);
answerRepository.save(q13AnswerTwo);
Answer q13AnswerThree = new Answer("Harry Styles", questionThirteen, false);
answerRepository.save(q13AnswerThree);
Answer q13AnswerFour = new Answer("Gary Barlow", questionThirteen, false);
answerRepository.save(q13AnswerFour);
Question questionFourteen = new Question("When someone is cowardly, they are said to have what color belly?", Difficulty.ZERO);
questionRepository.save(questionFourteen);
Answer q14AnswerOne = new Answer("Yellow", questionFourteen, true);
answerRepository.save(q14AnswerOne);
Answer q14AnswerTwo = new Answer("Green", questionFourteen, false);
answerRepository.save(q14AnswerTwo);
Answer q14AnswerThree = new Answer("Red", questionFourteen, false);
answerRepository.save(q14AnswerThree);
Answer q14AnswerFour = new Answer("Blue", questionFourteen, false);
answerRepository.save(q14AnswerFour);
Question questionFifteen = new Question("Who is the star of the AMC series Breaking Bad?", Difficulty.ZERO);
questionRepository.save(questionFifteen);
Answer q15AnswerOne = new Answer("Walter White", questionFifteen, true);
answerRepository.save(q15AnswerOne);
Answer q15AnswerTwo = new Answer("Saul Goodman", questionFifteen, false);
answerRepository.save(q15AnswerTwo);
Answer q15AnswerThree = new Answer("Jesse Pinkman", questionFifteen, false);
answerRepository.save(q15AnswerThree);
Answer q15AnswerFour = new Answer("Skyler White", questionFifteen, false);
answerRepository.save(q15AnswerFour);
Question questionSixteen = new Question("On which of these Daft Punk's tracks does Pharrell Williams feature?", Difficulty.ZERO);
questionRepository.save(questionSixteen);
Answer q16AnswerOne = new Answer("Get Lucky", questionSixteen, true);
answerRepository.save(q16AnswerOne);
Answer q16AnswerTwo = new Answer("Touch", questionSixteen, false);
answerRepository.save(q16AnswerTwo);
Answer q16AnswerThree = new Answer("Beyond", questionSixteen, false);
answerRepository.save(q16AnswerThree);
Answer q16AnswerFour = new Answer("Within", questionSixteen, false);
answerRepository.save(q16AnswerFour);
Question questionSeventeen = new Question("Which famous cartoon features a mouse and a cat as the two main characters?", Difficulty.ZERO);
questionRepository.save(questionSeventeen);
Answer q17AnswerOne = new Answer("Tom and Jerry", questionSeventeen, true);
answerRepository.save(q17AnswerOne);
Answer q17AnswerTwo = new Answer("Simpsons", questionSeventeen, false);
answerRepository.save(q17AnswerTwo);
Answer q17AnswerThree = new Answer("DuckTales", questionSeventeen, false);
answerRepository.save(q17AnswerThree);
Answer q17AnswerFour = new Answer("Futurama", questionSeventeen, false);
answerRepository.save(q17AnswerFour);
Question questionEighteen = new Question("What colour is the circle on the Japanese flag?", Difficulty.ZERO);
questionRepository.save(questionEighteen);
Answer q18AnswerOne = new Answer("Red", questionEighteen, true);
answerRepository.save(q18AnswerOne);
Answer q18AnswerTwo = new Answer("White", questionEighteen, false);
answerRepository.save(q18AnswerTwo);
Answer q18AnswerThree = new Answer("Yellow", questionEighteen, false);
answerRepository.save(q18AnswerThree);
Answer q18AnswerFour = new Answer("Black", questionEighteen, false);
answerRepository.save(q18AnswerFour);
Question questionNineteen = new Question("In the movie Gremlins, after what time of day should you not feed Mogwai?", Difficulty.ZERO);
questionRepository.save(questionNineteen);
Answer q19AnswerOne = new Answer("Midnight", questionNineteen, true);
answerRepository.save(q19AnswerOne);
Answer q19AnswerTwo = new Answer("Evening", questionNineteen, false);
answerRepository.save(q19AnswerTwo);
Answer q19AnswerThree = new Answer("Morning", questionNineteen, false);
answerRepository.save(q19AnswerThree);
Answer q19AnswerFour = new Answer("Afternoon", questionNineteen, false);
answerRepository.save(q19AnswerFour);
Question questionTwenty = new Question("What do the letters of the fast food chain KFC stand for?", Difficulty.ZERO);
questionRepository.save(questionTwenty);
Answer q20AnswerOne = new Answer("Kentucky Fried Chicken", questionTwenty, true);
answerRepository.save(q20AnswerOne);
Answer q20AnswerTwo = new Answer("Kentucky Fresh Cheese", questionTwenty, false);
answerRepository.save(q20AnswerTwo);
Answer q20AnswerThree = new Answer("Kibbled Freaky Cow", questionTwenty, false);
answerRepository.save(q20AnswerThree);
Answer q20AnswerFour = new Answer("Kiwi Food Cut", questionTwenty, false);
answerRepository.save(q20AnswerFour);
Question questionTwentyOne = new Question("Which of these is NOT a Disney cartoon character?", Difficulty.ONE);
questionRepository.save(questionTwentyOne);
Answer q21AnswerOne = new Answer("Daffy Duck", questionTwentyOne, true);
answerRepository.save(q21AnswerOne);
Answer q21AnswerTwo = new Answer("Donald Duck", questionTwentyOne, false);
answerRepository.save(q21AnswerTwo);
Answer q21AnswerThree = new Answer("Scrooge McDuck", questionTwentyOne, false);
answerRepository.save(q21AnswerThree);
Answer q21AnswerFour = new Answer("Dumbo", questionTwentyOne, false);
answerRepository.save(q21AnswerFour);
Question questionTwentyTwo = new Question("Which UK country features a dragon on their flag?", Difficulty.ONE);
questionRepository.save(questionTwentyTwo);
Answer q22AnswerOne = new Answer("Wales", questionTwentyTwo, true);
answerRepository.save(q22AnswerOne);
Answer q22AnswerTwo = new Answer("England", questionTwentyTwo, false);
answerRepository.save(q22AnswerTwo);
Answer q22AnswerThree = new Answer("North Ireland", questionTwentyTwo, false);
answerRepository.save(q22AnswerThree);
Answer q22AnswerFour = new Answer("Scotland", questionTwentyTwo, false);
answerRepository.save(q22AnswerFour);
Question questionTwentyThree = new Question("Which city is the capital of the United States of America?", Difficulty.ONE);
questionRepository.save(questionTwentyThree);
Answer q23AnswerOne = new Answer("Washington D.C", questionTwentyThree, true);
answerRepository.save(q23AnswerOne);
Answer q23AnswerTwo = new Answer("Seattle", questionTwentyThree, false);
answerRepository.save(q23AnswerTwo);
Answer q23AnswerThree = new Answer("Albany", questionTwentyThree, false);
answerRepository.save(q23AnswerThree);
Answer q23AnswerFour = new Answer("Los Angeles", questionTwentyThree, false);
answerRepository.save(q23AnswerFour);
Question questionTwentyFour = new Question("What is the capital of India?", Difficulty.ONE);
questionRepository.save(questionTwentyFour);
Answer q24AnswerOne = new Answer("New Delhi", questionTwentyFour, true);
answerRepository.save(q24AnswerOne);
Answer q24AnswerTwo = new Answer("Bejing", questionTwentyFour, false);
answerRepository.save(q24AnswerTwo);
Answer q24AnswerThree = new Answer("Montreal", questionTwentyFour, false);
answerRepository.save(q24AnswerThree);
Answer q24AnswerFour = new Answer("Tithi", questionTwentyFour, false);
answerRepository.save(q24AnswerFour);
Question questionTwentyFive = new Question("Which actor portrays 'Walter White' in the series 'Breaking Bad'?", Difficulty.ONE);
questionRepository.save(questionTwentyFive);
Answer q25AnswerOne = new Answer("Bryan Cranston", questionTwentyFive, true);
answerRepository.save(q25AnswerOne);
Answer q25AnswerTwo = new Answer("Andrew Lincoln", questionTwentyFive, false);
answerRepository.save(q25AnswerTwo);
Answer q25AnswerThree = new Answer("Aaron Paul", questionTwentyFive, false);
answerRepository.save(q25AnswerThree);
Answer q25AnswerFour = new Answer("RJ Mitte", questionTwentyFive, false);
answerRepository.save(q25AnswerFour);
Question questionTwentySix = new Question("The Kiwi is a flightless bird native to which country?", Difficulty.ONE);
questionRepository.save(questionTwentySix);
Answer q26AnswerOne = new Answer("New Zealand", questionTwentySix, true);
answerRepository.save(q26AnswerOne);
Answer q26AnswerTwo = new Answer("South Africa", questionTwentySix, false);
answerRepository.save(q26AnswerTwo);
Answer q26AnswerThree = new Answer("Australia", questionTwentySix, false);
answerRepository.save(q26AnswerThree);
Answer q26AnswerFour = new Answer("Madagascar", questionTwentySix, false);
answerRepository.save(q26AnswerFour);
Question questionTwentySeven = new Question("What is the name of Finnish DJ Darude's hit single released in October 1999?", Difficulty.ONE);
questionRepository.save(questionTwentySeven);
Answer q27AnswerOne = new Answer("Sandstorm", questionTwentySeven, true);
answerRepository.save(q27AnswerOne);
Answer q27AnswerTwo = new Answer("Dust Devil", questionTwentySeven, false);
answerRepository.save(q27AnswerTwo);
Answer q27AnswerThree = new Answer("Sirocco", questionTwentySeven, false);
answerRepository.save(q27AnswerThree);
Answer q27AnswerFour = new Answer("Khamsin", questionTwentySeven, false);
answerRepository.save(q27AnswerFour);
Question questionTwentyEight = new Question("Who is the lead singer of Foo Fighters?", Difficulty.ONE);
questionRepository.save(questionTwentyEight);
Answer q28AnswerOne = new Answer("Dave Grohl", questionTwentyEight, true);
answerRepository.save(q28AnswerOne);
Answer q28AnswerTwo = new Answer("Dave Mustaine", questionTwentyEight, false);
answerRepository.save(q28AnswerTwo);
Answer q28AnswerThree = new Answer("James Hetfield", questionTwentyEight, false);
answerRepository.save(q28AnswerThree);
Answer q28AnswerFour = new Answer("Little Red Riding Hood", questionTwentyEight, false);
answerRepository.save(q28AnswerFour);
Question questionTwentyNine = new Question("George Orwell wrote this book, which is often considered a statement on government oversight.", Difficulty.ONE);
questionRepository.save(questionTwentyNine);
Answer q29AnswerOne = new Answer("1984", questionTwentyNine, true);
answerRepository.save(q29AnswerOne);
Answer q29AnswerTwo = new Answer("The Old Man and the Sea", questionTwentyNine, false);
answerRepository.save(q29AnswerTwo);
Answer q29AnswerThree = new Answer("Catcher and the Rye", questionTwentyNine, false);
answerRepository.save(q29AnswerThree);
Answer q29AnswerFour = new Answer("To Kill a Mockingbird", questionTwentyNine, false);
answerRepository.save(q29AnswerFour);
Question questionThirty = new Question("What is the capital of South Korea?", Difficulty.ONE);
questionRepository.save(questionThirty);
Answer q30AnswerOne = new Answer("Seoul", questionThirty, true);
answerRepository.save(q30AnswerOne);
Answer q30AnswerTwo = new Answer("Pyongyang", questionThirty, false);
answerRepository.save(q30AnswerTwo);
Answer q30AnswerThree = new Answer("Taegu", questionThirty, false);
answerRepository.save(q30AnswerThree);
Answer q30AnswerFour = new Answer("Kitakyushu", questionThirty, false);
answerRepository.save(q30AnswerFour);
Question questionThirtyOne = new Question("The film 28 Day's Later is mainly set in which European country?", Difficulty.ONE);
questionRepository.save(questionThirtyOne);
Answer q31AnswerOne = new Answer("United Kingdom", questionThirtyOne, true);
answerRepository.save(q31AnswerOne);
Answer q31AnswerTwo = new Answer("France", questionThirtyOne, false);
answerRepository.save(q31AnswerTwo);
Answer q31AnswerThree = new Answer("Italy", questionThirtyOne, false);
answerRepository.save(q31AnswerThree);
Answer q31AnswerFour = new Answer("Germany", questionThirtyOne, false);
answerRepository.save(q31AnswerFour);
Question questionThirtyTwo = new Question("What is not a wind instrument?", Difficulty.ONE);
questionRepository.save(questionThirtyTwo);
Answer q32AnswerOne = new Answer("Violin", questionThirtyTwo, true);
answerRepository.save(q32AnswerOne);
Answer q32AnswerTwo = new Answer("Oboe", questionThirtyTwo, false);
answerRepository.save(q32AnswerTwo);
Answer q32AnswerThree = new Answer("Trombone", questionThirtyTwo, false);
answerRepository.save(q32AnswerThree);
Answer q32AnswerFour = new Answer("Tuba", questionThirtyTwo, false);
answerRepository.save(q32AnswerFour);
Question questionThirtyThree = new Question("The first rule is: 'you don't talk about it' is a reference to which movie?", Difficulty.ONE);
questionRepository.save(questionThirtyThree);
Answer q33AnswerOne = new Answer("Fight Club", questionThirtyThree, true);
answerRepository.save(q33AnswerOne);
Answer q33AnswerTwo = new Answer("The Island", questionThirtyThree, false);
answerRepository.save(q33AnswerTwo);
Answer q33AnswerThree = new Answer("Unthinkable", questionThirtyThree, false);
answerRepository.save(q33AnswerThree);
Answer q33AnswerFour = new Answer("American Pie", questionThirtyThree, false);
answerRepository.save(q33AnswerFour);
Question questionThirtyFour = new Question("What is the chemical makeup of water?", Difficulty.ONE);
questionRepository.save(questionThirtyFour);
Answer q34AnswerOne = new Answer("H20", questionThirtyFour, true);
answerRepository.save(q34AnswerOne);
Answer q34AnswerTwo = new Answer("C12H6O2", questionThirtyFour, false);
answerRepository.save(q34AnswerTwo);
Answer q34AnswerThree = new Answer("CO2", questionThirtyFour, false);
answerRepository.save(q34AnswerThree);
Answer q34AnswerFour = new Answer("H", questionThirtyFour, false);
answerRepository.save(q34AnswerFour);
Question questionThirtyFive = new Question("What was the name of the sea witch in the 1989 Disney film 'The Little Mermaid'?", Difficulty.ONE);
questionRepository.save(questionThirtyFive);
Answer q35AnswerOne = new Answer("Ursula", questionThirtyFive, true);
answerRepository.save(q35AnswerOne);
Answer q35AnswerTwo = new Answer("Madam Mim", questionThirtyFive, false);
answerRepository.save(q35AnswerTwo);
Answer q35AnswerThree = new Answer("Maleficent", questionThirtyFive, false);
answerRepository.save(q35AnswerThree);
Answer q35AnswerFour = new Answer("Lady Tremaine", questionThirtyFive, false);
answerRepository.save(q35AnswerFour);
Question questionThirtySix = new Question("Who is the lead vocalist of the band 'The Police", Difficulty.ONE);
questionRepository.save(questionThirtySix);
Answer q36AnswerOne = new Answer("Sting", questionThirtySix, true);
answerRepository.save(q36AnswerOne);
Answer q36AnswerTwo = new Answer("Bono", questionThirtySix, false);
answerRepository.save(q36AnswerTwo);
Answer q36AnswerThree = new Answer("Robert Plant", questionThirtySix, false);
answerRepository.save(q36AnswerThree);
Answer q36AnswerFour = new Answer("Axl Rose", questionThirtySix, false);
answerRepository.save(q36AnswerFour);
Question questionThirtySeven = new Question("Who performed the song 'I Took A Pill In Ibiza'?", Difficulty.ONE);
questionRepository.save(questionThirtySeven);
Answer q37AnswerOne = new Answer("Mike Posner", questionThirtySeven, true);
answerRepository.save(q37AnswerOne);
Answer q37AnswerTwo = new Answer("Robbie Williams", questionThirtySeven, false);
answerRepository.save(q37AnswerTwo);
Answer q37AnswerThree = new Answer("Harry Styles", questionThirtySeven, false);
answerRepository.save(q37AnswerThree);
Answer q37AnswerFour = new Answer("Avicii", questionThirtySeven, false);
answerRepository.save(q37AnswerFour);
Question questionThirtyEight = new Question("Which programming language shares its name with an island in Indonesia?", Difficulty.ONE);
questionRepository.save(questionThirtyEight);
Answer q38AnswerOne = new Answer("Java", questionThirtyEight, true);
answerRepository.save(q38AnswerOne);
Answer q38AnswerTwo = new Answer("Python", questionThirtyEight, false);
answerRepository.save(q38AnswerTwo);
Answer q38AnswerThree = new Answer("C", questionThirtyEight, false);
answerRepository.save(q38AnswerThree);
Answer q38AnswerFour = new Answer("C#", questionThirtyEight, false);
answerRepository.save(q38AnswerFour);
Question questionThirtyNine = new Question("Earth is located in which galaxy?", Difficulty.ONE);
questionRepository.save(questionThirtyNine);
Answer q39AnswerOne = new Answer("The Milky Way Galaxy", questionThirtyNine, true);
answerRepository.save(q39AnswerOne);
Answer q39AnswerTwo = new Answer("The Mars Galaxy", questionThirtyNine, false);
answerRepository.save(q39AnswerTwo);
Answer q39AnswerThree = new Answer("The Galaxy Note", questionThirtyNine, false);
answerRepository.save(q39AnswerThree);
Answer q39AnswerFour = new Answer("The Black Hole", questionThirtyNine, false);
answerRepository.save(q39AnswerFour);
Question questionForty = new Question("Which of the following is NOT a Nintendo game console?", Difficulty.ONE);
questionRepository.save(questionForty);
Answer q40AnswerOne = new Answer("Dreamcast", questionForty, true);
answerRepository.save(q40AnswerOne);
Answer q40AnswerTwo = new Answer("SNES", questionForty, false);
answerRepository.save(q40AnswerTwo);
Answer q40AnswerThree = new Answer("Wii", questionForty, false);
answerRepository.save(q40AnswerThree);
Answer q40AnswerFour = new Answer("Switch", questionForty, false);
answerRepository.save(q40AnswerFour);
Question questionFortyOne = new Question("What does the letter 'S' stand for in 'NASA'?", Difficulty.TWO);
questionRepository.save(questionFortyOne);
Answer q41AnswerOne = new Answer("Space", questionFortyOne, true);
answerRepository.save(q41AnswerOne);
Answer q41AnswerTwo = new Answer("Science", questionFortyOne, false);
answerRepository.save(q41AnswerTwo);
Answer q41AnswerThree = new Answer("Society", questionFortyOne, false);
answerRepository.save(q41AnswerThree);
Answer q41AnswerFour = new Answer("Star", questionFortyOne, false);
answerRepository.save(q41AnswerFour);
Question questionFortyTwo = new Question("The body of the Egyptian Sphinx was based on which animal?", Difficulty.TWO);
questionRepository.save(questionFortyTwo);
Answer q42AnswerOne = new Answer("Lion", questionFortyTwo, true);
answerRepository.save(q42AnswerOne);
Answer q42AnswerTwo = new Answer("Bull", questionFortyTwo, false);
answerRepository.save(q42AnswerTwo);
Answer q42AnswerThree = new Answer("Horse", questionFortyTwo, false);
answerRepository.save(q42AnswerThree);
Answer q42AnswerFour = new Answer("Dog", questionFortyTwo, false);
answerRepository.save(q42AnswerFour);
Question questionFortyThree = new Question("Ringo Starr of The Beatles mainly played what instrument?", Difficulty.TWO);
questionRepository.save(questionFortyThree);
Answer q43AnswerOne = new Answer("Drums", questionFortyThree, true);
answerRepository.save(q43AnswerOne);
Answer q43AnswerTwo = new Answer("Bass", questionFortyThree, false);
answerRepository.save(q43AnswerTwo);
Answer q43AnswerThree = new Answer("Guitar", questionFortyThree, false);
answerRepository.save(q43AnswerThree);
Answer q43AnswerFour = new Answer("Piano", questionFortyThree, false);
answerRepository.save(q43AnswerFour);
Question questionFortyFour = new Question("Which singer was featured in Jack-U (Skrillex & Diplo)'s 2015 song 'Where Are U Now'?", Difficulty.TWO);
questionRepository.save(questionFortyFour);
Answer q44AnswerOne = new Answer("Justin Bieber", questionFortyFour, true);
answerRepository.save(q44AnswerOne);
Answer q44AnswerTwo = new Answer("Selena Gomez", questionFortyFour, false);
answerRepository.save(q44AnswerTwo);
Answer q44AnswerThree = new Answer("Ellie Goulding", questionFortyFour, false);
answerRepository.save(q44AnswerThree);
Answer q44AnswerFour = new Answer("The Weeknd", questionFortyFour, false);
answerRepository.save(q44AnswerFour);
Question questionFortyFive = new Question("Which movie contains the quote, 'Say hello to my little friend!'?", Difficulty.TWO);
questionRepository.save(questionFortyFive);
Answer q45AnswerOne = new Answer("Scarface", questionFortyFive, true);
answerRepository.save(q45AnswerOne);
Answer q45AnswerTwo = new Answer("Reservoir Dogs", questionFortyFive, false);
answerRepository.save(q45AnswerTwo);
Answer q45AnswerThree = new Answer("Heat", questionFortyFive, false);
answerRepository.save(q45AnswerThree);
Answer q45AnswerFour = new Answer("Goodfellas", questionFortyFive, false);
answerRepository.save(q45AnswerFour);
Question questionFortySix = new Question("Which movie contains the quote, 'Houston, we have a problem'?", Difficulty.TWO);
questionRepository.save(questionFortySix);
Answer q46AnswerOne = new Answer("Apollo 13", questionFortySix, true);
answerRepository.save(q46AnswerOne);
Answer q46AnswerTwo = new Answer("The Right Stuff", questionFortySix, false);
answerRepository.save(q46AnswerTwo);
Answer q46AnswerThree = new Answer("Capricorn One", questionFortySix, false);
answerRepository.save(q46AnswerThree);
Answer q46AnswerFour = new Answer("Marooned", questionFortySix, false);
answerRepository.save(q46AnswerFour);
Question questionFortySeven = new Question("What is the official language of Costa Rica?", Difficulty.TWO);
questionRepository.save(questionFortySeven);
Answer q47AnswerOne = new Answer("Spanish", questionFortySeven, true);
answerRepository.save(q47AnswerOne);
Answer q47AnswerTwo = new Answer("English", questionFortySeven, false);
answerRepository.save(q47AnswerTwo);
Answer q47AnswerThree = new Answer("Portuguese", questionFortySeven, false);
answerRepository.save(q47AnswerThree);
Answer q47AnswerFour = new Answer("Creole", questionFortySeven, false);
answerRepository.save(q47AnswerFour);
Question questionFortyEight = new Question("'Hallelujah' is a song written by which Canadian recording artist?", Difficulty.TWO);
questionRepository.save(questionFortyEight);
Answer q48AnswerOne = new Answer("Leonard Cohen", questionFortyEight, true);
answerRepository.save(q48AnswerOne);
Answer q48AnswerTwo = new Answer("Kory Lefkowits", questionFortyEight, false);
answerRepository.save(q48AnswerTwo);
Answer q48AnswerThree = new Answer("Ryan Letourneau", questionFortyEight, false);
answerRepository.save(q48AnswerThree);
Answer q48AnswerFour = new Answer("Justin Bieber", questionFortyEight, false);
answerRepository.save(q48AnswerFour);
Question questionFortyNine = new Question("What is the shape of the toy invented by Hungarian professor Ernő Rubik?", Difficulty.TWO);
questionRepository.save(questionFortyNine);
Answer q49AnswerOne = new Answer("Cube", questionFortyNine, true);
answerRepository.save(q49AnswerOne);
Answer q49AnswerTwo = new Answer("Sphere", questionFortyNine, false);
answerRepository.save(q49AnswerTwo);
Answer q49AnswerThree = new Answer("Cylinder", questionFortyNine, false);
answerRepository.save(q49AnswerThree);
Answer q49AnswerFour = new Answer("Pyramid", questionFortyNine, false);
answerRepository.save(q49AnswerFour);
Question questionFifty = new Question("If you were to code software in this language you'd only be able to type 0's and 1's.", Difficulty.TWO);
questionRepository.save(questionFifty);
Answer q50AnswerOne = new Answer("Binary", questionFifty, true);
answerRepository.save(q50AnswerOne);
Answer q50AnswerTwo = new Answer("JavaScript", questionFifty, false);
answerRepository.save(q50AnswerTwo);
Answer q50AnswerThree = new Answer("C++", questionFifty, false);
answerRepository.save(q50AnswerThree);
Answer q50AnswerFour = new Answer("Python", questionFifty, false);
answerRepository.save(q50AnswerFour);
Question questionFiftyOne = new Question("Which artist released the 2012 single 'Harlem Shake', which was used in numerous YouTube videos in 2013?", Difficulty.TWO);
questionRepository.save(questionFiftyOne);
Answer q51AnswerOne = new Answer("Baauer", questionFiftyOne, true);
answerRepository.save(q51AnswerOne);
Answer q51AnswerTwo = new Answer("RL Grime", questionFiftyOne, false);
answerRepository.save(q51AnswerTwo);
Answer q51AnswerThree = new Answer("NGHTMRE", questionFiftyOne, false);
answerRepository.save(q51AnswerThree);
Answer q51AnswerFour = new Answer("Flosstradamus", questionFiftyOne, false);
answerRepository.save(q51AnswerFour);
Question questionFiftyTwo = new Question("In the Pixar film, 'Toy Story', what was the name of the child who owned the toys?", Difficulty.TWO);
questionRepository.save(questionFiftyTwo);
Answer q52AnswerOne = new Answer("Andy", questionFiftyTwo, true);
answerRepository.save(q52AnswerOne);
Answer q52AnswerTwo = new Answer("Edward", questionFiftyTwo, false);
answerRepository.save(q52AnswerTwo);
Answer q52AnswerThree = new Answer("Danny", questionFiftyTwo, false);
answerRepository.save(q52AnswerThree);
Answer q52AnswerFour = new Answer("Matt", questionFiftyTwo, false);
answerRepository.save(q52AnswerFour);
Question questionFiftyThree = new Question("Which Nirvana album had a naked baby on the cover?", Difficulty.TWO);
questionRepository.save(questionFiftyThree);
Answer q53AnswerOne = new Answer("Nevermind", questionFiftyThree, true);
answerRepository.save(q53AnswerOne);
Answer q53AnswerTwo = new Answer("Bleach", questionFiftyThree, false);
answerRepository.save(q53AnswerTwo);
Answer q53AnswerThree = new Answer("In Utero", questionFiftyThree, false);
answerRepository.save(q53AnswerThree);
Answer q53AnswerFour = new Answer("Incesticide", questionFiftyThree, false);
answerRepository.save(q53AnswerFour);
Question questionFiftyFour = new Question("According to Sherlock Holmes, 'If you eliminate the impossible, whatever remains, however improbable, must be the...'", Difficulty.TWO);
questionRepository.save(questionFiftyFour);
Answer q54AnswerOne = new Answer("Truth", questionFiftyFour, true);
answerRepository.save(q54AnswerOne);
Answer q54AnswerTwo = new Answer("Answer", questionFiftyFour, false);
answerRepository.save(q54AnswerTwo);
Answer q54AnswerThree = new Answer("Cause", questionFiftyFour, false);
answerRepository.save(q54AnswerThree);
Answer q54AnswerFour = new Answer("Source", questionFiftyFour, false);
answerRepository.save(q54AnswerFour);
Question questionFiftyFive = new Question("In the movie 'Blade Runner', what is the term used for human-like androids ?", Difficulty.TWO);
questionRepository.save(questionFiftyFive);
Answer q55AnswerOne = new Answer("Replicants", questionFiftyFive, true);
answerRepository.save(q55AnswerOne);
Answer q55AnswerTwo = new Answer("Cylons", questionFiftyFive, false);
answerRepository.save(q55AnswerTwo);
Answer q55AnswerThree = new Answer("Synthetics", questionFiftyFive, false);
answerRepository.save(q55AnswerThree);
Answer q55AnswerFour = new Answer("Skinjobs", questionFiftyFive, false);
answerRepository.save(q55AnswerFour);
Question questionFiftySix = new Question("What is the official name of the star located closest to the North Celestial Pole?", Difficulty.TWO);
questionRepository.save(questionFiftySix);
Answer q56AnswerOne = new Answer("Polaris", questionFiftySix, true);
answerRepository.save(q56AnswerOne);
Answer q56AnswerTwo = new Answer("Eridanus", questionFiftySix, false);
answerRepository.save(q56AnswerTwo);
Answer q56AnswerThree = new Answer("Gamma Cephei", questionFiftySix, false);
answerRepository.save(q56AnswerThree);
Answer q56AnswerFour = new Answer("Iota Cephei", questionFiftySix, false);
answerRepository.save(q56AnswerFour);
Question questionFiftySeven = new Question("Who created the digital distribution platform Steam?", Difficulty.TWO);
questionRepository.save(questionFiftySeven);
Answer q57AnswerOne = new Answer("Valve", questionFiftySeven, true);
answerRepository.save(q57AnswerOne);
Answer q57AnswerTwo = new Answer("Pixeltail Games", questionFiftySeven, false);
answerRepository.save(q57AnswerTwo);
Answer q57AnswerThree = new Answer("Ubisoft", questionFiftySeven, false);
answerRepository.save(q57AnswerThree);
Answer q57AnswerFour = new Answer("Electronic Arts", questionFiftySeven, false);
answerRepository.save(q57AnswerFour);
Question questionFiftyEight = new Question("Who directed the movies 'Pulp Fiction', 'Reservoir Dogs'; and 'Django Unchained'?", Difficulty.TWO);
questionRepository.save(questionFiftyEight);
Answer q58AnswerOne = new Answer("Quentin Tarantino", questionFiftyEight, true);
answerRepository.save(q58AnswerOne);
Answer q58AnswerTwo = new Answer("Martin Scorcese", questionFiftyEight, false);
answerRepository.save(q58AnswerTwo);
Answer q58AnswerThree = new Answer("Steven Spielberg", questionFiftyEight, false);
answerRepository.save(q58AnswerThree);
Answer q58AnswerFour = new Answer("James Cameron", questionFiftyEight, false);
answerRepository.save(q58AnswerFour);
Question questionFiftyNine = new Question("Who is the frontman of the band 30 Seconds to Mars?", Difficulty.TWO);
questionRepository.save(questionFiftyNine);
Answer q59AnswerOne = new Answer("Jared Leto", questionFiftyNine, true);
answerRepository.save(q59AnswerOne);
Answer q59AnswerTwo = new Answer("Gerard Way", questionFiftyNine, false);
answerRepository.save(q59AnswerTwo);
Answer q59AnswerThree = new Answer("Matthew Bellamy", questionFiftyNine, false);
answerRepository.save(q59AnswerThree);
Answer q59AnswerFour = new Answer("Mike Shinoda", questionFiftyNine, false);
answerRepository.save(q59AnswerFour);
Question questionSixty = new Question("How many members are there in the band Nirvana?", Difficulty.TWO);
questionRepository.save(questionSixty);
Answer q60AnswerOne = new Answer("Three", questionSixty, true);
answerRepository.save(q60AnswerOne);
Answer q60AnswerTwo = new Answer("Two", questionSixty, false);
answerRepository.save(q60AnswerTwo);
Answer q60AnswerThree = new Answer("Four", questionSixty, false);
answerRepository.save(q60AnswerThree);
Answer q60AnswerFour = new Answer("Five", questionSixty, false);
answerRepository.save(q60AnswerFour);
Question questionSixtyOne = new Question("Which American president appears on a one dollar bill?", Difficulty.THREE);
questionRepository.save(questionSixtyOne);
Answer q61AnswerOne = new Answer("George Washington", questionSixtyOne, true);
answerRepository.save(q61AnswerOne);
Answer q61AnswerTwo = new Answer("Thomas Jefferson", questionSixtyOne, false);
answerRepository.save(q61AnswerTwo);
Answer q61AnswerThree = new Answer("Abraham Lincoln", questionSixtyOne, false);
answerRepository.save(q61AnswerThree);
Answer q61AnswerFour = new Answer("Benjamin Franklin", questionSixtyOne, false);
answerRepository.save(q61AnswerFour);
Question questionSixtyTwo = new Question("Human cells typically have how many copies of each gene?", Difficulty.THREE);
questionRepository.save(questionSixtyTwo);
Answer q62AnswerOne = new Answer("2", questionSixtyTwo, true);
answerRepository.save(q62AnswerOne);
Answer q62AnswerTwo = new Answer("1", questionSixtyTwo, false);
answerRepository.save(q62AnswerTwo);
Answer q62AnswerThree = new Answer("4", questionSixtyTwo, false);
answerRepository.save(q62AnswerThree);
Answer q62AnswerFour = new Answer("3", questionSixtyTwo, false);
answerRepository.save(q62AnswerFour);
Question questionSixtyThree = new Question("What are the cylinder-like parts that pump up and down within the engine?", Difficulty.THREE);
questionRepository.save(questionSixtyThree);
Answer q63AnswerOne = new Answer("Pistons", questionSixtyThree, true);
answerRepository.save(q63AnswerOne);
Answer q63AnswerTwo = new Answer("Leaf Springs", questionSixtyThree, false);
answerRepository.save(q63AnswerTwo);
Answer q63AnswerThree = new Answer("Radiators", questionSixtyThree, false);
answerRepository.save(q63AnswerThree);
Answer q63AnswerFour = new Answer("ABS", questionSixtyThree, false);
answerRepository.save(q63AnswerFour);
Question questionSixtyFour = new Question("Which track by 'Massive Attack' is used for the theme of 'House'? ", Difficulty.THREE);
questionRepository.save(questionSixtyFour);
Answer q64AnswerOne = new Answer("Teardrop", questionSixtyFour, true);
answerRepository.save(q64AnswerOne);
Answer q64AnswerTwo = new Answer("Protection", questionSixtyFour, false);
answerRepository.save(q64AnswerTwo);
Answer q64AnswerThree = new Answer("Angel", questionSixtyFour, false);
answerRepository.save(q64AnswerThree);
Answer q64AnswerFour = new Answer("Black Milk", questionSixtyFour, false);
answerRepository.save(q64AnswerFour);
Question questionSixtyFive = new Question("What is the capital of Indonesia?", Difficulty.THREE);
questionRepository.save(questionSixtyFive);
Answer q65AnswerOne = new Answer("Jakarta", questionSixtyFive, true);
answerRepository.save(q65AnswerOne);
Answer q65AnswerTwo = new Answer("Bandung", questionSixtyFive, false);
answerRepository.save(q65AnswerTwo);
Answer q65AnswerThree = new Answer("Palembang", questionSixtyFive, false);
answerRepository.save(q65AnswerThree);
Answer q65AnswerFour = new Answer("Medan", questionSixtyFive, false);
answerRepository.save(q65AnswerFour);
Question questionSixtySix = new Question("During WWII, in 1945, the United States dropped atomic bombs on the two Japanese cities of Hiroshima and what other city?", Difficulty.THREE);
questionRepository.save(questionSixtySix);
Answer q66AnswerOne = new Answer("Nagasaki", questionSixtySix, true);
answerRepository.save(q66AnswerOne);
Answer q66AnswerTwo = new Answer("Tokyo", questionSixtySix, false);
answerRepository.save(q66AnswerTwo);
Answer q66AnswerThree = new Answer("Fukuoka", questionSixtySix, false);
answerRepository.save(q66AnswerThree);
Answer q66AnswerFour = new Answer("Nagoya", questionSixtySix, false);
answerRepository.save(q66AnswerFour);
Question questionSixtySeven = new Question("Who wrote the novel 'Fear And Loathing In Las Vegas'?", Difficulty.THREE);
questionRepository.save(questionSixtySeven);
Answer q67AnswerOne = new Answer("Hunter S. Thompson", questionSixtySeven, true);
answerRepository.save(q67AnswerOne);
Answer q67AnswerTwo = new Answer("F. Scott Fitzgerald", questionSixtySeven, false);
answerRepository.save(q67AnswerTwo);
Answer q67AnswerThree = new Answer("Henry Miller", questionSixtySeven, false);
answerRepository.save(q67AnswerThree);
Answer q67AnswerFour = new Answer("William S. Burroughs", questionSixtySeven, false);
answerRepository.save(q67AnswerFour);
Question questionSixtyEight = new Question("Which of these video game engines was made by the company Epic Games?", Difficulty.THREE);
questionRepository.save(questionSixtyEight);
Answer q68AnswerOne = new Answer("Unreal", questionSixtyEight, true);
answerRepository.save(q68AnswerOne);
Answer q68AnswerTwo = new Answer("Unity", questionSixtyEight, false);
answerRepository.save(q68AnswerTwo);
Answer q68AnswerThree = new Answer("Game Maker: Studio", questionSixtyEight, false);
answerRepository.save(q68AnswerThree);
Answer q68AnswerFour = new Answer("Cry Engine", questionSixtyEight, false);
answerRepository.save(q68AnswerFour);
Question questionSixtyNine = new Question("Finish these lyrics from the 2016 song 'Panda' by Desiigner: 'I got broads in....'", Difficulty.THREE);
questionRepository.save(questionSixtyNine);
Answer q69AnswerOne = new Answer("Atlanta", questionSixtyNine, true);
answerRepository.save(q69AnswerOne);
Answer q69AnswerTwo = new Answer("Savannah", questionSixtyNine, false);
answerRepository.save(q69AnswerTwo);
Answer q69AnswerThree = new Answer("Augusta", questionSixtyNine, false);
answerRepository.save(q69AnswerThree);
Answer q69AnswerFour = new Answer("Marietta", questionSixtyNine, false);
answerRepository.save(q69AnswerFour);
Question questionSeventy = new Question("In web design, what does CSS stand for?", Difficulty.THREE);
questionRepository.save(questionSeventy);
Answer q70AnswerOne = new Answer("Cascading Style Sheet", questionSeventy, true);
answerRepository.save(q70AnswerOne);
Answer q70AnswerTwo = new Answer("Complementary Style Sheet", questionSeventy, false);
answerRepository.save(q70AnswerTwo);
Answer q70AnswerThree = new Answer("Corrective Style Sheet", questionSeventy, false);
answerRepository.save(q70AnswerThree);
Answer q70AnswerFour = new Answer("Computer Style Sheet", questionSeventy, false);
answerRepository.save(q70AnswerFour);
Question questionSeventyOne = new Question("How many colors are there in a rainbow?", Difficulty.THREE);
questionRepository.save(questionSeventyOne);
Answer q71AnswerOne = new Answer("7", questionSeventyOne, true);
answerRepository.save(q71AnswerOne);
Answer q71AnswerTwo = new Answer("8", questionSeventyOne, false);
answerRepository.save(q71AnswerTwo);
Answer q71AnswerThree = new Answer("6", questionSeventyOne, false);
answerRepository.save(q71AnswerThree);
Answer q71AnswerFour = new Answer("9", questionSeventyOne, false);
answerRepository.save(q71AnswerFour);
Question questionSeventyTwo = new Question("Which movie includes a giant bunny-like spirit who has magic powers including growing trees?", Difficulty.THREE);
questionRepository.save(questionSeventyTwo);
Answer q72AnswerOne = new Answer("My Neighbor Totoro", questionSeventyTwo, true);
answerRepository.save(q72AnswerOne);
Answer q72AnswerTwo = new Answer("Hop", questionSeventyTwo, false);
answerRepository.save(q72AnswerTwo);
Answer q72AnswerThree = new Answer("Rise of the Guardians", questionSeventyTwo, false);
answerRepository.save(q72AnswerThree);
Answer q72AnswerFour = new Answer("Alice in Wonderland", questionSeventyTwo, false);
answerRepository.save(q72AnswerFour);
Question questionSeventyThree = new Question("How many faces does a dodecahedron have?", Difficulty.THREE);
questionRepository.save(questionSeventyThree);
Answer q73AnswerOne = new Answer("12", questionSeventyThree, true);
answerRepository.save(q73AnswerOne);
Answer q73AnswerTwo = new Answer("10", questionSeventyThree, false);
answerRepository.save(q73AnswerTwo);
Answer q73AnswerThree = new Answer("14", questionSeventyThree, false);
answerRepository.save(q73AnswerThree);
Answer q73AnswerFour = new Answer("8", questionSeventyThree, false);
answerRepository.save(q73AnswerFour);
Question questionSeventyFour = new Question("What do you call a baby bat?", Difficulty.THREE);
questionRepository.save(questionSeventyFour);
Answer q74AnswerOne = new Answer("Pup", questionSeventyFour, true);
answerRepository.save(q74AnswerOne);
Answer q74AnswerTwo = new Answer("Cub", questionSeventyFour, false);
answerRepository.save(q74AnswerTwo);
Answer q74AnswerThree = new Answer("Chick", questionSeventyFour, false);
answerRepository.save(q74AnswerThree);
Answer q74AnswerFour = new Answer("Kid", questionSeventyFour, false);
answerRepository.save(q74AnswerFour);
Question questionSeventyFive = new Question("In the show Stranger Things, what is Eleven's favorite breakfast food?", Difficulty.THREE);
questionRepository.save(questionSeventyFive);
Answer q75AnswerOne = new Answer("Eggo Waffles", questionSeventyFive, true);
answerRepository.save(q75AnswerOne);
Answer q75AnswerTwo = new Answer("Toast", questionSeventyFive, false);
answerRepository.save(q75AnswerTwo);
Answer q75AnswerThree = new Answer("Captain Crunch", questionSeventyFive, false);
answerRepository.save(q75AnswerThree);
Answer q75AnswerFour = new Answer("Bacon and Eggs", questionSeventyFive, false);
answerRepository.save(q75AnswerFour);
Question questionSeventySix = new Question("Which of these African countries list Spanish as an official language?", Difficulty.THREE);
questionRepository.save(questionSeventySix);
Answer q76AnswerOne = new Answer("Equatorial Guinea", questionSeventySix, true);
answerRepository.save(q76AnswerOne);
Answer q76AnswerTwo = new Answer("Guinea", questionSeventySix, false);
answerRepository.save(q76AnswerTwo);
Answer q76AnswerThree = new Answer("Cameroon", questionSeventySix, false);
answerRepository.save(q76AnswerThree);
Answer q76AnswerFour = new Answer("Angola", questionSeventySix, false);
answerRepository.save(q76AnswerFour);
Question questionSeventySeven = new Question("Which buzzword did Apple Inc. use to describe their removal of the headphone jack?", Difficulty.THREE);
questionRepository.save(questionSeventySeven);
Answer q77AnswerOne = new Answer("Courage", questionSeventySeven, true);
answerRepository.save(q77AnswerOne);
Answer q77AnswerTwo = new Answer("Innovation", questionSeventySeven, false);
answerRepository.save(q77AnswerTwo);
Answer q77AnswerThree = new Answer("Revolution", questionSeventySeven, false);
answerRepository.save(q77AnswerThree);
Answer q77AnswerFour = new Answer("Bravery", questionSeventySeven, false);
answerRepository.save(q77AnswerFour);
Question questionSeventyEight = new Question("Which one of these is not a real game in the Dungeons & Dragons series?", Difficulty.THREE);
questionRepository.save(questionSeventyEight);
Answer q78AnswerOne = new Answer("Extreme Dungeons & Dragons", questionSeventyEight, true);
answerRepository.save(q78AnswerOne);
Answer q78AnswerTwo = new Answer("Advanced Dungeons & Dragons", questionSeventyEight, false);
answerRepository.save(q78AnswerTwo);
Answer q78AnswerThree = new Answer("Dungeons & Dragons 3.5th edition", questionSeventyEight, false);
answerRepository.save(q78AnswerThree);
Answer q78AnswerFour = new Answer("Advanced Dungeons & Dragons 2nd edition", questionSeventyEight, false);
answerRepository.save(q78AnswerFour);
Question questionSeventyNine = new Question("What was the name of the the first episode of Doctor Who to air in 1963?", Difficulty.THREE);
questionRepository.save(questionSeventyNine);
Answer q79AnswerOne = new Answer("An Unearthly Child", questionSeventyNine, true);
answerRepository.save(q79AnswerOne);
Answer q79AnswerTwo = new Answer("The Daleks", questionSeventyNine, false);
answerRepository.save(q79AnswerTwo);
Answer q79AnswerThree = new Answer("The Aztecs", questionSeventyNine, false);
answerRepository.save(q79AnswerThree);
Answer q79AnswerFour = new Answer("The Edge of Destruction", questionSeventyNine, false);
answerRepository.save(q79AnswerFour);
Question questionEighty = new Question("On what street did the 1666 Great Fire of London start?", Difficulty.THREE);
questionRepository.save(questionEighty);
Answer q80AnswerOne = new Answer("Pudding Lane", questionEighty, true);
answerRepository.save(q80AnswerOne);
Answer q80AnswerTwo = new Answer("Baker Street", questionEighty, false);
answerRepository.save(q80AnswerTwo);
Answer q80AnswerThree = new Answer("Bread Lane", questionEighty, false);
answerRepository.save(q80AnswerThree);
Answer q80AnswerFour = new Answer("Baker Avenue", questionEighty, false);
answerRepository.save(q80AnswerFour);
Question questionEightyOne = new Question("What year did the television company BBC officially launch the channel BBC One?", Difficulty.FOUR);
questionRepository.save(questionEightyOne);
Answer q81AnswerOne = new Answer("1936", questionEightyOne, true);
answerRepository.save(q81AnswerOne);
Answer q81AnswerTwo = new Answer("1948", questionEightyOne, false);
answerRepository.save(q81AnswerTwo);
Answer q81AnswerThree = new Answer("1932", questionEightyOne, false);
answerRepository.save(q81AnswerThree);
Answer q81AnswerFour = new Answer("1955", questionEightyOne, false);
answerRepository.save(q81AnswerFour);
Question questionEightyTwo = new Question("The 'Tibia' is found in which part of the body?", Difficulty.FOUR);
questionRepository.save(questionEightyTwo);
Answer q82AnswerOne = new Answer("Leg", questionEightyTwo, true);
answerRepository.save(q82AnswerOne);
Answer q82AnswerTwo = new Answer("Arm", questionEightyTwo, false);
answerRepository.save(q82AnswerTwo);
Answer q82AnswerThree = new Answer("Hand", questionEightyTwo, false);
answerRepository.save(q82AnswerThree);
Answer q82AnswerFour = new Answer("Head", questionEightyTwo, false);
answerRepository.save(q82AnswerFour);
Question questionEightyThree = new Question("Which part of the body does glaucoma affect?", Difficulty.FOUR);
questionRepository.save(questionEightyThree);
Answer q83AnswerOne = new Answer("Eyes", questionEightyThree, true);
answerRepository.save(q83AnswerOne);
Answer q83AnswerTwo = new Answer("Throat", questionEightyThree, false);
answerRepository.save(q83AnswerTwo);
Answer q83AnswerThree = new Answer("Stomach", questionEightyThree, false);
answerRepository.save(q83AnswerThree);
Answer q83AnswerFour = new Answer("Blood", questionEightyThree, false);
answerRepository.save(q83AnswerFour);
Question questionEightyFour = new Question("What was the name of Ross's pet monkey on 'Friends'", Difficulty.FOUR);
questionRepository.save(questionEightyFour);
Answer q84AnswerOne = new Answer("Marcel", questionEightyFour, true);
answerRepository.save(q84AnswerOne);
Answer q84AnswerTwo = new Answer("Jojo", questionEightyFour, false);
answerRepository.save(q84AnswerTwo);
Answer q84AnswerThree = new Answer("George", questionEightyFour, false);
answerRepository.save(q84AnswerThree);
Answer q84AnswerFour = new Answer("Champ", questionEightyFour, false);
answerRepository.save(q84AnswerFour);
Question questionEightyFive = new Question("The novel 'Of Mice And Men' was written by what author?", Difficulty.FOUR);
questionRepository.save(questionEightyFive);
Answer q85AnswerOne = new Answer("John Steinbeck", questionEightyFive, true);
answerRepository.save(q85AnswerOne);
Answer q85AnswerTwo = new Answer("George Orwell", questionEightyFive, false);
answerRepository.save(q85AnswerTwo);
Answer q85AnswerThree = new Answer("Mark Twain", questionEightyFive, false);
answerRepository.save(q85AnswerThree);
Answer q85AnswerFour = new Answer("Harper Lee", questionEightyFive, false);
answerRepository.save(q85AnswerFour);
Question questionEightySix = new Question("Which of these is NOT a name of an album released by American rapper Pitbull?", Difficulty.FOUR);
questionRepository.save(questionEightySix);
Answer q86AnswerOne = new Answer("Welcome to Miami", questionEightySix, true);
answerRepository.save(q86AnswerOne);
Answer q86AnswerTwo = new Answer("Dale", questionEightySix, false);
answerRepository.save(q86AnswerTwo);
Answer q86AnswerThree = new Answer("Global Warming", questionEightySix, false);
answerRepository.save(q86AnswerThree);
Answer q86AnswerFour = new Answer("Armando", questionEightySix, false);
answerRepository.save(q86AnswerFour);
Question questionEightySeven = new Question("What is the designation given to the Marvel Cinematic Universe?", Difficulty.FOUR);
questionRepository.save(questionEightySeven);
Answer q87AnswerOne = new Answer("Earth-199999", questionEightySeven, true);
answerRepository.save(q87AnswerOne);
Answer q87AnswerTwo = new Answer("Earth-616", questionEightySeven, false);
answerRepository.save(q87AnswerTwo);
Answer q87AnswerThree = new Answer("Earth-10005", questionEightySeven, false);
answerRepository.save(q87AnswerThree);
Answer q87AnswerFour = new Answer("Earth-2008", questionEightySeven, false);
answerRepository.save(q87AnswerFour);
Question questionEightyEight = new Question("Where did the pineapple plant originate?", Difficulty.FOUR);
questionRepository.save(questionEightyEight);
Answer q88AnswerOne = new Answer("South America", questionEightyEight, true);
answerRepository.save(q88AnswerOne);
Answer q88AnswerTwo = new Answer("Hawaii", questionEightyEight, false);
answerRepository.save(q88AnswerTwo);
Answer q88AnswerThree = new Answer("Europe", questionEightyEight, false);
answerRepository.save(q88AnswerThree);
Answer q88AnswerFour = new Answer("Asia", questionEightyEight, false);
answerRepository.save(q88AnswerFour);
Question questionEightyNine = new Question("At which bridge does the annual Oxford and Cambridge boat race start?", Difficulty.FOUR);
questionRepository.save(questionEightyNine);
Answer q89AnswerOne = new Answer("Putney", questionEightyNine, true);
answerRepository.save(q89AnswerOne);
Answer q89AnswerTwo = new Answer("Hammersmith", questionEightyNine, false);
answerRepository.save(q89AnswerTwo);
Answer q89AnswerThree = new Answer("Vauxhall", questionEightyNine, false);
answerRepository.save(q89AnswerThree);
Answer q89AnswerFour = new Answer("Battersea", questionEightyNine, false);
answerRepository.save(q89AnswerFour);
Question questionNinety = new Question("One of the deadliest pandemics, the 'Spanish Flu', killed off what percentage of the human world population at the time?", Difficulty.FOUR);
questionRepository.save(questionNinety);
Answer q90AnswerOne = new Answer("3 to 6 percent", questionNinety, true);
answerRepository.save(q90AnswerOne);
Answer q90AnswerTwo = new Answer("6 to 10 percent", questionNinety, false);
answerRepository.save(q90AnswerTwo);
Answer q90AnswerThree = new Answer("1 to 3 percent", questionNinety, false);
answerRepository.save(q90AnswerThree);
Answer q90AnswerFour = new Answer("less than 1 percent", questionNinety, false);
answerRepository.save(q90AnswerFour);
Question questionNinetyOne = new Question("On average, Americans consume 100 pounds of what per second?", Difficulty.FOUR);
questionRepository.save(questionNinetyOne);
Answer q91AnswerOne = new Answer("Chocolate", questionNinetyOne, true);
answerRepository.save(q91AnswerOne);
Answer q91AnswerTwo = new Answer("Potatoes", questionNinetyOne, false);
answerRepository.save(q91AnswerTwo);
Answer q91AnswerThree = new Answer("Donuts", questionNinetyOne, false);
answerRepository.save(q91AnswerThree);
Answer q91AnswerFour = new Answer("Cocaine", questionNinetyOne, false);
answerRepository.save(q91AnswerFour);
Question questionNinetyTwo = new Question("The now extinct species 'Thylacine' was native to where?", Difficulty.FOUR);
questionRepository.save(questionNinetyTwo);
Answer q92AnswerOne = new Answer("Tasmania, Australia", questionNinetyTwo, true);
answerRepository.save(q92AnswerOne);
Answer q92AnswerTwo = new Answer("Baluchistan, Pakistan", questionNinetyTwo, false);
answerRepository.save(q92AnswerTwo);
Answer q92AnswerThree = new Answer("Wallachia, Romania", questionNinetyTwo, false);
answerRepository.save(q92AnswerThree);
Answer q92AnswerFour = new Answer("Oregon, United States", questionNinetyTwo, false);
answerRepository.save(q92AnswerFour);
Question questionNinetyThree = new Question("What was the first PlayStation game to require the use of the DualShock controller?", Difficulty.FOUR);
questionRepository.save(questionNinetyThree);
Answer q93AnswerOne = new Answer("Ape Escape", questionNinetyThree, true);
answerRepository.save(q93AnswerOne);
Answer q93AnswerTwo = new Answer("Metal Gear", questionNinetyThree, false);
answerRepository.save(q93AnswerTwo);
Answer q93AnswerThree = new Answer("Tekken", questionNinetyThree, false);
answerRepository.save(q93AnswerThree);
Answer q93AnswerFour = new Answer("Tomba 2!", questionNinetyThree, false);
answerRepository.save(q93AnswerFour);
Question questionNinetyFour = new Question("Myopia is the scientific term for which condition?", Difficulty.FOUR);
questionRepository.save(questionNinetyFour);
Answer q94AnswerOne = new Answer("Shortsightedness", questionNinetyFour, true);
answerRepository.save(q94AnswerOne);
Answer q94AnswerTwo = new Answer("Farsightedness", questionNinetyFour, false);
answerRepository.save(q94AnswerTwo);
Answer q94AnswerThree = new Answer("Double Vision", questionNinetyFour, false);
answerRepository.save(q94AnswerThree);
Answer q94AnswerFour = new Answer("Clouded Vision", questionNinetyFour, false);
answerRepository.save(q94AnswerFour);
Question questionNinetyFive = new Question("Which of the following was not developed by Bethesda?", Difficulty.FOUR);
questionRepository.save(questionNinetyFive);
Answer q95AnswerOne = new Answer("Fallout: New Vegas", questionNinetyFive, true);
answerRepository.save(q95AnswerOne);
Answer q95AnswerTwo = new Answer("Fallout 3", questionNinetyFive, false);
answerRepository.save(q95AnswerTwo);
Answer q95AnswerThree = new Answer("The Elder Scrolls V: Skyrim", questionNinetyFive, false);
answerRepository.save(q95AnswerThree);
Answer q95AnswerFour = new Answer("Fallout 4", questionNinetyFive, false);
answerRepository.save(q95AnswerFour);
Question questionNinetySix = new Question("Which new top 100 rapper, who featured in 'Computers' and 'Body Dance', was arrested in a NYPD sting for murder.", Difficulty.FOUR);
questionRepository.save(questionNinetySix);
Answer q96AnswerOne = new Answer("Bobby Shmurda", questionNinetySix, true);
answerRepository.save(q96AnswerOne);
Answer q96AnswerTwo = new Answer("DJ Snake", questionNinetySix, false);
answerRepository.save(q96AnswerTwo);
Answer q96AnswerThree = new Answer("Swae Lee", questionNinetySix, false);
answerRepository.save(q96AnswerThree);
Answer q96AnswerFour = new Answer("Young Thug", questionNinetySix, false);
answerRepository.save(q96AnswerFour);
Question questionNinetySeven = new Question("Which greek mathematician ran through the streets of Syracuse naked while shouting 'Eureka' after discovering the principle of displacement?", Difficulty.FOUR);
questionRepository.save(questionNinetySeven);
Answer q97AnswerOne = new Answer("Archimedes", questionNinetySeven, true);
answerRepository.save(q97AnswerOne);
Answer q97AnswerTwo = new Answer("Euclid", questionNinetySeven, false);
answerRepository.save(q97AnswerTwo);
Answer q97AnswerThree = new Answer("Homer", questionNinetySeven, false);
answerRepository.save(q97AnswerThree);
Answer q97AnswerFour = new Answer("Eratosthenes", questionNinetySeven, false);
answerRepository.save(q97AnswerFour);
Question questionNinetyEight = new Question("What was the African nation of Zimbabwe formerly known as?", Difficulty.FOUR);
questionRepository.save(questionNinetyEight);
Answer q98AnswerOne = new Answer("Rhodesia", questionNinetyEight, true);
answerRepository.save(q98AnswerOne);
Answer q98AnswerTwo = new Answer("Zambia", questionNinetyEight, false);
answerRepository.save(q98AnswerTwo);
Answer q98AnswerThree = new Answer("Mozambique", questionNinetyEight, false);
answerRepository.save(q98AnswerThree);
Answer q98AnswerFour = new Answer("Bulawayo", questionNinetyEight, false);
answerRepository.save(q98AnswerFour);
Question questionNinetyNine = new Question("According to the BBPA, what is the most common pub name in the UK?", Difficulty.FOUR);
questionRepository.save(questionNinetyNine);
Answer q99AnswerOne = new Answer("Red Lion", questionNinetyNine, true);
answerRepository.save(q99AnswerOne);
Answer q99AnswerTwo = new Answer("Royal Oak", questionNinetyNine, false);
answerRepository.save(q99AnswerTwo);
Answer q99AnswerThree = new Answer("White Hart", questionNinetyNine, false);
answerRepository.save(q99AnswerThree);
Answer q99AnswerFour = new Answer("King's Head", questionNinetyNine, false);
answerRepository.save(q99AnswerFour);
Question questionOneHundred = new Question("What is the capital of Peru?", Difficulty.FOUR);
questionRepository.save(questionOneHundred);
Answer q100AnswerOne = new Answer("Lima", questionOneHundred, true);
answerRepository.save(q100AnswerOne);
Answer q100AnswerTwo = new Answer("Santiago", questionOneHundred, false);
answerRepository.save(q100AnswerTwo);
Answer q100AnswerThree = new Answer("Montevideo", questionOneHundred, false);
answerRepository.save(q100AnswerThree);
Answer q100AnswerFour = new Answer("Buenos Aires", questionOneHundred, false);
answerRepository.save(q100AnswerFour);
Question questionOneHundredAndOne = new Question("What is the only country in the world with a flag that doesn't have four right angles?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndOne);
Answer q101AnswerOne = new Answer("Nepal", questionOneHundredAndOne, true);
answerRepository.save(q101AnswerOne);
Answer q101AnswerTwo = new Answer("Panama", questionOneHundredAndOne, false);
answerRepository.save(q101AnswerTwo);
Answer q101AnswerThree = new Answer("Angola", questionOneHundredAndOne, false);
answerRepository.save(q101AnswerThree);
Answer q101AnswerFour = new Answer("Egypt", questionOneHundredAndOne, false);
answerRepository.save(q101AnswerFour);
Question questionOneHundredAndTwo = new Question("In which Shakespearean play will you find the suicide of Ophelia?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndTwo);
Answer q102AnswerOne = new Answer("Hamlet", questionOneHundredAndTwo, true);
answerRepository.save(q102AnswerOne);
Answer q102AnswerTwo = new Answer("Macbeth", questionOneHundredAndTwo, false);
answerRepository.save(q102AnswerTwo);
Answer q102AnswerThree = new Answer("Othello", questionOneHundredAndTwo, false);
answerRepository.save(q102AnswerThree);
Answer q102AnswerFour = new Answer("King Lear", questionOneHundredAndTwo, false);
answerRepository.save(q102AnswerFour);
Question questionOneHundredAndThree = new Question("What is the largest lake in the African continent?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndThree);
Answer q103AnswerOne = new Answer("Lake Victoria", questionOneHundredAndThree, true);
answerRepository.save(q103AnswerOne);
Answer q103AnswerTwo = new Answer("Lake Tanganyika", questionOneHundredAndThree, false);
answerRepository.save(q103AnswerTwo);
Answer q103AnswerThree = new Answer("Lake Malawi", questionOneHundredAndThree, false);
answerRepository.save(q103AnswerThree);
Answer q103AnswerFour = new Answer("Lake Turkana", questionOneHundredAndThree, false);
answerRepository.save(q103AnswerFour);
Question questionOneHundredAndFour = new Question("How many copies have Metallica album 'Metallica' (A.K.A The Black Album) sold worldwide (in Millions of Copies)?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndFour);
Answer q104AnswerOne = new Answer("20.5", questionOneHundredAndFour, true);
answerRepository.save(q104AnswerOne);
Answer q104AnswerTwo = new Answer("19.5", questionOneHundredAndFour, false);
answerRepository.save(q104AnswerTwo);
Answer q104AnswerThree = new Answer("22.5", questionOneHundredAndFour, false);
answerRepository.save(q104AnswerThree);
Answer q104AnswerFour = new Answer("25.5", questionOneHundredAndFour, false);
answerRepository.save(q104AnswerFour);
Question questionOneHundredAndFive = new Question("When did the British hand-over sovereignty of Hong Kong back to China?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndFive);
Answer q105AnswerOne = new Answer("1997", questionOneHundredAndFive, true);
answerRepository.save(q105AnswerOne);
Answer q105AnswerTwo = new Answer("1999", questionOneHundredAndFive, false);
answerRepository.save(q105AnswerTwo);
Answer q105AnswerThree = new Answer("1841", questionOneHundredAndFive, false);
answerRepository.save(q105AnswerThree);
Answer q105AnswerFour = new Answer("1900", questionOneHundredAndFive, false);
answerRepository.save(q105AnswerFour);
Question questionOneHundredAndSix = new Question("Computer manufacturer Compaq was acquired for $25 billion dollars in 2002 by which company?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndSix);
Answer q106AnswerOne = new Answer("Hewlett-Packard", questionOneHundredAndSix, true);
answerRepository.save(q106AnswerOne);
Answer q106AnswerTwo = new Answer("Toshiba", questionOneHundredAndSix, false);
answerRepository.save(q106AnswerTwo);
Answer q106AnswerThree = new Answer("Asus", questionOneHundredAndSix, false);
answerRepository.save(q106AnswerThree);
Answer q106AnswerFour = new Answer("Dell", questionOneHundredAndSix, false);
answerRepository.save(q106AnswerFour);
Question questionOneHundredAndSeven = new Question("The Sun consists of mostly which two elements?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndSeven);
Answer q107AnswerOne = new Answer("Hydrogen & Helium", questionOneHundredAndSeven, true);
answerRepository.save(q107AnswerOne);
Answer q107AnswerTwo = new Answer("Hydrogen & Nitrogen", questionOneHundredAndSeven, false);
answerRepository.save(q107AnswerTwo);
Answer q107AnswerThree = new Answer("Carbon & Nitrogen", questionOneHundredAndSeven, false);
answerRepository.save(q107AnswerThree);
Answer q107AnswerFour = new Answer("Carbon & Helium", questionOneHundredAndSeven, false);
answerRepository.save(q107AnswerFour);
Question questionOneHundredAndEight = new Question("In Psychology, which need appears highest in the 'Maslow's hierarchy of needs' pyramid?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndEight);
Answer q108AnswerOne = new Answer("Esteem", questionOneHundredAndEight, true);
answerRepository.save(q108AnswerOne);
Answer q108AnswerTwo = new Answer("Love", questionOneHundredAndEight, false);
answerRepository.save(q108AnswerTwo);
Answer q108AnswerThree = new Answer("Safety", questionOneHundredAndEight, false);
answerRepository.save(q108AnswerThree);
Answer q108AnswerFour = new Answer("Physiological", questionOneHundredAndEight, false);
answerRepository.save(q108AnswerFour);
Question questionOneHundredAndNine = new Question("Who was the only US President to be elected four times?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndNine);
Answer q109AnswerOne = new Answer("Franklin Roosevelt", questionOneHundredAndNine, true);
answerRepository.save(q109AnswerOne);
Answer q109AnswerTwo = new Answer("Theodore Roosevelt", questionOneHundredAndNine, false);
answerRepository.save(q109AnswerTwo);
Answer q109AnswerThree = new Answer("George Washington", questionOneHundredAndNine, false);
answerRepository.save(q109AnswerThree);
Answer q109AnswerFour = new Answer("Abraham Lincoln", questionOneHundredAndNine, false);
answerRepository.save(q109AnswerFour);
Question questionOneHundredAndTen = new Question("Which of these Japanese islands is the largest by area?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndTen);
Answer q110AnswerOne = new Answer("Shikoku", questionOneHundredAndTen, true);
answerRepository.save(q110AnswerOne);
Answer q110AnswerTwo = new Answer("Iki", questionOneHundredAndTen, false);
answerRepository.save(q110AnswerTwo);
Answer q110AnswerThree = new Answer("Odaiba", questionOneHundredAndTen, false);
answerRepository.save(q110AnswerThree);
Answer q110AnswerFour = new Answer("Okinawa", questionOneHundredAndTen, false);
answerRepository.save(q110AnswerFour);
Question questionOneHundredAndEleven = new Question("The #64 in the Nintendo-64 console refers to what?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndEleven);
Answer q111AnswerOne = new Answer("The bits in the CPU architecture", questionOneHundredAndEleven, true);
answerRepository.save(q111AnswerOne);
Answer q111AnswerTwo = new Answer("The number of megabytes of RAM", questionOneHundredAndEleven, false);
answerRepository.save(q111AnswerTwo);
Answer q111AnswerThree = new Answer("Capacity of the ROM Cartridges in megabytes", questionOneHundredAndEleven, false);
answerRepository.save(q111AnswerThree);
Answer q111AnswerFour = new Answer("Clock speed of the CPU in Hertz", questionOneHundredAndEleven, false);
answerRepository.save(q111AnswerFour);
Question questionOneHundredAndTwelve = new Question("Which of these is not a member of the virtual band Gorillaz?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndTwelve);
Answer q112AnswerOne = new Answer("Phi Cypher", questionOneHundredAndTwelve, true);
answerRepository.save(q112AnswerOne);
Answer q112AnswerTwo = new Answer("Murdoc Niccals", questionOneHundredAndTwelve, false);
answerRepository.save(q112AnswerTwo);
Answer q112AnswerThree = new Answer("Noodle", questionOneHundredAndTwelve, false);
answerRepository.save(q112AnswerThree);
Answer q112AnswerFour = new Answer("Russel Hobbs", questionOneHundredAndTwelve, false);
answerRepository.save(q112AnswerFour);
Question questionOneHundredAndThirteen = new Question("Which river flows through the Scottish city of Glasgow?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndThirteen);
Answer q113AnswerOne = new Answer("Clyde", questionOneHundredAndThirteen, true);
answerRepository.save(q113AnswerOne);
Answer q113AnswerTwo = new Answer("Tay", questionOneHundredAndThirteen, false);
answerRepository.save(q113AnswerTwo);
Answer q113AnswerThree = new Answer("Dee", questionOneHundredAndThirteen, false);
answerRepository.save(q113AnswerThree);
Answer q113AnswerFour = new Answer("Tweed", questionOneHundredAndThirteen, false);
answerRepository.save(q113AnswerFour);
Question questionOneHundredAndFourteen = new Question("The humerus, paired radius, and ulna come together to form what joint?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndFourteen);
Answer q114AnswerOne = new Answer("Elbow", questionOneHundredAndFourteen, true);
answerRepository.save(q114AnswerOne);
Answer q114AnswerTwo = new Answer("Knee", questionOneHundredAndFourteen, false);
answerRepository.save(q114AnswerTwo);
Answer q114AnswerThree = new Answer("Shoulder", questionOneHundredAndFourteen, false);
answerRepository.save(q114AnswerThree);
Answer q114AnswerFour = new Answer("Ankle", questionOneHundredAndFourteen, false);
answerRepository.save(q114AnswerFour);
Question questionOneHundredAndFifteen = new Question("In relation to the British Occupation in Ireland, what does the IRA stand for?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndFifteen);
Answer q115AnswerOne = new Answer("Irish Republican Army", questionOneHundredAndFifteen, true);
answerRepository.save(q115AnswerOne);
Answer q115AnswerTwo = new Answer("Irish Rebel Alliance", questionOneHundredAndFifteen, false);
answerRepository.save(q115AnswerTwo);
Answer q115AnswerThree = new Answer("Irish Reformation Army", questionOneHundredAndFifteen, false);
answerRepository.save(q115AnswerThree);
Answer q115AnswerFour = new Answer("Irish-Royal Alliance", questionOneHundredAndFifteen, false);
answerRepository.save(q115AnswerFour);
Question questionOneHundredAndSixteen = new Question("What five letter word is the motto of the IBM Computer company?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndSixteen);
Answer q116AnswerOne = new Answer("Think", questionOneHundredAndSixteen, true);
answerRepository.save(q116AnswerOne);
Answer q116AnswerTwo = new Answer("Click", questionOneHundredAndSixteen, false);
answerRepository.save(q116AnswerTwo);
Answer q116AnswerThree = new Answer("Logic", questionOneHundredAndSixteen, false);
answerRepository.save(q116AnswerThree);
Answer q116AnswerFour = new Answer("Pixel", questionOneHundredAndSixteen, false);
answerRepository.save(q116AnswerFour);
Question questionOneHundredAndSeventeen = new Question("Which element has the atomic number of 7?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndSeventeen);
Answer q117AnswerOne = new Answer("Nitrogen", questionOneHundredAndSeventeen, true);
answerRepository.save(q117AnswerOne);
Answer q117AnswerTwo = new Answer("Oxygen", questionOneHundredAndSeventeen, false);
answerRepository.save(q117AnswerTwo);
Answer q117AnswerThree = new Answer("Hydrogen", questionOneHundredAndSeventeen, false);
answerRepository.save(q117AnswerThree);
Answer q117AnswerFour = new Answer("Neon", questionOneHundredAndSeventeen, false);
answerRepository.save(q117AnswerFour);
Question questionOneHundredAndEighteen = new Question("Who was the star of the TV series '24'?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndEighteen);
Answer q118AnswerOne = new Answer("Kiefer Sutherland", questionOneHundredAndEighteen, true);
answerRepository.save(q118AnswerOne);
Answer q118AnswerTwo = new Answer("Kevin Bacon", questionOneHundredAndEighteen, false);
answerRepository.save(q118AnswerTwo);
Answer q118AnswerThree = new Answer("Hugh Laurie", questionOneHundredAndEighteen, false);
answerRepository.save(q118AnswerThree);
Answer q118AnswerFour = new Answer("Rob Lowe", questionOneHundredAndEighteen, false);
answerRepository.save(q118AnswerFour);
Question questionOneHundredAndNineteen = new Question("How many points is the Z tile worth in Scrabble?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndNineteen);
Answer q119AnswerOne = new Answer("10", questionOneHundredAndNineteen, true);
answerRepository.save(q119AnswerOne);
Answer q119AnswerTwo = new Answer("12", questionOneHundredAndNineteen, false);
answerRepository.save(q119AnswerTwo);
Answer q119AnswerThree = new Answer("14", questionOneHundredAndNineteen, false);
answerRepository.save(q119AnswerThree);
Answer q119AnswerFour = new Answer("8", questionOneHundredAndNineteen, false);
answerRepository.save(q119AnswerFour);
Question questionOneHundredAndTwenty = new Question("In The Lord of the Rings: The Fellowship of the Ring, which one of the following characters from the book was left out of the film?", Difficulty.FIVE);
questionRepository.save(questionOneHundredAndTwenty);
Answer q120AnswerOne = new Answer("Tom Bombadil", questionOneHundredAndTwenty, true);
answerRepository.save(q120AnswerOne);
Answer q120AnswerTwo = new Answer("Strider", questionOneHundredAndTwenty, false);
answerRepository.save(q120AnswerTwo);
Answer q120AnswerThree = new Answer("Barliman Butterbur", questionOneHundredAndTwenty, false);
answerRepository.save(q120AnswerThree);
Answer q120AnswerFour = new Answer("Celeborn", questionOneHundredAndTwenty, false);
answerRepository.save(q120AnswerFour);
Question questionOneHundredAndTwentyOne = new Question("With which Greek philosopher would you associate the phrase, 'I know that I know nothing'?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyOne);
Answer q121AnswerOne = new Answer("Socrates", questionOneHundredAndTwentyOne, true);
answerRepository.save(q121AnswerOne);
Answer q121AnswerTwo = new Answer("Aristotle", questionOneHundredAndTwentyOne, false);
answerRepository.save(q121AnswerTwo);
Answer q121AnswerThree = new Answer("Plato", questionOneHundredAndTwentyOne, false);
answerRepository.save(q121AnswerThree);
Answer q121AnswerFour = new Answer("Pythagoras", questionOneHundredAndTwentyOne, false);
answerRepository.save(q121AnswerFour);
Question questionOneHundredAndTwentyTwo = new Question("Who was the original drummer for The Beatles?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyTwo);
Answer q122AnswerOne = new Answer("Tommy Moore", questionOneHundredAndTwentyTwo, true);
answerRepository.save(q122AnswerOne);
Answer q122AnswerTwo = new Answer("Ringo Starr", questionOneHundredAndTwentyTwo, false);
answerRepository.save(q122AnswerTwo);
Answer q122AnswerThree = new Answer("Stuart Sutcliffe", questionOneHundredAndTwentyTwo, false);
answerRepository.save(q122AnswerThree);
Answer q122AnswerFour = new Answer("Pete Best", questionOneHundredAndTwentyTwo, false);
answerRepository.save(q122AnswerFour);
Question questionOneHundredAndTwentyThree = new Question("What is Hermione Granger's middle name?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyThree);
Answer q123AnswerOne = new Answer("Jean", questionOneHundredAndTwentyThree, true);
answerRepository.save(q123AnswerOne);
Answer q123AnswerTwo = new Answer("Jane", questionOneHundredAndTwentyThree, false);
answerRepository.save(q123AnswerTwo);
Answer q123AnswerThree = new Answer("Emma", questionOneHundredAndTwentyThree, false);
answerRepository.save(q123AnswerThree);
Answer q123AnswerFour = new Answer("Jo", questionOneHundredAndTwentyThree, false);
answerRepository.save(q123AnswerFour);
Question questionOneHundredAndTwentyFour = new Question("The mountainous Khyber Pass connects which of the two following countries?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyFour);
Answer q124AnswerOne = new Answer("Afghanistan and Pakistan", questionOneHundredAndTwentyFour, true);
answerRepository.save(q124AnswerOne);
Answer q124AnswerTwo = new Answer("India and Nepal", questionOneHundredAndTwentyFour, false);
answerRepository.save(q124AnswerTwo);
Answer q124AnswerThree = new Answer("Pakistan and India", questionOneHundredAndTwentyFour, false);
answerRepository.save(q124AnswerThree);
Answer q124AnswerFour = new Answer("Tajikistan and Kyrgyzstan", questionOneHundredAndTwentyFour, false);
answerRepository.save(q124AnswerFour);
Question questionOneHundredAndTwentyFive = new Question("Why was the character Trevor Philips, from GTA V, discharged from the Air Force?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyFive);
Answer q125AnswerOne = new Answer("Mental Health Issues", questionOneHundredAndTwentyFive, true);
answerRepository.save(q125AnswerOne);
Answer q125AnswerTwo = new Answer("Injuries", questionOneHundredAndTwentyFive, false);
answerRepository.save(q125AnswerTwo);
Answer q125AnswerThree = new Answer("Disease", questionOneHundredAndTwentyFive, false);
answerRepository.save(q125AnswerThree);
Answer q125AnswerFour = new Answer("Danger to Others", questionOneHundredAndTwentyFive, false);
answerRepository.save(q125AnswerFour);
Question questionOneHundredAndTwentySix = new Question("Which of the following is not another name for the eggplant?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentySix);
Answer q126AnswerOne = new Answer("Potimarron", questionOneHundredAndTwentySix, true);
answerRepository.save(q126AnswerOne);
Answer q126AnswerTwo = new Answer("Brinjal", questionOneHundredAndTwentySix, false);
answerRepository.save(q126AnswerTwo);
Answer q126AnswerThree = new Answer("Guinea Squash", questionOneHundredAndTwentySix, false);
answerRepository.save(q126AnswerThree);
Answer q126AnswerFour = new Answer("Melongene", questionOneHundredAndTwentySix, false);
answerRepository.save(q126AnswerFour);
Question questionOneHundredAndTwentySeven = new Question("When was the Garfield comic first published?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentySeven);
Answer q127AnswerOne = new Answer("1978", questionOneHundredAndTwentySeven, true);
answerRepository.save(q127AnswerOne);
Answer q127AnswerTwo = new Answer("1982", questionOneHundredAndTwentySeven, false);
answerRepository.save(q127AnswerTwo);
Answer q127AnswerThree = new Answer("1973", questionOneHundredAndTwentySeven, false);
answerRepository.save(q127AnswerThree);
Answer q127AnswerFour = new Answer("1988", questionOneHundredAndTwentySeven, false);
answerRepository.save(q127AnswerFour);
Question questionOneHundredAndTwentyEight = new Question("According to Algonquian folklore, how does one transform into a Wendigo?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyEight);
Answer q128AnswerOne = new Answer("Participating in cannibalism", questionOneHundredAndTwentyEight, true);
answerRepository.save(q128AnswerOne);
Answer q128AnswerTwo = new Answer("Excessive mutilation of animal corpses", questionOneHundredAndTwentyEight, false);
answerRepository.save(q128AnswerTwo);
Answer q128AnswerThree = new Answer("Performing a ritual involving murder", questionOneHundredAndTwentyEight, false);
answerRepository.save(q128AnswerThree);
Answer q128AnswerFour = new Answer("Drinking the blood of many slain animals", questionOneHundredAndTwentyEight, false);
answerRepository.save(q128AnswerFour);
Question questionOneHundredAndTwentyNine = new Question("What is Canada's largest island?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndTwentyNine);
Answer q129AnswerOne = new Answer("Baffin Island", questionOneHundredAndTwentyNine, true);
answerRepository.save(q129AnswerOne);
Answer q129AnswerTwo = new Answer("Prince Edward Island", questionOneHundredAndTwentyNine, false);
answerRepository.save(q129AnswerTwo);
Answer q129AnswerThree = new Answer("Vancouver Island", questionOneHundredAndTwentyNine, false);
answerRepository.save(q129AnswerThree);
Answer q129AnswerFour = new Answer("Newfoundland", questionOneHundredAndTwentyNine, false);
answerRepository.save(q129AnswerFour);
Question questionOneHundredAndThirty = new Question("Which of these in the Star Trek series is NOT Klingon food?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirty);
Answer q130AnswerOne = new Answer("Hors d'oeuvre", questionOneHundredAndThirty, true);
answerRepository.save(q130AnswerOne);
Answer q130AnswerTwo = new Answer("Racht", questionOneHundredAndThirty, false);
answerRepository.save(q130AnswerTwo);
Answer q130AnswerThree = new Answer("Gagh", questionOneHundredAndThirty, false);
answerRepository.save(q130AnswerThree);
Answer q130AnswerFour = new Answer("Bloodwine", questionOneHundredAndThirty, false);
answerRepository.save(q130AnswerFour);
Question questionOneHundredAndThirtyOne = new Question("When Magic: The Gathering was first solicited, which of the following was it originally titled?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyOne);
Answer q131AnswerOne = new Answer("Mana Clash", questionOneHundredAndThirtyOne, true);
answerRepository.save(q131AnswerOne);
Answer q131AnswerTwo = new Answer("Magic", questionOneHundredAndThirtyOne, false);
answerRepository.save(q131AnswerTwo);
Answer q131AnswerThree = new Answer("Magic Clash", questionOneHundredAndThirtyOne, false);
answerRepository.save(q131AnswerThree);
Answer q131AnswerFour = new Answer("Mana Duels", questionOneHundredAndThirtyOne, false);
answerRepository.save(q131AnswerFour);
Question questionOneHundredAndThirtyTwo = new Question("Coulrophobia is the irrational fear of what?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyTwo);
Answer q132AnswerOne = new Answer("Clowns", questionOneHundredAndThirtyTwo, true);
answerRepository.save(q132AnswerOne);
Answer q132AnswerTwo = new Answer("Cemeteries", questionOneHundredAndThirtyTwo, false);
answerRepository.save(q132AnswerTwo);
Answer q132AnswerThree = new Answer("Needles", questionOneHundredAndThirtyTwo, false);
answerRepository.save(q132AnswerThree);
Answer q132AnswerFour = new Answer("Tunnels", questionOneHundredAndThirtyTwo, false);
answerRepository.save(q132AnswerFour);
Question questionOneHundredAndThirtyThree = new Question("The ancient city of 'Chich-én itz-acute' was built by which civilization?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyThree);
Answer q133AnswerOne = new Answer("Mayans", questionOneHundredAndThirtyThree, true);
answerRepository.save(q133AnswerOne);
Answer q133AnswerTwo = new Answer("Aztecs", questionOneHundredAndThirtyThree, false);
answerRepository.save(q133AnswerTwo);
Answer q133AnswerThree = new Answer("Incas", questionOneHundredAndThirtyThree, false);
answerRepository.save(q133AnswerThree);
Answer q133AnswerFour = new Answer("Toltecs", questionOneHundredAndThirtyThree, false);
answerRepository.save(q133AnswerFour);
Question questionOneHundredAndThirtyFour = new Question("Townsend Coleman provided the voice for which turtle in the original 1987 series of 'Teenage Mutant Ninja Turtles'?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyFour);
Answer q134AnswerOne = new Answer("Michelangelo", questionOneHundredAndThirtyFour, true);
answerRepository.save(q134AnswerOne);
Answer q134AnswerTwo = new Answer("Leonardo", questionOneHundredAndThirtyFour, false);
answerRepository.save(q134AnswerTwo);
Answer q134AnswerThree = new Answer("Donatello", questionOneHundredAndThirtyFour, false);
answerRepository.save(q134AnswerThree);
Answer q134AnswerFour = new Answer("Raphael", questionOneHundredAndThirtyFour, false);
answerRepository.save(q134AnswerFour);
Question questionOneHundredAndThirtyFive = new Question("Which scientific unit is named after an Italian nobleman?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyFive);
Answer q135AnswerOne = new Answer("Volt", questionOneHundredAndThirtyFive, true);
answerRepository.save(q135AnswerOne);
Answer q135AnswerTwo = new Answer("Pascal", questionOneHundredAndThirtyFive, false);
answerRepository.save(q135AnswerTwo);
Answer q135AnswerThree = new Answer("Ohm", questionOneHundredAndThirtyFive, false);
answerRepository.save(q135AnswerThree);
Answer q135AnswerFour = new Answer("Hertz", questionOneHundredAndThirtyFive, false);
answerRepository.save(q135AnswerFour);
Question questionOneHundredAndThirtySix = new Question("What is the most commonly used noun in the English language?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtySix);
Answer q136AnswerOne = new Answer("Time", questionOneHundredAndThirtySix, true);
answerRepository.save(q136AnswerOne);
Answer q136AnswerTwo = new Answer("Home", questionOneHundredAndThirtySix, false);
answerRepository.save(q136AnswerTwo);
Answer q136AnswerThree = new Answer("Water", questionOneHundredAndThirtySix, false);
answerRepository.save(q136AnswerThree);
Answer q136AnswerFour = new Answer("Man", questionOneHundredAndThirtySix, false);
answerRepository.save(q136AnswerFour);
Question questionOneHundredAndThirtySeven = new Question("In quantum physics, which of these theorised sub-atomic particles has yet to be observed?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtySeven);
Answer q137AnswerOne = new Answer("Graviton", questionOneHundredAndThirtySeven, true);
answerRepository.save(q137AnswerOne);
Answer q137AnswerTwo = new Answer("Z boson", questionOneHundredAndThirtySeven, false);
answerRepository.save(q137AnswerTwo);
Answer q137AnswerThree = new Answer("Tau neutrino", questionOneHundredAndThirtySeven, false);
answerRepository.save(q137AnswerThree);
Answer q137AnswerFour = new Answer("Gluon", questionOneHundredAndThirtySeven, false);
answerRepository.save(q137AnswerFour);
Question questionOneHundredAndThirtyEight = new Question("When did the French Revolution begin?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyEight);
Answer q138AnswerOne = new Answer("1789", questionOneHundredAndThirtyEight, true);
answerRepository.save(q138AnswerOne);
Answer q138AnswerTwo = new Answer("1823", questionOneHundredAndThirtyEight, false);
answerRepository.save(q138AnswerTwo);
Answer q138AnswerThree = new Answer("1756", questionOneHundredAndThirtyEight, false);
answerRepository.save(q138AnswerThree);
Answer q138AnswerFour = new Answer("1799", questionOneHundredAndThirtyEight, false);
answerRepository.save(q138AnswerFour);
Question questionOneHundredAndThirtyNine = new Question("In the Harry Potter universe, who does Draco Malfoy end up marrying?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndThirtyNine);
Answer q139AnswerOne = new Answer("Astoria Greengrass", questionOneHundredAndThirtyNine, true);
answerRepository.save(q139AnswerOne);
Answer q139AnswerTwo = new Answer("Pansy Parkinson", questionOneHundredAndThirtyNine, false);
answerRepository.save(q139AnswerTwo);
Answer q139AnswerThree = new Answer("Millicent Bulstrode", questionOneHundredAndThirtyNine, false);
answerRepository.save(q139AnswerThree);
Answer q139AnswerFour = new Answer("Hermione Granger", questionOneHundredAndThirtyNine, false);
answerRepository.save(q139AnswerFour);
Question questionOneHundredAndForty = new Question("Which of the following is the standard THX subwoofer crossover frequency?", Difficulty.SIX);
questionRepository.save(questionOneHundredAndForty);
Answer q140AnswerOne = new Answer("80 Hz", questionOneHundredAndForty, true);
answerRepository.save(q140AnswerOne);
Answer q140AnswerTwo = new Answer("70 Hz", questionOneHundredAndForty, false);
answerRepository.save(q140AnswerTwo);
Answer q140AnswerThree = new Answer("90 Hz", questionOneHundredAndForty, false);
answerRepository.save(q140AnswerThree);
Answer q140AnswerFour = new Answer("100 Hz", questionOneHundredAndForty, false);
answerRepository.save(q140AnswerFour);
Question questionOneHundredAndFortyOne = new Question("Where was the Games of the XXII Olympiad held?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyOne);
Answer q141AnswerOne = new Answer("Moscow", questionOneHundredAndFortyOne, true);
answerRepository.save(q141AnswerOne);
Answer q141AnswerTwo = new Answer("Barcelona", questionOneHundredAndFortyOne, false);
answerRepository.save(q141AnswerTwo);
Answer q141AnswerThree = new Answer("Tokyo", questionOneHundredAndFortyOne, false);
answerRepository.save(q141AnswerThree);
Answer q141AnswerFour = new Answer("Los Angeles", questionOneHundredAndFortyOne, false);
answerRepository.save(q141AnswerFour);
Question questionOneHundredAndFortyTwo = new Question("How many sonatas did Ludwig van Beethoven write?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyTwo);
Answer q142AnswerOne = new Answer("32", questionOneHundredAndFortyTwo, true);
answerRepository.save(q142AnswerOne);
Answer q142AnswerTwo = new Answer("50", questionOneHundredAndFortyTwo, false);
answerRepository.save(q142AnswerTwo);
Answer q142AnswerThree = new Answer("31", questionOneHundredAndFortyTwo, false);
answerRepository.save(q142AnswerThree);
Answer q142AnswerFour = new Answer("21", questionOneHundredAndFortyTwo, false);
answerRepository.save(q142AnswerFour);
Question questionOneHundredAndFortyThree = new Question("During the Roman Triumvirate of 42 BCE, what region of the Roman Republic was given to Lepidus?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyThree);
Answer q143AnswerOne = new Answer("Hispania", questionOneHundredAndFortyThree, true);
answerRepository.save(q143AnswerOne);
Answer q143AnswerTwo = new Answer("Italia", questionOneHundredAndFortyThree, false);
answerRepository.save(q143AnswerTwo);
Answer q143AnswerThree = new Answer("Gallia", questionOneHundredAndFortyThree, false);
answerRepository.save(q143AnswerThree);
Answer q143AnswerFour = new Answer("Asia", questionOneHundredAndFortyThree, false);
answerRepository.save(q143AnswerFour);
Question questionOneHundredAndFortyFour = new Question("Which male player won the gold medal of table tennis singles in 2016 Olympics Games?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyFour);
Answer q144AnswerOne = new Answer("Ma Long", questionOneHundredAndFortyFour, true);
answerRepository.save(q144AnswerOne);
Answer q144AnswerTwo = new Answer("Zhang Jike", questionOneHundredAndFortyFour, false);
answerRepository.save(q144AnswerTwo);
Answer q144AnswerThree = new Answer("Jun Mizutani", questionOneHundredAndFortyFour, false);
answerRepository.save(q144AnswerThree);
Answer q144AnswerFour = new Answer("Vladimir Samsonov", questionOneHundredAndFortyFour, false);
answerRepository.save(q144AnswerFour);
Question questionOneHundredAndFortyFive = new Question("What was the name of the German offensive operation in October 1941 to take Moscow before winter?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyFive);
Answer q145AnswerOne = new Answer("Operation Typhoon", questionOneHundredAndFortyFive, true);
answerRepository.save(q145AnswerOne);
Answer q145AnswerTwo = new Answer("Operation Sunflower", questionOneHundredAndFortyFive, false);
answerRepository.save(q145AnswerTwo);
Answer q145AnswerThree = new Answer("Operation Barbarossa", questionOneHundredAndFortyFive, false);
answerRepository.save(q145AnswerThree);
Answer q145AnswerFour = new Answer("Case Blue", questionOneHundredAndFortyFive, false);
answerRepository.save(q145AnswerFour);
Question questionOneHundredAndFortySix = new Question("How many stations does the Central Line have on the London Underground?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortySix);
Answer q146AnswerOne = new Answer("49", questionOneHundredAndFortySix, true);
answerRepository.save(q146AnswerOne);
Answer q146AnswerTwo = new Answer("51", questionOneHundredAndFortySix, false);
answerRepository.save(q146AnswerTwo);
Answer q146AnswerThree = new Answer("43", questionOneHundredAndFortySix, false);
answerRepository.save(q146AnswerThree);
Answer q146AnswerFour = new Answer("47", questionOneHundredAndFortySix, false);
answerRepository.save(q146AnswerFour);
Question questionOneHundredAndFortySeven = new Question("What is the scientific name for the extinct hominin known as 'Lucy'?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortySeven);
Answer q147AnswerOne = new Answer("Australopithecus Afarensis", questionOneHundredAndFortySeven, true);
answerRepository.save(q147AnswerOne);
Answer q147AnswerTwo = new Answer("Australopithecus Africanus", questionOneHundredAndFortySeven, false);
answerRepository.save(q147AnswerTwo);
Answer q147AnswerThree = new Answer("Australopithecus Architeuthis", questionOneHundredAndFortySeven, false);
answerRepository.save(q147AnswerThree);
Answer q147AnswerFour = new Answer("Australopithecus Antaris", questionOneHundredAndFortySeven, false);
answerRepository.save(q147AnswerFour);
Question questionOneHundredAndFortyEight = new Question("In the 'Harry Potter' series, what is Headmaster Dumbledore's full name?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyEight);
Answer q148AnswerOne = new Answer("Albus Percival Wulfric Brian Dumbledore", questionOneHundredAndFortyEight, true);
answerRepository.save(q148AnswerOne);
Answer q148AnswerTwo = new Answer("Albus Valum Jetta Mobius Dumbledore", questionOneHundredAndFortyEight, false);
answerRepository.save(q148AnswerTwo);
Answer q148AnswerThree = new Answer("Albus James Lunae Otto Dumbledore", questionOneHundredAndFortyEight, false);
answerRepository.save(q148AnswerThree);
Answer q148AnswerFour = new Answer("Albus Valencium Horatio Kul Dumbledore", questionOneHundredAndFortyEight, false);
answerRepository.save(q148AnswerFour);
Question questionOneHundredAndFortyNine = new Question("The Western Lowland Gorilla is scientifically know as?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFortyNine);
Answer q149AnswerOne = new Answer("Gorilla Gorilla Gorilla", questionOneHundredAndFortyNine, true);
answerRepository.save(q149AnswerOne);
Answer q149AnswerTwo = new Answer("Gorilla Gorilla Diehli", questionOneHundredAndFortyNine, false);
answerRepository.save(q149AnswerTwo);
Answer q149AnswerThree = new Answer("Gorilla Beringei Graueri", questionOneHundredAndFortyNine, false);
answerRepository.save(q149AnswerThree);
Answer q149AnswerFour = new Answer("Gorilla Beringei Beringei", questionOneHundredAndFortyNine, false);
answerRepository.save(q149AnswerFour);
Question questionOneHundredAndFifty = new Question("From 1940 to 1942, what was the capital-in-exile of Free France ?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFifty);
Answer q150AnswerOne = new Answer("Brazzaville", questionOneHundredAndFifty, true);
answerRepository.save(q150AnswerOne);
Answer q150AnswerTwo = new Answer("Algiers", questionOneHundredAndFifty, false);
answerRepository.save(q150AnswerTwo);
Answer q150AnswerThree = new Answer("Paris", questionOneHundredAndFifty, false);
answerRepository.save(q150AnswerThree);
Answer q150AnswerFour = new Answer("Tunis", questionOneHundredAndFifty, false);
answerRepository.save(q150AnswerFour);
Question questionOneHundredAndFiftyOne = new Question("What physics principle relates the net electric flux out of a closed surface to the charge enclosed by that surface?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyOne);
Answer q151AnswerOne = new Answer("Gauss's Law", questionOneHundredAndFiftyOne, true);
answerRepository.save(q151AnswerOne);
Answer q151AnswerTwo = new Answer("Faraday's Law", questionOneHundredAndFiftyOne, false);
answerRepository.save(q151AnswerTwo);
Answer q151AnswerThree = new Answer("Ampere's Law", questionOneHundredAndFiftyOne, false);
answerRepository.save(q151AnswerThree);
Answer q151AnswerFour = new Answer("Biot-Savart Law", questionOneHundredAndFiftyOne, false);
answerRepository.save(q151AnswerFour);
Question questionOneHundredAndFiftyTwo = new Question("Which horizon in a soil profile consists of bedrock?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyTwo);
Answer q152AnswerOne = new Answer("R", questionOneHundredAndFiftyTwo, true);
answerRepository.save(q152AnswerOne);
Answer q152AnswerTwo = new Answer("O", questionOneHundredAndFiftyTwo, false);
answerRepository.save(q152AnswerTwo);
Answer q152AnswerThree = new Answer("B", questionOneHundredAndFiftyTwo, false);
answerRepository.save(q152AnswerThree);
Answer q152AnswerFour = new Answer("D", questionOneHundredAndFiftyTwo, false);
answerRepository.save(q152AnswerFour);
Question questionOneHundredAndFiftyThree = new Question("What type of sound chip does the Super Nintendo Entertainment System (SNES) have?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyThree);
Answer q153AnswerOne = new Answer("ADPCM Sampler", questionOneHundredAndFiftyThree, true);
answerRepository.save(q153AnswerOne);
Answer q153AnswerTwo = new Answer("FM Synthesizer", questionOneHundredAndFiftyThree, false);
answerRepository.save(q153AnswerTwo);
Answer q153AnswerThree = new Answer("Programmable Sound Generator (PSG)", questionOneHundredAndFiftyThree, false);
answerRepository.save(q153AnswerThree);
Answer q153AnswerFour = new Answer("PCM Sampler", questionOneHundredAndFiftyThree, false);
answerRepository.save(q153AnswerFour);
Question questionOneHundredAndFiftyFour = new Question("Which kind of algorithm is Ron Rivest not famous for creating?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyFour);
Answer q154AnswerOne = new Answer("Secret sharing scheme", questionOneHundredAndFiftyFour, true);
answerRepository.save(q154AnswerOne);
Answer q154AnswerTwo = new Answer("Hashing algorithm", questionOneHundredAndFiftyFour, false);
answerRepository.save(q154AnswerTwo);
Answer q154AnswerThree = new Answer("Asymmetric encryption", questionOneHundredAndFiftyFour, false);
answerRepository.save(q154AnswerThree);
Answer q154AnswerFour = new Answer("Stream cipher", questionOneHundredAndFiftyFour, false);
answerRepository.save(q154AnswerFour);
Question questionOneHundredAndFiftyFive = new Question("How many times did Martina Navratilova win the Wimbledon Singles Championship?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyFive);
Answer q155AnswerOne = new Answer("Nine", questionOneHundredAndFiftyFive, true);
answerRepository.save(q155AnswerOne);
Answer q155AnswerTwo = new Answer("Ten", questionOneHundredAndFiftyFive, false);
answerRepository.save(q155AnswerTwo);
Answer q155AnswerThree = new Answer("Seven", questionOneHundredAndFiftyFive, false);
answerRepository.save(q155AnswerThree);
Answer q155AnswerFour = new Answer("Eight", questionOneHundredAndFiftyFive, false);
answerRepository.save(q155AnswerFour);
Question questionOneHundredAndFiftySix = new Question("How many objects are equivalent to one mole?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftySix);
Answer q156AnswerOne = new Answer("6.022 x 10^23", questionOneHundredAndFiftySix, true);
answerRepository.save(q156AnswerOne);
Answer q156AnswerTwo = new Answer("6.002 x 10^22", questionOneHundredAndFiftySix, false);
answerRepository.save(q156AnswerTwo);
Answer q156AnswerThree = new Answer("6.022 x 10^22", questionOneHundredAndFiftySix, false);
answerRepository.save(q156AnswerThree);
Answer q156AnswerFour = new Answer("6.002 x 10^23", questionOneHundredAndFiftySix, false);
answerRepository.save(q156AnswerFour);
Question questionOneHundredAndFiftySeven = new Question("On which day did ARPANET suffer a 4 hour long network crash?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftySeven);
Answer q157AnswerOne = new Answer("October 27, 1980", questionOneHundredAndFiftySeven, true);
answerRepository.save(q157AnswerOne);
Answer q157AnswerTwo = new Answer("November 21, 1969", questionOneHundredAndFiftySeven, false);
answerRepository.save(q157AnswerTwo);
Answer q157AnswerThree = new Answer("October 29, 1969", questionOneHundredAndFiftySeven, false);
answerRepository.save(q157AnswerThree);
Answer q157AnswerFour = new Answer("December 9, 1991", questionOneHundredAndFiftySeven, false);
answerRepository.save(q157AnswerFour);
Question questionOneHundredAndFiftyEight = new Question("What year was Queen Elizabeth II born?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyEight);
Answer q158AnswerOne = new Answer("1926", questionOneHundredAndFiftyEight, true);
answerRepository.save(q158AnswerOne);
Answer q158AnswerTwo = new Answer("1923", questionOneHundredAndFiftyEight, false);
answerRepository.save(q158AnswerTwo);
Answer q158AnswerThree = new Answer("1929", questionOneHundredAndFiftyEight, false);
answerRepository.save(q158AnswerThree);
Answer q158AnswerFour = new Answer("1930", questionOneHundredAndFiftyEight, false);
answerRepository.save(q158AnswerFour);
Question questionOneHundredAndFiftyNine = new Question("What internet protocol was documented in RFC 1459?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndFiftyNine);
Answer q159AnswerOne = new Answer("IRC", questionOneHundredAndFiftyNine, true);
answerRepository.save(q159AnswerOne);
Answer q159AnswerTwo = new Answer("HTTP", questionOneHundredAndFiftyNine, false);
answerRepository.save(q159AnswerTwo);
Answer q159AnswerThree = new Answer("HTTPS", questionOneHundredAndFiftyNine, false);
answerRepository.save(q159AnswerThree);
Answer q159AnswerFour = new Answer("FTP", questionOneHundredAndFiftyNine, false);
answerRepository.save(q159AnswerFour);
Question questionOneHundredAndSixty = new Question("Which RAID array type is associated with data mirroring?", Difficulty.SEVEN);
questionRepository.save(questionOneHundredAndSixty);
Answer q160AnswerOne = new Answer("RAID 1", questionOneHundredAndSixty, true);
answerRepository.save(q160AnswerOne);
Answer q160AnswerTwo = new Answer("RAID 0", questionOneHundredAndSixty, false);
answerRepository.save(q160AnswerTwo);
Answer q160AnswerThree = new Answer("RAID 10", questionOneHundredAndSixty, false);
answerRepository.save(q160AnswerThree);
Answer q160AnswerFour = new Answer("RAID 5", questionOneHundredAndSixty, false);
answerRepository.save(q160AnswerFour);
Round roundOne = new Round(100,"£100" );
roundRepository.save(roundOne);
Round roundTwe = new Round(200, "£200");
roundRepository.save(roundTwe);
Round roundThree = new Round(300, "£300");
roundRepository.save(roundThree);
Round roundFour = new Round(500, "£500");
roundRepository.save(roundFour);
Round roundFive = new Round(1000, "£1,000");
roundRepository.save(roundFive);
Round roundSix = new Round(2000, "£2,000");
roundRepository.save(roundSix);
Round roundSeven = new Round(4000, "£4,000");
roundRepository.save(roundSeven);
Round roundEight = new Round(8000, "£8,000");
roundRepository.save(roundEight);
Round roundNine = new Round(16000, "£16,000");
roundRepository.save(roundNine);
Round roundTen = new Round(32000, "£32,000");
roundRepository.save(roundTen);
Round roundEleven = new Round(64000, "£64,000");
roundRepository.save(roundEleven);
Round roundTwelve = new Round(125000, "£125,000");
roundRepository.save(roundTwelve);
Round roundThirteen = new Round(250000, "£250,000");
roundRepository.save(roundThirteen);
Round roundFourteen = new Round(500000, "£500,000");
roundRepository.save(roundFourteen);
Round roundFifteen = new Round(1000000, "£1,000,000");
roundRepository.save(roundFifteen);
}
}
| [
"samspam19941@gmail.com"
] | samspam19941@gmail.com |
d92d82d776a8cbbc01a4f81a23ecc13ec2228655 | 243766f55a70a9779ca0848826708f27ff26b8f7 | /src/com/example/pulltorefreshviewdemo/PullToRefreshView.java | 3367888cb88df10145f937516c4348f1d070804f | [] | no_license | caiyc0818/PullToRefreshView | e200b5048ca3038baf167ab578c01813d9a7de14 | 55a4186dfa10c20ff81a693249fa3498704b5187 | refs/heads/master | 2021-01-12T12:17:35.723620 | 2016-10-31T09:27:18 | 2016-10-31T09:27:18 | 72,414,230 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,209 | java | package com.example.pulltorefreshviewdemo;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.ScrollView;
import android.widget.TextView;
public class PullToRefreshView extends LinearLayout{
private static final int PULL_TO_REFRESH = 2;
private static final int RELEASE_TO_REFRESH = 3;
private static final int REFRESHING = 4;
private static final int PULL_UP_STATE = 0;
private static final int PULL_DOWN_STATE = 1;
private static final int HEADER_OFFERT = 20;
private boolean enablePullTorefresh = true;
private boolean enablePullLoadMoreDataStatus = true;
private int mLastMotionY;
private boolean mLock;
private boolean isFooter;
private View mHeaderView;
private View mFooterView;
private LayoutParams params;
private AdapterView<?> mAdapterView;
private ScrollView mScrollView;
private int mHeaderViewHeight;
private int mFooterViewHeight;
private ImageView mHeaderImageView;
private ImageView mFooterImageView;
private TextView mFooterTextView;
private ProgressBar mFooterProgressBar;
private LayoutInflater mInflater;
private int mHeaderState;
private int mFooterState;
private int mPullState;
private RotateAnimation mFlipAnimation;
private RotateAnimation mReverseFlipAnimation;
private OnFooterRefreshListener mOnFooterRefreshListener;
private OnHeaderRefreshListener mOnHeaderRefreshListener;
private float mCurrentDragPercent;
private boolean isShow = false;
private Drawable showDrawable;
public PullToRefreshView(Context context) {
super(context);
init();
}
public PullToRefreshView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
private void init() {
setOrientation(LinearLayout.VERTICAL);
// Load all of the animations we need in code rather than through XML
mFlipAnimation = new RotateAnimation(0, -180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
mFlipAnimation.setInterpolator(new LinearInterpolator());
mFlipAnimation.setDuration(150);
mFlipAnimation.setFillAfter(true);
mReverseFlipAnimation = new RotateAnimation(-180, 0,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
mReverseFlipAnimation.setInterpolator(new LinearInterpolator());
mReverseFlipAnimation.setDuration(150);
mReverseFlipAnimation.setFillAfter(true);
mHeaderState = 2;
mInflater = LayoutInflater.from(getContext());
addHeaderView();
}
/**
* 头部刷新视图
*/
private void addHeaderView() {
mHeaderView = mInflater.inflate(R.layout.refresh_header, this, false);
mHeaderImageView = (ImageView) mHeaderView.findViewById(R.id.pull_to_refresh_image);
measureView(mHeaderView);
mHeaderViewHeight = mHeaderView.getMeasuredHeight();
params = new LayoutParams(LayoutParams.MATCH_PARENT, mHeaderViewHeight);
params.topMargin = -(mHeaderViewHeight);
addView(mHeaderView, params);
}
private void measureView(View child) {
ViewGroup.LayoutParams p = child.getLayoutParams();
if (p == null) {
p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight, MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
/**
* 尾部刷新视图
*/
private void addFooterView() {
mFooterView = mInflater.inflate(R.layout.refresh_footer, this, false);
mFooterImageView = (ImageView) mFooterView.findViewById(R.id.pull_to_load_image);
mFooterTextView = (TextView) mFooterView.findViewById(R.id.pull_to_load_text);
mFooterProgressBar = (ProgressBar) mFooterView.findViewById(R.id.pull_to_load_progress);
measureView(mFooterView);
mFooterViewHeight = mFooterView.getMeasuredHeight();
LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, mFooterViewHeight);
addView(mFooterView, params);
}
@Override
protected void onFinishInflate() {
super.onFinishInflate();
// footer view 鍦ㄦ娣诲姞淇濊瘉娣诲姞鍒發inearlayout涓殑鏈�悗
addFooterView();
initContentAdapterView();
}
private void initContentAdapterView() {
int count = getChildCount();
if (count < 3) {
throw new IllegalArgumentException("this layout must contain 3 child views,and AdapterView or ScrollView must in the second position!");
}
View view = null;
for (int i = 0; i < count - 1; ++i) {
view = getChildAt(i);
if (view instanceof AdapterView<?>) {
mAdapterView = (AdapterView<?>) view;
}
if (view instanceof ScrollView) {
// finish later
mScrollView = (ScrollView) view;
break;
}
}
if (mAdapterView == null && mScrollView == null) {
throw new IllegalArgumentException("must contain a AdapterView or ScrollView in this layout!");
}
}
@Override
public boolean onInterceptTouchEvent(MotionEvent e) {
int y = (int) e.getRawY();
switch (e.getAction()) {
case MotionEvent.ACTION_DOWN:
mLastMotionY = y;
break;
case MotionEvent.ACTION_MOVE:
int deltaY = y - mLastMotionY;
if (isRefreshViewScroll(deltaY)) {
return true;
}
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
break;
}
return false;
}
private boolean isRefreshViewScroll(int deltaY) {
if (mHeaderState == REFRESHING || mFooterState == REFRESHING) {
return false;
}
if (mAdapterView != null) {
if (deltaY > 0) {
if (!enablePullTorefresh) {
return false;
}
View child = mAdapterView.getChildAt(0);
if (child == null) {
return false;
}
if (mAdapterView.getFirstVisiblePosition() == 0 && child.getTop() == 0) {
mPullState = PULL_DOWN_STATE;
return true;
}
int top = child.getTop();
int padding = mAdapterView.getPaddingTop();
if (mAdapterView.getFirstVisiblePosition() == 0 && Math.abs(top - padding) <= 11) {
mPullState = PULL_DOWN_STATE;
return true;
}
} else if (deltaY < 0) {
if (!enablePullLoadMoreDataStatus) {
return false;
}
View lastChild = mAdapterView.getChildAt(mAdapterView.getChildCount() - 1);
if (lastChild == null) {
return false;
}
if (lastChild.getBottom() <= getHeight() && mAdapterView.getLastVisiblePosition() == mAdapterView.getCount() - 1) {
mPullState = PULL_UP_STATE;
return true;
}
}
}
if (mScrollView != null) {
View child = mScrollView.getChildAt(0);
if (deltaY > 0 && mScrollView.getScrollY() == 0) {
mPullState = PULL_DOWN_STATE;
return true;
} else if (deltaY < 0 && child.getMeasuredHeight() <= getHeight() + mScrollView.getScrollY()) {
mPullState = PULL_UP_STATE;
return true;
}
}
return false;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (mLock) {
return true;
}
int y = (int) event.getRawY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
break;
case MotionEvent.ACTION_MOVE:
int deltaY = y - mLastMotionY;
if (mPullState == PULL_DOWN_STATE) {
headerPrepareToRefresh(deltaY);
} else if (mPullState == PULL_UP_STATE && isFooter) {
footerPrepareToRefresh(deltaY);
}
mLastMotionY = y;
changeDrawable();//处理头部下拉刷新动画
break;
case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
isShow = false;
int topMargin = getHeaderTopMargin();
if (mPullState == PULL_DOWN_STATE) {
if (topMargin >= 0) {
headerRefreshing();
} else {
setHeaderTopMargin(-mHeaderViewHeight);
}
} else if (mPullState == PULL_UP_STATE && isFooter) {
if (Math.abs(topMargin) >= mHeaderViewHeight + mFooterViewHeight) {
footerRefreshing();
} else {
setHeaderTopMargin(-mHeaderViewHeight);
}
}
break;
}
return super.onTouchEvent(event);
}
private void headerPrepareToRefresh(int deltaY) {
int newTopMargin = changingHeaderViewTopMargin(deltaY);
if (newTopMargin >= 0 && mHeaderState != RELEASE_TO_REFRESH) {
mHeaderState = RELEASE_TO_REFRESH;
} else if (newTopMargin < 0 && newTopMargin > -mHeaderViewHeight && mHeaderState != PULL_TO_REFRESH) {
mHeaderState = PULL_TO_REFRESH;
}
}
private void footerPrepareToRefresh(int deltaY) {
int newTopMargin = changingHeaderViewTopMargin(deltaY);
if (Math.abs(newTopMargin) >= (mHeaderViewHeight + mFooterViewHeight) && mFooterState != RELEASE_TO_REFRESH) {
mFooterTextView.setText(R.string.pull_to_refresh_footer_release_label);
mHeaderImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow);
mFooterImageView.clearAnimation();
mFooterImageView.startAnimation(mFlipAnimation);
mFooterState = RELEASE_TO_REFRESH;
} else if (Math.abs(newTopMargin) < (mHeaderViewHeight + mFooterViewHeight)) {
mFooterImageView.clearAnimation();
mFooterImageView.startAnimation(mFlipAnimation);
mHeaderImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow_up);
mFooterTextView.setText(R.string.pull_to_refresh_footer_pull_label);
mFooterState = PULL_TO_REFRESH;
}
}
private int changingHeaderViewTopMargin(int deltaY) {
float newTopMargin = params.topMargin + deltaY * 0.3f;
if (deltaY > 0 && mPullState == PULL_UP_STATE && Math.abs(params.topMargin) <= mHeaderViewHeight) {
return params.topMargin;
}
if (deltaY < 0 && mPullState == PULL_DOWN_STATE && Math.abs(params.topMargin) >= mHeaderViewHeight) {
return params.topMargin;
}
params.topMargin = (int) newTopMargin;
mHeaderView.setLayoutParams(params);
invalidate();
return params.topMargin;
}
public void headerRefreshing() {
mHeaderState = REFRESHING;
setHeaderTopMargin(0);
mHeaderImageView.clearAnimation();
AnimationDrawable drawable = (AnimationDrawable) getResources().getDrawable(R.drawable.meimei_showing2);
mHeaderImageView.setImageDrawable(drawable);
drawable.start();
if (mOnHeaderRefreshListener != null) {
mOnHeaderRefreshListener.onHeaderRefresh(this);
}
}
public void footerRefreshing() {
mFooterState = REFRESHING;
int top = mHeaderViewHeight + mFooterViewHeight;
setHeaderTopMargin(-top);
mFooterImageView.setVisibility(View.GONE);
mFooterImageView.clearAnimation();
mFooterImageView.setImageDrawable(null);
mFooterProgressBar.setVisibility(View.VISIBLE);
mFooterTextView.setText(R.string.pull_to_refresh_footer_refreshing_label);
if (mOnFooterRefreshListener != null) {
mOnFooterRefreshListener.onFooterRefresh(this);
}
}
private void setHeaderTopMargin(int topMargin) {
LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
params.topMargin = topMargin;
mHeaderView.setLayoutParams(params);
invalidate();
}
public void onHeaderRefreshComplete() {
setHeaderTopMargin(-mHeaderViewHeight);
mHeaderImageView.setVisibility(View.VISIBLE);
mHeaderImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow);
mHeaderState = PULL_TO_REFRESH;
}
public void onHeaderRefreshComplete(CharSequence lastUpdated) {
onHeaderRefreshComplete();
}
public void onFooterRefreshComplete() {
setHeaderTopMargin(-mHeaderViewHeight);
mFooterImageView.setVisibility(View.VISIBLE);
mFooterImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow_up);
mFooterTextView.setText(R.string.pull_to_refresh_footer_pull_label);
mFooterProgressBar.setVisibility(View.GONE);
mFooterState = PULL_TO_REFRESH;
}
public void onFooterRefreshComplete(int size) {
if (size > 0) {
mFooterView.setVisibility(View.VISIBLE);
} else {
mFooterView.setVisibility(View.GONE);
}
setHeaderTopMargin(-mHeaderViewHeight);
mFooterImageView.setVisibility(View.VISIBLE);
mFooterImageView.setImageResource(R.drawable.ic_pulltorefresh_arrow_up);
mFooterTextView.setText(R.string.pull_to_refresh_footer_pull_label);
mFooterProgressBar.setVisibility(View.GONE);
mFooterState = PULL_TO_REFRESH;
}
private int getHeaderTopMargin() {
LayoutParams params = (LayoutParams) mHeaderView.getLayoutParams();
return params.topMargin;
}
public void setOnHeaderRefreshListener(OnHeaderRefreshListener headerRefreshListener) {
mOnHeaderRefreshListener = headerRefreshListener;
}
public void setOnFooterRefreshListener(OnFooterRefreshListener footerRefreshListener) {
mOnFooterRefreshListener = footerRefreshListener;
}
public interface OnFooterRefreshListener {
public void onFooterRefresh(PullToRefreshView view);
}
public interface OnHeaderRefreshListener {
public void onHeaderRefresh(PullToRefreshView view);
}
public boolean isEnablePullTorefresh() {
return enablePullTorefresh;
}
public void setEnablePullTorefresh(boolean enablePullTorefresh) {
this.enablePullTorefresh = enablePullTorefresh;
}
public boolean isEnablePullLoadMoreDataStatus() {
return enablePullLoadMoreDataStatus;
}
public void setEnablePullLoadMoreDataStatus(boolean enablePullLoadMoreDataStatus) {
this.enablePullLoadMoreDataStatus = enablePullLoadMoreDataStatus;
}
public void setFooter(boolean footer){
isFooter = footer;
}
/**
* 头部刷新动画
*/
public void changeDrawable() {
int margin = params.topMargin;
if(margin < HEADER_OFFERT) {
mCurrentDragPercent = ((float) mHeaderViewHeight + margin)/(float) mHeaderViewHeight;
mCurrentDragPercent *= mCurrentDragPercent;
if(mCurrentDragPercent > 0.02 && mCurrentDragPercent < 0.9) {//下拉过程的动画
isShow = false;
if(showDrawable == null)
showDrawable = getResources().getDrawable(R.drawable.pull_end_image_frame_00);
Drawable one = zoomDrawable(showDrawable, mCurrentDragPercent);
mHeaderImageView.setImageDrawable(one);
} else if(mCurrentDragPercent >= 0.9 && !isShow) {//刷新过程的动画
AnimationDrawable drawable = (AnimationDrawable) getResources().getDrawable(R.drawable.meimei_showing2);
mHeaderImageView.setImageDrawable(drawable);
drawable.start();
isShow = true;
}
}
}
/**
* 改变图片的尺寸
* @param drawable
* @param s
* @return
*/
private Drawable zoomDrawable(Drawable drawable, float s) {
int width = drawable.getIntrinsicWidth();
int height = drawable.getIntrinsicHeight();
Bitmap oldbmp = drawableToBitmap(drawable);// drawable转换成bitmap
Matrix matrix = new Matrix(); // 创建操作图片用的Matrix对象
matrix.postScale(s, s); // 设置缩放比例
if(width <= 0 || height <= 0) return null;
Bitmap newbmp = Bitmap.createBitmap(oldbmp, 0, 0, width, height, matrix, true); // 建立新的bitmap,其内容是对原bitmap的缩放后的图
return new BitmapDrawable(getResources(), newbmp); // 把bitmap转换成drawable并返回
}
private Bitmap drawableToBitmap(Drawable drawable) {// drawable 转换成bitmap
BitmapDrawable bitmapDrawable = (BitmapDrawable) drawable;
return bitmapDrawable.getBitmap();
}
}
| [
"Administrator@USER-20160722FW"
] | Administrator@USER-20160722FW |
51984c9c7398e28b3f8930a8e601b8de732462e7 | 2e5bdebf7d235a1b543e5c271a41798c1d20c2bd | /src/packagesix/Consumer.java | a98141fbfada670ff0f83dffbe428c65ac0d3f2f | [] | no_license | ra6yee/learnOfJava | f2c565a89d14e12f6a209f0bff2c7abc15c95ab1 | a575915721923cf4d654e78ce2d37c94074a647d | refs/heads/master | 2020-12-08T09:10:06.268212 | 2020-01-10T01:54:42 | 2020-01-10T01:54:42 | 232,942,960 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package packagesix;
import java.util.concurrent.TransferQueue;
public class Consumer implements Runnable {
private TransferQueue<ShareItem> queue;
public Consumer( TransferQueue<ShareItem> queue) {
this.queue = queue;
}
@Override
public void run() {
try {
Thread.sleep(450);
} catch (InterruptedException e) {
// e.printStackTrace();
}
while (true){
try {
System.out.format("Processing %s",queue.take().toString()+"\n");
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
return;
}
}
}
}
| [
"ra6yee@mail.ru"
] | ra6yee@mail.ru |
f88acf8e1cb45f56e9a7f8fd5ad19abae2f18f62 | a0a7a637fcaac08217a40e8191f70c1c9426ba1c | /backend/src/main/java/london/stambourne6/swimlog/model/Database.java | 3dbb444e60450996cdfb3b4fba57d743ac0732cc | [] | no_license | kovalevvlad/swimlog | 551450aa6382488f90036519213226ce876dceab | 9a7ad293d6251b9e8fb9a8baaf8c88543946d04b | refs/heads/master | 2021-01-13T14:04:48.495244 | 2016-12-18T17:36:26 | 2016-12-18T17:36:26 | 76,196,749 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 14,012 | java | package london.stambourne6.swimlog.model;
import com.google.common.base.Preconditions;
import london.stambourne6.swimlog.controller.PlaintextUserCredentials;
import london.stambourne6.swimlog.controller.PlaintextUserCredentialsWithRole;
import org.apache.commons.io.IOUtils;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.sql.*;
import java.sql.Date;
import java.time.LocalDate;
import java.util.*;
public class Database {
public final static String DEFAULT_USERNAME = "admin";
public final static String DEFAULT_PASSWORD = "changeme";
private final File dataFile;
private PasswordManager pm;
public Database(@NotNull File dataFile, @NotNull PasswordManager pm) {
Preconditions.checkArgument(dataFile.getName().endsWith(".mv.db"), "Database filename must end with .mv.db");
this.pm = pm;
try {
Class.forName("org.h2.Driver");
this.dataFile = dataFile;
if (dataFile.length() == 0) {
try (Connection con = newConnection()) {
// Install schema
String initQuery = IOUtils.toString(
this.getClass().getClassLoader().getResourceAsStream("initialise_db.sql"),
Charset.forName("UTF-8"));
try (Statement st = con.createStatement()) {
st.execute(initQuery);
}
// Install default admin user
insertUser(new PlaintextUserCredentials(DEFAULT_USERNAME, DEFAULT_PASSWORD), UserRole.Admin);
}
}
} catch(ClassNotFoundException e){
throw new RuntimeException("Unable to load H2 drivers", e);
} catch (SQLException e) {
throw new RuntimeException("Encountered issues when setting up DB schema", e);
} catch (IOException e) {
throw new RuntimeException("Unable to load schema SQL file", e);
}
}
public @NotNull User insertUser(@NotNull PlaintextUserCredentials user, UserRole role) {
byte[] salt = pm.randomSalt();
byte[] hashedPassword = pm.hashPassword(user.getPassword(), salt);
return runWithPreparedStatement(
"INSERT INTO \"user\" (name, role_id, salt, hashed_password)\n" +
"SELECT ?, id, ?, ? FROM \"role\" WHERE name = ?",
st -> {
st.setString(1, user.getUsername());
st.setBytes(2, salt);
st.setBytes(3, hashedPassword);
st.setString(4, role.name());
st.executeUpdate();
try (ResultSet generatedKeys = st.getGeneratedKeys()) {
Preconditions.checkState(generatedKeys.next());
int userId = generatedKeys.getInt(1);
return new User(userId, user.getUsername(), role, salt, hashedPassword);
}
});
}
public void deleteUser(@NotNull User user) {
runWithPreparedStatement(
"DELETE FROM swim WHERE user_id = ?",
st -> {
st.setInt(1, user.id());
st.execute();
});
runWithPreparedStatement(
"DELETE FROM \"user\" WHERE id = ?",
st -> {
st.setInt(1, user.id());
st.execute();
});
}
public @Null User userForId(int userId) {
return runWithPreparedStatement(
"SELECT u.name, r.name, u.salt, u.hashed_password FROM \"user\" AS u\n" +
"JOIN \"role\" AS r ON r.id = u.role_id WHERE u.id = ?",
st -> {
st.setInt(1, userId);
try (ResultSet rs = st.executeQuery()) {
if (!rs.next()) {
return null;
} else {
User fetchedUser = new User(userId, rs.getString(1), UserRole.valueOf(rs.getString(2)), rs.getBytes(3), rs.getBytes(4));
Preconditions.checkState(!rs.next(), String.format("Got multiple users for userId = %d", userId));
return fetchedUser;
}
}
});
}
public @Null User userForName(@NotNull String username) {
return runWithPreparedStatement(
"SELECT u.id, r.name, u.salt, u.hashed_password FROM \"user\" AS u\n" +
"JOIN \"role\" AS r ON r.id = u.role_id WHERE u.name = ?",
st -> {
st.setString(1, username);
try (ResultSet rs = st.executeQuery()) {
if (!rs.next()) {
return null;
} else {
User fetchedUser = new User(rs.getInt(1), username, UserRole.valueOf(rs.getString(2)), rs.getBytes(3), rs.getBytes(4));
Preconditions.checkState(!rs.next(), String.format("Got multiple users for name = %s", username));
return fetchedUser;
}
}
});
}
private @Null User userForUsername(@NotNull String username) {
Preconditions.checkArgument(username != null, "username must not be null");
return runWithPreparedStatement(
"SELECT u.id, r.name, u.salt, u.hashed_password FROM \"user\" AS u\n" +
"JOIN \"role\" AS r ON r.id = u.role_id WHERE u.name = ?",
st -> {
st.setString(1, username);
try (ResultSet rs = st.executeQuery()) {
if (!rs.next()) {
return null;
} else {
User fetchedUser = new User(rs.getInt(1), username, UserRole.valueOf(rs.getString(2)), rs.getBytes(3), rs.getBytes(4));
Preconditions.checkState(!rs.next(), String.format("Got multiple users for username = %s", username));
return fetchedUser;
}
}
});
}
public void updateUser(@NotNull User toUpdate, @NotNull PlaintextUserCredentialsWithRole update) {
runWithPreparedStatement(
"UPDATE \"user\" u\n" +
"SET name = ?, role_id = (SELECT id FROM \"role\" AS r WHERE r.name = ?), salt = ?, hashed_password = ?\n" +
"WHERE u.id = ?",
st -> {
byte[] salt = pm.randomSalt();
byte[] hashedPassword = pm.hashPassword(update.getPassword(), salt);
st.setString(1, update.getUsername());
st.setString(2, update.getRole().name());
st.setBytes(3, salt);
st.setBytes(4, hashedPassword);
st.setInt(5, toUpdate.id());
st.execute();
});
}
public @NotNull Set<User> users() {
String query = "SELECT u.id, r.name, u.name, u.salt, u.hashed_password FROM \"user\" AS u JOIN \"role\" AS r on r.id = u.role_id";
return runWithPreparedStatement(query, st -> {
Set<User> result = new HashSet<>();
try (ResultSet rs = st.executeQuery()) {
while (rs.next()) {
int id = rs.getInt(1);
UserRole role = UserRole.valueOf(rs.getString(2));
String name = rs.getString(3);
byte[] salt = rs.getBytes(4);
byte[] hashedPassword = rs.getBytes(5);
result.add(new User(id, name, role, salt, hashedPassword));
}
}
return result;
});
}
public @NotNull
SwimWithId insertSwim(@NotNull Swim swim) {
return runWithPreparedStatement(
"INSERT INTO swim (user_id, \"date\", distance_km, duration_seconds) VALUES (?, ?, ?, ?)",
st -> {
st.setInt(1, swim.getUserId());
st.setDate(2, Date.valueOf(swim.getDate()));
st.setDouble(3, swim.getDistanceKm());
st.setDouble(4, swim.getDurationSeconds());
st.execute();
try (ResultSet generatedKeys = st.getGeneratedKeys()) {
Preconditions.checkState(generatedKeys.next());
return SwimWithId.fromSwimState(generatedKeys.getInt(1), swim);
}
});
}
public void deleteSwim(@NotNull SwimWithId swim) {
runWithPreparedStatement(
"DELETE FROM swim WHERE id = ?;",
st -> {
st.setInt(1, swim.getId());
st.execute();
});
}
public void updateSwim(@NotNull SwimWithId toUpdate, @NotNull Swim update) {
runWithPreparedStatement(
"UPDATE swim\n" +
"SET user_id = ?, \"date\" = ?, distance_km = ?, duration_seconds = ?\n" +
"WHERE id = ?",
st -> {
st.setInt(1, update.getUserId());
st.setDate(2, Date.valueOf(update.getDate()));
st.setDouble(3, update.getDistanceKm());
st.setDouble(4, update.getDurationSeconds());
st.setInt(5, toUpdate.getId());
st.execute();
});
}
public @Null
SwimWithId swimForId(int swimId) {
return runWithPreparedStatement("SELECT \"date\", duration_seconds, distance_km, user_id FROM swim WHERE id = ?", st -> {
st.setInt(1, swimId);
try (ResultSet rs = st.executeQuery()) {
if (!rs.next()) {
return null;
} else {
SwimWithId fetchedSwim = new SwimWithId(swimId, rs.getDate(1).toLocalDate(), rs.getDouble(3), rs.getDouble(2), rs.getInt(4));
Preconditions.checkState(!rs.next(), String.format("Got multiple users for userId = %d", swimId));
return fetchedSwim;
}
}
});
}
public @NotNull Set<SwimWithId> swims() {
return swimsWithFilter("", st -> {});
}
public @NotNull Set<SwimWithId> swimsForUser(User user) {
return swimsWithFilter(" WHERE user_id = ?", st -> st.setInt(1, user.id()));
}
public @Null User userForCreadentialsIfValid(PlaintextUserCredentials userCredentials) {
User user = userForUsername(userCredentials.getUsername());
boolean credentialsValid = user != null && Arrays.equals(user.hashedPassword(), pm.hashPassword(userCredentials.getPassword(), user.salt()));
return credentialsValid ? user : null;
}
private Set<SwimWithId> swimsWithFilter(String sqlFilter, PreparedStatementConsumer statementInitializer) {
String query = "SELECT user_id, id, \"date\", duration_seconds, distance_km FROM swim";
return runWithPreparedStatement(query + sqlFilter, st -> {
statementInitializer.run(st);
Set<SwimWithId> result = new HashSet<>();
try (ResultSet rs = st.executeQuery()) {
while (rs.next()) {
int userId = rs.getInt(1);
int id = rs.getInt(2);
LocalDate date = rs.getDate(3).toLocalDate();
double duration = rs.getDouble(4);
double distance = rs.getDouble(5);
result.add(new SwimWithId(id, date, distance, duration, userId));
}
}
return result;
});
}
private Connection newConnection() throws SQLException {
String absolutePath = dataFile.getAbsolutePath();
String connectionString = String.format("jdbc:h2:%s", absolutePath.substring(0, absolutePath.length() - ".mv.db".length()));
Connection con = DriverManager.getConnection(connectionString, "sa", "");
con.setAutoCommit(true);
return con;
}
private interface PreparedStatementConsumer { void run(PreparedStatement st) throws SQLException; }
private interface ProducingPreparedStatementConsumer<T> { T run(PreparedStatement st) throws SQLException; }
private <T> T runWithPreparedStatement(String queryToPrepare, ProducingPreparedStatementConsumer<T> func) {
return runWithSqlErrors(() -> {
try (Connection con = newConnection()) {
try (PreparedStatement st = con.prepareStatement(queryToPrepare)) {
return func.run(st);
}
}
});
}
private void runWithPreparedStatement(String queryToPrepare, PreparedStatementConsumer func) {
runWithSqlErrors(() -> {
try (Connection con = newConnection()) {
try (PreparedStatement st = con.prepareStatement(queryToPrepare)) {
func.run(st);
}
}
});
}
private interface ProducerThrowingSqlExceptions<T> { T run() throws SQLException; }
private interface RunnableThrowingSqlExceptions { void run() throws SQLException; }
private static <T> T runWithSqlErrors(ProducerThrowingSqlExceptions<T> r) {
try {
return r.run();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
private static void runWithSqlErrors(RunnableThrowingSqlExceptions r) {
try {
r.run();
} catch (SQLException e) {
throw new RuntimeException(e);
}
}
} | [
"kovalev.vladimir1990@gmail.com"
] | kovalev.vladimir1990@gmail.com |
3265764c350711a156b8a15c4ec88c095e590d7d | 75c497d8c726ae9941ce75fb0be20de9b1c98782 | /src/main/java/br/com/jorgemendesjr/cursomc/repositories/CategoriaRepository.java | 82ff1dbe837269733ede220c0936f8b5ec491686 | [] | no_license | jorgemendesjr/cursomc | 9cb8205e921f07b27d1d9585b8ee27ea8d75d9a9 | fba7cb52818eebe32f7457260d4bd73e19adfe0e | refs/heads/master | 2021-09-05T05:19:34.910247 | 2018-01-24T00:05:32 | 2018-01-24T00:05:32 | 114,402,710 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 318 | java | package br.com.jorgemendesjr.cursomc.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import br.com.jorgemendesjr.cursomc.domain.Categoria;
@Repository
public interface CategoriaRepository extends JpaRepository<Categoria, Integer>
{
}
| [
"jorgemendesjr@outlook.com"
] | jorgemendesjr@outlook.com |
ab456b98a2d051d0c85cd34db901073d0220aa54 | 99448792260e964acd4422844c7ed1e47c35770a | /src/com/glub/util/GTFileSystemView.java | a1534e5e61b18b61ce0f5b6ea699e872e7fca4c4 | [
"Apache-2.0"
] | permissive | berrybue/secureftp | 756e9473d992388fed7c7c4d4657454905cade21 | d8964e1ced2e3168c29b36d82c60724c7e277f64 | refs/heads/master | 2021-01-22T09:48:34.599720 | 2013-07-28T13:18:04 | 2013-07-28T13:18:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,744 | java |
//*****************************************************************************
//*
//* (c) Copyright 2002. Glub Tech, Incorporated. All Rights Reserved.
//*
//* $Id: GTFileSystemView.java 37 2009-05-11 22:46:15Z gary $
//*
//*****************************************************************************
package com.glub.util;
import javax.swing.filechooser.*;
import java.io.*;
import java.util.*;
public class GTFileSystemView extends FileSystemView {
public GTFileSystemView() {
super();
}
public File createNewFolder( File file ) throws IOException {
return FileSystemView.getFileSystemView().createNewFolder( file );
}
public static String getProperSystemDisplayName( File file ) {
String result = getFileSystemView().getSystemDisplayName( file );
return result;
}
public static File[] getProperRoots() {
File[] result = getFileSystemView().getRoots();
if ( Util.isMacOS() ) {
ArrayList resultList = new ArrayList();
File volumes = new File("/Volumes");
File[] mountedDisks = volumes.listFiles();
int rootDrive = 0;
for ( int i = 0; i < mountedDisks.length; i++ ) {
try {
if ( mountedDisks[i].getCanonicalPath().equals("/") ) {
rootDrive = i;
resultList.add( mountedDisks[i] );
}
}
catch ( IOException ioe ) {}
}
for ( int i = 0; i < mountedDisks.length; i++ ) {
if ( rootDrive == i ) {
continue;
}
if( mountedDisks[i].isDirectory() ) {
resultList.add( mountedDisks[i] );
}
}
File[] tempObject = new File[resultList.size()];
result = (File[])resultList.toArray( tempObject );
}
return result;
}
}
| [
"gcohen@adobe.com"
] | gcohen@adobe.com |
3150193a35c985a2c006fdd7002e902ede26621d | 588aaaa3e66bf3e988d1294af9ef78f3b8b9ce74 | /src/test/java/org/usgbc/regression/CommunityRegistrationPriceValidationTest.java | 2b8ed714344a2853a167c0ec8b101336cbaf6113 | [] | no_license | suruchi10/usgbc | 76a393900c6ab363a496aae9225e5801dba57616 | 7a60ced951d10da2c0450a7772c155e925e9c779 | refs/heads/master | 2021-05-07T07:35:24.130831 | 2017-12-14T12:07:30 | 2017-12-14T12:07:30 | 103,144,672 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,413 | java | package org.usgbc.regression;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.PageFactory;
import org.testng.annotations.Test;
import org.usgbc.business.CommunityRegistration;
import org.usgbc.business.CommunityRegistrationPriceValidation;
import org.usgbc.utility.Base;
import org.usgbc.utility.CommunityRegistrationFormData;
import org.usgbc.utility.ReusableMethods;
import com.relevantcodes.extentreports.LogStatus;
public class CommunityRegistrationPriceValidationTest extends Base {
@Test(priority=0)
public void testCommunityRegistrationForCostValidationDefault35() throws Exception {
System.out.println("Communtiy Registration Module for cost validationas default $35");
CommunityRegistrationPriceValidation communityRegistrationPriceValidation = PageFactory.initElements(driver,CommunityRegistrationPriceValidation.class);
try {
test= extent.startTest("Communtiy Registration Module for cost validation default $35");
test.log(LogStatus.INFO, "Test Started");
communityRegistrationPriceValidation.CommunityRegistartionModuleForCostValidationDefault35();
System.out.println("Communtiy Registration Module for cost validation default $35 Test Finished");
} catch (Throwable t) {
System.out.println(t.getLocalizedMessage());
Error e1 = new Error(t.getMessage());
e1.setStackTrace(t.getStackTrace());
throw e1;
}
}
@Test(priority=1)
public void testCommunityRegistrationForCostValidationStudentMember50() throws Exception {
System.out.println("Communtiy Registration Module for cost validation as Student Member $50");
CommunityRegistrationPriceValidation communityRegistrationPriceValidation = PageFactory.initElements(driver,CommunityRegistrationPriceValidation.class);
try {
test= extent.startTest("Communtiy Registration Module for cost validation as Student Member $50");
test.log(LogStatus.INFO, "Test Started");
communityRegistrationPriceValidation.CommunityRegistrationForCostValidationStudentMember50();
System.out.println("Communtiy Registration Module for cost validation as Student Member $50 Test Finished");
} catch (Throwable t) {
System.out.println(t.getLocalizedMessage());
Error e1 = new Error(t.getMessage());
e1.setStackTrace(t.getStackTrace());
throw e1;
}
}
@Test(priority=2)
public void testCommunityRegistrationForCostValidationEmergingprofessionalMember75() throws Exception {
System.out.println("Communtiy Registration Module for cost validation as Emerging professional Member $75");
CommunityRegistrationPriceValidation communityRegistrationPriceValidation = PageFactory.initElements(driver,CommunityRegistrationPriceValidation.class);
try {
test= extent.startTest("Communtiy Registration Module for cost validation as Emerging professional Member $75");
test.log(LogStatus.INFO, "Test Started");
communityRegistrationPriceValidation.CommunityRegistrationForCostValidationEmergingProfessionalMember75();
System.out.println("Communtiy Registration Module for cost validationas as Emerging professional Member $75 Test Finished");
} catch (Throwable t) {
System.out.println(t.getLocalizedMessage());
Error e1 = new Error(t.getMessage());
e1.setStackTrace(t.getStackTrace());
throw e1;
}
}
}
| [
"suruchisinha.10@gmail.com"
] | suruchisinha.10@gmail.com |
f5544db00e764803856bef93dc3cfba23a35689a | 9377c916505a62748c4bb0707095efdd7f758635 | /app/src/main/java/cn/sanshaoxingqiu/ssbm/module/login/bean/AuthInfo.java | 2cf89ffcb7fdc34cf0865011154ba0cabed9227f | [] | no_license | yuexingxing/sxxq_android | 5f54e1b0daa83fd260b986a5c78423e96cbecdb6 | 641ebe2b09d9ee5c9d9e1a256116ca45eee6a0c0 | refs/heads/master | 2023-01-01T23:22:11.988072 | 2020-10-10T10:23:31 | 2020-10-10T10:23:31 | 281,279,599 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,289 | java | package cn.sanshaoxingqiu.ssbm.module.login.bean;
/**
* yxx
* <p>
* ${Date} ${time}
**/
public class AuthInfo {
public String getUid() {
return uid;
}
public void setUid(String uid) {
this.uid = uid;
}
public String getOpenid() {
return openid;
}
public void setOpenid(String openid) {
this.openid = openid;
}
public String getUnionid() {
return unionid;
}
public void setUnionid(String unionid) {
this.unionid = unionid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getIconurl() {
return iconurl;
}
public void setIconurl(String iconurl) {
this.iconurl = iconurl;
}
public String uid;
public String openid;
public String unionid;
public String name;
public String gender;
public String iconurl;
public String platform;
public String getPlatform() {
return platform;
}
public void setPlatform(String platform) {
this.platform = platform;
}
}
| [
"670176656@qq.com"
] | 670176656@qq.com |
aee332000bc9946afca33336876b4c5caab58c55 | 0f85584be94b58c9a385953cf87229dcc2a7f589 | /src/Enemys/Factory.java | c29dc542b0f376418a6625bd2356e74a5a9573b8 | [] | no_license | Abstractize/Invaders | ee6668a523d18a3c10f192a9d837241d9d2df1f7 | ef80648072f670c205ccd2f24141b335ca339cae | refs/heads/master | 2021-09-12T21:41:04.989899 | 2018-04-21T03:38:58 | 2018-04-21T03:38:58 | 124,340,367 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 227 | java | package Enemys;
//Abstract Factory
public interface Factory {
public SingleRow createSingleRow(int Width,int level);
public row createOther(int Width,int level);
public CircularRow createCircularRow(int Width,int level);
}
| [
"gababarca@hotmail.com"
] | gababarca@hotmail.com |
187ad1d9baa11c99e7bec4da2f4f2674572501a7 | 5786a21ad105e413e81f7d3bd8953e0a092b0d07 | /src/TestBoard.java | 8821f3bb6ccef5580b25443b2cfa3371a585ec49 | [] | no_license | nishx09/2048-clone | fb86508ca95a55de40074a489296d8a089325e38 | 1b431e67880a7924f6235a7a7c34885ea1f7a96a | refs/heads/main | 2023-04-19T10:48:08.174200 | 2021-05-12T20:39:20 | 2021-05-12T20:39:20 | 366,847,321 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,870 | java | /**
* @file: TestBoard.java
* @Author: Nishant Garg
* @Date: April 11, 2021
* @Description: Tests for Board.java
*/
package src;
import org.junit.*;
import static org.junit.Assert.*;
public class TestBoard {
public Tile t1;
public Tile t2;
public Tile t3;
public Tile t4;
public Tile t5;
public Board b1;
public Board b2;
public Board b3;
public Board b4;
public Board b5;
@Before
public void setUp() {
t1 = new Tile();
t2 = new Tile(4);
t3 = new Tile(8);
t4 = new Tile(32);
t5 = new Tile(2048);
Tile[][] tt1 = new Tile[][]{{t1, t1, t3, t1}, {t1, t1, t3, t1}, {t1, t1, t1, t1}, {t1, t1, t1, t1}};
b1 = new Board(tt1);
Tile[][] tt2 = new Tile[][]{{t4, t4, t1, t1}, {t1, t2, t2, t1}, {t1, t1, t1, t1}, {t3, t3, t1, t1}};
b2 = new Board(tt2);
Tile[][] tt3 = new Tile[][]{{t1, t1, t4, t4}, {t1, t1, t2, t2}, {t1, t1, t1, t1}, {t3, t4, t1, t5}};
b3 = new Board(tt3);
b4 = new Board(5);
Tile[][] tt5 = new Tile[][]{{t4, t4, t1, t3}, {t1, t1, t2, t5}, {t2, t3, t4, t1}, {t3, t5, t1, t1}};
b5 = new Board(tt5);
}
@After
public void tearDown() {
b1 = null;
b2 = null;
b3 = null;
b4 = null;
b5 = null;
}
@Test
public void testgetScore1() {
b1.up();
Assert.assertEquals(16, b1.getScore());
}
@Test
public void testgetScore2() {
b2.left();
Assert.assertEquals(88, b2.getScore());
}
@Test
public void testhighestTile1() {
Assert.assertEquals(8, b1.highestTile());
}
@Test
public void testhighestTile2() {
Assert.assertEquals(32, b2.highestTile());
}
@Test
public void testspawn() {
Board b = new Board();
b.spawnRandom();
assertTrue(b.highestTile() == 2 || b.highestTile() == 4);
}
@Test
public void testmove1() {
b1.move(MoveT.w);
assertEquals(16, b1.getScore());
}
@Test
public void testmove2() {
b2.move(MoveT.a);
assertEquals(88, b2.getScore());
}
@Test
public void testmove3() {
b2.move(MoveT.s);
assertEquals(72, b2.getScore());
}
@Test
public void testmove4() {
b3.move(MoveT.d);
assertEquals(72, b3.getScore());
}
@Test
public void testgameWon1() {
assertTrue(b3.gameWon());
}
@Test
public void testgameWon2() {
assertFalse(b2.gameWon());
}
@Test
public void testgameOver1() {
assertTrue(b4.gameOver());
}
@Test
public void testgameOver2() {
assertFalse(b5.gameOver());
}
@Test
public void testup1() {
b1.up();
assertEquals(16, b1.getScore());
}
@Test
public void testup2() {
b5.up();
assertEquals(0, b5.getScore());
}
@Test
public void testdown1() {
b2.down();
assertEquals(72, b2.getScore());
}
@Test
public void testdown2() {
Tile[][] tt1 = new Tile[][]{{t1, t1, t1, t1}, {t1, t1, t1, t1}, {t2, t1, t4, t1}, {t2, t1, t4, t1}};
Board b = new Board(tt1);
b.down();
assertEquals(72, b.getScore());
}
@Test
public void testleft1() {
b2.left();
assertEquals(88, b2.getScore());
}
@Test
public void testleft2() {
b5.left();
assertEquals(64, b5.getScore());
}
@Test
public void testright1() {
Tile[][] tt1 = new Tile[][]{{t4, t1, t3, t3}, {t4, t1, t1, t1}, {t1, t1, t1, t3}, {t1, t1, t1, t2}};
Board b = new Board(tt1);
b.right();
assertEquals(16, b.getScore());
}
@Test
public void testright2() {
b3.right();
assertEquals(72, b3.getScore());
}
}
| [
"gargn4@mcmaster.ca"
] | gargn4@mcmaster.ca |
fdedac526fb44f4e04de3aca856ff8ea6f4b2dbc | 587f50e0178aa497afeea24cdab0f3e933af025c | /joker-engine/src/main/java/cs/bilkent/joker/engine/pipeline/OperatorReplicaStatus.java | cc5cd983a5ce85b61f2e316e77fd54a994078748 | [] | no_license | metanet-ci/joker | 226edad3bd271b32998cfdcc073a7c1bac8a8f14 | 33ab2c8fe3e6e3deb410e60f0709b42f7df3afbc | refs/heads/master | 2021-07-06T23:13:36.887272 | 2018-04-29T15:53:12 | 2018-04-29T15:53:12 | 43,027,635 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,228 | java | package cs.bilkent.joker.engine.pipeline;
import cs.bilkent.joker.operator.InitCtx;
import cs.bilkent.joker.operator.Operator;
import cs.bilkent.joker.operator.scheduling.ScheduleNever;
/**
* @see OperatorReplica
*/
public enum OperatorReplicaStatus
{
/**
* Indicates that the operator has not been initialized yet.
*/
INITIAL,
/**
* Indicates that initialization of an operator has failed. It may be because {@link Operator#init(InitCtx)} method
* throws an exception or it returns an invalid scheduling strategy.
*/
INITIALIZATION_FAILED,
/**
* Indicates that the operator is being invoked with its scheduling strategy successfully.
*/
RUNNING,
/**
* Indicates that normal running schedule of an operator has ended and it is completing its invocations. It may be because
* operator's all input ports are closed or an operator invocation returns {@link ScheduleNever} as new scheduling strategy.
*/
COMPLETING,
/**
* Indicates that an operator has completed its invocations and there will not be any new invocation.
*/
COMPLETED,
/**
* Indicates that an operator has been shut down.
*/
SHUT_DOWN
}
| [
"ebkahveci@gmail.com"
] | ebkahveci@gmail.com |
5a7e382f3bbe84ceff4ff096471865ceedc556db | 507a6a3d1c47d81aaf17b58a1e11bc8c4d018998 | /DB/DB project/Music/src/musicdb/analyzer/arc/LinkManager3.java | e11a2f46e6c8ef1d828ce16559508ef44f8ab734 | [] | no_license | srisachin/Courses | c6504bb62bc8efcc3f060905356ffd9c90f51d4e | a253fa90bc0f21adae9e321b2e6388cc99113eb7 | refs/heads/master | 2021-01-10T03:43:32.495418 | 2015-10-01T12:12:38 | 2015-10-01T12:12:38 | 43,493,771 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,643 | java | package musicdb.analyzer.arc;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import musicdb.analyzer.DB;
public class LinkManager3 {
private HashMap<String, Integer> countryHash;
private HashMap<Integer, Integer> decadeHash;
public LinkManager3() {
}
public ArcDiagramData getData() {
Connection con = null, con2 = null;
Statement st = null;
ResultSet rs = null;
ArcDiagramData arcDiagramData = new ArcDiagramData();
try {
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost:3306/database_project_db2";
String user = "root";
String password = "1234";
arcDiagramData.addNode("196", 0);
arcDiagramData.addNode("197", 0);
arcDiagramData.addNode("198", 0);
arcDiagramData.addNode("199", 0);
arcDiagramData.addNode("200", 0);
// arcDiagramData.addNode("210", 1);
decadeHash = new HashMap<Integer, Integer>();
countryHash = new HashMap<String, Integer>();
// decadeHash.put(196, 0);
// decadeHash.put(197, 1);
// decadeHash.put(198, 2);
// decadeHash.put(199, 3);
// decadeHash.put(200, 4);
// decadeHash.put(210, 5);
int index = 5;
//con = DriverManager.getConnection(url, user, password);
DB db_Connection = new DB();
con = db_Connection.getConnection();
st = con.createStatement();
// rs =
// st.executeQuery("SELECT * FROM database_project_db2.genre_summary order by count desc limit 20;");
// rs =
// st.executeQuery("SELECT * FROM database_project_db2.genre_country_1 order by count desc limit 100;");
// rs =
// st.executeQuery("SELECT * FROM database_project_db2.genre_country_1 where name='Rock Music' or name='Hip hop music' or name='Alternative rock' or name='Electronic music' or name='Blues' or name='Jazz' or name='Country music' or name='Pop music' or name='Indie rock' or name='Punk rock' or name='Folk music' or name='Religious music' or name='Heavy metal' or name='Dance music' or name='Rock and roll' or name='Christian music' order by count desc limit 200;");
rs = st.executeQuery("SELECT * FROM database_project_db2.top_country;");
String country;
double count;
int countryIndex, decade196, decade197, decade198, decade199, decade200, genreIndex, e_count;
double d196_n, d197_n, d198_n, d199_n, d200_n;
while (rs.next()) {
country = rs.getString(1);
decade196 = rs.getInt(2);
decade197 = rs.getInt(3);
decade198 = rs.getInt(4);
decade199 = rs.getInt(5);
decade200 = rs.getInt(6);
d196_n = rs.getDouble(8) + 1.5;
d197_n = rs.getDouble(9) + 1.5;
d198_n = rs.getDouble(10) + 1.5;
d199_n = rs.getDouble(11) + 1.5;
d200_n = rs.getDouble(12) + 1.5;
if (countryHash.containsKey(country)) {
countryIndex = countryHash.get(country);
} else {
countryIndex = index;
countryHash.put(country, countryIndex);
arcDiagramData.addNode(country, 1);
index++;
}
// if (decadeHash.containsKey(genre)) {
// genreIndex = decadeHash.get(genre);
// } else {
// genreIndex = index;
// decadeHash.put(genre, index);
// arcDiagramData.addNode(genre, 1);
// index++;
// }
arcDiagramData.addLink(countryIndex, 0, d196_n, decade196);
arcDiagramData.addLink(countryIndex, 1, d197_n, decade197);
arcDiagramData.addLink(countryIndex, 2, d198_n, decade198);
arcDiagramData.addLink(countryIndex, 3, d199_n, decade199);
arcDiagramData.addLink(countryIndex, 4, d200_n, decade200);
}
} catch (Exception e) {
e.printStackTrace();
}
return arcDiagramData;
}
}
| [
"sri.sachin@hotmail.com"
] | sri.sachin@hotmail.com |
5b67658fe1523b34dd8f51567d980e3cba5bd98c | 0deae7e623fb20902031da8325978209051ca69c | /app/src/main/java/com/example/jobshare/menu/DetailActivity.java | 3c9124206ad6146299374474f6c8931a7ea84bbe | [] | no_license | Xingyann/FYP_2015P2_JobShare | 144a08ac3ebe13dcedc64619a9882960af60d020 | ab63e5ed868b1b61e2a71638ccd3dbadb4897f1b | refs/heads/master | 2021-01-15T22:29:09.517434 | 2015-08-21T02:57:23 | 2015-08-21T02:57:23 | 41,131,081 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,383 | java | package com.example.jobshare.menu;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
public class DetailActivity extends Activity implements View.OnClickListener {
private DisplayImageOptions options;
private ImageLoader imageLoader;
private TextView tvTitle, tvDesc,liketext,disliketext;
private ImageView imgView,likealert,dislikealert;
String[] spinnerValues = {
"Comments(10)",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous",
"Anonymous"};
String[] spinnerSubs = {
"",
"Roughly what is the job like?",
"Wah still need to work at night?",
"Is the job operating at 24/7?",
"Did you enjoy your job?",
"So far what you like about this job?",
"How long have you been working?",
"Is it hard?",
"What opportunities?",
"Did you get to learn something?",};
int total_images[] = {
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile,
R.drawable.profile};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
Spinner mySpinner = (Spinner) findViewById(R.id.spinner_show);
mySpinner.setAdapter(new MyAdapter(this, R.layout.custom_spinner, spinnerValues));
tvTitle = (TextView) findViewById(R.id.tvtitle);
tvDesc = (TextView) findViewById(R.id.tvdesc);
imgView = (ImageView) findViewById(R.id.imgdesc);
Bundle b = getIntent().getExtras();
String title = b.getString("title");
String desc = b.getString("desc");
tvTitle.setText(title);
tvDesc.setText(desc);
ImageView likealert = (ImageView) findViewById(R.id.like);
likealert.setOnClickListener(this);
ImageView dislikealert = (ImageView) findViewById(R.id.dislike);
dislikealert.setOnClickListener(this);
}
public class MyAdapter extends ArrayAdapter<String> {
public MyAdapter(Context ctx, int txtViewResourceId, String[] objects) {
super(ctx, txtViewResourceId, objects);
}
@Override
public View getDropDownView(int position, View cnvtView, ViewGroup prnt) {
return getCustomView(position, cnvtView, prnt);
}
@Override
public View getView(int pos, View cnvtView, ViewGroup prnt) {
return getCustomView(pos, cnvtView, prnt);
}
public View getCustomView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = getLayoutInflater();
View mySpinner = inflater.inflate(R.layout.custom_spinner, parent, false);
TextView main_text = (TextView) mySpinner.findViewById(R.id.text_main_seen);
main_text.setText(spinnerValues[position]);
TextView subSpinner = (TextView) mySpinner.findViewById(R.id.sub_text_seen);
subSpinner.setText(spinnerSubs[position]);
ImageView left_icon = (ImageView) mySpinner.findViewById(R.id.left_pic);
left_icon.setImageResource(total_images[position]);
return mySpinner;
}
}
public void onClick(View view) {
if (view == findViewById(R.id.like)) {
AlertDialog.Builder likealertbox = new AlertDialog.Builder(this);
likealertbox.setMessage("You have liked this post");
likealertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), "Liked", Toast.LENGTH_LONG).show();
}
});
likealertbox.show();
ImageView likealert = (ImageView) findViewById(R.id.like);
//increment the like counter
liketext=(TextView)findViewById(R.id.likelabel);
String presentValStr=liketext.getText().toString();
int presentIntVal=Integer.parseInt(presentValStr);
presentIntVal++;
liketext.setText(String.valueOf(presentIntVal));
likealert.setBackgroundColor(Color.rgb(255, 255, 0));
}
else if (view == findViewById(R.id.dislike)) {
AlertDialog.Builder dislikealertbox = new AlertDialog.Builder(this);
dislikealertbox.setMessage("You disliked this post");
dislikealertbox.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface arg0, int arg1) {
Toast.makeText(getApplicationContext(), "Disliked", Toast.LENGTH_LONG).show();
}
});
dislikealertbox.show();
ImageView dislikealert = (ImageView) findViewById(R.id.dislike);
//increment the dislike counter
disliketext=(TextView)findViewById(R.id.dislikelabel);
String presentValStr=disliketext.getText().toString();
int presentIntVal=Integer.parseInt(presentValStr);
presentIntVal++;
disliketext.setText(String.valueOf(presentIntVal));
dislikealert.setBackgroundColor(Color.rgb(255, 255, 0));
}
}
}
| [
"xingyan_95@hotmail.com"
] | xingyan_95@hotmail.com |
2cc8d7f79b7c608adef0119a81cfc0b209159c8e | f08fe8ae6e7b5a86660c0a910e9c21549a184f0c | /src/main/java/au/id/aj/efbp/endpoint/Sink.java | bc62c345a7f3af244ade14daa7aab36409da8e5d | [
"Apache-2.0"
] | permissive | amboar/efbp | 83c28c2de4742c0cb736e9f225c94f0a9531117a | b145307d06798e5bf576a131de0a2ee2e356ac4e | refs/heads/master | 2020-06-04T09:24:52.224395 | 2013-10-12T02:38:36 | 2013-10-13T09:52:39 | 11,364,674 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,615 | java | /* Copyright 2013 Andrew Jeffery
*
* 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 au.id.aj.efbp.endpoint;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import au.id.aj.efbp.node.Node;
import au.id.aj.efbp.transport.ConcurrentConnection;
import au.id.aj.efbp.transport.Connection;
import au.id.aj.efbp.transport.Outbound;
public interface Sink<I> extends Node {
/**
* Retrieves a specific ingress queue given its name. Typically {@see
* #port(String)} will be used by the {@see Egress#connect(Ingress<E, ?>,
* String)} implementation for connecting Ingress and Egress instances
* together.
*
* @param name
* The name of the Ingress queue to return
*
* @return The ingress queue
*/
Outbound<I> port(final String name);
public static final class Utils {
private Utils() {
}
/**
* Generate a port map through varargs names.
*
* @return names A varargs container of port names
*
* @return An unmodifiable port map.
*/
public static <I> Ports<I> generatePortMap(final String... names) {
final Map<String, Connection<I>> portMap = new HashMap<>();
for (final String name : names) {
portMap.put(name, new ConcurrentConnection<I>());
}
return new PortRegistry<I>(Collections.unmodifiableMap(portMap));
}
/**
* Generate a port map through a collection of names.
*
* @return names A collection of port names
*
* @return An unmodifiable port map.
*/
public static <I> Ports<I> generatePortMap(
final Collection<String> names) {
final Map<String, Connection<I>> portMap = new HashMap<>();
for (final String name : names) {
portMap.put(name, new ConcurrentConnection<I>());
}
return new PortRegistry<I>(Collections.unmodifiableMap(portMap));
}
}
}
| [
"andrew@aj.id.au"
] | andrew@aj.id.au |
184d070ee08084338e349341bca7ee606c682370 | 36fcc447ae6fe92c75ff395a288bef78dc0600e1 | /thinkin-in-java/src/util/Generator.java | 646df9e1acd8be658bd9b5e0515fe6d5b68bc784 | [] | no_license | pirent/FunStuff | 7373817cabb99379e1de45c49e8c1874c7a90c05 | fa6071351de4a358b2a0c96ce1b49354d4d747be | refs/heads/master | 2020-04-06T06:58:16.521317 | 2016-08-06T15:43:46 | 2016-08-06T15:43:46 | 22,543,727 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 399 | java | package util;
/**
* A specialization of the Factory Method design pattern, but when you ask
* generator for a new object, you don't past it any arguments. The generator
* know how to create a new object without extra information.
*
* @author pirent
*
* @param <T>
*/
public interface Generator<T> {
/**
* Generate a new instance of a specific type.
*
* @return
*/
T next();
}
| [
"pirent420@gmail.com"
] | pirent420@gmail.com |
781a5e6658a7b800be75f1fcf693dc6e6dc41d82 | 86f004402d0bd605332c55e715c903d22a07a9dd | /ecsite/src/com/internousdev/ecsite/dao/BuyItemCompleteDAO.java | df110388cd2f0c6fed7af0783cf19eb5ef43b1b1 | [] | no_license | typeshin/ECsite | 6342be8d944187cde14132b3020058760e2c36f5 | 496a8d42cc2088712ea36be4ed196f92bc33b7a6 | refs/heads/master | 2021-05-19T00:22:00.630873 | 2020-03-31T06:07:33 | 2020-03-31T06:07:33 | 251,491,862 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,067 | java | package com.internousdev.ecsite.dao;
import java.sql.SQLException;
import com.internousdev.ecsite.util.DBConnector;
import com.internousdev.ecsite.util.DateUtil;
import com.mysql.jdbc.Connection;
import com.mysql.jdbc.PreparedStatement;
public class BuyItemCompleteDAO {
public void buyItemInfo(String item_transaction_id,String total_price,String total_count,String user_master_id,String pay)throws SQLException{
DBConnector db = new DBConnector();
Connection con = db.getConnection();
DateUtil dateUtil = new DateUtil();
String sql = "INSERT INTO user_buy_item_transaction(item_transaction_id,total_price,total_count,user_master_id,pay,insert_date)VALUES(?,?,?,?,?,?)";
try {
PreparedStatement ps = con.prepareStatement(sql);
ps.setString(1, item_transaction_id);
ps.setString(2, total_price);
ps.setString(3, total_count);
ps.setString(4, user_master_id);
ps.setString(5, pay);
ps.setString(6, dateUtil.getDate());
ps.execute();
}catch(Exception e) {
e.printStackTrace();
}finally {
con.close();
}
}
}
| [
"type.ventus@gmail.com"
] | type.ventus@gmail.com |
df65a965556eba4d4f8efc2bd341dca4b79ad8ef | 458128fb19b3eb12973c885a8a12cb3f14e01f38 | /spring-cloud-gcp-data-datastore/src/test/java/com/google/cloud/spring/data/datastore/it/subclasses/descendants/SubclassesDescendantsIntegrationTests.java | bd86d4922bb756a7aa355d35a86695c7bd58fc27 | [
"Apache-2.0"
] | permissive | GoogleCloudPlatform/spring-cloud-gcp | 612f913408ec83fce4eb0110f3c6da07b90725a5 | c92260f1b583575436a61ec8f6fb2252737cd43f | refs/heads/main | 2023-08-18T18:42:31.426488 | 2023-08-15T17:31:31 | 2023-08-15T17:31:31 | 257,984,305 | 342 | 275 | Apache-2.0 | 2023-09-14T18:22:34 | 2020-04-22T18:19:22 | Java | UTF-8 | Java | false | false | 3,644 | java | /*
* Copyright 2017-2018 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 com.google.cloud.spring.data.datastore.it.subclasses.descendants;
import static org.assertj.core.api.Assertions.assertThat;
import com.google.cloud.datastore.Key;
import com.google.cloud.spring.data.datastore.core.DatastoreTemplate;
import com.google.cloud.spring.data.datastore.core.mapping.Descendants;
import com.google.cloud.spring.data.datastore.core.mapping.DiscriminatorField;
import com.google.cloud.spring.data.datastore.core.mapping.DiscriminatorValue;
import com.google.cloud.spring.data.datastore.core.mapping.Entity;
import com.google.cloud.spring.data.datastore.it.AbstractDatastoreIntegrationTests;
import com.google.cloud.spring.data.datastore.it.DatastoreIntegrationTestConfiguration;
import com.google.cloud.spring.data.datastore.repository.DatastoreRepository;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledIfSystemProperty;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.annotation.Id;
import org.springframework.stereotype.Repository;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@Repository
interface SubclassesDescendantsEntityArepository extends DatastoreRepository<EntityA, Key> {}
@EnabledIfSystemProperty(named = "it.datastore", matches = "true")
@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {DatastoreIntegrationTestConfiguration.class})
public class SubclassesDescendantsIntegrationTests extends AbstractDatastoreIntegrationTests {
@Autowired
SubclassesDescendantsEntityArepository entityArepository;
@Autowired private DatastoreTemplate datastoreTemplate;
@AfterEach
void deleteAll() {
datastoreTemplate.deleteAll(EntityA.class);
datastoreTemplate.deleteAll(EntityB.class);
datastoreTemplate.deleteAll(EntityC.class);
}
@Test
void testEntityCcontainsReferenceToEntityB() {
EntityB entityB1 = new EntityB();
EntityC entityC1 = new EntityC();
entityB1.addEntityC(entityC1);
entityArepository.saveAll(Arrays.asList(entityB1, entityC1));
EntityB fetchedB = (EntityB) entityArepository.findById(entityB1.getId()).get();
List<EntityC> entitiesCofB = fetchedB.getEntitiesC();
assertThat(entitiesCofB).hasSize(1);
}
}
@Entity(name = "A")
@DiscriminatorField(field = "type")
abstract class EntityA {
@Id private Key id;
public Key getId() {
return id;
}
}
@Entity(name = "A")
@DiscriminatorValue("B")
class EntityB extends EntityA {
@Descendants private List<EntityC> entitiesC = new ArrayList<>();
public void addEntityC(EntityC entityCdescendants) {
this.entitiesC.add(entityCdescendants);
}
public List<EntityC> getEntitiesC() {
return entitiesC;
}
}
@Entity(name = "A")
@DiscriminatorValue("C")
class EntityC extends EntityA {}
| [
"noreply@github.com"
] | GoogleCloudPlatform.noreply@github.com |
d02d9571a8b2b3277ae55b1322081513f0658e76 | fb0b65349b7e39d6f5664ec004302bbd7ecab375 | /src/weka/WekaInterface.java | a768cafa11a3687045fb7e80e8de39f65fd3f397 | [] | no_license | DennisdeW/Mod6AI | 6c662b1b7ba1c03c23afaa8a7243712ab824a66f | 6066ba81d8b65ad3a161b932de7ef16e5635cc21 | refs/heads/master | 2016-09-10T13:39:01.526976 | 2014-12-09T09:30:52 | 2014-12-09T09:30:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,385 | java | package weka;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import weka.classifiers.Classifier;
import weka.classifiers.bayes.NaiveBayes;
import weka.classifiers.bayes.NaiveBayesSimple;
import weka.classifiers.functions.SimpleLogistic;
import weka.classifiers.meta.FilteredClassifier;
import weka.classifiers.trees.J48;
import weka.classifiers.trees.NBTree;
import weka.core.Attribute;
import weka.core.FastVector;
import weka.core.Instance;
import weka.core.Instances;
import weka.filters.Filter;
import weka.filters.unsupervised.attribute.StringToWordVector;
public class WekaInterface {
public static final WekaClass[] MALE_FEMALE = new WekaClass[] {
new WekaClass("Male", "M-", 1.0),
new WekaClass("Female", "F-", 0.0) };
public static final WekaClass[] SPAM_HAM = new WekaClass[] {
new WekaClass("Spam", "spam", 1.0),
new WekaClass("Ham", "msg", 0.0) };
public static FilteredClassifier getClassifierFromDirs(Classifier learner,
WekaClass[] classes, File[] folders) throws Exception {
FastVector classVec = new FastVector();
for (WekaClass wc : classes)
classVec.addElement(wc.getName());
FastVector attrs = new FastVector();
attrs.addElement(new Attribute("content", (FastVector) null));
attrs.addElement(new Attribute("@@class@@", classVec));
Instances model = new Instances("Blogs", attrs, 0);
for (File dir : folders)
buildModel(model, classes, dir);
model.setClassIndex(model.numAttributes() - 1);
File file = new File("out.arff");
PrintWriter out = new PrintWriter(file, "UTF-8");
out.print(model);
out.flush();
out.close();
StringToWordVector filter = new StringToWordVector();
filter.setAttributeIndices("first");
// filter.setInputFormat(model);
// Instances filtered = Filter.useFilter(model, filter);
// filtered.setClassIndex(0);
FilteredClassifier classifier = new FilteredClassifier();
classifier.setFilter(filter);
classifier.setClassifier(learner);
classifier.buildClassifier(model);
return classifier;
}
public static Map<String, FilteredClassifier> getClassifiersFromDirs(
String[] learners, WekaClass[] classes, File[] folders)
throws Exception {
Map<String, FilteredClassifier> map = new HashMap<>();
for (String s : learners) {
map.put(s,
getClassifierFromDirs(Classifier.forName(s, null), classes,
folders));
}
return map;
}
private static void buildModel(Instances model, WekaClass[] classes,
File dir) throws IOException {
for (File f : dir.listFiles()) {
Scanner scanner = new Scanner(f);
if (scanner.hasNext()) {
WekaClass wc = null;
for (int i = 0; i < classes.length; i++)
if (f.getName().contains(classes[i].getSignifier())) {
wc = classes[i];
break;
}
if (wc == null)
continue;
double[] value = new double[model.numAttributes()];
BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(f)));
String text = scanner.useDelimiter("\\Z").next();
// System.out.println(text);
value[0] = model.attribute(0).addStringValue(text);
reader.close();
value[1] = wc.getValue();
model.add(new Instance(1.0, value));
}
scanner.close();
}
}
public static void addToInstances(String text, WekaClass type, Instances data) {
double[] toAdd = new double[data.numAttributes()];
toAdd[0] = data.attribute(0).addStringValue(text);
toAdd[1] = type.getValue();
data.add(new Instance(1.0, toAdd));
}
public static Instances getInstancesFromDirs(String name,
WekaClass[] classes, File[] folders) throws IOException {
FastVector classVec = new FastVector();
for (WekaClass wc : classes)
classVec.addElement(wc.getName());
FastVector attrs = new FastVector();
attrs.addElement(new Attribute("content", (FastVector) null));
attrs.addElement(new Attribute("@@class@@", classVec));
Instances res = new Instances(name, attrs, 0);
for (File dir : folders)
buildModel(res, classes, dir);
res.setClassIndex(res.numAttributes() - 1);
return res;
}
public static Set<Result> classify(File folder, Classifier c,
WekaClass[] classes) throws Exception {
Set<Result> results = new HashSet<>();
Instances data = getInstancesFromDirs("internal", classes, arr(folder));
for (int i = 0; i < data.numInstances(); i++) {
double val = c.classifyInstance(data.instance(i));
Result result = new Result(data.instance(i).toString(0), val,
classes);
results.add(result);
}
return results;
}
public static Set<Result> classify(File[] folders, Classifier c,
WekaClass[] classes) throws Exception {
Set<Result> results = new HashSet<>();
for (File dir : folders)
results.addAll(classify(dir, c, classes));
return results;
}
public static Set<Result> classify(String data, Classifier c,
WekaClass[] classes) throws Exception {
File dir = null, f = null;
try {
dir = new File("tmp");
dir.mkdir();
f = new File("tmp/tmp");
f.createNewFile();
FileOutputStream fos = new FileOutputStream(f);
fos.write(data.getBytes());
fos.flush();
fos.close();
} catch (IOException e) {
e.printStackTrace();
}
Set<Result> res = classify(dir, c, classes);
f.delete();
dir.delete();
return res;
}
public static Set<Result> classify(String[] data, Classifier c,
WekaClass[] classes) throws Exception {
Set<Result> res = new HashSet<>();
for (String s : data)
res.addAll(classify(s, c, classes));
return res;
}
@SafeVarargs
public static <T> T[] arr(T... ts) {
return ts;
}
public static void main(String[] args) {
try {
WekaClass[] classes = new WekaClass[2];
classes[0] = new WekaClass("Male", "M-", 1.0);
classes[1] = new WekaClass("Female", "F-", 0.0);
FilteredClassifier fc = getClassifierFromDirs(new J48(), classes,
arr(new File("blogstrain/F"), new File("blogstrain/M")));
Set<Result> set = classify(new File("blogstest/F"), fc, classes);
System.out.println(set);
/*
* Instances test = getInstancesFromDirs("Test", classes, new File[]
* { new File("blogstest/F") }); int successes = 0; for (int i = 0;
* i < test.numInstances(); i++) { Instance instance =
* test.instance(i); boolean correct = fc.classifyInstance(instance)
* == 0.0; if (correct) successes++; System.out.println(correct); }
* System.out.println(successes + "/25");
*/
} catch (Exception e) {
e.printStackTrace();
}
}
public static Classifier classifierForName(String name) {
switch (name) {
case "J48":
return new J48();
case "NaiveBayes":
return new NaiveBayes();
case "NBTree":
return new NBTree();
default:
try {
return (Classifier) Class.forName(name).newInstance();
} catch (Throwable t) {
throw new gui.LearnerGui.ConfigurationException(t);
}
}
}
}
| [
"dennisdw@outlook.com"
] | dennisdw@outlook.com |
f2725e1922fcb80529cc3ba371d790fbe262dd7f | 2da87d8ef7afa718de7efa72e16848799c73029f | /ikep4-collpack/src/test/java/com/lgcns/ikep4/collpack/expertnetwork/test/service/ExpertNetworkTaggingServiceTest.java | 3574b2f3384cbccf63f0efe67087b93cdddb5b0b | [] | no_license | haifeiforwork/ehr-moo | d3ee29e2cae688f343164384958f3560255e52b2 | 921ff597b316a9a0111ed4db1d5b63b88838d331 | refs/heads/master | 2020-05-03T02:34:00.078388 | 2018-04-05T00:54:04 | 2018-04-05T00:54:04 | 178,373,434 | 0 | 1 | null | 2019-03-29T09:21:01 | 2019-03-29T09:21:01 | null | UTF-8 | Java | false | false | 4,213 | java | /*
* Copyright (C) 2011 LG CNS Inc.
* All rights reserved.
*
* 모든 권한은 LG CNS(http://www.lgcns.com)에 있으며,
* LG CNS의 허락없이 소스 및 이진형식으로 재배포, 사용하는 행위를 금지합니다.
*/
package com.lgcns.ikep4.collpack.expertnetwork.test.service;
import static org.junit.Assert.assertEquals;
import java.util.List;
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import com.lgcns.ikep4.collpack.expertnetwork.model.ExpertNetworkCategory;
import com.lgcns.ikep4.collpack.expertnetwork.model.ExpertNetworkTagging;
import com.lgcns.ikep4.collpack.expertnetwork.service.ExpertNetworkCategoryService;
import com.lgcns.ikep4.collpack.expertnetwork.service.ExpertNetworkTaggingService;
import com.lgcns.ikep4.util.idgen.service.IdgenService;
/**
* Expert Network ExpertTaggingService Test Unit
*
* @author 우동진 (jins02@nate.com)
* @version $Id: ExpertNetworkTaggingServiceTest.java 16289 2011-08-19 06:52:01Z giljae $
*/
public class ExpertNetworkTaggingServiceTest extends BaseServiceTestCase {
@Autowired
private ExpertNetworkTaggingService expertNetworkTaggingService;
@Autowired
private IdgenService idgenService;
@Autowired
private ExpertNetworkCategoryService expertNetworkCategoryService;
private ExpertNetworkTagging expertNetworkTagging;
private String categoryId = "";
private ExpertNetworkCategory expertNetworkCategory;
private String portalId = "";
@Before
public void setUp() {
portalId = idgenService.getNextId();
String rootCategoryId = idgenService.getNextId();
expertNetworkCategory = new ExpertNetworkCategory();
expertNetworkCategory.setCategoryId(rootCategoryId);
expertNetworkCategory.setCategoryParentId(rootCategoryId);
expertNetworkCategory.setCategoryName("testCategory");
expertNetworkCategory.setSortOrder(1);
expertNetworkCategory.setPortalId(portalId);
expertNetworkCategory.setRegisterId("admin");
expertNetworkCategory.setRegisterName("관리자");
expertNetworkCategoryService.create(expertNetworkCategory);
categoryId = idgenService.getNextId();
expertNetworkCategory.setCategoryId(categoryId);
expertNetworkCategory.setCategoryName("testCategoryNode1");
expertNetworkCategoryService.create(expertNetworkCategory);
expertNetworkTagging = new ExpertNetworkTagging();
expertNetworkTagging.setCategoryId(categoryId);
expertNetworkTagging.setSortOrder(1);
expertNetworkTagging.setTag("testTag");
expertNetworkTaggingService.create(expertNetworkTagging);
}
@Test
public void listByCategoryIdTest() {
List<ExpertNetworkTagging> result = expertNetworkTaggingService.listByCategoryId(categoryId);
assertEquals(1, result.size());
}
@Test
public void createTagsTest() {
categoryId = idgenService.getNextId();
expertNetworkCategory.setCategoryId(categoryId);
expertNetworkCategory.setCategoryName("testCategoryNode2");
expertNetworkCategoryService.create(expertNetworkCategory);
String tags = "a,s,d,f";
expertNetworkTaggingService.createTags(categoryId, tags);
List<ExpertNetworkTagging> result = expertNetworkTaggingService.listByCategoryId(categoryId);
assertEquals(4, result.size());
}
@Test
public void getTagsByCategoryIdTest() {
categoryId = idgenService.getNextId();
expertNetworkCategory.setCategoryId(categoryId);
expertNetworkCategory.setCategoryName("testCategoryNode2");
expertNetworkCategoryService.create(expertNetworkCategory);
String tags = "a,s,d,f";
expertNetworkTaggingService.createTags(categoryId, tags);
String result = expertNetworkTaggingService.getTagsByCategoryId(categoryId);
assertEquals(tags, result);
}
@Test
public void deleteByCategoryIdTest() {
expertNetworkTaggingService.deleteByCategoryId(categoryId);
List<ExpertNetworkTagging> result = expertNetworkTaggingService.listByCategoryId(categoryId);
assertEquals(0, result.size());
}
@Test
public void deleteByCategoryIdHierarchyTest() {
expertNetworkTaggingService.deleteByCategoryIdHierarchy(categoryId);
List<ExpertNetworkTagging> result = expertNetworkTaggingService.listByCategoryId(categoryId);
assertEquals(0, result.size());
}
}
| [
"haneul9@gmail.com"
] | haneul9@gmail.com |
7a5976fcdfdc685be8deb58d9c2322b06fae8d7e | 5050b38f3a734077d32f762351b7cb8a9ce4fe04 | /Spielfeld.java | 8b377ab92a21bbaf3112f6409f3baf84f8c0d7fe | [] | no_license | Sarkles/mallriderfinalversion | 1dbb3511067d61690b34b36a454f39a1e5f03e8c | a821993fe03a65c93749bb06862000605f443ad4 | refs/heads/master | 2023-05-27T10:59:56.374773 | 2021-06-11T09:08:28 | 2021-06-11T09:08:28 | 375,967,373 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,240 | java | import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
/**
* Beschreiben Sie hier die Klasse Spielfeld.
*
* @author Moritz Rembold, Jakob Linz, Karl Konrad Hanka, Emma Holtz, Fabian Turfan
* @version (eine Versionsnummer oder ein Datum)
*/
public class Spielfeld extends JPanel implements KeyListener
{
//Wie schnell der Spieler faellt
private static final double GRAVITY = 0.1;
//Die Fahrebene des Cops
private static final float GROUNDY = 150;
//Der Character
private Character character;
//Der Hindernismanager
private HindernisManager hindernisManager;
//Der Hintergund
private Hintergrund hintergrund;
private int score;
/**
* Konstruktor für Objekte der Klasse Spielfeld
*/
public Spielfeld()
{
character = new Character(GRAVITY, GROUNDY);
hindernisManager = new HindernisManager(GRAVITY, GROUNDY);
hintergrund = new Hintergrund();
score = 0;
}
//Getter fuer die Konstanten
public double getGRAVITY(){return GRAVITY;}
public float getGROUNDY(){return GROUNDY;}
/**
* Auf allen bekannten Objekten werden ihre update Methoden aufgerufen und prüft die Hitboxen
* @return boolean Sollte der Spieler mit einem Hindernis zusammenstoßen, so wird false zurueckgegeben
*/
public boolean update()
{
character.update();
hindernisManager.update();
hintergrund.update();
//Score wird erhoeht
score += 1;
//Es wird geprueft ob sich die Hitboxen von Character und Hinderniss ueberschneiden
if(hindernisManager.getHindernis().getHitbox().intersects(character.getHitbox())){return false;}
else return true;
}
/**
* Ruft die repaint Methode auf
*/
public void render()
{
repaint();
}
@Override
/**
* erstellt die Grafiken für das Spielfeld
* @param Graphics g wird benoetigt um darauf die Zeichenmethoden aufzurufen
*/
public void paint(Graphics g){
g.setColor(Color.white);
g.fillRect(0,0,getWidth(),getHeight()); //Erschafft weißen Hintergrund
g.setColor(Color.red);
g.drawLine(0, (int) GROUNDY, 600, (int) GROUNDY); //Erschafft rote Grundlinie (Boden)
Image img = Resource.getResourceImage("boden.png");
g.drawImage(img, 0,(int) GROUNDY, null);//Zeichnet den Boden auf dem der Cop faehrt
hintergrund.paint(g);
character.paint(g);
hindernisManager.paint(g); //Wichtigste Bestandteile werden extern erschaffen
g.setColor(Color.black);
g.drawString("Score: " + Integer.toString(score), 500, 160); //Erschafft die Score-Anzeige
}
/**
* Eine KeyListener-Methode, muss ueberschrieben werden, ist aber in unserem Falle nicht
* benoetigt, also leer
*/
@Override
public void keyTyped(KeyEvent e){
}
/**
* Eine KeyListener-Methode, muss ueberschrieben werden
* Achtet ("Listened") auf Tastendruecke
*/
@Override
public void keyPressed(KeyEvent e){
//Sollte die w Taste gedreuckt werden und der Character sich auf der Fahrebene
//Befinden, so wird die jump methode aufgerufen
if(character.getYPos() == GROUNDY - character.getBild1().getHeight() && e.getKeyChar() == 'w' )character.jump();
//Sollte die s Taste gedrueckt werden und der Character sich auf der Fahrebene
//Befinden, so wird die cower methode aufgerufen
if(character.getYPos() == GROUNDY - character.getBild1().getHeight() && e.getKeyChar() == 's' )character.cower();
}
/**
* Eine KeyListener-Methode, muss ueberschrieben werden
* Achtet ("Listened") auf die losgelassenen Tasten
*/
@Override
public void keyReleased(KeyEvent e){
//wird die s Taste losgelassen, so wir die aufstehen Methode aufgerufen
//und die Spielfigur richtet sich wieder auf
if(character.getYPos() == GROUNDY - character.getBild1().getHeight() && e.getKeyChar() == 's' )character.aufstehen();
}
}
| [
"jakob.linz@s15-15.ad.b-fk-leos.logodidact.net"
] | jakob.linz@s15-15.ad.b-fk-leos.logodidact.net |
7e9fff0c618fa7bdce1c4b52a73bba1f263663dc | 47119d527d55e9adcb08a3a5834afe9a82dd2254 | /exportLibraries/recoverpoint/src/main/java/com/emc/storageos/recoverpoint/requests/CGRequestParams.java | 1f07bb7e5bc6248c1a3b557c8774496170070174 | [] | no_license | chrisdail/coprhd-controller | 1c3ddf91bb840c66e4ece3d4b336a6df421b43e4 | 38a063c5620135a49013aae5e078aeb6534a5480 | refs/heads/master | 2020-12-03T10:42:22.520837 | 2015-06-08T15:24:36 | 2015-06-08T15:24:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,236 | java | /**
* Copyright 2015 EMC Corporation
* All Rights Reserved
*/
package com.emc.storageos.recoverpoint.requests;
/**
* Copyright (c) 2013 EMC Corporation
* All Rights Reserved
*
* This software contains the intellectual property of EMC Corporation
* or is licensed to EMC Corporation from third parties. Use of this
* software and the intellectual property contained therein is expressly
* limited to the terms and conditions of the License Agreement under which
* it is provided by or on behalf of EMC.
**/
import java.io.Serializable;
import java.net.URI;
import java.util.List;
/**
* Parameters necessary to create/update a consistency group, given newly created volumes.
* Need enough information to be able to export the volumes to the RPAs and to create the CG.
*
*/
@SuppressWarnings("serial")
public class CGRequestParams implements Serializable {
private boolean isJunitTest;
// Name of the CG Group
private String cgName;
// CG URI
private URI cgUri;
// Project of the source volume
private URI project;
// Tenant making request
private URI tenant;
// Top-level policy for the CG
public CGPolicyParams cgPolicy;
// List of copies
private List<CreateCopyParams> copies;
// List of replication sets that make up this consistency group.
private List<CreateRSetParams> rsets;
public CGRequestParams() {
isJunitTest = false;
}
public boolean isJunitTest() {
return isJunitTest;
}
public void setJunitTest(boolean isJunitTest) {
this.isJunitTest = isJunitTest;
}
public String getCgName() {
return cgName;
}
public void setCgName(String cgName) {
this.cgName = cgName;
}
public URI getCgUri() {
return cgUri;
}
public void setCgUri(URI cgUri) {
this.cgUri = cgUri;
}
public URI getProject() {
return project;
}
public void setProject(URI project) {
this.project = project;
}
public URI getTenant() {
return tenant;
}
public void setTenant(URI tenant) {
this.tenant = tenant;
}
public List<CreateCopyParams> getCopies() {
return copies;
}
public void setCopies(List<CreateCopyParams> copies) {
this.copies = copies;
}
public List<CreateRSetParams> getRsets() {
return rsets;
}
public void setRsets(List<CreateRSetParams> rsets) {
this.rsets = rsets;
}
// The top-level CG policy objects
public static class CGPolicyParams implements Serializable {
public String copyMode;
public Long rpoValue;
public String rpoType;
}
@Override
public String toString() {
StringBuffer sb = new StringBuffer();
sb.append("\ncgName: " + cgName);
sb.append("\nproject: " + project);
sb.append("\ntenant: " + tenant);
sb.append("\n---------------\n");
if (copies != null) {
for (CreateCopyParams copy : copies) {
sb.append(copy);
sb.append("\n");
}
}
sb.append("\n---------------\n");
if (rsets != null) {
for (CreateRSetParams rset : rsets) {
sb.append(rset);
sb.append("\n");
}
}
sb.append("\n---------------\n");
return sb.toString();
}
}
| [
"review-coprhd@coprhd.org"
] | review-coprhd@coprhd.org |
5e948a300b2ca66f8955bb141db89bc13569b396 | 1fb317d6bd8cbb5bcccf5fe992935476eb67e3a0 | /Dev2_YalLockMalLock/src/main/java/com/dev2/ylml/controller/SampleController.java | 3f7f2bffce22ce887ad3aff145b784e31b4ce327 | [] | no_license | devA-2/YeolLockMalLock | 0f30236fdd43fcc9e53d7509275e0da8046cb9d4 | 0e87e45bfb1b024b36fb6a4e2b2c0850515cd41d | refs/heads/main | 2023-02-25T13:07:39.627369 | 2021-02-09T08:27:52 | 2021-02-09T08:27:52 | 319,901,560 | 1 | 0 | null | 2020-12-10T08:09:39 | 2020-12-09T09:11:12 | Java | UTF-8 | Java | false | false | 2,319 | java | package com.dev2.ylml.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.dev2.ylml.abstractView.ExcelDownload;
import com.dev2.ylml.dto.ExcelDto;
@Controller
public class SampleController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@RequestMapping(value = "index.do")
public String index() {
return "index";
}
/* 엑셀 다운로드 예제 */
@Autowired
ExcelDownload excelView;
/* 1. ModelAndView로 excelView 객체를 생성
* 2. 테 | 스 | 트
* 1 | 2 | 3
* 4 | 5 | 6
* 을 넣는다면
* key[]에 {"테","스","트"}
* 한줄의 값을 hashmap에 <테, 1> <스, 2> <트, 3> 형식으로 담고 -> 해당 hashmap을 list에 담아서
* ExcelDto에 setKeys(key), setData_list(list)해준다
* ExcelDto에 버전과 파일네임을 설정해주고 excelView 객체에 등록 후 return 해주면
* 해당 주소(/downloadExcel.do)를 호출한 페이지에서 해당 list가 excel형식으로 다운로드하는 창이 뜨게 된다
*
* 예제는 아래와 같다
* */
@RequestMapping(value="/downloadExcel.do")
public ModelAndView downloadExcel() throws Exception{
if(excelView==null) {
logger.info("downloadExcel -> excelView is null!!!");
}
ModelAndView mav = new ModelAndView(excelView);
//테스트용 더미 데이터
String[] keys = {"테","스","트"};
List<HashMap<String, String>> data_list =
new ArrayList<HashMap<String, String>>();
HashMap<String, String> value;
for (int i = 0; i < 5; i++) {
value=new HashMap<>();
for (int j = 0; j < keys.length; j++) {
value.put(keys[j], Integer.toString(((i+1)*10+j+1)));
}
data_list.add(value);
}
ExcelDto excelDto=new ExcelDto();
excelDto.setVersion_XLSX();
excelDto.setFile_name("testExcel");
excelDto.setKeys(keys);
excelDto.setData_list(data_list);
mav.addObject("excelDto", excelDto);
return mav;
}
}
| [
"wntjd337@gmail.com"
] | wntjd337@gmail.com |
13083472789ae8cf515918af4ca6edd040811ce4 | f9907a2efe91f5d987e4069e3200ed46a7ed5dc4 | /app/src/main/java/com/devqt/fity/Bachelor.java | 111b37fd4d398eb9b9afdf46351864c5f366427d | [] | no_license | BelRoy/FITY | 31dcd932d795ff4ac268b12b003bbe4dec59ffb5 | 291d12d49ead10e4d6083ba01e5daddced222d0b | refs/heads/master | 2021-01-20T00:22:11.001506 | 2017-04-13T13:35:42 | 2017-04-13T13:35:42 | 78,646,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,561 | java | package com.devqt.fity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import com.devqt.fity.course_b.FiKB;
import com.devqt.fity.course_b.InformaticB;
import com.devqt.fity.course_b.MatematicB;
import com.devqt.fity.course_b.MenedjmentB;
public class Bachelor extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.bachelor_act);
findViewById(R.id.inf_b).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Bachelor.this, InformaticB.class));
}
});
findViewById(R.id.menedjer_b).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Bachelor.this, MenedjmentB.class));
}
});
findViewById(R.id.matem_b).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Bachelor.this, MatematicB.class));
}
});
findViewById(R.id.finans_credit_b).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(Bachelor.this, FiKB.class ));
}
});
}
}
| [
"oksiwhite@ukr.net"
] | oksiwhite@ukr.net |
e837cc57e3022451a2c34730bae37f892fb53485 | 3273c20fa83737d101caae77eaa1049788f9e2c6 | /material/src/main/java/com/amlzq/android/viewer/material/ComponentsActivity.java | efcea5b41a91f18f8558bec3bffd73ec813544ef | [] | no_license | amlzq/AndroidViewer | d126ae8a30a4dbf6e4918efd3f4e2d54cd8a003e | b1408e503586b642cec45efb08d28d1f98111ca2 | refs/heads/master | 2021-07-22T14:28:52.011010 | 2020-08-31T10:59:37 | 2020-08-31T10:59:37 | 213,563,559 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,582 | java | package com.amlzq.android.viewer.material;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import androidx.appcompat.app.AppCompatActivity;
import com.amlzq.android.viewer.material.templates.activities.NavigationDrawerActivity;
/**
* 组件/部件
*/
public class ComponentsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_components_material);
}
public void onWidget(View view) {
startActivity(new Intent(this, WidgetActivity.class));
}
public void onPalette(View view) {
Intent intent = PaletteActivity.newIntent(this,
R.drawable.ippawards_49_1st_sunset_sreekumar_krishnan);
startActivity(intent);
}
public void onChip(View view) {
startActivity(new Intent(this, ChipActivity.class));
}
public void onAlertDialog(View view) {
startActivity(new Intent(this, AlertDialogActivity.class));
}
public void onCollapsingToolbar(View view) {
startActivity(new Intent(this, CollapsingToolbarActivity.class));
}
public void onBadge(View view) {
startActivity(new Intent(this, BadgeActivity.class));
}
public void onBottomAppBar(View view) {
startActivity(new Intent(this, BottomAppBarActivity.class));
}
public void onBottomNavigation(View view) {
startActivity(new Intent(this, BottomNavigationViewActivity.class));
}
public void onBottomSheet(View view) {
startActivity(new Intent(this, BottomSheetActivity.class));
}
public void onCheckbox(View view) {
startActivity(new Intent(this, CheckBoxActivity.class));
}
public void onFloatingActionButton(View view) {
startActivity(new Intent(this, FloatingActionButtonActivity.class));
}
public void onMaterialButton(View view) {
startActivity(new Intent(this, MaterialButtonActivity.class));
}
public void onMaterialCard(View view) {
startActivity(new Intent(this, CardViewActivity.class));
}
public void onConstraintLayout(View view) {
startActivity(new Intent(this, ConstraintLayoutActivity.class));
}
public void onFlexBoxLayout(View view) {
startActivity(new Intent(this, FlexboxLayoutActivity.class));
}
public void onMaterialText(View view) {
startActivity(new Intent(this, MaterialTextViewActivity.class));
}
public void onMenu(View view) {
startActivity(new Intent(this, MenusActivity.class));
}
public void onNavigationViews(View view) {
startActivity(new Intent(this, NavigationDrawerActivity.class));
}
public void onRadioButton(View view) {
startActivity(new Intent(this, RadioButtonActivity.class));
}
public void onRecycleView(View view) {
startActivity(new Intent(this, RecycleViewActivity.class));
}
public void onSnackbar(View view) {
startActivity(new Intent(this, SnackbarActivity.class));
}
public void onTabLayout(View view) {
startActivity(new Intent(this, TabLayoutActivity.class));
}
public void onTextField(View view) {
startActivity(new Intent(this, TextFieldActivity.class));
}
public void onSwitches(View view) {
startActivity(new Intent(this, SwitchCompatActivity.class));
}
public void onTopAppBars(View view) {
startActivity(new Intent(this, TopAppBarsActivity.class));
}
}
| [
"lzqjiujiang@gmail.com"
] | lzqjiujiang@gmail.com |
76f47f86d04524e5f7413fc3d1a843d1880a09ec | 79c2e2094a6f4184b4643ed7619d3c7748924605 | /src/main/java/uk/gov/di/ipv/core/back/domain/gpg45/EvidenceScore.java | 720ee77b79e7f1fd526f5d4ff5a712521971ea8a | [
"MIT"
] | permissive | alphagov/di-ipv-alpha-core-back | 86f01330a7d02acebeed999faabafe53cfbdc753 | d21500e293fa347789a91150cffd61afd60e2887 | refs/heads/main | 2023-08-27T10:43:13.391694 | 2021-10-11T10:07:46 | 2021-10-11T10:07:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 669 | java | package uk.gov.di.ipv.core.back.domain.gpg45;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class EvidenceScore {
private Score strength = Score.NOT_AVAILABLE;
private Score validity = Score.NOT_AVAILABLE;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EvidenceScore that = (EvidenceScore) o;
return this.hashCode() == that.hashCode();
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
}
| [
"7595909+martin-bucinskas@users.noreply.github.com"
] | 7595909+martin-bucinskas@users.noreply.github.com |
f30029fa057fca31488a80399f277bfb89fb4dc9 | f139ad2948073c6c4858c923d5da3d9fc4f6a3c7 | /src/main/java/com/xc/common/CmcPayConfig.java | 9faabb937f54a89cbb46d1a36c7d078bbff9db52 | [] | no_license | wangwensheng001/st-api-java | 875e52d59139755f5e5f7c94c678fd38834450f9 | 30c118a55f14a74a95bd7f2d17bd807a742f890d | refs/heads/master | 2023-03-18T23:29:53.969020 | 2020-11-26T18:52:08 | 2020-11-26T18:52:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,338 | java | package com.xc.common;
import com.xc.utils.PropertiesUtil;
/**
* Created by xieyuxing on 2017/9/18.
*/
public class CmcPayConfig {
//商户后台密匙
public static final String KEY="1ee6fa81e2471cacdc14714f704bf5ec11";
//商户后台appid
public static final String UID="LXHKVG11";
//同步返回地址
public static final String RETURN_URL= PropertiesUtil.getProperty("website.domain.url") + "/homes/#/rechargelist";
//异步回调地址
public static final String NOTIFY_URL= PropertiesUtil.getProperty("website.domain.url") + "/api/pay/juhenewpayNotify.do";
//接口服务器地址
public static final String URL="https://zf.flyotcpay.com/payment/";
// 商户网页的编码方式【请根据实际情况自行配置】
public static final String CHARSET="utf-8";
public static final String TOKEN="ABCDEFG";
/*H5配置*/
//商户后台appid
public static final String H5UID="318543172911";
//商户后台密匙
public static final String H5KEY="0aa9ac8194025b7721648cdf541e4e0b11";
//public static final String H5URL="https://open.yunmianqian.com/api/pay";
public static final String H5URL="http://yunpay.waa.cn/";
//异步回调地址
public static final String H5NOTIFY_URL="http://www.huijuwang888.com/api/pay/juheh5payNotify.do";
}
| [
"mikhail.an06@yandex.com"
] | mikhail.an06@yandex.com |
4a3ff44fbc75e34dc26e904c68f546632283ffc0 | bcee6a3a9cda8960cc462c7d24bdd74c8feceab3 | /src/main/java/com/kevin/mvc/java/config/ApplicationConfig.java | ef07617533479c400351b436fbd2aa43736acb49 | [] | no_license | alamnr/spring-web-mvc-xml-and-java-config | 4a5d0d074c5cf0bd181da3473bc1064e5fa5d0b0 | 4f8ef8f6ee9c770e9769020fe27983594b89df25 | refs/heads/main | 2023-05-30T03:56:24.461623 | 2021-06-21T11:29:39 | 2021-06-21T11:29:39 | 375,663,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 513 | java | package com.kevin.mvc.java.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import com.kevin.mvc.service.ProjectService;
@Configuration
//@EnableJpaRepositories("com.telusko.domain")
//@EnableTransactionManagement
@ComponentScan(basePackages = { "com.kevin.mvc.service" })
//@EnableJpaAuditing(auditorAwareRef = "customAuditorAware")
public class ApplicationConfig {
}
| [
"alamnr@gmail.com"
] | alamnr@gmail.com |
94430d8ed8821229eda6a69d945ae7057f374992 | 6fc5d0ab847fba0879421e4bc882ba399ebd1517 | /app/src/main/java/com/justwayward/book/base/BaseFragment.java | 30ad40f594e1102d60d229850ef44f579eca7acd | [
"Apache-2.0"
] | permissive | gaoyuan117/BookReader | 5f7b0d999cef1beeff67040ad00e45bd031d47b1 | 4546b24466aba16e751c59db08b3864fab04ae31 | refs/heads/master | 2021-05-11T04:38:16.866446 | 2018-01-22T13:11:51 | 2018-01-22T13:11:51 | 117,943,898 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,712 | java | /**
* Copyright 2016 JustWayward Team
* <p>
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.justwayward.book.base;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.justwayward.book.ReaderApplication;
import com.justwayward.book.component.AppComponent;
import com.justwayward.book.view.loadding.CustomDialog;
import com.umeng.analytics.MobclickAgent;
import butterknife.ButterKnife;
public abstract class BaseFragment extends Fragment {
protected View parentView;
protected FragmentActivity activity;
protected LayoutInflater inflater;
protected Context mContext;
private CustomDialog dialog;
public abstract
@LayoutRes
int getLayoutResId();
protected abstract void setupActivityComponent(AppComponent appComponent);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
parentView = inflater.inflate(getLayoutResId(), container, false);
activity = getSupportActivity();
mContext = activity;
this.inflater = inflater;
return parentView;
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
ButterKnife.bind(this, view);
setupActivityComponent(ReaderApplication.getsInstance().getAppComponent());
attachView();
initDatas();
configViews();
}
public abstract void attachView();
public abstract void initDatas();
/**
* 对各种控件进行设置、适配、填充数据
*/
public abstract void configViews();
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
this.activity = (FragmentActivity) activity;
}
@Override
public void onDetach() {
super.onDetach();
this.activity = null;
}
@Override
public void onDestroyView() {
super.onDestroyView();
ButterKnife.unbind(this);
}
public FragmentActivity getSupportActivity() {
return super.getActivity();
}
public Context getApplicationContext() {
return this.activity == null ? (getActivity() == null ? null : getActivity()
.getApplicationContext()) : this.activity.getApplicationContext();
}
protected LayoutInflater getLayoutInflater() {
return inflater;
}
protected View getParentView() {
return parentView;
}
public CustomDialog getDialog() {
if (dialog == null) {
dialog = CustomDialog.instance(getActivity());
dialog.setCancelable(false);
}
return dialog;
}
public void hideDialog() {
if (dialog != null)
dialog.hide();
}
public void showDialog() {
getDialog().show();
}
public void dismissDialog() {
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
}
protected void gone(final View... views) {
if (views != null && views.length > 0) {
for (View view : views) {
if (view != null) {
view.setVisibility(View.GONE);
}
}
}
}
protected void visible(final View... views) {
if (views != null && views.length > 0) {
for (View view : views) {
if (view != null) {
view.setVisibility(View.VISIBLE);
}
}
}
}
protected boolean isVisible(View view) {
return view.getVisibility() == View.VISIBLE;
}
@Override
public void onResume() {
super.onResume();
MobclickAgent.onPageStart(getActivity().getClass().getName());
}
@Override
public void onPause() {
super.onPause();
MobclickAgent.onPageEnd(getActivity().getClass().getName());
}
} | [
"1179074755@qq.com"
] | 1179074755@qq.com |
9c86561ab9ab3e0ea98a77f180640963bd0a63e8 | e30db5883cb7d4099dfb62fc1e25aa9bd2bb978f | /src/main/java/AC.java | d78ced02439ff9cef3bc2d31963a3297dfa0bbde | [] | no_license | ltadangi/Test | a4a76cbe6fd64427a80bd78764047e69c6a8f786 | 4d7eb7a7c06dda4c1c35db1f579a44115a848ee5 | refs/heads/master | 2021-04-12T08:52:21.676780 | 2018-04-08T07:34:35 | 2018-04-08T07:34:35 | 126,671,676 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 73 | java | import testing1.AC;
public class AC {
public boolean power=false;
}
| [
"leelavathi.t@gmail.com"
] | leelavathi.t@gmail.com |
5fff7c58ca594bba98c7e16bfeb3d21187a87e38 | da02a5efb4c9b4e315ee6b913ae1f4fec4729f6c | /app/src/main/java/com/example/administrator/tour_menology/Adapter/shoucanghuodong_adapter.java | 3ad692f30b2f41e9a02d42ffd7e8b00131c5c1e3 | [] | no_license | yhYan7/tour_menology | 4a6367176cf4fa59bf33e8042dcea330d715cad1 | da3fa58be36dc228c8224b2840f992b1f690ac16 | refs/heads/master | 2021-01-21T10:08:56.557695 | 2017-02-28T03:33:14 | 2017-02-28T03:33:14 | 83,385,499 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,852 | java | package com.example.administrator.tour_menology.Adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.example.administrator.tour_menology.Bean.shoucanghuodong_list;
import com.example.administrator.tour_menology.Bean.zhaohuodong_list;
import com.example.administrator.tour_menology.R;
import java.util.List;
/**
* Created by Administrator on 2016/9/28 0028.
*/
public class shoucanghuodong_adapter extends BaseAdapter {
private List<shoucanghuodong_list.LIstdate> mList;
private Context mContext;
public shoucanghuodong_adapter(List<shoucanghuodong_list.LIstdate> list, Context context) {
mList = list;
mContext = context;
}
@Override
public int getCount() {
return mList.size();
}
@Override
public Object getItem(int position) {
return mList.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = null;
if (convertView == null) {
convertView = LayoutInflater.from(mContext).inflate(R.layout.item_main_list1,parent,false);
holder =new ViewHolder(convertView) ;
convertView.setTag(holder);
} else
holder = (ViewHolder) convertView.getTag();
holder.title.setText(mList.get(position).getActName());
holder.gaunzhu.setText(mList.get(position).getCountCollect());
holder.fabu.setText(mList.get(position).getAddress());
holder.date.setText(mList.get(position).getActDate());
Glide.with(mContext).load("http://bobtrip.com/tripcal"+mList.get(position).getImgPath()).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.img);
Log.i("", "====我的收藏图片-->>" + mList.get(position).getImgPath());
return convertView;
}
class ViewHolder {
private TextView title;
private TextView fabu;
private TextView gaunzhu;
private ImageView img;
private TextView date;
public ViewHolder(View convertView) {
title = (TextView) convertView.findViewById(R.id.main_list1_title);
fabu = (TextView) convertView.findViewById(R.id.main_list1_address);
gaunzhu = (TextView) convertView.findViewById(R.id.main_list1_guanzhu);
img = (ImageView) convertView.findViewById(R.id.main_List1_img);
date = (TextView) convertView.findViewById(R.id.main_list1_date);
}
}
}
| [
"982151220@qq.com"
] | 982151220@qq.com |
efeb67344c9767a8e830d97eaf9dca55ab64f578 | bca0526ca68c9635058e164930ae20363d28cdf8 | /src/com/clinkworld/pay/http/SimpleMultipartEntity.java | 21df8b03aded1d840741691e2e7159aa1c382398 | [] | no_license | zouguo/cw | db318f7a3dbb68b59685262cd2e98d4d9137842c | ea42c7953d62e139604b9f75dedc8e39d73fd6c0 | refs/heads/master | 2021-01-18T15:07:23.070374 | 2015-12-15T07:45:24 | 2015-12-15T07:45:24 | 48,027,215 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,396 | java | /*
Android Asynchronous Http Client
Copyright (c) 2011 James Smith <james@loopj.com>
http://loopj.com
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.
*/
/*
This code is taken from Rafael Sanches' blog.
http://blog.rafaelsanches.com/2011/01/29/upload-using-multipart-post-using-httpclient-in-android/
*/
package com.clinkworld.pay.http;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.message.BasicHeader;
import java.io.*;
import java.util.Random;
public class SimpleMultipartEntity implements HttpEntity {
private final static char[] MULTIPART_CHARS = "-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
private String boundary = null;
ByteArrayOutputStream out = new ByteArrayOutputStream();
boolean isSetLast = false;
boolean isSetFirst = false;
public SimpleMultipartEntity() {
final StringBuffer buf = new StringBuffer();
final Random rand = new Random();
for (int i = 0; i < 30; i++) {
buf.append(MULTIPART_CHARS[rand.nextInt(MULTIPART_CHARS.length)]);
}
this.boundary = buf.toString();
}
public void writeFirstBoundaryIfNeeds() {
if (!isSetFirst) {
try {
out.write(("--" + boundary + "\r\n").getBytes());
} catch (final IOException e) {
e.printStackTrace();
}
}
isSetFirst = true;
}
public void writeLastBoundaryIfNeeds() {
if (isSetLast) {
return;
}
try {
out.write(("\r\n--" + boundary + "--\r\n").getBytes());
} catch (final IOException e) {
e.printStackTrace();
}
isSetLast = true;
}
public void addPart(final String key, final String value) {
writeFirstBoundaryIfNeeds();
try {
out.write(("Content-Disposition: form-data; name=\"" + key + "\"\r\n\r\n").getBytes());
out.write(value.getBytes());
out.write(("\r\n--" + boundary + "\r\n").getBytes());
} catch (final IOException e) {
e.printStackTrace();
}
}
public void addPart(final String key, final String fileName, final InputStream fin, final boolean isLast) {
addPart(key, fileName, fin, "application/octet-stream", isLast);
}
public void addPart(final String key, final String fileName, final InputStream fin, String type, final boolean isLast) {
writeFirstBoundaryIfNeeds();
try {
type = "Content-Type: " + type + "\r\n";
out.write(("Content-Disposition: form-data; name=\"" + key + "\"; filename=\"" + fileName + "\"\r\n").getBytes());
out.write(type.getBytes());
out.write("Content-Transfer-Encoding: binary\r\n\r\n".getBytes());
final byte[] tmp = new byte[4096];
int l = 0;
while ((l = fin.read(tmp)) != -1) {
out.write(tmp, 0, l);
}
if (!isLast)
out.write(("\r\n--" + boundary + "\r\n").getBytes());
out.flush();
} catch (final IOException e) {
e.printStackTrace();
} finally {
try {
fin.close();
} catch (final IOException e) {
e.printStackTrace();
}
}
}
public void addPart(final String key, final File value, final boolean isLast) {
try {
addPart(key, value.getName(), new FileInputStream(value), isLast);
} catch (final FileNotFoundException e) {
e.printStackTrace();
}
}
@Override
public long getContentLength() {
writeLastBoundaryIfNeeds();
return out.toByteArray().length;
}
@Override
public Header getContentType() {
return new BasicHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
}
@Override
public boolean isChunked() {
return false;
}
@Override
public boolean isRepeatable() {
return false;
}
@Override
public boolean isStreaming() {
return false;
}
@Override
public void writeTo(final OutputStream outstream) throws IOException {
outstream.write(out.toByteArray());
}
@Override
public Header getContentEncoding() {
return null;
}
@Override
public void consumeContent() throws IOException,
UnsupportedOperationException {
if (isStreaming()) {
throw new UnsupportedOperationException(
"Streaming entity does not implement #consumeContent()");
}
}
@Override
public InputStream getContent() throws IOException,
UnsupportedOperationException {
return new ByteArrayInputStream(out.toByteArray());
}
} | [
"shirenhua@365ime.com"
] | shirenhua@365ime.com |
66c8d368d2498c0395ae69e77987b6240f0f20af | d231cf5808703d4c7631c6a814ad0c98e0fb3b24 | /app/src/main/java/ru/atc/bclient/model/entity/Account.java | a24c42f2ffbcb0078bc2fd4f245bc76ff65eb9fb | [] | no_license | jacksn/bcl | ffca8553c58958f40e6ad63b0b21912129ef0ac7 | af600189f7bbe3f2521b9df3aab09864d7fdc4ce | refs/heads/master | 2021-04-27T20:19:41.961722 | 2018-02-21T18:33:31 | 2018-02-21T18:33:31 | 122,376,655 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,964 | java | package ru.atc.bclient.model.entity;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import javax.persistence.AttributeOverride;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
@Getter
@Setter
@NoArgsConstructor
@RequiredArgsConstructor
@ToString(callSuper = true)
@Entity
@Table(name = "dim_account")
@AttributeOverride(name = "id", column = @Column(name = "account_id"))
@SequenceGenerator(name = "default_gen", sequenceName = "seq_account_id", allocationSize = 1)
public class Account extends BaseEntity {
@NonNull
@Column(name = "account_name")
@NotNull
@Size(max = 100)
private String name;
@NonNull
@Column(name = "account_num")
@NotNull
@Size(max = 100)
private String number;
@ManyToOne
@JoinColumn(name = "legal_entity_id", referencedColumnName = "legal_entity_id")
private LegalEntity legalEntity;
@NonNull
@ManyToOne(optional = false)
@NotNull
@JoinColumn(name = "bank_id", referencedColumnName = "bank_id")
private Bank bank;
@NonNull
@Column(name = "currency_code")
@NotNull
@Size(max = 10)
private String currencyCode;
@NonNull
@Column(name = "account_status_id")
@NotNull
private AccountStatus status;
public Account(Integer id, String name, String number, LegalEntity legalEntity, Bank bank, String currencyCode, AccountStatus status) {
super(id);
this.name = name;
this.number = number;
this.legalEntity = legalEntity;
this.bank = bank;
this.currencyCode = currencyCode;
this.status = status;
}
}
| [
"EugeneAkhramovich@gmail.com"
] | EugeneAkhramovich@gmail.com |
4365c45adb6613202675b2fbcd676925096692f7 | 0470726aec36a60cc381822637a42cb9be1fb7e4 | /Sudoku/src/capaPresentacion/JFrameRegistrarse.java | de5d297a2c3ef3e016343548005803c2e7f8f5df | [] | no_license | Martouta/Sudoku | 44f465d8144a0667412e4eeb570a5e56b7981a57 | 28ed9bca2987541fefc26fb7540472c8d14b107b | refs/heads/master | 2021-01-18T01:59:56.942313 | 2016-05-06T15:39:49 | 2016-05-06T15:39:49 | 45,053,078 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,402 | java | package capaPresentacion;
import java.awt.*;
import javax.swing.*;
public class JFrameRegistrarse extends JFrame{
private static final long serialVersionUID = 1L;
private JButton butRegistrarse;
private JButton butVolverMenuPrincipal;
private JButton butSalir;
private JLabel labNombreUsuario;
private JLabel labContrasena;
private JLabel labConfirmContrasena;
private JPanel panRegistrarse;
private JPasswordField passwordfieldContrasena;
private JPasswordField passwordfieldConfirmContrasena;
private JTextField textfieldNombreUsuario;
private JLabel labMensajeError;
private JLabel labCamposObligatorios;
public JFrameRegistrarse() {
initComponents();
}
public JButton getButRegistrarse() {
return butRegistrarse;
}
public JButton getButVolverMenuPrincipal() {
return butVolverMenuPrincipal;
}
public JButton getButSalir() {
return butSalir;
}
public String getNombreUsuario(){
return textfieldNombreUsuario.getText();
}
public String getContrasena(){
return new String(passwordfieldContrasena.getPassword());
}
public String getConfirmContrasena(){
return new String(passwordfieldConfirmContrasena.getPassword());
}
public void setMensajeError(String msj){
labMensajeError.setText(msj);
}
public void cleanValues(){
labMensajeError.setText("");
textfieldNombreUsuario.setText("");
passwordfieldContrasena.setText("");
passwordfieldConfirmContrasena.setText("");
}
private void initComponents() {
setTitle("Registrarse");
setSize(500,400); //ancho por alto
setMinimumSize(new Dimension(480, 400));
setResizable(true);
setDefaultCloseOperation(EXIT_ON_CLOSE);
panRegistrarse = new JPanel();
labNombreUsuario = new JLabel();
labContrasena = new JLabel();
labConfirmContrasena = new JLabel();
labMensajeError = new JLabel();
labCamposObligatorios = new JLabel();
butRegistrarse = new JButton();
butVolverMenuPrincipal = new JButton();
butSalir = new JButton();
textfieldNombreUsuario = new JTextField();
passwordfieldContrasena = new JPasswordField();
passwordfieldConfirmContrasena = new JPasswordField();
labNombreUsuario.setText("Nombre de usuario: ");
labContrasena.setText("Contrasena: ");
labConfirmContrasena.setText("Confirma la contrasena: ");
labMensajeError.setText("");
butRegistrarse.setText("Registrarse");
butVolverMenuPrincipal.setText("Volver al Menu Principal");
butSalir.setText("Salir");
textfieldNombreUsuario.setText("");
passwordfieldContrasena.setText("");
passwordfieldConfirmContrasena.setText("");
StringBuilder sb = new StringBuilder(64);
sb.append("<html>Campos obligatorios")
.append("<br/>Si no desea tener contrasena, deje los 2 campos de contrasena en blanco</html>");
labCamposObligatorios.setText(sb.toString());
textfieldNombreUsuario.setPreferredSize(new Dimension(100, 20));
passwordfieldContrasena.setPreferredSize(new Dimension(100, 20));
passwordfieldConfirmContrasena.setPreferredSize(new Dimension(100, 20));
labNombreUsuario.setPreferredSize(new Dimension(140, 20));
labContrasena.setPreferredSize(new Dimension(140, 20));
labConfirmContrasena.setPreferredSize(new Dimension(140, 20));
panRegistrarse.setLayout(new GridLayout(8,1));
JPanel panNameUser = new JPanel();
panNameUser.setLayout(new FlowLayout(FlowLayout.CENTER));
panNameUser.add(labNombreUsuario);
panNameUser.add(textfieldNombreUsuario);
JPanel panPassword = new JPanel();
panPassword.setLayout(new FlowLayout(FlowLayout.CENTER));
panPassword.add(labContrasena);
panPassword.add(passwordfieldContrasena);
JPanel panConfirmPassword = new JPanel();
panConfirmPassword.setLayout(new FlowLayout(FlowLayout.CENTER));
panConfirmPassword.add(labConfirmContrasena);
panConfirmPassword.add(passwordfieldConfirmContrasena);
JPanel panCamposObligatorios = new JPanel();
panCamposObligatorios.setLayout(new FlowLayout(FlowLayout.CENTER));
panCamposObligatorios.add(labCamposObligatorios);
JPanel panMensError = new JPanel();
panMensError.setLayout(new FlowLayout(FlowLayout.CENTER));
panMensError.add(labMensajeError);
JPanel panButRegistrarse = new JPanel();
panButRegistrarse.setLayout(new FlowLayout(FlowLayout.CENTER));
//panButRegistrarse.setBackground(new Color(0,0,0));
panButRegistrarse.add(butRegistrarse);
JPanel panButVolverMenuPrincipal = new JPanel();
panButVolverMenuPrincipal.setLayout(new FlowLayout(FlowLayout.CENTER));
panButVolverMenuPrincipal.add(butVolverMenuPrincipal);
JPanel panButSalir = new JPanel();
panButSalir.setLayout(new FlowLayout(FlowLayout.CENTER));
panButSalir.add(butSalir);
panRegistrarse.add(panNameUser);
panRegistrarse.add(panPassword);
panRegistrarse.add(panConfirmPassword);
panRegistrarse.add(panCamposObligatorios);
panRegistrarse.add(panMensError);
panRegistrarse.add(panButRegistrarse);
panRegistrarse.add(panButVolverMenuPrincipal);
panRegistrarse.add(panButSalir);
add(panRegistrarse);
}
}
| [
"marta.noya@est.fib.upc.edu"
] | marta.noya@est.fib.upc.edu |
b268c6467a79bae5716abcd46381a114a7afddba | 66f5ea8718fe4e78d378c3be50a7db57c87bf789 | /app/src/main/java/com/example/fcronin/fragments/PrivacyPolicyDialogFragment.java | 8cf2526f316fbdc8385cb26970cee077741c3fbd | [] | no_license | alizahid1996/FcRonin | f1eab5cc5628e63dc6bd1f6a99c16821ab258b9f | 1a12fce9e60d53b00f15138e47e53fe2fa4ec9bb | refs/heads/master | 2023-03-22T12:39:56.804617 | 2021-03-24T13:18:35 | 2021-03-24T13:18:35 | 350,847,136 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,181 | java | package com.example.fcronin.fragments;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
import android.widget.ProgressBar;
import com.example.fcronin.R;
public class PrivacyPolicyDialogFragment extends BaseFullDialogFragment {
private ProgressBar progressBar;
private Context context;
private WebView webView;
@Override
public void onAttach(Context context) {
super.onAttach(context);
this.context = context;
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_privacy, container);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
webView = view.findViewById(R.id.webView);
progressBar = view.findViewById(R.id.progressBar);
webView.setWebViewClient(new WebViewClient());
webView.loadUrl(getString(R.string.privacy_policy_url));
view.findViewById(R.id.back).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
}
public class WebViewClient extends android.webkit.WebViewClient {
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
progressBar.setVisibility(View.GONE);
}
}
}
| [
"ali.zahid050@gmail.com"
] | ali.zahid050@gmail.com |
0c9f3c14e994443172f0259e90ef3c4c087c9745 | 24b285f8ca80a357f1afef09a37dbf0f9fb3291f | /src/main/java/com/oneorzero/bean/LogoutBean.java | 0e1d51f31b91171037f390ef8912d089ae4eeed5 | [] | no_license | oneorzero0903/OneOrZero | e98f63bec7f5faf8a36263e931fa2dd83a314365 | a3cb0f719a7a5f4802de0f135f8e001933b33652 | refs/heads/master | 2023-01-14T22:47:11.824244 | 2020-11-29T11:32:43 | 2020-11-29T11:32:43 | 306,328,570 | 0 | 0 | null | 2020-10-29T03:45:58 | 2020-10-22T12:23:51 | JavaScript | UTF-8 | Java | false | false | 320 | java | package com.oneorzero.bean;
import javax.servlet.http.HttpSession;
public class LogoutBean {
HttpSession session;
public HttpSession getSession() {
return session;
}
public void setSession(HttpSession session) {
this.session = session;
}
public int getLogout() {
session.invalidate();
return 0;
}
}
| [
"sakurazaki0428@gmail.com"
] | sakurazaki0428@gmail.com |
32dabf3b9b8c0caf78387b86c92e0d79713a4fbd | b908931bf9f21badfd6ae935c16b73d3e0d81a75 | /src/main/java/com/vivebest/entity/User.java | 5c3d118831d1aa4dbad86e7abb49bfd9a167a062 | [] | no_license | zhuxiongw/springboot | 0b644960b1c9fe1f9d479447a0248a5d33b824d9 | 42181574837c6578a4e06d29b603d63285ed5be4 | refs/heads/master | 2020-06-12T15:07:28.226369 | 2016-12-09T06:52:01 | 2016-12-09T06:52:01 | 75,811,101 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 868 | java | package com.vivebest.entity;
import java.io.Serializable;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
public class User implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1879197482104259255L;
@Id
@GeneratedValue
String id;
String username;
String password;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "User [id=" + id + ", username=" + username + ", password=" + password + "]";
}
}
| [
"zhuxiongw@126.com"
] | zhuxiongw@126.com |
eee8aa5479854bf767062b52167391ac47c22d0e | 85b9203512e2bec31daee385a8aca1b6339a8096 | /test/src/FizzBuzz.java | 78826542692dd7afaeb6a5662c66bf4ce1babf2b | [] | no_license | LitvinenkoIra/java_elementary | 626593d66f06a61b0e3536157d1da6551297d806 | 9a0b43e75ae24e50d9c20a7849061e46a965191c | refs/heads/master | 2021-01-21T14:24:53.427750 | 2016-07-07T12:13:20 | 2016-07-07T12:13:20 | 59,149,879 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 503 | java |
public class FizzBuzz {
public static void main(String[] args) {
for(int i = 1; i < 100; i++) {
if (i % 3 == 0 ){
if (i % 5 == 0)
System.out.println("FizzBuzz");
else
System.out.println("Fizz");
}
else {
if (i % 5 == 0)
System.out.println("Buzz");
else
System.out.println(i);
}
}
}
}
| [
"Ira Litvinenko"
] | Ira Litvinenko |
8d93c34974af322cc8a86bc68d7ebe5db142d835 | 41b543f0a1f7336404bba9929e96b47178230907 | /ATAfinal/src/com/wipro/ata/bean/ReservationBean.java | 10d2c187430e907453b8a22174037b1f6f7a4111 | [] | no_license | AnkitVashist11/Ankit-java-project-intern | 0eff7548bdc2c86b1583b2d37a0475b890b8ce09 | f8e1da191c36c4c6d2163ded517e6a25ebb95d6d | refs/heads/master | 2023-05-30T16:32:18.062923 | 2021-06-21T16:23:16 | 2021-06-21T16:23:16 | 378,988,873 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,929 | java | package com.wipro.ata.bean;
import java.util.Date;
public class ReservationBean
{
private String reservationID ;
private String userID ;
private String routeID ;
private Date bookingDate;
private Date journeyDate ;
private String vehicleID ;
private String driverID ;
private String bookingStatus ;
private double totalFare ;
private String boardingPoint ;
private String dropPoint ;
public String getReservationID() {
return reservationID;
}
public void setReservationID(String reservationID) {
this.reservationID = reservationID;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
public String getRouteID() {
return routeID;
}
public void setRouteID(String routeID) {
this.routeID = routeID;
}
public Date getBookingDate() {
return bookingDate;
}
public void setBookingDate(Date bookingDate) {
this.bookingDate = bookingDate;
}
public Date getJourneyDate() {
return journeyDate;
}
public void setJourneyDate(Date journeyDate) {
this.journeyDate = journeyDate;
}
public String getVehicleID() {
return vehicleID;
}
public void setVehicleID(String vehicleID) {
this.vehicleID = vehicleID;
}
public String getDriverID() {
return driverID;
}
public void setDriverID(String driverID) {
this.driverID = driverID;
}
public String getBookingStatus() {
return bookingStatus;
}
public void setBookingStatus(String bookingStatus) {
this.bookingStatus = bookingStatus;
}
public double getTotalFare() {
return totalFare;
}
public void setTotalFare(double totalFare) {
this.totalFare = totalFare;
}
public String getBoardingPoint() {
return boardingPoint;
}
public void setBoardingPoint(String boardingPoint) {
this.boardingPoint = boardingPoint;
}
public String getDropPoint() {
return dropPoint;
}
public void setDropPoint(String dropPoint) {
this.dropPoint = dropPoint;
}
}
| [
"ankitvashist11@gamil.com"
] | ankitvashist11@gamil.com |
ab593167636264078ec2cad51a628fd203a777cb | d8a760fd362354f11fbfdb9eb6e0345cb72f8d4c | /aula10_DateTimeFormatter/src/aula10_DateTimeFormatter/Main.java | 9e618c544360cc2aa9d5529f5157bab1d2a60cb3 | [] | no_license | CamilaAmaral/DateTimeFormatter-Java1 | bc2c0f02c1fcee59b889db7871250a2ecd7c6e64 | 497be7b1e8911527130408fd2a6291acb5de459c | refs/heads/master | 2022-12-12T23:04:25.636913 | 2020-09-11T13:08:27 | 2020-09-11T13:08:27 | 294,697,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 822 | java | package aula10_DateTimeFormatter;
import java.time.Duration;
import java.time.LocalDateTime;
import java.time.Month;
import java.time.format.DateTimeFormatter;
public class Main {
public static void main(String[] args) {
LocalDateTime localDateTime = LocalDateTime.now();
LocalDateTime dataAniversario = LocalDateTime.of(1989, Month.DECEMBER, 18, 14,30,15);
DateTimeFormatter formatadorBarra = DateTimeFormatter.ofPattern("dd/MM/yyyy");
Duration duracao = Duration.between(dataAniversario, localDateTime);
System.out.println("Data nasc: " + dataAniversario.format(formatadorBarra));
System.out.println("Diferença entre datas em segundos: " + duracao.getSeconds());
System.out.println("Ano de nascimento foi bissexto? " + dataAniversario.toLocalDate().isLeapYear());
}
}
| [
"noreply@github.com"
] | CamilaAmaral.noreply@github.com |
b23db09363f022aa7144668a87073b0b643ab75f | 200099ef003e06457f3f6aebd0e455e09e55e4aa | /src/main/java/com/handy/aws/functions/HttpProductListResponse.java | f502611ad0299599d9cbf29dd5ebbd45597c50d8 | [] | no_license | monsonhaefel/handy3 | 76722dab402520a2035debc952cb17d230089538 | 139e973565404cd6aecbf0a4f962856b547ec3eb | refs/heads/master | 2020-04-13T17:02:03.619096 | 2019-01-18T15:15:24 | 2019-01-18T15:15:24 | 163,337,194 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,075 | java | package com.handy.aws.functions;
import com.google.gson.Gson;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.handy.aws.domain.Product;
public class HttpProductListResponse {
private String body;
String statusCode = "200";
Map<String, String> headers = new HashMap<String, String>();
// Using the Gson class and instruct a Gson instance
Gson gson = new Gson();
public HttpProductListResponse() {
super();
this.headers.put("Content-Type","application/json");
}
public HttpProductListResponse(String errorMsg) {
this();
this.body = errorMsg;
}
public HttpProductListResponse(List<Product> products) {
this();
this.body = gson.toJson(products);
}
public String getBody() {
return body;
}
public void setBody(List<Product> products) {
this.body = gson.toJson(products);
}
public void setBody(String errorMsg) {
this.body = errorMsg;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
}
| [
"pluralsight@richards-imac.lan"
] | pluralsight@richards-imac.lan |
513e6ea429ea2a16aa69e76eb4e52a63bf6844d9 | 3d880ab36886ff0effdf657b370d1fefc8f37853 | /glide/src/main/java/com/sdyl/easyblelib/glide/fragment/LifecycleCallback.java | 9bf50bcf1ab4b0af565ff53adfabfbdbf9387da3 | [] | no_license | doubizhu/Gildelib | 214292ce53729314802ff64ba427b807c9e9d374 | ad0287f029ba1df778a62ea32f4ad028981fab80 | refs/heads/master | 2022-11-13T14:24:17.433445 | 2020-07-14T08:17:14 | 2020-07-14T08:17:14 | 279,524,751 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 296 | java | package com.sdyl.easyblelib.glide.fragment;
// Fragment 监听
public interface LifecycleCallback {
// 生命周期 开始初始化了
void glideInitAction();
// 生命周期 停止了
void glideStopAction();
// 生命周期 释放操作
void glideRecycleAction();
}
| [
"123456"
] | 123456 |
14f7fa980e1679eea159cf294aab36f6cf740ee2 | cfd1abfff11825a3a8a176cf98eeb37e05b9b791 | /SWEA/MiddleValue_2063.java | 6582f2334f81db8469b4f51e988c316aa1298f26 | [] | no_license | qkrjh0904/AlgorithmStudy | 2c5cc4c13abbab72696d8d7429e5fa91bd62427d | adfa71ab757e675b55de36168404754479200153 | refs/heads/master | 2022-02-17T03:11:56.755243 | 2019-09-19T04:11:24 | 2019-09-19T04:11:24 | 198,194,681 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | import java.util.Arrays;
import java.util.Scanner;
public class MiddleValue_0717 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] nums = new int[n];
for(int i=0; i<n; ++i) {
nums[i] = sc.nextInt();
}
Arrays.sort(nums);
System.out.println(nums[n/2]);
}
}
| [
"jjwook1016@gmail.com"
] | jjwook1016@gmail.com |
c2fa3223686ec0936cad444f5a584230271cb80c | 138f79bc9495b6a6670eed8380a395dcecce7b89 | /Java-Spring-boot-Student-Management-System-master/student-management-system/src/main/java/com/studentmgr/service/impl/StudentsServiceImpl.java | 451fad4dfeec948f424ab5698cc406f9c8cdb5a9 | [] | no_license | yfhonholahola/enrollment | 4a47c86671cbb0aecc36eb8d5a56310fa9d51cc9 | 86c809ee2df684bf8df41f05bef2b1bd4541f15a | refs/heads/master | 2023-05-28T08:45:24.323855 | 2019-08-30T20:25:19 | 2019-08-30T20:25:19 | 203,215,846 | 0 | 0 | null | 2023-05-06T13:59:18 | 2019-08-19T17:07:44 | CSS | UTF-8 | Java | false | false | 608 | java | package com.studentmgr.service.impl;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.studentmgr.common.service.impl.GenericServiceImpl;
import com.studentmgr.dao.StudentsDao;
import com.studentmgr.model.Students;
import com.studentmgr.service.StudentsService;
@Service
public class StudentsServiceImpl extends GenericServiceImpl<Students> implements StudentsService {
@Autowired
protected StudentsDao studentsDao;
@PostConstruct
void init() {
init(Students.class, studentsDao);
}
}
| [
"yfhon2-c@ad-cityu.edu.hk"
] | yfhon2-c@ad-cityu.edu.hk |
deed94e1d826f267d84c12bb4dca2111b38dcb15 | 53042b8c049a850027bd63f8cb95f81b3e61479e | /src/main/java/ab/tjl/tscommunity/dto/QuestionQueryDTO.java | db5988106dfbb728788d519cd3fb22886b6ae2d4 | [] | no_license | tangjilin-java/community | 51817bc4b9bc5cd78754b0d7c9195bfe4cd229ab | 08ea6c1b763e9d6faad2b2e382fdfa3fe894cd26 | refs/heads/master | 2022-06-27T02:22:58.216565 | 2019-11-07T05:59:00 | 2019-11-07T05:59:00 | 204,135,830 | 1 | 0 | null | 2022-06-21T01:46:49 | 2019-08-24T09:20:38 | JavaScript | UTF-8 | Java | false | false | 356 | java | package ab.tjl.tscommunity.dto;
import lombok.Data;
/**
* @author:tangjilin
* @Description:搜索数据
* @Date:Created in 14:10 2019/8/30
* @Modified By:
*/
@Data
public class QuestionQueryDTO {
private String search;
private String sort;
private Long time;
private String tag;
private Integer page;
private Integer size;
}
| [
"1037766906@qq.com"
] | 1037766906@qq.com |
cb7f005ff5fc363369bafe4690876421fe6e35d8 | e64dac3b20d87aac6b4d1bca0498adbcbe5ab315 | /src/test/java/org/talangsoft/maze/explorer/MazeExplorerTest.java | e44725b20d3873df1581b92430557b8112431ab1 | [] | no_license | tamaslang/maze | f722a9600573a8b5a6a8478da96de9ad09efcb4c | e57b362e9db6fb317c364ca58ed1518f7e9edf7e | refs/heads/master | 2021-01-20T12:06:27.418918 | 2017-04-24T15:07:06 | 2017-04-24T15:07:06 | 86,561,072 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 10,913 | java | package org.talangsoft.maze.explorer;
import org.talangsoft.maze.model.Maze;
import org.talangsoft.maze.model.MazeCoordinate;
import org.talangsoft.maze.model.MazeStructure;
import org.junit.Before;
import org.junit.Test;
import java.util.Arrays;
import java.util.Optional;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class MazeExplorerTest {
private final int mazeDimension = 10;
private final MazeCoordinate bottomRightCorner = new MazeCoordinate(mazeDimension - 1, mazeDimension - 1);
private final MazeCoordinate topLeftCorner = new MazeCoordinate(0, 0);
private final Maze mazeMock = mock(Maze.class);
private final MazeCoordinate startLocation = new MazeCoordinate(1, 1);
@Before
public void Setup() {
when(mazeMock.getStartLocation()).thenReturn(startLocation);
when(mazeMock.getDimensionX()).thenReturn(mazeDimension);
when(mazeMock.getDimensionY()).thenReturn(mazeDimension);
}
@Test
public void shouldInitializeInStartLocationTest() {
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
ExplorerPosition loc = explorer.getPosition();
assertThat(loc.getDirection(), is(HeadingDirectionClockWise.UP));
assertThat(loc.getCoordinate(), is(startLocation));
}
@Test
public void shouldMoveForwardToUpIfFieldIsSpace() {
shouldMoveUpWhenFieldIs(new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP), MazeStructure.SPACE);
}
@Test
public void shouldMoveForwardToUpIfFieldIsExit() {
shouldMoveUpWhenFieldIs(new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP), MazeStructure.EXIT);
}
@Test
public void shouldMoveForwardToUpIfFieldIsStart() {
shouldMoveUpWhenFieldIs(new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP), MazeStructure.START);
}
@Test
public void shouldThrowExceptionWhenMoveForwardAndFieldIsWall() {
when(mazeMock.whatsAt(startLocation.above())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThatThrownBy(() ->
explorer.moveForward()
).isInstanceOf(MovementBlockedException.class)
.hasMessageContaining("Movement to location MazeCoordinate{x=1, y=0} is blocked!");
}
@Test
public void shouldThrowExceptionWhenMoveToUpAndFieldIsOutOfBounds() {
when(mazeMock.getStartLocation()).thenReturn(topLeftCorner);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThatThrownBy(() ->
explorer.moveForward()
).isInstanceOf(FieldIsOutOfMazeBoundsException.class)
.hasMessageContaining("Field is out of the maze!");
}
@Test
public void shouldThrowExceptionWhenMoveToLeftAndFieldIsOutOfBounds() {
when(mazeMock.getStartLocation()).thenReturn(topLeftCorner);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.LEFT);
assertThatThrownBy(() ->
explorer.moveForward()
).isInstanceOf(FieldIsOutOfMazeBoundsException.class)
.hasMessageContaining("Field is out of the maze!");
}
@Test
public void shouldThrowExceptionWhenMoveToDownAndFieldIsOutOfBounds() {
when(mazeMock.getStartLocation()).thenReturn(bottomRightCorner);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.DOWN);
assertThatThrownBy(() ->
explorer.moveForward()
).isInstanceOf(FieldIsOutOfMazeBoundsException.class)
.hasMessageContaining("Field is out of the maze!");
}
@Test
public void shouldThrowExceptionWhenMoveToRightAndFieldIsOutOfBounds() {
when(mazeMock.getStartLocation()).thenReturn(bottomRightCorner);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.RIGHT);
assertThatThrownBy(() ->
explorer.moveForward()
).isInstanceOf(FieldIsOutOfMazeBoundsException.class)
.hasMessageContaining("Field is out of the maze!");
}
@Test
public void shouldMoveToRightIfFieldIsSpace() {
when(mazeMock.whatsAt(startLocation.toTheRight())).thenReturn(MazeStructure.SPACE);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.RIGHT);
explorer.moveForward();
ExplorerPosition loc = explorer.getPosition();
assertThat(loc.getDirection(), is(HeadingDirectionClockWise.RIGHT));
assertThat(loc.getCoordinate(), is(startLocation.toTheRight()));
}
@Test
public void shouldMoveToLeftIfFieldIsSpace() {
when(mazeMock.whatsAt(startLocation.toTheLeft())).thenReturn(MazeStructure.SPACE);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.LEFT);
explorer.moveForward();
ExplorerPosition loc = explorer.getPosition();
assertThat(loc.getDirection(), is(HeadingDirectionClockWise.LEFT));
assertThat(loc.getCoordinate(), is(startLocation.toTheLeft()));
}
@Test
public void shouldMoveDownIfFieldIsSpace() {
when(mazeMock.whatsAt(startLocation.below())).thenReturn(MazeStructure.SPACE);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.DOWN);
explorer.moveForward();
ExplorerPosition loc = explorer.getPosition();
assertThat(loc.getDirection(), is(HeadingDirectionClockWise.DOWN));
assertThat(loc.getCoordinate(), is(startLocation.below()));
}
@Test
public void whatsInFrontShouldReturnWallIfAbove() {
when(mazeMock.whatsAt(startLocation.above())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.whatsInFront(), is(Optional.of(MazeStructure.WALL)));
}
@Test
public void whatsInFrontShouldReturnWallIfLeft() {
when(mazeMock.whatsAt(startLocation.toTheLeft())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.LEFT);
assertThat(explorer.whatsInFront(), is(Optional.of(MazeStructure.WALL)));
}
@Test
public void whatsInFrontShouldReturnWallIfRight() {
when(mazeMock.whatsAt(startLocation.toTheRight())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.RIGHT);
assertThat(explorer.whatsInFront(), is(Optional.of(MazeStructure.WALL)));
}
@Test
public void whatsInFrontShouldReturnWallIfDown() {
when(mazeMock.whatsAt(startLocation.below())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.DOWN);
assertThat(explorer.whatsInFront(), is(Optional.of(MazeStructure.WALL)));
}
@Test
public void whatsInFrontShouldReturnNoneIfOutOfBounds() {
when(mazeMock.getStartLocation()).thenReturn(topLeftCorner);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.whatsInFront(), is(Optional.empty()));
}
@Test
public void whatsAtMyLocationReturnTheCurrentLocationType() {
when(mazeMock.whatsAt(startLocation)).thenReturn(MazeStructure.EXIT);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.whatsAtMyLocation(), is(MazeStructure.EXIT));
}
@Test
public void getPossibleDirectionsShouldReturnAllTheDirectionsIfExplorerCanMoveThere() {
when(mazeMock.whatsAt(startLocation.below())).thenReturn(MazeStructure.SPACE);
when(mazeMock.whatsAt(startLocation.above())).thenReturn(MazeStructure.SPACE);
when(mazeMock.whatsAt(startLocation.toTheLeft())).thenReturn(MazeStructure.SPACE);
when(mazeMock.whatsAt(startLocation.toTheRight())).thenReturn(MazeStructure.SPACE);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.getPossibleDirections(), is(Arrays.asList(HeadingDirectionClockWise.values())));
}
@Test
public void getPossibleDirectionsShouldReturnNoTheDirectionsIfExplorerCannotMoveAnywhere() {
when(mazeMock.whatsAt(startLocation.below())).thenReturn(MazeStructure.WALL);
when(mazeMock.whatsAt(startLocation.above())).thenReturn(MazeStructure.WALL);
when(mazeMock.whatsAt(startLocation.toTheLeft())).thenReturn(MazeStructure.WALL);
when(mazeMock.whatsAt(startLocation.toTheRight())).thenReturn(MazeStructure.WALL);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.getPossibleDirections(), is(Arrays.asList(new HeadingDirectionClockWise[]{})));
}
@Test
public void movementShouldBeTracked() {
when(mazeMock.whatsAt(startLocation.above())).thenReturn(MazeStructure.SPACE);
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
explorer.moveForward();
assertThat(explorer.getPosition(), is(new ExplorerPosition(new MazeCoordinate(1, 0), HeadingDirectionClockWise.UP)));
explorer.turnLeft();
when(mazeMock.whatsAt(new MazeCoordinate(1, 0).toTheLeft())).thenReturn(MazeStructure.SPACE);
explorer.moveForward();
assertThat(explorer.getPosition(), is(new ExplorerPosition(new MazeCoordinate(0, 0), HeadingDirectionClockWise.LEFT)));
assertThat(explorer.getMovement(), is(Arrays.asList(
new MazeCoordinate[]{
new MazeCoordinate(1, 1),
new MazeCoordinate(1, 0),
new MazeCoordinate(0, 0)
}
)));
}
@Test
public void turnToShouldSetDirection() {
MazeExplorer explorer = new MazeExplorer(mazeMock, HeadingDirectionClockWise.UP);
assertThat(explorer.getPosition().getDirection(), is(HeadingDirectionClockWise.UP));
explorer.turnTo(HeadingDirectionClockWise.DOWN);
assertThat(explorer.getPosition().getDirection(), is(HeadingDirectionClockWise.DOWN));
}
private void shouldMoveUpWhenFieldIs(MazeExplorer explorer, MazeStructure field) {
when(mazeMock.whatsAt(startLocation.above())).thenReturn(field);
explorer.moveForward();
ExplorerPosition loc = explorer.getPosition();
assertThat(loc.getDirection(), is(HeadingDirectionClockWise.UP));
assertThat(loc.getCoordinate(), is(startLocation.above()));
}
}
| [
"tamas.lang@talangsoft.org"
] | tamas.lang@talangsoft.org |
0ba1387cbf896f0f70771c078bc802294f54e55e | f39a93222b1ba17a4d1cb8ae8340186d51bf5590 | /src/collection/simple_bindings/SimpleBindingsImpl.java | 106551911538eab89a918ad817f6b8b9ff765db6 | [] | no_license | cocodas/javaBasic | c625b88d5f65c30e4dbe6281ed850b960217acd1 | 22bae8817742ca98d05bb0a7ffe572f1682b5990 | refs/heads/master | 2018-12-28T21:48:50.420389 | 2015-09-12T09:13:02 | 2015-09-12T09:13:17 | 25,062,807 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,728 | java | package collection.simple_bindings;
import java.util.Collection;
import java.util.Map;
import java.util.Set;
import javax.script.SimpleBindings;
public class SimpleBindingsImpl {
private SimpleBindings simpleBindings;
/** Default constructor uses a HashMap. **/
public SimpleBindingsImpl()
{
simpleBindings = new SimpleBindings();
}
/** Constructor uses an existing Map to store the values. **/
public SimpleBindingsImpl(Map<String, Object> m)
{
simpleBindings = new SimpleBindings(m);
}
/** Removes all of the mappings from this map. **/
public void clear()
{
simpleBindings.clear();
}
/** Returns true if this map contains a mapping for the specified key. **/
public boolean containsKey(Object key)
{
return simpleBindings.containsKey(key);
}
/** Returns true if this map maps one or more keys to the specified value. **/
public boolean containsValue(Object value)
{
return simpleBindings.containsValue(value);
}
/** Returns a Set view of the mappings contained in this map. **/
public Set<Map.Entry<String, Object>> entrySet()
{
return simpleBindings.entrySet();
}
/**
* Returns the value to which the specified key is mapped, or null if this
* map contains no mapping for the key.
**/
public Object get(Object key)
{
return simpleBindings.get(key);
}
/** Returns true if this map contains no key-value mappings. **/
public boolean isEmpty()
{
return simpleBindings.isEmpty();
}
/** Returns a Set view of the keys contained in this map. **/
public Set<String> keySet()
{
return simpleBindings.keySet();
}
/** Associates the specified value with the specified key in this map. **/
public Object put(String key, Object value)
{
return simpleBindings.put(key, value);
}
/** Copies all of the mappings from the specified map to this map. **/
public void putAll(Map<? extends String, ? extends Object> m)
{
simpleBindings.putAll(m);
}
/** Removes the mapping for the specified key from this map if present. **/
public Object remove(Object key)
{
return simpleBindings.remove(key);
}
/** Returns the number of key-value mappings in this map. **/
public int size()
{
return simpleBindings.size();
}
/** Returns a Collection view of the values contained in this map. **/
public Collection<Object> values()
{
return simpleBindings.values();
}
}
| [
"sunq0011@gmail.com"
] | sunq0011@gmail.com |
9130f4590cf2405205fb031f37ac59e239586f46 | 672afc67533f674f2cae121168a8300129ca3a05 | /app/src/main/java/com/example/jickay/top6/notifications/OnAlarmReceiver.java | ce220e01d7e3f4f9c51297425db942ee1c43787b | [] | no_license | jickay/Top6 | c7e4b50fbd2c6c5ce4017951f9516e4c89f07043 | 82ed2d5feafc68b5eefbf3975edd237d9f43e991 | refs/heads/master | 2020-04-05T13:04:51.311575 | 2017-10-03T17:41:39 | 2017-10-03T17:41:39 | 95,064,895 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,147 | java | package com.example.jickay.top6.notifications;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.content.ContextCompat;
import android.util.Log;
import com.example.jickay.top6.MainActivity;
import com.example.jickay.top6.R;
import com.example.jickay.top6.provider.TaskProvider;
/**
* Created by User on 8/24/2017.
*/
public class OnAlarmReceiver extends BroadcastReceiver {
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
int id = (int) intent.getLongExtra(TaskProvider.COLUMN_TASKID,0);
String title = intent.getStringExtra(TaskProvider.COLUMN_TITLE);
int color = intent.getIntExtra(TaskProvider.COLUMN_IMPORTANCE,R.color.cardview_dark_background);
int daysBefore = intent.getIntExtra("AlarmDaysBefore",0);
NotificationManager nMgr = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Intent toMainActivity = new Intent (context, MainActivity.class);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, toMainActivity, PendingIntent.FLAG_ONE_SHOT);
// Default notification for early warning
String message;
int icon;
// Change icon and message for overdue and empty conditions
if (action.matches("Overdue")) {
icon = R.drawable.ic_error_black_24dp;
message = "TASK IS OVERDUE!";
} else if (action.matches("Empty")) {
icon = R.drawable.ic_format_list_bulleted_black_24dp;
message = "Sweet! You're done all your tasks!";
title = "Go add some more when you're ready";
} else {
if (daysBefore == 0) {
message = "Task due today:";
} else if (daysBefore == 1) {
message = "Task due in 1 day:";
} else {
message = "Task due in " + Integer.toString(daysBefore) + " days:";
}
icon = R.drawable.ic_access_time_black_24dp;
}
// Build actual notification
Notification note = new Notification.Builder(context)
.setDefaults(0)
.setContentTitle(message)
.setContentText(title)
.setSmallIcon(icon)
.setColor(ContextCompat.getColor(context,color))
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setVibrate(new long[] { 0, 100, 100, 50, 100, 50, 100, 50 })
.setLights(Color.RED,1000,1000)
.build();
// Make overdue notifications sticky
if (action.matches("Overdue")) {
note.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT;
}
nMgr.notify(id,note);
}
}
| [
"jickay@gmail.com"
] | jickay@gmail.com |
ce59a841d36a9a3e291be145b63df9dffca22de8 | f36e146307944db43ae3a9bccd510e2b7f7ccb58 | /app/src/main/java/demo/example/com/mydrinkwater/otheractivity/DingshiActivity.java | 5726a54c43c478e59add24a145759b570613bcd9 | [] | no_license | zhizhi1hao/MyDrinkWater | 68bf20508f8a4adb277ed8bc022df633c069f5a8 | ce5138a9ced4b88fb274db392b5ead021eec76d9 | refs/heads/master | 2021-01-01T19:38:46.734357 | 2015-04-28T01:59:39 | 2015-04-28T01:59:39 | 34,701,876 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,495 | java | package demo.example.com.mydrinkwater.otheractivity;
import android.support.v4.view.ViewCompat;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListView;
import demo.example.com.mydrinkwater.R;
import demo.example.com.mydrinkwater.adapter.TiXingAdapter;
import demo.example.com.mydrinkwater.adapter.TiXingAdapter2;
import demo.example.com.mydrinkwater.zidiyiview.TixinRecyleLayout;
import demo.example.com.mydrinkwater.zidiyiview.TixingView;
public class DingshiActivity extends ActionBarActivity implements View.OnClickListener{
private ListView lv;
private TixinRecyleLayout recyclerView;
private TiXingAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dingshi);
recyclerView=(TixinRecyleLayout)findViewById(R.id.rcylv);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
adapter=new TiXingAdapter(this);
recyclerView.setAdapter(adapter);
//
// lv=(ListView)findViewById(R.id.lv);
//
// lv.setAdapter(new TiXingAdapter2(this));
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_dingshi, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onClick(View v) {
TixingView ttv=(TixingView) v.findViewById(R.id.txview);
}
}
| [
"445383232@qq.com"
] | 445383232@qq.com |
b67372fa20fe65cd386c92c25c584cfa89db75db | dac1794dfbdb182af8c3a33fe34cafd29905c291 | /kam.demo/src/main/java/com/kam/tomcat/MySpringApplication.java | 634880bb823ba238866d0bb514670b5b23f5aafc | [
"Apache-2.0"
] | permissive | Tim1999/spring-framework-5.0.x | 7d4628c786c0a7284959030de1b4a757727b36d5 | 8355750beb9bdbca1fabd3d4dd71c3d1ebbb57f1 | refs/heads/master | 2020-06-14T00:19:33.256721 | 2019-04-24T07:53:08 | 2019-04-24T07:53:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,181 | java | package com.kam.tomcat;
import com.kam.config.Config;
import org.apache.catalina.Context;
import org.apache.catalina.LifecycleException;
import org.apache.catalina.Wrapper;
import org.apache.catalina.startup.Tomcat;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import java.io.File;
public class MySpringApplication {
public static void run() {
//spring初始化
AnnotationConfigWebApplicationContext appContext = new AnnotationConfigWebApplicationContext();
appContext.register(Config.class);
appContext.refresh();
File base = new File(System.getProperty("java.io.tmpdir"));
//tomcat启动
Tomcat tomcat = new Tomcat();
tomcat.setPort(8080);
Context context = tomcat.addContext("/", base.getAbsolutePath());
DispatcherServlet dispatcherServlet = new DispatcherServlet(appContext);
Wrapper wrapper = tomcat.addServlet("/", "dispatcherServlet", dispatcherServlet);
wrapper.setLoadOnStartup(1);
wrapper.addMapping("/");
try {
tomcat.start();
tomcat.getServer().await();
} catch (LifecycleException e) {
e.printStackTrace();
}
}
}
| [
"123"
] | 123 |
44947d872fe1f4abcdd0bbd66ff7dd463649a585 | 764ea5105c51b6088543e3aeb2573d57f4bbad7d | /java/speedtest/src/main/java/com/kevinsprong/TimedArrayLoop.java | 9d999bad729fcea477d78879f75eb4cf56401bb4 | [] | no_license | kevinsprong23/speedtest | 7a46613a3d9b40864414f87542036e6c004db4b9 | b14ae371a7597df5c829f4df3afe2a926a594403 | refs/heads/master | 2021-01-19T06:35:18.384071 | 2014-06-18T12:20:56 | 2014-06-18T12:20:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 379 | java | package com.kevinsprong;
public class TimedArrayLoop {
public static void ArrayLoop() {
// make an array
int[] x = new int[10000000];
for (int i = 0; i < 10000000; i++) {
x[i] = 1; // java.util.Arrays.fill uses a loop internally anyways
}
// loop and multiply each element by 2
@SuppressWarnings("unused")
int y;
for(int el : x) {
y = el * 2;
}
}
}
| [
"ksprong@mitre.org"
] | ksprong@mitre.org |
3e3de1b0716d10efec33a2e80d4f5700f11edf47 | 4341dc1db4734b47bee3fa67a7d5d9f8b8274d38 | /app/src/androidTest/java/abhiandroid/com/simpletoolbarexample/ApplicationTest.java | 242eb109007431966bfb212447351e1ea25eb622 | [] | no_license | hung257/SimpleToolbarExample | f88ba017e6ba73e2b34c8b12deba22d077e3124e | 3b54a13107cd5e000b512c4f475fd94aeb53b45f | refs/heads/master | 2020-08-13T16:46:39.763780 | 2019-10-14T09:38:04 | 2019-10-14T09:38:04 | 215,003,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 367 | java | package abhiandroid.com.simpletoolbarexample;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"="
] | = |
d26599d101a524c50c84116b175947c71ed435cc | 662d4dd5a0844b81a572df4a6b98c28f34977842 | /src/main/java/com/zenika/decathlon/tp7/ConflitDeCompteException.java | 4375e6c915dce66569548f9ef6117838d313b7c1 | [] | no_license | Zenika/decathlon-coding-school-java-tp-7 | 112d40874634b7e609f3cc5b396f78715541d611 | ad073ffbe201da2fd4f9496013e2ebd4a6c247f1 | refs/heads/master | 2020-04-29T02:43:31.039820 | 2019-04-01T11:42:26 | 2019-04-01T11:42:26 | 175,781,204 | 0 | 7 | null | null | null | null | UTF-8 | Java | false | false | 184 | java | package com.zenika.decathlon.tp7;
public class ConflitDeCompteException extends VirementException {
public ConflitDeCompteException(String format) {
super(format);
}
}
| [
"nicolas.delsaux@zenika.com"
] | nicolas.delsaux@zenika.com |
ecf60c0c0712978c1f6a47e65e22d8cdb9fd5e0e | 495c3224bb76476c96576c6b4ce79a096b62774f | /EcoBikeApp/src/station/UserStationPageController.java | f90c6de61c4576750b76f32578598631e69afb33 | [] | no_license | hayasakayangg/traxe | 75f4a4838397ba587479457a3c37201716823117 | 0cc2d427a0ad37f2491f3984e712876f71d70a3a | refs/heads/main | 2023-02-04T04:52:35.801313 | 2020-12-22T06:52:27 | 2020-12-22T06:52:27 | 323,544,745 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,185 | java | package station;
import java.util.List;
import java.util.Map;
import javax.swing.JPanel;
import com.eco.bean.Station;
import api.StationApi;
public class UserStationPageController {
private String address;
private StationPagePane pagePane;
private StationListPane listPane;
private StationSearchPane searchPane;
public UserStationPageController() {
super();
}
public UserStationPageController(String address) {
super();
this.address = address;
listPane = new StationListPane();
searchPane = new StationSearchPane();
listPane.setController(this);
searchPane.setController(this);
searchPane.addressSearch(address);
pagePane = new StationPagePane(listPane,searchPane);
pagePane.setController(this);
}
public JPanel getStationPane() {
return pagePane;
}
public void search(Map<String, String> queryParams) {
List<Station> list = new StationApi().getStation(queryParams);
listPane.updateData(list);
}
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public StationSinglePane createSinglePane() {
return new StationSinglePane(this);
}
}
| [
"hayasakayang@gmail.com"
] | hayasakayang@gmail.com |
21f6024d19422fbdf43d4ca3cdbea1a953ccff88 | 9adf176a5863c35be9b912c16b89250ec2bb30e6 | /src/main/java/ru/effector/glu/model/Delta.java | 8bb6f9e5229e0a0cd6d4f908af5d0a7c7c69e31c | [] | no_license | a8t3r/glu-client | 2d5c6e8ce90233e66cffbe2abe2f52f8ed5a32be | 593b6465c944128e8630deea1e06f377eef4ef68 | refs/heads/master | 2016-09-05T21:19:33.496128 | 2015-07-31T15:56:23 | 2015-07-31T15:56:23 | 39,827,301 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 207 | java | package ru.effector.glu.model;
import java.util.Map;
/**
* @author Alexandr Kolosov
* @since 28.07.2015
*/
public class Delta {
public String accuracy;
public Map<String, DeltaEntry> delta;
}
| [
"winter.schweigen@gmail.com"
] | winter.schweigen@gmail.com |
ebc29d925cad664f5c47d4da08b26688e1a54820 | e3a8770506f64d81990e8ed3c4f74c3fe3ae497e | /programming-java/PROGRAMMING HELPERS/Number/Dec2Hex.java | b02e77201fcd09a7128b1da77db20881a9597a04 | [] | no_license | Sriharsha-Singam/JavaPrograms | f816dbc25850b30ffcea458cf1b75149d3a4fc4a | 326686732d69d6c4a49052de3e7262b13c6022ab | refs/heads/master | 2021-08-31T10:24:11.206678 | 2017-12-21T02:36:10 | 2017-12-21T02:36:10 | 114,944,369 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 804 | java | import java.io.*;
class Dec2Hex
{
public static void main(String aaa[])throws IOException
{
BufferedReader br=new BufferedReader (new InputStreamReader(System.in));
System.out.print("Enter a decimal number : ");
int n=Integer.parseInt(br.readLine());
int r;
String s=""; //variable for storing the result
//array storing the digits (as characters) in a hexadecimal number system
char dig[]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
while(n>0)
{
r=n%16; //finding remainder by dividing the number by 16
s=dig[r]+s; //adding the remainder to the result
n=n/16;
}
System.out.println("Output = "+s);
}
}
| [
"harshasingam3@gmail.com"
] | harshasingam3@gmail.com |
d4497c010939946c6f1344169858076a26ecd0ad | 57fdba3d199c1bf5ea7fc31208fdcc6532e4016d | /src/main/java/annotations/database/TableCreator.java | 254f75ac4ba3e7ef9868019a37d6c0a18933be64 | [] | no_license | yujmh/thinking-in-java | c8ec89f757fab079dc22e87cd49eeaf8be0e3c24 | 9c3620f7a919ac0c7c68cbeca5cf034dea9dbcfc | refs/heads/master | 2020-03-26T21:36:01.506688 | 2018-09-17T14:13:53 | 2018-09-17T14:13:53 | 145,397,329 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,055 | java | package annotations.database;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
public class TableCreator {
public static void main(String[] args) throws Exception {
args = new String[]{"annotations.database.Member"};
for (String className : args) {
Class<?> cl = Class.forName(className);
DBTable dbTable = cl.getAnnotation(DBTable.class);
if (dbTable == null) {
System.out.println("No DBTable annotations in class " + className);
continue;
}
String tableName = dbTable.name();
// If the name is empty, use the Class name:
if (tableName.length() < 1) {
tableName = cl.getSimpleName().toUpperCase();
}
List<String> columnDefs = new ArrayList<>();
for (Field field : cl.getDeclaredFields()) {
String columnName = null;
Annotation[] anns = field.getDeclaredAnnotations();
if (anns.length < 1) {
continue; // Not a db table column
}
if (anns[0] instanceof SQLInteger) {
SQLInteger sInt = (SQLInteger) anns[0];
// Use field name if name not specified
if (sInt.name().length() < 1) {
columnName = field.getName().toUpperCase();
} else {
columnName = sInt.name();
}
columnDefs.add(columnName + " INT" + getConstrains(sInt.constrains()));
} else if (anns[0] instanceof SQLString) {
SQLString sString = (SQLString) anns[0];
// Use field name if name not specified
if (sString.name().length() < 1) {
columnName = field.getName().toUpperCase();
} else {
columnName = sString.name();
}
columnDefs.add(columnName + " VARCHAR(" + sString.value() + ")" + getConstrains(sString.constrains()));
}
}
StringBuilder createCommand = new StringBuilder("CREATE TABLE ").append(tableName).append("(");
for (String columnDef : columnDefs) {
createCommand.append("\n ").append(columnDef).append(",");
}
createCommand.deleteCharAt(createCommand.length() - 1).append(");");
System.out.println("Table Creation SQL for " + className + " is: \n" + createCommand.toString());
}
}
private static String getConstrains(Constraints con) {
String constrains = "";
if (!con.allowNull()) {
constrains += " NOT NULL";
}
if (con.primaryKey()) {
constrains += " PRIMARY KEY";
}
if (con.unique()) {
constrains += " UNIQUE";
}
return constrains;
}
}
| [
"cheng.cheng@shatacloud.com"
] | cheng.cheng@shatacloud.com |
5180d23dca6991bd6dcb2d6f10966b165c01e8f4 | 1ef2d5df62d91696a047cc2b69eebc36f6b1f8b5 | /s2csv-tutorial/src/main/java/org/seasar/s2csv/tutorial/entity/Dept.java | 5ed69a5bf7801c3adf401cad4b67c45f2bfa50ed | [
"Apache-2.0"
] | permissive | seasarorg/s2csv | 0bd24e89e9b32ad4a80ac726f220559e3799c387 | 01ef501c246ff3f12b33483bbeeb529c67fb9caa | refs/heads/master | 2021-01-19T14:06:23.223480 | 2013-10-08T06:14:39 | 2013-10-08T06:14:39 | 13,405,022 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 505 | java | package org.seasar.s2csv.tutorial.entity;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Version;
@Entity
public class Dept {
@Id
@GeneratedValue
public Long id;
@Column(name="DEPT_NO")
public Integer deptNo;
@Column(name="DEPT_NAME")
public String deptName;
public String loc;
@Version
@Column(name="VERSION_NO")
public Integer versionNo;
} | [
"t.newtaro@gmail.com"
] | t.newtaro@gmail.com |
e91608a314058f49184f31c2ea182ddae0e3956f | 1a6491562aa7529aa99548db535e1bd5d48aa60b | /HobbyLobby/src/main/java/com/hobbylobby/service/UserDetailsServiceImpl.java | eba565dc5135628f195e1dd1c146070daf2e36ed | [] | no_license | MalihaBakhshi/HobbyLobby | fc6ff931bc4cecf9f5a1f156a93fa78e792265e9 | 41144367e043929920946bc53e8048d39e0ca2db | refs/heads/main | 2023-03-06T05:53:28.723426 | 2021-01-14T05:28:35 | 2021-01-14T05:28:35 | 301,791,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 916 | java | package com.hobbylobby.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;
import com.hobbylobby.domain.User;
import com.hobbylobby.repository.UserRepository;
import com.hobbylobby.security.CustomSecurityUser;
@Service
public class UserDetailsServiceImpl implements UserDetailsService {
@Autowired
private UserRepository userRepo;
@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user=userRepo.findByUsername(username);
if(user == null)
throw new UsernameNotFoundException("Invalid Username and Password");
return new CustomSecurityUser(user);
}
}
| [
"malihabakhshi01@gmail.com"
] | malihabakhshi01@gmail.com |
c91339ab9bdd37365771b3043a9c366460cff395 | 74ca72a287d13b4a677069f6a82998e684e5af81 | /dsj_house/dsj-wap/src/main/java/com/dsj/data/web/utils/QRCodeUtil.java | 464ac3d7eb43da559b9ea23aadbe0fde5948e8dc | [] | no_license | tomdev2008/dsj_house | 5d8187b3fca63bd2fc83ea781ea9cda0a91943a2 | 988ab003b1fec4dfb12d3712adde58a4abef067c | refs/heads/master | 2020-03-29T05:17:18.866087 | 2017-12-01T11:53:58 | 2017-12-01T11:53:58 | 149,575,972 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,614 | java | package com.dsj.data.web.utils;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.imageio.ImageIO;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.EncodeHintType;
import com.google.zxing.MultiFormatWriter;
import com.google.zxing.WriterException;
import com.google.zxing.common.BitMatrix;
/**
* 二维码生成工具类
* @author Cloud
* @data 2016-12-15
* QRCode
*/
public class QRCodeUtil {
//二维码颜色
private static final int BLACK = 0xFF000000;
//二维码颜色
private static final int WHITE = 0xFFFFFFFF;
/**
* <span style="font-size:18px;font-weight:blod;">ZXing 方式生成二维码</span>
* @param text <a href="javascript:void();">二维码内容</a>
* @param width 二维码宽
* @param height 二维码高
* @param outPutPath 二维码生成保存路径
* @param imageType 二维码生成格式
*/
public static BufferedImage zxingCodeCreate(String text, int width, int height){
Map<EncodeHintType, String> his = new HashMap<EncodeHintType, String>();
//设置编码字符集
his.put(EncodeHintType.CHARACTER_SET, "utf-8");
try {
//1、生成二维码
BitMatrix encode = new MultiFormatWriter().encode(text, BarcodeFormat.QR_CODE, width, height, his);
//2、获取二维码宽高
int codeWidth = encode.getWidth();
int codeHeight = encode.getHeight();
//3、将二维码放入缓冲流
BufferedImage image = new BufferedImage(codeWidth, codeHeight, BufferedImage.TYPE_INT_RGB);
for (int i = 0; i < codeWidth; i++) {
for (int j = 0; j < codeHeight; j++) {
//4、循环将二维码内容定入图片
image.setRGB(i, j, encode.get(i, j) ? BLACK : WHITE);
}
}
return image;
// File outPutImage = new File(outPutPath);
// //如果图片不存在创建图片
// if(!outPutImage.exists())
// outPutImage.createNewFile();
// //5、将二维码写入图片
// ImageIO.write(image, imageType, outPutImage);
} catch (WriterException e) {
e.printStackTrace();
System.out.println("二维码生成失败");
return null;
}
}
} | [
"940678055@qq.com"
] | 940678055@qq.com |
183d28fa561d703eba0d38d57b8e0350bc2c2bd2 | 7fb7e45083e9f78010a0112da80889202195fa51 | /sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/fluent/DeletedWebAppsClient.java | 0f95e6bc977364f13dc77c39aaca30bc4d6412a5 | [
"LicenseRef-scancode-generic-cla",
"MIT",
"BSD-3-Clause",
"LicenseRef-scancode-warranty-disclaimer",
"LGPL-2.1-or-later",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | abouquet/azure-sdk-for-java | 1f79d75636ef5c354d1229531583f67d97b104cd | 05bcf7062f5bc1bca09eeec36b2ca8fa2c4e3655 | refs/heads/master | 2023-01-06T04:17:28.305062 | 2020-09-24T18:47:53 | 2020-09-24T18:47:53 | 298,386,196 | 0 | 0 | MIT | 2020-09-24T20:19:37 | 2020-09-24T20:19:36 | null | UTF-8 | Java | false | false | 31,568 | java | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.appservice.fluent;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
import com.azure.core.annotation.Headers;
import com.azure.core.annotation.Host;
import com.azure.core.annotation.HostParam;
import com.azure.core.annotation.PathParam;
import com.azure.core.annotation.QueryParam;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceInterface;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.annotation.UnexpectedResponseExceptionType;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.PagedResponse;
import com.azure.core.http.rest.PagedResponseBase;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
import com.azure.core.util.logging.ClientLogger;
import com.azure.resourcemanager.appservice.fluent.inner.DeletedSiteInner;
import com.azure.resourcemanager.appservice.models.DefaultErrorResponseErrorException;
import com.azure.resourcemanager.appservice.models.DeletedWebAppCollection;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in DeletedWebApps. */
public final class DeletedWebAppsClient {
private final ClientLogger logger = new ClientLogger(DeletedWebAppsClient.class);
/** The proxy service used to perform REST calls. */
private final DeletedWebAppsService service;
/** The service client containing this operation class. */
private final WebSiteManagementClient client;
/**
* Initializes an instance of DeletedWebAppsClient.
*
* @param client the instance of the service client containing this operation class.
*/
DeletedWebAppsClient(WebSiteManagementClient client) {
this.service =
RestProxy.create(DeletedWebAppsService.class, client.getHttpPipeline(), client.getSerializerAdapter());
this.client = client;
}
/**
* The interface defining all the services for WebSiteManagementClientDeletedWebApps to be used by the proxy service
* to perform REST calls.
*/
@Host("{$host}")
@ServiceInterface(name = "WebSiteManagementCli")
private interface DeletedWebAppsService {
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Web/deletedSites")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DefaultErrorResponseErrorException.class)
Mono<Response<DeletedWebAppCollection>> list(
@HostParam("$host") String endpoint,
@PathParam("subscriptionId") String subscriptionId,
@QueryParam("api-version") String apiVersion,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DefaultErrorResponseErrorException.class)
Mono<Response<DeletedWebAppCollection>> listByLocation(
@HostParam("$host") String endpoint,
@PathParam("location") String location,
@PathParam("subscriptionId") String subscriptionId,
@QueryParam("api-version") String apiVersion,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get(
"/subscriptions/{subscriptionId}/providers/Microsoft.Web/locations/{location}/deletedSites/{deletedSiteId}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DefaultErrorResponseErrorException.class)
Mono<Response<DeletedSiteInner>> getDeletedWebAppByLocation(
@HostParam("$host") String endpoint,
@PathParam("location") String location,
@PathParam("deletedSiteId") String deletedSiteId,
@PathParam("subscriptionId") String subscriptionId,
@QueryParam("api-version") String apiVersion,
Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DefaultErrorResponseErrorException.class)
Mono<Response<DeletedWebAppCollection>> listNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
@Headers({"Accept: application/json", "Content-Type: application/json"})
@Get("{nextLink}")
@ExpectedResponses({200})
@UnexpectedResponseExceptionType(DefaultErrorResponseErrorException.class)
Mono<Response<DeletedWebAppCollection>> listByLocationNext(
@PathParam(value = "nextLink", encoded = true) String nextLink, Context context);
}
/**
* Description for Get all deleted apps for a subscription.
*
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listSinglePageAsync() {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.list(
this.client.getEndpoint(),
this.client.getSubscriptionId(),
this.client.getApiVersion(),
context))
.<PagedResponse<DeletedSiteInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Description for Get all deleted apps for a subscription.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listSinglePageAsync(Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.list(this.client.getEndpoint(), this.client.getSubscriptionId(), this.client.getApiVersion(), context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* Description for Get all deleted apps for a subscription.
*
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DeletedSiteInner> listAsync() {
return new PagedFlux<>(() -> listSinglePageAsync(), nextLink -> listNextSinglePageAsync(nextLink));
}
/**
* Description for Get all deleted apps for a subscription.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DeletedSiteInner> listAsync(Context context) {
return new PagedFlux<>(
() -> listSinglePageAsync(context), nextLink -> listNextSinglePageAsync(nextLink, context));
}
/**
* Description for Get all deleted apps for a subscription.
*
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DeletedSiteInner> list() {
return new PagedIterable<>(listAsync());
}
/**
* Description for Get all deleted apps for a subscription.
*
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DeletedSiteInner> list(Context context) {
return new PagedIterable<>(listAsync(context));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listByLocationSinglePageAsync(String location) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.listByLocation(
this.client.getEndpoint(),
location,
this.client.getSubscriptionId(),
this.client.getApiVersion(),
context))
.<PagedResponse<DeletedSiteInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listByLocationSinglePageAsync(String location, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listByLocation(
this.client.getEndpoint(),
location,
this.client.getSubscriptionId(),
this.client.getApiVersion(),
context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DeletedSiteInner> listByLocationAsync(String location) {
return new PagedFlux<>(
() -> listByLocationSinglePageAsync(location), nextLink -> listByLocationNextSinglePageAsync(nextLink));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedFlux<DeletedSiteInner> listByLocationAsync(String location, Context context) {
return new PagedFlux<>(
() -> listByLocationSinglePageAsync(location, context),
nextLink -> listByLocationNextSinglePageAsync(nextLink, context));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DeletedSiteInner> listByLocation(String location) {
return new PagedIterable<>(listByLocationAsync(location));
}
/**
* Description for Get all deleted apps for a subscription at location.
*
* @param location The location parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable<DeletedSiteInner> listByLocation(String location, Context context) {
return new PagedIterable<>(listByLocationAsync(location, context));
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<DeletedSiteInner>> getDeletedWebAppByLocationWithResponseAsync(
String location, String deletedSiteId) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (deletedSiteId == null) {
return Mono.error(new IllegalArgumentException("Parameter deletedSiteId is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
return FluxUtil
.withContext(
context ->
service
.getDeletedWebAppByLocation(
this.client.getEndpoint(),
location,
deletedSiteId,
this.client.getSubscriptionId(),
this.client.getApiVersion(),
context))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<DeletedSiteInner>> getDeletedWebAppByLocationWithResponseAsync(
String location, String deletedSiteId, Context context) {
if (this.client.getEndpoint() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getEndpoint() is required and cannot be null."));
}
if (location == null) {
return Mono.error(new IllegalArgumentException("Parameter location is required and cannot be null."));
}
if (deletedSiteId == null) {
return Mono.error(new IllegalArgumentException("Parameter deletedSiteId is required and cannot be null."));
}
if (this.client.getSubscriptionId() == null) {
return Mono
.error(
new IllegalArgumentException(
"Parameter this.client.getSubscriptionId() is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.getDeletedWebAppByLocation(
this.client.getEndpoint(),
location,
deletedSiteId,
this.client.getSubscriptionId(),
this.client.getApiVersion(),
context);
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DeletedSiteInner> getDeletedWebAppByLocationAsync(String location, String deletedSiteId) {
return getDeletedWebAppByLocationWithResponseAsync(location, deletedSiteId)
.flatMap(
(Response<DeletedSiteInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<DeletedSiteInner> getDeletedWebAppByLocationAsync(
String location, String deletedSiteId, Context context) {
return getDeletedWebAppByLocationWithResponseAsync(location, deletedSiteId, context)
.flatMap(
(Response<DeletedSiteInner> res) -> {
if (res.getValue() != null) {
return Mono.just(res.getValue());
} else {
return Mono.empty();
}
});
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public DeletedSiteInner getDeletedWebAppByLocation(String location, String deletedSiteId) {
return getDeletedWebAppByLocationAsync(location, deletedSiteId).block();
}
/**
* Description for Get deleted app for a subscription at location.
*
* @param location The location parameter.
* @param deletedSiteId The numeric ID of the deleted app, e.g. 12345.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return a deleted app.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public DeletedSiteInner getDeletedWebAppByLocation(String location, String deletedSiteId, Context context) {
return getDeletedWebAppByLocationAsync(location, deletedSiteId, context).block();
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listNext(nextLink, context))
.<PagedResponse<DeletedSiteInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listNextSinglePageAsync(String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listNext(nextLink, context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listByLocationNextSinglePageAsync(String nextLink) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
return FluxUtil
.withContext(context -> service.listByLocationNext(nextLink, context))
.<PagedResponse<DeletedSiteInner>>map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null))
.subscriberContext(context -> context.putAll(FluxUtil.toReactorContext(this.client.getContext())));
}
/**
* Get the next page of items.
*
* @param nextLink The nextLink parameter.
* @param context The context to associate with this operation.
* @throws IllegalArgumentException thrown if parameters fail the validation.
* @throws DefaultErrorResponseErrorException thrown if the request is rejected by server.
* @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent.
* @return collection of deleted apps.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<PagedResponse<DeletedSiteInner>> listByLocationNextSinglePageAsync(String nextLink, Context context) {
if (nextLink == null) {
return Mono.error(new IllegalArgumentException("Parameter nextLink is required and cannot be null."));
}
context = this.client.mergeContext(context);
return service
.listByLocationNext(nextLink, context)
.map(
res ->
new PagedResponseBase<>(
res.getRequest(),
res.getStatusCode(),
res.getHeaders(),
res.getValue().value(),
res.getValue().nextLink(),
null));
}
}
| [
"noreply@github.com"
] | abouquet.noreply@github.com |
b6282536a1b53373ff0f43396fb435d3f7d72fde | 9401bc376bc258bd5500476bc4736e69d22f57d1 | /src/TicTacToe.java | 54a38764cfe49a902ac47d24c398f4e16c9f918e | [] | no_license | pchoubey00/tictactoe | 3d3389db1af7dbfb6adb8e5914577f88aa8b8606 | 0f15ad5d51b40ea9504e0ade230483ad3aed6e68 | refs/heads/main | 2023-02-05T20:43:44.299219 | 2020-12-23T22:56:58 | 2020-12-23T22:56:58 | 324,016,968 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,629 | java | import java.util.Random;
import java.util.Scanner;
public class TicTacToe {
public static final Random RANDOM = new Random();
public static void main(String[] args) {
Board board = new Board();
Scanner scanner = new Scanner(System.in);
int exitchoice = 1;
board.displayBoard();
System.out.println("Select Turn: \n 1. Computer is X \n 2. User is O");
int choice = scanner.nextInt();
if (choice == board.Computer) {
Point p = new Point(RANDOM.nextInt(3), RANDOM.nextInt(3));
board.play(p, board.Computer);
board.displayBoard();
}
while (!board.GameOver()) {
boolean validMove = true;
do {
if (!validMove) {
System.out.println("Not a valid move!");
}
System.out.println("Please enter next move: ");
Point userMove = new Point(scanner.nextInt(), scanner.nextInt());
validMove = board.play(userMove, board.human );
}while(!validMove);
board.displayBoard();
if (board.GameOver()) {
break;
}
board.minimax(0, board.Computer);
System.out.println("Computer chose position: "+board.computermove);
board.play(board.computermove, board.Computer);
board.displayBoard();
System.out.println("Do you want to continue: \n 1. Yes \n 2. no");
exitchoice = scanner.nextInt();
if (exitchoice == 2 ) {
break;
} else {
continue;
}
}
if (board.hasPlayerWon(board.Computer)){
System.out.println("Computer has won the game");
} else if (board.hasPlayerWon(board.human)) {
System.out.println("You have won the game!! ");
} else if (exitchoice == 2) {
System.out.println("Good day!");
}else {
System.out.println("There is a draw");
}
}
}
| [
"pchoubey@u.rochester.edu"
] | pchoubey@u.rochester.edu |
2e07d59f888897768fe0b8440ab9b48f6080c736 | 2344955423e1333ef7c808c7a9e3297835b1903f | /src/main/java/com/venusz/admin/service/SysDeptService.java | 0e73c22ac843e3b242296bb3dc1f2552131d2e6d | [] | no_license | venusj/admin | 139afef7c8dfeeed8803886f8422fbf6e5f7724c | 20fb17cb5c0a7d4384b1e4425db9353c69d63b56 | refs/heads/master | 2020-04-02T10:48:52.684087 | 2018-10-29T15:50:18 | 2018-10-29T15:50:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,206 | java | package com.venusz.admin.service;
import com.alibaba.druid.filter.AutoLoad;
import com.google.common.base.Preconditions;
import com.venusz.admin.dao.SysDeptMapper;
import com.venusz.admin.exception.ParamException;
import com.venusz.admin.model.SysDept;
import com.venusz.admin.param.DeptParam;
import com.venusz.admin.util.BeanValidator;
import com.venusz.admin.util.LevelUtil;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@Service
public class SysDeptService {
@Autowired
private SysDeptMapper sysDeptMapper;
public void save(DeptParam deptParam){
BeanValidator.check(deptParam);
if(checkIsExists(deptParam.getParentId(),deptParam.getName(),deptParam.getId())){
throw new ParamException("同一层级下存在相同名称的部门");
}
SysDept sysDept = SysDept.builder().name(deptParam.getName()).parentId(deptParam.getParentId())
.remark(deptParam.getRemark()).seq(deptParam.getSeq()).build();
sysDept.setLevel(LevelUtil.calculateLevel(getLevel(deptParam.getParentId()),deptParam.getParentId()));
sysDept.setOperator("system");
sysDept.setOperateIp("127.0.0.1");
sysDept.setOperateTime(new Date());
sysDeptMapper.insertSelective(sysDept);
}
/**
* 校验当前层级是否存在相同的部门
* @param parentId 父节点ID
* @param deptName 部门名称
* @param deptID 当前部门ID
* @return
*/
private boolean checkIsExists(Integer parentId,String deptName,Integer deptID){
return sysDeptMapper.countByNameAndParentId(parentId,deptName,deptID)>0;
}
/**
* 获取当前部门的ID,没有则返回父级ID
* @param deptId
* @return
*/
private String getLevel(Integer deptId){
SysDept dept = sysDeptMapper.selectByPrimaryKey(deptId);
if(dept == null){
return null;
}
return dept.getLevel();
}
public void update(DeptParam deptParam) {
if(checkIsExists(deptParam.getParentId(),deptParam.getName(),deptParam.getId())){
throw new ParamException("同一层级下存在相同名称的部门");
}
SysDept before = sysDeptMapper.selectByPrimaryKey(deptParam.getId());
Preconditions.checkNotNull(before,"待更新的部门不存在");
if(checkIsExists(deptParam.getParentId(),deptParam.getName(),deptParam.getId())){
throw new ParamException("同一层级下存在相同名称的部门");
}
SysDept after = SysDept.builder().id(deptParam.getId()).name(deptParam.getName()).parentId(deptParam.getParentId())
.remark(deptParam.getRemark()).seq(deptParam.getSeq()).build();
after.setLevel(LevelUtil.calculateLevel(getLevel(deptParam.getParentId()),deptParam.getParentId()));
after.setOperator("system");
after.setOperateIp("127.0.0.1");
after.setOperateTime(new Date());
//是否更新当前信息以及子节点的信息
updateWithChild(before,after);
}
@Transactional
void updateWithChild(SysDept before, SysDept after) {
String newLevelPrefix = after.getLevel();
String oldLevelPrefix = before.getLevel();
if(!after.getLevel().equals(before.getLevel())){
List<SysDept> childDeptListBylevel = sysDeptMapper.getChildDeptListBylevel(before.getLevel());
if(CollectionUtils.isEmpty(childDeptListBylevel)){
for (SysDept sysDept : childDeptListBylevel){
String level = sysDept.getLevel();
if(level.indexOf(oldLevelPrefix) == 0){
level = newLevelPrefix + level.substring(oldLevelPrefix.length());
sysDept.setLevel(level);
}
}
sysDeptMapper.batchUpdateLevel(childDeptListBylevel);
}
}
sysDeptMapper.updateByPrimaryKey(after);
}
}
| [
"1329705209@qq.com"
] | 1329705209@qq.com |
a794a0a94a917a883c778c9c17cb0b5a78afdfe0 | 2a80c8f3004960d07f3461ab7f32072095fd3a67 | /src/main/java/com/tencentcloudapi/cdb/v20170320/models/ModifyDBInstanceProjectResponse.java | 435108f9fd2acd30d6d735ba7a7c1f641287d1e7 | [
"Apache-2.0"
] | permissive | kennyshittu/tencentcloud-sdk-java-intl-en | 495a6e9cf3936406a0d95974aee666ded6632118 | 2ed6e287c3f451e3709791a3c7ac4b5316205670 | refs/heads/master | 2022-04-15T06:59:48.967043 | 2020-04-02T14:13:10 | 2020-04-02T14:13:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,059 | java | /*
* Copyright (c) 2017-2018 THL A29 Limited, a Tencent company. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.tencentcloudapi.cdb.v20170320.models;
import com.tencentcloudapi.common.AbstractModel;
import com.google.gson.annotations.SerializedName;
import com.google.gson.annotations.Expose;
import java.util.HashMap;
public class ModifyDBInstanceProjectResponse extends AbstractModel{
/**
* The unique request ID, which is returned for each request. RequestId is required for locating a problem.
*/
@SerializedName("RequestId")
@Expose
private String RequestId;
/**
* Get The unique request ID, which is returned for each request. RequestId is required for locating a problem.
* @return RequestId The unique request ID, which is returned for each request. RequestId is required for locating a problem.
*/
public String getRequestId() {
return this.RequestId;
}
/**
* Set The unique request ID, which is returned for each request. RequestId is required for locating a problem.
* @param RequestId The unique request ID, which is returned for each request. RequestId is required for locating a problem.
*/
public void setRequestId(String RequestId) {
this.RequestId = RequestId;
}
/**
* Internal implementation, normal users should not use it.
*/
public void toMap(HashMap<String, String> map, String prefix) {
this.setParamSimple(map, prefix + "RequestId", this.RequestId);
}
}
| [
"hapsyou@foxmail.com"
] | hapsyou@foxmail.com |
464592e02e24e2776c3d669b1afd7426425b3b89 | 40091169612c88c9d8aca424e90f94f9c3af9a4f | /MarchBreakHomework/DiscountPrices.java | ff50fcf1d90447032e6d3c09f2bc747448f0d766 | [] | no_license | 1AhmadElmasri/High-School-Java | 55ed5f255c2a07ccd8ea6dce01d2074228c1f0e2 | 706d5eb5be131499bd7411ac2baf4764b214a840 | refs/heads/master | 2020-04-19T08:44:33.118135 | 2019-01-29T04:22:07 | 2019-01-29T04:22:07 | 168,087,386 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,412 | 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 MarchBreakHomework;
import java.text.NumberFormat;
import java.util.Scanner;
/**
*
* @author ahmad
*/
public class DiscountPrices {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
//Scanner and Variables
Scanner input = new Scanner(System.in);
int cost = 0;
double totalCost;
final double DISCOUNT = 0.10;
boolean checker = false;
String holder;
NumberFormat money = NumberFormat.getCurrencyInstance();
//Intros
System.out.println("Hi! What is the cost of the thing you're buying?");
//checker for incorrect input
while (!checker) {
try {
holder = input.nextLine();
cost = Integer.parseInt(holder);
checker = true;
} catch (Exception e) {
System.out.println("Incorrect input. Put in one number");
checker = false;
}
}
totalCost = cost - (cost * DISCOUNT);
System.out.println(money.format(totalCost));
}
}
| [
"noreply@github.com"
] | 1AhmadElmasri.noreply@github.com |
e43097f99123a1ffc3d9be67dc3e9427c9dc9120 | b84813fe658f5c3ae0cb795274f3d64e49a91cd6 | /H3Common/src/main/java/com/czx/h3common/coder/FastDecoder.java | d5ef3d041b48019de2d476a76bad338eacf43991 | [] | no_license | ZhiYu2018/HS3 | ec81f66eb5b3198bdd62ff3d3df71712ffa25ae4 | 3e2ac24a228eaa5ac9dfa78f0c87ec448a998b34 | refs/heads/master | 2023-08-25T13:32:39.534124 | 2021-10-30T04:50:53 | 2021-10-30T04:50:53 | 413,252,902 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,092 | java | package com.czx.h3common.coder;
import com.alibaba.fastjson.JSON;
import feign.FeignException;
import feign.Response;
import feign.codec.DecodeException;
import feign.codec.Decoder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.input.ReaderInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.lang.reflect.Type;
import static feign.Util.UTF_8;
import static feign.Util.ensureClosed;
@Slf4j
public class FastDecoder implements Decoder {
@Override
public Object decode(Response response, Type type) throws IOException, FeignException {
if (response.body() == null) {
log.info("body is null");
return null;
}
Reader reader = response.body().asReader(UTF_8);
try{
InputStream ins = new ReaderInputStream(reader);
return JSON.parseObject(ins,UTF_8, type);
}catch (Throwable t){
log.info("Get exceptions:{}", t.getMessage());
throw t;
}finally {
ensureClosed(reader);
}
}
}
| [
"forbelief@126.com"
] | forbelief@126.com |
8bb97c7e2e5afd71cea93f3af0bccfb2f39a5de7 | 3105ec0caaaf4c7ef161faa30dd27fcd205b0dc4 | /src/main/java/com/github/zxl0714/leveldb/TableFormat.java | 17e10e5e9130ff7f7c746a43769702772204d76e | [
"MIT"
] | permissive | zxl0714/leveldb-sstable | 1f6bc7bcdf9fb5364eea11e06440dbf3c2a6954a | 4cc9f2a545b8f4fc05619d23dcb00a38125c5350 | refs/heads/master | 2021-01-10T01:49:35.909391 | 2016-03-09T02:29:12 | 2016-03-09T02:29:12 | 53,111,960 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,807 | java | package com.github.zxl0714.leveldb;
import java.io.DataOutput;
import java.io.IOException;
/**
* Created by xiaolu on 4/30/15.
*/
public class TableFormat {
public static final long TABLE_MAGIC_NUMBER = 0xdb4775248b80fb57L;
public static final int BLOCK_TRAILER_SIZE = 5;
public static class BlockHandle {
public static final long MAX_ENCODED_LENGTH = 10 + 10;
private long offset;
private long size;
public BlockHandle() { }
public void setOffset(long offset) {
this.offset = offset;
}
public void setSize(long size) {
this.size = size;
}
public int encodeTo(DataOutput out) throws IOException {
int len = 0;
len += Coding.putVarint64(out, offset);
len += Coding.putVarint64(out, size);
return len;
}
}
public static class Footer {
public static final long ENCODED_LENGTH = 2 * BlockHandle.MAX_ENCODED_LENGTH + 8;
private BlockHandle metaindexHandle;
private BlockHandle indexHandle;
public Footer() { }
public void setMetaindexHandle(BlockHandle h) {
metaindexHandle = h;
}
public void setIndexHandle(BlockHandle h) {
indexHandle = h;
}
public void encodeTo(DataOutput out) throws IOException {
int len = 0;
len += metaindexHandle.encodeTo(out);
len += indexHandle.encodeTo(out);
for (int i = len; i < BlockHandle.MAX_ENCODED_LENGTH * 2; i++) {
out.writeByte(0);
}
Coding.putFixed32(out, (int) (TableFormat.TABLE_MAGIC_NUMBER));
Coding.putFixed32(out, (int) (TableFormat.TABLE_MAGIC_NUMBER >>> 32));
}
}
}
| [
"xiaolu3@staff.weibo.com"
] | xiaolu3@staff.weibo.com |
9859323a25bf732fadb82c133e457776c66ff587 | ae84044d4cbf25eb35d1f2189e588ed205896a84 | /src/test/java/org/example/Auto9.java | 42d38225e94261360db507c44179c788465dd1bc | [] | no_license | vthakkar27/Automation9 | 8c95cd3aabee7cebcf9fe4f44323a2de8e3c22f4 | e82a794b2daacad7333c3a0ea2a970cbc06d75d3 | refs/heads/master | 2023-05-11T00:39:12.179067 | 2020-07-08T21:38:01 | 2020-07-08T21:38:01 | 276,993,812 | 0 | 0 | null | 2023-05-09T18:52:06 | 2020-07-03T21:58:06 | Java | UTF-8 | Java | false | false | 7,289 | java | package org.example;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.Select;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.concurrent.TimeUnit;
public class Auto9 {
static WebDriver driver;
//reusable method to wait until element is clickable
public static void waitUntilElementIsClickable(By by, int time) {
WebDriverWait wait = new WebDriverWait(driver, time);
wait.until(ExpectedConditions.elementToBeClickable(by));
}
public static void clickOnElement(By by,int time) {
driver.findElement(by).click();
}
public static void typeText(By by, String text) {
driver.findElement(by).sendKeys(text);
}
public static long timestamp() {
return (System.currentTimeMillis());
}
public static String getTextFromElement(By by)
{
return driver.findElement(by).getText();
}
public static void selectFromDropDownByVisibleText(By by,String text){
Select select = new Select(driver.findElement(by));
select.selectByVisibleText(text);
}
public static void selectFromDropDownByVisibleIndex(By by,int n){
Select select = new Select(driver.findElement(by));
select.selectByIndex(n);
}
public static void selectFromDropDownByValue(By by,String Value){
Select select = new Select(driver.findElement(by));
select.selectByValue(Value);
}
//creating Clickable method for driver to click on element
public static void waitUntilElementToClickble(By by) {
WebDriverWait wait = new WebDriverWait(driver,30);
WebElement element = wait.until(
ExpectedConditions.elementToBeClickable(by));
}
@BeforeMethod
public static void initialiseMethod () {
//setting up chrom driver path
System.setProperty("webdriver.chrome.driver", "C:\\Soft\\chromedriver\\chromedriver.exe");
//creating object to open chrome driver
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
driver = new ChromeDriver(options);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://demo.nopcommerce.com/");
// WebDriver driver = new ChromeDriver(options);
}
@AfterMethod
public static void closingMethod(){
driver.close();}
@Test
public static void registration ()
{
//driver.findElement(By.xpath("//a[@class=\"ico-register\"]")).click();
//driver.findElement(By.xpath("//*[@id=\"FirstName\"]")).sendKeys("vaishali");
// driver.findElement(By.cssSelector("input#LastName")).sendKeys("Thakkar");
// String actualText= driver.findElement("By.xpath("//div/strong")").getText();
// String expectedRegisterPageText = "Your Personal Detail";
// String actualOnRegisterPageText= getTextFromElement(By.xpath("By.xpath(\"//div/strong\")"));
// Assert.assertEquals(actualOnRegisterPageText,expectedRegisterPageText,"Registe page is not Opened");
// driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
clickOnElement(By.linkText("Register"),30); // Starting registration process
clickOnElement(By.xpath("//input[@id=\"gender-female\"]"),40);
typeText(By.id("FirstName"),"Vaishali");
typeText(By.cssSelector("input#LastName"),"Thakkar");
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
selectFromDropDownByVisibleIndex(By.xpath("//select[@name='DateOfBirthDay']"),8);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
selectFromDropDownByVisibleText(By.xpath("//select[@name='DateOfBirthMonth']"),"October");
selectFromDropDownByValue(By.xpath("//select[@name='DateOfBirthYear']"),"1980");
//using Timestamp method to use same email address
typeText(By.name("Email"),"dasvthakkar27+"+timestamp()+"@gmail.com");
typeText(By.id("Company"),"Devam10");
typeText(By.id("Password"),"123das");
typeText(By.id("ConfirmPassword"),"123das");
clickOnElement(By.id("register-button"),20);
String expectedText = "Your registration completed";//user should be able to register on nopcommerce.com
String actualText = getTextFromElement(By.xpath("//div[@class=\"result\"]"));
Assert.assertEquals(actualText,expectedText);
}
@Test
public static void Computer(){
registration(); //calling Registration method to send email to friend
clickOnElement(By.linkText("Computers"),20);
clickOnElement(By.linkText("Desktops"),20);
clickOnElement(By.linkText("Digital Storm VANQUISH 3 Custom Performance PC"),20); //selecting item to email friend
clickOnElement(By.xpath("//input[@value=\"Email a friend\"]"),20);
typeText(By.xpath("//input[@id=\"FriendEmail\"]"),"jaiswaminarayan2020@yahoo.com"); //Friend email address
typeText(By.xpath("//input[@id=\"YourEmailAddress\"]"),"dasvthakkar27@gmail.com"); //user email address
typeText(By.xpath("//textarea[@id=\"PersonalMessage\"]"),"Happy Rakshabandhan"); //Sending email with personal message
clickOnElement(By.xpath("//input[@name=\"send-email\"]"),20);
String expectedText = "Digital Storm VANQUISH 3 Custom Performance PC";
String actualText = getTextFromElement(By.linkText("Digital Storm VANQUISH 3 Custom Performance PC"));
Assert.assertEquals(actualText,expectedText);
}
@Test
//Method for adding books to cart
public static void Books(){
// waitUntilElementToClickble(By.linkText("Books"));
clickOnElement(By.linkText("Books"),30);//
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
clickOnElement(By.xpath("//div[@class=\"item-grid\"]/div[2]/div/div[2]/div[3]/div[2]/input[1]"),30);//adding "First prize book in cart
clickOnElement(By.linkText("Fahrenheit 451 by Ray Bradbury"),40);//clicking on Bradbury book
clickOnElement(By.xpath("//input[@id=\"add-to-cart-button-37\"]"),30);//adding Bradbury book in cart
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
clickOnElement(By.linkText("Shopping cart"),30);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
String expectedText = ("Fahrenheit 451 by Ray Bradbury");
String actualText = getTextFromElement(By.linkText("Fahrenheit 451 by Ray Bradbury"));
Assert.assertEquals(actualText,expectedText);
String expectedText1 = ("First Prize Pies"); //
String actualText1 = getTextFromElement(By.linkText("First Prize Pies"));
Assert.assertEquals(actualText1,expectedText1);
}
}
| [
"dasvthakkar27@gmail.com"
] | dasvthakkar27@gmail.com |
637786ae69436499dad03959f45a6a13ec96fb3a | 54476289c13cc53bbb78a8edbd57cdaa381c7461 | /src/main/java/tools/xor/MutableJsonType.java | dc0c10ccbc414715c07f98a69d1feadcd18a1af5 | [
"Apache-2.0"
] | permissive | ddalton/xor | bd8a04e8c5946581543b4c00e77a18b28a4959d1 | a1fa648ccce7344573840de62d8751b09f3c18a3 | refs/heads/master | 2022-03-13T05:40:25.180438 | 2022-03-05T23:10:26 | 2022-03-05T23:10:26 | 56,424,620 | 0 | 0 | Apache-2.0 | 2022-03-05T22:49:14 | 2016-04-17T07:34:37 | Java | UTF-8 | Java | false | false | 13,820 | java | /**
* XOR, empowering Model Driven Architecture in J2EE applications
*
* Copyright (c) 2012, Dilip Dalton
*
* 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 tools.xor;
import java.lang.reflect.Method;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.json.JSONArray;
import org.json.JSONObject;
import tools.xor.service.Shape;
import tools.xor.util.ClassUtil;
/**
* SimpleType have no properties
*
* @author Dilip Dalton
*
*/
public class MutableJsonType extends ExternalType {
private static final Logger logger = LogManager.getLogger(new Exception().getStackTrace()[0].getClassName());
public static final String SCHEMA_ALLOF = "allOf";
public static final String SCHEMA_TYPE = "type";
public static final String SCHEMA_FORMAT = "format";
public static final String SCHEMA_ITEMS = "items";
public static final String SCHEMA_PROPERTIES = "properties";
public static final String SCHEMA_REQUIRED = "required";
public static final String SCHEMA_REF = "$ref";
public static final String SCHEMA_REF_SEPARATOR = "/";
public static final String SCHEMA_ID_PROPERTY = "surrogateKey";
public static final String JSONSCHEMA_STRING_TYPE = "string";
public static final String JSONSCHEMA_NUMBER_TYPE = "number";
public static final String JSONSCHEMA_INTEGER_TYPE = "integer";
public static final String JSONSCHEMA_BOOLEAN_TYPE = "boolean";
public static final String JSONSCHEMA_ARRAY_TYPE = "array";
public static final String JSONSCHEMA_OBJECT_TYPE = "object";
private static final Map<String, Class<?>> JSONSCHEMA_TYPES = new HashMap<>();
public static final String JSONSCHEMA_FORMAT_DATE_TIME = "date-time";
public static final String JSONSCHEMA_FORMAT_BIGINTEGER = "biginteger";
public static final String JSONSCHEMA_FORMAT_BIGDECIMAL = "bigdecimal";
static {
JSONSCHEMA_TYPES.put(JSONSCHEMA_STRING_TYPE, String.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_NUMBER_TYPE, BigDecimal.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_INTEGER_TYPE, Integer.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_BOOLEAN_TYPE, boolean.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_ARRAY_TYPE, List.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_OBJECT_TYPE, Object.class);
// some types are decided by the format specifier
JSONSCHEMA_TYPES.put(JSONSCHEMA_FORMAT_DATE_TIME, Date.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_FORMAT_BIGINTEGER, BigInteger.class);
JSONSCHEMA_TYPES.put(JSONSCHEMA_FORMAT_BIGDECIMAL, BigDecimal.class);
}
private List<String> parentTypeNames;
private JSONObject jsonSchema;
public MutableJsonType(EntityType domainType, Class<?> javaClass) {
super(domainType, javaClass);
}
/**
* Used to support swagger schema
* @param entityName for the type
* @param json schema for the type
* @param idPropertyName identifier property name
*/
public MutableJsonType(String entityName, JSONObject json, String idPropertyName) {
super(entityName, JSONObject.class);
this.jsonSchema = json;
this.isDataType = true;
this.idPropertyName = idPropertyName;
this.versionPropertyName = null; // currently not supported as this schema is not used for updates
this.isEmbedded = idPropertyName == null;
this.isEntity = true;
this.parentTypeNames = new ArrayList<>();
// extract parentTypes
if(json.has(SCHEMA_ALLOF)) {
JSONArray array = json.getJSONArray(SCHEMA_ALLOF);
// Process each element in the array
for(int i = 0 ; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
if(obj.has(SCHEMA_REF)) {
// get the parent entity name from the ref path
this.parentTypeNames.add(getEntityNameFromRef(obj));
}
}
}
}
public void setIdPropertyName(String name) {
this.idPropertyName = name;
this.isEmbedded = false;
}
private String getEntityNameFromRef(JSONObject obj) {
String refPath = obj.getString(SCHEMA_REF);
// get the last component in the parent path
String refEntityName = refPath.substring(refPath.lastIndexOf(SCHEMA_REF_SEPARATOR) + SCHEMA_REF_SEPARATOR.length());
return refEntityName;
}
@Override
public void initParentTypes(EntityType domainType, TypeMapper typeMapper) {
// Are we initializing for a Swagger schema
if(this.parentTypeNames != null) {
for (String parentEntityName : this.parentTypeNames) {
Type externalType = getShape().getType(parentEntityName);
this.parentTypes.add((ExternalType) externalType);
}
} else {
super.initParentTypes(domainType, typeMapper);
}
}
@Override
public Method getGetterMethod(String targetProperty){
// Dynamic type does not have getters
return null;
}
@Override
public String getName() {
return getEntityName();
}
@Override
public boolean isOpen() {
return true;
}
@Override
public Property defineProperty(Property domainProperty, Shape dynamicShape, TypeMapper typeMapper) {
Class<?> externalClass = typeMapper.toExternal(domainProperty.getType());
if(externalClass == null) {
throw new RuntimeException("The dynamic type is missing for the following domain class: " + domainProperty.getType().getInstanceClass().getName());
}
String typeName = domainProperty.getType().getName();
if(domainProperty.getType() instanceof EntityType) {
typeName = ((EntityType)domainProperty.getType()).getEntityName();
}
Type propertyType = dynamicShape.getType(typeName);
Type elementType = null;
if(((ExtendedProperty)domainProperty).getElementType() != null) {
String elementTypeName = ((ExtendedProperty)domainProperty).getElementType().getName();
if(((ExtendedProperty)domainProperty).getElementType() instanceof EntityType) {
elementTypeName = ((EntityType)((ExtendedProperty)domainProperty).getElementType()).getEntityName();
}
elementType = dynamicShape.getType(elementTypeName);
}
if(propertyType == null) {
Class<?> propertyClass = typeMapper.toExternal(domainProperty.getType());
logger.debug("Name: " + domainProperty.getName() + ", Domain class: " + domainProperty.getType().getInstanceClass().getName() + ", property class: " + propertyClass.getName());
propertyType = dynamicShape.getType(propertyClass);
}
MutableJsonProperty dynamicProperty = null;
if(domainProperty.isOpenContent()) {
dynamicProperty = new MutableJsonProperty(domainProperty.getName(), (ExtendedProperty) domainProperty, propertyType, this, elementType);
} else {
dynamicProperty = new MutableJsonProperty((ExtendedProperty) domainProperty, propertyType, this, elementType);
}
dynamicProperty.setDomainTypeName(domainProperty.getType().getInstanceClass().getName());
dynamicProperty.setConverter(((ExtendedProperty)domainProperty).getConverter());
return dynamicProperty;
}
@Override
public void setProperty (Shape domainShape, Shape dynamicShape, TypeMapper typeMapper)
{
// populate the properties for this type
EntityType domainType = (EntityType) domainShape.getType(getEntityName());
for (Property domainProperty : domainShape.getProperties(domainType).values()) {
MutableJsonProperty dynamicProperty = (MutableJsonProperty)defineProperty(
domainProperty,
dynamicShape,
typeMapper);
dynamicProperty.init((ExtendedProperty) domainProperty, dynamicShape);
logger.debug(
"[" + getName() + "] Domain property name: " + domainProperty.getName()
+ ", type name: " + dynamicProperty.getJavaType());
dynamicShape.addProperty(dynamicProperty);
}
}
public void defineRequired() {
JSONArray required = jsonSchema.has(SCHEMA_REQUIRED) ? jsonSchema.getJSONArray(SCHEMA_REQUIRED)
: null;
if (required == null && jsonSchema.has(SCHEMA_ALLOF)) {
JSONArray array = jsonSchema.getJSONArray(SCHEMA_ALLOF);
// Process each element in the array
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
if (obj.has(SCHEMA_REQUIRED)) {
required = obj.getJSONArray(SCHEMA_REQUIRED);
}
if(required != null) {
break;
}
}
}
if(required != null) {
for(int i = 0; i < required.length(); i++) {
String propertyName = required.getString(i);
MutableJsonProperty property = (MutableJsonProperty) ClassUtil.getDelegate(getProperty(propertyName));
property.setNullable(true);
}
}
}
/**
* Used to define the swagger type properties
* @param shape for swagger schema
*/
public void defineProperties(Shape shape) {
JSONObject properties = jsonSchema.has(SCHEMA_PROPERTIES) ? jsonSchema.getJSONObject(SCHEMA_PROPERTIES)
: null;
if (properties == null && jsonSchema.has(SCHEMA_ALLOF)) {
JSONArray array = jsonSchema.getJSONArray(SCHEMA_ALLOF);
// Process each element in the array
for (int i = 0; i < array.length(); i++) {
JSONObject obj = array.getJSONObject(i);
if (obj.has(SCHEMA_PROPERTIES)) {
properties = obj.getJSONObject(SCHEMA_PROPERTIES);
if(obj.has(SCHEMA_ID_PROPERTY)) {
this.idPropertyName = obj.getString(SCHEMA_ID_PROPERTY);
}
}
if(properties != null) {
break;
}
}
} else if(jsonSchema.has(SCHEMA_ID_PROPERTY)) {
this.idPropertyName = jsonSchema.getString(SCHEMA_ID_PROPERTY);
}
// process each property
if (this.parentTypeNames.size() == 0 && properties == null) {
throw new RuntimeException("Unable to find the properties object or the type has no properties");
} else {
// this is an entity type and mark it as such
this.isDataType = false;
}
if (properties != null) {
String[] propertyNames = JSONObject.getNames(properties);
for (int i = 0; i < propertyNames.length; i++) {
JSONObject obj = properties.getJSONObject(propertyNames[i]);
Type propertyType = null;
Type elementType = null;
// TO_ONE relationship
if (obj.has(SCHEMA_REF)) {
String toOneEntityName = getEntityNameFromRef(obj);
propertyType = getShape().getType(toOneEntityName);
} else if (obj.has(SCHEMA_TYPE)) {
propertyType = getType(obj);
if (JSONSCHEMA_ARRAY_TYPE.equals(obj.get(SCHEMA_TYPE))) {
// look for the items object
JSONObject items = obj.getJSONObject(SCHEMA_ITEMS);
// to many entity relationship
if (items.has(SCHEMA_REF)) {
elementType = getShape().getType(getEntityNameFromRef(items));
} else {
elementType = getType(items);
}
}
}
// The property might just be a placeholder, so we check for this scenario.
if(propertyType != null) {
shape.addProperty(new MutableJsonProperty(propertyNames[i], propertyType, this, elementType));
}
}
}
}
private Type getType(JSONObject obj) {
if (obj.has(SCHEMA_FORMAT)) {
return getShape().getType(JSONSCHEMA_TYPES.get(obj.get(SCHEMA_FORMAT)));
}
if (obj.has(SCHEMA_TYPE)) {
return getShape().getType(JSONSCHEMA_TYPES.get(obj.get(SCHEMA_TYPE)));
}
return null;
}
@Override
public void setOpenProperty(Object obj, String propertyName, Object value ) {
if(obj instanceof JSONObject) {
JSONObject json = (JSONObject) obj;
json.put(propertyName, value);
} else {
super.setOpenProperty(obj, propertyName, value);
}
}
protected MutableJsonType (String typeName,
Class<JSONObject> javaClass)
{
super(typeName, javaClass);
}
}
| [
"dilipdalton@hotmail.com"
] | dilipdalton@hotmail.com |
e6b8d5c379b5f2ab543295c28fbaca01642e2c65 | 7120ed04f7d305641529ea82c8642438acec920c | /codeforces/1466/A.java | 36a4ca6d3426694336718e7aaeefc7306e29a158 | [] | no_license | aditya-786/coding-submissions | d1a886f837d25f25bfbabd911b3bc47eb9d5edf8 | eb563f09ca79fdb6a8ffbb22038f5dc35d24b275 | refs/heads/master | 2023-06-27T13:07:39.322504 | 2021-07-24T18:46:57 | 2021-07-24T18:46:57 | 387,923,409 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,806 | java | import java.io.*;
import java.util.*;
import java.util.Arrays;
/*
author @ Aditya Aggarwal
LinkedIn : https://www.linkedin.com/in/aditya7861/
' The Dawn does not come twice to awaken the man '
Never Give Up ... Failure is the biggest success
*/
public class Main {
static void run(){
boolean tc = true;
//AdityaFastIO r = new AdityaFastIO();
FastReader r = new FastReader();
try (OutputStream out = new BufferedOutputStream(System.out)) {
int testcases = tc ? r.ni() : 1;
// Hold Here Sparky------------------->>>
// Solution Starts Here
while (testcases -- > 0){
int n = r.ni();
List<Integer> list = new ArrayList<>();
for (int i=0;i<n;i++) list.add(r.ni());
HashSet<Integer> hs = new HashSet<>();
for (int i=0;i<n;i++){
for (int j=i+1;j<n;j++){
hs.add(list.get(j)-list.get(i));
}
}
out.write((hs.size() + " ").getBytes());
out.write(("\n").getBytes());
}
// Solution Ends Here
} catch (IOException e) {
e.printStackTrace();
}
}
static int getBit(int ele){
long mask = ele&(ele-1);
return (int) (Math.log(ele^mask)/Math.log(2));
}
static class AdityaFastIO{
final private int BUFFER_SIZE = 1<<16;
private final DataInputStream din;
private final byte[] buffer;
private int bufferPointer, bytesRead;
public BufferedReader br;
public StringTokenizer st;
public AdityaFastIO() {
br = new BufferedReader(new InputStreamReader(System.in));
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public AdityaFastIO(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String word() {
while (st == null || !st.hasMoreElements()) {
try { st = new StringTokenizer(br.readLine()); }
catch (IOException e) { e.printStackTrace(); }
}
return st.nextToken();
}
public String line() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public String readLine() throws IOException {
byte[] buf = new byte[100000001]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int ni() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do { ret = ret * 10 + c - '0'; }
while ((c = read()) >= '0' && c <= '9');
if (neg) return -ret;
return ret;
}
public long nl() throws IOException {
long ret = 0;byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do { ret = ret * 10 + c - '0'; }
while ((c = read()) >= '0' && c <= '9');
if (neg) return -ret;return ret;
}
public double nd() throws IOException {
double ret = 0, div = 1;byte c = read();
while (c <= ' ') c = read();
boolean neg = (c == '-');
if (neg) c = read();
do { ret = ret * 10 + c - '0'; }
while ((c = read()) >= '0' && c <= '9');
if (c == '.') while ((c = read()) >= '0' && c <= '9') ret += (c - '0') / (div *= 10);
if (neg) return -ret;return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead) fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null) return;
din.close();
}
}
public static void main(String[] srgs) throws java.lang.Exception {run();}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); }
String word() {
while (st == null || !st.hasMoreElements()) {
try { st = new StringTokenizer(br.readLine()); }
catch (IOException e) { e.printStackTrace(); }
}
return st.nextToken();
}
String line() {
String str = "";
try { str = br.readLine(); }
catch (IOException e) { e.printStackTrace(); }
return str;
}
int ni() { return Integer.parseInt(word()); }
long nl() { return Long.parseLong(word()); }
double nd() { return Double.parseDouble(word()); }
}
interface Constants{
int mod = (int)(1e9+7);
}
static int MOD = (int) (1e9 + 7);
static long powerLL(long x, long n) {
long result = 1;
while (n > 0) {
if (n % 2 == 1) result = result * x % MOD;
n = n / 2;x = x * x % MOD;
}
return result;
}
static long powerStrings(int i1, int i2) {
String sa = String.valueOf(i1);
String sb = String.valueOf(i2);
long a = 0, b = 0;
for (int i = 0; i < sa.length(); i++) a = (a * 10 + (sa.charAt(i) - '0')) % MOD;
for (int i = 0; i < sb.length(); i++) b = (b * 10 + (sb.charAt(i) - '0')) % (MOD - 1);
return powerLL(a, b);
}
static long gcd(long a, long b) { if (a == 0) return b;else return gcd(b % a, a); }
static long lcm(long a, long b) { return (a * b) / gcd(a, b); }
static long lower_bound(List<Long> list, long k) {
int s = 0;
int e = list.size();
while (s != e) {
int mid = (s + e) >> 1;
if (list.get(mid) < k) s = mid + 1;
else e = mid;
}
if (s == list.size()) return -1;
return s;
}
static int upper_bound(List<Long> list, long k) {
int s = 0;
int e = list.size();
while (s != e) {
int mid = (s + e) >> 1;
if (list.get(mid) <= k) s = mid + 1;
else e = mid;
}
if (s == list.size()) return -1; return s;
}
static void addEdge(ArrayList<ArrayList<Integer>> graph, int edge1, int edge2) {
graph.get(edge1).add(edge2);graph.get(edge2).add(edge1);
}
static class Pair<X, Y> {
public X first;
public Y second;
Pair(X first, Y second) { this.first = first;this.second = second; }
public static <X, Y> Pair<X, Y> of(X a, Y b) { return new Pair<>(a, b); }
public String toString() { return "(" + first + "," + second + ")"; }
}
static boolean isCollectionsSorted(List<Integer> list) {
if (list.size() == 0 || list.size() == 1) return true;
for (int i = 1; i < list.size(); i++) if (list.get(i) < list.get(i - 1)) return false;
return true;
}
} | [
"adityaaggarwal7861@gmail.com"
] | adityaaggarwal7861@gmail.com |
862702647262bdbca1780973021165f5abbf0d29 | aa4aa63ece5a31e3ef0821c7f5c7cdb7d9baf294 | /app/src/main/java/com/example/romanpc/rosyama/DataBaseHelper.java | 423262202f2b6d37f92b91edebd1405d1afec63c | [] | no_license | rvachev/project | d0a47cc80e53fc7c01f2f26074585c0a894fadd7 | ec869b57ed45feb8ee954b7660bd333ae40d7d94 | refs/heads/master | 2018-09-05T00:03:41.745013 | 2018-08-31T06:47:37 | 2018-08-31T06:47:37 | 116,545,274 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,572 | java | package com.example.romanpc.rosyama;
import android.content.Context;
import android.content.res.AssetManager;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
public class DataBaseHelper extends SQLiteOpenHelper{
private Context context;
public DataBaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
super(context, name, factory, version);
}
public DataBaseHelper(Context context) {
super(context, "database.db", null, 1);
this.context = context;
}
//Выполняется при создании базы данных, нужно написать код для создания таблиц
@Override
public void onCreate(SQLiteDatabase sqLiteDatabase) {
String sqlQuery1 = "CREATE TABLE pits (\n" +
" _id INTEGER PRIMARY KEY\n" +
" NOT NULL,\n" +
" latitude REAL,\n" +
" longitude REAL,\n" +
" address TEXT,\n" +
" status TEXT,\n" +
" photo TEXT\n" +
")";
sqLiteDatabase.execSQL(sqlQuery1); //Этот метод позволяет выполнить любой SQL-запрос
String sqlQuery4 = "CREATE TABLE user (\n" +
" _id INTEGER PRIMARY KEY AUTOINCREMENT\n" +
" NOT NULL,\n" +
" name TEXT,\n" +
" photo TEXT\n" +
")";
sqLiteDatabase.execSQL(sqlQuery4);
AssetManager assetManager = context.getAssets();
try {
InputStream inputStream = assetManager.open("regions.txt");
Scanner scanner = new Scanner(inputStream);
while (scanner.hasNextLine()){
String sql = scanner.nextLine();
sqLiteDatabase.execSQL(sql);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
}
public void addPit(int id, double lat, double lng, String address, String status, String photo){
//Объект, позволяющий записывать БД
SQLiteDatabase writableDatabase = this.getWritableDatabase();
String sql = "INSERT INTO pits (_id, latitude, longitude, address, status, photo) VALUES ("+id+", "+lat+", "+lng+", '"+address+"', '"+status+"', '"+photo+"')";
writableDatabase.execSQL(sql);
}
public int getId(){
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT _id FROM pits";
Cursor cursor = readableDatabase.rawQuery(sql, null);
int id = 0;
while (cursor.moveToNext()){
id = cursor.getInt(0);
}
return id;
}
public ArrayList<HashMap<String,String>> getPits(){
//получение объекта, с помощью которого вы можете выполнять запросы к БД
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT _id, latitude, longitude, status FROM pits";
Cursor cursor = readableDatabase.rawQuery(sql, null);
ArrayList<HashMap<String,String>> pitsList = new ArrayList<>();
while(cursor.moveToNext()) {
int id = cursor.getInt(0);
double latitude = cursor.getDouble(1);
double longitude = cursor.getDouble(2);
String status = cursor.getString(3);
HashMap<String, String> pit = new HashMap<>();
pit.put("_id", Integer.toString(id));
pit.put("Lat", Double.toString(latitude));
pit.put("Lng", Double.toString(longitude));
pit.put("stat", status);
pitsList.add(pit);
}
return pitsList;
}
public HashMap<String, String> getPitsById(String id){
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT latitude, longitude, address, status, photo FROM pits WHERE _id = ?";
Cursor cursor = readableDatabase.rawQuery(sql, new String[]{id});
HashMap<String, String> hashMap = new HashMap<>();
while(cursor.moveToNext()) {
double lat = cursor.getDouble(0);
double lng = cursor.getDouble(1);
String address = cursor.getString(2);
String status = cursor.getString(3);
String photo = cursor.getString(4);
hashMap.put("lat", Double.toString(lat));
hashMap.put("lng", Double.toString(lng));
hashMap.put("adr", address);
hashMap.put("stat", status);
hashMap.put("photo", photo);
}
return hashMap;
}
public ArrayList<String> getCities(){
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT region FROM regions ORDER BY region";
Cursor cursor = readableDatabase.rawQuery(sql, null);
ArrayList<String> list = new ArrayList<>();
while(cursor.moveToNext()){
String region = cursor.getString(0);
list.add(region);
}
return list;
}
public void cleanTable(){
SQLiteDatabase writableDatabase = this.getWritableDatabase();
String sql = "DELETE FROM pits";
writableDatabase.execSQL(sql);
}
public int dataExist(){
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT COUNT(*) FROM pits";
Cursor cursor = readableDatabase.rawQuery(sql, null);
cursor.moveToFirst();
int i = cursor.getInt(0);
return i;
}
public ArrayList<ClusterItemImpl> getCompaniesForClaster(){
ArrayList<ClusterItemImpl> items = new ArrayList<>();
SQLiteDatabase readableDatabase = this.getReadableDatabase();
String sql = "SELECT _id, latitude, longitude FROM pits";
Cursor cursor = readableDatabase.rawQuery(sql, null);
while (cursor.moveToNext()){
int id = cursor.getInt(0);
double lat = cursor.getDouble(1);
double lng = cursor.getDouble(2);
items.add(new ClusterItemImpl(String.valueOf(id), lat, lng));
}
return items;
}
}
| [
"romandauria@gmail.com"
] | romandauria@gmail.com |
d8eb98c45d7c36d61e76a0a777e1104b857125fb | 053b6812997b15be513e2dd9adfc16d396bab9dc | /src/main/java/com/beierdeba/list/AbstractList.java | eb5919bb62405c66824e6ab998ce82c5ecc4d367 | [] | no_license | beierdeba/data-structure | 7bcf6c30529cfcf930195aafdcaa6b065041aefe | d4a3f3cf78eec8f6f469e014fd60a451648d4c97 | refs/heads/master | 2022-12-11T17:17:27.613763 | 2020-09-12T14:28:56 | 2020-09-12T14:28:56 | 294,846,890 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 646 | java | package com.beierdeba.list;
/**
* @author Administrator
* @since 2020/9/12 15:36
*/
public abstract class AbstractList<E> implements List<E> {
// 包含的元素的个数, 不是数组的长度
protected int size;
public int size() {
return size;
}
public boolean isEmpty() {
return size == 0;
}
public boolean contains(Object o) {
int i = indexOf(o);
return i != -1;
}
// 防止数据越界
protected void rangeCheck(int index) {
if (index > size || index < 0)
throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size);
}
}
| [
"nicholasinlove@126.com"
] | nicholasinlove@126.com |
952292c218941761cce90cbe01a1c80da801495f | 31447899832d43eed4fe01b2d8c367bdc81b848c | /src/main/java/org/esupportail/publisher/service/factories/impl/PermissionDTOSelectorFactoryImpl.java | d5241a511fc3db10a9209cec754351d0b654904b | [
"Apache-2.0"
] | permissive | tolobial/esup-publisher | ec623ec6d924026294bbd29ef5586f1baf7b1078 | 0d23dca47a38dd2b4f6f02df5817d8011636fc15 | refs/heads/master | 2021-01-11T03:38:46.716454 | 2016-08-30T16:19:36 | 2016-08-30T16:19:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,791 | java | package org.esupportail.publisher.service.factories.impl;
import lombok.Getter;
import org.apache.commons.lang.IllegalClassException;
import org.esupportail.publisher.domain.AbstractPermission;
import org.esupportail.publisher.repository.PermissionRepository;
import org.esupportail.publisher.service.exceptions.ObjectNotFoundException;
import org.esupportail.publisher.service.factories.APermissionDTOFactory;
import org.esupportail.publisher.service.factories.PermissionDTOSelectorFactory;
import org.esupportail.publisher.web.rest.dto.PermissionDTO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.inject.Inject;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
*
* @author GIP RECIA - Julien Gribonvald
* 23 oct. 2014
*/
@Service
@Transactional(readOnly=true)
public class PermissionDTOSelectorFactoryImpl extends AbstractDTOFactoryImpl<PermissionDTO, AbstractPermission, Long> implements PermissionDTOSelectorFactory {
@Inject
@Getter
private transient PermissionRepository<AbstractPermission> dao;
@Inject
private transient List<APermissionDTOFactory<? extends PermissionDTO, ? extends AbstractPermission>> permissionFactories;
public PermissionDTOSelectorFactoryImpl() {
super(PermissionDTO.class, AbstractPermission.class);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public PermissionDTO from(@NotNull AbstractPermission model) {
return (PermissionDTO) ((APermissionDTOFactory) getFactory(model)).from(model);
}
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public AbstractPermission from(@NotNull PermissionDTO dtObject) throws ObjectNotFoundException {
return (AbstractPermission) ((APermissionDTOFactory) getFactory(dtObject)).from(dtObject);
}
private APermissionDTOFactory<? extends PermissionDTO, ? extends AbstractPermission> getFactory(final PermissionDTO dtoObject) {
for (APermissionDTOFactory<? extends PermissionDTO, ? extends AbstractPermission> factory : permissionFactories) {
if (factory.isDTOFactoryImpl(dtoObject)) return factory;
}
throw new IllegalClassException("No DTOFactoryImpl found for " + dtoObject.getClass().getCanonicalName());
}
private APermissionDTOFactory<? extends PermissionDTO, ? extends AbstractPermission> getFactory(final AbstractPermission model) {
for (APermissionDTOFactory<? extends PermissionDTO, ? extends AbstractPermission> factory : permissionFactories) {
if (factory.isDTOFactoryImpl(model)) return factory;
}
throw new IllegalClassException("No DTOFactoryImpl found for " + model.getClass().getCanonicalName());
}
}
| [
"julien.gribonvald@gmail.com"
] | julien.gribonvald@gmail.com |
cade837f2559d5c76e5073377853f1935e14a997 | 5d2c2cd7585c69c9a576e91189f2947357418c87 | /src/main/java/it/maior/icaro/word/docx/DocxFileCreator.java | e29666645913bd76a9926c85503bfbec807aeb10 | [] | no_license | matommaso/FromJiraToWord | 798d6f8a4c46675f78cf3cbed87f595517649ce6 | a481c084987d8263f969d579d4bc2174e9d32fc3 | refs/heads/master | 2020-03-21T07:38:23.997611 | 2018-06-26T07:06:04 | 2018-06-26T07:06:04 | 138,290,960 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,619 | java | package it.maior.icaro.word.docx;
import org.docx4j.XmlUtils;
import org.docx4j.dml.wordprocessingDrawing.Inline;
import org.docx4j.jaxb.Context;
import org.docx4j.model.table.TblFactory;
import org.docx4j.openpackaging.exceptions.Docx4JException;
import org.docx4j.openpackaging.exceptions.InvalidFormatException;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.*;
import org.docx4j.wml.*;
import org.docx4j.wml.Color;
import javax.xml.bind.JAXBException;
import java.io.File;
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.util.List;
public class DocxFileCreator {
public WordprocessingMLPackage wordPackage;
public MainDocumentPart mainDocumentPart;
public DocxFileCreator() {
init();
}
private void init() {
try {
this.wordPackage = WordprocessingMLPackage.createPackage();
this.mainDocumentPart= this.wordPackage.getMainDocumentPart();
// Add numbering part
NumberingDefinitionsPart ndp = new NumberingDefinitionsPart();
this.wordPackage.getMainDocumentPart().addTargetPart(ndp);
ndp.setJaxbElement( (Numbering) XmlUtils.unmarshalString(initialNumbering) );
} catch (InvalidFormatException e) {
e.printStackTrace();
} catch (JAXBException e) {
e.printStackTrace();
}
}
public void addStyledParagraphOfText (String styleId, String text){
mainDocumentPart.addStyledParagraphOfText(styleId, text);
}
public void addParagraphOfText (String text){
mainDocumentPart.addParagraphOfText(text);
}
// MATO: it creates a paragraph with a hard coded configuration: object r and rpr
public void addParagraphWithConfiguration(String s) {
ObjectFactory factory = Context.getWmlObjectFactory();
P p = factory.createP();
R r = factory.createR();
Text t = factory.createText();
t.setValue(s);
r.getContent().add(t);
p.getContent().add(r);
RPr rpr = factory.createRPr();
BooleanDefaultTrue b = new BooleanDefaultTrue();
rpr.setB(b);
rpr.setI(b);
rpr.setCaps(b);
Color red = factory.createColor();
red.setVal("green");
rpr.setColor(red);
r.setRPr(rpr);
mainDocumentPart.getContent().add(p);
}
//MATO: it creates a table with dimension equal to rowNumber X columnNumber where every cell contains the same value (value parameter)
public void addTable(int columnNumber, int rowNumber, String value){
int writableWidthTwips = wordPackage.getDocumentModel().getSections().get(0).getPageDimensions().getWritableWidthTwips();
Tbl tbl = TblFactory.createTable(columnNumber, rowNumber, writableWidthTwips / columnNumber);
List<Object> rows = tbl.getContent();
for (Object row : rows) {
Tr tr = (Tr) row;
List<Object> cells = tr.getContent();
for (Object cell : cells) {
Tc td = (Tc) cell;
td.getContent().add(value);
}
}
}
public void addImage(String imagePath, String filenameHint){
try {
File image = new File(imagePath);
byte[] fileContent = Files.readAllBytes(image.toPath());
BinaryPartAbstractImage imagePart = BinaryPartAbstractImage.createImagePart(wordPackage, fileContent);
Inline inline = imagePart.createImageInline(filenameHint, "Alt Text", 1, 2, false);
P Imageparagraph = addImageToParagraph(inline);
mainDocumentPart.getContent().add(Imageparagraph);
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
private P addImageToParagraph(Inline inline) {
ObjectFactory factory = new ObjectFactory();
P p = factory.createP();
R r = factory.createR();
p.getContent().add(r);
Drawing drawing = factory.createDrawing();
r.getContent().add(drawing);
drawing.getAnchorOrInline().add(inline);
return p;
}
public void saveFileDocx(String outputPath) {
try {
File exportFile = new File(outputPath);
wordPackage.save(exportFile);
} catch (Docx4JException e) {
e.printStackTrace();
}
}
public void addBulletParagraphOfText(long numId, long ilvl, String paragraphText ) {
ObjectFactory factory = Context.getWmlObjectFactory();
P p = factory.createP();
org.docx4j.wml.Text t = factory.createText();
t.setValue(paragraphText);
org.docx4j.wml.R run = factory.createR();
run.getContent().add(t);
p.getContent().add(run);
org.docx4j.wml.PPr ppr = factory.createPPr();
p.setPPr( ppr );
// Create and add <w:numPr>
PPrBase.NumPr numPr = factory.createPPrBaseNumPr();
ppr.setNumPr(numPr);
// The <w:ilvl> element
PPrBase.NumPr.Ilvl ilvlElement = factory.createPPrBaseNumPrIlvl();
numPr.setIlvl(ilvlElement);
ilvlElement.setVal(BigInteger.valueOf(ilvl));
// The <w:numId> element
PPrBase.NumPr.NumId numIdElement = factory.createPPrBaseNumPrNumId();
numPr.setNumId(numIdElement);
numIdElement.setVal(BigInteger.valueOf(numId));
this.wordPackage.getMainDocumentPart().addObject(p);
}
static final String initialNumbering = "<w:numbering xmlns:ve=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\" xmlns:m=\"http://schemas.openxmlformats.org/officeDocument/2006/math\" xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:wp=\"http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing\" xmlns:w10=\"urn:schemas-microsoft-com:office:word\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\">"
+ "<w:abstractNum w:abstractNumId=\"0\">"
+ "<w:nsid w:val=\"2DD860C0\"/>"
+ "<w:multiLevelType w:val=\"multilevel\"/>"
+ "<w:tmpl w:val=\"0409001D\"/>"
+ "<w:lvl w:ilvl=\"0\">"
+ "<w:start w:val=\"1\"/>"
+ "<w:numFmt w:val=\"bullet\"/>"
+ "<w:lvlText w:val=\"•\"/>"
+ "<w:lvlJc w:val=\"left\"/>"
+ "<w:pPr>"
+ "<w:ind w:left=\"360\" w:hanging=\"360\"/>"
+ "</w:pPr>"
+ "</w:lvl>"
+ "<w:lvl w:ilvl=\"1\">"
+ "<w:start w:val=\"1\"/>"
+ "<w:numFmt w:val=\"bullet\"/>"
+ "<w:lvlText w:val=\"○\"/>"
+ "<w:lvlJc w:val=\"left\"/>"
+ "<w:pPr>"
+ "<w:ind w:left=\"720\" w:hanging=\"360\"/>"
+ "</w:pPr>"
+ "</w:lvl>"
+ "<w:lvl w:ilvl=\"2\">"
+ "<w:start w:val=\"1\"/>"
+ "<w:numFmt w:val=\"bullet\"/>"
+ "<w:lvlText w:val=\"◘\"/>"
+ "<w:lvlJc w:val=\"left\"/>"
+ "<w:pPr>"
+ "<w:ind w:left=\"1080\" w:hanging=\"360\"/>"
+ "</w:pPr>"
+ "</w:lvl>"
+ "</w:abstractNum>"
+ "<w:num w:numId=\"1\">"
+ "<w:abstractNumId w:val=\"0\"/>"
+ "</w:num>"
+ "</w:numbering>";
}
| [
"tommaso.magherini@maior.it"
] | tommaso.magherini@maior.it |
db945072f5219a075153348396e6b0911a36e3cd | 94090bf9fd05a6be5d2bbb96bdebacf78dcc3ce9 | /Angular/src/main/java/br/com/Prevent/SpringAngular/request/LogPostDto.java | 65c301de0e877baa142e88a183e92c60cc4a08be | [] | no_license | souzaantunes/Aplicacao-de-Log | 1aea49da63fa44021547c88711b7a2c6e78eeb4c | 98488c69bcbcc0fd5f2813099beb3f2aa9c83516 | refs/heads/master | 2023-07-17T04:15:11.742371 | 2021-08-23T17:15:47 | 2021-08-23T17:15:47 | 378,933,527 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 820 | java | package br.com.Prevent.SpringAngular.request;
import java.time.LocalDateTime;
public class LogPostDto {
private String ip;
private String metodo;
private LocalDateTime data;
private String status;
private String userAgent;
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String getMetodo() {
return metodo;
}
public void setMetodo(String metodo) {
this.metodo = metodo;
}
public LocalDateTime getData() {
return data;
}
public void setData(LocalDateTime data) {
this.data = data;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getUserAgent() {
return userAgent;
}
public void setUserAgent(String userAgent) {
this.userAgent = userAgent;
}
}
| [
"souza.andinho.as@gmail.com"
] | souza.andinho.as@gmail.com |
034fb754ac60b7f569b6fb98578022782bc79f02 | ee8d225e46dfe56e8d48cdcb41ab6a8be4cfdb6a | /src/test/java/com/spp/pages/CreateBonusDefinitionModeofPaymentDDPTonBonusRespectiveMonthDoNotConsiderPreviousYear.java | 6f4989104110315fb2dea58a1e26d911c77d33ac | [] | no_license | chandra-relyon/NewSPP | 11f43cef4f87ed4cbe5148a4a7bb5813ab9cb66f | ff66bdb85b3c1c9c42f0e0d41179f3127745c4c2 | refs/heads/master | 2020-07-04T12:40:29.002189 | 2019-08-14T06:26:56 | 2019-08-14T06:26:56 | 202,288,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,636 | java | package com.spp.pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import com.spp.common.BasePage;
public class CreateBonusDefinitionModeofPaymentDDPTonBonusRespectiveMonthDoNotConsiderPreviousYear extends BasePage{
@FindBy(id="salary")
WebElement Salary;
@FindBy(xpath="//*[@id=\"menu\"]/li[6]/div/div[1]/ul/li[11]/a")
WebElement Bonus;
@FindBy(xpath="//*[@id=\"bonus_definition_list\"]/div[1]/span/a")
WebElement AddNewBonus;
@FindBy(id="bonusHeadName")
WebElement BonusHead;
@FindBy(id="bonus_exgratia_definition_manual_editing")
WebElement Manual;
@FindBy(id="bonus_exgratia_definition_max_amount")
WebElement MaxBonus;
@FindBy(id="bonus_exgratia_definition_from_month")
WebElement FromMonth;
@FindBy(id="bonus_exgratia_definition_to_month")
WebElement ToMonth;
@FindBy(id="bonus_exgratia_definition_paymonth")
WebElement Paymonth;
@FindBy(id="bonus_exgratia_definition_mode_of_payment")
WebElement SelectModeofPayment;
@FindBy(id="bonus_exgratia_definition_min_working_days")
WebElement EmployeeswithMinWorkingDays;
@FindBy(id="bonus_exgratia_definition_salary_independent")
WebElement CheckSalaryIndependent;
@FindBy(id="bonus_exgratia_definition_pt_on_bonus_exgratia")
WebElement SelectPTOnBonus;
@FindBy(id="bonus_exgratia_definition_pt_consider_month_current_month")
WebElement SelectCurrentMonth;
@FindBy(id="bonus_exgratia_definition_pt_consider_month_respective_month")
WebElement SelectRespectiveMonth;
@FindBy(id="bonus_exgratia_definition_pt_consider_year_dont_consider_previous_year")
WebElement Donotconsiderpreviousyear;
@FindBy(id="bonus_exgratia_definition_round_off_nearest_rupee")
WebElement CheckNearestrupee;
@FindBy(id="create_heading_name")
WebElement CreateBonus;
@FindBy(xpath="//*[@id=\"main\"]/div[2]/strong")
WebElement SuccessfulMessage;
@FindBy(xpath="//*[@id='bonus_or_exgratia']/div/table/tbody/tr[1]/td[4]/a")
WebElement DeleteButton;
public CreateBonusDefinitionModeofPaymentDDPTonBonusRespectiveMonthDoNotConsiderPreviousYear(WebDriver driver) {
super(driver);
PageFactory.initElements(driver,this);
}
public void clickSalary(){
Salary.click();
}
public void selectBonus(){
Bonus.click();
}
public void clickAddNewBonus(){
AddNewBonus.click();
}
public void EnterBonusHead(String value){
BonusHead.sendKeys(value);
}
public void clickManual(){
Manual.click();
}
public void EnterMaxBonus(String value){
MaxBonus.sendKeys(value);
}
public void SelectFromMonth(String value){
dropDownSelect(FromMonth, value);
}
public void SelectToMonth(String value){
dropDownSelect(ToMonth, value);
}
public void SelectPaymonth(String value){
dropDownSelect(Paymonth, value);
}
public void SelectModeofPayment(String value) {
dropDownSelect(SelectModeofPayment, value);
}
public void consideremployeeswithminwork() {
EmployeeswithMinWorkingDays.click();
}
public void checksalaryindependent() {
CheckSalaryIndependent.click();
}
public void selectptonbonus() {
SelectPTOnBonus.click();
}
public void selectcurrentmonth() {
SelectCurrentMonth.click();
}
public void selectrespectivemonth() {
SelectRespectiveMonth.click();
}
public void selectdonotconsiderpreviousyear() {
Donotconsiderpreviousyear.click();
}
public void checknearestrupee() {
CheckNearestrupee.click();
}
public void clickCreateBonus(){
CreateBonus.click();
}
public String getMessage(){
return SuccessfulMessage.getText();
}
public void clickDeleteButton(){
DeleteButton.click();
}
}
| [
"RSL@Lenovo430"
] | RSL@Lenovo430 |
4042d1597a501946ce634ebd75b5f48751fc7d65 | 14a4f0c31c582a7a6dd657bc295a4b5b811d07ed | /builder/src/main/java/com/yeyouluo/Director.java | 9d6246bbfee7db197bee60b92e69b5ac4b853617 | [
"Apache-2.0"
] | permissive | yeyouluo/java-design | 5e33e4fe851a8346a212c2621fdbc101f6d366fc | cafa5bd97ad23f7266c2bfc31d109f15a44db3d0 | refs/heads/master | 2020-03-22T15:39:16.795734 | 2019-03-31T09:19:13 | 2019-03-31T09:19:13 | 140,267,272 | 9 | 1 | null | null | null | null | UTF-8 | Java | false | false | 206 | java | package com.yeyouluo;
/**
* Author: yeyouluo
* Date: 2018/7/11
*/
public class Director {
public void construct(Builder builder){
builder.buildPartA();
builder.buildPartB();
}
}
| [
"chenzxwangyi@163.com"
] | chenzxwangyi@163.com |
9cab6384c808e43cea4e9734d40e1348f4d45c48 | 6496517875975361d71a72c3f07a1abbe4c42242 | /SeleniumPumpkinSoup.java | d7b69e75edce4d29355102a69cf784bd0e6d5d9d | [] | no_license | KellySarah1/CIT360 | 8fd8fe46c14e5a54424ed71c80b6f0200fea52c0 | d8e9537ec7d5dd81d5805d88150af1b4c526ee9e | refs/heads/master | 2020-04-06T04:55:42.598889 | 2016-12-13T22:43:09 | 2016-12-13T22:43:09 | 70,720,157 | 0 | 0 | null | 2016-10-21T00:12:22 | 2016-10-12T16:40:29 | Java | UTF-8 | Java | false | false | 1,030 | java | import java.util.List;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class SeleniumPumpkinSoup {
public static void main(String[] args) {
WebDriver driver;
System.setProperty("webdriver.gecko.driver", "D:\\Java\\geckodriver-v0.11.1-win64\\geckodriver.exe");
driver =new FirefoxDriver();
driver.get("http://www.google.com");
WebElement element = driver.findElement(By.id("gsr"));
element.sendKeys("Pumpkin Soup"); // send also a "\n"
element.submit();
driver.get("https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&cad=rja&uact=8&sqi=2&ved=0ahUKEwjzgNG6k9bQAhVRx2MKHZrLCqwQFggjMAI&url=http%3A%2F%2Fallrecipes.com%2Frecipe%2F9191%2Fpumpkin-soup%2F&usg=AFQjCNEBWy9J1RF7GcptChObZKTLuD9_nA&bvm=bv.139782543,d.cGc");
element.click();
}
}
| [
"noreply@github.com"
] | KellySarah1.noreply@github.com |
9baec39fa46036e1292e0a488f5b982969e45af2 | 750b3dc1b3d0128d5e08a1ba6c9337ab4a498f73 | /src/by/it/siarheikorbut/jd01_09/Parser.java | 61b65c43adde41bcd565a1a491953aca227b8404 | [] | no_license | siarheikorbut/JD2020-09-15 | be7e43f328be3c83b32902736c18e223025c6e86 | bf917ca5bb89182ad48c5ac9fb6a2acb1a8bf3fd | refs/heads/master | 2023-01-21T16:30:58.839670 | 2020-11-22T17:40:38 | 2020-11-22T17:40:38 | 298,222,599 | 0 | 0 | null | 2020-09-24T08:53:37 | 2020-09-24T08:53:36 | null | UTF-8 | Java | false | false | 1,198 | java | package by.it.siarheikorbut.jd01_09;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author Siarhei Korbut
* @see <a href="https://drive.google.com/file/d/1C-wHpUcHtxb-Qq0lfyExNQsYeKr3yIPh/view?usp=sharing">Задание JD01_09</a>
*/
class Parser {
Var calc(String expression) {
String[] parts = expression.split(Patterns.OPERATIONS, 2);
if (parts.length != 2) {
//TODO expression
return null;
}
Var left = Var.createVar(parts[0]);
Var right = Var.createVar(parts[1]);
if (left == null || right == null) {
return null;
}
Pattern patternOperation = Pattern.compile(Patterns.OPERATIONS);
Matcher matcherOperation = patternOperation.matcher(expression);
if (matcherOperation.find()) {
String operation = matcherOperation.group();
return switch (operation) {
case "+" -> left.add(right);
case "-" -> left.sub(right);
case "*" -> left.mul(right);
case "/" -> left.div(right);
default -> null;
};
}
return null;
}
} | [
"siarheikorbut@gmail.com"
] | siarheikorbut@gmail.com |
3d9c14626e04581c20335ce356b7375b796cbade | 435a1f478647747b9d53247660ad1fb27b1f3d5a | /vieeo/vieeo-orm/src/main/java/com/vieeo/orm/jdbc/support/DataSourceConnector.java | 4e359afd0bc52b9674a70ad2d192757e32550728 | [] | no_license | happyjianguo/vieeo | 4c008fc18dfab597da4dc91303f7835420671186 | ff7e1195a5441f696a2e38dd3f55af2821a118e0 | refs/heads/master | 2020-06-20T04:22:31.065097 | 2015-04-14T03:01:14 | 2015-04-14T03:01:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,221 | java | package com.vieeo.orm.jdbc.support;
import java.sql.Connection;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.vieeo.orm.jdbc.Connector;
import com.vieeo.orm.jdbc.JdbcException;
import com.vieeo.orm.jdbc.JdbcUtils;
/**
* 连接池连接类,负责与连接池通信
* @author hehy
*
*/
public class DataSourceConnector implements Connector{
private static final Log logger = LogFactory.getLog(DataSourceConnector.class);
private DataSource dataSource;
public DataSourceConnector(){}
public DataSourceConnector(DataSource dataSource){
this.dataSource = dataSource;
}
@Override
public Connection getConnection() throws JdbcException {
try {
return dataSource.getConnection();
} catch (SQLException e) {
logger.error("Could not open jdbc connection:"+e);
throw new JdbcException("Could not open jdbc connection:",e);
}
}
@Override
public void release(Connection connection) {
JdbcUtils.closeConnection(connection);
}
public DataSource getDataSource() {
return dataSource;
}
public void setDataSource(DataSource dataSource) {
this.dataSource = dataSource;
}
}
| [
"lakerhe520@gmail.com"
] | lakerhe520@gmail.com |
56a14685077f2261101397d736cd030bbf69d63c | 00387fe46383162f99df40c94a854b9e5e04b651 | /src/stacks/RainwaterTrapping.java | 71dd2092f771543bfc1b9c4218b5bc7198da6204 | [] | no_license | navspeak/CP | 39b55da0222cb62c0f9194364969338931d07226 | 7938d75d0438cfb2ad212e2ba71ba1d9af33ca62 | refs/heads/master | 2020-04-08T17:03:55.375297 | 2019-05-14T03:01:41 | 2019-05-14T03:01:41 | 159,548,774 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,527 | java | package stacks;
/*
InterviewBit (not really stack. But anyways):
Given n non-negative integers representing an elevation map where the width of each bar is 1,
compute how much water it is able to trap after raining.
Example :
Given [0,1,0,2,1,0,1,3,2,1,2,1], return 6.
*/
public class RainwaterTrapping {
/*
__
| |
--- | |
| | ---| |
| |___| | | ---
| | | | |__ __| |
[ 3 1 2 5 0 0 1 ]
Find left[i] which shows Max height left of i including i 3335555
Find right[i] which shows Max height right of i including i 5555111
water += min(left[i], right[i]) - arr[i]
0+2+1+1+1
*/
int solve(int[] arr){
final int left[] = new int[arr.length];
final int right[] = new int[arr.length];
int result = 0;
left[0] = arr[0];
right[arr.length - 1] = arr[arr.length - 1];
for (int i = 1; i < arr.length ; i++) {
left[i] = Math.max(left[i-1], arr[i]);
}
for (int i = arr.length - 2; i >= 0 ; i--) {
right[i] = Math.max(right[i+1], arr[i]);
}
for (int i = 0; i < arr.length; i++) {
result += Math.min(left[i],right[i]) - arr[i];
}
return result;
}
/*
__
| |
--- | |
| | ---| |
| |___| | | ---
| | | | |__ __| |
[ 3 1 2 5 0 0 1 ]
Keep two pointers at left and right end. Do below till i < j
See height at which end is lesser
Update leftMax or rightMax while traversing the array if ht at i or j is greater than leftMax or rightMax
else water += leftMax or rightMax - arr[i]
i=0, j=6
leftMax = 0, 0
RightMax = 0, 1
ht[i=0] > ht[j=6] (3>1) check right
ht[6] > rightMax = 0 update rightMax = 1 and j = 5
ht[i=0] > ht[j=5] (3>0) check right
ht[5] < rightMax = 1 water = rightMax - ht[5] = 1 - 0 = 1 & j = 4
ht[i=0] > ht[j=4] (3>0) check right
ht[5] < rightMax = 1 water = 1 + (rightMax - ht[4]) = 1+ 1 - 0 = 2 & j = 3
ht[i=0] < ht[j=3] (3<5) check left
ht[0] > leftMax = 0 update leftMax = 3 and i = 1
ht[i=1] < ht[j=3] (1<5) check left
ht[1] < leftMax = 3 water = 2 + (leftMax - ht[1]) = 2 + 3 - 1 = 4 & i = 2
ht[2] < ht[3] (2<5) check left
ht[2] < leftmax water = 4 + (3 -2) = 5 and i = 3
since i == j break
*/
int solve_improved (int[] arr){
int i = 0;
int j = arr.length - 1;
int leftMax = 0, rightMax = 0;
int result = 0;
while (i < j) {
if (arr[i] < arr[j]) {
if (arr[i] > leftMax)
leftMax = arr[i];
else
result+=leftMax - arr[i];
i++;
} else {
if (arr[j] > rightMax)
rightMax = arr[j];
else
result+=rightMax - arr[j];
j--;
}
}
return result;
}
}
class RainWaterTrappingTest {
public static void main(String[] args) {
RainwaterTrapping rainWaterTrapping = new RainwaterTrapping();
System.out.println(rainWaterTrapping.solve_improved(new int[]{0,1,0,2,1,0,1,3,2,1,2,1}) == 6?
"Test 1 Passed" : "Test 1 failed");
System.out.println(rainWaterTrapping.solve(new int[]{ 3, 1, 2,5,0, 0, 1}) == 5 ?
"Test 2 Passed" : "Test 2 failed");
}
} | [
"navneet.sahay@gmail.com"
] | navneet.sahay@gmail.com |
8f7f758b6bafdc8b1c3bf4ab8fadf200cd283686 | 5f3747c6e5226ae66f128a65461d7d6251cb0689 | /dmpproject_bak/src/cn/clickwise/liqi/mark/LABEL.java | ea5636c6a1989d2391c38c54b00b3caf6aa88305 | [] | no_license | genghaihua/user_click | 4a6071ad0e394040cd8db8599cf6cde4603dc2ba | ed0c58533f1c59e040f69a06f6d74124f117211f | refs/heads/master | 2020-05-18T19:40:16.852710 | 2015-05-19T07:38:27 | 2015-05-19T07:38:27 | 35,866,687 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 415 | java | package cn.clickwise.liqi.mark;
import java.io.Serializable;
/**
* 标记的封装
* @author lq
*
*/
public class LABEL implements Serializable{
/**
* label 的编号 ,从1开始的整数
*/
public int index;
/**
* 所有类别的数目
*/
public int label_num;
public LABEL(int index,int label_num)
{
this.index=index;
this.label_num=label_num;
}
}
| [
"genghaihua@yeah.net"
] | genghaihua@yeah.net |
ab88dc092f28f62e3f725c32c8990a2e83e36952 | 5f126d58e906fe171ba50aeece22e6e1246e6ba6 | /app/src/main/java/com/nvisio/video/videostreamsample/view/VideoPlayActivity.java | 8eb1fcae91fd5e88b39adf7c26d881307f4754aa | [] | no_license | shakilnvisio/VideoStreamSample | 46071d0eef553d04c478a4ff5730438080fc60c6 | 1e59cfe61255992b45b37b68a2bcbd6022b5b93d | refs/heads/master | 2020-03-25T17:57:55.801033 | 2018-09-04T12:05:50 | 2018-09-04T12:05:50 | 144,005,811 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,194 | java | package com.nvisio.video.videostreamsample.view;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.google.android.exoplayer2.ExoPlayerFactory;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.SimpleExoPlayer;
import com.google.android.exoplayer2.source.ExtractorMediaSource;
import com.google.android.exoplayer2.source.MediaSource;
import com.google.android.exoplayer2.source.dash.DashChunkSource;
import com.google.android.exoplayer2.source.dash.DashMediaSource;
import com.google.android.exoplayer2.source.dash.DefaultDashChunkSource;
import com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection;
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector;
import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.ui.PlayerView;
import com.google.android.exoplayer2.upstream.BandwidthMeter;
import com.google.android.exoplayer2.upstream.DataSource;
import com.google.android.exoplayer2.upstream.DefaultBandwidthMeter;
import com.google.android.exoplayer2.upstream.DefaultDataSourceFactory;
import com.google.android.exoplayer2.upstream.DefaultHttpDataSourceFactory;
import com.google.android.exoplayer2.upstream.TransferListener;
import com.google.android.exoplayer2.util.Util;
import com.nvisio.video.videostreamsample.R;
import com.nvisio.video.videostreamsample.view.news.NewsActivity;
public class VideoPlayActivity extends AppCompatActivity {
private static final String KEY_PLAY_WHEN_READY = "play_when_ready";
private static final String KEY_WINDOW = "window";
private static final String KEY_POSITION = "position";
private static final String KEY_HAVE_DATA = "havedata";
private final String vidAddress = "https://archive.org/download/ksnn_compilation_master_the_internet/ksnn_compilation_master_the_internet_512kb.mp4";
private PlayerView playerView;
private SimpleExoPlayer player;
private DataSource.Factory mediaDataSourceFactory;
private DefaultTrackSelector trackSelector;
private boolean shouldAutoPlay;
private BandwidthMeter bandwidthMeter;
private long playbackPosition;
private int currentWindow;
private boolean playWhenReady = true;
private static final DefaultBandwidthMeter BANDWIDTH_METER = new DefaultBandwidthMeter();
private SharedPreferences preferences;
private ComponentListener componentListener;
private String link;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_play);
preferences = getSharedPreferences("shared",MODE_PRIVATE);
componentListener = new ComponentListener();
if (!preferences.getBoolean(KEY_HAVE_DATA,false)){
playWhenReady = true;
currentWindow = 0;
playbackPosition = 0;
}
else{
playWhenReady = preferences.getBoolean(KEY_PLAY_WHEN_READY,false);
currentWindow = preferences.getInt(KEY_WINDOW,0);
playbackPosition = preferences.getLong(KEY_POSITION,0);
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(KEY_HAVE_DATA,false).apply();
Log.d("boo>>","oncretae: pos: "+playbackPosition);
}
//link = getIntent().getStringExtra("link");
mediaDataSourceFactory = new DefaultDataSourceFactory(this,
Util.getUserAgent(this, "mediaPlayerSample"), (TransferListener<? super DataSource>) bandwidthMeter);
}
private void initializePlayer(){
if (player == null){
playerView = findViewById(R.id.playerView);
// create a default TrackSelector
bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
// create a player
player = ExoPlayerFactory.newSimpleInstance(this,trackSelector);
player.addListener(componentListener);
playerView.setPlayer(player);
player.setPlayWhenReady(true);
Log.d("boo>>","win: "+currentWindow+" pos: "+playbackPosition);
player.seekTo(currentWindow,playbackPosition);
MediaSource mediaSource = buildMediaSource(Uri.parse(getString(R.string.media_url_dash)));
player.prepare(mediaSource,false,false);
}
/*MediaSource mediaSource = new ExtractorMediaSource.Factory(mediaDataSourceFactory)
.createMediaSource(Uri.parse(vidAddress));*/
//player.prepare(mediaSource,true,false);
}
/*private MediaSource buildMediaSource(Uri uri){
DataSource.Factory manifestDataSourceFactory = new DefaultHttpDataSourceFactory("ua");
DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(
new DefaultHttpDataSourceFactory("ua", BANDWIDTH_METER));
return new DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
.createMediaSource(uri);
}*/
private MediaSource buildMediaSource(Uri uri){
String userAgent = "exoplayer-codelab";
//return new ExtractorMediaSource.Factory(new DefaultHttpDataSourceFactory(userAgent)).createMediaSource(uri);
if (uri.getLastPathSegment().contains("mp4")){
return new ExtractorMediaSource.Factory(new DefaultHttpDataSourceFactory(userAgent)).createMediaSource(uri);
}
else{
DataSource.Factory manifestDataSourceFactory = new DefaultHttpDataSourceFactory(userAgent);
DashChunkSource.Factory dashChunkSourceFactory = new DefaultDashChunkSource.Factory(
new DefaultHttpDataSourceFactory(userAgent, BANDWIDTH_METER));
return new DashMediaSource.Factory(dashChunkSourceFactory, manifestDataSourceFactory)
.createMediaSource(uri);
}
}
private void releasePlayer(){
if (player!=null){
updateStartPosition();
player.removeListener(componentListener);
player.release();
player = null;
trackSelector = null;
}
}
@Override
protected void onStart() {
super.onStart();
initializePlayer();
}
@Override
protected void onResume() {
super.onResume();
hideSystemUi();
initializePlayer();
}
@Override
protected void onPause() {
super.onPause();
releasePlayer();
}
@Override
protected void onStop() {
super.onStop();
releasePlayer();
}
private void hideSystemUi() {
playerView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
private void updateStartPosition() {
playbackPosition = player.getCurrentPosition();
currentWindow = player.getCurrentWindowIndex();
playWhenReady = player.getPlayWhenReady();
SharedPreferences.Editor editor = preferences.edit();
editor.putBoolean(KEY_HAVE_DATA,true);
editor.putBoolean(KEY_PLAY_WHEN_READY,playWhenReady);
editor.putInt(KEY_WINDOW,currentWindow);
editor.putLong(KEY_POSITION,playbackPosition);
editor.apply();
}
private class ComponentListener extends Player.DefaultEventListener{
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
String stateString;
switch (playbackState){
case Player.STATE_IDLE:{
stateString = "idle";
Log.d("state>>", stateString);
break;
}
case Player.STATE_BUFFERING:{
stateString = "buffering";
Log.d("state>>", stateString);
break;
}
case Player.STATE_READY:{
stateString = "ready";
Log.d("state>>", stateString);
break;
}
case Player.STATE_ENDED:{
stateString = "ended";
Log.d("state>>", stateString);
break;
}
default:
stateString = "unknown state";
Log.d("state>>", stateString);
break;
}
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
startActivity(new Intent(VideoPlayActivity.this, VideoActivity.class));
finish();
}
}
| [
"shakil.sharin14@gmail.com"
] | shakil.sharin14@gmail.com |
a831d82d2b8a74ff11fe7c8be3647b1b769857b3 | 26f58561cda045395a1ae980b0ad7499cb719ec2 | /src/hasor-jetty/src/main/java/org/eclipse/jetty/server/nio/SelectChannelConnector.java | 39b6758cbafbbe260703b87802772bde1060d24b | [] | no_license | simplechen/hasor | 5338037bb4e4553df4c78dc13b118b70da779a47 | 438fe8caa378aa0d6835121d06a5cf5b77c4e11d | refs/heads/master | 2021-01-16T22:24:41.395124 | 2014-07-04T11:59:07 | 2014-07-04T11:59:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,644 | java | //
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.server.nio;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.nio.channels.SelectionKey;
import java.nio.channels.ServerSocketChannel;
import java.nio.channels.SocketChannel;
import org.eclipse.jetty.continuation.Continuation;
import org.eclipse.jetty.io.AsyncEndPoint;
import org.eclipse.jetty.io.ConnectedEndPoint;
import org.eclipse.jetty.io.Connection;
import org.eclipse.jetty.io.EndPoint;
import org.eclipse.jetty.io.nio.AsyncConnection;
import org.eclipse.jetty.io.nio.SelectChannelEndPoint;
import org.eclipse.jetty.io.nio.SelectorManager;
import org.eclipse.jetty.io.nio.SelectorManager.SelectSet;
import org.eclipse.jetty.server.AsyncHttpConnection;
import org.eclipse.jetty.server.Request;
import org.eclipse.jetty.util.thread.ThreadPool;
/* ------------------------------------------------------------------------------- */
/**
* Selecting NIO connector.
* <p>
* This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers
* are used and threads are only allocated to connections with requests. Synchronization is used to
* simulate blocking for the servlet API, and any unflushed content at the end of request handling
* is written asynchronously.
* </p>
* <p>
* This connector is best used when there are a many connections that have idle periods.
* </p>
* <p>
* When used with {@link org.eclipse.jetty.continuation.Continuation}, threadless waits are supported.
* If a filter or servlet returns after calling {@link Continuation#suspend()} or when a
* runtime exception is thrown from a call to {@link Continuation#undispatch()}, Jetty will
* will not send a response to the client. Instead the thread is released and the Continuation is
* placed on the timer queue. If the Continuation timeout expires, or it's
* resume method is called, then the request is again allocated a thread and the request is retried.
* The limitation of this approach is that request content is not available on the retried request,
* thus if possible it should be read after the continuation or saved as a request attribute or as the
* associated object of the Continuation instance.
* </p>
*
* @org.apache.xbean.XBean element="nioConnector" description="Creates an NIO based socket connector"
*/
public class SelectChannelConnector extends AbstractNIOConnector
{
protected ServerSocketChannel _acceptChannel;
private int _lowResourcesConnections;
private int _lowResourcesMaxIdleTime;
private int _localPort=-1;
private final SelectorManager _manager = new ConnectorSelectorManager();
/* ------------------------------------------------------------------------------- */
/**
* Constructor.
*
*/
public SelectChannelConnector()
{
_manager.setMaxIdleTime(getMaxIdleTime());
addBean(_manager,true);
setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4));
}
@Override
public void setThreadPool(ThreadPool pool)
{
super.setThreadPool(pool);
// preserve start order
removeBean(_manager);
addBean(_manager,true);
}
/* ------------------------------------------------------------ */
@Override
public void accept(int acceptorID) throws IOException
{
ServerSocketChannel server;
synchronized(this)
{
server = _acceptChannel;
}
if (server!=null && server.isOpen() && _manager.isStarted())
{
SocketChannel channel = server.accept();
channel.configureBlocking(false);
Socket socket = channel.socket();
configure(socket);
_manager.register(channel);
}
}
/* ------------------------------------------------------------ */
public void close() throws IOException
{
synchronized(this)
{
if (_acceptChannel != null)
{
removeBean(_acceptChannel);
if (_acceptChannel.isOpen())
_acceptChannel.close();
}
_acceptChannel = null;
_localPort=-2;
}
}
/* ------------------------------------------------------------------------------- */
@Override
public void customize(EndPoint endpoint, Request request) throws IOException
{
request.setTimeStamp(System.currentTimeMillis());
endpoint.setMaxIdleTime(_maxIdleTime);
super.customize(endpoint, request);
}
/* ------------------------------------------------------------------------------- */
@Override
public void persist(EndPoint endpoint) throws IOException
{
AsyncEndPoint aEndp = ((AsyncEndPoint)endpoint);
aEndp.setCheckForIdle(true);
super.persist(endpoint);
}
/* ------------------------------------------------------------ */
public SelectorManager getSelectorManager()
{
return _manager;
}
/* ------------------------------------------------------------ */
public synchronized Object getConnection()
{
return _acceptChannel;
}
/* ------------------------------------------------------------------------------- */
public int getLocalPort()
{
synchronized(this)
{
return _localPort;
}
}
/* ------------------------------------------------------------ */
public void open() throws IOException
{
synchronized(this)
{
if (_acceptChannel == null)
{
// Create a new server socket
_acceptChannel = ServerSocketChannel.open();
// Set to blocking mode
_acceptChannel.configureBlocking(true);
// Bind the server socket to the local host and port
_acceptChannel.socket().setReuseAddress(getReuseAddress());
InetSocketAddress addr = getHost()==null?new InetSocketAddress(getPort()):new InetSocketAddress(getHost(),getPort());
_acceptChannel.socket().bind(addr,getAcceptQueueSize());
_localPort=_acceptChannel.socket().getLocalPort();
if (_localPort<=0)
throw new IOException("Server channel not bound");
addBean(_acceptChannel);
}
}
}
/* ------------------------------------------------------------ */
@Override
public void setMaxIdleTime(int maxIdleTime)
{
_manager.setMaxIdleTime(maxIdleTime);
super.setMaxIdleTime(maxIdleTime);
}
/* ------------------------------------------------------------ */
/**
* @return the lowResourcesConnections
*/
public int getLowResourcesConnections()
{
return _lowResourcesConnections;
}
/* ------------------------------------------------------------ */
/**
* Set the number of connections, which if exceeded places this manager in low resources state.
* This is not an exact measure as the connection count is averaged over the select sets.
* @param lowResourcesConnections the number of connections
* @see #setLowResourcesMaxIdleTime(int)
*/
public void setLowResourcesConnections(int lowResourcesConnections)
{
_lowResourcesConnections=lowResourcesConnections;
}
/* ------------------------------------------------------------ */
/**
* @return the lowResourcesMaxIdleTime
*/
@Override
public int getLowResourcesMaxIdleTime()
{
return _lowResourcesMaxIdleTime;
}
/* ------------------------------------------------------------ */
/**
* Set the period in ms that a connection is allowed to be idle when this there are more
* than {@link #getLowResourcesConnections()} connections. This allows the server to rapidly close idle connections
* in order to gracefully handle high load situations.
* @param lowResourcesMaxIdleTime the period in ms that a connection is allowed to be idle when resources are low.
* @see #setMaxIdleTime(int)
*/
@Override
public void setLowResourcesMaxIdleTime(int lowResourcesMaxIdleTime)
{
_lowResourcesMaxIdleTime=lowResourcesMaxIdleTime;
super.setLowResourcesMaxIdleTime(lowResourcesMaxIdleTime);
}
/* ------------------------------------------------------------ */
/*
* @see org.eclipse.jetty.server.server.AbstractConnector#doStart()
*/
@Override
protected void doStart() throws Exception
{
_manager.setSelectSets(getAcceptors());
_manager.setMaxIdleTime(getMaxIdleTime());
_manager.setLowResourcesConnections(getLowResourcesConnections());
_manager.setLowResourcesMaxIdleTime(getLowResourcesMaxIdleTime());
super.doStart();
}
/* ------------------------------------------------------------ */
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException
{
SelectChannelEndPoint endp= new SelectChannelEndPoint(channel,selectSet,key, SelectChannelConnector.this._maxIdleTime);
endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment()));
return endp;
}
/* ------------------------------------------------------------------------------- */
protected void endPointClosed(SelectChannelEndPoint endpoint)
{
connectionClosed(endpoint.getConnection());
}
/* ------------------------------------------------------------------------------- */
protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint)
{
return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,getServer());
}
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
/* ------------------------------------------------------------ */
private final class ConnectorSelectorManager extends SelectorManager
{
@Override
public boolean dispatch(Runnable task)
{
ThreadPool pool=getThreadPool();
if (pool==null)
pool=getServer().getThreadPool();
return pool.dispatch(task);
}
@Override
protected void endPointClosed(final SelectChannelEndPoint endpoint)
{
SelectChannelConnector.this.endPointClosed(endpoint);
}
@Override
protected void endPointOpened(SelectChannelEndPoint endpoint)
{
// TODO handle max connections and low resources
connectionOpened(endpoint.getConnection());
}
@Override
protected void endPointUpgraded(ConnectedEndPoint endpoint, Connection oldConnection)
{
connectionUpgraded(oldConnection,endpoint.getConnection());
}
@Override
public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint, Object attachment)
{
return SelectChannelConnector.this.newConnection(channel,endpoint);
}
@Override
protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey sKey) throws IOException
{
return SelectChannelConnector.this.newEndPoint(channel,selectSet,sKey);
}
}
}
| [
"zyc@byshell.org"
] | zyc@byshell.org |
a0259038a00a16527a02d47425f260cd6031eea7 | d2ed265486f8e06f40ad49bbca676a3add42f62a | /lib/src/main/java/com/orange/lib/constance/IViewConst.java | ac0072c7b1f9787395318e5c8cd1c2832b798a94 | [] | no_license | orangesunshine/NdLib | 6fd5d2bc51a981aab0f7ddaedd8981644ca58817 | f968dec97443cb8a937c66189c390fd7a4fe1c57 | refs/heads/master | 2020-06-07T06:18:09.472803 | 2019-12-16T16:18:08 | 2019-12-16T16:18:08 | 192,946,556 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 98 | java | package com.orange.lib.constance;
public interface IViewConst {
int HEIGHT_STATUSBAR = 64;
}
| [
"429360705@qq.com"
] | 429360705@qq.com |
5f8b3ac7570ffd2ede6c1da9465e148d70e99208 | e472e5635e2661ba59ba43124af70e621f4086db | /Sam De Wachter/Oefeningen labo/Labo Java/blz31/Oef2/Main.java | 2a3e1a3d2f6ff09eaa82eaad68b9e94d11024344 | [] | no_license | samdewachter/Digital-broadcast | ffb093d5de5a74818b919e3644be00c3c4238f80 | 0903dcf73f921a94d5dd771d5e75a9a066dbfcb0 | refs/heads/master | 2020-04-06T03:52:15.056814 | 2016-06-20T14:15:03 | 2016-06-20T14:15:03 | 59,659,043 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 763 | java | /**
*De klasse Main is een java applicatie
*
*@author Sophie Moons
*@version 1,0
*/
import java.lang.*;
public class Main{
/**
*Dit is een main function, hier start het programma
*@param args -> hiermee kan een array meegegeven worden via command line
*/
public static void main(String args[])
{
Werknemer david = new Werknemer("David", "Davidse", 24, 2000);
Werknemer jolien = new Werknemer("Jolien", "Harman", 22, 1900);
Werknemer fred = new Werknemer("Fred", "Fredrickson", 12, 2000);
Werknemer jaap = new Werknemer("Jaap", "Jan", 14, 2000);
System.out.println("David zijn salaris is "+david.getSalaris());
david.salarisVerhogen(25);
System.out.println("Met promotie is david zijn salaris: "+david.getSalaris());
}//einde main
}//einde programma | [
"sam.dewachter@student.kdg.be"
] | sam.dewachter@student.kdg.be |
32afe4b4bd0b40b935f1dbd0003be36fcdc21e01 | 52017997a5c5372148cf8b01253e404be25204ef | /app/src/main/java/com/easy/make/tenantmaker/core/main/presenter/MainPresenter.java | dc0009e20fadc5129a03b176f08ab2e2b9612f4c | [] | no_license | AndroidKiran/TenantMaker | 26e5474b1507cf946fe5dddfeb670593948a7e9f | 29d18b7da9bc2607191a0881d68adad740993d05 | refs/heads/master | 2020-12-25T14:32:43.306889 | 2016-12-14T07:26:49 | 2016-12-14T07:26:49 | 67,667,989 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,051 | java | package com.easy.make.tenantmaker.core.main.presenter;
import com.easy.make.tenantmaker.core.Utils.PreferenceService;
import com.easy.make.tenantmaker.core.navigation.Navigator;
/**
* Created by ravi on 12/09/16.
*/
public class MainPresenter {
private final Navigator navigator;
private final PreferenceService preferenceService;
public MainPresenter(Navigator navigator, PreferenceService preferenceService){
this.navigator = navigator;
this.preferenceService = preferenceService;
}
public void startPresenting(){
manageFirstFlow();
}
public void stopPresenting(){
}
private void manageFirstFlow(){
String userData = preferenceService.getLoginUserPreference();
boolean flatOnBoarding = preferenceService.getFirstFlowValue();
if (userData == null || userData.trim().length() == 0 ){
navigator.toLogin();
} else if (!flatOnBoarding){
navigator.toNewFlat();
} else {
navigator.toHome();
}
}
}
| [
"ravikiran.surpur@gmail.com"
] | ravikiran.surpur@gmail.com |
ebdedb1972cd1a6faf81ffa9e48061f994b381c2 | 535a78bab52a95d62a2d14df236a06c498ea660d | /kmeansga/src/org/jgap/Genotype.java | ef5fe386956f3ee3ca90a0665ade5cde9773fe38 | [] | no_license | squarlhan/jluccst | 1cc5624976325da12163f68f05c74127c0ae7f4f | 298c532108df0633fb5acb5d2302e7cc1992a67c | refs/heads/master | 2021-01-23T21:28:07.918280 | 2013-12-02T00:10:32 | 2013-12-02T00:10:32 | 34,333,265 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 25,000 | java | /*
* This file is part of JGAP.
*
* JGAP offers a dual license model containing the LGPL as well as the MPL.
*
* For licensing information please see the file license.txt included with JGAP
* or have a look at the top of class org.jgap.Chromosome which representatively
* includes the JGAP license policy applicable for any file delivered with JGAP.
*/
package org.jgap;
import java.io.*;
import java.util.*;
import org.jgap.audit.*;
import org.jgap.distr.*;
import org.jgap.impl.job.*;
import experiments.kmeansga.KMeansGA;
/**
* Genotypes are fixed-length populations of chromosomes. As an instance of
* a Genotype is evolved, all of its Chromosomes are also evolved. A Genotype
* may be constructed normally via constructor, or the static
* randomInitialGenotype() method can be used to generate a Genotype with a
* randomized Chromosome population.
* <p>
* Please note that among all created Genotype instances there may only be one
* configuration, used by all Genotype instances.
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
*/
public class Genotype
implements Serializable, Runnable {
/** String containing the CVS revision. Read out via reflection!*/
private final static String CVS_REVISION = "$Revision: 1.107 $";
/**
* The current Configuration instance.
* @since 1.0
*/
private Configuration m_activeConfiguration;
private transient static Configuration m_staticConfiguration;
/**
* The array of Chromosomes that make-up the Genotype's population.
* @since 2.0
*/
private Population m_population;
/**
* Constructs a new Genotype instance with the given array of Chromosomes and
* the given active Configuration instance. Note that the Configuration object
* must be in a valid state when this method is invoked, or a
* InvalidConfigurationException will be thrown.
*
* @param a_configuration the Configuration object to use
* @param a_initialChromosomes the Chromosome population to be managed by
* this Genotype instance
* @throws InvalidConfigurationException if the given Configuration object is
* in an invalid state
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
* @deprecated use Genotype(Configuration, Population) instead
*/
public Genotype(Configuration a_configuration,
IChromosome[] a_initialChromosomes)
throws InvalidConfigurationException {
this(a_configuration, new Population(a_configuration, a_initialChromosomes));
}
/**
* Constructs a new Genotype instance with the given array of
* Chromosomes and the given active Configuration instance. Note
* that the Configuration object must be in a valid state
* when this method is invoked, or a InvalidconfigurationException
* will be thrown.
*
* @param a_configuration the Configuration object to use
* @param a_population the Chromosome population to be managed by this
* Genotype instance
* @throws InvalidConfigurationException
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 2.0
*/
public Genotype(Configuration a_configuration, Population a_population)
throws InvalidConfigurationException {
// Sanity checks: Make sure neither the Configuration, nor the array
// of Chromosomes, nor any of the Genes inside the array is null.
// -----------------------------------------------------------------
if (a_configuration == null) {
throw new IllegalArgumentException(
"The Configuration instance must not be null.");
}
if (a_population == null) {
throw new IllegalArgumentException(
"The Population must not be null.");
}
for (int i = 0; i < a_population.size(); i++) {
if (a_population.getChromosome(i) == null) {
throw new IllegalArgumentException(
"The Chromosome instance at index " + i + " of the array of " +
"Chromosomes is null. No Chromosomes instance in this array " +
"must not be null.");
}
}
m_population = a_population;
// Lock the settings of the configuration object so that it cannot
// be altered.
// ---------------------------------------------------------------
a_configuration.lockSettings();
m_activeConfiguration = a_configuration;
}
/**
* Don't use this constructor, it's only for internal use.
*
* @param a_configuration not used here!
* @throws InvalidConfigurationException
*
* @author Klaus Meffert
* @since 3.0
*/
public Genotype(Configuration a_configuration)
throws InvalidConfigurationException {
}
/**
* Retrieves the array of Chromosomes that make up the population of this
* Genotype instance.
*
* @return the Population of Chromosomes
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
* @deprecated uses getPopulation() instead
*/
public synchronized IChromosome[] getChromosomes() {
Iterator it = getPopulation().iterator();
IChromosome[] result = new Chromosome[getPopulation().size()];
int i = 0;
while (it.hasNext()) {
result[i++] = (IChromosome) it.next();
}
return result;
}
/**
* @return the current population of chromosomes
*
* @author Klaus Meffert
* @since 2.1
*/
public Population getPopulation() {
return m_population;
}
/**
* Retrieves the Chromosome in the Population with the highest fitness
* value.
*
* @return the Chromosome with the highest fitness value, or null if there
* are no chromosomes in this Genotype
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
*/
public synchronized IChromosome getFittestChromosome() {
return getPopulation().determineFittestChromosome();
}
/**
* Retrieves the Chromosome in the Population with the highest fitness
* value within the given indices.
*
* @param a_startIndex the index to start the determination with
* @param a_endIndex the index to end the determination with
* @return the Chromosome with the highest fitness value within the given
* indices, or null if there are no chromosomes in this Genotype
*
* @author Klaus Meffert
* @since 3.0
*/
public synchronized IChromosome getFittestChromosome(int a_startIndex,
int a_endIndex) {
return getPopulation().determineFittestChromosome(a_startIndex, a_endIndex);
}
/**
* Retrieves the top n Chromsomes in the population (the ones with the best
* fitness values).
*
* @param a_numberOfChromosomes the number of chromosomes desired
* @return the list of Chromosomes with the highest fitness values, or null
* if there are no chromosomes in this Genotype
*
* @author Charles Kevin Hill
* @since 2.4
*/
public synchronized List getFittestChromosomes(int a_numberOfChromosomes) {
return getPopulation().determineFittestChromosomes(a_numberOfChromosomes);
}
/**
* Evolves the population of Chromosomes within this Genotype. This will
* execute all of the genetic operators added to the present active
* configuration and then invoke the natural selector to choose which
* chromosomes will be included in the next generation population. Note
* that the population size not always remains constant (dependent on the
* NaturalSelectors used!).
* To consecutively call this method, use evolve(int)!!!
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
*/
public synchronized void evolve() {
IBreeder breeder = getConfiguration().getBreeder();
Population newPop = breeder.evolve(getPopulation(), getConfiguration());
setPopulation(newPop);
}
public synchronized void evolve(KMeansGA obj, FitnessFunction fitness, int kmeans_max, double kmeans_num, double fit_lamda, double cutoff, double extra,BufferedWriter output) {
IBreeder breeder = getConfiguration().getBreeder();
Population newPop = breeder.evolve(getPopulation(), getConfiguration(), obj, fitness, kmeans_max, kmeans_num, fit_lamda, cutoff, extra,output);
setPopulation(newPop);
}
/**
* Evolves this Genotype the specified number of times. This is
* equivalent to invoking the standard evolve() method the given number
* of times in a row.
*
* @param a_numberOfEvolutions the number of times to evolve this Genotype
* before returning
*
* @author Klaus Meffert
* @since 1.1
*/
public void evolve(int a_numberOfEvolutions) {
for (int i = 0; i < a_numberOfEvolutions; i++) {
evolve();
}
if (m_activeConfiguration.isKeepPopulationSizeConstant()) {
keepPopSizeConstant(getPopulation(),
m_activeConfiguration.getPopulationSize());
}
}
/**
* Evolves this genotype until the given monitor asks to quit the evolution
* cycle.
*
* @param a_monitor the monitor used to decide when to stop evolution
*
* @return messages of the registered evolution monitor. May indicate why the
* evolution was asked to be stopped. May be empty, depending on the
* implementation of the used monitor
*
* @author Klaus Meffert
* @since 3.4.4
*/
public List<String> evolve(IEvolutionMonitor a_monitor) {
a_monitor.start(getConfiguration());
getConfiguration().setMonitor(a_monitor);
List<String> messages = new Vector();
do {
evolve();
boolean goon = a_monitor.nextCycle(getPopulation(), messages);
if (!goon) {
break;
}
} while (true);
return messages;
}
/**
* @return string representation of this Genotype instance, useful for display
* or debug purposes
*
* @author Neil Rotstan
* @since 1.0
*/
public String toString() {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < getPopulation().size(); i++) {
buffer.append(getPopulation().getChromosome(i).toString());
buffer.append(" [");
buffer.append(getPopulation().getChromosome(i).getFitnessValueDirectly());
buffer.append("]\n");
}
return buffer.toString();
}
/**
* Convenience method that returns a newly constructed Genotype
* instance configured according to the given Configuration instance.
* The population of Chromosomes will be created according to the setup of
* the sample Chromosome in the Configuration object, but the gene values
* (alleles) will be set to random legal values.
*
* @param a_configuration the current active Configuration object
* @return a newly constructed Genotype instance
*
* @throws IllegalArgumentException if the given Configuration object is null
* @throws InvalidConfigurationException if the given Configuration
* instance is not in a valid state
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 2.3
*/
public static Genotype randomInitialGenotype(Configuration
a_configuration)
throws InvalidConfigurationException {
if (a_configuration == null) {
throw new IllegalArgumentException(
"The Configuration instance may not be null.");
}
a_configuration.lockSettings();
// Create an array of chromosomes equal to the desired size in the
// active Configuration and then populate that array with Chromosome
// instances constructed according to the setup in the sample
// Chromosome, but with random gene values (alleles). The Chromosome
// class randomInitialChromosome() method will take care of that for
// us.
// ------------------------------------------------------------------
int populationSize = a_configuration.getPopulationSize();
Population pop = new Population(a_configuration, populationSize);
// Do randomized initialization.
// -----------------------------
Genotype result = new Genotype(a_configuration, pop);
result.fillPopulation(populationSize);
return result;
}
/**
* Fills up the population with random chromosomes if necessary.
*
* @param a_num the number of chromosomes to add
* @throws InvalidConfigurationException
*
* @author Klaus Meffert
* @since 3.2
*/
public void fillPopulation(final int a_num)
throws InvalidConfigurationException {
IChromosome sampleChrom = getConfiguration().getSampleChromosome();
Class sampleClass = sampleChrom.getClass();
IInitializer chromIniter = getConfiguration().getJGAPFactory().
getInitializerFor(sampleChrom, sampleClass);
if (chromIniter == null) {
throw new InvalidConfigurationException("No initializer found for class "
+ sampleClass);
}
try {
for (int i = 0; i < a_num; i++) {
getPopulation().addChromosome( (IChromosome) chromIniter.perform(
sampleChrom,
sampleClass, null));
}
} catch (Exception ex) {
// Try to propagate exception, see "bug" 1661635.
// ----------------------------------------------
if (ex.getCause() != null) {
throw new IllegalStateException(ex.getCause().toString());
}
else {
throw new IllegalStateException(ex.getMessage());
}
}
}
/**
* Compares this Genotype against the specified object. The result is true
* if the argument is an instance of the Genotype class, has exactly the
* same number of chromosomes as the given Genotype, and, for each
* Chromosome in this Genotype, there is an equal chromosome in the
* given Genotype. The chromosomes do not need to appear in the same order
* within the population.
*
* @param a_other the object to compare against
* @return true if the objects are the same, false otherwise
*
* @author Neil Rotstan
* @author Klaus Meffert
* @since 1.0
*/
public boolean equals(Object a_other) {
try {
// First, if the other Genotype is null, then they're not equal.
// -------------------------------------------------------------
if (a_other == null) {
return false;
}
Genotype otherGenotype = (Genotype) a_other;
// First, make sure the other Genotype has the same number of
// chromosomes as this one.
// ----------------------------------------------------------
if (getPopulation().size() != otherGenotype.getPopulation().size()) {
return false;
}
// Next, prepare to compare the chromosomes of the other Genotype
// against the chromosomes of this Genotype. To make this a lot
// simpler, we first sort the chromosomes in both this Genotype
// and the one we're comparing against. This won't affect the
// genetic algorithm (it doesn't care about the order), but makes
// it much easier to perform the comparison here.
// --------------------------------------------------------------
Collections.sort(getPopulation().getChromosomes());
Collections.sort(otherGenotype.getPopulation().getChromosomes());
for (int i = 0; i < getPopulation().size(); i++) {
if (! (getPopulation().getChromosome(i).equals(
otherGenotype.getPopulation().getChromosome(i)))) {
return false;
}
}
return true;
} catch (ClassCastException e) {
return false;
}
}
/**
* Applies all NaturalSelectors registered with the Configuration.
*
* @param a_processBeforeGeneticOperators true apply NaturalSelectors
* applicable before GeneticOperators, false: apply the ones applicable
* after GeneticOperators
*
* @author Klaus Meffert
* @since 2.0
*/
protected void applyNaturalSelectors(
boolean a_processBeforeGeneticOperators) {
/**@todo optionally use working pool*/
try {
// Process all natural selectors applicable before executing the
// genetic operators (reproduction, crossing over, mutation...).
// -------------------------------------------------------------
int selectorSize = m_activeConfiguration.getNaturalSelectorsSize(
a_processBeforeGeneticOperators);
if (selectorSize > 0) {
int population_size = m_activeConfiguration.getPopulationSize();
if (a_processBeforeGeneticOperators) {
// Only select part of the previous population into this generation.
// -----------------------------------------------------------------
population_size = (int) Math.round(population_size *
getConfiguration().getSelectFromPrevGen());
}
int single_selection_size;
Population new_population;
new_population = new Population(m_activeConfiguration,
population_size);
NaturalSelector selector;
// Repopulate the population of chromosomes with those selected
// by the natural selector. Iterate over all natural selectors.
// ------------------------------------------------------------
for (int i = 0; i < selectorSize; i++) {
selector = m_activeConfiguration.getNaturalSelector(
a_processBeforeGeneticOperators, i);
if (i == selectorSize - 1 && i > 0) {
// Ensure the last NaturalSelector adds the remaining Chromosomes.
// ---------------------------------------------------------------
single_selection_size = population_size - getPopulation().size();
}
else {
single_selection_size = population_size / selectorSize;
}
// Do selection of Chromosomes.
// ----------------------------
selector.select(single_selection_size, getPopulation(),
new_population);
// Clean up the natural selector.
// ------------------------------
selector.empty();
}
setPopulation(new Population(m_activeConfiguration));
getPopulation().addChromosomes(new_population);
}
} catch (InvalidConfigurationException iex) {
// This exception should never be reached
throw new IllegalStateException(iex.getMessage());
}
}
/**
* Applies all GeneticOperators registered with the Configuration.
*
* @author Klaus Meffert
* @since 3.0
*/
public void applyGeneticOperators() {
List geneticOperators = m_activeConfiguration.getGeneticOperators();
Iterator operatorIterator = geneticOperators.iterator();
while (operatorIterator.hasNext()) {
GeneticOperator operator = (GeneticOperator) operatorIterator.next();
applyGeneticOperator(operator, getPopulation(),
getPopulation().getChromosomes());
// List workingPool = new Vector();
// applyGeneticOperator(operator, getPopulation(),
// workingPool);
}
}
/**
* @return the configuration to use with the Genetic Algorithm
*
* @author Klaus Meffert
* @since 2.0
*/
public static Configuration getStaticConfiguration() {
return m_staticConfiguration;
}
/**
* Sets the configuration to use with the Genetic Algorithm.
* @param a_configuration the configuration to use
*
* @author Klaus Meffert
* @since 2.0
*/
public static void setStaticConfiguration(Configuration a_configuration) {
m_staticConfiguration = a_configuration;
}
public Configuration getConfiguration() {
return m_activeConfiguration;
}
/***
* Hashcode function for the genotype, tries to create a unique hashcode for
* the chromosomes within the population. The logic for the hashcode is
*
* Step Result
* ---- ------
* 1 31*0 + hashcode_0 = y(1)
* 2 31*y(1) + hashcode_1 = y(2)
* 3 31*y(2) + hashcode_2 = y(3)
* n 31*y(n-1) + hashcode_n-1 = y(n)
*
* @return the computed hashcode
*
* @author vamsi
* @since 2.1
*/
public int hashCode() {
int i, size = getPopulation().size();
IChromosome s;
int twopower = 1;
// For empty genotype we want a special value different from other hashcode
// implementations.
// ------------------------------------------------------------------------
int localHashCode = -573;
for (i = 0; i < size; i++, twopower = 2 * twopower) {
s = getPopulation().getChromosome(i);
localHashCode = 31 * localHashCode + s.hashCode();
}
return localHashCode;
}
protected void setPopulation(Population a_pop) {
m_population = a_pop;
}
/**
* Overwritable method that calls a GeneticOperator to operate on a given
* population and asks him to store the result in the list of chromosomes.
* Override this method if you want to ensure that a_chromosomes is not
* part of a_population resp. if you want to use a different list.
*
* @param a_operator the GeneticOperator to call
* @param a_population the population to use
* @param a_chromosomes the list of Chromosome objects to return
*
* @author Klaus Meffert
* @since 2.4
*/
protected void applyGeneticOperator(GeneticOperator a_operator,
Population a_population,
List a_chromosomes) {
a_operator.operate(a_population, a_chromosomes);
}
/**
* Cares that the population size does not exceed the given maximum size.
*
* @param a_pop the population to keep constant in size
* @param a_maxSize the maximum size allowed for the population
*
* @author Klaus Meffert
* @since 2.5
*/
protected void keepPopSizeConstant(Population a_pop, int a_maxSize) {
/**@todo use StandardPostSelector instead?*/
int popSize = a_pop.size();
// See request 1213752.
// ---------------------
while (popSize > a_maxSize) {
// Remove a chromosome.
// --------------------
a_pop.removeChromosome(0);
popSize--;
}
}
/**
* If used in a Thread: runs the evolution forever.
* You have to implement a listener to stop computation sometime. See
* examples.simpleBooleanThreaded for a possible implementation of such a
* listener.
*
* @author Klaus Meffert
* @since 3.01
*/
public void run() {
while (!Thread.currentThread().interrupted()) {
evolve();
}
}
/**
* Splits a population into pieces that can be evolved independently.
*
* @param a_splitter splits the population
* @return list of IEvolveJob objects
* @throws Exception
*
* @author Klaus Meffert
*/
public List<IEvolveJob> getEvolves(IPopulationSplitter a_splitter)
throws Exception {
// We return a list of IEvolveJob instances.
// -----------------------------------------
List result = new Vector();
Population[] pops = a_splitter.split(getPopulation());
// Feed the population chunks into different evolve jobs.
// ------------------------------------------------------
for (int i = 0; i < pops.length; i++) {
Configuration newConf = (Configuration) getConfiguration().clone();
EvolveData data = new EvolveData(newConf);
if (pops[i] == null) {
throw new IllegalStateException("Population must no be null"
+ " (Index: " + i
+ ", Splitter: "
+ a_splitter.getClass().getName() + ")");
}
data.setPopulation(pops[i]);
data.setBreeder(newConf.getBreeder());
IEvolveJob evolver = new EvolveJob(data);
result.add(evolver);
}
getPopulation().clear();
return result;
}
public void mergeResults(IPopulationMerger a_merger, EvolveResult[] a_results)
throws Exception {
int size = a_results.length;
Population target = new Population(getConfiguration());
for (int i = 0; i < size; i++) {
EvolveResult singleResult = a_results[i];
if (singleResult == null) {
throw new IllegalStateException("Single result is null!");
}
Population pop = singleResult.getPopulation();
/**@todo use/enhance IPopulationMerger*/
// a_merger.mergePopulations()
List goodOnes = pop.determineFittestChromosomes(3);
for (int j = 0; j < goodOnes.size(); j++) {
IChromosome goodOne = (IChromosome) goodOnes.get(j);
target.addChromosome(goodOne);
}
}
setPopulation(target);
}
}
| [
"squarlhan@264059c0-66d9-11de-8235-5b595ee06194"
] | squarlhan@264059c0-66d9-11de-8235-5b595ee06194 |
b71a1630132e5c8aa6a4e25d2368480a07ddbcf6 | 334648257ed6aa34c39e08e5c7f2361ff962ab5d | /src/main/java/com/safziy/commom/utils/JSONUtils.java | 7a863bfc46d596c51fbaac7e8cf40db8eed66de3 | [] | no_license | safziy/safziy-commom-old | dcc95013c72fa694cef43ac809335ca32b9f4192 | 8f752f58f532a2014d19c85d1cc89f48cc7f5b50 | refs/heads/master | 2021-01-24T20:42:21.301116 | 2016-03-21T05:51:44 | 2016-03-21T05:51:44 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,596 | java | package com.safziy.commom.utils;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.safziy.commom.service.log.LogUtil;
public class JSONUtils {
/**
* list to JSasONString
*
* @param list
* @return
*/
public static String collection2String(Collection<?> collection) {
JSONArray jSArray = new JSONArray(collection);
return jSArray.toString();
}
public static String list2String(List<?> list) {
JSONArray jSArray = new JSONArray(list);
return jSArray.toString();
}
/**
* object to JSONString
*
* @param object
* @return
*/
public static String object2tring(Object object) {
JSONObject jSObject = new JSONObject(object);
return jSObject.toString();
}
/**
* map to JSONString
*
* @param map
* @return
*/
public static <K, V> String map2String(Map<K, V> map) {
JSONObject jSObject = new JSONObject(map);
return jSObject.toString();
}
public static String mapToString(Map<Integer, Integer> map) {
JSONObject jSObject = new JSONObject(map);
return jSObject.toString();
}
public static String maptoString(Map<Byte, Integer> map) {
JSONObject jSObject = new JSONObject(map);
return jSObject.toString();
}
public static String multimap2String(Multimap<Object, Object> map) {
JSONObject jSObject = new JSONObject(map);
return jSObject.toString();
}
@SuppressWarnings("unchecked")
public static Map<Integer, Multiset<Integer>> string2MultiSet(String value) {
value = value.trim();
Map<Integer, Multiset<Integer>> map = new HashMap<Integer, Multiset<Integer>>();
if (ValidateUtils.isFalse(ValidateUtils.isNotNullAndMoreThanZero(value))) {
return map;
}
try {
JSONObject jSObject = new JSONObject(value);
Iterator<String> params = jSObject.keys();
while (params.hasNext()) {
String param = params.next();
if (ValidateUtils.isFalse(map.containsKey(Integer.parseInt(param)))) {
Multiset<Integer> set = HashMultiset.create();
map.put(Integer.valueOf(param), set);
}
JSONObject tempJsObject = new JSONObject(jSObject.get(param).toString());
Iterator<String> keys = tempJsObject.keys();
while (keys.hasNext()) {
String key = keys.next();
int tempValue = tempJsObject.getInt(key);
map.get(Integer.valueOf(param)).add(Integer.parseInt(key), tempValue);
}
}
} catch (JSONException e) {
LogUtil.error(e);
}
return map;
}
@SuppressWarnings("unchecked")
public static List<Map<String, String>> string2ListMap(String value) {
List<Map<String, String>> list = new LinkedList<Map<String, String>>();
if(ValidateUtils.isNull(value)){
return list;
}
value = value.trim();
if (ValidateUtils.isFalse(ValidateUtils.isNotNullAndMoreThanZero(value))) {
return list;
}
try {
JSONArray jSArray = new JSONArray(value);
for (int i = 0; i < jSArray.length(); i++) {
Map<String, String> map = new HashMap<String, String>();
JSONObject jSObject = jSArray.getJSONObject(i);
for (Iterator<String> it = jSObject.keys(); it.hasNext();) {
String key = it.next();
map.put(key, jSObject.get(key).toString());
}
if (map.containsKey("beginTime")) {
map.put("beginTimeStr", DateUtils.commomFormatDate(Integer.parseInt(map.get("beginTime"))));
}
if (map.containsKey("endTime")) {
map.put("endTimeStr", DateUtils.commomFormatDate(Integer.parseInt(map.get("endTime"))));
}
if (map.containsKey("addTime")) {
map.put("addTimeStr", DateUtils.commomFormatDate(Integer.parseInt(map.get("addTime"))));
}
list.add(map);
}
} catch (JSONException e) {
e.printStackTrace();
}
return list;
}
@SuppressWarnings("unchecked")
public static Map<String, String> string2Map(String value) {
Map<String, String> map = new HashMap<String, String>();
if (ValidateUtils.isNotNullAndMoreThanZero(value)) {
try {
JSONObject jsb = new JSONObject(value);
for (Iterator<String> it = jsb.keys(); it.hasNext();) {
String key = it.next();
map.put(key, jsb.get(key).toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
}
return map;
}
}
| [
"787395455@qq.com"
] | 787395455@qq.com |
bdb5360e1a50ad06baa70d9c42f5303045c62127 | aeeb9ec9b6b4e1d72c0d8e16b2dcad528881f337 | /src/vuePopUpInterrogerJoueur/DemanderUtiliserCarteSansThread.java | c3a8ebb34c7f1a2be940871d6387a8d1c10f9fae | [] | no_license | z00000010a/LO02_projet-JAVA- | 754afae89b12521f0badceaa3d6218ac35b699e0 | d360207be56f8dd6190f13bfd93d317384e810cd | refs/heads/master | 2021-08-26T08:36:22.434033 | 2017-11-22T15:27:07 | 2017-11-22T15:27:07 | 111,317,627 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,599 | java | package vuePopUpInterrogerJoueur;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.LinkedList;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import Test.Test;
import modelCarte.CarteAction;
import modelJoueur.Joueur;
import vueAction.ActionFermeFenetre;
import vueBouton.BoutonNumJoueur;
/**
* Cette classe permet d'interroger le joueur pendant qu'il joue sa phase. Ses m閠hodes ne sont pas synchronis閑s car
* elle doivent 阾re appel� pendant la phase du joueur humain, un moment ou le d閞oulement de la partie est fig�,
* en attente de la fin du tour du joueur humain.
* Cette classe est instanci� par toutes les carte Croyant et GuideSpirituel quand elles sont sacrifier et les carte DeusEx quand
* elles sont utilis閑s.
*
*/
public class DemanderUtiliserCarteSansThread
{
/**
* Le choix du joueur, modifi� par les BoutonNumJoueur. Et r閏up閞� gr鈉e aux getters par les cartes qui instancie cette classe pour
* r閏up閞er le choix du joueur.
*/
private static int choixJoueur;
/**
* La linkedList des joueurs, permet de cr閑r autant de BoutonJoueur qu'il y a de joueur � cibler pour la
* capacit� de la carte qui � instanci閑 la classe. Sp閏ifi� par le constructeur.
*/
private LinkedList<Joueur> listeJ;
/**
* La carte qui � instanci� la classe. Utilis� par la m閠hode demander(). Sp閏ifi閑 par le constructeur.
*/
private static CarteAction carte;
/**
* Le constructeur de la classe.
* @param listeJoueur La LinkedList de joueur que l'on souhaite proposer au joueur pour qu'il d閟igne l'un d'entre eux
* @param carte2 La CarteAction qui � instanci� l'objet. Elle sera utilis閑 par la m閠hode appelerSacrifice() de
* cette classe.
* @see vuePopUpInterrogerJoueur.DemanderUtiliserCarteSansThread#appelerSacrifice()
*/
public DemanderUtiliserCarteSansThread(LinkedList <Joueur> listeJoueur, CarteAction carte2)
{
this.listeJ=listeJoueur;
carte=carte2;
}
/**
* Cette m閠hode va cr閑r autant de bouton qu'il y a de joueur dans l'attribut listeJ de cette classe et va ajouter
* un bouton Valider pour que le joueur valide son choix. La validation entrainera l'appel de la m閠hode AppelerSacrifice().
* Elle renvoie un pop up d'erreur si listeJ est vide.
*/
public void demander()
{
if (listeJ.size()!=0)
{
DemanderUtiliserCarteSansThread.choixJoueur=-1;
JFrame frame = new JFrame("Choisissez le joueur que vous déirer ciblez :");
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frame.setLocation(dim.width/2, dim.height/2 + 100);
frame.setLayout(new FlowLayout());
Iterator <Joueur> iteBouton = listeJ.iterator();
while (iteBouton.hasNext())
{
Joueur j = iteBouton.next();
frame.getContentPane().add(new BoutonNumJoueur(j.getNumJoueur()));
}
JButton valider = new JButton("Valider votre choix");
valider.addActionListener( new ActionListener(){public void actionPerformed(ActionEvent e) {DemanderUtiliserCarteSansThread.appelerSacrifice();}} );
valider.addActionListener(new ActionFermeFenetre(frame));
frame.getContentPane().add(valider);
frame.pack();
this.listeJ=null;
frame.setDefaultCloseOperation(0);
frame.setVisible(true);
}
else
{
JFrame frameErreur = new JFrame();
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
frameErreur.setLocation(dim.width/2-frameErreur.getSize().width/2, dim.height/2-frameErreur.getSize().height/2);
JOptionPane.showMessageDialog(frameErreur ,
"Vous ne pouvez pas effectuer ceci"
+"\n ",
"Non.",
JOptionPane.WARNING_MESSAGE);
}
}
/**
* Cette m閠hode va appeler la m閠hode sacrifier(int i) de la carte (Note : cette m閠hode est redefini pour chaque carte). Avec en argument le num閞o du joueur que le joueur
* humain souhaite cibler avec cette carte.
* @see modelCarte.CarteAction#sacrifier(int)
*/
public static void appelerSacrifice()
{
carte.sacrifier(DemanderUtiliserCarteSansThread.getChoixJoueur());
}
public static int getChoixJoueur() {
return choixJoueur;
}
public static void setChoixJoueur(int choixJoueur) {
DemanderUtiliserCarteSansThread.choixJoueur = choixJoueur;
}
public LinkedList<Joueur> getListeJ() {
return listeJ;
}
public void setListeJ(LinkedList<Joueur> listeJ) {
this.listeJ = listeJ;
}
}
| [
"zhaozhe.zhang@utt.fr"
] | zhaozhe.zhang@utt.fr |
a7edf2be6356e8786a57e2701c19f451854117fe | f02bd3bd236a9f694289f14a0425d8eef1931347 | /plugin/src/main/java/gwtquery/plugins/ui/interactions/Selectable.java | 90d0a0b539e4f23a32c89f13f0dca4c89b27eafd | [] | no_license | vortekc/gwtquery-ui | f6c2fc303447b35e6ab819d60c5b1bf853da28a7 | d47e6691b31c63425a7f889f03665672e529f6ea | refs/heads/master | 2021-01-18T01:03:28.180334 | 2016-09-06T08:02:22 | 2016-09-06T08:02:22 | 67,411,653 | 0 | 0 | null | 2016-09-05T10:30:13 | 2016-09-05T10:30:13 | null | UTF-8 | Java | false | false | 6,085 | java | package gwtquery.plugins.ui.interactions;
import gwtquery.plugins.ui.Ui;
import gwtquery.plugins.ui.UiPlugin;
import gwtquery.plugins.ui.UiWidget;
import gwtquery.plugins.ui.WidgetOptions;
import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NodeList;
import com.google.gwt.query.client.GQuery;
/**
* Implements jQuery-UI's Selectable
*
* @see <a href="http://docs.jquery.com/UI/Selectable">jQuery-UI's Selectable</a>
*
* @author Philippe Laflamme
*/
public class Selectable extends UiWidget<Selectable, Selectable.Options> {
public static class Options extends WidgetOptions<Options> {
protected Options() {
}
public static native final Options create() /*-{
return {};
}-*/;
public native final Options autoRefresh(boolean autoRefresh) /*-{
this["autoRefresh"] = autoRefresh;
return this;
}-*/;
public native final boolean autoRefresh() /*-{
return this["autoRefresh"];
}-*/;
public native final Options cancel(String selector) /*-{
this["cancel"] = selector;
return this;
}-*/;
public native final Options cancel(NodeList<?> selector) /*-{
this["cancel"] = selector;
return this;
}-*/;
public final Options cancel(GQuery selector) {
this.cancel(selector.get());
return this;
}
public native final String cancel() /*-{
return this["cancel"];
}-*/;
public native final Options delay(int delay) /*-{
this["delay"] = delay;
return this;
}-*/;
public native final int delay() /*-{
return this["delay"];
}-*/;
public native final Options distance(int distance) /*-{
this["distance"] = distance;
return this;
}-*/;
public native final int distance() /*-{
return this["distance"];
}-*/;
public native final Options filter(String filter) /*-{
this["filter"] = filter;
return this;
}-*/;
public native final Options filter(NodeList<?> selector) /*-{
this["filter"] = selector;
return this;
}-*/;
public final Options filter(GQuery selector) {
this.filter(selector.get());
return this;
}
public native final String filter() /*-{
return this["filter"];
}-*/;
public native final Options tolerance(String tolerance) /*-{
this["tolerance"] = tolerance;
return this;
}-*/;
public native final String tolerance() /*-{
return this["tolerance"];
}-*/;
}
public static class Event extends JavaScriptObject {
public static final String selected = "selectableselected";
public static final String selecting = "selectableselecting";
public static final String start = "selectablestart";
public static final String stop = "selectablestop";
public static final String unselected = "selectableunselected";
public static final String unselecting = "selectableunselecting";
protected Event() {
}
public native final Element selected() /*-{
return this["selected"];
}-*/;
public native final Element selecting() /*-{
return this["selecting"];
}-*/;
public native final Element unselected() /*-{
return this["unselected"];
}-*/;
public native final Element unselecting() /*-{
return this["unselecting"];
}-*/;
}
/**
* Used to register the plugin.
*/
private static class SelectablePlugin implements UiPlugin<Selectable> {
public Selectable init(Ui ui, WidgetOptions<?> options) {
return new Selectable(ui, (Selectable.Options) options.cast());
}
}
public static final Class<Selectable> Selectable = Selectable.class;
static {
registerPlugin(Selectable.class, new SelectablePlugin());
}
public Selectable(Ui ui, Selectable.Options options) {
super(ui, "selectable", options);
}
public Selectable refresh() {
invoke("refresh");
return this;
}
}
| [
"philippe.laflamme@gmail.com"
] | philippe.laflamme@gmail.com |
dc38b83a9b3652216805e958178e3648f49f20a1 | 6bdd970a53a20b882fff055fbade2a532f5e43e0 | /system-event-service-local/src/main/java/com/telecominfraproject/wlan/systemevent/SystemEventServiceLocal.java | 5655f2c7bf401ab634e91884b6ad780a6f95d3e4 | [] | no_license | eugenetaranov-opsfleet/wlan-cloud-services | 826a333d0aa517f2f23e605638ec6df12d91a4b4 | 3410672fd978374ee74902ee6396955054b6728a | refs/heads/master | 2022-11-16T00:44:40.672726 | 2020-07-01T12:11:45 | 2020-07-01T12:11:45 | 276,321,568 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,331 | java | package com.telecominfraproject.wlan.systemevent;
import java.util.List;
import java.util.Set;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.telecominfraproject.wlan.core.model.json.GenericResponse;
import com.telecominfraproject.wlan.core.model.pagination.ColumnAndSort;
import com.telecominfraproject.wlan.core.model.pagination.PaginationContext;
import com.telecominfraproject.wlan.core.model.pagination.PaginationResponse;
import com.telecominfraproject.wlan.systemevent.controller.SystemEventController;
import com.telecominfraproject.wlan.systemevent.models.SystemEventRecord;
/**
* @author dtoptygin
*
*/
@Component
public class SystemEventServiceLocal implements SystemEventServiceInterface {
@Autowired private SystemEventController systemEventController;
private static final Logger LOG = LoggerFactory.getLogger(SystemEventServiceLocal.class);
@Override
public GenericResponse create(SystemEventRecord systemEventRecord) {
LOG.debug("calling systemEventController.create {} ", systemEventRecord);
return systemEventController.create(systemEventRecord);
}
@Override
public GenericResponse create(List<SystemEventRecord> systemEventRecords) {
LOG.debug("calling systemEventController.create bulk {} ", systemEventRecords.size());
return systemEventController.createBulk(systemEventRecords);
}
@Override
public GenericResponse delete(int customerId, long equipmentId, long createdBeforeTimestamp) {
LOG.debug("calling systemEventController.delete {} {} {}", customerId, equipmentId, createdBeforeTimestamp);
return systemEventController.delete(customerId, equipmentId, createdBeforeTimestamp);
}
@Override
public PaginationResponse<SystemEventRecord> getForCustomer(long fromTime, long toTime, int customerId,
Set<Long> equipmentIds, Set<String> dataTypes, List<ColumnAndSort> sortBy,
PaginationContext<SystemEventRecord> context) {
LOG.debug("calling serviceMetricController.getForCustomer {} {} {} ", fromTime, toTime, customerId);
return systemEventController.getForCustomer(fromTime, toTime, customerId,
equipmentIds, dataTypes, sortBy, context);
}
}
| [
"dmitry.toptygin@connectus.ai"
] | dmitry.toptygin@connectus.ai |
f083c61a7d9db4dbc45a55cd9d3677e3d458630d | 75950d61f2e7517f3fe4c32f0109b203d41466bf | /modules/tags/fabric3-modules-parent-pom-0.7/kernel/impl/fabric3-transform/src/main/java/org/fabric3/transform/dom2java/String2Double.java | 7864c11fd269e5da583c29af56e65da132bb4cb2 | [] | no_license | codehaus/fabric3 | 3677d558dca066fb58845db5b0ad73d951acf880 | 491ff9ddaff6cb47cbb4452e4ddbf715314cd340 | refs/heads/master | 2023-07-20T00:34:33.992727 | 2012-10-31T16:32:19 | 2012-10-31T16:32:19 | 36,338,853 | 0 | 0 | null | null | null | null | MacCentralEurope | Java | false | false | 1,702 | java | /*
* Fabric3
* Copyright © 2008 Metaform Systems Limited
*
* This proprietary software may be used only connection with the Fabric3 license
* (the “License”), a copy of which is included in the software or may be
* obtained at: http://www.metaformsystems.com/licenses/license.html.
* Software distributed under the License is distributed on an “as is” basis,
* without warranties or conditions of any kind. See the License for the
* specific language governing permissions and limitations of use of the software.
* This software is distributed in conjunction with other software licensed under
* different terms. See the separate licenses for those programs included in the
* distribution for the permitted and restricted uses of such software.
*
*/
package org.fabric3.transform.dom2java;
import org.w3c.dom.Node;
import org.fabric3.model.type.service.DataType;
import org.fabric3.spi.model.type.JavaClass;
import org.fabric3.spi.transform.TransformContext;
import org.fabric3.spi.transform.TransformationException;
import org.fabric3.transform.AbstractPullTransformer;
/**
* @version $Rev$ $Date$
*/
public class String2Double extends AbstractPullTransformer<Node, Double> {
private static final JavaClass<Double> TARGET = new JavaClass<Double>(Double.class);
public DataType<?> getTargetType() {
return TARGET;
}
public Double transform(Node node, TransformContext context) throws TransformationException {
try {
return Double.valueOf(node.getTextContent());
} catch (NumberFormatException ex) {
throw new TransformationException("Unsupportable double " + node.getTextContent(), ex);
}
}
}
| [
"meerajk@83866bfc-822f-0410-aa35-bd5043b85eaf"
] | meerajk@83866bfc-822f-0410-aa35-bd5043b85eaf |
d5d6bc35934e3ca32dc4ad837f5355d29e47abe9 | 254ebef44e844f083179ee000839b81e42b203b1 | /whm-intf/src/main/java/com/summer/whm/mapper/sys/NoticeMapper.java | 7c3953498df1008fa7cad7fbc2eec5e4b929f4e5 | [] | no_license | whocj/Dodoer | af387341cf43a0b723549fb47ea64243badb5c60 | e10bff4c229beb238c3e26ec9af617fef28d37a4 | refs/heads/master | 2021-10-23T18:46:53.781157 | 2019-03-19T07:55:00 | 2019-03-19T07:55:00 | 121,004,382 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 318 | java | package com.summer.whm.mapper.sys;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.summer.whm.entiry.sys.Notice;
import com.summer.whm.mapper.BaseMapper;
public interface NoticeMapper extends BaseMapper {
List<Notice> queryBySiteId(@Param("siteId") Integer siteId);
}
| [
"dodoer@78c6e549-bab0-4dcd-97f5-38ca0bb93b42"
] | dodoer@78c6e549-bab0-4dcd-97f5-38ca0bb93b42 |
5fa5867c5e39044fb0502eadd3d7ae174519f616 | eca4a253fe0eba19f60d28363b10c433c57ab7a1 | /apps/jacob.call_expert/java/jacob/event/ui/customer/CustomerStaticImage.java | 78bda01207f8aaed2f93ce2d7fc7d0b5c65c7e5f | [] | no_license | freegroup/Open-jACOB | 632f20575092516f449591bf6f251772f599e5fc | 84f0a6af83876bd21c453132ca6f98a46609f1f4 | refs/heads/master | 2021-01-10T11:08:03.604819 | 2015-05-25T10:25:49 | 2015-05-25T10:25:49 | 36,183,560 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,451 | java | /*
* jACOB event handler created with the jACOB Application Designer
*
* Created on Thu Nov 06 09:15:51 CET 2008
*/
package jacob.event.ui.customer;
import jacob.common.tabcontainer.TabManagerRequest;
import de.tif.jacob.screen.IClientContext;
import de.tif.jacob.screen.IGuiElement;
import de.tif.jacob.screen.IStaticImage;
import de.tif.jacob.screen.event.IOnClickEventHandler;
import de.tif.jacob.screen.event.IStaticImageEventHandler;
/**
* You must implement the interface "IOnClickEventHandler" if you want receive the
* onClick events of the user.
*
* @author achim
*/
public class CustomerStaticImage extends IStaticImageEventHandler implements IOnClickEventHandler
{
public void onClick(IClientContext context, IGuiElement element) throws Exception
{
String groupAliasName = element.getGroupTableAlias();
if (context.getDataTable(groupAliasName).getSelectedRecord()!=null)
{
TabManagerRequest.setActive(context, groupAliasName);
}
}
/**
* The event handler if the group status has been changed.<br>
*
* @param context The current work context of the jACOB application.
* @param status The new state of the group.
* @param emitter The emitter of the event.
*/
public void onGroupStatusChanged( IClientContext context, IGuiElement.GroupState state, IStaticImage image) throws Exception
{
// image.setVisible(state == IGroup.SELECTED || state == IGroup.UPDATE);
}
}
| [
"a.herz@freegroup.de"
] | a.herz@freegroup.de |
1a9204d50a628daa31d90965e16c6925855808b9 | 77996b363f5e449d53242b912d98e5bc3dd96fe8 | /baekjoon19/src/dfs_bfs/dfs_bfs_14502_r.java | 82425e1edcd3e9ef2d39c971b86e75e0277bbc48 | [] | no_license | boen0314/baekjoon19 | ebdd02b24e6acffae278007fd18abb7ff9991cd4 | 9dd68c513568ee66276e19508931a9866569bb50 | refs/heads/master | 2020-05-02T14:21:30.963911 | 2019-04-10T13:11:11 | 2019-04-10T13:11:11 | 178,008,424 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,387 | java | package dfs_bfs;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;
class Virus {
int x, y;
public Virus(int x, int y) {
super();
this.x = x;
this.y = y;
}
}
public class dfs_bfs_14502_r {
static int N, M;
static int[][] matrix;
static int[][] tmp;
// 방문 여부는 필요 없음. 최단거리를 구하는게 아닌 바이러스를 퍼트리기만 하면 되므로
static int[] dx = { 1, 0, -1, 0 };
static int[] dy = { 0, 1, 0, -1 };
static int max;
public static void Wall(int cnt) {
if (cnt == 3) {
BFS();
return;
}
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (matrix[i][j] == 0) {
matrix[i][j] = 1; // 벽 설치
Wall(cnt + 1);
matrix[i][j] = 0; // 벽 초기화 (백트래킹)
}
}
}
}
public static void BFS() {
Queue<Virus> q = new LinkedList<>();
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
tmp[i][j] = matrix[i][j];
if (tmp[i][j] == 2) { // 바이러스가 있다면
q.add(new Virus(i, j)); // 큐에 추가
}
}
}
while (!q.isEmpty()) {
Virus v = q.poll();
for (int i = 0; i < 4; i++) {
int nx = v.x + dx[i];
int ny = v.y + dy[i];
if (nx >= N || ny >= M || nx < 0 || ny < 0)
continue;
if (tmp[nx][ny] != 0)
continue;
tmp[nx][ny] = 2;
q.add(new Virus(nx, ny));
}
}
MaxSafety();
}
public static void MaxSafety() {
int safeCount = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j < M; j++) {
if (tmp[i][j] == 0)
safeCount++;
}
}
max = Math.max(max, safeCount);
}
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
matrix = new int[N][M];
tmp = new int[N][M];
for (int i = 0; i < N; i++) {
st = new StringTokenizer(br.readLine());
for (int j = 0; j < M; j++) {
matrix[i][j] = Integer.parseInt(st.nextToken());
}
}
Wall(0);
System.out.println(max);
}
}
| [
"boen0323@naver.com"
] | boen0323@naver.com |
49eef2e89b1cad5b184bd3ca7b51d40cc6236a58 | 78f284cd59ae5795f0717173f50e0ebe96228e96 | /factura-entidades/src/cl/stotomas/factura/errores_7/TestingFinalTry.java | 288bac8c60e3001a62ac1a5db3ec292166d4bd8f | [] | no_license | Pattricio/Factura | ebb394e525dfebc97ee2225ffc5fca10962ff477 | eae66593ac653f85d05071b6ccb97fb1e058502d | refs/heads/master | 2020-03-16T03:08:45.822070 | 2018-05-07T15:29:25 | 2018-05-07T15:29:25 | 132,481,305 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 1,794 | java | package cl.stotomas.factura.errores_7;
import java.applet.Applet;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
public class TestingFinalTry {
public static String decryptMessage(final byte[] message, byte[] secretKey)
{
try {
// CÓDIGO VULNERABLE
final SecretKeySpec KeySpec = new SecretKeySpec(secretKey, "DES");
final Cipher cipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(Cipher.DECRYPT_MODE, KeySpec);
// RECOMENDACIÓN VERACODE
// final Cipher cipher = Cipher.getInstance("DES...");
// cipher.init(Cipher.DECRYPT_MODE, KeySpec);
return new String(cipher.doFinal(message));
}
catch(Exception e)
{
e.printStackTrace();
}
return null;
}
class Echo {
// Control de Proceso
// Posible reemplazo de librería por una maliciosa
// Donde además s enos muestra el nombre explícito de esta.
public native void runEcho();
{
System.loadLibrary("echo"); // Se carga librería
}
public void main(String[] args)
{
new Echo().runEcho();
}
public final class TestApplet extends Applet {
private static final long serialVersionUID = 1L;
}
public final class TestAppletDos extends Applet {
private static final long serialVersionUID = 1L;
}
//Comparación de referencias de objeto en lugar de contenido de objeto
// El if dentro de este código no se ejecutará.
// porque se prioriza el String a mostrar.
public final class compareStrings{
public String str1;
public String str2;
public void comparar()
{
if (str1 == str2)
{
System.out.println("str1 == str2");
}
}
}
}
}
| [
"Adriana Molano@DESKTOP-GQ96FK8"
] | Adriana Molano@DESKTOP-GQ96FK8 |
1cfce80111c4286cd72f701b281265aaacce8a19 | 6517c4ada7b685509aed1cb46366a44df6e41f82 | /src/main/java/com/podong/game/module/schduling/batched/BasicClass.java | acfdb5251976121b23fb31ee22b509c9a603bb68 | [] | no_license | podonghee/Game | aaadfe5739ba933c07688c18c39d7468bf762c60 | a64f24666840ead279f406fe2008cd4445a9d440 | refs/heads/master | 2023-05-02T08:38:55.442729 | 2021-05-28T08:55:51 | 2021-05-28T08:55:51 | 365,454,759 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,262 | java | package com.podong.game.module.schduling.batched;
import com.podong.game.module.schduling.batch.Batch;
import com.podong.game.module.schduling.bean.GameCompanyVO;
import com.podong.game.module.schduling.bean.GameDataVO;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class BasicClass implements Batch {
public static final String WEB_DRIVER_ID = "webdriver.chrome.driver"; //드라이버 ID
public static final String WEB_DRIVER_PATH = "//Users//podonghi//Downloads//chromedriver"; //드라이버 경로
@Override
public void start(){}
public WebDriver chromeDriver(String gameUrl){
try {
System.setProperty(WEB_DRIVER_ID, WEB_DRIVER_PATH);
} catch (Exception e) {
e.printStackTrace();
}
ChromeOptions options = new ChromeOptions();
//크롬창 띄울지 말지 결정
//options.addArguments("headless");
WebDriver driver = new ChromeDriver(options);
//크롬으로 크롤링할 페이지 Url 삽입
driver.get(gameUrl);
// 페이지 로드되는시간 1초 기다리기.
try {Thread.sleep(1000);} catch (InterruptedException e) {}
return driver;
}
/**
* Author : po dong hee
* Date : 2021-04-21
* Description : Game 에서 사용할 값 셋팅 해주는함수.
* Param : imgUrl = "이미지주소 : https://cdn.gamemeca.com/gmdb/g001/22/84/gm662247_210421-risell-uu4.jpg"
* imgName = '이미지가 저장될떄 게임명'
* uploadUrl = 이미지를 업로드할 경로
* */
public void imgDownload(String imgUrl ,String imgName , String uploadUrl){
BufferedImage jpg = null;
HttpURLConnection conn = null;
try {
URL url = new URL(imgUrl);
conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Referer", imgUrl);
jpg = ImageIO.read(conn.getInputStream());
//imgName 에 / 가 들어가 있을경우 디렉토리로 인식하여 오류발생.
imgName =imgName.replaceAll("/","");
FileOutputStream out = new FileOutputStream(uploadUrl + "/" + imgName+ ".jpg");
ImageIO.write(jpg, "jpg", out);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* Author : po dong hee
* Date : 2021-04-21
* Description : Game 에서 사용할 값 셋팅 해주는함수.
* Param : key = "플랫폼" value : 'PC' vo : 셋팅할 GameDataVO
* */
public void switchGame(String key , String value , GameDataVO vo){
switch (key){
case "플랫폼" : vo.setPlatform(value);
break;
case "장르" : vo.setGenre(value);
break;
case "제작사" : vo.setProducer(value);
break;
case "제공업체" : vo.setProvider(value);
break;
case "이용등급" : vo.setUseCount(value);
break;
case "출시년도" : vo.setYearRelase(value);
break;
case "게임설명" : vo.setDescription(value);
break;
}
}
/**
* Author : po dong hee
* Date : 2021-04-21
* Description : Game Company 에서 사용할 값 셋팅 해주는함수.
* Param : 예시 ) key = "업체명" value : '네오플' vo : 셋팅할 GameCompanyVO
* */
public void switchGameCompany(String key, String value, GameCompanyVO vo){
switch (key){
case "업체명" : vo.setGameCompanyName(value);
break;
case "대표전화" : vo.setGameCompanyTel(value);
break;
case "주소" : vo.setGameCompanyAddr(value);
break;
case "대표사이트" : vo.setGameCompanySite(value);
break;
case "이미지" : vo.setGameCompanyImg(value);
break;
}
}
}
| [
"sgh01101@naver.com"
] | sgh01101@naver.com |
bab5e233cae3e62cec75b027d3950af1f911674f | 71de91337ccbf2d3ea43808eda64feab8b8e9ee0 | /ChatServer/src/Mensaje.java | 61e0ea7751a1cc824904bdee4ef0a819fd871b15 | [] | no_license | Unaip96/Chat | 8baa80c5d6c0c73d8559f05e58c50229f27bb499 | 5489f8ec9ad8cda13edd9fcaae14fabf73e80c00 | refs/heads/master | 2020-03-19T22:44:19.766875 | 2018-06-11T20:55:19 | 2018-06-11T20:55:19 | 136,979,892 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 906 | java | import java.io.Serializable;
public class Mensaje implements Serializable{
private static final long serialVersionUID = 1L;
String mensaje;
String nick;
String ip;
public Mensaje(String all) {
split(all);
}
public Mensaje(String mensaje, String ip) {
this.mensaje = mensaje;
this.ip = ip;
}
public String getMensaje() {
return mensaje;
}
public void setMensaje(String mensaje) {
this.mensaje = mensaje;
}
public String getNick() {
return nick;
}
public void setNick(String nick) {
this.nick = nick;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public String toString(){
return ip+";"+nick+";"+mensaje+";";
}
public void split(String x){
String[] split = x.split(";");
this.ip = split[0];
this.nick = split[1];
this.mensaje = split[2];
}
}
| [
"unaip@live.com"
] | unaip@live.com |
c5f7a9daea24a55e2c6908c674409cd17733f699 | dde3cb4b08e37d3c370762befaf26ecd481a5d30 | /app/src/main/java/top/vchao/live/utils/SerialPortUtils.java | 996ec7a4d2cd6d88a8136984befe58197eb89fb5 | [] | no_license | zhengweichao/live | 29245db363d0403fd048db952338ba03cbc3ef38 | 046b98ecff8e97eebee4eff2a00428c315ae0ece | refs/heads/master | 2020-03-15T16:06:23.836587 | 2018-11-20T07:14:48 | 2018-11-20T07:14:48 | 132,228,434 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,333 | java | package top.vchao.live.utils;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import android_serialport_api.SerialPort;
/**
* @ Create_time: 2018/6/28 on 11:08.
* @ description: 串口工具类
* @ author: vchao blog: http://blog.csdn.net/zheng_weichao
*/
public class SerialPortUtils {
private final String TAG = "SerialPortUtils";
private String path = "/dev/ttyS1";
private int baudrate = 9600;
public boolean serialPortStatus = false; //是否打开串口标志
public String data_;
public boolean threadStatus; //线程状态,为了安全终止线程
public SerialPort serialPort = null;
public InputStream inputStream = null;
public OutputStream outputStream = null;
public ChangeTool changeTool = new ChangeTool();
/**
* 打开串口
* @return serialPort串口对象
*/
public SerialPort openSerialPort(){
try {
serialPort = new SerialPort(new File(path),baudrate,0);
this.serialPortStatus = true;
threadStatus = false; //线程状态
//获取打开的串口中的输入输出流,以便于串口数据的收发
inputStream = serialPort.getInputStream();
outputStream = serialPort.getOutputStream();
new ReadThread().start(); //开始线程监控是否有数据要接收
} catch (IOException e) {
Log.e(TAG, "openSerialPort: 打开串口异常:" + e.toString());
return serialPort;
}
Log.d(TAG, "openSerialPort: 打开串口");
return serialPort;
}
/**
* 关闭串口
*/
public void closeSerialPort(){
try {
inputStream.close();
outputStream.close();
this.serialPortStatus = false;
this.threadStatus = true; //线程状态
serialPort.close();
} catch (IOException e) {
Log.e(TAG, "closeSerialPort: 关闭串口异常:"+e.toString());
return;
}
Log.d(TAG, "closeSerialPort: 关闭串口成功");
}
/**
* 发送串口指令(字符串)
* @param data String数据指令
*/
public void sendSerialPort(String data){
Log.d(TAG, "sendSerialPort: 发送数据");
try {
byte[] sendData = data.getBytes(); //string转byte[]
this.data_ = new String(sendData); //byte[]转string
if (sendData.length > 0) {
outputStream.write(sendData);
outputStream.write('\n');
//outputStream.write('\r'+'\n');
outputStream.flush();
Log.d(TAG, "sendSerialPort: 串口数据发送成功");
}
} catch (IOException e) {
Log.e(TAG, "sendSerialPort: 串口数据发送失败:"+e.toString());
}
}
/**
* 单开一线程,来读数据
*/
private class ReadThread extends Thread{
@Override
public void run() {
super.run();
//判断进程是否在运行,更安全的结束进程
while (!threadStatus){
Log.d(TAG, "进入线程run");
//64 1024
byte[] buffer = new byte[64];
int size; //读取数据的大小
try {
size = inputStream.read(buffer);
if (size > 0){
Log.d(TAG, "run: 接收到了数据:" + changeTool.ByteArrToHex(buffer));
Log.d(TAG, "run: 接收到了数据大小:" + String.valueOf(size));
onDataReceiveListener.onDataReceive(buffer,size);
}
} catch (IOException e) {
Log.e(TAG, "run: 数据读取异常:" +e.toString());
}
}
}
}
//这是写了一监听器来监听接收数据
public OnDataReceiveListener onDataReceiveListener = null;
public static interface OnDataReceiveListener {
public void onDataReceive(byte[] buffer, int size);
}
public void setOnDataReceiveListener(OnDataReceiveListener dataReceiveListener) {
onDataReceiveListener = dataReceiveListener;
}
}
| [
"weichao211314"
] | weichao211314 |
f799f90d1d9b776b1f156a8a5c6e630809db0fe4 | c859b36adcb1c8d0346f1234d6b5b770c355c075 | /app/src/main/java/com/johnnyfivedev/utilpack/CustomHtmpHttpImageGetter.java | 629c6192740a620ebb327392b7f29dabbc96d155 | [
"Apache-2.0"
] | permissive | johnnyfivedev/UtilPack | 4ec520b9223945204d81dec4bb62681b57acdc83 | ca626aceeb1bddd52ff004e4472099065c615d04 | refs/heads/master | 2020-06-20T02:53:56.629839 | 2019-07-15T09:58:40 | 2019-07-15T09:58:40 | 196,966,947 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,052 | java | package com.johnnyfivedev.utilpack;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.AsyncTask;
import android.text.Html;
import android.util.Log;
import android.view.View;
import android.widget.TextView;
import org.sufficientlysecure.htmltextview.HtmlHttpImageGetter;
import org.sufficientlysecure.htmltextview.HtmlTextView;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.net.URI;
import java.net.URL;
public class CustomHtmpHttpImageGetter implements Html.ImageGetter {
TextView container;
URI baseUri;
boolean matchParentWidth;
private boolean compressImage = false;
private int qualityImage = 50;
public CustomHtmpHttpImageGetter(TextView textView) {
this.container = textView;
this.matchParentWidth = false;
}
public CustomHtmpHttpImageGetter(TextView textView, boolean matchParentWidth) {
this.container = textView;
this.matchParentWidth = matchParentWidth;
}
public CustomHtmpHttpImageGetter(TextView textView, String baseUrl) {
this.container = textView;
if (baseUrl != null) {
this.baseUri = URI.create(baseUrl);
}
}
public CustomHtmpHttpImageGetter(TextView textView, String baseUrl, boolean matchParentWidth) {
this.container = textView;
this.matchParentWidth = matchParentWidth;
if (baseUrl != null) {
this.baseUri = URI.create(baseUrl);
}
}
public void enableCompressImage(boolean enable) {
enableCompressImage(enable, 50);
}
public void enableCompressImage(boolean enable, int quality) {
compressImage = enable;
qualityImage = quality;
}
public Drawable getDrawable(String source) {
UrlDrawable urlDrawable = new UrlDrawable();
// get the actual source
ImageGetterAsyncTask asyncTask = new ImageGetterAsyncTask(urlDrawable, this, container,
matchParentWidth, compressImage, qualityImage);
asyncTask.execute(source);
// return reference to URLDrawable which will asynchronously load the image specified in the src tag
return urlDrawable;
}
/**
* Static inner {@link AsyncTask} that keeps a {@link WeakReference} to the {@link UrlDrawable}
* and {@link HtmlHttpImageGetter}.
* <p/>
* This way, if the AsyncTask has a longer life span than the UrlDrawable,
* we won't leak the UrlDrawable or the HtmlRemoteImageGetter.
*/
private static class ImageGetterAsyncTask extends AsyncTask<String, Void, Drawable> {
private final WeakReference<UrlDrawable> drawableReference;
private final WeakReference<CustomHtmpHttpImageGetter> imageGetterReference;
private final WeakReference<View> containerReference;
private final WeakReference<Resources> resources;
private String source;
private boolean matchParentWidth;
private float scale;
private boolean compressImage = false;
private int qualityImage = 50;
public ImageGetterAsyncTask(UrlDrawable d, CustomHtmpHttpImageGetter imageGetter, View container,
boolean matchParentWidth, boolean compressImage, int qualityImage) {
this.drawableReference = new WeakReference<>(d);
this.imageGetterReference = new WeakReference<>(imageGetter);
this.containerReference = new WeakReference<>(container);
this.resources = new WeakReference<>(container.getResources());
this.matchParentWidth = matchParentWidth;
this.compressImage = compressImage;
this.qualityImage = qualityImage;
}
@Override
protected Drawable doInBackground(String... params) {
source = params[0];
if (resources.get() != null) {
if (compressImage) {
return fetchCompressedDrawable(resources.get(), source);
} else {
return fetchDrawable(resources.get(), source);
}
}
return null;
}
@Override
protected void onPostExecute(Drawable result) {
if (result == null) {
Log.w(HtmlTextView.TAG, "Drawable result is null! (source: " + source + ")");
return;
}
final UrlDrawable urlDrawable = drawableReference.get();
if (urlDrawable == null) {
return;
}
// set the correct bound according to the result from HTTP call
urlDrawable.setBounds(0, 0, (int) (result.getIntrinsicWidth() * scale), (int) (result.getIntrinsicHeight() * scale));
// change the reference of the current drawable to the result from the HTTP call
urlDrawable.drawable = result;
final CustomHtmpHttpImageGetter imageGetter = imageGetterReference.get();
if (imageGetter == null) {
return;
}
// redraw the image by invalidating the container
imageGetter.container.invalidate();
// re-set text to fix images overlapping text
imageGetter.container.setText(imageGetter.container.getText());
}
/**
* Get the Drawable from URL
*/
public Drawable fetchDrawable(Resources res, String urlString) {
try {
InputStream is = fetch(urlString);
Drawable drawable = new BitmapDrawable(res, is);
scale = getScale();
drawable.setBounds(0, 0, (int) (drawable.getIntrinsicWidth() * scale), (int) (drawable.getIntrinsicHeight() * scale));
return drawable;
} catch (Exception e) {
return null;
}
}
/**
* Get the compressed image with specific quality from URL
*/
public Drawable fetchCompressedDrawable(Resources res, String urlString) {
try {
InputStream is = fetch(urlString);
Bitmap original = new BitmapDrawable(res, is).getBitmap();
ByteArrayOutputStream out = new ByteArrayOutputStream();
original.compress(Bitmap.CompressFormat.PNG, qualityImage, out);
original.recycle();
is.close();
Bitmap decoded = BitmapFactory.decodeStream(new ByteArrayInputStream(out.toByteArray()));
out.close();
scale = getScale();
BitmapDrawable b = new BitmapDrawable(res, decoded);
b.setBounds(0, 0, (int) (b.getIntrinsicWidth() * scale), (int) (b.getIntrinsicHeight() * scale));
return b;
} catch (Exception e) {
return null;
}
}
// При скачке Bitmap уменьшается в размере на примерно 1.8
private float getScale() {
return 1.8f * DimensManager.getDensity(containerReference.get().getContext());
}
/* private float getScale(Bitmap bitmap) {
View container = containerReference.get();
if (container == null) {
return 1f;
}
float maxWidth = container.getWidth();
float originalDrawableWidth = bitmap.getWidth();
return maxWidth / originalDrawableWidth;
}
private float getScale(Drawable drawable) {
View container = containerReference.get();
if (!matchParentWidth || container == null) {
return 1f;
}
float maxWidth = container.getWidth();
float originalDrawableWidth = drawable.getIntrinsicWidth();
return maxWidth / originalDrawableWidth;
}*/
private InputStream fetch(String urlString) throws IOException {
URL url;
final CustomHtmpHttpImageGetter imageGetter = imageGetterReference.get();
if (imageGetter == null) {
return null;
}
if (imageGetter.baseUri != null) {
url = imageGetter.baseUri.resolve(urlString).toURL();
} else {
url = URI.create(urlString).toURL();
}
return (InputStream) url.getContent();
}
}
@SuppressWarnings("deprecation")
public class UrlDrawable extends BitmapDrawable {
protected Drawable drawable;
@Override
public void draw(Canvas canvas) {
// override the draw to facilitate refresh function later
if (drawable != null) {
drawable.draw(canvas);
}
}
}
}
| [
"d.syrovatchenko@medsolutions.ru"
] | d.syrovatchenko@medsolutions.ru |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.