id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
47b29111-1c63-40f0-87d3-f7dc7dc2bc58 | @Bean
public GraphvizProcessor graphvizProcessor()
{
GraphvizProcessor result = new GraphvizProcessor();
return result;
} |
02af4dd0-6832-426b-ac0f-9374b5226332 | @Test
public final void whenSpringContextIsInstantiated_thenNoExceptions(){
// When
} |
99cda837-9cfe-48f3-bc0c-02485bf7236c | public WebServer(int port) {
this.port = port;
} |
e2e7d798-227a-4fc3-a3a7-938f9e75c8e7 | public WebServer() {
} |
c63f7f29-d3a2-47c4-9a84-5a05f0f82beb | public void start(File webAppContextPath, String applicationContext) {
server = startWebServer(webAppContextPath, applicationContext);
port = getServerPort(server);
} |
fe4d4490-16b3-47ea-9907-d3b5f48026f7 | private Integer getServerPort(Server server) {
return server.getConnectors()[0].getLocalPort();
} |
1f57c1e1-cfa1-4474-8584-ac7b9b1c32ac | private Server startWebServer(File webAppContextPath, String applicationContext) {
Assert.isTrue(webAppContextPath.exists(), "The context path you have specified does not exist: " + webAppContextPath);
Assert.notNull(applicationContext, "You must specify the context path of the application");
int startPort = 0;
... |
66b68dfe-3554-4406-82d3-3bb95d56f13b | private void setUpClassPath(WebAppContext webAppContext) {
String classpath = System.getProperty("java.class.path");
String separator = System.getProperty("path.separator");
if (":".equals(separator)) {
classpath = classpath.replace(":", ";");
}
webAppContext.setExtraClasspath(classpath);
} |
3c49328c-2d8f-4cc6-82be-07db7cb6bd3f | public Integer getPort() {
Assert.notNull(port, "Server must be started before port can be determined");
return this.port;
} |
f5d95eb9-9674-4955-874e-7419f2edf1bf | public void stop() {
try {
server.stop();
} catch (Exception e) {
throw new RuntimeException(e);
}
} |
75948320-b411-4186-aa84-9b2d28177adf | public static void main(String[] args) throws Exception {
int port = determineServerPort();
File contextPath = determineContextPath();
WebServer setupServer = new WebServer(port);
setupServer.start(contextPath, "");
} |
641a351d-8c3e-48f9-957c-8e54b9f03716 | private static File determineContextPath() {
File contextPath = new File("./src/main/webapp");
File herokuPath = new File("./herokudemo-webapp/src/main/webapp");
if (herokuPath.exists()) {
return herokuPath;
}
return contextPath;
} |
627a1675-d90d-4b6d-841f-1e0251198be0 | private static int determineServerPort() {
int port = 8080;
String systemPort = System.getenv("PORT");
if (systemPort != null) {
port = Integer.valueOf(systemPort);
}
return port;
} |
92863592-c3aa-4fa5-a9a3-894b61949078 | public String getName() {
return name;
} |
a5c663fe-f124-4e08-8cf4-d1d557ccc6f2 | public void setName(String name) {
this.name = name;
} |
48d4ee2c-0ca5-4447-ab73-200a7381bcd4 | @RequestMapping(method = RequestMethod.GET)
public String startApplication() {
return redirectTo(VIEW_WEB_OVERVIEW);
} |
eaaa7c05-6c83-4a62-aff7-a279896a9d6c | public static final String redirectTo(String url) {
return "redirect:" + url;
} |
f39c75be-b18e-44f4-a32a-eeb874deac3b | public static final String url(String... parts) {
String result = "";
for (String string : parts) {
result += "/" + string;
}
return result;
} |
f4b41e06-549f-4305-8389-8bb79ee2218e | @RequestMapping(value = URL_OVERVIEW, method = RequestMethod.GET)
public String showFrontpage(Model model) {
List<Name> names = nameService.getAll();
model.addAttribute("addNameForm", new AddNameForm());
model.addAttribute("names", names);
return VIEW_WEB_OVERVIEW;
} |
e354d745-5a03-418a-815f-d18a2dd34a1c | @RequestMapping(value = URL_OVERVIEW, method = RequestMethod.POST, params = "addName")
public String addName(@ModelAttribute AddNameForm addNameForm,
Errors errors, Model model) {
// Add name if not null or empty
String name = addNameForm.getName();
if(name != null && name.length() != 0){
nameService.ad... |
03cd1348-f126-4274-9342-d473807c176b | @RequestMapping(value = URL_OVERVIEW, method = RequestMethod.POST, params = "deleteAll")
public String deleteAll(@ModelAttribute AddNameForm addNameForm,
Errors errors, Model model) {
// Delete them all
nameService.deleteAll();
// Go back to web/overview
return redirectTo(URL_OVERVIEW);
} |
ee8dd2a5-a77e-4750-9b40-a0eb778369e2 | @RequestMapping(value = URL_OVERVIEW, method = RequestMethod.GET, params = "name")
public String addName(@RequestParam(value="name") String name) {
// Add name if not null or empty
if(name != null && name.length() != 0){
nameService.add(new Name(name));
}
// Go back to web/overview
return redirectTo... |
7738cc24-2adb-4ebc-8bc4-9ae085d7d359 | public Name(String name){
setName(name);
} |
56a1c46b-11d9-4113-a3f9-f82469c2e20a | public Name(){
} |
7d63e4ca-fb91-45f5-b89f-995d539e72dd | public String getName() {
return name;
} |
8ca37623-0213-46d1-ba13-db9d6bf2db7e | public void setName(String name) {
this.name = name;
} |
680b9e21-5207-49b2-9a68-80709c488fb6 | public Long getId() {
return id;
} |
5e792139-15e3-450c-867f-cd819f55af81 | public List<T> getAll(); |
619a8e3e-e6a0-49ac-8476-f6928e87bfdb | public T get(Long id); |
291a3fb8-5ca6-4c76-a26e-4fe560218d2f | public boolean add(T entity); |
ab6a17db-e8c4-452a-ac06-b1bfd21cec8b | public void update(T entity); |
654ef363-d3ed-4469-8052-c8128c5915c4 | public void remove(T entity); |
2bc3e841-9a84-4d6a-8fb8-cf7ee17bf97d | @Override
public List<T> getAll() {
return repository.getAll();
} |
a0fca4b2-d08d-46ff-ba5e-de44709524d2 | @Override
public T get(Long id) {
return repository.get(id);
} |
1ecb338d-dd43-455b-b2a3-89decdfde54b | @Override
public boolean add(T entity) {
repository.add(entity);
return true;
} |
61c0c493-34bf-45c5-b1b2-ebbddbe54cb6 | @Override
public void update(T entity) {
repository.update(entity);
} |
007ba0a6-fef0-4fd9-9a3c-9bfd1b8072a9 | @Override
public void remove(T entity) {
repository.remove(entity);
} |
ab66a1b1-8740-400e-ad59-fa15881b4ead | public void deleteAll(); |
4d61bcd2-60bb-42eb-9841-ca0c6ace35c4 | @Autowired
public void setNameRepository(NameRepository nameRepository) {
this.nameRepository = nameRepository;
repository = nameRepository;
} |
11453838-0e5a-48c7-8980-b1ddd8c51bcf | @Override
public void deleteAll() {
nameRepository.deleteAll();
} |
3d366063-486b-4a0e-8fb7-5805b88647bb | public void deleteAll(); |
74d147ec-03c5-4844-9818-1aec61ab9390 | public NameRepositoryImpl() {
super(Name.class);
} |
3ca56428-ce2a-459b-aeb5-0cdccb8bc6cc | @Override
public void deleteAll(){
Session session = getSession();
String stringQuery = "DELETE FROM Name";
Query query = session.createQuery(stringQuery);
query.executeUpdate();
} |
3fb7699c-f73d-41d5-b47a-2e9c6b9f214f | public List<T> getAll(); |
c7457c7c-0b78-4448-a7e3-d26e6ae5b0be | public T get(Long id); |
eeba2e13-0799-45c1-ba46-0e8096b0326c | public void add(T entity); |
4dd307bc-ad02-49a0-b6a6-30dbffd74a6e | public void update(T entity); |
4211b5fe-be76-4f27-a126-1fa5e3c5bb79 | public void remove(T entity); |
66306bf1-dfad-4fb0-99da-d3ca1868470f | public EntityRepositoryImpl(Class clazz) {
this.clazz = clazz;
} |
1b289df9-ca16-4cce-8206-cf1b1c7c82c7 | @SuppressWarnings("unchecked")
protected List<T> getAll(Criteria criteria) {
List<T> entities = criteria.list();
return entities;
} |
ea14f795-fef5-408d-8508-545e36472a71 | protected T get(Criteria criteria) {
List<T> entities = getAll(criteria);
if (entities.isEmpty()) return null;
return entities.get(0);
} |
6f5d1277-914e-4f90-b496-9cdf727f66f2 | protected Session getSession() {
Session session = sessionFactory.getCurrentSession();
return session;
} |
ef5f6ecd-1baa-496d-b3ac-d99f8a0409bb | @Override
public T get(Long id) {
Session session = sessionFactory.getCurrentSession();
return (T) session.get(clazz, id);
} |
d9cf1932-5620-4f02-81a2-6a7a62d67d01 | @Override
public List<T> getAll() {
Session session = sessionFactory.getCurrentSession();
Criteria criteria = session.createCriteria(clazz);
return criteria.list();
} |
3c6d8352-3906-4909-a9a5-b234f2bce256 | @Override
public void add(T entity) {
Session session = getSession();
session.save(entity);
} |
5cffea74-3d0d-42aa-b9e4-63f5a7b53d3a | @Override
public void update(T entity) {
Session session = getSession();
session.merge(entity);
} |
5adca550-d6de-4aae-92b5-7736499accd4 | @Override
public void remove(T entity) {
Session session = getSession();
session.delete(entity);
} |
39a3e7d2-f602-4987-bfa8-ce75ccb530f4 | public String getName() {
return name;
} |
06643abc-baf0-4d92-90f2-777cc2565600 | public void setName(String name) {
this.name = name;
} |
92ca8410-3b02-4663-bdab-abca986055c9 | public String getName() {
return name;
} |
1553bf11-7956-433f-87e7-e1eee4b986d1 | public void setName(String name) {
this.name = name;
} |
9cc9d99c-2228-462c-be2d-270f85a57d66 | public EmbededBean getEb() {
return eb;
} |
8d572f0a-2152-49b6-a983-0095b677312e | public void setEb(EmbededBean eb) {
this.eb = eb;
} |
cc4f6e8f-8cc9-47c5-8d3b-4a46361820ee | public List<ListBean> getLbs() {
return lbs;
} |
7bb71480-70a2-45e7-af12-236b09c03eb8 | public void setLbs(List<ListBean> lbs) {
this.lbs = lbs;
} |
836a320f-2bf6-47c2-8cca-b317f5d24fec | public String getValue() {
return value;
} |
05ab50ad-bf8f-4e15-a918-d51f6d527aa6 | public void setValue(String value) {
this.value = value;
} |
b2a6261f-f898-4171-a5c2-6a614c2b72e4 | public String getName() {
return name;
} |
ae4843b8-1f75-4506-9165-f238621d307b | public void setName(String name) {
this.name = name;
} |
a5ed4272-a446-4e06-973a-791af710bcd2 | @RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
logger.info("Welcome home! The client locale is {}.", locale);
Date date = new Date();
DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
String formatt... |
c08def3f-2dc3-49c7-992c-a217ce19e761 | @RequestMapping(value = "/sessionScope/{value}")
public String test(@PathVariable String value){
sessionBean.setValue(value);
return "home";
} |
93a04739-a40c-4014-bd91-f2ba4ac6dd75 | @RequestMapping(value="/{name}", method = RequestMethod.GET, produces="application/json")
public @ResponseBody MyBean get(@PathVariable String name){
return map.get(name);
} |
adaa33d9-feb8-48cc-9522-8f6253f0dda0 | @RequestMapping(method = RequestMethod.POST, consumes="application/json")
public @ResponseBody MyBean put(@RequestBody MyBean bean){
return map.put(bean.getName(), bean);
} |
af1f47ac-fe25-46b5-8721-56a2758068b1 | @RequestMapping(value="/{name}", method = RequestMethod.DELETE)
public @ResponseBody MyBean delete(@PathVariable String name){
return map.remove(name);
} |
f150d028-0285-46ad-b073-36a15865f92d | @Test
public void getRestTemplate(){
Assert.assertNotNull(restTemplate);
} |
015b7500-d8d3-49f2-9459-1beb4e399660 | @Test
public void get(){
MyBean bean = new MyBean();
bean.setName("Hello");
EmbededBean eb = new EmbededBean();
eb.setName("eb");
bean.setEb(eb);
restTemplate.postForObject(URL, bean, String.class);
String ret = restTemplate.getForObject(URL + "/Hello", String.class);
Assert.assertNotNull(ret);... |
9aa3a51d-8d74-4583-aac2-f25e316462ad | @Test
public void delete(){
restTemplate.delete(URL + "/Hello");
String ret = restTemplate.getForObject(URL + "/Hello", String.class);
Assert.assertNull(ret);
} |
1331f459-4cab-481b-9705-912f0bbcd312 | @Before
public void setup(){
this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
} |
9e21c13f-4ecd-496f-b1d8-32ef1b6b60b7 | @Test
public void test() throws Exception{
System.out.println(wac.getBeanNamesForType(SessionScopeBean.class)[0]);
mockMvc.perform(get("/sessionScope/abc")).
andExpect(view().name("home")).
andExpect(request().sessionAttribute("scopedTarget.sessionScopeBean", hasProperty("value", is("abc"))));
} |
3c58207b-f0c8-4299-abef-ee2d7d229ef5 | @Bean
public RestTemplate getRestTemplate(){
return new RestTemplate();
} |
a0d7c30f-9391-4387-8a47-60b091ee9a74 | public SignalProcessor(){
listLock = new Object();
temporalList = new ArrayList<>();
temporalList.add(getRandomSignal());
temporalList.ensureCapacity(30);
} |
dc3270c3-0d6a-4eed-8d2f-71220121b4bc | public void insertSignal(int[] signal){
synchronized(listLock){
if(temporalList.size()>=30){
temporalList.remove(0);
}
System.out.println(signal[0]+" "+signal[1]+" "+signal[2]+" "+signal[3]);
temporalList.add(signal);
}
} |
2de0e035-c229-4209-8f72-a44136a9479c | public int[] getSample(){
ArrayList<int[]> temporalListClone;
synchronized(listLock){ temporalListClone = new ArrayList<>(temporalList); }
int[] avgSignal = new int[4];
for(int i = 0; i<temporalListClone.size(); i++){
int[] listSample = temporalListClone.get(i);
System.out.println(listSample[0]+" "+listSa... |
d41b4af4-bf41-4b4c-a900-37ac4f8337e6 | public static int[] getBlankSignal(){
int[] temp = new int[4];
temp[0]=0;
temp[1]=0;
temp[2]=0;
temp[3]=0;
return temp;
} |
28fde16f-9abb-45ec-9e24-9608612b2140 | public static int[] getRandomSignal(){
int[] temp = new int[4];
temp[0] = (int) Math.round(Math.random()*maxSignalValue);
temp[1] = (int) Math.round(Math.random()*maxSignalValue);
temp[2] = (int) Math.round(Math.random()*maxSignalValue);
temp[3] = (int) Math.round(Math.random()*maxSignalValue);
return temp;... |
8a0a5167-8f6c-4540-a509-a278f0ff0317 | public static int getMaxSignalValue(){
return maxSignalValue;
} |
2671ed72-4e29-43b4-baf8-52821b9d7f70 | public static void setMaxSignalValue(int value){
maxSignalValue = value;
} |
131b25ee-3a67-4f7d-944f-aac69899d51c | public static void main(String[] args) {
array[0] = a1;
array[1] = a2;
array[2] = a3;
array[3] = a4;
SignalProcessor sP = new SignalProcessor();
for(int i=0;i<40;i++){
sP.insertSignal(SignalProcessor.getRandomSignal());
}
int[] sample = sP.getSample();
System.out.print(sample[0]+" - ");
Sys... |
57db888b-e2d8-4151-9d44-fe0d401d54d5 | public static String doRecognition(int[] positions){
String bestMatchString = null;
float bestMatchPercentage = 0;
for(Gesture item : gestureList){
float variance = 0;
for(int i=0; i<4; i++){
variance += (float) Math.abs( item.getPosition(i) - positions[i]/(SignalProcessor.getMaxSignalValue()*0.01) );
... |
96eb4491-9397-49b7-b054-08f23bf96268 | public static void setMinimumMatchPercentage(int percentage){
minimumMatchPercentage = percentage;
} |
3b9b8a77-113b-48f2-8451-f165ac714376 | public Gesture(String inputName,int index,int middle,int ring,int pinkie){
name = inputName;
positions = new int[4];
positions[0] = index;
positions[1] = middle;
positions[2] = ring;
positions[3] = pinkie;
} |
19a1a394-21db-47f6-8720-185c70d3c7e4 | public String getName(){return name;} |
77dd21c2-d6e6-4957-a5d5-335d28a742fa | public int[] getPositions(){return positions;} |
8898b16b-9161-4699-a4df-7d33b8a7105f | public int getPosition(int index){
return positions[index];
} |
490a20c8-3a0b-4762-a24c-b1b9c441edef | public static synchronized void sayString(String str){
if(null == str || str.isEmpty()){
System.out.println("String Error");
} else {
try {
URL word = new URL("http://translate.google.com/translate_tts?ie=utf-8&tl=en&q="+str);
HttpURLConnection connection = (HttpURLConnection) word.openConnection();
... |
714cd2c9-8e93-498c-8c1f-24e2cff1a3e0 | public Deck () {
MAXCARDS = 52;
int i;
i = 0;
deck = new Card[MAXCARDS];
// initialize the deck with cards
for (Suit suit : Suit.values()) {
for (Rank rank : Rank.values()) {
if (i < MAXCARDS) {
deck[i++] = new Card(suit, rank);
}
}
}
} |
d4ef7d8b-c03f-4c8e-be61-0d35c6666702 | public void showDeck() {
for (int i=0; i < MAXCARDS; i++)
System.out.println(deck[i].getSuit().toString() + " of " + deck[i].getRank().toString());
} |
850042f5-9880-485c-9993-43f26dd91bb5 | public Card getRandomCard() {
Random rand = new Random();
int randint = Math.abs(rand.nextInt())%MAXCARDS;
return deck[randint];
} |
8d2d2fcd-2b72-4d13-a4ed-1da50e051a68 | public static void main (String[] arg) {
// initialize the deck
Deck mydeck = new Deck();
// display the deck for everyone to see
// mydeck.showDeck();
// blow away the deck
// mydeck = null;
// check to see if the deck is gone
// if true, let user know.
if (mydeck == null) {
System.out... |
c9c2bb78-3792-4664-bb50-64cd61cc46c4 | public static void main(String[] args) {
//Card mycard1;
// Card mycard2;
// Suit x_suit;
// Rank x_rank;
// mycard1 = new Card(Suit.HEARTS, Rank.DEUCE);
// mycard2 = mycard1.getCard();
// x_suit = mycard1.getSuit();
// x_rank = mycard2.getRank();
// System.out.println(x_suit.toString());
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.