blob_id stringlengths 40 40 | __id__ int64 225 39,780B | directory_id stringlengths 40 40 | path stringlengths 6 313 | content_id stringlengths 40 40 | detected_licenses list | license_type stringclasses 2
values | repo_name stringlengths 6 132 | repo_url stringlengths 25 151 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 70 | visit_date timestamp[ns] | revision_date timestamp[ns] | committer_date timestamp[ns] | github_id int64 7.28k 689M ⌀ | star_events_count int64 0 131k | fork_events_count int64 0 48k | gha_license_id stringclasses 23
values | gha_fork bool 2
classes | gha_event_created_at timestamp[ns] | gha_created_at timestamp[ns] | gha_updated_at timestamp[ns] | gha_pushed_at timestamp[ns] | gha_size int64 0 40.4M ⌀ | gha_stargazers_count int32 0 112k ⌀ | gha_forks_count int32 0 39.4k ⌀ | gha_open_issues_count int32 0 11k ⌀ | gha_language stringlengths 1 21 ⌀ | gha_archived bool 2
classes | gha_disabled bool 1
class | content stringlengths 7 4.37M | src_encoding stringlengths 3 16 | language stringclasses 1
value | length_bytes int64 7 4.37M | extension stringclasses 24
values | filename stringlengths 4 174 | language_id stringclasses 1
value | entities list | contaminating_dataset stringclasses 0
values | malware_signatures list | redacted_content stringlengths 7 4.37M | redacted_length_bytes int64 7 4.37M | alphanum_fraction float32 0.25 0.94 | alpha_fraction float32 0.25 0.94 | num_lines int32 1 84k | avg_line_length float32 0.76 99.9 | std_line_length float32 0 220 | max_line_length int32 5 998 | is_vendor bool 2
classes | is_generated bool 1
class | max_hex_length int32 0 319 | hex_fraction float32 0 0.38 | max_unicode_length int32 0 408 | unicode_fraction float32 0 0.36 | max_base64_length int32 0 506 | base64_fraction float32 0 0.5 | avg_csv_sep_count float32 0 4 | is_autogen_header bool 1
class | is_empty_html bool 1
class | shard stringclasses 16
values |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7992b4de1adc1eae3faab54eae0f486c3a009caf | 11,038,065,986,777 | d9bcb88222dfe0bf2e84226437dded21f00726b8 | /src/main/java/io/github/axle2005/commands/Register.java | f90e59b2dda68f87f872ff25c4365b6b30791af4 | [] | no_license | axle2005/SpigotCommandConverter | https://github.com/axle2005/SpigotCommandConverter | c19268619878fa15f664acce335453dbd7c7f31e | 71fbffe662d19f5801ae5b5d95a1975d0dbe3ec5 | refs/heads/master | 2021-01-11T07:59:26.608000 | 2016-10-28T13:27:22 | 2016-10-28T13:27:22 | 72,133,383 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.axle2005.commands;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.text.Text;
import io.github.axle2005.SpigotCommandConverter;
public class Register {
public Register(SpigotCommandConverter plugin) {
CommandSpec pex = CommandSpec.builder().permission("permissionsex").description(Text.of("Pex user commands"))
.arguments(
// GenericArguments.onlyOne(GenericArguments.string(Text.of("group|user"))),
GenericArguments.remainingJoinedStrings(Text.of("remaining")))
.executor(new Pex2(plugin)).build();
CommandSpec eco = CommandSpec.builder().permission("totaleconomy.command.adminpay").description(Text.of("Spigot Eco Command"))
.arguments(
// GenericArguments.onlyOne(GenericArguments.string(Text.of("group|user"))),
GenericArguments.remainingJoinedStrings(Text.of("<give><player><amount>")))
.executor(new Eco(plugin)).build();
Sponge.getCommandManager().register(plugin, pex, "scc", "pex");
Sponge.getCommandManager().register(plugin, eco, "eco");
}
}
| UTF-8 | Java | 1,192 | java | Register.java | Java | [
{
"context": "package io.github.axle2005.commands;\r\n\r\nimport org.spongepowered.api.Sponge;",
"end": 26,
"score": 0.9996029734611511,
"start": 18,
"tag": "USERNAME",
"value": "axle2005"
},
{
"context": ".spongepowered.api.text.Text;\r\n\r\nimport io.github.axle2005.SpigotCommandCo... | null | [] | package io.github.axle2005.commands;
import org.spongepowered.api.Sponge;
import org.spongepowered.api.command.args.GenericArguments;
import org.spongepowered.api.command.spec.CommandSpec;
import org.spongepowered.api.text.Text;
import io.github.axle2005.SpigotCommandConverter;
public class Register {
public Register(SpigotCommandConverter plugin) {
CommandSpec pex = CommandSpec.builder().permission("permissionsex").description(Text.of("Pex user commands"))
.arguments(
// GenericArguments.onlyOne(GenericArguments.string(Text.of("group|user"))),
GenericArguments.remainingJoinedStrings(Text.of("remaining")))
.executor(new Pex2(plugin)).build();
CommandSpec eco = CommandSpec.builder().permission("totaleconomy.command.adminpay").description(Text.of("Spigot Eco Command"))
.arguments(
// GenericArguments.onlyOne(GenericArguments.string(Text.of("group|user"))),
GenericArguments.remainingJoinedStrings(Text.of("<give><player><amount>")))
.executor(new Eco(plugin)).build();
Sponge.getCommandManager().register(plugin, pex, "scc", "pex");
Sponge.getCommandManager().register(plugin, eco, "eco");
}
}
| 1,192 | 0.737416 | 0.729866 | 29 | 39.103447 | 35.235508 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.448276 | false | false | 10 |
3dec848e2456558a2ecfe7ee76b962cc9df1725c | 28,965,259,495,246 | 3e49407ba02f64e4790cbcb7db2ef32a86e92742 | /facturator-libra-ejb/ejbModule/uy/com/tmwc/facturator/libra/entity/ParticipacionVendedorLPK.java | c32e2589868742cd9d72668a9a2806b66731aaf3 | [] | no_license | epirisroggero/facturador-server | https://github.com/epirisroggero/facturador-server | e8b01fea785d895cbedf975070ae0bc68043982d | df77ca2c608c2647eb777bddbf5d0dbca144313d | refs/heads/master | 2022-07-07T23:54:45.123000 | 2022-07-02T20:00:37 | 2022-07-02T20:00:37 | 129,334,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package uy.com.tmwc.facturator.libra.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class ParticipacionVendedorLPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "EmpId", length = 10)
private String empId;
@Column(name = "DocId")
private int docId;
@Column(name = "VenId", length = 3)
private String venId;
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public int getDocId() {
return this.docId;
}
public void setDocId(int docId) {
this.docId = docId;
}
public String getVenId() {
return this.venId;
}
public void setVenId(String venId) {
this.venId = venId;
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ParticipacionVendedorLPK)) {
return false;
}
ParticipacionVendedorLPK castOther = (ParticipacionVendedorLPK) other;
return this.empId.equals(castOther.empId) && this.docId == castOther.docId && this.venId.equals(castOther.venId);
}
public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + this.empId.hashCode();
hash = hash * prime + this.venId.hashCode();
hash = hash * prime + this.docId;
return hash;
}
} | UTF-8 | Java | 1,355 | java | ParticipacionVendedorLPK.java | Java | [] | null | [] | package uy.com.tmwc.facturator.libra.entity;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Embeddable;
@Embeddable
public class ParticipacionVendedorLPK implements Serializable {
private static final long serialVersionUID = 1L;
@Column(name = "EmpId", length = 10)
private String empId;
@Column(name = "DocId")
private int docId;
@Column(name = "VenId", length = 3)
private String venId;
public String getEmpId() {
return this.empId;
}
public void setEmpId(String empId) {
this.empId = empId;
}
public int getDocId() {
return this.docId;
}
public void setDocId(int docId) {
this.docId = docId;
}
public String getVenId() {
return this.venId;
}
public void setVenId(String venId) {
this.venId = venId;
}
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (!(other instanceof ParticipacionVendedorLPK)) {
return false;
}
ParticipacionVendedorLPK castOther = (ParticipacionVendedorLPK) other;
return this.empId.equals(castOther.empId) && this.docId == castOther.docId && this.venId.equals(castOther.venId);
}
public int hashCode() {
final int prime = 31;
int hash = 17;
hash = hash * prime + this.empId.hashCode();
hash = hash * prime + this.venId.hashCode();
hash = hash * prime + this.docId;
return hash;
}
} | 1,355 | 0.702583 | 0.696679 | 66 | 19.545454 | 21.330858 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.378788 | false | false | 10 |
ad3ccb8c1a1a79deabecbe7d2c0f446670e98b83 | 18,451,179,510,498 | 17810972d4dd27f923f6e0af36a52e76dd3d0b39 | /gustaf/Snake/src/Controller.java | a99fe2a3e3bb8378b9cfef199e7dea3b233fca8f | [] | no_license | maxbergmark/old-work | https://github.com/maxbergmark/old-work | a6b4e77e9f345f0f2f437c9f60d18aa4e2d4ddcb | beeded9b15acc612796fad880873aaa495653f71 | refs/heads/master | 2020-04-18T12:45:21.657000 | 2019-02-04T09:32:18 | 2019-02-04T09:32:18 | 167,543,304 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Controller extends JFrame implements ActionListener, KeyListener {
Timer timer;
SnakePanel panel;
int time, counter;
Window window;
Bot bot;
Snek snek;
boolean isPaused, speedUp, fixtime;
long nanoTime;
public Controller (int snakeLength, int gridSize, int gridLength, int time, boolean fade) {
isPaused = false;
speedUp = false;
fixtime = false;
counter = 0;
window = new Window(snakeLength, gridSize, this);
bot = new Bot(window);
snek = new Snek(window);
panel = new SnakePanel(window, gridLength, fade, this);
this.time = time;
timer = new Timer(time, this);
add(panel);
addKeyListener(this);
pack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
timer.start();
nanoTime = System.nanoTime();
}
@Override
public void actionPerformed(ActionEvent e) {
//bot.updateBot();
snek.updateBot();
if(counter % 10000 == 0 && speedUp) {
fixtime = true;
} else if (counter % 10000 == 0 && !speedUp) {
fixtime = false;
}
if(window.snake.checkSnake(window.snake.get(0))) {
counter++;
window.snake.updateSnake();
if( (fixtime && counter % 10000 == 0) || window.score > window.grid.length * window.grid[0].length ) {
panel.repaint();
} else if (!fixtime) {
panel.repaint();
}
} else {
panel.repaint();
System.out.println(window.snake.get(0).x + " " + window.snake.get(0).y + " " +
window.snake.direction + " " + snek.why + " " + window.goal.x + " " + window.goal.y);
timer.stop();
if(window.score > window.grid.length * window.grid[0].length) {
System.out.println("SUCCESS! COUNTER: " + counter + " TIME: " + (System.nanoTime() - nanoTime)/1e9);
} else {
System.out.println("FAILURE! COUNTER: " + counter);
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_UP && window.snake.get(0).y - 1 != window.snake.get(1).y) {
window.snake.direction = 0;
}
if (key == KeyEvent.VK_RIGHT && window.snake.get(0).x + 1 != window.snake.get(1).x) {
window.snake.direction = 1;
}
if (key == KeyEvent.VK_DOWN && window.snake.get(0).y + 1 != window.snake.get(1).y) {
window.snake.direction = 2;
}
if (key == KeyEvent.VK_LEFT && window.snake.get(0).x - 1 != window.snake.get(1).x) {
window.snake.direction = 3;
}
if (key == KeyEvent.VK_SPACE) {
if(isPaused) {
timer.start();
isPaused = false;
} else {
timer.stop();
isPaused = true;
}
}
if (key == KeyEvent.VK_S) {
speedUp = !speedUp;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
| UTF-8 | Java | 3,528 | java | Controller.java | Java | [] | null | [] | import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
public class Controller extends JFrame implements ActionListener, KeyListener {
Timer timer;
SnakePanel panel;
int time, counter;
Window window;
Bot bot;
Snek snek;
boolean isPaused, speedUp, fixtime;
long nanoTime;
public Controller (int snakeLength, int gridSize, int gridLength, int time, boolean fade) {
isPaused = false;
speedUp = false;
fixtime = false;
counter = 0;
window = new Window(snakeLength, gridSize, this);
bot = new Bot(window);
snek = new Snek(window);
panel = new SnakePanel(window, gridLength, fade, this);
this.time = time;
timer = new Timer(time, this);
add(panel);
addKeyListener(this);
pack();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
timer.start();
nanoTime = System.nanoTime();
}
@Override
public void actionPerformed(ActionEvent e) {
//bot.updateBot();
snek.updateBot();
if(counter % 10000 == 0 && speedUp) {
fixtime = true;
} else if (counter % 10000 == 0 && !speedUp) {
fixtime = false;
}
if(window.snake.checkSnake(window.snake.get(0))) {
counter++;
window.snake.updateSnake();
if( (fixtime && counter % 10000 == 0) || window.score > window.grid.length * window.grid[0].length ) {
panel.repaint();
} else if (!fixtime) {
panel.repaint();
}
} else {
panel.repaint();
System.out.println(window.snake.get(0).x + " " + window.snake.get(0).y + " " +
window.snake.direction + " " + snek.why + " " + window.goal.x + " " + window.goal.y);
timer.stop();
if(window.score > window.grid.length * window.grid[0].length) {
System.out.println("SUCCESS! COUNTER: " + counter + " TIME: " + (System.nanoTime() - nanoTime)/1e9);
} else {
System.out.println("FAILURE! COUNTER: " + counter);
}
}
}
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
int key = e.getKeyCode();
if (key == KeyEvent.VK_UP && window.snake.get(0).y - 1 != window.snake.get(1).y) {
window.snake.direction = 0;
}
if (key == KeyEvent.VK_RIGHT && window.snake.get(0).x + 1 != window.snake.get(1).x) {
window.snake.direction = 1;
}
if (key == KeyEvent.VK_DOWN && window.snake.get(0).y + 1 != window.snake.get(1).y) {
window.snake.direction = 2;
}
if (key == KeyEvent.VK_LEFT && window.snake.get(0).x - 1 != window.snake.get(1).x) {
window.snake.direction = 3;
}
if (key == KeyEvent.VK_SPACE) {
if(isPaused) {
timer.start();
isPaused = false;
} else {
timer.stop();
isPaused = true;
}
}
if (key == KeyEvent.VK_S) {
speedUp = !speedUp;
}
}
@Override
public void keyReleased(KeyEvent e) {
}
}
| 3,528 | 0.509637 | 0.497732 | 105 | 31.6 | 27.01132 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.657143 | false | false | 10 |
0cec1d700ba068eb8a7d6db4d28e49b1787bac16 | 13,889,924,242,076 | 9309a4e2a799515f0fdb20d592e94cf9ac668770 | /app/src/main/java/kz/ltd/gamer/Main/TabPageThreeDisk.java | 74989fe6485ae940084350a13a115af07bef81ca | [] | no_license | GamerOrg/GamerApp | https://github.com/GamerOrg/GamerApp | 1886c71ac16e08228e9790cddeb5c64161431967 | c97dc5578e8836ba21317423323c8b675d85caed | refs/heads/master | 2018-01-08T02:01:48.485000 | 2015-11-01T16:37:59 | 2015-11-01T16:37:59 | 43,649,486 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kz.ltd.gamer.Main;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import kz.ltd.gamer.R;
public class TabPageThreeDisk extends FragmentActivity implements View.OnClickListener {
public FragmentTabHost mTabHost;
private TextView txtTitle;
private Typeface fontHelveticaNeueLight;
private Typeface fontHelveticaNeueCondensedBold;
public ImageButton btnMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_page_three_disk);
fontHelveticaNeueLight = Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeueLight.ttf");
fontHelveticaNeueCondensedBold = Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeueCondensedBold.ttf");
txtTitle = (TextView) findViewById(R.id.txtTitle);
txtTitle.setText(getString(R.string.my_disc));
txtTitle.setTypeface(fontHelveticaNeueLight);
btnMenu = (ImageButton) findViewById(R.id.btnMenu);
btnMenu.setOnClickListener(this);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("t").setIndicator(getString(R.string.my_disc), null),
DiscMy.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("t2").setIndicator(getString(R.string.my_wanted_disc), null),
DiscAboutIWanted.class, null);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnMenu:
startActivity(new Intent(TabPageThreeDisk.this, DiscSearch.class));
break;
}
}
} | UTF-8 | Java | 2,048 | java | TabPageThreeDisk.java | Java | [] | null | [] | package kz.ltd.gamer.Main;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTabHost;
import android.view.View;
import android.widget.ImageButton;
import android.widget.TextView;
import kz.ltd.gamer.R;
public class TabPageThreeDisk extends FragmentActivity implements View.OnClickListener {
public FragmentTabHost mTabHost;
private TextView txtTitle;
private Typeface fontHelveticaNeueLight;
private Typeface fontHelveticaNeueCondensedBold;
public ImageButton btnMenu;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.tab_page_three_disk);
fontHelveticaNeueLight = Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeueLight.ttf");
fontHelveticaNeueCondensedBold = Typeface.createFromAsset(getAssets(), "fonts/HelveticaNeueCondensedBold.ttf");
txtTitle = (TextView) findViewById(R.id.txtTitle);
txtTitle.setText(getString(R.string.my_disc));
txtTitle.setTypeface(fontHelveticaNeueLight);
btnMenu = (ImageButton) findViewById(R.id.btnMenu);
btnMenu.setOnClickListener(this);
mTabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
mTabHost.setup(this, getSupportFragmentManager(), android.R.id.tabcontent);
mTabHost.addTab(
mTabHost.newTabSpec("t").setIndicator(getString(R.string.my_disc), null),
DiscMy.class, null);
mTabHost.addTab(
mTabHost.newTabSpec("t2").setIndicator(getString(R.string.my_wanted_disc), null),
DiscAboutIWanted.class, null);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnMenu:
startActivity(new Intent(TabPageThreeDisk.this, DiscSearch.class));
break;
}
}
} | 2,048 | 0.706543 | 0.70459 | 58 | 34.327587 | 29.640017 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.724138 | false | false | 10 |
bbf0c7d3bd9ff96c4a4faf139dda23dcd5b2b379 | 4,664,334,529,910 | 35ff52502b4fb2449b6165e379d1fa04177b5b66 | /app/src/main/java/com/example/android/tour_guide_app/TopAttractionsActivity.java | 00a1c0cabb9bc1c67c06b6409d7223b8e2da4001 | [] | no_license | luciancroitoru/Tour_Guide_App | https://github.com/luciancroitoru/Tour_Guide_App | d693992b2efc4f6ea6e05bdff8084130ce5b21a5 | d9e9480126359703665e1f105eda1623ea1a62be | refs/heads/master | 2020-12-03T08:14:35.729000 | 2017-06-30T12:10:59 | 2017-06-30T12:11:02 | 95,674,293 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.android.tour_guide_app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
public class TopAttractionsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_list);
// Create an array of words
final ArrayList<Location> locations = new ArrayList<Location>();
locations.add(new Location(getString(R.string.ta_attraction_one_name), getString(R.string.ta_attraction_one_address), R.drawable.ta_palace_of_parliament));
locations.add(new Location(getString(R.string.ta_attraction_two_name), getString(R.string.ta_attraction_two_address), R.drawable.ta_cismigiu_gardens));
locations.add(new Location(getString(R.string.ta_attraction_three_name), getString(R.string.ta_attraction_three_address), R.drawable.ta_grigore_antipa));
locations.add(new Location(getString(R.string.ta_attraction_four_name), getString(R.string.ta_attraction_four_address), R.drawable.ta_herastrau_park));
locations.add(new Location(getString(R.string.ta_attraction_five_name), getString(R.string.ta_attraction_five_address), R.drawable.ta_old_town));
locations.add(new Location(getString(R.string.ta_attraction_six_name), getString(R.string.ta_attraction_six_address), R.drawable.ta_revolution_square));
locations.add(new Location(getString(R.string.ta_attraction_seven_name), getString(R.string.ta_attraction_seven_address), R.drawable.ta_spring_pallace));
locations.add(new Location(getString(R.string.ta_attraction_eight_name), getString(R.string.ta_attraction_eight_address), R.drawable.ta_stavropoleos_church));
locations.add(new Location(getString(R.string.ta_attraction_nine_name), getString(R.string.ta_attraction_nine_address), R.drawable.ta_victoriei_street));
locations.add(new Location(getString(R.string.ta_attraction_ten_name), getString(R.string.ta_attraction_ten_address), R.drawable.ta_village_museum));
// Create an {@link ArrayAdapter}, whose data source is a list of Strings. The
// adapter knows how to create layouts for each item in the list, using the
// simple_list_item_1.xml layout resource defined in the Android framework.
// This list item layout contains a single {@link TextView}, which the adapter will set to
// display a single word.
LocationAdapter adapter =
new LocationAdapter(this, locations, R.color.category_top_attractions);
// Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
// There should be a {@link ListView} with the view ID called list, which is declared in the
// word_listyout file.
ListView listView = (ListView) findViewById(R.id.list);
// Make the {@link ListView} use the {@link ArrayAdapter} we created above, so that the
// {@link ListView} will display list items for each word in the list of words.
// Do this by calling the setAdapter method on the {@link ListView} object and pass in
// 1 argument, which is the {@link ArrayAdapter} with the variable name itemsAdapter.
listView.setAdapter(adapter);
}
} | UTF-8 | Java | 3,351 | java | TopAttractionsActivity.java | Java | [] | null | [] | package com.example.android.tour_guide_app;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.ListView;
import java.util.ArrayList;
public class TopAttractionsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.location_list);
// Create an array of words
final ArrayList<Location> locations = new ArrayList<Location>();
locations.add(new Location(getString(R.string.ta_attraction_one_name), getString(R.string.ta_attraction_one_address), R.drawable.ta_palace_of_parliament));
locations.add(new Location(getString(R.string.ta_attraction_two_name), getString(R.string.ta_attraction_two_address), R.drawable.ta_cismigiu_gardens));
locations.add(new Location(getString(R.string.ta_attraction_three_name), getString(R.string.ta_attraction_three_address), R.drawable.ta_grigore_antipa));
locations.add(new Location(getString(R.string.ta_attraction_four_name), getString(R.string.ta_attraction_four_address), R.drawable.ta_herastrau_park));
locations.add(new Location(getString(R.string.ta_attraction_five_name), getString(R.string.ta_attraction_five_address), R.drawable.ta_old_town));
locations.add(new Location(getString(R.string.ta_attraction_six_name), getString(R.string.ta_attraction_six_address), R.drawable.ta_revolution_square));
locations.add(new Location(getString(R.string.ta_attraction_seven_name), getString(R.string.ta_attraction_seven_address), R.drawable.ta_spring_pallace));
locations.add(new Location(getString(R.string.ta_attraction_eight_name), getString(R.string.ta_attraction_eight_address), R.drawable.ta_stavropoleos_church));
locations.add(new Location(getString(R.string.ta_attraction_nine_name), getString(R.string.ta_attraction_nine_address), R.drawable.ta_victoriei_street));
locations.add(new Location(getString(R.string.ta_attraction_ten_name), getString(R.string.ta_attraction_ten_address), R.drawable.ta_village_museum));
// Create an {@link ArrayAdapter}, whose data source is a list of Strings. The
// adapter knows how to create layouts for each item in the list, using the
// simple_list_item_1.xml layout resource defined in the Android framework.
// This list item layout contains a single {@link TextView}, which the adapter will set to
// display a single word.
LocationAdapter adapter =
new LocationAdapter(this, locations, R.color.category_top_attractions);
// Find the {@link ListView} object in the view hierarchy of the {@link Activity}.
// There should be a {@link ListView} with the view ID called list, which is declared in the
// word_listyout file.
ListView listView = (ListView) findViewById(R.id.list);
// Make the {@link ListView} use the {@link ArrayAdapter} we created above, so that the
// {@link ListView} will display list items for each word in the list of words.
// Do this by calling the setAdapter method on the {@link ListView} object and pass in
// 1 argument, which is the {@link ArrayAdapter} with the variable name itemsAdapter.
listView.setAdapter(adapter);
}
} | 3,351 | 0.726649 | 0.725753 | 51 | 64.725487 | 56.987469 | 166 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.960784 | false | false | 10 |
8de42bf50a58924c92403257edaa40ccd849d68a | 7,679,401,550,426 | 7e65f5a9a85d10bea5336a910266b32279aefcb5 | /blackjack_java/BlackJack/view/IView.java | 114b186c3fd3a30ee532b0fa2ec2f643733e7ec1 | [] | no_license | dargiriou/1dv607-BlackJack | https://github.com/dargiriou/1dv607-BlackJack | 603c09136acb7d5cf1cb3e3eb9a78d3cb7cb1f08 | d6668d39d6e11994303b881101c19e2ac5f4bc83 | refs/heads/master | 2021-09-03T19:47:53.322000 | 2018-01-11T13:36:09 | 2018-01-11T13:36:09 | 108,743,116 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package BlackJack.view;
public interface IView
{
enum EnumInput{play,hit,stand,quit};
EnumInput GetEnumInput();
void DisplayWelcomeMessage();
void DisplayCard(BlackJack.model.Card a_card);
void DisplayPlayerHand(Iterable<BlackJack.model.Card> a_hand, int a_score);
void DisplayDealerHand(Iterable<BlackJack.model.Card> a_hand, int a_score);
void DisplayGameOver(boolean a_dealerIsWinner);
void CreateSpace();
void DisplayInstructions();
void DisplayRules();
} | UTF-8 | Java | 480 | java | IView.java | Java | [] | null | [] | package BlackJack.view;
public interface IView
{
enum EnumInput{play,hit,stand,quit};
EnumInput GetEnumInput();
void DisplayWelcomeMessage();
void DisplayCard(BlackJack.model.Card a_card);
void DisplayPlayerHand(Iterable<BlackJack.model.Card> a_hand, int a_score);
void DisplayDealerHand(Iterable<BlackJack.model.Card> a_hand, int a_score);
void DisplayGameOver(boolean a_dealerIsWinner);
void CreateSpace();
void DisplayInstructions();
void DisplayRules();
} | 480 | 0.770833 | 0.770833 | 15 | 31.066668 | 23.095358 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.066667 | false | false | 10 |
ae44e7792671bd6a2bf1e68eb53c9027e7d4b584 | 8,229,157,369,704 | 961784d9373c696120b949575e680421bca695ad | /app/src/main/java/com/cxgm/app/data/io/goods/SearchReq.java | 88dbf327235d83e661fbf3efa76dce21fe2d4b4f | [] | no_license | cxgmTeam/Cxgm_android | https://github.com/cxgmTeam/Cxgm_android | 72543844f30ead3cf8ce8e54121b18deac8002f0 | 31246a24008f6abb8e9aafedc97652801489f978 | refs/heads/master | 2021-05-26T05:46:29.134000 | 2018-10-15T05:39:50 | 2018-10-15T05:39:50 | 127,717,080 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.cxgm.app.data.io.goods;
import android.content.Context;
import com.alibaba.fastjson.JSON;
import com.cxgm.app.app.Constants;
import com.cxgm.app.app.UserResult;
import com.cxgm.app.data.entity.ProductTransfer;
import com.cxgm.app.data.entity.base.PageInfo;
import com.deanlib.ootb.data.io.Request;
import org.xutils.http.HttpMethod;
import org.xutils.http.RequestParams;
/**
* 根据门店ID查询首页新品上市
*
* @author dean
* @time 2018/5/29 上午11:06
*/
public class SearchReq extends Request {
int shopId;
String goodName;
public SearchReq(Context context,int shopId,String goodName) {
super(context);
this.shopId = shopId;
this.goodName = goodName;
}
@Override
public String getName() {
return getClass().getSimpleName();
}
@Override
public RequestParams params() {
RequestParams params = new RequestParams(SERVER + Constants.PORT2 + "/homePage/serch");
params.setMethod(HttpMethod.GET);
params.addQueryStringParameter("shopId",shopId+"");
params.addQueryStringParameter("goodName",goodName);
return params;
}
@Override
public PageInfo<ProductTransfer> parse(String json) {
UserResult<PageInfo<ProductTransfer>> result = JSON.parseObject(json,new UserResult<PageInfo<ProductTransfer>>(){}.getEntityType());
return result.data;
}
}
| UTF-8 | Java | 1,410 | java | SearchReq.java | Java | [
{
"context": "equestParams;\n\n/**\n * 根据门店ID查询首页新品上市\n *\n * @author dean\n * @time 2018/5/29 上午11:06\n */\npublic class Searc",
"end": 427,
"score": 0.9775766134262085,
"start": 423,
"tag": "USERNAME",
"value": "dean"
}
] | null | [] | package com.cxgm.app.data.io.goods;
import android.content.Context;
import com.alibaba.fastjson.JSON;
import com.cxgm.app.app.Constants;
import com.cxgm.app.app.UserResult;
import com.cxgm.app.data.entity.ProductTransfer;
import com.cxgm.app.data.entity.base.PageInfo;
import com.deanlib.ootb.data.io.Request;
import org.xutils.http.HttpMethod;
import org.xutils.http.RequestParams;
/**
* 根据门店ID查询首页新品上市
*
* @author dean
* @time 2018/5/29 上午11:06
*/
public class SearchReq extends Request {
int shopId;
String goodName;
public SearchReq(Context context,int shopId,String goodName) {
super(context);
this.shopId = shopId;
this.goodName = goodName;
}
@Override
public String getName() {
return getClass().getSimpleName();
}
@Override
public RequestParams params() {
RequestParams params = new RequestParams(SERVER + Constants.PORT2 + "/homePage/serch");
params.setMethod(HttpMethod.GET);
params.addQueryStringParameter("shopId",shopId+"");
params.addQueryStringParameter("goodName",goodName);
return params;
}
@Override
public PageInfo<ProductTransfer> parse(String json) {
UserResult<PageInfo<ProductTransfer>> result = JSON.parseObject(json,new UserResult<PageInfo<ProductTransfer>>(){}.getEntityType());
return result.data;
}
}
| 1,410 | 0.699711 | 0.691028 | 50 | 26.639999 | 26.553915 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.56 | false | false | 10 |
ceef20d378bf2d20b9ac71c6a7c21941e02d7c0a | 17,145,509,477,860 | db2b991e66fd6d16346c3780ef1cd6542beb3667 | /commons-api/src/main/java/net/lc4ever/framework/dao/GenericDaoStatistics.java | ade3976c8358c8374fdc9ba2dbf1757afbec3bdf | [
"MIT"
] | permissive | ronghua49/pc_ftk-server | https://github.com/ronghua49/pc_ftk-server | 45a844b7355627d8a627ac46c5ae1b4a0296bb70 | 1395568d475d92a5936da0ba944e95f951058017 | refs/heads/master | 2020-04-13T23:59:23.634000 | 2019-01-16T02:46:16 | 2019-01-16T02:46:16 | 163,521,538 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* MIT License
*
* Copyright (c) 2008-2017 q-wang, <apeidou@gmail.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.lc4ever.framework.dao;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
*
* @revision $Revision:$
* @author <a href="mailto:apeidou@gmail.com">Q-Wang</a>
*/
@SuppressWarnings("rawtypes")
public class GenericDaoStatistics {
private long start = System.currentTimeMillis();
public static class Cost implements Serializable {
private long count;
private long cost;
public synchronized void cost(final long cost) {
count++;
this.cost += cost;
}
public long avg() {
return count == 0 ? 0 : cost / count;
}
public long getCount() {
return count;
}
public long getCost() {
return cost;
}
public synchronized void reset() {
this.cost = 0;
this.count = 0;
}
@Override
public String toString() {
return "Cost [count=" + count + ", cost=" + cost + ", avg=" + avg() + "]";
}
}
// List<E> list(Class<E> clazz)
private GenericDaoStatistics.Cost listCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> list = new HashMap<Class, GenericDaoStatistics.Cost>();
public void listCost(final Class clazz, final long cost) {
listCost.cost(cost);
Cost classCost = list.get(clazz);
if (classCost == null) {
classCost = new Cost();
list.put(clazz, classCost);
}
classCost.cost(cost);
}
// E get(Class<E> clazz, ID id)
private GenericDaoStatistics.Cost getCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> get = new HashMap<Class, GenericDaoStatistics.Cost>();
public void getCost(final Class clazz, final long cost) {
getCost.cost(cost);
Cost classCost = get.get(clazz);
if (classCost == null) {
classCost = new Cost();
get.put(clazz, classCost);
}
classCost.cost(cost);
}
// void delete(E entity)
private GenericDaoStatistics.Cost deleteCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> delete = new HashMap<Class, GenericDaoStatistics.Cost>();
public void deleteCost(final Class clazz, final long cost) {
deleteCost.cost(cost);
Cost classCost = delete.get(clazz);
if (classCost == null) {
classCost = new Cost();
delete.put(clazz, classCost);
}
classCost.cost(cost);
}
// ID save(E entity)
private GenericDaoStatistics.Cost saveCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> save = new HashMap<Class, GenericDaoStatistics.Cost>();
public void saveCost(final Class clazz, final long cost) {
saveCost.cost(cost);
Cost classCost = save.get(clazz);
if (classCost == null) {
classCost = new Cost();
save.put(clazz, classCost);
}
classCost.cost(cost);
}
// void update(E entity)
private GenericDaoStatistics.Cost updateCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> update = new HashMap<Class, GenericDaoStatistics.Cost>();
public void updateCost(final Class clazz, final long cost) {
updateCost.cost(cost);
Cost classCost = update.get(clazz);
if (classCost == null) {
classCost = new Cost();
update.put(clazz, classCost);
}
classCost.cost(cost);
}
// void saveOrUpdate(E entity)
private GenericDaoStatistics.Cost saveOrUpdateCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> saveOrUpdate = new HashMap<Class, GenericDaoStatistics.Cost>();
public void saveOrUpdateCost(final Class clazz, final long cost) {
saveOrUpdateCost.cost(cost);
Cost classCost = saveOrUpdate.get(clazz);
if (classCost == null) {
classCost = new Cost();
saveOrUpdate.put(clazz, classCost);
}
classCost.cost(cost);
}
// long count(Class<E> clazz)
private GenericDaoStatistics.Cost countCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> count = new HashMap<Class, GenericDaoStatistics.Cost>();
public void countCost(final Class clazz, final long cost) {
countCost.cost(cost);
Cost classCost = count.get(clazz);
if (classCost == null) {
classCost = new Cost();
count.put(clazz, classCost);
}
classCost.cost(cost);
}
// Pager<T> page(Pager<T> pager)
private GenericDaoStatistics.Cost pageCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> page = new HashMap<String, GenericDaoStatistics.Cost>();
public void pageCost(final String key, final long cost) {
pageCost.cost(cost);
Cost classCost = page.get(key);
if (classCost == null) {
classCost = new Cost();
page.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> hql(String hql, Object... args)
private GenericDaoStatistics.Cost hqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> hql = new HashMap<String, GenericDaoStatistics.Cost>();
public void hqlCost(final String key, final long cost) {
hqlCost.cost(cost);
Cost classCost = hql.get(key);
if (classCost == null) {
classCost = new Cost();
hql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> List<T> hql(Class<T> expectType, String hql, Object... args)
private GenericDaoStatistics.Cost hqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> hqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void hqlClassCost(final String key, final long cost) {
hqlClassCost.cost(cost);
Cost classCost = hqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
hqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> sql(final String sql, final Object... args)
private GenericDaoStatistics.Cost sqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> sql = new HashMap<String, GenericDaoStatistics.Cost>();
public void sqlCost(final String key, final long cost) {
sqlCost.cost(cost);
Cost classCost = sql.get(key);
if (classCost == null) {
classCost = new Cost();
sql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> List<T> sql(Class<T> expectType, final String sql, final Object... args)
private GenericDaoStatistics.Cost sqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> sqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void sqlClassCost(final String key, final long cost) {
sqlClassCost.cost(cost);
Cost classCost = sqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
sqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object uniqueResultHql(String hql, Object... args)
private GenericDaoStatistics.Cost uniqueResultHqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultHql = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultHqlCost(final String key, final long cost) {
uniqueResultHqlCost.cost(cost);
Cost classCost = uniqueResultHql.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultHql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T uniqueResultHql(Class<T> expectType, String hql, Object... args)
private GenericDaoStatistics.Cost uniqueResultHqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultHqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultHqlClassCost(final String key, final long cost) {
uniqueResultHqlClassCost.cost(cost);
Cost classCost = uniqueResultHqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultHqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object uniqueResultSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost uniqueResultSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultSqlCost(final String key, final long cost) {
uniqueResultSqlCost.cost(cost);
Cost classCost = uniqueResultSql.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultSql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T uniqueResultSql(Class<T> expectType, final String sql, final Object... args);
private GenericDaoStatistics.Cost uniqueResultSqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultSqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultSqlClassCost(final String key, final long cost) {
uniqueResultSqlClassCost.cost(cost);
Cost classCost = uniqueResultSqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultSqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> criteria(DetachedCriteria criteria);
private GenericDaoStatistics.Cost criteriaCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> criteria = new HashMap<Class, GenericDaoStatistics.Cost>();
public void criteriaCost(final Class clazz, final long cost) {
criteriaCost.cost(cost);
Cost classCost = criteria.get(clazz);
if (classCost == null) {
classCost = new Cost();
criteria.put(clazz, classCost);
}
classCost.cost(cost);
}
// <T> T callback(HibernateCallback<T> callback);
private GenericDaoStatistics.Cost callbackCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> callback = new HashMap<Class, GenericDaoStatistics.Cost>();
public void callbackCost(final Class clazz, final long cost) {
callbackCost.cost(cost);
Cost classCost = callback.get(clazz);
if (classCost == null) {
classCost = new Cost();
callback.put(clazz, classCost);
}
classCost.cost(cost);
}
// Object topResultHql(final String hql, final Object... args);
private GenericDaoStatistics.Cost topResultHqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultHql = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultHqlCost(final String key, final long cost) {
topResultHqlCost.cost(cost);
Cost classCost = topResultHql.get(key);
if (classCost == null) {
classCost = new Cost();
topResultHql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T topResultHql(Class<T> clazz, final String hql, final Object... args);
private GenericDaoStatistics.Cost topResultHqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultHqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultHqlClassCost(final String key, final long cost) {
topResultHqlClassCost.cost(cost);
Cost classCost = topResultHqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
topResultHqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object topResultSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost topResultSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultSqlCost(final String key, final long cost) {
topResultSqlCost.cost(cost);
Cost classCost = topResultSql.get(key);
if (classCost == null) {
classCost = new Cost();
topResultSql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T topResultSql(Class<T> clazz, final String sql, final Object... args);
private GenericDaoStatistics.Cost topResultSqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultSqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultSqlClassCost(final String key, final long cost) {
topResultSqlClassCost.cost(cost);
Cost classCost = topResultSqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
topResultSqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// <T> Iterator<T> iterate(Class<T> clazz, final String hql, final Object... args);
private GenericDaoStatistics.Cost iterateCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> iterate = new HashMap<String, GenericDaoStatistics.Cost>();
public void iterateCost(final String key, final long cost) {
iterateCost.cost(cost);
Cost classCost = iterate.get(key);
if (classCost == null) {
classCost = new Cost();
iterate.put(key, classCost);
}
classCost.cost(cost);
}
// void closeIterator(Iterator<?> iterator);
private GenericDaoStatistics.Cost closeIteratorCost = new Cost();
public void closeIterator(final long cost) {
closeIteratorCost.cost(cost);
}
// int bulkUpdate(String hql, Object... args);
private GenericDaoStatistics.Cost bulkUpdateCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> bulkUpdate = new HashMap<String, GenericDaoStatistics.Cost>();
public void bulkUpdateCost(final String key, final long cost) {
bulkUpdateCost.cost(cost);
Cost classCost = bulkUpdate.get(key);
if (classCost == null) {
classCost = new Cost();
bulkUpdate.put(key, classCost);
}
classCost.cost(cost);
}
// int bulkUpdateSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost bulkUpdateSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> bulkUpdateSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void bulkUpdateSqlCost(final String key, final long cost) {
bulkUpdateSqlCost.cost(cost);
Cost classCost = bulkUpdateSql.get(key);
if (classCost == null) {
classCost = new Cost();
bulkUpdateSql.put(key, classCost);
}
classCost.cost(cost);
}
/**
* @return the start
*/
public long getStart() {
return start;
}
/**
* @return the listCost
*/
public GenericDaoStatistics.Cost getListCost() {
return listCost;
}
/**
* @return the list
*/
public Map<Class, GenericDaoStatistics.Cost> getList() {
return list;
}
/**
* @return the getCost
*/
public GenericDaoStatistics.Cost getGetCost() {
return getCost;
}
/**
* @return the get
*/
public Map<Class, GenericDaoStatistics.Cost> getGet() {
return get;
}
/**
* @return the deleteCost
*/
public GenericDaoStatistics.Cost getDeleteCost() {
return deleteCost;
}
/**
* @return the delete
*/
public Map<Class, GenericDaoStatistics.Cost> getDelete() {
return delete;
}
/**
* @return the saveCost
*/
public GenericDaoStatistics.Cost getSaveCost() {
return saveCost;
}
/**
* @return the save
*/
public Map<Class, GenericDaoStatistics.Cost> getSave() {
return save;
}
/**
* @return the updateCost
*/
public GenericDaoStatistics.Cost getUpdateCost() {
return updateCost;
}
/**
* @return the update
*/
public Map<Class, GenericDaoStatistics.Cost> getUpdate() {
return update;
}
/**
* @return the saveOrUpdateCost
*/
public GenericDaoStatistics.Cost getSaveOrUpdateCost() {
return saveOrUpdateCost;
}
/**
* @return the saveOrUpdate
*/
public Map<Class, GenericDaoStatistics.Cost> getSaveOrUpdate() {
return saveOrUpdate;
}
/**
* @return the countCost
*/
public GenericDaoStatistics.Cost getCountCost() {
return countCost;
}
/**
* @return the count
*/
public Map<Class, GenericDaoStatistics.Cost> getCount() {
return count;
}
/**
* @return the pageCost
*/
public GenericDaoStatistics.Cost getPageCost() {
return pageCost;
}
/**
* @return the page
*/
public Map<String, GenericDaoStatistics.Cost> getPage() {
return page;
}
/**
* @return the hqlCost
*/
public GenericDaoStatistics.Cost getHqlCost() {
return hqlCost;
}
/**
* @return the hql
*/
public Map<String, GenericDaoStatistics.Cost> getHql() {
return hql;
}
/**
* @return the hqlClassCost
*/
public GenericDaoStatistics.Cost getHqlClassCost() {
return hqlClassCost;
}
/**
* @return the hqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getHqlClass() {
return hqlClass;
}
/**
* @return the sqlCost
*/
public GenericDaoStatistics.Cost getSqlCost() {
return sqlCost;
}
/**
* @return the sql
*/
public Map<String, GenericDaoStatistics.Cost> getSql() {
return sql;
}
/**
* @return the sqlClassCost
*/
public GenericDaoStatistics.Cost getSqlClassCost() {
return sqlClassCost;
}
/**
* @return the sqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getSqlClass() {
return sqlClass;
}
/**
* @return the uniqueResultHqlCost
*/
public GenericDaoStatistics.Cost getUniqueResultHqlCost() {
return uniqueResultHqlCost;
}
/**
* @return the uniqueResultHql
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultHql() {
return uniqueResultHql;
}
/**
* @return the uniqueResultHqlClassCost
*/
public GenericDaoStatistics.Cost getUniqueResultHqlClassCost() {
return uniqueResultHqlClassCost;
}
/**
* @return the uniqueResultHqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultHqlClass() {
return uniqueResultHqlClass;
}
/**
* @return the uniqueResultSqlCost
*/
public GenericDaoStatistics.Cost getUniqueResultSqlCost() {
return uniqueResultSqlCost;
}
/**
* @return the uniqueResultSql
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultSql() {
return uniqueResultSql;
}
/**
* @return the uniqueResultSqlClassCost
*/
public GenericDaoStatistics.Cost getUniqueResultSqlClassCost() {
return uniqueResultSqlClassCost;
}
/**
* @return the uniqueResultSqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultSqlClass() {
return uniqueResultSqlClass;
}
/**
* @return the criteriaCost
*/
public GenericDaoStatistics.Cost getCriteriaCost() {
return criteriaCost;
}
/**
* @return the criteria
*/
public Map<Class, GenericDaoStatistics.Cost> getCriteria() {
return criteria;
}
/**
* @return the callbackCost
*/
public GenericDaoStatistics.Cost getCallbackCost() {
return callbackCost;
}
/**
* @return the callback
*/
public Map<Class, GenericDaoStatistics.Cost> getCallback() {
return callback;
}
/**
* @return the topResultHqlCost
*/
public GenericDaoStatistics.Cost getTopResultHqlCost() {
return topResultHqlCost;
}
/**
* @return the topResultHql
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultHql() {
return topResultHql;
}
/**
* @return the topResultHqlClassCost
*/
public GenericDaoStatistics.Cost getTopResultHqlClassCost() {
return topResultHqlClassCost;
}
/**
* @return the topResultHqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultHqlClass() {
return topResultHqlClass;
}
/**
* @return the topResultSqlCost
*/
public GenericDaoStatistics.Cost getTopResultSqlCost() {
return topResultSqlCost;
}
/**
* @return the topResultSql
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultSql() {
return topResultSql;
}
/**
* @return the topResultSqlClassCost
*/
public GenericDaoStatistics.Cost getTopResultSqlClassCost() {
return topResultSqlClassCost;
}
/**
* @return the topResultSqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultSqlClass() {
return topResultSqlClass;
}
/**
* @return the iterateCost
*/
public GenericDaoStatistics.Cost getIterateCost() {
return iterateCost;
}
/**
* @return the iterate
*/
public Map<String, GenericDaoStatistics.Cost> getIterate() {
return iterate;
}
/**
* @return the closeIteratorCost
*/
public GenericDaoStatistics.Cost getCloseIteratorCost() {
return closeIteratorCost;
}
/**
* @return the bulkUpdateCost
*/
public GenericDaoStatistics.Cost getBulkUpdateCost() {
return bulkUpdateCost;
}
/**
* @return the bulkUpdate
*/
public Map<String, GenericDaoStatistics.Cost> getBulkUpdate() {
return bulkUpdate;
}
/**
* @return the bulkUpdateSqlCost
*/
public GenericDaoStatistics.Cost getBulkUpdateSqlCost() {
return bulkUpdateSqlCost;
}
/**
* @return the bulkUpdateSql
*/
public Map<String, GenericDaoStatistics.Cost> getBulkUpdateSql() {
return bulkUpdateSql;
}
}
| UTF-8 | Java | 20,812 | java | GenericDaoStatistics.java | Java | [
{
"context": "/*\n * MIT License\n *\n * Copyright (c) 2008-2017 q-wang, <apeidou@gmail.com>\n *\n * Permission is he",
"end": 54,
"score": 0.9985041618347168,
"start": 48,
"tag": "USERNAME",
"value": "q-wang"
},
{
"context": "License\n *\n * Copyright (c) 2008-2017 q-wang, <... | null | [] | /*
* MIT License
*
* Copyright (c) 2008-2017 q-wang, <<EMAIL>>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.lc4ever.framework.dao;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
*
* @revision $Revision:$
* @author <a href="mailto:<EMAIL>">Q-Wang</a>
*/
@SuppressWarnings("rawtypes")
public class GenericDaoStatistics {
private long start = System.currentTimeMillis();
public static class Cost implements Serializable {
private long count;
private long cost;
public synchronized void cost(final long cost) {
count++;
this.cost += cost;
}
public long avg() {
return count == 0 ? 0 : cost / count;
}
public long getCount() {
return count;
}
public long getCost() {
return cost;
}
public synchronized void reset() {
this.cost = 0;
this.count = 0;
}
@Override
public String toString() {
return "Cost [count=" + count + ", cost=" + cost + ", avg=" + avg() + "]";
}
}
// List<E> list(Class<E> clazz)
private GenericDaoStatistics.Cost listCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> list = new HashMap<Class, GenericDaoStatistics.Cost>();
public void listCost(final Class clazz, final long cost) {
listCost.cost(cost);
Cost classCost = list.get(clazz);
if (classCost == null) {
classCost = new Cost();
list.put(clazz, classCost);
}
classCost.cost(cost);
}
// E get(Class<E> clazz, ID id)
private GenericDaoStatistics.Cost getCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> get = new HashMap<Class, GenericDaoStatistics.Cost>();
public void getCost(final Class clazz, final long cost) {
getCost.cost(cost);
Cost classCost = get.get(clazz);
if (classCost == null) {
classCost = new Cost();
get.put(clazz, classCost);
}
classCost.cost(cost);
}
// void delete(E entity)
private GenericDaoStatistics.Cost deleteCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> delete = new HashMap<Class, GenericDaoStatistics.Cost>();
public void deleteCost(final Class clazz, final long cost) {
deleteCost.cost(cost);
Cost classCost = delete.get(clazz);
if (classCost == null) {
classCost = new Cost();
delete.put(clazz, classCost);
}
classCost.cost(cost);
}
// ID save(E entity)
private GenericDaoStatistics.Cost saveCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> save = new HashMap<Class, GenericDaoStatistics.Cost>();
public void saveCost(final Class clazz, final long cost) {
saveCost.cost(cost);
Cost classCost = save.get(clazz);
if (classCost == null) {
classCost = new Cost();
save.put(clazz, classCost);
}
classCost.cost(cost);
}
// void update(E entity)
private GenericDaoStatistics.Cost updateCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> update = new HashMap<Class, GenericDaoStatistics.Cost>();
public void updateCost(final Class clazz, final long cost) {
updateCost.cost(cost);
Cost classCost = update.get(clazz);
if (classCost == null) {
classCost = new Cost();
update.put(clazz, classCost);
}
classCost.cost(cost);
}
// void saveOrUpdate(E entity)
private GenericDaoStatistics.Cost saveOrUpdateCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> saveOrUpdate = new HashMap<Class, GenericDaoStatistics.Cost>();
public void saveOrUpdateCost(final Class clazz, final long cost) {
saveOrUpdateCost.cost(cost);
Cost classCost = saveOrUpdate.get(clazz);
if (classCost == null) {
classCost = new Cost();
saveOrUpdate.put(clazz, classCost);
}
classCost.cost(cost);
}
// long count(Class<E> clazz)
private GenericDaoStatistics.Cost countCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> count = new HashMap<Class, GenericDaoStatistics.Cost>();
public void countCost(final Class clazz, final long cost) {
countCost.cost(cost);
Cost classCost = count.get(clazz);
if (classCost == null) {
classCost = new Cost();
count.put(clazz, classCost);
}
classCost.cost(cost);
}
// Pager<T> page(Pager<T> pager)
private GenericDaoStatistics.Cost pageCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> page = new HashMap<String, GenericDaoStatistics.Cost>();
public void pageCost(final String key, final long cost) {
pageCost.cost(cost);
Cost classCost = page.get(key);
if (classCost == null) {
classCost = new Cost();
page.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> hql(String hql, Object... args)
private GenericDaoStatistics.Cost hqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> hql = new HashMap<String, GenericDaoStatistics.Cost>();
public void hqlCost(final String key, final long cost) {
hqlCost.cost(cost);
Cost classCost = hql.get(key);
if (classCost == null) {
classCost = new Cost();
hql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> List<T> hql(Class<T> expectType, String hql, Object... args)
private GenericDaoStatistics.Cost hqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> hqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void hqlClassCost(final String key, final long cost) {
hqlClassCost.cost(cost);
Cost classCost = hqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
hqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> sql(final String sql, final Object... args)
private GenericDaoStatistics.Cost sqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> sql = new HashMap<String, GenericDaoStatistics.Cost>();
public void sqlCost(final String key, final long cost) {
sqlCost.cost(cost);
Cost classCost = sql.get(key);
if (classCost == null) {
classCost = new Cost();
sql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> List<T> sql(Class<T> expectType, final String sql, final Object... args)
private GenericDaoStatistics.Cost sqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> sqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void sqlClassCost(final String key, final long cost) {
sqlClassCost.cost(cost);
Cost classCost = sqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
sqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object uniqueResultHql(String hql, Object... args)
private GenericDaoStatistics.Cost uniqueResultHqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultHql = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultHqlCost(final String key, final long cost) {
uniqueResultHqlCost.cost(cost);
Cost classCost = uniqueResultHql.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultHql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T uniqueResultHql(Class<T> expectType, String hql, Object... args)
private GenericDaoStatistics.Cost uniqueResultHqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultHqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultHqlClassCost(final String key, final long cost) {
uniqueResultHqlClassCost.cost(cost);
Cost classCost = uniqueResultHqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultHqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object uniqueResultSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost uniqueResultSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultSqlCost(final String key, final long cost) {
uniqueResultSqlCost.cost(cost);
Cost classCost = uniqueResultSql.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultSql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T uniqueResultSql(Class<T> expectType, final String sql, final Object... args);
private GenericDaoStatistics.Cost uniqueResultSqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> uniqueResultSqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void uniqueResultSqlClassCost(final String key, final long cost) {
uniqueResultSqlClassCost.cost(cost);
Cost classCost = uniqueResultSqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
uniqueResultSqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// List<?> criteria(DetachedCriteria criteria);
private GenericDaoStatistics.Cost criteriaCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> criteria = new HashMap<Class, GenericDaoStatistics.Cost>();
public void criteriaCost(final Class clazz, final long cost) {
criteriaCost.cost(cost);
Cost classCost = criteria.get(clazz);
if (classCost == null) {
classCost = new Cost();
criteria.put(clazz, classCost);
}
classCost.cost(cost);
}
// <T> T callback(HibernateCallback<T> callback);
private GenericDaoStatistics.Cost callbackCost = new Cost();
private Map<Class, GenericDaoStatistics.Cost> callback = new HashMap<Class, GenericDaoStatistics.Cost>();
public void callbackCost(final Class clazz, final long cost) {
callbackCost.cost(cost);
Cost classCost = callback.get(clazz);
if (classCost == null) {
classCost = new Cost();
callback.put(clazz, classCost);
}
classCost.cost(cost);
}
// Object topResultHql(final String hql, final Object... args);
private GenericDaoStatistics.Cost topResultHqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultHql = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultHqlCost(final String key, final long cost) {
topResultHqlCost.cost(cost);
Cost classCost = topResultHql.get(key);
if (classCost == null) {
classCost = new Cost();
topResultHql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T topResultHql(Class<T> clazz, final String hql, final Object... args);
private GenericDaoStatistics.Cost topResultHqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultHqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultHqlClassCost(final String key, final long cost) {
topResultHqlClassCost.cost(cost);
Cost classCost = topResultHqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
topResultHqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// Object topResultSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost topResultSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultSqlCost(final String key, final long cost) {
topResultSqlCost.cost(cost);
Cost classCost = topResultSql.get(key);
if (classCost == null) {
classCost = new Cost();
topResultSql.put(key, classCost);
}
classCost.cost(cost);
}
// <T> T topResultSql(Class<T> clazz, final String sql, final Object... args);
private GenericDaoStatistics.Cost topResultSqlClassCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> topResultSqlClass = new HashMap<String, GenericDaoStatistics.Cost>();
public void topResultSqlClassCost(final String key, final long cost) {
topResultSqlClassCost.cost(cost);
Cost classCost = topResultSqlClass.get(key);
if (classCost == null) {
classCost = new Cost();
topResultSqlClass.put(key, classCost);
}
classCost.cost(cost);
}
// <T> Iterator<T> iterate(Class<T> clazz, final String hql, final Object... args);
private GenericDaoStatistics.Cost iterateCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> iterate = new HashMap<String, GenericDaoStatistics.Cost>();
public void iterateCost(final String key, final long cost) {
iterateCost.cost(cost);
Cost classCost = iterate.get(key);
if (classCost == null) {
classCost = new Cost();
iterate.put(key, classCost);
}
classCost.cost(cost);
}
// void closeIterator(Iterator<?> iterator);
private GenericDaoStatistics.Cost closeIteratorCost = new Cost();
public void closeIterator(final long cost) {
closeIteratorCost.cost(cost);
}
// int bulkUpdate(String hql, Object... args);
private GenericDaoStatistics.Cost bulkUpdateCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> bulkUpdate = new HashMap<String, GenericDaoStatistics.Cost>();
public void bulkUpdateCost(final String key, final long cost) {
bulkUpdateCost.cost(cost);
Cost classCost = bulkUpdate.get(key);
if (classCost == null) {
classCost = new Cost();
bulkUpdate.put(key, classCost);
}
classCost.cost(cost);
}
// int bulkUpdateSql(final String sql, final Object... args);
private GenericDaoStatistics.Cost bulkUpdateSqlCost = new Cost();
private Map<String, GenericDaoStatistics.Cost> bulkUpdateSql = new HashMap<String, GenericDaoStatistics.Cost>();
public void bulkUpdateSqlCost(final String key, final long cost) {
bulkUpdateSqlCost.cost(cost);
Cost classCost = bulkUpdateSql.get(key);
if (classCost == null) {
classCost = new Cost();
bulkUpdateSql.put(key, classCost);
}
classCost.cost(cost);
}
/**
* @return the start
*/
public long getStart() {
return start;
}
/**
* @return the listCost
*/
public GenericDaoStatistics.Cost getListCost() {
return listCost;
}
/**
* @return the list
*/
public Map<Class, GenericDaoStatistics.Cost> getList() {
return list;
}
/**
* @return the getCost
*/
public GenericDaoStatistics.Cost getGetCost() {
return getCost;
}
/**
* @return the get
*/
public Map<Class, GenericDaoStatistics.Cost> getGet() {
return get;
}
/**
* @return the deleteCost
*/
public GenericDaoStatistics.Cost getDeleteCost() {
return deleteCost;
}
/**
* @return the delete
*/
public Map<Class, GenericDaoStatistics.Cost> getDelete() {
return delete;
}
/**
* @return the saveCost
*/
public GenericDaoStatistics.Cost getSaveCost() {
return saveCost;
}
/**
* @return the save
*/
public Map<Class, GenericDaoStatistics.Cost> getSave() {
return save;
}
/**
* @return the updateCost
*/
public GenericDaoStatistics.Cost getUpdateCost() {
return updateCost;
}
/**
* @return the update
*/
public Map<Class, GenericDaoStatistics.Cost> getUpdate() {
return update;
}
/**
* @return the saveOrUpdateCost
*/
public GenericDaoStatistics.Cost getSaveOrUpdateCost() {
return saveOrUpdateCost;
}
/**
* @return the saveOrUpdate
*/
public Map<Class, GenericDaoStatistics.Cost> getSaveOrUpdate() {
return saveOrUpdate;
}
/**
* @return the countCost
*/
public GenericDaoStatistics.Cost getCountCost() {
return countCost;
}
/**
* @return the count
*/
public Map<Class, GenericDaoStatistics.Cost> getCount() {
return count;
}
/**
* @return the pageCost
*/
public GenericDaoStatistics.Cost getPageCost() {
return pageCost;
}
/**
* @return the page
*/
public Map<String, GenericDaoStatistics.Cost> getPage() {
return page;
}
/**
* @return the hqlCost
*/
public GenericDaoStatistics.Cost getHqlCost() {
return hqlCost;
}
/**
* @return the hql
*/
public Map<String, GenericDaoStatistics.Cost> getHql() {
return hql;
}
/**
* @return the hqlClassCost
*/
public GenericDaoStatistics.Cost getHqlClassCost() {
return hqlClassCost;
}
/**
* @return the hqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getHqlClass() {
return hqlClass;
}
/**
* @return the sqlCost
*/
public GenericDaoStatistics.Cost getSqlCost() {
return sqlCost;
}
/**
* @return the sql
*/
public Map<String, GenericDaoStatistics.Cost> getSql() {
return sql;
}
/**
* @return the sqlClassCost
*/
public GenericDaoStatistics.Cost getSqlClassCost() {
return sqlClassCost;
}
/**
* @return the sqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getSqlClass() {
return sqlClass;
}
/**
* @return the uniqueResultHqlCost
*/
public GenericDaoStatistics.Cost getUniqueResultHqlCost() {
return uniqueResultHqlCost;
}
/**
* @return the uniqueResultHql
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultHql() {
return uniqueResultHql;
}
/**
* @return the uniqueResultHqlClassCost
*/
public GenericDaoStatistics.Cost getUniqueResultHqlClassCost() {
return uniqueResultHqlClassCost;
}
/**
* @return the uniqueResultHqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultHqlClass() {
return uniqueResultHqlClass;
}
/**
* @return the uniqueResultSqlCost
*/
public GenericDaoStatistics.Cost getUniqueResultSqlCost() {
return uniqueResultSqlCost;
}
/**
* @return the uniqueResultSql
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultSql() {
return uniqueResultSql;
}
/**
* @return the uniqueResultSqlClassCost
*/
public GenericDaoStatistics.Cost getUniqueResultSqlClassCost() {
return uniqueResultSqlClassCost;
}
/**
* @return the uniqueResultSqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getUniqueResultSqlClass() {
return uniqueResultSqlClass;
}
/**
* @return the criteriaCost
*/
public GenericDaoStatistics.Cost getCriteriaCost() {
return criteriaCost;
}
/**
* @return the criteria
*/
public Map<Class, GenericDaoStatistics.Cost> getCriteria() {
return criteria;
}
/**
* @return the callbackCost
*/
public GenericDaoStatistics.Cost getCallbackCost() {
return callbackCost;
}
/**
* @return the callback
*/
public Map<Class, GenericDaoStatistics.Cost> getCallback() {
return callback;
}
/**
* @return the topResultHqlCost
*/
public GenericDaoStatistics.Cost getTopResultHqlCost() {
return topResultHqlCost;
}
/**
* @return the topResultHql
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultHql() {
return topResultHql;
}
/**
* @return the topResultHqlClassCost
*/
public GenericDaoStatistics.Cost getTopResultHqlClassCost() {
return topResultHqlClassCost;
}
/**
* @return the topResultHqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultHqlClass() {
return topResultHqlClass;
}
/**
* @return the topResultSqlCost
*/
public GenericDaoStatistics.Cost getTopResultSqlCost() {
return topResultSqlCost;
}
/**
* @return the topResultSql
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultSql() {
return topResultSql;
}
/**
* @return the topResultSqlClassCost
*/
public GenericDaoStatistics.Cost getTopResultSqlClassCost() {
return topResultSqlClassCost;
}
/**
* @return the topResultSqlClass
*/
public Map<String, GenericDaoStatistics.Cost> getTopResultSqlClass() {
return topResultSqlClass;
}
/**
* @return the iterateCost
*/
public GenericDaoStatistics.Cost getIterateCost() {
return iterateCost;
}
/**
* @return the iterate
*/
public Map<String, GenericDaoStatistics.Cost> getIterate() {
return iterate;
}
/**
* @return the closeIteratorCost
*/
public GenericDaoStatistics.Cost getCloseIteratorCost() {
return closeIteratorCost;
}
/**
* @return the bulkUpdateCost
*/
public GenericDaoStatistics.Cost getBulkUpdateCost() {
return bulkUpdateCost;
}
/**
* @return the bulkUpdate
*/
public Map<String, GenericDaoStatistics.Cost> getBulkUpdate() {
return bulkUpdate;
}
/**
* @return the bulkUpdateSqlCost
*/
public GenericDaoStatistics.Cost getBulkUpdateSqlCost() {
return bulkUpdateSqlCost;
}
/**
* @return the bulkUpdateSql
*/
public Map<String, GenericDaoStatistics.Cost> getBulkUpdateSql() {
return bulkUpdateSql;
}
}
| 20,792 | 0.716269 | 0.715645 | 795 | 25.178616 | 27.094307 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.74088 | false | false | 10 |
7e142f91e686ef72e6f3b8c6fbb3289653033715 | 21,328,807,627,905 | 18f4c72fd6e538a5b5c2ba7696769151b121a6d9 | /Calculadorcilla3/app/src/main/java/com/victor/calculadorcilla/BaseActivity.java | a37fe81fd01f8aad06c4512bd84ef3dafdd26133 | [] | no_license | isVicjiar/AndroidPopurri | https://github.com/isVicjiar/AndroidPopurri | 82dfeeae9aca96d43f7388b2b0f69c0ca49a461f | 09d914aebd4c5b77bedb0800a47b279771a3a666 | refs/heads/master | 2021-01-09T06:28:28.962000 | 2017-02-09T23:46:16 | 2017-02-09T23:46:16 | 80,993,146 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.victor.calculadorcilla;
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.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;
public class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
SharedPreferences settings;
protected Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings=getSharedPreferences("MYAPP", Context.MODE_PRIVATE);
super.setContentView(R.layout.activity_base);
setView();
}
protected void setToolbarTitle(String title) {
toolbar.setTitle(title);
}
protected void setView() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(Color.WHITE);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
protected Toolbar getToolbar(){
return this.toolbar;
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
switch (id){
case R.id.calculator:
if (this instanceof Select_Activity) {
Fragment fi=new Calculator();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Calculator");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Calculator");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.music:
if (this instanceof Select_Activity) {
Fragment fi=new Music();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Music");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Music");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.game:
if (this instanceof Select_Activity) {
Fragment fi=new Game();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Game");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Game");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.profile:
if (this instanceof Select_Activity) {
Fragment fi=new Profile();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Profile");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Profile");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.loggout:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Log Out");
builder.setMessage("Are you sure?");
builder.setPositiveButton("LogOut",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
settings=getSharedPreferences("MYAPP", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=settings.edit();
editor.putString("CurrentUser",null);
editor.apply();
Intent i=new Intent(getApplicationContext(), Login.class);
startActivity(i);
finish();
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
}
});
AlertDialog dialog = builder.create();
dialog.show();
break;
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void setContentView(int layoutResID) {
DrawerLayout fullLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base,
null);
FrameLayout frameLayout = (FrameLayout) fullLayout.findViewById(R.id.frame_layout_base);
getLayoutInflater().inflate(layoutResID, frameLayout, true);
super.setContentView(fullLayout);
setView();
}
}
| UTF-8 | Java | 7,351 | java | BaseActivity.java | Java | [] | null | [] | package com.victor.calculadorcilla;
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.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.View;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.FrameLayout;
public class BaseActivity extends AppCompatActivity implements NavigationView.OnNavigationItemSelectedListener {
SharedPreferences settings;
protected Toolbar toolbar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
settings=getSharedPreferences("MYAPP", Context.MODE_PRIVATE);
super.setContentView(R.layout.activity_base);
setView();
}
protected void setToolbarTitle(String title) {
toolbar.setTitle(title);
}
protected void setView() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
toolbar.setTitleTextColor(Color.WHITE);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.setDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
}
protected Toolbar getToolbar(){
return this.toolbar;
}
@Override
public boolean onNavigationItemSelected(MenuItem item) {
// Handle navigation view item clicks here.
int id = item.getItemId();
switch (id){
case R.id.calculator:
if (this instanceof Select_Activity) {
Fragment fi=new Calculator();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Calculator");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Calculator");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.music:
if (this instanceof Select_Activity) {
Fragment fi=new Music();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Music");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Music");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.game:
if (this instanceof Select_Activity) {
Fragment fi=new Game();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Game");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Game");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.profile:
if (this instanceof Select_Activity) {
Fragment fi=new Profile();
((Toolbar)findViewById(R.id.toolbar)).setTitle("Profile");
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container,
fi,"MEMORY_FRAGMENT").commit();
} else {
SharedPreferences.Editor editor=settings.edit();
editor.putString("curr_fragment","Profile");
editor.apply();
Intent i=new Intent(this,Select_Activity.class);
startActivity(i);
finish();
}
break;
case R.id.loggout:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Log Out");
builder.setMessage("Are you sure?");
builder.setPositiveButton("LogOut",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
settings=getSharedPreferences("MYAPP", Context.MODE_PRIVATE);
SharedPreferences.Editor editor=settings.edit();
editor.putString("CurrentUser",null);
editor.apply();
Intent i=new Intent(getApplicationContext(), Login.class);
startActivity(i);
finish();
}
});
builder.setNegativeButton("Cancel",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
}
});
AlertDialog dialog = builder.create();
dialog.show();
break;
}
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
drawer.closeDrawer(GravityCompat.START);
return true;
}
@Override
public void setContentView(int layoutResID) {
DrawerLayout fullLayout = (DrawerLayout) getLayoutInflater().inflate(R.layout.activity_base,
null);
FrameLayout frameLayout = (FrameLayout) fullLayout.findViewById(R.id.frame_layout_base);
getLayoutInflater().inflate(layoutResID, frameLayout, true);
super.setContentView(fullLayout);
setView();
}
}
| 7,351 | 0.558291 | 0.557475 | 185 | 38.735134 | 27.120953 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.724324 | false | false | 10 |
a9df2d74209378449d2aa4db050fd3f478dea2de | 15,917,148,865,981 | 0f8af3676ac970b00da4ce34ce3d53ab5ea9084d | /ResLearn/src/reslearn/gui/rescanvas/ResFeld.java | 2ded4bfbe2e59b6d645b2a32a8c5c15f8cbe9fab | [] | no_license | GoldAdler/ResLearn | https://github.com/GoldAdler/ResLearn | bedec4c3449ec59db548f7b64593a1ae38580b46 | 003a432f9a22405ca3013ce252cbe433abc749f2 | refs/heads/master | 2020-03-10T13:07:21.546000 | 2018-06-28T15:10:34 | 2018-06-28T15:10:34 | 129,392,855 | 4 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package reslearn.gui.rescanvas;
import javafx.scene.shape.Rectangle;
import reslearn.model.paket.ResEinheit;
public class ResFeld extends Rectangle {
private ResEinheit resEinheit;
public ResFeld(double x, double y, ResEinheit resEinheit) {
super(x, y, DisplayCanvas.resFeldBreite, DisplayCanvas.resFeldLaenge);
this.resEinheit = resEinheit;
}
public ResEinheit getResEinheit() {
return resEinheit;
}
} | UTF-8 | Java | 418 | java | ResFeld.java | Java | [] | null | [] | package reslearn.gui.rescanvas;
import javafx.scene.shape.Rectangle;
import reslearn.model.paket.ResEinheit;
public class ResFeld extends Rectangle {
private ResEinheit resEinheit;
public ResFeld(double x, double y, ResEinheit resEinheit) {
super(x, y, DisplayCanvas.resFeldBreite, DisplayCanvas.resFeldLaenge);
this.resEinheit = resEinheit;
}
public ResEinheit getResEinheit() {
return resEinheit;
}
} | 418 | 0.784689 | 0.784689 | 18 | 22.277779 | 22.180586 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.277778 | false | false | 10 |
6b9a0d49d4a0b2621632b88b7b54aad30d8cb386 | 5,042,291,617,947 | 9f188926dfeabe56eec889c17fb7a5e14f41b2a9 | /chapter_007/src/main/java/ru/job4j/servlet/UserStore.java | 078af9bd9cbe44ba141a0063c7b5b08fd6c10338 | [
"Apache-2.0"
] | permissive | MichaelHodkov/mhodkov | https://github.com/MichaelHodkov/mhodkov | b63135cec75939466b4ba5a7778b250c493211b9 | 9e8045c2bacac80a126a1f8b2dc83054528246a4 | refs/heads/master | 2022-12-27T05:28:57.922000 | 2020-03-22T21:19:43 | 2020-03-22T21:19:43 | 112,625,423 | 0 | 1 | Apache-2.0 | false | 2022-12-16T04:28:00 | 2017-11-30T15:08:48 | 2020-03-22T21:19:55 | 2022-12-16T04:27:57 | 3,204 | 0 | 1 | 26 | Java | false | false | package ru.job4j.servlet;
import ru.job4j.crudservlet.User;
import java.util.List;
/**
* @author Michael Hodkov
* @version $Id$
* @since 0.1
*/
public class UserStore {
private final static PoolSQL POOL_SQL = new PoolSQL();
private final static UserStore INSTANCE = new UserStore();
private UserStore() {
}
public static synchronized UserStore getInstance() {
return INSTANCE;
}
public void addUser(User user) {
POOL_SQL.addUser(user);
}
public void updateUser(String id, User userNew) {
POOL_SQL.updateUser(id, userNew);
}
public void delUser(String id) {
POOL_SQL.delUser(id);
}
public boolean isDublicat(String login) {
boolean exist = false;
for (User user : getUsers()) {
if (user.getLogin().equals(login)) {
exist = true;
break;
}
}
return exist;
}
public boolean isEnter(String login, String email) {
boolean exist = false;
for (User user : getUsers()) {
if (user.getLogin().equals(login) && user.getEmail().equals(email)) {
exist = true;
break;
}
}
return exist;
}
public User getUser(String login) {
for (User user : getUsers()) {
if (user.getLogin().equals(login)) {
return user;
}
}
return null;
}
public List<User> getUsers() {
return POOL_SQL.getUsers();
}
public List<String> getRoles() {
return POOL_SQL.getRoles();
}
}
| UTF-8 | Java | 1,628 | java | UserStore.java | Java | [
{
"context": "vlet.User;\n\nimport java.util.List;\n\n/**\n * @author Michael Hodkov\n * @version $Id$\n * @since 0.1\n */\npublic class U",
"end": 115,
"score": 0.9986586570739746,
"start": 101,
"tag": "NAME",
"value": "Michael Hodkov"
}
] | null | [] | package ru.job4j.servlet;
import ru.job4j.crudservlet.User;
import java.util.List;
/**
* @author <NAME>
* @version $Id$
* @since 0.1
*/
public class UserStore {
private final static PoolSQL POOL_SQL = new PoolSQL();
private final static UserStore INSTANCE = new UserStore();
private UserStore() {
}
public static synchronized UserStore getInstance() {
return INSTANCE;
}
public void addUser(User user) {
POOL_SQL.addUser(user);
}
public void updateUser(String id, User userNew) {
POOL_SQL.updateUser(id, userNew);
}
public void delUser(String id) {
POOL_SQL.delUser(id);
}
public boolean isDublicat(String login) {
boolean exist = false;
for (User user : getUsers()) {
if (user.getLogin().equals(login)) {
exist = true;
break;
}
}
return exist;
}
public boolean isEnter(String login, String email) {
boolean exist = false;
for (User user : getUsers()) {
if (user.getLogin().equals(login) && user.getEmail().equals(email)) {
exist = true;
break;
}
}
return exist;
}
public User getUser(String login) {
for (User user : getUsers()) {
if (user.getLogin().equals(login)) {
return user;
}
}
return null;
}
public List<User> getUsers() {
return POOL_SQL.getUsers();
}
public List<String> getRoles() {
return POOL_SQL.getRoles();
}
}
| 1,620 | 0.543612 | 0.541155 | 73 | 21.301371 | 18.781137 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.328767 | false | false | 10 |
9d29e5cf6657058df2fe8ab5bc1d29afd5e5a65a | 34,222,299,415,302 | 141d5f4d7aa495163a104c92744de18880086181 | /src/main/java/com/bumblebee_reportservice/services/handlers/ReportExcelHandler.java | 70625051084eb09e1b434918f694142dbcc2e674 | [] | no_license | TimurBaldin/BumblebeeReportService | https://github.com/TimurBaldin/BumblebeeReportService | 486dee63c2a323f33d2767a63931f69991b91d6d | 719bca4823ddadb040f8ffe7eefd1c2366638eb2 | refs/heads/develop | 2023-07-12T11:23:02.308000 | 2021-09-03T07:14:00 | 2021-09-03T07:14:00 | 393,128,889 | 0 | 0 | null | false | 2021-08-14T10:05:47 | 2021-08-05T17:49:45 | 2021-08-10T05:34:18 | 2021-08-14T10:05:47 | 24 | 0 | 0 | 0 | Java | false | false | package com.bumblebee_reportservice.services.handlers;
import com.bumblebee_reportservice.services.dto.TestDataDto;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
@Component("reportExcelHandler")
public class ReportExcelHandler implements ReportHandler<List<TestDataDto>, byte[]> {
@Override
public byte[] buildReport(List<TestDataDto> data) throws IOException {
XSSFWorkbook book = new XSSFWorkbook();
XSSFSheet sheet = book.createSheet();
XSSFRow row = sheet.createRow(0);
XSSFCell cell;
int cellIndex = 0;
int rowIndex = 1;
int maxSizeData = getMaxSize(data);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//пишем заголовки документа
for (TestDataDto dto : data) {
cell = row.createCell(cellIndex, CellType.STRING);
cell.setCellValue(dto.getGeneratorName());
++cellIndex;
}
//пишем тестовые данные документа
for (int i = 0; i <= maxSizeData; i++) {
row = sheet.createRow(rowIndex);
int value_id = 0;
for (TestDataDto dto : data) {
cell = row.createCell(value_id);
cell.setCellType(CellType.STRING);
if (isIndexInCollection(dto.getData(), i)) {
cell.setCellValue(dto.getData().get(i));
} else {
cell.setCellValue("");
}
++value_id;
}
++rowIndex;
}
book.write(baos);
return baos.toByteArray();
}
private int getMaxSize(List<TestDataDto> data) {
int max = 0;
for (TestDataDto dto : data) {
if (dto.getData().size() - 1 > max) {
max = dto.getData().size() - 1;
}
}
return max;
}
private boolean isIndexInCollection(List<String> data, int index) {
if (data.size() - 1 <= index) {
return true;
}
return false;
}
}
| UTF-8 | Java | 2,410 | java | ReportExcelHandler.java | Java | [] | null | [] | package com.bumblebee_reportservice.services.handlers;
import com.bumblebee_reportservice.services.dto.TestDataDto;
import org.apache.poi.ss.usermodel.CellType;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.stereotype.Component;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.List;
@Component("reportExcelHandler")
public class ReportExcelHandler implements ReportHandler<List<TestDataDto>, byte[]> {
@Override
public byte[] buildReport(List<TestDataDto> data) throws IOException {
XSSFWorkbook book = new XSSFWorkbook();
XSSFSheet sheet = book.createSheet();
XSSFRow row = sheet.createRow(0);
XSSFCell cell;
int cellIndex = 0;
int rowIndex = 1;
int maxSizeData = getMaxSize(data);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
//пишем заголовки документа
for (TestDataDto dto : data) {
cell = row.createCell(cellIndex, CellType.STRING);
cell.setCellValue(dto.getGeneratorName());
++cellIndex;
}
//пишем тестовые данные документа
for (int i = 0; i <= maxSizeData; i++) {
row = sheet.createRow(rowIndex);
int value_id = 0;
for (TestDataDto dto : data) {
cell = row.createCell(value_id);
cell.setCellType(CellType.STRING);
if (isIndexInCollection(dto.getData(), i)) {
cell.setCellValue(dto.getData().get(i));
} else {
cell.setCellValue("");
}
++value_id;
}
++rowIndex;
}
book.write(baos);
return baos.toByteArray();
}
private int getMaxSize(List<TestDataDto> data) {
int max = 0;
for (TestDataDto dto : data) {
if (dto.getData().size() - 1 > max) {
max = dto.getData().size() - 1;
}
}
return max;
}
private boolean isIndexInCollection(List<String> data, int index) {
if (data.size() - 1 <= index) {
return true;
}
return false;
}
}
| 2,410 | 0.593896 | 0.590081 | 76 | 30.039474 | 21.556194 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.565789 | false | false | 10 |
8959dcd1dcbbc929d8360ef4f543acf970a446ff | 68,719,521,819 | 90350fc516b22708d24d9ebdd8cb63e276660547 | /app/src/main/java/com/you/mm/page/adapter/MeizhiListAdapter.java | d8090623367631a0e0e7211e52d44c43d4921b84 | [] | no_license | humorfish/mm | https://github.com/humorfish/mm | de586c179069e570afb23b80e4c30a8b6f321984 | 1bcd2b01ed0e7984d625aa6f8c6527b9878f1709 | refs/heads/master | 2021-01-12T10:47:07.567000 | 2017-04-12T14:35:09 | 2017-04-12T14:35:09 | 72,699,808 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.you.mm.page.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.you.mm.R;
import com.you.mm.bean.Meizhi;
import com.you.mm.widget.RatioImageView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by Administrator on 2017/2/27.
*/
public class MeizhiListAdapter
extends RecyclerView.Adapter<MeizhiListAdapter.ViewHolder>
{
public static final String TAG = "MeizhiListAdapter";
private List<Meizhi> mList;
private Context mContext;
private OnMeizhiTouchListener mOnMeizhiTouchListener;
public MeizhiListAdapter(Context context)
{
mContext = context;
}
public void setDatas(List<Meizhi> meizhiList)
{
mList = meizhiList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int i)
{
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_mm, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position)
{
Meizhi meizhi = mList.get(position);
int limit = 48;
String text = meizhi.desc.length() > limit ? meizhi.desc.substring(0, limit) +
"..." : meizhi.desc;
viewHolder.meizhi = meizhi;
viewHolder.titleView.setText(text);
viewHolder.card.setTag(meizhi.desc);
Glide.with(mContext)
.load(meizhi.url)
.centerCrop()
.into(viewHolder.meizhiView)
.getSize((width, height) -> {
if (!viewHolder.card.isShown())
{
viewHolder.card.setVisibility(View.VISIBLE);
}
});
}
@Override
public void onViewRecycled(ViewHolder holder)
{
super.onViewRecycled(holder);
}
@Override
public int getItemCount()
{
return mList.size();
}
public void setOnMeizhiTouchListener(OnMeizhiTouchListener onMeizhiTouchListener)
{
this.mOnMeizhiTouchListener = onMeizhiTouchListener;
}
public interface OnMeizhiTouchListener
{
void onTouch(View view, RatioImageView RameizhiView, View card, Meizhi meizhi);
}
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
@BindView(R.id.meizhi)
RatioImageView meizhiView;
@BindView(R.id.title)
TextView titleView;
View card;
Meizhi meizhi;
public ViewHolder(View itemView)
{
super(itemView);
card = itemView;
ButterKnife.bind(this, itemView);
meizhiView.setOnClickListener(this);
card.setOnClickListener(this);
meizhiView.setOriginalSize(50, 50);
}
@Override
public void onClick(View v)
{
mOnMeizhiTouchListener.onTouch(v, meizhiView, card, meizhi);
}
}
}
| UTF-8 | Java | 3,232 | java | MeizhiListAdapter.java | Java | [] | null | [] | package com.you.mm.page.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.you.mm.R;
import com.you.mm.bean.Meizhi;
import com.you.mm.widget.RatioImageView;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
/**
* Created by Administrator on 2017/2/27.
*/
public class MeizhiListAdapter
extends RecyclerView.Adapter<MeizhiListAdapter.ViewHolder>
{
public static final String TAG = "MeizhiListAdapter";
private List<Meizhi> mList;
private Context mContext;
private OnMeizhiTouchListener mOnMeizhiTouchListener;
public MeizhiListAdapter(Context context)
{
mContext = context;
}
public void setDatas(List<Meizhi> meizhiList)
{
mList = meizhiList;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int i)
{
View v = LayoutInflater.from(parent.getContext())
.inflate(R.layout.item_mm, parent, false);
return new ViewHolder(v);
}
@Override
public void onBindViewHolder(final ViewHolder viewHolder, final int position)
{
Meizhi meizhi = mList.get(position);
int limit = 48;
String text = meizhi.desc.length() > limit ? meizhi.desc.substring(0, limit) +
"..." : meizhi.desc;
viewHolder.meizhi = meizhi;
viewHolder.titleView.setText(text);
viewHolder.card.setTag(meizhi.desc);
Glide.with(mContext)
.load(meizhi.url)
.centerCrop()
.into(viewHolder.meizhiView)
.getSize((width, height) -> {
if (!viewHolder.card.isShown())
{
viewHolder.card.setVisibility(View.VISIBLE);
}
});
}
@Override
public void onViewRecycled(ViewHolder holder)
{
super.onViewRecycled(holder);
}
@Override
public int getItemCount()
{
return mList.size();
}
public void setOnMeizhiTouchListener(OnMeizhiTouchListener onMeizhiTouchListener)
{
this.mOnMeizhiTouchListener = onMeizhiTouchListener;
}
public interface OnMeizhiTouchListener
{
void onTouch(View view, RatioImageView RameizhiView, View card, Meizhi meizhi);
}
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener
{
@BindView(R.id.meizhi)
RatioImageView meizhiView;
@BindView(R.id.title)
TextView titleView;
View card;
Meizhi meizhi;
public ViewHolder(View itemView)
{
super(itemView);
card = itemView;
ButterKnife.bind(this, itemView);
meizhiView.setOnClickListener(this);
card.setOnClickListener(this);
meizhiView.setOriginalSize(50, 50);
}
@Override
public void onClick(View v)
{
mOnMeizhiTouchListener.onTouch(v, meizhiView, card, meizhi);
}
}
}
| 3,232 | 0.629022 | 0.624381 | 127 | 24.448818 | 22.73632 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.464567 | false | false | 10 |
409f6355ed53977b7727532d4adab2c810715d7b | 3,350,074,539,277 | 16e7f17c62951d26677db71bc796549e75a388db | /src/j5th/jStringAf.java | 1b27777d7a156fde02f2e624b0866695d8b347a8 | [] | no_license | mitsuhide1992/javaEx | https://github.com/mitsuhide1992/javaEx | 2ebc08189ffe4fdb710bf3e8298aea9df8213284 | 562cd95e1d175889567a51481b6b7fe75149914f | refs/heads/master | 2020-04-30T01:50:47.801000 | 2015-09-22T02:49:07 | 2015-09-22T02:49:07 | 42,907,656 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package j5th;
public class jStringAf {
String js;
jStringAf () {
js = "zhangliyuan";
}
public void outS () {
System.out.println(js);
}
}
| UTF-8 | Java | 147 | java | jStringAf.java | Java | [
{
"context": "s jStringAf {\n\tString js;\n\tjStringAf () {\n\t\tjs = \"zhangliyuan\";\n\t}\n\tpublic void outS () {\n\t\tSystem.out.println(",
"end": 87,
"score": 0.9719247817993164,
"start": 76,
"tag": "NAME",
"value": "zhangliyuan"
}
] | null | [] | package j5th;
public class jStringAf {
String js;
jStringAf () {
js = "zhangliyuan";
}
public void outS () {
System.out.println(js);
}
}
| 147 | 0.632653 | 0.62585 | 11 | 12.363636 | 9.383474 | 25 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.181818 | false | false | 10 |
6f5cdfc573b9995ccb9099e86274121c44b7f99c | 10,685,878,686,472 | ffdef393a20ee36721d8eb831e84139595e031cc | /src/main/java/com/crew/repository/coustom/UserRepositoryCustom.java | d6efb635960ea2d9234a8ac942a172f7bafaaaae | [] | no_license | JaeHan-Kim/crewVue | https://github.com/JaeHan-Kim/crewVue | 50e4eba17103e4a1b4e1d6d1a8668ccb8c729c81 | b6f6126fdef70187acf64d4c6031a44a8ab98eb3 | refs/heads/master | 2022-12-26T02:24:36.755000 | 2020-12-17T02:40:50 | 2020-12-17T02:40:50 | 245,952,119 | 0 | 0 | null | false | 2022-12-12T04:36:10 | 2020-03-09T05:34:07 | 2020-12-17T02:40:57 | 2022-12-12T04:36:10 | 1,308 | 0 | 0 | 24 | Java | false | false | package com.crew.repository.coustom;
import java.util.List;
import com.crew.domain.entity.UserEntity;
public interface UserRepositoryCustom {
List<UserEntity> findbyName(String name);
}
| UTF-8 | Java | 190 | java | UserRepositoryCustom.java | Java | [] | null | [] | package com.crew.repository.coustom;
import java.util.List;
import com.crew.domain.entity.UserEntity;
public interface UserRepositoryCustom {
List<UserEntity> findbyName(String name);
}
| 190 | 0.805263 | 0.805263 | 9 | 20.111111 | 18.579824 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 10 |
812507f9c96edd35d7ac71c50c65250474bd7fee | 13,082,470,437,806 | 1f956725b7ab021bd2968739f73c66efba5e3130 | /src/main/java/io/student/modules/datacenter/dao/StudentCourseInfoDao.java | 9122f84835cef3a25774a6c8cce973b22de73d8d | [
"Apache-2.0"
] | permissive | stuMental/StudentMental | https://github.com/stuMental/StudentMental | 80fb3f6378a21f86ba9e933f580eb6b72bf5f0c6 | 4df0c71d7a5694afaf995e322d0ba1b6b2a6754d | refs/heads/master | 2022-07-17T23:30:38.985000 | 2020-09-19T07:49:17 | 2020-09-19T07:49:17 | 160,053,441 | 0 | 0 | Apache-2.0 | false | 2022-07-06T20:33:01 | 2018-12-02T14:03:42 | 2020-09-19T07:49:20 | 2022-07-06T20:32:58 | 2,269 | 0 | 0 | 7 | JavaScript | false | false | package io.student.modules.datacenter.dao;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import io.student.modules.datacenter.entity.StudentCourseInfo;
import java.util.List;
import java.util.Map;
@Mapper
public interface StudentCourseInfoDao extends BaseMapper<StudentCourseInfo> {
int deleteCourseByStudentId(String student_id);
List<Map<String, Object>> getCourseByTeacher(Map<String, Object> params);
}
| UTF-8 | Java | 488 | java | StudentCourseInfoDao.java | Java | [] | null | [] | package io.student.modules.datacenter.dao;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.mapper.BaseMapper;
import io.student.modules.datacenter.entity.StudentCourseInfo;
import java.util.List;
import java.util.Map;
@Mapper
public interface StudentCourseInfoDao extends BaseMapper<StudentCourseInfo> {
int deleteCourseByStudentId(String student_id);
List<Map<String, Object>> getCourseByTeacher(Map<String, Object> params);
}
| 488 | 0.782787 | 0.782787 | 17 | 26.705883 | 28.026804 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.588235 | false | false | 10 |
74b7ca7b214f6ba6613ec7924179dda8ca569064 | 979,252,592,967 | 3629ef877d1cf8e82b26a446c6c4c13e37f1a69a | /ui/uiwidget/src/main/java/com/supets/pet/uiwidget/SimpleOnScrollListener.java | d0bd4b1912cbe504f4a097e128c4c120947f60aa | [] | no_license | supets-open/SupetsCloudpetLib | https://github.com/supets-open/SupetsCloudpetLib | 93796b42ba9352318a91ad977000e329eecda9b2 | c60f47a35a9411369c942b5cce95a173332b6c73 | refs/heads/master | 2021-09-06T04:34:57.826000 | 2018-02-02T11:01:27 | 2018-02-02T11:01:27 | 104,031,608 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.supets.pet.uiwidget;
import android.widget.AbsListView;
public class SimpleOnScrollListener implements AbsListView.OnScrollListener {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
} | UTF-8 | Java | 359 | java | SimpleOnScrollListener.java | Java | [] | null | [] | package com.supets.pet.uiwidget;
import android.widget.AbsListView;
public class SimpleOnScrollListener implements AbsListView.OnScrollListener {
@Override
public void onScrollStateChanged(AbsListView view, int scrollState) {
}
@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
}
} | 359 | 0.807799 | 0.807799 | 17 | 20.17647 | 31.921291 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705882 | false | false | 10 |
506ad077ad632a711fb62058126e22b7fe42f6ab | 19,481,971,698,646 | afaba1418888cd8699007f0ff5eb088651ceb618 | /CardGameMahjong/src/main/java/com/kuaikai/game/mahjong/engine/checker/gang/GangChecker.java | 437c323e5734ed40db374935d83b304454544150 | [] | no_license | KuaiKaiPlatform/Server | https://github.com/KuaiKaiPlatform/Server | 9db070243f05e8b7a4eb1c90d77cd47e899aa8dc | 06b58f75a989d83ce6027d60da2e2758493d5f4d | refs/heads/master | 2020-04-12T18:17:32.210000 | 2019-04-06T14:08:25 | 2019-04-06T14:08:25 | 162,675,201 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kuaikai.game.mahjong.engine.checker.gang;
import java.util.List;
import com.kuaikai.game.mahjong.engine.oper.BaseOperation;
import com.kuaikai.game.mahjong.engine.oper.DianGangOperation;
/***
* 杠牌检查器
*
*/
public interface GangChecker {
/*
* 检查并返回指定玩家的补杠操作(摸、吃、碰后)
*/
public List<BaseOperation> checkBuGangOperations(BaseOperation oper);
/*
* 检查并返回指定玩家的暗杠操作(摸、吃、碰后)
*/
public List<BaseOperation> checkAnGangOperations(BaseOperation oper);
/*
* 检查并返回指定玩家的点杠操作
*/
public DianGangOperation checkDianGangOperation(BaseOperation daOper);
}
| UTF-8 | Java | 705 | java | GangChecker.java | Java | [] | null | [] | package com.kuaikai.game.mahjong.engine.checker.gang;
import java.util.List;
import com.kuaikai.game.mahjong.engine.oper.BaseOperation;
import com.kuaikai.game.mahjong.engine.oper.DianGangOperation;
/***
* 杠牌检查器
*
*/
public interface GangChecker {
/*
* 检查并返回指定玩家的补杠操作(摸、吃、碰后)
*/
public List<BaseOperation> checkBuGangOperations(BaseOperation oper);
/*
* 检查并返回指定玩家的暗杠操作(摸、吃、碰后)
*/
public List<BaseOperation> checkAnGangOperations(BaseOperation oper);
/*
* 检查并返回指定玩家的点杠操作
*/
public DianGangOperation checkDianGangOperation(BaseOperation daOper);
}
| 705 | 0.749568 | 0.749568 | 29 | 18.965517 | 24.697456 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.793103 | false | false | 10 |
5f0b04ca1711f91401ffbd743c0a7a052f772ab9 | 19,481,971,698,956 | 1a2ac7bdb2c4d16e49c2d5c9f87945973273c2bf | /java-algorithm-learn/src/main/java/com/frankstar/leetcode/二叉树/先序遍历与中序遍历构造二叉树.java | 0e0e74a9677dcf7c6736ced4b5ca84bc16da413e | [] | no_license | frankstar007/java-improve | https://github.com/frankstar007/java-improve | bab64590cf4df004411ad592ffb69be62da5d0e6 | 11882102197d6b0bf8f3cb0922fc287ee9901791 | refs/heads/master | 2022-01-22T00:32:24.748000 | 2021-03-29T13:01:05 | 2021-03-29T13:01:05 | 97,022,321 | 0 | 0 | null | false | 2022-01-21T23:47:17 | 2017-07-12T15:15:28 | 2021-03-29T13:01:21 | 2022-01-21T23:47:14 | 20,257 | 0 | 0 | 9 | Java | false | false | package com.frankstar.leetcode.二叉树;
/**
* @Author : frankstar
* @AddTime : 2020/3/12
* @EMail : yehongxing@meituan.com
* @Project : java-improve
* @Desc : https://leetcode-cn.com/explore/learn/card/data-structure-binary-tree/4/conclusion/16/
*/
public class 先序遍历与中序遍历构造二叉树 {
public TreeNode buildTree(int[] preorder, int[] inorder) {
int preLength = preorder.length - 1;
int inLength = inorder.length -1;
return build(preorder, 0, preLength, inorder, 0, inLength);
}
private TreeNode build(int[] preorder, int preStart, int preLength, int[] inorder, int inStart, int inLength) {
if (inStart > inLength || preStart > preLength) return null;
//在中序列表中找到根节点的位置
int key = 0;
for (int k = 0; k<= inLength; k++) {
if (preorder[preStart] == inorder[k]) {
key = k;
break;
}
}
int preLeft = preStart + 1 + (key - 1 - inStart);
int preRight = preStart + 1 + (key - 1 -inStart ) + 1;
TreeNode root = new TreeNode(preorder[preStart]);
TreeNode left = build(preorder, preStart + 1, preLeft, inorder, inStart, key - 1);
TreeNode right = build(preorder, preRight, preLength, inorder, key + 1, inLength);
root.left = left;
root.right = right;
return root;
}
}
| UTF-8 | Java | 1,276 | java | 先序遍历与中序遍历构造二叉树.java | Java | [
{
"context": "age com.frankstar.leetcode.二叉树;\n\n/**\n * @Author : frankstar\n * @AddTime : 2020/3/12\n * @EMail : yehongxing@",
"end": 64,
"score": 0.9996357560157776,
"start": 55,
"tag": "USERNAME",
"value": "frankstar"
},
{
"context": ": frankstar\n * @AddTime : 2020/3/12\n *... | null | [] | package com.frankstar.leetcode.二叉树;
/**
* @Author : frankstar
* @AddTime : 2020/3/12
* @EMail : <EMAIL>
* @Project : java-improve
* @Desc : https://leetcode-cn.com/explore/learn/card/data-structure-binary-tree/4/conclusion/16/
*/
public class 先序遍历与中序遍历构造二叉树 {
public TreeNode buildTree(int[] preorder, int[] inorder) {
int preLength = preorder.length - 1;
int inLength = inorder.length -1;
return build(preorder, 0, preLength, inorder, 0, inLength);
}
private TreeNode build(int[] preorder, int preStart, int preLength, int[] inorder, int inStart, int inLength) {
if (inStart > inLength || preStart > preLength) return null;
//在中序列表中找到根节点的位置
int key = 0;
for (int k = 0; k<= inLength; k++) {
if (preorder[preStart] == inorder[k]) {
key = k;
break;
}
}
int preLeft = preStart + 1 + (key - 1 - inStart);
int preRight = preStart + 1 + (key - 1 -inStart ) + 1;
TreeNode root = new TreeNode(preorder[preStart]);
TreeNode left = build(preorder, preStart + 1, preLeft, inorder, inStart, key - 1);
TreeNode right = build(preorder, preRight, preLength, inorder, key + 1, inLength);
root.left = left;
root.right = right;
return root;
}
}
| 1,261 | 0.66145 | 0.64168 | 45 | 25.977777 | 29.019909 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.022222 | false | false | 10 |
2f00a63a3ff66aef8f0e9724782d2108a4db0295 | 19,481,971,698,017 | 7ed1ed2826f313ea1867be1dd86cfff6a0695bfd | /compiler/src/test/java/compiler/condition/ElementsPrinter.java | ab72824fc515c82dc9d60da2b2a87de16d9edcb2 | [] | no_license | sasza2/sand | https://github.com/sasza2/sand | 25c1d26c9432f6bfd50226a220ad090c75c86263 | b7c96c7f4058277f0075f0c871ceb456a5ae42e2 | refs/heads/master | 2020-04-03T16:46:47.775000 | 2018-11-06T00:15:45 | 2018-11-06T00:15:45 | 155,418,743 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package compiler.condition;
import compiler.Script;
import compiler.condition.element.Element;
import java.util.List;
/**
*
* @author sasza
*/
public class ElementsPrinter {
public static String print(Script script){
final StringBuilder sb = new StringBuilder();
ConditionRead condition = new ConditionRead();
sb.append(script.getCode())
.append("\n")
.append(print(condition.read(script)));
return sb.toString();
}
public static String print(List <Element> elements){
final StringBuilder sb = new StringBuilder();
elements.forEach(e -> {
sb.append(e.toString());
});
sb.append("\n");
return sb.toString();
}
}
| UTF-8 | Java | 789 | java | ElementsPrinter.java | Java | [
{
"context": "Element;\nimport java.util.List;\n\n/**\n *\n * @author sasza\n */\npublic class ElementsPrinter {\n \n public",
"end": 143,
"score": 0.9953944087028503,
"start": 138,
"tag": "USERNAME",
"value": "sasza"
}
] | null | [] | package compiler.condition;
import compiler.Script;
import compiler.condition.element.Element;
import java.util.List;
/**
*
* @author sasza
*/
public class ElementsPrinter {
public static String print(Script script){
final StringBuilder sb = new StringBuilder();
ConditionRead condition = new ConditionRead();
sb.append(script.getCode())
.append("\n")
.append(print(condition.read(script)));
return sb.toString();
}
public static String print(List <Element> elements){
final StringBuilder sb = new StringBuilder();
elements.forEach(e -> {
sb.append(e.toString());
});
sb.append("\n");
return sb.toString();
}
}
| 789 | 0.576679 | 0.576679 | 34 | 22.205883 | 18.626009 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.382353 | false | false | 10 |
a8fb0039f710c2b0b7a110a8eb4b72102d2e93af | 27,650,999,453,699 | 713a65e3d4a39ef899769ff629572de9b7aa9ca9 | /bigdata-emr/src/main/java/com/data/emr/trade/common/TradeLogParser.java | fa923431f9ccf71c734d57d8b345df9053d209d1 | [] | no_license | bit-linjiang/emr-demo | https://github.com/bit-linjiang/emr-demo | 488be8a3afd0edfefe2188c9a155c1a104245a3d | 3f7407c3e4f56e0239b4de587fdaea64f729dca1 | refs/heads/master | 2021-01-22T04:24:21.309000 | 2017-02-10T10:02:18 | 2017-02-10T10:02:18 | 81,540,571 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.data.emr.trade.common;
import com.alibaba.fastjson.JSON;
import com.data.emr.trade.model.TradeLog;
/**
* 格式化日志数据
* <p>
* Created by candy on 2016/11/13.
*/
public class TradeLogParser {
/**
* 解析日志的行记录
*
* @param line 日志行数
* @return tradeLog
*/
public static TradeLog parse(String line) {
return JSON.parseObject(line, TradeLog.class);
}
}
| UTF-8 | Java | 444 | java | TradeLogParser.java | Java | [
{
"context": "del.TradeLog;\n\n/**\n * 格式化日志数据\n * <p>\n * Created by candy on 2016/11/13.\n */\npublic class TradeLogParser {\n",
"end": 154,
"score": 0.9987092018127441,
"start": 149,
"tag": "USERNAME",
"value": "candy"
}
] | null | [] | package com.data.emr.trade.common;
import com.alibaba.fastjson.JSON;
import com.data.emr.trade.model.TradeLog;
/**
* 格式化日志数据
* <p>
* Created by candy on 2016/11/13.
*/
public class TradeLogParser {
/**
* 解析日志的行记录
*
* @param line 日志行数
* @return tradeLog
*/
public static TradeLog parse(String line) {
return JSON.parseObject(line, TradeLog.class);
}
}
| 444 | 0.628079 | 0.608374 | 25 | 15.24 | 16.539118 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 10 |
e5c1be1b192b1c78e8877688e5d08c92a7ef36c6 | 27,324,582,007,633 | f964aa46660a6dfe0ce242f894bd5a37b759d40b | /src/com/tcmkb/service/impl/AsthmaHospitalPreparationServiceImpl.java | 86a5276fc63d2a2c641d5a4fb9e7bbd18a7c81d0 | [] | no_license | HuangYin0514/yaopin_beijing | https://github.com/HuangYin0514/yaopin_beijing | d352129169a6633f1ca18fd669d8cb5accf9c6b4 | ecacf05730b82602a987e2ce065b664612848af3 | refs/heads/master | 2021-01-22T01:10:26.030000 | 2017-09-02T14:08:51 | 2017-09-02T14:08:51 | 102,200,565 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tcmkb.service.impl;
import com.tcmkb.service.AsthmaHospitalPreparationService;
public class AsthmaHospitalPreparationServiceImpl implements AsthmaHospitalPreparationService{
} | UTF-8 | Java | 188 | java | AsthmaHospitalPreparationServiceImpl.java | Java | [] | null | [] | package com.tcmkb.service.impl;
import com.tcmkb.service.AsthmaHospitalPreparationService;
public class AsthmaHospitalPreparationServiceImpl implements AsthmaHospitalPreparationService{
} | 188 | 0.893617 | 0.893617 | 5 | 36.799999 | 35.751362 | 94 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 10 |
65b0617529175c4aac49b9205c7db91d318f4324 | 18,502,719,119,465 | 655d7dc90603bd61530f91fa534b5d3760854160 | /cite_culture/src/IServices/IFilm.java | 3d81f4639b769d3e287f85a4a5a15743c1c19b7d | [] | no_license | HATEM-CHAABINI/DEVils-3A3 | https://github.com/HATEM-CHAABINI/DEVils-3A3 | 7527286fd4f6697fa9122794a6e29f586d3aa98b | 06f9a1f617ddb734db56382efb586d7d772d116f | refs/heads/master | 2022-05-04T01:52:08.701000 | 2022-04-13T12:38:58 | 2022-04-13T12:38:58 | 168,212,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* 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 IServices;
import Entities.Film;
import java.util.List;
import javafx.collections.ObservableList;
/**
*
* @author mouna dridi
*/
public interface IFilm {
public void ajouterFilm(Film f);
public ObservableList<Film> afficherFilm();
public void modifierFilm(Film f);
public void supprimerFilm(Film f);
public int RetourIdEvent(Film f);
public ObservableList<Film> rechercheFilmParID(int id);
/**
*
* @return
*/
public List<Film> tousFilms();
public List<Film> tousFilmsParDate(java.sql.Date d);
public ObservableList<String> affecterSalle();
// public void modifierEtatSalle();
}
| UTF-8 | Java | 890 | java | IFilm.java | Java | [
{
"context": "collections.ObservableList;\r\n\r\n/**\r\n *\r\n * @author mouna dridi\r\n */\r\npublic interface IFilm {\r\n public void ",
"end": 335,
"score": 0.9993568658828735,
"start": 324,
"tag": "NAME",
"value": "mouna dridi"
}
] | null | [] | /*
* 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 IServices;
import Entities.Film;
import java.util.List;
import javafx.collections.ObservableList;
/**
*
* @author <NAME>
*/
public interface IFilm {
public void ajouterFilm(Film f);
public ObservableList<Film> afficherFilm();
public void modifierFilm(Film f);
public void supprimerFilm(Film f);
public int RetourIdEvent(Film f);
public ObservableList<Film> rechercheFilmParID(int id);
/**
*
* @return
*/
public List<Film> tousFilms();
public List<Film> tousFilmsParDate(java.sql.Date d);
public ObservableList<String> affecterSalle();
// public void modifierEtatSalle();
}
| 885 | 0.662921 | 0.662921 | 34 | 24.17647 | 21.565865 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
b6f3786856c1cc4a70fe87e8989b059afdcec69b | 9,105,330,698,144 | e059efcb7972d45cd34e15306aa8197cc34ade62 | /HackerEarth/Social Networking Graph.java | 5e3cf600f461c7acb3749e76ee376e89affa6246 | [] | no_license | Wild-Soul/Algorithmic-challenges | https://github.com/Wild-Soul/Algorithmic-challenges | b2f7403ca26e43ad47be37fedd9a4ead0b627e32 | 68fb21fa3e6951baf6100e2414d5a13c0a7a7809 | refs/heads/master | 2023-02-28T07:34:20.401000 | 2021-02-03T19:24:00 | 2021-02-03T19:24:00 | 226,368,299 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
import java.io.*;
class Graph {
final int N = 100005;
ArrayList< List<Integer> > adj = new ArrayList<List<Integer>> (N);
void init() {
for(int i=0; i<N; i++) {
adj.add(new ArrayList<Integer>());
}
}
int bfs(int s, int d, int n) {
boolean[] vis = new boolean[n];
for(int i=0; i<n; i++) {
vis[i] = false;
}
Queue<Integer> q = new LinkedList<>();
q.add(s);
vis[s] = true;
int ans = 0;
int lvl = 0;
while(!q.isEmpty()) {
int sz = q.size();
for(int i=0; i<sz; i++) {
int u = q.remove();
List<Integer> a = adj.get(u);
for(int v: a) {
if(vis[v])continue;
vis[v] = true;
q.add(v);
}
}
lvl++;
if(lvl == d) { ans = q.size(); break;}
}
return ans;
}
public static void main(String args[]) {
Graph g = new Graph();
g.init();
int n,m,q,u,v,t;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
for(int i=0; i<m; i++) {
u = sc.nextInt(); v = sc.nextInt();
g.adj.get(u).add(v);
g.adj.get(v).add(u);
}
q = sc.nextInt();
while(q-->0) {
u = sc.nextInt();
t = sc.nextInt();
System.out.println(g.bfs(u,t,n));
}
}
} | UTF-8 | Java | 1,625 | java | Social Networking Graph.java | Java | [] | null | [] | import java.util.*;
import java.io.*;
class Graph {
final int N = 100005;
ArrayList< List<Integer> > adj = new ArrayList<List<Integer>> (N);
void init() {
for(int i=0; i<N; i++) {
adj.add(new ArrayList<Integer>());
}
}
int bfs(int s, int d, int n) {
boolean[] vis = new boolean[n];
for(int i=0; i<n; i++) {
vis[i] = false;
}
Queue<Integer> q = new LinkedList<>();
q.add(s);
vis[s] = true;
int ans = 0;
int lvl = 0;
while(!q.isEmpty()) {
int sz = q.size();
for(int i=0; i<sz; i++) {
int u = q.remove();
List<Integer> a = adj.get(u);
for(int v: a) {
if(vis[v])continue;
vis[v] = true;
q.add(v);
}
}
lvl++;
if(lvl == d) { ans = q.size(); break;}
}
return ans;
}
public static void main(String args[]) {
Graph g = new Graph();
g.init();
int n,m,q,u,v,t;
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
m = sc.nextInt();
for(int i=0; i<m; i++) {
u = sc.nextInt(); v = sc.nextInt();
g.adj.get(u).add(v);
g.adj.get(v).add(u);
}
q = sc.nextInt();
while(q-->0) {
u = sc.nextInt();
t = sc.nextInt();
System.out.println(g.bfs(u,t,n));
}
}
} | 1,625 | 0.372308 | 0.364308 | 61 | 24.672131 | 14.550896 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.868852 | false | false | 10 |
923a7631f51df494078b56502dc76cd478b3c666 | 25,434,796,337,620 | 8dc0fbdf0ce901c3af9d3bd38d8d62e9b0e8591e | /app/src/main/java/com/example/topics/DetailFragment.java | 5927e90ab73b668cb91b6b5c9cd6b2f83b0336e7 | [] | no_license | DamianMatysko/Topics | https://github.com/DamianMatysko/Topics | 4cad41aebc8e194bc8472f662236ecc0d4b7c678 | 3c0d46c3af0728843b9cb1e91d2091f7f35478e8 | refs/heads/master | 2023-01-01T03:54:35.119000 | 2020-10-22T17:22:57 | 2020-10-22T17:22:57 | 306,408,711 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.topics;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
public class DetailFragment extends Fragment {
private TextView textViewTopic;
private TextView textViewStudent;
public DetailFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_detail, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
textViewTopic = view.findViewById(R.id.textViewDetail);
textViewStudent = view.findViewById(R.id.textViewSelectedStudent);
RecyclerView recyclerView = view.findViewById(R.id.recyclerViewTopics);
String[] students = getResources().getStringArray(R.array.names);
StudentsAdapter studentsAdapter = new StudentsAdapter(students);
recyclerView.setAdapter(studentsAdapter);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.HORIZONTAL));
TopicsViewModel model = new ViewModelProvider(requireActivity()).get(TopicsViewModel.class);
model.getSlectedTopic().observe(this, this::setTopic);
}
private void setTopic(Topic topic) {
textViewTopic.setText(topic.getTopic());
textViewStudent.setText(topic.getStudent());
}
} | UTF-8 | Java | 1,946 | java | DetailFragment.java | Java | [] | null | [] | package com.example.topics;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
public class DetailFragment extends Fragment {
private TextView textViewTopic;
private TextView textViewStudent;
public DetailFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_detail, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
textViewTopic = view.findViewById(R.id.textViewDetail);
textViewStudent = view.findViewById(R.id.textViewSelectedStudent);
RecyclerView recyclerView = view.findViewById(R.id.recyclerViewTopics);
String[] students = getResources().getStringArray(R.array.names);
StudentsAdapter studentsAdapter = new StudentsAdapter(students);
recyclerView.setAdapter(studentsAdapter);
recyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,StaggeredGridLayoutManager.HORIZONTAL));
TopicsViewModel model = new ViewModelProvider(requireActivity()).get(TopicsViewModel.class);
model.getSlectedTopic().observe(this, this::setTopic);
}
private void setTopic(Topic topic) {
textViewTopic.setText(topic.getTopic());
textViewStudent.setText(topic.getStudent());
}
} | 1,946 | 0.748201 | 0.747688 | 52 | 36.442307 | 29.400036 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.673077 | false | false | 10 |
b051f0660fd231494c5c6ee50c89e3cb0b6a2e03 | 25,434,796,338,200 | 25017100e2777599271b4fb798eb03669ec8d8f4 | /libunilight/src/model/Triangle.java | 1b5628cd009efd00cc2b446c5aa80a576a5ea364 | [] | no_license | danmunteanu/unilight | https://github.com/danmunteanu/unilight | c85ac3e723838d2d161bfe924780c9cd2f67d5a6 | 4212c0380f526267ddc0460cd4a7d022f15fff26 | refs/heads/master | 2021-05-28T15:59:17.820000 | 2014-05-04T11:52:42 | 2014-05-04T11:52:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /****************************************************************************************
This file is part of libunilight
Copyright (c) 2014, Dan Munteanu <dandm@dmsoundhouse.com>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Dan Munteanu nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAN MUNTEANU BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************************/
package model;
import engine.Pair;
/**
*
* @author cups
*/
public class Triangle extends Geobject
{
// vertices in counter clockwise order
private Vector v1 = new Vector ();
private Vector v2 = new Vector ();
private Vector v3 = new Vector ();
private Vector normal = new Vector ();
// Default constructor
public Triangle ()
{
recomputeNormal();
}
public Triangle (Vector v1, Vector v2, Vector v3)
{
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
recomputeNormal ();
}
private void recomputeNormal ()
{
normal = v1.sub (v3).cross (v2.sub (v3));
normal.normalize ();
}
public void accept (Visitor v)
{
v.visit (this);
}
public Vector getNormalAt (Vector p)
{
return normal;
}
public Vector getV1() {
return v1;
}
public void setV1(Vector p1) {
boolean mustRecompute = !this.v1.equals (p1);
this.v1 = p1;
if (mustRecompute) {
recomputeNormal();
}
}
public Vector getV2() {
return v2;
}
public void setV2(Vector p2) {
boolean mustRecompute = !this.v2.equals (p2);
this.v2 = p2;
if (mustRecompute) {
recomputeNormal();
}
}
public Vector getV3() {
return v3;
}
public void setV3(Vector p3) {
boolean mustRecompute = !this.v3.equals (p3);
this.v3 = p3;
if (mustRecompute) {
recomputeNormal();
}
}
public Pair<Vector, Vector> computeBoundary ()
{
return null;
}
}
| UTF-8 | Java | 3,407 | java | Triangle.java | Java | [
{
"context": " file is part of libunilight\t\n Copyright (c) 2014, Dan Munteanu <dandm@dmsoundhouse.com>\n All rights reserved.\n\n ",
"end": 158,
"score": 0.9997691512107849,
"start": 146,
"tag": "NAME",
"value": "Dan Munteanu"
},
{
"context": "f libunilight\t\n Copyright (c) 2014, ... | null | [] | /****************************************************************************************
This file is part of libunilight
Copyright (c) 2014, <NAME> <<EMAIL>>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Dan Munteanu nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL DAN MUNTEANU BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************************************/
package model;
import engine.Pair;
/**
*
* @author cups
*/
public class Triangle extends Geobject
{
// vertices in counter clockwise order
private Vector v1 = new Vector ();
private Vector v2 = new Vector ();
private Vector v3 = new Vector ();
private Vector normal = new Vector ();
// Default constructor
public Triangle ()
{
recomputeNormal();
}
public Triangle (Vector v1, Vector v2, Vector v3)
{
this.v1 = v1;
this.v2 = v2;
this.v3 = v3;
recomputeNormal ();
}
private void recomputeNormal ()
{
normal = v1.sub (v3).cross (v2.sub (v3));
normal.normalize ();
}
public void accept (Visitor v)
{
v.visit (this);
}
public Vector getNormalAt (Vector p)
{
return normal;
}
public Vector getV1() {
return v1;
}
public void setV1(Vector p1) {
boolean mustRecompute = !this.v1.equals (p1);
this.v1 = p1;
if (mustRecompute) {
recomputeNormal();
}
}
public Vector getV2() {
return v2;
}
public void setV2(Vector p2) {
boolean mustRecompute = !this.v2.equals (p2);
this.v2 = p2;
if (mustRecompute) {
recomputeNormal();
}
}
public Vector getV3() {
return v3;
}
public void setV3(Vector p3) {
boolean mustRecompute = !this.v3.equals (p3);
this.v3 = p3;
if (mustRecompute) {
recomputeNormal();
}
}
public Pair<Vector, Vector> computeBoundary ()
{
return null;
}
}
| 3,386 | 0.617552 | 0.604638 | 116 | 28.370689 | 25.933447 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.543103 | false | false | 10 |
a2f70aaa9ef9468df0bca111ce8c7b14850eab01 | 9,698,036,157,538 | ffd1bfac774503ec1ea1cde940cfb0c9ec32c797 | /ex-java-ee/src/main/java/cn/dbdj1201/jpa/utils/JpaUtilsNew.java | c201d5ed3b0b8512fc31ed1623753f74772bd604 | [] | no_license | yz1201/empty | https://github.com/yz1201/empty | bab93393c22fa20c95830454df36b92a8a1152d2 | 0f09927262199cc914faf1c7e1e77ac37d3f5995 | refs/heads/master | 2022-12-24T22:52:15.607000 | 2020-08-01T10:45:55 | 2020-08-01T10:45:55 | 247,601,502 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.dbdj1201.jpa.utils;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
* @author tyz1201
* @datetime 2020-04-11 16:48
* 解决实体管理器工厂的资源浪费问题
**/
public class JpaUtilsNew {
private static EntityManagerFactory entityManagerFactory;
static {
JpaUtilsNew.entityManagerFactory = Persistence.createEntityManagerFactory("myJpa");
}
//获取实体类的管理
public EntityManager getEntityManager() {
return entityManagerFactory.createEntityManager();
}
}
| UTF-8 | Java | 614 | java | JpaUtilsNew.java | Java | [
{
"context": "ort javax.persistence.Persistence;\n\n/**\n * @author tyz1201\n * @datetime 2020-04-11 16:48\n * 解决实体管理器工厂的资源浪费问题",
"end": 180,
"score": 0.9994528293609619,
"start": 173,
"tag": "USERNAME",
"value": "tyz1201"
}
] | null | [] | package cn.dbdj1201.jpa.utils;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
/**
* @author tyz1201
* @datetime 2020-04-11 16:48
* 解决实体管理器工厂的资源浪费问题
**/
public class JpaUtilsNew {
private static EntityManagerFactory entityManagerFactory;
static {
JpaUtilsNew.entityManagerFactory = Persistence.createEntityManagerFactory("myJpa");
}
//获取实体类的管理
public EntityManager getEntityManager() {
return entityManagerFactory.createEntityManager();
}
}
| 614 | 0.75265 | 0.717314 | 23 | 23.608696 | 23.861446 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304348 | false | false | 10 |
0b78cf2a05fa2e783db0817b7d8b2a40605ff0c2 | 31,473,520,355,500 | 5799f1cd477f72bef79b27d8c5650300ee8e2bd5 | /src/main/java/com/mycompany/mavenproject1/xlsx.java | 1e486714031f967a62cce952dee809cd7a622da3 | [] | no_license | kzkit/ExcelToMD | https://github.com/kzkit/ExcelToMD | 4a246879db299133d7852e1b136706973ab6b19a | 14cc1ba067fa61bf8859f328230372577640401a | refs/heads/master | 2020-03-13T03:24:27.459000 | 2018-04-25T03:11:24 | 2018-04-25T03:11:24 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.mavenproject1;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
*
* @author aspire
*/
public class xlsx {
public void convert(File inputFile, File outputFile) {
StringBuffer bf = new StringBuffer();
FileOutputStream fos = null;
String strGetValue = "";
try {
fos = new FileOutputStream(outputFile);
XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(inputFile));
XSSFSheet sheet = wb.getSheetAt(0);
Row row;
Cell cell;
int intRowCounter = 0;
Iterator<Row> rowIterator = sheet.iterator();
bf.append("# Hello World");
bf.append("\n");
bf.append("## I love french fries");
bf.append("\n");
bf.append("\n");
while (rowIterator.hasNext()) {
StringBuffer cellDData = new StringBuffer();
row = rowIterator.next();
int maxNumOfCells = sheet.getRow(0).getLastCellNum();
int cellCounter = 0;
while ((cellCounter) < maxNumOfCells) {
if (sheet.getRow(row.getRowNum()) != null
&& sheet.getRow(row.getRowNum()).getCell(cellCounter) != null) {
cell = sheet.getRow(row.getRowNum()).getCell(cellCounter);
switch (cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
strGetValue = cell.getBooleanCellValue() + "|";
cellDData.append(removeSpace(strGetValue));
break;
case Cell.CELL_TYPE_NUMERIC:
strGetValue = new BigDecimal(cell.getNumericCellValue()).toPlainString();
if (DateUtil.isCellDateFormatted(cell)) {
strGetValue = new DataFormatter().formatCellValue(cell);
} else {
strGetValue = new BigDecimal(cell.getNumericCellValue()).toPlainString();
}
String tempStrGetValue = removeSpace(strGetValue);
if (tempStrGetValue.length() == 0) {
strGetValue = " |";
cellDData.append(strGetValue);
} else {
strGetValue = strGetValue + "|";
cellDData.append(removeSpace(strGetValue));
}
break;
case Cell.CELL_TYPE_STRING:
strGetValue = cell.getStringCellValue();
String tempStrGetValue1 = removeSpace(strGetValue);
if (tempStrGetValue1.length() == 0) {
strGetValue = " |";
cellDData.append(strGetValue);
} else {
strGetValue = strGetValue + "|";
cellDData.append(removeSpace(strGetValue));
}
break;
case Cell.CELL_TYPE_BLANK:
strGetValue = "" + "|";
cellDData.append(removeSpace(strGetValue));
break;
default:
strGetValue = cell + "|";
cellDData.append(removeSpace(strGetValue));
}
} else {
strGetValue = "|";
cellDData.append(strGetValue);
}
cellCounter++;
}
String temp = cellDData.toString();
if (temp != null && temp.contains("|||")) {
temp = temp.replaceFirst("|||", "| |");
}
if (temp.endsWith("|")) {
temp = temp.substring(0, temp.lastIndexOf("|"));
cellDData = null;
bf.append(temp.trim());
}
bf.append("\n");
if( intRowCounter==0){
bf.append("---|---|----|---|");
bf.append("\n");
}
intRowCounter++;
}
fos.write(bf.toString().getBytes());
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (fos != null)
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private static String removeSpace(String strString) {
if (strString != null && !strString.equals("")) {
return strString.trim();
}
return strString;
}
}
| UTF-8 | Java | 5,336 | java | xlsx.java | Java | [
{
"context": "ssf.usermodel.XSSFWorkbook;\r\n\r\n/**\r\n *\r\n * @author aspire\r\n */\r\npublic class xlsx {\r\n public void conver",
"end": 686,
"score": 0.9758847951889038,
"start": 680,
"tag": "USERNAME",
"value": "aspire"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package com.mycompany.mavenproject1;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.math.BigDecimal;
import java.util.Iterator;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
*
* @author aspire
*/
public class xlsx {
public void convert(File inputFile, File outputFile) {
StringBuffer bf = new StringBuffer();
FileOutputStream fos = null;
String strGetValue = "";
try {
fos = new FileOutputStream(outputFile);
XSSFWorkbook wb = new XSSFWorkbook(new FileInputStream(inputFile));
XSSFSheet sheet = wb.getSheetAt(0);
Row row;
Cell cell;
int intRowCounter = 0;
Iterator<Row> rowIterator = sheet.iterator();
bf.append("# Hello World");
bf.append("\n");
bf.append("## I love french fries");
bf.append("\n");
bf.append("\n");
while (rowIterator.hasNext()) {
StringBuffer cellDData = new StringBuffer();
row = rowIterator.next();
int maxNumOfCells = sheet.getRow(0).getLastCellNum();
int cellCounter = 0;
while ((cellCounter) < maxNumOfCells) {
if (sheet.getRow(row.getRowNum()) != null
&& sheet.getRow(row.getRowNum()).getCell(cellCounter) != null) {
cell = sheet.getRow(row.getRowNum()).getCell(cellCounter);
switch (cell.getCellType()) {
case Cell.CELL_TYPE_BOOLEAN:
strGetValue = cell.getBooleanCellValue() + "|";
cellDData.append(removeSpace(strGetValue));
break;
case Cell.CELL_TYPE_NUMERIC:
strGetValue = new BigDecimal(cell.getNumericCellValue()).toPlainString();
if (DateUtil.isCellDateFormatted(cell)) {
strGetValue = new DataFormatter().formatCellValue(cell);
} else {
strGetValue = new BigDecimal(cell.getNumericCellValue()).toPlainString();
}
String tempStrGetValue = removeSpace(strGetValue);
if (tempStrGetValue.length() == 0) {
strGetValue = " |";
cellDData.append(strGetValue);
} else {
strGetValue = strGetValue + "|";
cellDData.append(removeSpace(strGetValue));
}
break;
case Cell.CELL_TYPE_STRING:
strGetValue = cell.getStringCellValue();
String tempStrGetValue1 = removeSpace(strGetValue);
if (tempStrGetValue1.length() == 0) {
strGetValue = " |";
cellDData.append(strGetValue);
} else {
strGetValue = strGetValue + "|";
cellDData.append(removeSpace(strGetValue));
}
break;
case Cell.CELL_TYPE_BLANK:
strGetValue = "" + "|";
cellDData.append(removeSpace(strGetValue));
break;
default:
strGetValue = cell + "|";
cellDData.append(removeSpace(strGetValue));
}
} else {
strGetValue = "|";
cellDData.append(strGetValue);
}
cellCounter++;
}
String temp = cellDData.toString();
if (temp != null && temp.contains("|||")) {
temp = temp.replaceFirst("|||", "| |");
}
if (temp.endsWith("|")) {
temp = temp.substring(0, temp.lastIndexOf("|"));
cellDData = null;
bf.append(temp.trim());
}
bf.append("\n");
if( intRowCounter==0){
bf.append("---|---|----|---|");
bf.append("\n");
}
intRowCounter++;
}
fos.write(bf.toString().getBytes());
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
} finally {
try {
if (fos != null)
fos.close();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
private static String removeSpace(String strString) {
if (strString != null && !strString.equals("")) {
return strString.trim();
}
return strString;
}
}
| 5,336 | 0.47901 | 0.476949 | 134 | 37.820896 | 22.021988 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.768657 | false | false | 10 |
ac837aff4d04a188d58bc716b9c479d15c24e1dd | 1,881,195,692,777 | 7cf02d59afbbbc7b3bb26069ba05270ed4b353e1 | /src/Java0222/FileDemo/Test09.java | 2f2c138b4d025b0adb9b569c903fad7682718345 | [] | no_license | Aaronhxl/study | https://github.com/Aaronhxl/study | 78948a629a40632e3406227d67e0f9792816ece3 | 3d90a375cfe8d64a72a93ee3724a730c7f230083 | refs/heads/master | 2022-01-05T17:07:14.508000 | 2019-07-20T13:34:31 | 2019-07-20T13:34:31 | 197,934,377 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Java0222.FileDemo;
import java.io.File;
/**
* 文件过滤器的使用
* String[] list(FilenameFilter filter)
* 返回一个字符串数组,这些字符串指定此抽象路径名表示的目录中满足指定过滤器的文件和目录。
* File[] listFiles(FilenameFilter filter)
* 返回抽象路径名数组,这些路径名表示此抽象路径名表示的目录中满足指定过滤器的文件和目录。
*/
public class Test09 {
public static void main(String[] args) {
File[] files = File.listRoots();
for (File file : files) {
System.out.println(file);
}
}
}
| UTF-8 | Java | 654 | java | Test09.java | Java | [] | null | [] | package Java0222.FileDemo;
import java.io.File;
/**
* 文件过滤器的使用
* String[] list(FilenameFilter filter)
* 返回一个字符串数组,这些字符串指定此抽象路径名表示的目录中满足指定过滤器的文件和目录。
* File[] listFiles(FilenameFilter filter)
* 返回抽象路径名数组,这些路径名表示此抽象路径名表示的目录中满足指定过滤器的文件和目录。
*/
public class Test09 {
public static void main(String[] args) {
File[] files = File.listRoots();
for (File file : files) {
System.out.println(file);
}
}
}
| 654 | 0.637339 | 0.624463 | 20 | 22.299999 | 19.19401 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 10 |
a4943e753c07c4e934f8bb752f662febf7b5cc65 | 26,087,631,425,810 | 0d9ecef6e8ce2cb437711f312e2f5b50bd2cfbba | /src/test/java/com/hust/mem/Test4396.java | 9910aa32cdd9e29e63dd2bb8bebe6c0c28d12af5 | [] | no_license | ksyzz/mem | https://github.com/ksyzz/mem | 678f7310845eb431911cc9af8b029f2414d5feb0 | 0643b79f06d12234f07b24ea224225032bcaccd6 | refs/heads/master | 2020-03-13T03:20:47.649000 | 2018-05-11T06:53:52 | 2018-05-11T06:53:52 | 130,942,292 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hust.mem;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MemApplication.class)
@Sql("/init.sql")
public class Test4396 {
@Test()
public void runInit(){
}
}
| UTF-8 | Java | 419 | java | Test4396.java | Java | [] | null | [] | package com.hust.mem;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.jdbc.Sql;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MemApplication.class)
@Sql("/init.sql")
public class Test4396 {
@Test()
public void runInit(){
}
}
| 419 | 0.77327 | 0.761337 | 17 | 23.647058 | 19.819601 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false | 10 |
c72276c52f6500d25783d046c22e90fd203e3478 | 27,565,100,174,327 | 743d3a06df2ff5094224cee398ac00f6fcd8a6f5 | /src/test/java/SpringDataTest1.java | 08470eb9b4f3cb469ca136236d77718e54fd4ce3 | [] | no_license | 2249692487/springDataJpaDemo | https://github.com/2249692487/springDataJpaDemo | 3fb509c29f7a840db6666622efb8ea05398ab7c0 | 57c882d2d3062f3a66817ceaf0da44a4de99b7cd | refs/heads/master | 2020-04-29T14:23:12.266000 | 2019-03-18T03:02:22 | 2019-03-18T03:02:22 | 176,194,633 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import com.test.dao.CustomerDao;
import com.test.dao.CustomerExtDao;
import com.test.pojo.Customer;
import com.test.pojo.CustomerExt;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
/**
* 描述:测试一对一
* </p>
*
* @author QinLiNa
* @data 2019/3/18
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class SpringDataTest1 {
@Autowired
private CustomerDao customerDao;
@Autowired
private CustomerExtDao extDao;
@Test
//保存客户|客户的扩展信息
@Transactional
@Commit
public void fun1() {
//创建客户
Customer c = new Customer();
c.setCustName("Hello World !!!");
//创建扩展信息
CustomerExt ext = new CustomerExt();
ext.setInfo("你好!");
//表达关系
c.setExt(ext);
//保存客户|扩展信息
customerDao.save(c);
extDao.save(ext);
}
@Test
//删除客户并删除客户关联的扩展信息
@Transactional
@Commit
public void fun2() {
customerDao.delete(6L);
extDao.delete(1L);
}
}
| UTF-8 | Java | 1,481 | java | SpringDataTest1.java | Java | [
{
"context": "nsactional;\n\n/**\n * 描述:测试一对一\n * </p>\n *\n * @author QinLiNa\n * @data 2019/3/18\n */\n@RunWith(SpringJUnit4Class",
"end": 549,
"score": 0.9993570446968079,
"start": 542,
"tag": "NAME",
"value": "QinLiNa"
}
] | null | [] | import com.test.dao.CustomerDao;
import com.test.dao.CustomerExtDao;
import com.test.pojo.Customer;
import com.test.pojo.CustomerExt;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.annotation.Commit;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
/**
* 描述:测试一对一
* </p>
*
* @author QinLiNa
* @data 2019/3/18
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:applicationContext.xml")
public class SpringDataTest1 {
@Autowired
private CustomerDao customerDao;
@Autowired
private CustomerExtDao extDao;
@Test
//保存客户|客户的扩展信息
@Transactional
@Commit
public void fun1() {
//创建客户
Customer c = new Customer();
c.setCustName("Hello World !!!");
//创建扩展信息
CustomerExt ext = new CustomerExt();
ext.setInfo("你好!");
//表达关系
c.setExt(ext);
//保存客户|扩展信息
customerDao.save(c);
extDao.save(ext);
}
@Test
//删除客户并删除客户关联的扩展信息
@Transactional
@Commit
public void fun2() {
customerDao.delete(6L);
extDao.delete(1L);
}
}
| 1,481 | 0.685253 | 0.674248 | 55 | 23.781818 | 18.066233 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.436364 | false | false | 10 |
75aa50746541fdcc1870604d935e4ad00cb647fd | 35,888,746,767,336 | 6c78507cefba02131426935aa7e00fce4a5f9eb2 | /src/APPDidattica/src/nu/mine/egoless/didattica/app/gui/registroDocente/RegistroInsegnantePanel.java | a94f0cbab549de4a8dfffe47a04dd02829222ccf | [] | no_license | egoless/pqs | https://github.com/egoless/pqs | 1a1b048bfe194d40ac0d6f9e72b0c33a9675cf50 | 1733d0b0c6e4b02d19f234dd8c50ad122dcd0fce | refs/heads/master | 2021-01-02T09:31:57.205000 | 2012-06-26T18:35:40 | 2012-06-26T18:35:40 | 4,742,809 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* RegistroInsegnantePanel.java
*
* Created on 8 marzo 2007, 23.36
*
* $Id$
*/
package nu.mine.egoless.didattica.app.gui.registroDocente;
import java.util.Date;
import nu.mine.egoless.didattica.app.bean.ClasseBean;
import nu.mine.egoless.didattica.app.bean.ClassiBean;
import nu.mine.egoless.didattica.app.bean.MateriaInsegnamentoBean;
import nu.mine.egoless.didattica.app.bean.MaterieInsegnamentoBean;
import nu.mine.egoless.didattica.app.bean.NazioniBean;
import nu.mine.egoless.didattica.app.bean.ReligioniBean;
import nu.mine.egoless.didattica.app.bean.TipiAssenzeBean;
import nu.mine.egoless.didattica.app.bean.TipiVotiBean;
import nu.mine.egoless.didattica.app.gui.componentiComuni.BarraDiStatoPanel;
import nu.mine.egoless.didattica.app.gui.componentiComuni.ContenitoreDati;
import nu.mine.egoless.didattica.app.gui.componentiComuni.UtilitaGUI;
import nu.mine.egoless.didattica.ws.personaclient.Studente;
/**
* Interfaccia grafica da cui un docente può gestire una lezione.
*
* @author Alberto Meneghello
*/
public class RegistroInsegnantePanel extends javax.swing.JPanel {
/**
* Crea un nuovo form RegistroInsegnantePanel
* @param contenitoreDati Oggetto da cui preleva i dati semplici
* fissi, precaricati al caricamento dell'applicazione.
*/
public RegistroInsegnantePanel (ContenitoreDati contenitoreDati) {
this.contenitoreDati = contenitoreDati;
if(contenitoreDati==null) caricaDati();
inizializzaComponenti ();
}
/**
* Inizializza le componenti della GUI.
*/
private void inizializzaComponenti () {
initComponents();
add (new SelezionaRegistroPanel(this) , "North" );
barraStato = new BarraDiStatoPanel();
add( barraStato, "South");
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jsplRegistroInsegnante = new javax.swing.JSplitPane();
jtbpDatiStudente = new javax.swing.JTabbedPane();
jtbpRegistri = new javax.swing.JTabbedPane();
setLayout(new java.awt.BorderLayout());
setBackground(new java.awt.Color(153, 153, 255));
jsplRegistroInsegnante.setBackground(new java.awt.Color(153, 153, 255));
jsplRegistroInsegnante.setResizeWeight(0.7);
jtbpDatiStudente.setBackground(new java.awt.Color(204, 204, 255));
jtbpDatiStudente.setOpaque(true);
jsplRegistroInsegnante.setRightComponent(jtbpDatiStudente);
jtbpRegistri.setBackground(new java.awt.Color(213, 213, 252));
jtbpRegistri.setOpaque(true);
jsplRegistroInsegnante.setLeftComponent(jtbpRegistri);
add(jsplRegistroInsegnante, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
/**
* Apre nel tab sinistro una nuova pagina che visualizza il registro docente
* corrispondente ai parametri selezionati.
* @param classe Oggetto ClasseBean che modella la classe a cui si riferisce il registro.
* @param materia Materia a cui si riferisce il registro.
* @param data Data della pagina del registro.
*/
public void apriNuovoRegistro( ClasseBean classe, MateriaInsegnamentoBean materia, Date data ) {
if( !isApertoRegistro ( classe, materia, data) ) {
RegistroPanel registro = new RegistroPanel(this, classe, materia, data);
jtbpRegistri.addTab ("Registro", registro );
UtilitaGUI.initTabComponent (jtbpRegistri, registro , "Registro "+materia.getNome () );
jtbpRegistri.setSelectedComponent (registro);
}
}
/**
* Controlla se una pagina di registro e' gia' aperta.
* @param classe Identifica la pagina da controlllare.
* @param materia Identifica la pagina da controlllare.
* @param data Identifica la pagina da controlllare.
* @returns true Ritorna true se e solo se e' gia aperta
* una pagina per i parametri selezionati.
*/
public boolean isApertoRegistro( ClasseBean classe, MateriaInsegnamentoBean materia, Date data ){
for(int i=0; i<jtbpRegistri.getTabCount(); i++){
javax.swing.JPanel pannello = (javax.swing.JPanel) jtbpRegistri.getComponentAt(i);
if( pannello instanceof RegistroPanel &&
((RegistroPanel)pannello).corrispondeA(classe, materia, data) ) {
jtbpRegistri.setSelectedIndex(i);
return true;
}
}
return false;
}
/**
* Chiude la pagina di registro corrente.
* @param registro Pagina registro da chiudere.
*/
public void chiudiRegistro(RegistroPanel registro) //ParametriRegistro param )
{
jtbpRegistri.remove(registro);
}
/**
* Apre una nuova pagina nel tab destro, contentente i dati dello studente.
* @param materia Materia del registro.
* @param studente Studente di cui visualizzare i dati.
* @param dato Dato didattico associato allo studente (assenza, voto o null).
* @param data Data del giorno cui il registro si riferisce.
*/
public void apriNuovoGestioneDatiStudente( RegistroPanel registro, MateriaInsegnamentoBean materia, Studente studente, Object dato, Date data) {
if( studente!=null && !isApertoGestioneDatiStudente(studente) ) {
String nomeStudente = studente.getCognome () +" "+studente.getNome ();
GestioneDatiStudentePanel gestioneStudente = new GestioneDatiStudentePanel(this, registro, materia, studente, dato, data);
jtbpDatiStudente.addTab (nomeStudente, gestioneStudente ); // this, param) );
UtilitaGUI.initTabComponent (jtbpDatiStudente, gestioneStudente , "" );
jtbpDatiStudente.setSelectedComponent (gestioneStudente);
}
}
/**
* Controlla se una pagina dedicata da uno studente e' gia' aperta.
* @param studente Lo studente da controllare.
* @returns true Ritorna true se e solo se e' gia aperta
* una pagina dedicata allo studente
*/
public boolean isApertoGestioneDatiStudente(Studente studente) {
for(int i=0; i<jtbpDatiStudente.getTabCount(); i++){
javax.swing.JPanel pannello = (javax.swing.JPanel) jtbpDatiStudente.getComponentAt(i);
if( pannello instanceof GestioneDatiStudentePanel &&
((GestioneDatiStudentePanel)pannello).corrispondeA(studente) ){
jtbpDatiStudente.setSelectedIndex(i);
return true;
}
}
return false;
}
/**
* Chiude una pagina dei dati dello studente (quella del tab destro).
* @param pannello Pannello da chiudere.
*/
public void chiudiGestioneDatiStudente(GestioneDatiStudentePanel pannello) {
jtbpDatiStudente.remove(pannello);
}
/**
* Setta il testo della Status Bar.
* @param testo Stringa di testo da visualizzare.
*/
public void setTesto(String testo) {
barraStato.setTesto (testo);
}
/**
* Setta il valore della barra di Download ad un certo valore.
* @param n Il valora a cui settare la barra.
*/
public void setValoreDownload(int n){
if (n<0) barraStato.setDownloadIndeterminato(true);
else { barraStato.setDownloadIndeterminato(false); barraStato.setValoreDownload(n); }
}
/**
* Setta il valore della barra di Upload ad un certo valore.
* @param n Il valora a cui settare la barra.
*/
public void setValoreUpload(int n){
if (n<0) barraStato.setUploadIndeterminato(true);
else { barraStato.setUploadIndeterminato(false); barraStato.setValoreUpload(n); }
}
/**
* Visualizza un mesaggio di warning riportante un messaggio.
* @param string Testo del messaggio da visualizzare;
* se null viene impostato di default il messaggio
* "Impossibile completare l'operazione.".
*/
public void showMessage(String string) {
if(string == null) string = "Impossibile completare l'operazione.";
javax.swing.JOptionPane.showMessageDialog(this,string);
}
/**
* Ritorna un contenitore di dati semplici,
* precaricati all'inizio dell'applicazione.
*/
public ContenitoreDati getContenitoreDati() {
return contenitoreDati;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSplitPane jsplRegistroInsegnante;
private javax.swing.JTabbedPane jtbpDatiStudente;
private javax.swing.JTabbedPane jtbpRegistri;
// End of variables declaration//GEN-END:variables
private BarraDiStatoPanel barraStato;
private ContenitoreDati contenitoreDati;
/**
* Avvia un'anteprima dell'interfaccia grafica.
*/
public static void main(String[] args) {
String str = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try { javax.swing.UIManager.setLookAndFeel(str); }
catch (Exception ex) { System.out.println("Failed loading Look And Feel:\n"+ex+'\n'); }
javax.swing.JFrame temp=new javax.swing.JFrame();
temp.setLayout(new java.awt.BorderLayout());
temp.add(new RegistroInsegnantePanel( null ));
temp.setSize(800,600);
temp.setVisible(true);
}
private boolean caricaDati() {
NazioniBean nazioniBean = null;
ReligioniBean religioniBean = null;
ClassiBean classiBean = null;
MaterieInsegnamentoBean materieBean = null;
TipiVotiBean tipiVotiBean = null;
TipiAssenzeBean tipiAssenzeBean = null;
//inizializza le variabili locali
religioniBean = new ReligioniBean();
nazioniBean = new NazioniBean();
classiBean = new ClassiBean();
materieBean = new MaterieInsegnamentoBean();
tipiVotiBean = new TipiVotiBean();
tipiAssenzeBean = new TipiAssenzeBean();
boolean ecc = true; //traccia il fallimento nel caricamento di qualche dato
int step = 100/6; //passo di aumento della barra di progresso
String missed = ""; //traccia i dati che non si è riusciti a caricare
System.out.println("GuiFrame: Caricamento Dati Iniziali") ;
try{
System.out.println("Inizio del caricamento della lista delle religioni");
religioniBean.caricaReligioni();
}catch(Exception e){missed += "religioni; "; System.out.println("Fallito il caricamento della lista delle religioni"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dellle nazioni");
nazioniBean.caricaNazioni();
}catch(Exception e){missed += "nazioni; "; System.out.println("Fallito il caricamento della lista dellle nazioni"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista classi");
classiBean.caricaClassi();
}catch(Exception e){missed += "classi; "; System.out.println("Fallito il caricamento della lista classi"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista materie");
materieBean.caricaMaterie();
}catch(Exception e){missed += "materie; "; System.out.println("Fallito il caricamento della lista delle materie"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dei tipi di voto");
tipiVotiBean.caricaTipiVoti();
}catch(Exception e){missed += "tipi di voto; "; System.out.println("Fallito il caricamento della lista dei tipi di voto"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dei tipi di assenza");
tipiAssenzeBean.caricaTipiAssenze();
}catch(Exception e){missed += "tipi di assenze; "; System.out.println("Fallito il caricamento della lista dei tipi di assenza"); ecc=false;}
if(ecc) System.out.println("Caricamento completato con successo");
else { //se è fallito i caricamento di qualche dato
System.out.println("GUIFrame: Errore di Caricamento: "+missed);
}
contenitoreDati = new ContenitoreDati(religioniBean, nazioniBean, classiBean, materieBean, tipiVotiBean, tipiAssenzeBean, null);
return ecc;
}
}
| WINDOWS-1252 | Java | 13,110 | java | RegistroInsegnantePanel.java | Java | [
{
"context": " docente può gestire una lezione.\r\n *\r\n * @author Alberto Meneghello\r\n */\r\npublic class RegistroInsegnantePanel extend",
"end": 1065,
"score": 0.999888002872467,
"start": 1047,
"tag": "NAME",
"value": "Alberto Meneghello"
}
] | null | [] | /*
* RegistroInsegnantePanel.java
*
* Created on 8 marzo 2007, 23.36
*
* $Id$
*/
package nu.mine.egoless.didattica.app.gui.registroDocente;
import java.util.Date;
import nu.mine.egoless.didattica.app.bean.ClasseBean;
import nu.mine.egoless.didattica.app.bean.ClassiBean;
import nu.mine.egoless.didattica.app.bean.MateriaInsegnamentoBean;
import nu.mine.egoless.didattica.app.bean.MaterieInsegnamentoBean;
import nu.mine.egoless.didattica.app.bean.NazioniBean;
import nu.mine.egoless.didattica.app.bean.ReligioniBean;
import nu.mine.egoless.didattica.app.bean.TipiAssenzeBean;
import nu.mine.egoless.didattica.app.bean.TipiVotiBean;
import nu.mine.egoless.didattica.app.gui.componentiComuni.BarraDiStatoPanel;
import nu.mine.egoless.didattica.app.gui.componentiComuni.ContenitoreDati;
import nu.mine.egoless.didattica.app.gui.componentiComuni.UtilitaGUI;
import nu.mine.egoless.didattica.ws.personaclient.Studente;
/**
* Interfaccia grafica da cui un docente può gestire una lezione.
*
* @author <NAME>
*/
public class RegistroInsegnantePanel extends javax.swing.JPanel {
/**
* Crea un nuovo form RegistroInsegnantePanel
* @param contenitoreDati Oggetto da cui preleva i dati semplici
* fissi, precaricati al caricamento dell'applicazione.
*/
public RegistroInsegnantePanel (ContenitoreDati contenitoreDati) {
this.contenitoreDati = contenitoreDati;
if(contenitoreDati==null) caricaDati();
inizializzaComponenti ();
}
/**
* Inizializza le componenti della GUI.
*/
private void inizializzaComponenti () {
initComponents();
add (new SelezionaRegistroPanel(this) , "North" );
barraStato = new BarraDiStatoPanel();
add( barraStato, "South");
}
/**
* This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
jsplRegistroInsegnante = new javax.swing.JSplitPane();
jtbpDatiStudente = new javax.swing.JTabbedPane();
jtbpRegistri = new javax.swing.JTabbedPane();
setLayout(new java.awt.BorderLayout());
setBackground(new java.awt.Color(153, 153, 255));
jsplRegistroInsegnante.setBackground(new java.awt.Color(153, 153, 255));
jsplRegistroInsegnante.setResizeWeight(0.7);
jtbpDatiStudente.setBackground(new java.awt.Color(204, 204, 255));
jtbpDatiStudente.setOpaque(true);
jsplRegistroInsegnante.setRightComponent(jtbpDatiStudente);
jtbpRegistri.setBackground(new java.awt.Color(213, 213, 252));
jtbpRegistri.setOpaque(true);
jsplRegistroInsegnante.setLeftComponent(jtbpRegistri);
add(jsplRegistroInsegnante, java.awt.BorderLayout.CENTER);
}// </editor-fold>//GEN-END:initComponents
/**
* Apre nel tab sinistro una nuova pagina che visualizza il registro docente
* corrispondente ai parametri selezionati.
* @param classe Oggetto ClasseBean che modella la classe a cui si riferisce il registro.
* @param materia Materia a cui si riferisce il registro.
* @param data Data della pagina del registro.
*/
public void apriNuovoRegistro( ClasseBean classe, MateriaInsegnamentoBean materia, Date data ) {
if( !isApertoRegistro ( classe, materia, data) ) {
RegistroPanel registro = new RegistroPanel(this, classe, materia, data);
jtbpRegistri.addTab ("Registro", registro );
UtilitaGUI.initTabComponent (jtbpRegistri, registro , "Registro "+materia.getNome () );
jtbpRegistri.setSelectedComponent (registro);
}
}
/**
* Controlla se una pagina di registro e' gia' aperta.
* @param classe Identifica la pagina da controlllare.
* @param materia Identifica la pagina da controlllare.
* @param data Identifica la pagina da controlllare.
* @returns true Ritorna true se e solo se e' gia aperta
* una pagina per i parametri selezionati.
*/
public boolean isApertoRegistro( ClasseBean classe, MateriaInsegnamentoBean materia, Date data ){
for(int i=0; i<jtbpRegistri.getTabCount(); i++){
javax.swing.JPanel pannello = (javax.swing.JPanel) jtbpRegistri.getComponentAt(i);
if( pannello instanceof RegistroPanel &&
((RegistroPanel)pannello).corrispondeA(classe, materia, data) ) {
jtbpRegistri.setSelectedIndex(i);
return true;
}
}
return false;
}
/**
* Chiude la pagina di registro corrente.
* @param registro Pagina registro da chiudere.
*/
public void chiudiRegistro(RegistroPanel registro) //ParametriRegistro param )
{
jtbpRegistri.remove(registro);
}
/**
* Apre una nuova pagina nel tab destro, contentente i dati dello studente.
* @param materia Materia del registro.
* @param studente Studente di cui visualizzare i dati.
* @param dato Dato didattico associato allo studente (assenza, voto o null).
* @param data Data del giorno cui il registro si riferisce.
*/
public void apriNuovoGestioneDatiStudente( RegistroPanel registro, MateriaInsegnamentoBean materia, Studente studente, Object dato, Date data) {
if( studente!=null && !isApertoGestioneDatiStudente(studente) ) {
String nomeStudente = studente.getCognome () +" "+studente.getNome ();
GestioneDatiStudentePanel gestioneStudente = new GestioneDatiStudentePanel(this, registro, materia, studente, dato, data);
jtbpDatiStudente.addTab (nomeStudente, gestioneStudente ); // this, param) );
UtilitaGUI.initTabComponent (jtbpDatiStudente, gestioneStudente , "" );
jtbpDatiStudente.setSelectedComponent (gestioneStudente);
}
}
/**
* Controlla se una pagina dedicata da uno studente e' gia' aperta.
* @param studente Lo studente da controllare.
* @returns true Ritorna true se e solo se e' gia aperta
* una pagina dedicata allo studente
*/
public boolean isApertoGestioneDatiStudente(Studente studente) {
for(int i=0; i<jtbpDatiStudente.getTabCount(); i++){
javax.swing.JPanel pannello = (javax.swing.JPanel) jtbpDatiStudente.getComponentAt(i);
if( pannello instanceof GestioneDatiStudentePanel &&
((GestioneDatiStudentePanel)pannello).corrispondeA(studente) ){
jtbpDatiStudente.setSelectedIndex(i);
return true;
}
}
return false;
}
/**
* Chiude una pagina dei dati dello studente (quella del tab destro).
* @param pannello Pannello da chiudere.
*/
public void chiudiGestioneDatiStudente(GestioneDatiStudentePanel pannello) {
jtbpDatiStudente.remove(pannello);
}
/**
* Setta il testo della Status Bar.
* @param testo Stringa di testo da visualizzare.
*/
public void setTesto(String testo) {
barraStato.setTesto (testo);
}
/**
* Setta il valore della barra di Download ad un certo valore.
* @param n Il valora a cui settare la barra.
*/
public void setValoreDownload(int n){
if (n<0) barraStato.setDownloadIndeterminato(true);
else { barraStato.setDownloadIndeterminato(false); barraStato.setValoreDownload(n); }
}
/**
* Setta il valore della barra di Upload ad un certo valore.
* @param n Il valora a cui settare la barra.
*/
public void setValoreUpload(int n){
if (n<0) barraStato.setUploadIndeterminato(true);
else { barraStato.setUploadIndeterminato(false); barraStato.setValoreUpload(n); }
}
/**
* Visualizza un mesaggio di warning riportante un messaggio.
* @param string Testo del messaggio da visualizzare;
* se null viene impostato di default il messaggio
* "Impossibile completare l'operazione.".
*/
public void showMessage(String string) {
if(string == null) string = "Impossibile completare l'operazione.";
javax.swing.JOptionPane.showMessageDialog(this,string);
}
/**
* Ritorna un contenitore di dati semplici,
* precaricati all'inizio dell'applicazione.
*/
public ContenitoreDati getContenitoreDati() {
return contenitoreDati;
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JSplitPane jsplRegistroInsegnante;
private javax.swing.JTabbedPane jtbpDatiStudente;
private javax.swing.JTabbedPane jtbpRegistri;
// End of variables declaration//GEN-END:variables
private BarraDiStatoPanel barraStato;
private ContenitoreDati contenitoreDati;
/**
* Avvia un'anteprima dell'interfaccia grafica.
*/
public static void main(String[] args) {
String str = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
try { javax.swing.UIManager.setLookAndFeel(str); }
catch (Exception ex) { System.out.println("Failed loading Look And Feel:\n"+ex+'\n'); }
javax.swing.JFrame temp=new javax.swing.JFrame();
temp.setLayout(new java.awt.BorderLayout());
temp.add(new RegistroInsegnantePanel( null ));
temp.setSize(800,600);
temp.setVisible(true);
}
private boolean caricaDati() {
NazioniBean nazioniBean = null;
ReligioniBean religioniBean = null;
ClassiBean classiBean = null;
MaterieInsegnamentoBean materieBean = null;
TipiVotiBean tipiVotiBean = null;
TipiAssenzeBean tipiAssenzeBean = null;
//inizializza le variabili locali
religioniBean = new ReligioniBean();
nazioniBean = new NazioniBean();
classiBean = new ClassiBean();
materieBean = new MaterieInsegnamentoBean();
tipiVotiBean = new TipiVotiBean();
tipiAssenzeBean = new TipiAssenzeBean();
boolean ecc = true; //traccia il fallimento nel caricamento di qualche dato
int step = 100/6; //passo di aumento della barra di progresso
String missed = ""; //traccia i dati che non si è riusciti a caricare
System.out.println("GuiFrame: Caricamento Dati Iniziali") ;
try{
System.out.println("Inizio del caricamento della lista delle religioni");
religioniBean.caricaReligioni();
}catch(Exception e){missed += "religioni; "; System.out.println("Fallito il caricamento della lista delle religioni"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dellle nazioni");
nazioniBean.caricaNazioni();
}catch(Exception e){missed += "nazioni; "; System.out.println("Fallito il caricamento della lista dellle nazioni"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista classi");
classiBean.caricaClassi();
}catch(Exception e){missed += "classi; "; System.out.println("Fallito il caricamento della lista classi"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista materie");
materieBean.caricaMaterie();
}catch(Exception e){missed += "materie; "; System.out.println("Fallito il caricamento della lista delle materie"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dei tipi di voto");
tipiVotiBean.caricaTipiVoti();
}catch(Exception e){missed += "tipi di voto; "; System.out.println("Fallito il caricamento della lista dei tipi di voto"); ecc=false;}
try{
System.out.println("Inizio del caricamento della lista dei tipi di assenza");
tipiAssenzeBean.caricaTipiAssenze();
}catch(Exception e){missed += "tipi di assenze; "; System.out.println("Fallito il caricamento della lista dei tipi di assenza"); ecc=false;}
if(ecc) System.out.println("Caricamento completato con successo");
else { //se è fallito i caricamento di qualche dato
System.out.println("GUIFrame: Errore di Caricamento: "+missed);
}
contenitoreDati = new ContenitoreDati(religioniBean, nazioniBean, classiBean, materieBean, tipiVotiBean, tipiAssenzeBean, null);
return ecc;
}
}
| 13,098 | 0.646677 | 0.642023 | 345 | 35.991302 | 33.323055 | 158 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.556522 | false | false | 10 |
f58533cfbfcaf231a596839d16d1edebfa2abe58 | 36,318,243,498,379 | fe0e31dbc818a9831fa96ec764d60a5e83c296e0 | /crontab/src/main/java/cn/itfh/crontab/service/CronTaskService.java | b127022e7d542a0a35904022de4c2b130d01716f | [] | no_license | FANHUIMotF/Idea_learn_all | https://github.com/FANHUIMotF/Idea_learn_all | 894d2fbb6b9a52c1b8f4f2f628b861c33494a10a | 223d8b7faf3d2ccd3dce14e6a359fc240d6c7c01 | refs/heads/master | 2022-12-20T20:17:35.847000 | 2020-09-28T09:29:56 | 2020-09-28T09:29:56 | 285,247,314 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.itfh.crontab.service;
import cn.itfh.crontab.entity.CronTaskEntity;
import cn.itfh.crontab.task.Job;
import java.util.List;
/***
*
* @className: CronTaskService
* @author: fh
* @date: 2020/7/29
* @version : V1.0
*/
public interface CronTaskService {
/**
* 查询所有定时任务
* @return
*/
List<CronTaskEntity> findAll();
/**
* 执行任务,返回最新的cron
* @param className
* @param job
*/
String execute(String className,Job job);
/**
* 根据主键查找定时任务
* @param className
* @return
*/
CronTaskEntity findByPriKey(String className);
/**
* 添加定时任务
* @param cronTaskEntity
*/
void addTask(CronTaskEntity cronTaskEntity);
/**
* 删除定时任务
* @param className
*/
void delTask(String className);
/**
* 暂停任务
* @param className
*/
void suspendTask(String className);
/**
* 开启任务
* @param className
*/
void runTask(String className);
/**
* 立刻执行定时任务
* @param className
*/
void doNow(String className);
/**
* 修改任务执行状态
* @param className
* @param status
*/
void updateStatus(String className,String status);
}
| UTF-8 | Java | 1,345 | java | CronTaskService.java | Java | [
{
"context": "**\n *\n * @className: CronTaskService\n * @author: fh\n * @date: 2020/7/29\n * @version : V1.0\n */\npubl",
"end": 193,
"score": 0.9938865303993225,
"start": 191,
"tag": "USERNAME",
"value": "fh"
}
] | null | [] | package cn.itfh.crontab.service;
import cn.itfh.crontab.entity.CronTaskEntity;
import cn.itfh.crontab.task.Job;
import java.util.List;
/***
*
* @className: CronTaskService
* @author: fh
* @date: 2020/7/29
* @version : V1.0
*/
public interface CronTaskService {
/**
* 查询所有定时任务
* @return
*/
List<CronTaskEntity> findAll();
/**
* 执行任务,返回最新的cron
* @param className
* @param job
*/
String execute(String className,Job job);
/**
* 根据主键查找定时任务
* @param className
* @return
*/
CronTaskEntity findByPriKey(String className);
/**
* 添加定时任务
* @param cronTaskEntity
*/
void addTask(CronTaskEntity cronTaskEntity);
/**
* 删除定时任务
* @param className
*/
void delTask(String className);
/**
* 暂停任务
* @param className
*/
void suspendTask(String className);
/**
* 开启任务
* @param className
*/
void runTask(String className);
/**
* 立刻执行定时任务
* @param className
*/
void doNow(String className);
/**
* 修改任务执行状态
* @param className
* @param status
*/
void updateStatus(String className,String status);
}
| 1,345 | 0.571898 | 0.564503 | 72 | 15.902778 | 13.917575 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.208333 | false | false | 10 |
d4fa5ea3f9283fe1a0eeeb9031c669324074172c | 35,862,976,965,537 | 4006327a5b8c07b2321d8dc6dcb5800601a74de0 | /src/Main.java | aca788d97d9e6f8ef9da7286b5507bb6a70dcc22 | [] | no_license | pedrosv/SorteioTimes | https://github.com/pedrosv/SorteioTimes | f3392e5d6ad81d02a35af399c0863d890f8e6eac | 8c1b5a53d8a80f6b5186eb23212c535de1e4145b | refs/heads/master | 2019-07-24T05:25:15.763000 | 2017-02-13T12:22:27 | 2017-02-13T12:22:27 | 81,821,630 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<Time> times = criaTimes();
ArrayList<Jogador> atletas = criaJogadores();
int tamanhoTime = 5; //receber de entrada
Sorteador s = new Sorteador(tamanhoTime,atletas, times);
//s.sorteie();
}
private static ArrayList<Time> criaTimes(){
//criando times
String[] NomeTimes = {"Azul", "Branco", "Verde", "sem camisa"};
int numDeTimes = 4; //sera variavel no futuro
ArrayList<Time> times = new ArrayList<Time>();
for(int i = 0; i < numDeTimes; i++){
Time novoTime = new Time(NomeTimes[i]);
times.add(novoTime);
}
return times;
}
private static ArrayList<Jogador> criaJogadores(){
//criando jogadores
//futuramente pegar de um arquivo as informacoes
ArrayList<Jogador> atletas = new ArrayList<Jogador> ();
Jogador j1 = new Jogador("pedro", 2.5);
atletas.add(j1);
Jogador j2 = new Jogador("antonio", 3.5);
atletas.add(j2);
Jogador j3 = new Jogador("snarf", 1.5);
atletas.add(j3);
Jogador j4 = new Jogador("vitinho", 4.5);
atletas.add(j4);
Jogador j5 = new Jogador("rodrigo", 2.5);
atletas.add(j5);
Jogador j6 = new Jogador("mattheus", 3.5);
atletas.add(j6);
Jogador j7 = new Jogador("cicero", 1.5);
atletas.add(j7);
Jogador j8 = new Jogador("fabio", 4.5);
atletas.add(j8);
Jogador j9 = new Jogador("wallyson", 2.5);
atletas.add(j9);
Jogador j10 = new Jogador("Artur", 3.5);
atletas.add(j10);
Jogador j11 = new Jogador("brincanagem", 1.5);
atletas.add(j11);
Jogador j12 = new Jogador("filipe", 4.5);
atletas.add(j12);
Jogador j13 = new Jogador("iva", 2.5);
atletas.add(j13);
Jogador j14 = new Jogador("davi", 3.5);
atletas.add(j14);
Jogador j15 = new Jogador("emanuel", 1.5);
atletas.add(j15);
Jogador j16 = new Jogador("vlauber", 4.5);
atletas.add(j16);
Jogador j17 = new Jogador("dudu", 2.5);
atletas.add(j17);
Jogador j18 = new Jogador("raniere", 3.5);
atletas.add(j18);
Jogador j19 = new Jogador("lucas", 1.5);
atletas.add(j19);
Jogador j20 = new Jogador("john", 4.5);
atletas.add(j20);
return atletas;
}
}
| UTF-8 | Java | 2,144 | java | Main.java | Java | [
{
"context": "rayList<Jogador> ();\n\n\t\tJogador j1 = new Jogador(\"pedro\", 2.5);\n\t\tatletas.add(j1);\n\t\tJogador j2 = new Jog",
"end": 888,
"score": 0.9995203018188477,
"start": 883,
"tag": "NAME",
"value": "pedro"
},
{
"context": ");\n\t\tatletas.add(j1);\n\t\tJogador j2 = new... | null | [] | import java.util.ArrayList;
public class Main {
public static void main(String[] args) {
ArrayList<Time> times = criaTimes();
ArrayList<Jogador> atletas = criaJogadores();
int tamanhoTime = 5; //receber de entrada
Sorteador s = new Sorteador(tamanhoTime,atletas, times);
//s.sorteie();
}
private static ArrayList<Time> criaTimes(){
//criando times
String[] NomeTimes = {"Azul", "Branco", "Verde", "sem camisa"};
int numDeTimes = 4; //sera variavel no futuro
ArrayList<Time> times = new ArrayList<Time>();
for(int i = 0; i < numDeTimes; i++){
Time novoTime = new Time(NomeTimes[i]);
times.add(novoTime);
}
return times;
}
private static ArrayList<Jogador> criaJogadores(){
//criando jogadores
//futuramente pegar de um arquivo as informacoes
ArrayList<Jogador> atletas = new ArrayList<Jogador> ();
Jogador j1 = new Jogador("pedro", 2.5);
atletas.add(j1);
Jogador j2 = new Jogador("antonio", 3.5);
atletas.add(j2);
Jogador j3 = new Jogador("snarf", 1.5);
atletas.add(j3);
Jogador j4 = new Jogador("vitinho", 4.5);
atletas.add(j4);
Jogador j5 = new Jogador("rodrigo", 2.5);
atletas.add(j5);
Jogador j6 = new Jogador("mattheus", 3.5);
atletas.add(j6);
Jogador j7 = new Jogador("cicero", 1.5);
atletas.add(j7);
Jogador j8 = new Jogador("fabio", 4.5);
atletas.add(j8);
Jogador j9 = new Jogador("wallyson", 2.5);
atletas.add(j9);
Jogador j10 = new Jogador("Artur", 3.5);
atletas.add(j10);
Jogador j11 = new Jogador("brincanagem", 1.5);
atletas.add(j11);
Jogador j12 = new Jogador("filipe", 4.5);
atletas.add(j12);
Jogador j13 = new Jogador("iva", 2.5);
atletas.add(j13);
Jogador j14 = new Jogador("davi", 3.5);
atletas.add(j14);
Jogador j15 = new Jogador("emanuel", 1.5);
atletas.add(j15);
Jogador j16 = new Jogador("vlauber", 4.5);
atletas.add(j16);
Jogador j17 = new Jogador("dudu", 2.5);
atletas.add(j17);
Jogador j18 = new Jogador("raniere", 3.5);
atletas.add(j18);
Jogador j19 = new Jogador("lucas", 1.5);
atletas.add(j19);
Jogador j20 = new Jogador("john", 4.5);
atletas.add(j20);
return atletas;
}
}
| 2,144 | 0.653452 | 0.604478 | 78 | 26.487179 | 17.708281 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.74359 | false | false | 10 |
5c9a66464932ea90dc6d86164d509c2ed57c624c | 35,012,573,441,655 | 8ecc5fd0e22f3f507003d93c830b3274b5562737 | /3_EJB_Glassfish/src/server/beans/ProductBean.java | 4b9394726094701c645b3e54aafb2e53c5bd22bf | [] | no_license | olisve/web_programming | https://github.com/olisve/web_programming | e48a04c9929f4ea3b0ee42ac7fa611de9832d2e6 | 09591e3846bfe5aa77af7dbecc526e3bff2d6bec | refs/heads/master | 2020-07-27T00:49:48.209000 | 2017-03-20T15:30:49 | 2017-03-20T15:30:49 | 73,708,781 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package server.beans;
import server.entities.Product;
import server.exceptions.BeanException;
import server.remotes.ProductBeanRemote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;
/**
* Bean for work with table Product
*/
@Stateless
public class ProductBean implements ProductBeanRemote {
@PersistenceContext(unitName = "testjpa")
EntityManager entityManager;
public void addProduct(String title, int price) throws BeanException {
try {
Product product = new Product();
product.setPrice(price);
product.setTitle(title);
entityManager.persist(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void removeProductById(int id) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
entityManager.remove(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void updateProductTitle(int id, String title) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
product.setTitle(title);
entityManager.merge(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void updateProductPrice(int id, int price) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
product.setPrice(price);
entityManager.merge(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public List<Product> getAllProducts() throws BeanException {
try {
Query query = entityManager.createNamedQuery("Product.findAll");
List<Product> productList = (List<Product>) query.getResultList();
return productList;
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
}
| UTF-8 | Java | 2,245 | java | ProductBean.java | Java | [] | null | [] | package server.beans;
import server.entities.Product;
import server.exceptions.BeanException;
import server.remotes.ProductBeanRemote;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import java.util.List;
/**
* Bean for work with table Product
*/
@Stateless
public class ProductBean implements ProductBeanRemote {
@PersistenceContext(unitName = "testjpa")
EntityManager entityManager;
public void addProduct(String title, int price) throws BeanException {
try {
Product product = new Product();
product.setPrice(price);
product.setTitle(title);
entityManager.persist(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void removeProductById(int id) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
entityManager.remove(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void updateProductTitle(int id, String title) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
product.setTitle(title);
entityManager.merge(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public void updateProductPrice(int id, int price) throws BeanException {
try {
Product product = entityManager.find(Product.class, id);
product.setPrice(price);
entityManager.merge(product);
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
public List<Product> getAllProducts() throws BeanException {
try {
Query query = entityManager.createNamedQuery("Product.findAll");
List<Product> productList = (List<Product>) query.getResultList();
return productList;
}
catch (Exception ex){
throw new BeanException(ex.getMessage());
}
}
}
| 2,245 | 0.627172 | 0.627172 | 76 | 28.539474 | 23.55645 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.473684 | false | false | 10 |
73271d2c793c65c511e5c0eda4ad113cde31f34b | 36,369,783,103,638 | c5826f8234d1f5a0fc7a2b54064c7e4363f58828 | /SpringCellStore/src/test/java/com/training/cellstore/service/CellPhoneServiceTest.java | f3482838da97054b0281a6a19dbbee9f6349af8d | [] | no_license | RTMyGitHub/JavaTraining | https://github.com/RTMyGitHub/JavaTraining | 91b5ff8012bcf5ab7be7617b9bfeb8a787bab0dd | 329886d50aae4e27548782f81ee431d95f86ef7c | refs/heads/master | 2021-01-10T16:08:27.933000 | 2015-06-29T22:47:46 | 2015-06-29T22:47:46 | 53,686,948 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.training.cellstore.service;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.training.cellstore.domain.Cellphone;
public class CellPhoneServiceTest {
@Test
public void testAddCellPhone() throws Exception {
/* BeanFactory factory = new ClassPathXmlApplicationContext("cellphone-config.xml");
CellPhoneService service = factory.getBean(CellPhoneService.class);
Cellphone cp = new Cellphone();
cp.setCellCompanyname("Nokia");
cp.setCellid(150);
cp.setModel("N-91");
cp.setPrice(421.23f);
service.create(cp);
Cellphone newlyCreatedCellPhone = service.getByCellPhoneId(150);
Assert.assertNotNull("Newly created cell can't be null", newlyCreatedCellPhone);
Assert.assertEquals(150, newlyCreatedCellPhone.getCellid());
Assert.assertEquals("N-91", newlyCreatedCellPhone.getModel());
Assert.assertEquals("Nokia", newlyCreatedCellPhone.getCellCompanyname());
*/ }
}
| UTF-8 | Java | 1,122 | java | CellPhoneServiceTest.java | Java | [] | null | [] | package com.training.cellstore.service;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.training.cellstore.domain.Cellphone;
public class CellPhoneServiceTest {
@Test
public void testAddCellPhone() throws Exception {
/* BeanFactory factory = new ClassPathXmlApplicationContext("cellphone-config.xml");
CellPhoneService service = factory.getBean(CellPhoneService.class);
Cellphone cp = new Cellphone();
cp.setCellCompanyname("Nokia");
cp.setCellid(150);
cp.setModel("N-91");
cp.setPrice(421.23f);
service.create(cp);
Cellphone newlyCreatedCellPhone = service.getByCellPhoneId(150);
Assert.assertNotNull("Newly created cell can't be null", newlyCreatedCellPhone);
Assert.assertEquals(150, newlyCreatedCellPhone.getCellid());
Assert.assertEquals("N-91", newlyCreatedCellPhone.getModel());
Assert.assertEquals("Nokia", newlyCreatedCellPhone.getCellCompanyname());
*/ }
}
| 1,122 | 0.750446 | 0.734403 | 37 | 28.324324 | 27.721642 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.810811 | false | false | 10 |
41204f46d9f4eec151fdbbe6fa2cf5dca279bb14 | 36,369,783,102,724 | 296f954479dacc04e208150cbcda20e0d11336e1 | /src/main/java/com/github/modules/sys/service/impl/SysUserServiceImpl.java | 33be0809ac0d44fe600def64801f79719b3a65ed | [] | no_license | Public-G/search-house | https://github.com/Public-G/search-house | 3e9a76bc1d1e7d82abd0172b9b6ef2e3f43bb8a6 | d38fa9f34e074a90b47d22532da8e0053eb1a04d | refs/heads/master | 2020-04-02T09:15:22.167000 | 2019-03-20T07:54:00 | 2019-03-20T07:54:00 | 154,284,162 | 6 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.modules.sys.service.impl;
import com.github.common.utils.PageUtils;
import com.github.modules.base.form.PageForm;
import com.github.modules.sys.dto.SysUserDTO;
import com.github.modules.sys.entity.SysUserEntity;
import com.github.modules.sys.repository.SysUserRepository;
import com.github.modules.sys.service.SysUserService;
import org.apache.commons.lang.StringUtils;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.*;
/**
* 系统用户
*
* @author ZEALER
* @date 2018-10-22
*/
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
@Autowired
private SysUserRepository sysUserRepository;
@Autowired
private ModelMapper modelMapper;
@Autowired
private PasswordEncoder passwordEncoder;
@Override
public PageUtils findPage(PageForm pageForm) {
String keyword = pageForm.getKeyword();
Integer curr = pageForm.getCurr();
Integer limit = pageForm.getLimit();
Sort.Order order = new Sort.Order(Sort.Direction.DESC, "userId");
Sort sort = new Sort(order);
PageRequest pageable = new PageRequest(curr - 1, limit, sort);
Page<SysUserEntity> sysUserEntityPage;
if (!StringUtils.isBlank(keyword)) {
Specification<SysUserEntity> specification = new Specification<SysUserEntity>() {
/**
* @param root 代表查询的实体类
* @param criteriaQuery 添加查询条件
* @param criteriaBuilder 用于创建 Criteria 相关对象的工厂,可以从中获取到 Predicate 对象(查询条件对象)
* @return
*/
@Override
public Predicate toPredicate(Root<SysUserEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Path usernamePath = root.get("username");
return criteriaBuilder.like(usernamePath, "%" + keyword + "%");
}
};
sysUserEntityPage = sysUserRepository.findAll(specification, pageable);
} else {
sysUserEntityPage = sysUserRepository.findAll(pageable);
}
List<SysUserEntity> pageContent = sysUserEntityPage.getContent();
List<SysUserDTO> pageContentDTO = new ArrayList<>();
for (SysUserEntity sysUserEntity : pageContent) {
// 设置创建者名称
Long createUserId = sysUserEntity.getCreateUserId();
if (createUserId != null && createUserId != 0) {
SysUserEntity userEntity = findById(createUserId);
sysUserEntity.setCreateUserName(userEntity.getUsername());
}
SysUserDTO sysUserDTO = modelMapper.map(sysUserEntity, SysUserDTO.class);
pageContentDTO.add(sysUserDTO);
}
return new PageUtils(sysUserEntityPage, pageContentDTO);
}
@Override
public SysUserEntity findById(Long userId) {
return sysUserRepository.findOne(userId);
}
@Override
public SysUserEntity findByName(String username) {
return sysUserRepository.findByUsername(username);
}
@Override
public List<Long> findAllMenuId(Long userId) {
return sysUserRepository.findAllMenuId(userId);
}
@Override
@Transactional
public void save(SysUserEntity sysUserEntity) {
sysUserEntity.setPassword(encodePassword());
sysUserEntity.setCreateTime(new Date());
sysUserRepository.save(sysUserEntity);
}
@Override
@Transactional
public void update(SysUserEntity sysUserEntity) {
sysUserRepository.save(sysUserEntity);
}
@Override
@Transactional
public void deleteBatch(Long[] userIds) {
sysUserRepository.deleteByUserIdIn(Arrays.asList(userIds));
}
@Override
@Transactional
public void reset(Long userId) {
String resetPassword = encodePassword();
sysUserRepository.updatePassword(userId, resetPassword);
}
private String encodePassword() {
return passwordEncoder.encode("123456");
}
}
| UTF-8 | Java | 4,657 | java | SysUserServiceImpl.java | Java | [
{
"context": ".*;\nimport java.util.*;\n\n/**\n * 系统用户\n *\n * @author ZEALER\n * @date 2018-10-22\n */\n@Service(\"sysUserService\"",
"end": 961,
"score": 0.9938844442367554,
"start": 955,
"tag": "USERNAME",
"value": "ZEALER"
},
{
"context": "ysUserEntity) {\n sysUserEntity.s... | null | [] | package com.github.modules.sys.service.impl;
import com.github.common.utils.PageUtils;
import com.github.modules.base.form.PageForm;
import com.github.modules.sys.dto.SysUserDTO;
import com.github.modules.sys.entity.SysUserEntity;
import com.github.modules.sys.repository.SysUserRepository;
import com.github.modules.sys.service.SysUserService;
import org.apache.commons.lang.StringUtils;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.persistence.criteria.*;
import java.util.*;
/**
* 系统用户
*
* @author ZEALER
* @date 2018-10-22
*/
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
@Autowired
private SysUserRepository sysUserRepository;
@Autowired
private ModelMapper modelMapper;
@Autowired
private PasswordEncoder passwordEncoder;
@Override
public PageUtils findPage(PageForm pageForm) {
String keyword = pageForm.getKeyword();
Integer curr = pageForm.getCurr();
Integer limit = pageForm.getLimit();
Sort.Order order = new Sort.Order(Sort.Direction.DESC, "userId");
Sort sort = new Sort(order);
PageRequest pageable = new PageRequest(curr - 1, limit, sort);
Page<SysUserEntity> sysUserEntityPage;
if (!StringUtils.isBlank(keyword)) {
Specification<SysUserEntity> specification = new Specification<SysUserEntity>() {
/**
* @param root 代表查询的实体类
* @param criteriaQuery 添加查询条件
* @param criteriaBuilder 用于创建 Criteria 相关对象的工厂,可以从中获取到 Predicate 对象(查询条件对象)
* @return
*/
@Override
public Predicate toPredicate(Root<SysUserEntity> root, CriteriaQuery<?> criteriaQuery, CriteriaBuilder criteriaBuilder) {
Path usernamePath = root.get("username");
return criteriaBuilder.like(usernamePath, "%" + keyword + "%");
}
};
sysUserEntityPage = sysUserRepository.findAll(specification, pageable);
} else {
sysUserEntityPage = sysUserRepository.findAll(pageable);
}
List<SysUserEntity> pageContent = sysUserEntityPage.getContent();
List<SysUserDTO> pageContentDTO = new ArrayList<>();
for (SysUserEntity sysUserEntity : pageContent) {
// 设置创建者名称
Long createUserId = sysUserEntity.getCreateUserId();
if (createUserId != null && createUserId != 0) {
SysUserEntity userEntity = findById(createUserId);
sysUserEntity.setCreateUserName(userEntity.getUsername());
}
SysUserDTO sysUserDTO = modelMapper.map(sysUserEntity, SysUserDTO.class);
pageContentDTO.add(sysUserDTO);
}
return new PageUtils(sysUserEntityPage, pageContentDTO);
}
@Override
public SysUserEntity findById(Long userId) {
return sysUserRepository.findOne(userId);
}
@Override
public SysUserEntity findByName(String username) {
return sysUserRepository.findByUsername(username);
}
@Override
public List<Long> findAllMenuId(Long userId) {
return sysUserRepository.findAllMenuId(userId);
}
@Override
@Transactional
public void save(SysUserEntity sysUserEntity) {
sysUserEntity.setPassword(<PASSWORD>());
sysUserEntity.setCreateTime(new Date());
sysUserRepository.save(sysUserEntity);
}
@Override
@Transactional
public void update(SysUserEntity sysUserEntity) {
sysUserRepository.save(sysUserEntity);
}
@Override
@Transactional
public void deleteBatch(Long[] userIds) {
sysUserRepository.deleteByUserIdIn(Arrays.asList(userIds));
}
@Override
@Transactional
public void reset(Long userId) {
String resetPassword = <PASSWORD>Password();
sysUserRepository.updatePassword(userId, resetPassword);
}
private String encodePassword() {
return passwordEncoder.encode("<PASSWORD>");
}
}
| 4,661 | 0.676619 | 0.673106 | 136 | 32.492645 | 27.270432 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false | 10 |
1cab88bb8b28aadd2ecfe593f86fb18cba376713 | 39,230,231,306,659 | 47b807b3e3ad512eda508cd5324988ac1127b956 | /src/homeword/collection/Dog.java | ae7795b1250923a4e908e5beb6390b45bb28a420 | [] | no_license | honghuabin/javase | https://github.com/honghuabin/javase | 19c773c3db1aa08e987512a8050ec274f9cd0add | 19345af1aa059ed4c41a284b6b58ee69fcd05f2c | refs/heads/main | 2023-01-28T06:26:06.090000 | 2020-12-06T14:45:49 | 2020-12-06T14:45:49 | 313,168,853 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package homeword.collection;
/**
* Dog
*/
public class Dog {
private String name; // 昵称
private int intimacy; // 亲密度
public Dog() {
}
public Dog(String name, int intimacy) {
this.name = name;
this.intimacy = intimacy;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIntimacy() {
return intimacy;
}
public void setIntimacy(int intimacy) {
this.intimacy = intimacy;
}
@Override
public String toString() {
return "Dog{" +
"name='" + name + '\'' +
", intimacy=" + intimacy +
'}';
}
}
| UTF-8 | Java | 750 | java | Dog.java | Java | [] | null | [] | package homeword.collection;
/**
* Dog
*/
public class Dog {
private String name; // 昵称
private int intimacy; // 亲密度
public Dog() {
}
public Dog(String name, int intimacy) {
this.name = name;
this.intimacy = intimacy;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIntimacy() {
return intimacy;
}
public void setIntimacy(int intimacy) {
this.intimacy = intimacy;
}
@Override
public String toString() {
return "Dog{" +
"name='" + name + '\'' +
", intimacy=" + intimacy +
'}';
}
}
| 750 | 0.497297 | 0.497297 | 42 | 16.619047 | 15.05854 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 10 |
2be84afbec494669cd1fd1cc396d35ecff066a1b | 30,090,540,907,652 | 9a164aa12713d58232b9960905336b24ab9b7af1 | /RepetitionFreeNumbers.java | f62e6df1bc34f44fafc7bf08a4e69a676c33069d | [
"MIT"
] | permissive | wasitshafi/codecheffsolutions | https://github.com/wasitshafi/codecheffsolutions | 533f181be24c0b371de7f7a3061438b995fc8a33 | 82d598e1f14ec5f12a7238dc6cdc37be559cf7e9 | refs/heads/master | 2021-07-09T09:54:22.060000 | 2021-04-17T12:32:15 | 2021-04-17T12:32:15 | 241,938,824 | 0 | 2 | MIT | false | 2020-10-02T18:46:25 | 2020-02-20T16:53:19 | 2020-10-02T18:29:09 | 2020-10-02T18:29:06 | 10 | 0 | 1 | 1 | C++ | false | false | // Q : https://www.codechef.com/IARCSJUD/problems/REPFREE
// 9 outof 11 TC passed, 2 TLE
/**
* @author wasitshafi
* @since 14-03-20
*/
import java.util.Arrays;
import java.util.Scanner;
import java.math.BigInteger;
class RepetitionFreeNumbers
{
public static Boolean isRepetitionFree(String s)
{
Boolean digits[] = new Boolean[10];
Arrays.fill(digits, false);
int len = s.length();
for(int i = 0 ; i < len ; i++)
if(s.charAt(i) == '0' || digits[s.charAt(i) - '0'] == true)
return false;
else
digits[s.charAt(i) - '0'] = true;
return true;
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String s = scan.next();
BigInteger n = new BigInteger(s);
n = n.add(BigInteger.valueOf(1));
while(isRepetitionFree(n.toString()) == false) n = n.add(BigInteger.valueOf(1));
System.out.println(n);
scan.close();
}
} | UTF-8 | Java | 1,037 | java | RepetitionFreeNumbers.java | Java | [
{
"context": "E\r\n// 9 outof 11 TC passed, 2 TLE\r\n/**\r\n * @author wasitshafi\r\n * @since 14-03-20\r\n */\r\nimport java.util.Array",
"end": 117,
"score": 0.9970641136169434,
"start": 107,
"tag": "USERNAME",
"value": "wasitshafi"
}
] | null | [] | // Q : https://www.codechef.com/IARCSJUD/problems/REPFREE
// 9 outof 11 TC passed, 2 TLE
/**
* @author wasitshafi
* @since 14-03-20
*/
import java.util.Arrays;
import java.util.Scanner;
import java.math.BigInteger;
class RepetitionFreeNumbers
{
public static Boolean isRepetitionFree(String s)
{
Boolean digits[] = new Boolean[10];
Arrays.fill(digits, false);
int len = s.length();
for(int i = 0 ; i < len ; i++)
if(s.charAt(i) == '0' || digits[s.charAt(i) - '0'] == true)
return false;
else
digits[s.charAt(i) - '0'] = true;
return true;
}
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
String s = scan.next();
BigInteger n = new BigInteger(s);
n = n.add(BigInteger.valueOf(1));
while(isRepetitionFree(n.toString()) == false) n = n.add(BigInteger.valueOf(1));
System.out.println(n);
scan.close();
}
} | 1,037 | 0.554484 | 0.537126 | 35 | 27.685715 | 20.578451 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.742857 | false | false | 10 |
1c01ab49c30f8bb18676b513094bb5e48bdd5668 | 4,973,572,164,906 | 0f35e38d626100f6dd5be69f2e20136bf5cd9d6a | /src/test/java/com/helloworld/use/di/construcor/HelloWorld3Test.java | ae60e6be30379a66889f45677fdc3bb8667a6be2 | [] | no_license | Iwrbw/SpringLearning | https://github.com/Iwrbw/SpringLearning | 7afbcaedb53964131366fc86c3181d53d32744a2 | a4bdd04a0ec431b5da8227903f0449a76b19053a | refs/heads/master | 2020-03-08T14:21:47.240000 | 2018-04-07T04:19:27 | 2018-04-07T04:19:27 | 128,183,120 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.helloworld.use.di.construcor;
import com.helloworld.use.HelloApi;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Create by yangshunfan
* 2018/4/6 14:31
*/
public class HelloWorld3Test {
@Test
public void testDiConstrucor() {
BeanFactory beanFactory = new ClassPathXmlApplicationContext("spring.xml");
HelloApi byIndex = beanFactory.getBean("byIndex",HelloWorld3.class);
byIndex.sayHello();
HelloApi byType = beanFactory.getBean("byType",HelloWorld3.class);
byType.sayHello();
HelloApi byName = beanFactory.getBean("byName",HelloWorld3.class);
byName.sayHello();
}
} | UTF-8 | Java | 765 | java | HelloWorld3Test.java | Java | [
{
"context": ".ClassPathXmlApplicationContext;\n\n/**\n * Create by yangshunfan\n * 2018/4/6 14:31\n */\npublic class HelloWorld3Tes",
"end": 260,
"score": 0.9995974898338318,
"start": 249,
"tag": "USERNAME",
"value": "yangshunfan"
}
] | null | [] | package com.helloworld.use.di.construcor;
import com.helloworld.use.HelloApi;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
* Create by yangshunfan
* 2018/4/6 14:31
*/
public class HelloWorld3Test {
@Test
public void testDiConstrucor() {
BeanFactory beanFactory = new ClassPathXmlApplicationContext("spring.xml");
HelloApi byIndex = beanFactory.getBean("byIndex",HelloWorld3.class);
byIndex.sayHello();
HelloApi byType = beanFactory.getBean("byType",HelloWorld3.class);
byType.sayHello();
HelloApi byName = beanFactory.getBean("byName",HelloWorld3.class);
byName.sayHello();
}
} | 765 | 0.724183 | 0.705882 | 27 | 27.370371 | 27.441721 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 10 |
e57a68b833950dc153864af31020880c60d8d24a | 34,557,306,874,767 | 838d5e5a4c0edbdef7a70ffdf2950afb0e0d133a | /Safe/app/src/main/java/com/gipsyz/safe/dto/SimpleBeacon.java | 7d7bff7851d9b16614e71d542eb41eb0b28e60c0 | [] | no_license | marianmoldovan/cybercamp | https://github.com/marianmoldovan/cybercamp | 791450f64a5502e4b57bf63d85b9c3daddec5320 | 016be69c39a190fb44e434630d5df84cde1c7bcf | refs/heads/master | 2020-06-07T06:47:11.675000 | 2014-12-07T07:03:24 | 2014-12-07T07:03:24 | 27,601,347 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gipsyz.safe.dto;
import uk.co.alt236.bluetoothlelib.device.IBeaconDevice;
/**
* Created by batman on 06/12/2014.
*/
public class SimpleBeacon {
private String id;
private String uuid;
private int major, minor;
public SimpleBeacon(IBeaconDevice device){
this.uuid = device.getUUID();
this.major = device.getMajor();
this.minor = device.getMinor();
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getMajor() {
return major;
}
public void setMajor(int major) {
this.major = major;
}
public int getMinor() {
return minor;
}
public void setMinor(int minor) {
this.minor = minor;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
| UTF-8 | Java | 921 | java | SimpleBeacon.java | Java | [
{
"context": "package com.gipsyz.safe.dto;\n\nimport uk.co.alt236.bluetoothlelib.device.IBeaconDevice;\n\n/**\n * Crea",
"end": 49,
"score": 0.8513107299804688,
"start": 46,
"tag": "USERNAME",
"value": "236"
},
{
"context": "oothlelib.device.IBeaconDevice;\n\n/**\n * Created by batma... | null | [] | package com.gipsyz.safe.dto;
import uk.co.alt236.bluetoothlelib.device.IBeaconDevice;
/**
* Created by batman on 06/12/2014.
*/
public class SimpleBeacon {
private String id;
private String uuid;
private int major, minor;
public SimpleBeacon(IBeaconDevice device){
this.uuid = device.getUUID();
this.major = device.getMajor();
this.minor = device.getMinor();
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
public int getMajor() {
return major;
}
public void setMajor(int major) {
this.major = major;
}
public int getMinor() {
return minor;
}
public void setMinor(int minor) {
this.minor = minor;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
}
| 921 | 0.581976 | 0.570033 | 51 | 17.058823 | 15.467121 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 10 |
268a36a82dcf5756a4c483942c06f8ab89dc9c35 | 13,108,240,253,716 | 0ace4d0442347ebc9eb0f1c728dd7ee84205a46a | /src/main/java/com/ssafy/safefood/dao/FoodDaoImpl.java | 78671e55b323323e209d4744633a22a1856e688a | [] | no_license | atlanboa/web_rest_back_end | https://github.com/atlanboa/web_rest_back_end | 8e4f69c71082343af345afef7df6084d2e819938 | 6f84acfa0441a7f99541905962a2a2bbfc742650 | refs/heads/master | 2022-11-28T06:53:08.665000 | 2019-11-27T05:51:12 | 2019-11-27T05:51:12 | 226,233,549 | 0 | 0 | null | false | 2022-11-16T09:59:49 | 2019-12-06T02:55:36 | 2020-01-18T06:19:49 | 2022-11-16T09:59:46 | 33,228 | 0 | 0 | 2 | CSS | false | false | package com.ssafy.safefood.dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ssafy.safefood.vo.FoodVO;
@Repository
public class FoodDaoImpl implements FoodDao {
private String[] allergys = { "대두", "땅콩", "우유", "게", "새우", "참치", "연어", "쑥", "소고기", "닭고기", "돼지고기", "복숭아", "민들레",
"계란흰자" };
private final String ns = "FoodMapper.";
@Autowired
private SqlSession session;
@Override
public List<FoodVO> selectByFoodName(String name) throws Exception {
return session.selectList(ns+"selectByFoodName", name);
}
@Override
public List<FoodVO> selectByFoodMaker(String maker) throws Exception {
return session.selectList(ns+"selectByFoodMaker", maker);
}
@Override
public List<FoodVO> selectByFoodMaterial(String material) throws Exception {
return session.selectList(ns+"selectByFoodMaterial", material);
}
@Override
public FoodVO selectByFoodCode(String code) throws Exception {
return session.selectOne(ns+"selectByFoodCode", code);
}
@Override
public List<FoodVO> selectAll() throws Exception {
return session.selectList(ns+"selectAll");
}
@Override
public void insertFood(FoodVO vo) throws Exception {
session.insert(ns+"insertFood", vo);
}
@Override
public void updateFood(FoodVO vo) throws Exception {
session.update(ns+"updateFood", vo);
}
@Override
public void deleteFood(int code) throws Exception {
session.delete(ns+"deleteFood", code);
}
}
| UTF-8 | Java | 1,685 | java | FoodDaoImpl.java | Java | [] | null | [] | package com.ssafy.safefood.dao;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.ssafy.safefood.vo.FoodVO;
@Repository
public class FoodDaoImpl implements FoodDao {
private String[] allergys = { "대두", "땅콩", "우유", "게", "새우", "참치", "연어", "쑥", "소고기", "닭고기", "돼지고기", "복숭아", "민들레",
"계란흰자" };
private final String ns = "FoodMapper.";
@Autowired
private SqlSession session;
@Override
public List<FoodVO> selectByFoodName(String name) throws Exception {
return session.selectList(ns+"selectByFoodName", name);
}
@Override
public List<FoodVO> selectByFoodMaker(String maker) throws Exception {
return session.selectList(ns+"selectByFoodMaker", maker);
}
@Override
public List<FoodVO> selectByFoodMaterial(String material) throws Exception {
return session.selectList(ns+"selectByFoodMaterial", material);
}
@Override
public FoodVO selectByFoodCode(String code) throws Exception {
return session.selectOne(ns+"selectByFoodCode", code);
}
@Override
public List<FoodVO> selectAll() throws Exception {
return session.selectList(ns+"selectAll");
}
@Override
public void insertFood(FoodVO vo) throws Exception {
session.insert(ns+"insertFood", vo);
}
@Override
public void updateFood(FoodVO vo) throws Exception {
session.update(ns+"updateFood", vo);
}
@Override
public void deleteFood(int code) throws Exception {
session.delete(ns+"deleteFood", code);
}
}
| 1,685 | 0.711194 | 0.711194 | 64 | 23.265625 | 26.702202 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.34375 | false | false | 10 |
6dbbc5f5f91e450a14323f38ae2c38eea9039270 | 2,233,383,024,929 | ea46ba0d4a674578cba62e7fcfdf55306687ab0c | /src/analogyFinder/src/models/Subforest.java | 60c59fc85ac5eaffd029e76b5838901e4fc0138e | [
"MIT"
] | permissive | rrinott-coursera/codewebs | https://github.com/rrinott-coursera/codewebs | ee0a9143072f27e75578a2779be53803c1d16189 | 38302bcc9af16e3e879c8ed6fbf98f3407923c18 | refs/heads/master | 2021-01-20T17:53:46.069000 | 2017-02-03T21:33:56 | 2017-02-03T21:33:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package models;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import models.ast.Forest;
import models.ast.Node;
import org.json.JSONObject;
import util.FileSystem;
/**
* Class Subforest
* A subforest represents a subtree or a forest of statement subtrees (in many
* ways, this class is a sibling class of a context). In general there is one
* subforest instance for each codeBlock from each program, but two identical
* subforests from different programs will hash to the same value (and pass
* equals).
*/
public class Subforest {
// To save memory these are pointers.
private Forest forest;
// This is a back pointer which is useful for reconstructing codeStrings
private Program program;
public Subforest(Program program, Forest forest) {
this.forest = forest;
this.program = program;
}
public int size() {
return forest.getSize();
}
public String getCodeString() {
return forest.getCodeString(program);
}
public int getLineNumber() {
return forest.getLineNumber(program);
}
public boolean isEmpty() {
return forest == Forest.NULL;
}
public void markEquivalence(Equivalence equivalence) {
for(Node root : forest.getRoots()) {
root.markEquivalence(equivalence);
}
}
@Override
public int hashCode() {
return forest.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
if (hashCode() != obj.hashCode())
return false;
Subforest other = (Subforest) obj;
return other.forest.equals(forest);
}
public List<Node> getRoots() {
return forest.getRoots();
}
public static Subforest loadFromFile(String path, Set<String> keywords) {
JSONObject json = FileSystem.loadJson(path);
Forest forest = Forest.loadFromJson(json, keywords);
return new Subforest(null, forest);
}
public boolean containsId(int id) {
return forest.containsId(id);
}
public boolean isIsomorphic(Subforest other) {
if (!this.equals(other)) return false;
Map<String, String> association = new HashMap<String, String>();
return forest.checkValidIdentifierMap(other.forest, association);
}
}
| UTF-8 | Java | 2,224 | java | Subforest.java | Java | [] | null | [] | package models;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import models.ast.Forest;
import models.ast.Node;
import org.json.JSONObject;
import util.FileSystem;
/**
* Class Subforest
* A subforest represents a subtree or a forest of statement subtrees (in many
* ways, this class is a sibling class of a context). In general there is one
* subforest instance for each codeBlock from each program, but two identical
* subforests from different programs will hash to the same value (and pass
* equals).
*/
public class Subforest {
// To save memory these are pointers.
private Forest forest;
// This is a back pointer which is useful for reconstructing codeStrings
private Program program;
public Subforest(Program program, Forest forest) {
this.forest = forest;
this.program = program;
}
public int size() {
return forest.getSize();
}
public String getCodeString() {
return forest.getCodeString(program);
}
public int getLineNumber() {
return forest.getLineNumber(program);
}
public boolean isEmpty() {
return forest == Forest.NULL;
}
public void markEquivalence(Equivalence equivalence) {
for(Node root : forest.getRoots()) {
root.markEquivalence(equivalence);
}
}
@Override
public int hashCode() {
return forest.hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null || getClass() != obj.getClass())
return false;
if (hashCode() != obj.hashCode())
return false;
Subforest other = (Subforest) obj;
return other.forest.equals(forest);
}
public List<Node> getRoots() {
return forest.getRoots();
}
public static Subforest loadFromFile(String path, Set<String> keywords) {
JSONObject json = FileSystem.loadJson(path);
Forest forest = Forest.loadFromJson(json, keywords);
return new Subforest(null, forest);
}
public boolean containsId(int id) {
return forest.containsId(id);
}
public boolean isIsomorphic(Subforest other) {
if (!this.equals(other)) return false;
Map<String, String> association = new HashMap<String, String>();
return forest.checkValidIdentifierMap(other.forest, association);
}
}
| 2,224 | 0.718525 | 0.718525 | 95 | 22.410526 | 22.095245 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.347368 | false | false | 10 |
15b94db5c176b63086faeded8b1dd6ec53ab55fc | 22,093,311,772,185 | 854ae5673a5d1acf8c2d346156e7ed89a93aa821 | /app/src/main/java/com/coldzify/finalproject/Dialog/ProgressDialog.java | 703ecdaecfe15a64f2e07a962c0a8a8ef33cc3be | [] | no_license | nakkarintho/SCI-TU-REPORT | https://github.com/nakkarintho/SCI-TU-REPORT | c40dc0c1fb418d6697ac59bee9c0b43f9f35894a | 7b710269065c2e9666d2de29e502c3995b229d07 | refs/heads/master | 2023-05-23T19:16:29.282000 | 2021-06-18T07:04:32 | 2021-06-18T07:04:32 | 378,320,801 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.coldzify.finalproject.Dialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.coldzify.finalproject.R;
public class ProgressDialog extends DialogFragment {
//private double progress = 0;
private TextView progress_textView;
private ProgressBar progressBar;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
setCancelable(false);
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.progress_dialog,null);
progress_textView = view.findViewById(R.id.progress_textView);
progressBar = view.findViewById(R.id.progress_bar);
builder.setView(view);
return builder.create();
}
@Override
public void onDestroyView() {
Dialog dialog = getDialog();
// handles https://code.google.com/p/android/issues/detail?id=17423
if (dialog != null && getRetainInstance()) {
dialog.setDismissMessage(null);
}
super.onDestroyView();
}
public void setProgressText(String text){
if(progress_textView != null){
progress_textView.setText(text);
}
}
public void show() {
}
}
| UTF-8 | Java | 1,605 | java | ProgressDialog.java | Java | [] | null | [] | package com.coldzify.finalproject.Dialog;
import android.app.Dialog;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.coldzify.finalproject.R;
public class ProgressDialog extends DialogFragment {
//private double progress = 0;
private TextView progress_textView;
private ProgressBar progressBar;
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
setCancelable(false);
// Use the Builder class for convenient dialog construction
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = requireActivity().getLayoutInflater();
View view = inflater.inflate(R.layout.progress_dialog,null);
progress_textView = view.findViewById(R.id.progress_textView);
progressBar = view.findViewById(R.id.progress_bar);
builder.setView(view);
return builder.create();
}
@Override
public void onDestroyView() {
Dialog dialog = getDialog();
// handles https://code.google.com/p/android/issues/detail?id=17423
if (dialog != null && getRetainInstance()) {
dialog.setDismissMessage(null);
}
super.onDestroyView();
}
public void setProgressText(String text){
if(progress_textView != null){
progress_textView.setText(text);
}
}
public void show() {
}
}
| 1,605 | 0.691589 | 0.686604 | 55 | 28.181818 | 23.392378 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.472727 | false | false | 10 |
117dd3aa02268ed7aab8375ce8906cb65fd46100 | 28,509,992,950,517 | 1505e2c83acccb3f765980c6e1ef635e8e6361d3 | /src/main/java/osmedile/intellij/javadochelper/IConfig.java | 8122a85877513453d67af63b83ceac7bd5c8e5e7 | [] | no_license | Longri/javadoc-helper | https://github.com/Longri/javadoc-helper | 29145d08c396d00b2a4b05f1d090865bfde2b04d | f69b82701c5c9df4f17a96e87c9c355ce4f93328 | refs/heads/master | 2021-01-10T16:58:15.518000 | 2015-10-20T12:52:34 | 2015-10-20T12:52:34 | 44,526,684 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package osmedile.intellij.javadochelper;
import java.util.List;
/**
* @author Olivier Smedile
* @version $Id: IConfig.java 52 2008-07-29 10:32:50Z osmedile $
*/
public interface IConfig {
boolean getAddIfDocDiffers();
List<ClassTag> getClassTags();
void setAddIfDocDiffers(boolean addIfNonEmpty);
void setClassTags(List<ClassTag> classTags);
void resetToDefault();
boolean getAddInheritDocIfNoDoc();
void setAddInheritDocIfNoDoc(boolean addInheritDocIfNoDoc);
boolean getRemoveIfDocMatch();
void setRemoveIfDocMatch(boolean removeIfDocMatch);
}
| UTF-8 | Java | 596 | java | IConfig.java | Java | [
{
"context": "dochelper;\n\nimport java.util.List;\n\n/**\n * @author Olivier Smedile\n * @version $Id: IConfig.java 52 2008-07-29 10:32",
"end": 96,
"score": 0.9998814463615417,
"start": 81,
"tag": "NAME",
"value": "Olivier Smedile"
}
] | null | [] | package osmedile.intellij.javadochelper;
import java.util.List;
/**
* @author <NAME>
* @version $Id: IConfig.java 52 2008-07-29 10:32:50Z osmedile $
*/
public interface IConfig {
boolean getAddIfDocDiffers();
List<ClassTag> getClassTags();
void setAddIfDocDiffers(boolean addIfNonEmpty);
void setClassTags(List<ClassTag> classTags);
void resetToDefault();
boolean getAddInheritDocIfNoDoc();
void setAddInheritDocIfNoDoc(boolean addInheritDocIfNoDoc);
boolean getRemoveIfDocMatch();
void setRemoveIfDocMatch(boolean removeIfDocMatch);
}
| 587 | 0.743289 | 0.716443 | 29 | 19.551723 | 21.881477 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.37931 | false | false | 10 |
8fd59e7770c87e7ad1da8ae5451ccc229076c724 | 4,664,334,538,601 | d7f21e533df9dbd7362fa94d422ded766039b421 | /app/src/main/java/com/mingnong/xizangphone/dao/StoreProductA.java | 128fbc9f5a8f2eb3fff020c4f5633982b3f2b47a | [] | no_license | 2017HHL/XiZangPhone | https://github.com/2017HHL/XiZangPhone | 043c5757ad0521c83704ca746e8061d5b7404dbb | afb77c7eb7a459879ebefef853073a050b2c910a | refs/heads/master | 2021-05-08T12:01:28.613000 | 2018-02-02T01:38:19 | 2018-02-02T01:38:19 | 119,916,118 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mingnong.xizangphone.dao;
import com.mingnong.xizangphone.dao.local.DaoSession;
import com.mingnong.xizangphone.dao.local.Product_ADao;
import com.mingnong.xizangphone.dao.local.StoreProductADao;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
/**
* Created by wyw on 2017/2/21.
*/
@Entity(nameInDb = "StoreProductA")
public class StoreProductA {
@Id(autoincrement = true)
private Long id;
private Long beanId;
private String userId;
private String tableName;
@ToOne(joinProperty = "beanId")
private Product_A bean;
/** Used to resolve relations */
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/** Used for active entity operations. */
@Generated(hash = 1653307514)
private transient StoreProductADao myDao;
@Generated(hash = 2095499535)
public StoreProductA(Long id, Long beanId, String userId, String tableName) {
this.id = id;
this.beanId = beanId;
this.userId = userId;
this.tableName = tableName;
}
@Generated(hash = 178002082)
public StoreProductA() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getBeanId() {
return this.beanId;
}
public void setBeanId(Long beanId) {
this.beanId = beanId;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getTableName() {
return this.tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Generated(hash = 871179490)
private transient Long bean__resolvedKey;
/** To-one relationship, resolved on first access. */
@Generated(hash = 734427849)
public Product_A getBean() {
Long __key = this.beanId;
if (bean__resolvedKey == null || !bean__resolvedKey.equals(__key)) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
Product_ADao targetDao = daoSession.getProduct_ADao();
Product_A beanNew = targetDao.load(__key);
synchronized (this) {
bean = beanNew;
bean__resolvedKey = __key;
}
}
return bean;
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 766011464)
public void setBean(Product_A bean) {
synchronized (this) {
this.bean = bean;
beanId = bean == null ? null : bean.getTId();
bean__resolvedKey = beanId;
}
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 349371482)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getStoreProductADao() : null;
}
}
| UTF-8 | Java | 4,337 | java | StoreProductA.java | Java | [
{
"context": "obot.greendao.annotation.ToOne;\n\n/**\n * Created by wyw on 2017/2/21.\n */\n\n@Entity(nameInDb = \"StoreProdu",
"end": 475,
"score": 0.9991652965545654,
"start": 472,
"tag": "USERNAME",
"value": "wyw"
}
] | null | [] | package com.mingnong.xizangphone.dao;
import com.mingnong.xizangphone.dao.local.DaoSession;
import com.mingnong.xizangphone.dao.local.Product_ADao;
import com.mingnong.xizangphone.dao.local.StoreProductADao;
import org.greenrobot.greendao.DaoException;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
import org.greenrobot.greendao.annotation.Id;
import org.greenrobot.greendao.annotation.ToOne;
/**
* Created by wyw on 2017/2/21.
*/
@Entity(nameInDb = "StoreProductA")
public class StoreProductA {
@Id(autoincrement = true)
private Long id;
private Long beanId;
private String userId;
private String tableName;
@ToOne(joinProperty = "beanId")
private Product_A bean;
/** Used to resolve relations */
@Generated(hash = 2040040024)
private transient DaoSession daoSession;
/** Used for active entity operations. */
@Generated(hash = 1653307514)
private transient StoreProductADao myDao;
@Generated(hash = 2095499535)
public StoreProductA(Long id, Long beanId, String userId, String tableName) {
this.id = id;
this.beanId = beanId;
this.userId = userId;
this.tableName = tableName;
}
@Generated(hash = 178002082)
public StoreProductA() {
}
public Long getId() {
return this.id;
}
public void setId(Long id) {
this.id = id;
}
public Long getBeanId() {
return this.beanId;
}
public void setBeanId(Long beanId) {
this.beanId = beanId;
}
public String getUserId() {
return this.userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getTableName() {
return this.tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
@Generated(hash = 871179490)
private transient Long bean__resolvedKey;
/** To-one relationship, resolved on first access. */
@Generated(hash = 734427849)
public Product_A getBean() {
Long __key = this.beanId;
if (bean__resolvedKey == null || !bean__resolvedKey.equals(__key)) {
final DaoSession daoSession = this.daoSession;
if (daoSession == null) {
throw new DaoException("Entity is detached from DAO context");
}
Product_ADao targetDao = daoSession.getProduct_ADao();
Product_A beanNew = targetDao.load(__key);
synchronized (this) {
bean = beanNew;
bean__resolvedKey = __key;
}
}
return bean;
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 766011464)
public void setBean(Product_A bean) {
synchronized (this) {
this.bean = bean;
beanId = bean == null ? null : bean.getTId();
bean__resolvedKey = beanId;
}
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#delete(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 128553479)
public void delete() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.delete(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#refresh(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 1942392019)
public void refresh() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.refresh(this);
}
/**
* Convenient call for {@link org.greenrobot.greendao.AbstractDao#update(Object)}.
* Entity must attached to an entity context.
*/
@Generated(hash = 713229351)
public void update() {
if (myDao == null) {
throw new DaoException("Entity is detached from DAO context");
}
myDao.update(this);
}
/** called by internal mechanisms, do not call yourself. */
@Generated(hash = 349371482)
public void __setDaoSession(DaoSession daoSession) {
this.daoSession = daoSession;
myDao = daoSession != null ? daoSession.getStoreProductADao() : null;
}
}
| 4,337 | 0.623934 | 0.59857 | 134 | 31.365671 | 21.263288 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.41791 | false | false | 10 |
12b97641b294c1bc239aac1ddd2c1e356d5e50a0 | 9,517,647,571,610 | 4556b65a82638df048c50edbe0d5b378e9b664f0 | /src/main/java/io/circleline/filter/auth/HmacAuth.java | ceea97f00d5ee8730b0674503a4f568dd137966b | [
"Apache-2.0"
] | permissive | circlelineio/circleline-gw | https://github.com/circlelineio/circleline-gw | 1334e25c18f627555e7a017dfaf5645c9851b270 | 77a28c0ebe1eed7492103acc52a04d15bc17406b | refs/heads/master | 2021-01-10T13:43:05.676000 | 2016-03-21T00:56:33 | 2016-03-21T00:56:33 | 50,407,218 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.circleline.filter.auth;
import io.circleline.filter.error.UnauthorizedException;
import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* Created by 1002515 on 2016. 2. 25..
*/
public class HmacAuth implements Authentication {
private static final String HEADER_NAME = "Authentication";
@Override
public void challenge(HttpServletRequest request) throws UnauthorizedException {
String credentials = request.getHeader(HEADER_NAME);
if(credentials == null)
throw new UnauthorizedException("'Authentication' header must not be null");
Signature signature = Signature.from(credentials);
if(!isValidKeyId(signature.keyId())){
throw new UnauthorizedException("invalid keyId");
}
String signatureFromDateHeader = generateSignatureBasedOnDateHeader(request);
if (!signature.signature().equals(signatureFromDateHeader)) {
throw new UnauthorizedException("invalid signature");
}
}
private boolean isValidKeyId(String keyId){
//TODO keyId가 유효한지 확인한다.
return false;
}
private String generateSignatureBasedOnDateHeader(HttpServletRequest request){
String date = request.getHeader("date");
String signedStr = HmacUtils.hmacSha1Hex("secret".getBytes(), ("date:" + date).getBytes());
return Base64.getEncoder().encodeToString(signedStr.getBytes());
}
static class Signature {
private Map<String, String> fields = new HashMap();
public String keyId(){
return get("KeyId");
}
public String algorithm(){
return get("algorithm");
}
public String signature(){
return get("signature");
}
private String get(String field){
return StringUtils.substringBetween(fields.get(field), "\"", "\"");
}
public static Signature from(final String credentials){
String params = credentials.replaceFirst("Signature","");
Signature hmac = new Signature();
for(String field: fieldsIn(params)){
hmac.addField(field);
}
return hmac;
}
public void addField(String field){
String[] pair = field.split("=",2);
fields.put(pair[0].trim(), pair[1].trim());
}
static String[] fieldsIn(String credentials){
return credentials.split(",");
}
}
}
| UTF-8 | Java | 2,661 | java | HmacAuth.java | Java | [
{
"context": "HashMap;\nimport java.util.Map;\n\n/**\n * Created by 1002515 on 2016. 2. 25..\n */\npublic class HmacAuth implem",
"end": 333,
"score": 0.9982738494873047,
"start": 326,
"tag": "USERNAME",
"value": "1002515"
}
] | null | [] | package io.circleline.filter.auth;
import io.circleline.filter.error.UnauthorizedException;
import org.apache.commons.codec.digest.HmacUtils;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
/**
* Created by 1002515 on 2016. 2. 25..
*/
public class HmacAuth implements Authentication {
private static final String HEADER_NAME = "Authentication";
@Override
public void challenge(HttpServletRequest request) throws UnauthorizedException {
String credentials = request.getHeader(HEADER_NAME);
if(credentials == null)
throw new UnauthorizedException("'Authentication' header must not be null");
Signature signature = Signature.from(credentials);
if(!isValidKeyId(signature.keyId())){
throw new UnauthorizedException("invalid keyId");
}
String signatureFromDateHeader = generateSignatureBasedOnDateHeader(request);
if (!signature.signature().equals(signatureFromDateHeader)) {
throw new UnauthorizedException("invalid signature");
}
}
private boolean isValidKeyId(String keyId){
//TODO keyId가 유효한지 확인한다.
return false;
}
private String generateSignatureBasedOnDateHeader(HttpServletRequest request){
String date = request.getHeader("date");
String signedStr = HmacUtils.hmacSha1Hex("secret".getBytes(), ("date:" + date).getBytes());
return Base64.getEncoder().encodeToString(signedStr.getBytes());
}
static class Signature {
private Map<String, String> fields = new HashMap();
public String keyId(){
return get("KeyId");
}
public String algorithm(){
return get("algorithm");
}
public String signature(){
return get("signature");
}
private String get(String field){
return StringUtils.substringBetween(fields.get(field), "\"", "\"");
}
public static Signature from(final String credentials){
String params = credentials.replaceFirst("Signature","");
Signature hmac = new Signature();
for(String field: fieldsIn(params)){
hmac.addField(field);
}
return hmac;
}
public void addField(String field){
String[] pair = field.split("=",2);
fields.put(pair[0].trim(), pair[1].trim());
}
static String[] fieldsIn(String credentials){
return credentials.split(",");
}
}
}
| 2,661 | 0.636398 | 0.628074 | 80 | 32.037498 | 26.725664 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4875 | false | false | 10 |
49263e360210e3db77d2408d217805590d41ce42 | 13,108,240,244,867 | a2b26afc801eaaf3b3f89ffeefeba07600185c07 | /app/src/main/java/com/pigdogbay/foodhygieneratings/model/Coordinate.java | a2acd6a424059adcfbc7a13f0b1f62c61f9123d8 | [
"Apache-2.0"
] | permissive | PigDogBay/FHR-Android | https://github.com/PigDogBay/FHR-Android | 2df98c21e301d2984cc0d81ba672e72b70b48ffa | 9a32fd61d0fd20afd1cbca0321f2ed4b2e277f74 | refs/heads/master | 2020-05-25T22:39:41.384000 | 2019-08-05T09:32:19 | 2019-08-05T09:32:19 | 84,975,251 | 4 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.pigdogbay.foodhygieneratings.model;
/**
* Created by Mark on 18/03/2017.
*/
public class Coordinate {
public static final double ukEast = 1.46;
public static final double ukWest = -8.638;
public static final double ukNorth = 60.51;
public static final double ukSouth = 49.53;
private final double longitude, latitude;
public double getLongitude() {
return longitude;
}
public double getLatitude() {
return latitude;
}
public Coordinate(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
private static Coordinate emptyCoordinate;
public static Coordinate getEmptyCoordinate(){
if (emptyCoordinate==null){
emptyCoordinate = new Coordinate(0,0);
}
return emptyCoordinate;
}
public boolean isWithinUk(){
return latitude>=ukSouth && latitude<=ukNorth && longitude>=ukWest && longitude<=ukEast;
}
}
| UTF-8 | Java | 1,000 | java | Coordinate.java | Java | [
{
"context": "ogbay.foodhygieneratings.model;\n\n/**\n * Created by Mark on 18/03/2017.\n */\n\npublic class Coordinate {\n\n ",
"end": 71,
"score": 0.9996540546417236,
"start": 67,
"tag": "NAME",
"value": "Mark"
}
] | null | [] | package com.pigdogbay.foodhygieneratings.model;
/**
* Created by Mark on 18/03/2017.
*/
public class Coordinate {
public static final double ukEast = 1.46;
public static final double ukWest = -8.638;
public static final double ukNorth = 60.51;
public static final double ukSouth = 49.53;
private final double longitude, latitude;
public double getLongitude() {
return longitude;
}
public double getLatitude() {
return latitude;
}
public Coordinate(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
private static Coordinate emptyCoordinate;
public static Coordinate getEmptyCoordinate(){
if (emptyCoordinate==null){
emptyCoordinate = new Coordinate(0,0);
}
return emptyCoordinate;
}
public boolean isWithinUk(){
return latitude>=ukSouth && latitude<=ukNorth && longitude>=ukWest && longitude<=ukEast;
}
}
| 1,000 | 0.656 | 0.631 | 41 | 23.390244 | 22.663904 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.414634 | false | false | 10 |
a2c794b0f6edbe4deae91eb6378b8b336e025144 | 6,897,717,495,207 | 765c2b193810e421dbbf7ec37d71cfeedcdaa4d0 | /app/src/main/java/com/example/oviepos/databases/models/responses/TransactionsAndItems.java | 25d36eca176e7d69fc3982b30ede394e11f171f8 | [] | no_license | handharbeni/OviePOS | https://github.com/handharbeni/OviePOS | 22c7b55156048da14fc3bc226856a921f9de3881 | 9b04df4ca1c3602ee7057aa0bc5a838f6e20f658 | refs/heads/master | 2022-12-04T11:49:28.522000 | 2020-08-15T20:05:16 | 2020-08-15T20:05:16 | 277,265,263 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.oviepos.databases.models.responses;
import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.Relation;
import java.util.List;
public class TransactionsAndItems {
@Embedded
public Transactions transactions;
@Relation(parentColumn = "id", entityColumn = "transactionId", entity = TransactionItems.class)
public List<TransactionItems> transactionItems;
}
| UTF-8 | Java | 415 | java | TransactionsAndItems.java | Java | [] | null | [] | package com.example.oviepos.databases.models.responses;
import androidx.room.Embedded;
import androidx.room.Entity;
import androidx.room.Relation;
import java.util.List;
public class TransactionsAndItems {
@Embedded
public Transactions transactions;
@Relation(parentColumn = "id", entityColumn = "transactionId", entity = TransactionItems.class)
public List<TransactionItems> transactionItems;
}
| 415 | 0.787952 | 0.787952 | 14 | 28.642857 | 26.421331 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.642857 | false | false | 10 |
c5b393359939a774f54f466534b197b0f27d1d63 | 6,124,623,392,456 | 343239ee3de8776c5db93c2031ab427a8ea039fc | /src/com/mh/redis/jedis/config/bean/RedisPoolBean.java | bcae7bc07acccc7e9dcf3d6b9ac4a982bd740540 | [] | no_license | jasonsuzhou/JedisSDK | https://github.com/jasonsuzhou/JedisSDK | fc5625c1411941e3f42e5b634fdaf0e09e3852a0 | 62686f0542893cf9ec738dad7f812a165f0ada2d | refs/heads/master | 2021-05-06T03:05:18.767000 | 2018-07-20T09:00:21 | 2018-07-20T09:00:21 | 114,778,836 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mh.redis.jedis.config.bean;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="pool")
public class RedisPoolBean {
private int maxIdle;
private int maxTotal;
private boolean testOnBorrow;
private boolean testOnReturn;
private int timeoutMillis;
public int getMaxIdle() {
return maxIdle;
}
@XmlAttribute
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
public int getMaxTotal() {
return maxTotal;
}
@XmlAttribute
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
@XmlAttribute
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
@XmlAttribute
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public int getTimeoutMillis() {
return timeoutMillis;
}
@XmlAttribute
public void setTimeoutMillis(int timeoutMillis) {
this.timeoutMillis = timeoutMillis;
}
}
| UTF-8 | Java | 1,176 | java | RedisPoolBean.java | Java | [] | null | [] | package com.mh.redis.jedis.config.bean;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name="pool")
public class RedisPoolBean {
private int maxIdle;
private int maxTotal;
private boolean testOnBorrow;
private boolean testOnReturn;
private int timeoutMillis;
public int getMaxIdle() {
return maxIdle;
}
@XmlAttribute
public void setMaxIdle(int maxIdle) {
this.maxIdle = maxIdle;
}
public int getMaxTotal() {
return maxTotal;
}
@XmlAttribute
public void setMaxTotal(int maxTotal) {
this.maxTotal = maxTotal;
}
public boolean isTestOnBorrow() {
return testOnBorrow;
}
@XmlAttribute
public void setTestOnBorrow(boolean testOnBorrow) {
this.testOnBorrow = testOnBorrow;
}
public boolean isTestOnReturn() {
return testOnReturn;
}
@XmlAttribute
public void setTestOnReturn(boolean testOnReturn) {
this.testOnReturn = testOnReturn;
}
public int getTimeoutMillis() {
return timeoutMillis;
}
@XmlAttribute
public void setTimeoutMillis(int timeoutMillis) {
this.timeoutMillis = timeoutMillis;
}
}
| 1,176 | 0.719388 | 0.719388 | 60 | 17.6 | 16.519888 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.133333 | false | false | 10 |
84ab718e0836e680fe4023a9a80358a134aea923 | 32,564,442,083,360 | 51a60a945d7c6f12ab438f189bb065351392f89a | /PhotoAppApiUsers/src/main/java/com/amsidh/mvc/util/UuidUtil.java | b3dd3acbd0254425cfc7a4c463898395969da069 | [] | no_license | amsidhlokhande/MyProject | https://github.com/amsidhlokhande/MyProject | 25f2a500c25f41c7a313946de6ceca099d66d13e | fd55fc4711698ff297a6cebb745e1ebf8fd58e9c | refs/heads/master | 2022-10-04T04:43:25.354000 | 2020-05-30T11:02:26 | 2020-05-30T11:02:26 | 266,879,059 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.amsidh.mvc.util;
import org.springframework.stereotype.Service;
import static java.util.UUID.randomUUID;
@Service
public class UuidUtil {
public String getNextUuid() {
return randomUUID().toString();
}
}
| UTF-8 | Java | 236 | java | UuidUtil.java | Java | [] | null | [] | package com.amsidh.mvc.util;
import org.springframework.stereotype.Service;
import static java.util.UUID.randomUUID;
@Service
public class UuidUtil {
public String getNextUuid() {
return randomUUID().toString();
}
}
| 236 | 0.724576 | 0.724576 | 13 | 17.153847 | 17.328705 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 10 |
798cea6494dfab3a2ffee4ce977087e288349cda | 10,737,418,284,699 | 08266832f10ef10975b010dd430dfa65c7de36d2 | /src/main/java/com/example/dto/CategoryDto.java | e26c9ad3547cb8c2e6e23e6782a744519227eaff | [
"Apache-2.0"
] | permissive | AlexanderByzov/ads-manager | https://github.com/AlexanderByzov/ads-manager | 54f467bd24d7e14d6ba3cd8f35ec34c11758e8c9 | 3908c16d8ef10a967a4f1e58ac7445a350329c18 | refs/heads/master | 2020-05-27T17:27:36.546000 | 2019-05-29T11:52:45 | 2019-05-29T11:52:45 | 188,721,597 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
@Getter
@AllArgsConstructor
@ToString
@Builder(toBuilder = true)
public class CategoryDto {
private final Integer id;
@NotBlank
@Size(max = 255)
private final String name;
@NotBlank
@Size(max = 255)
private final String requestName;
}
| UTF-8 | Java | 485 | java | CategoryDto.java | Java | [] | null | [] | package com.example.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
@Getter
@AllArgsConstructor
@ToString
@Builder(toBuilder = true)
public class CategoryDto {
private final Integer id;
@NotBlank
@Size(max = 255)
private final String name;
@NotBlank
@Size(max = 255)
private final String requestName;
}
| 485 | 0.752577 | 0.740206 | 26 | 17.653847 | 13.606962 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 10 |
75576c6f494dc04218360cef2ca141cbd9f307c5 | 7,962,869,431,970 | 3986a6e2b96613dcc3438be838a97af349cb603e | /src/main/java/heritage/mergen/core/model/Media.java | 6eb122e8a753f10457da9e054596b8419b188780 | [] | no_license | MergenGroup/ProjectMergen | https://github.com/MergenGroup/ProjectMergen | 6375169aaaabe4828ad9076b3664769cca6eab0d | c9ddd4e87242116224c73bb1208d21c9c1555488 | refs/heads/master | 2016-08-30T19:05:43.616000 | 2016-06-01T16:31:15 | 2016-06-01T16:31:15 | 51,354,846 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package heritage.mergen.core.model;
/* User: baris Date: 27/03/16 Time: 22:00 */
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
@Entity
@Table(name = "media")
public class Media {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@Getter @Setter private long id;
@Basic @Column(name = "html")
@Getter @Setter private String html;
@Basic @Column(name = "title")
@Getter @Setter private String title;
@Basic @Column(name = "source")
@Getter @Setter private String source;
}
| UTF-8 | Java | 566 | java | Media.java | Java | [
{
"context": "package heritage.mergen.core.model;\n/* User: baris Date: 27/03/16 Time: 22:00 */\n\nimport lombok.Gett",
"end": 50,
"score": 0.9993999004364014,
"start": 45,
"tag": "USERNAME",
"value": "baris"
}
] | null | [] | package heritage.mergen.core.model;
/* User: baris Date: 27/03/16 Time: 22:00 */
import lombok.Getter;
import lombok.Setter;
import javax.persistence.*;
@Entity
@Table(name = "media")
public class Media {
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
@Getter @Setter private long id;
@Basic @Column(name = "html")
@Getter @Setter private String html;
@Basic @Column(name = "title")
@Getter @Setter private String title;
@Basic @Column(name = "source")
@Getter @Setter private String source;
}
| 566 | 0.678445 | 0.660777 | 24 | 22.583334 | 17.480743 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 10 |
1d31fac5cbbfaad62cbde424ec7cf5dd520cfe79 | 9,620,726,806,574 | ca03133e02ecdccada8734eafe5c49ed335ed20b | /MailServer/src/java/DAO/FeedbackDAO.java | 217c44bed9a54b1c086208870c37420689633f90 | [] | no_license | anhdv282/MailServer | https://github.com/anhdv282/MailServer | dd0bd3779fcd231256f9235d5856f2e5c09cd12b | 1a0ed03fa424cd26ad76f8516e6831b356dc7235 | refs/heads/master | 2021-04-09T17:00:46.176000 | 2014-08-08T01:06:22 | 2014-08-08T01:06:22 | 21,929,310 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* 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 DAO;
import entities.Feedback;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import util.DbUtil;
/**
*
* @author DANG
*/
public class FeedbackDAO {
DbUtil util = new DbUtil();
public boolean sentFeedBack(Feedback feedback){
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call SentFeedBack(?,?,?)}");
stm.setString(1, feedback.getEmail());
stm.setString(2, feedback.getTitle());
stm.setString(3, feedback.getContent());
stm.executeUpdate();
conn.close();
return true;
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
public List<Feedback> loadFeedback(){
List<Feedback> lst = new ArrayList<Feedback>();
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call GetAllFeedback}");
ResultSet rs = stm.executeQuery();
while (rs.next()) {
Feedback feedback = new Feedback();
feedback.setFeedId(rs.getInt(1));
feedback.setEmail(rs.getString(2));
feedback.setTitle(rs.getString(3));
feedback.setDate(rs.getString(4));
lst.add(feedback);
}
conn.close();
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return lst;
}
public Feedback getFeedbackById(int id){
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call GetFeedbackById(?)}");
stm.setInt(1, id);
ResultSet rs = stm.executeQuery();
if(rs.next()){
Feedback feedback = new Feedback();
feedback.setEmail(rs.getString(1));
feedback.setTitle(rs.getString(2));
feedback.setContent(rs.getString(3));
feedback.setDate(rs.getString(4));
conn.close();
return feedback;
}
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
| UTF-8 | Java | 2,793 | java | FeedbackDAO.java | Java | [
{
"context": "ing.Logger;\nimport util.DbUtil;\n\n/**\n *\n * @author DANG\n */\npublic class FeedbackDAO {\n DbUtil util",
"end": 502,
"score": 0.6064105033874512,
"start": 501,
"tag": "NAME",
"value": "D"
},
{
"context": "g.Logger;\nimport util.DbUtil;\n\n/**\n *\n * @author DAN... | null | [] | /*
* 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 DAO;
import entities.Feedback;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import util.DbUtil;
/**
*
* @author DANG
*/
public class FeedbackDAO {
DbUtil util = new DbUtil();
public boolean sentFeedBack(Feedback feedback){
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call SentFeedBack(?,?,?)}");
stm.setString(1, feedback.getEmail());
stm.setString(2, feedback.getTitle());
stm.setString(3, feedback.getContent());
stm.executeUpdate();
conn.close();
return true;
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
public List<Feedback> loadFeedback(){
List<Feedback> lst = new ArrayList<Feedback>();
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call GetAllFeedback}");
ResultSet rs = stm.executeQuery();
while (rs.next()) {
Feedback feedback = new Feedback();
feedback.setFeedId(rs.getInt(1));
feedback.setEmail(rs.getString(2));
feedback.setTitle(rs.getString(3));
feedback.setDate(rs.getString(4));
lst.add(feedback);
}
conn.close();
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return lst;
}
public Feedback getFeedbackById(int id){
try {
Connection conn = util.getConnection();
CallableStatement stm = conn.prepareCall("{call GetFeedbackById(?)}");
stm.setInt(1, id);
ResultSet rs = stm.executeQuery();
if(rs.next()){
Feedback feedback = new Feedback();
feedback.setEmail(rs.getString(1));
feedback.setTitle(rs.getString(2));
feedback.setContent(rs.getString(3));
feedback.setDate(rs.getString(4));
conn.close();
return feedback;
}
} catch (SQLException ex) {
Logger.getLogger(FeedbackDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return null;
}
}
| 2,793 | 0.580022 | 0.575725 | 83 | 32.650604 | 22.845438 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.759036 | false | false | 10 |
b3e4a5f90dc5ab5f7fd0c8d02610ab2e86567165 | 21,122,649,189,477 | 8a233e93584930a536fd4a5b51ed4d0d3398d8d3 | /src/main/java/com/einevault/users/model/UserPWD.java | afd62b316961132bfa99f12e56f5ac95cd8bdffd | [
"MIT"
] | permissive | einevea/users | https://github.com/einevea/users | c452304e15ee5834b2bf3a1eaeabb8cda6954b84 | 0be565e508cb1163bc8c9161d4013b8bfd525ea2 | refs/heads/master | 2020-04-09T08:07:56.736000 | 2015-08-16T22:26:09 | 2015-08-16T22:26:09 | 40,806,046 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.einevault.users.model;
/**
* Created by einevea on 16/08/15.
*/
public class UserPWD {
public transient final static UserPWD ANONYMOUS = new UserPWD("","");
private final String username;
private final String pwd;
public UserPWD(String username, String pwd) {
this.username = username;
this.pwd = pwd;
}
public String getUsername() {
return username;
}
public String getPwd() {
return pwd;
}
}
| UTF-8 | Java | 480 | java | UserPWD.java | Java | [
{
"context": "kage com.einevault.users.model;\n\n/**\n * Created by einevea on 16/08/15.\n */\npublic class UserPWD {\n publi",
"end": 61,
"score": 0.9995937943458557,
"start": 54,
"tag": "USERNAME",
"value": "einevea"
},
{
"context": "ng username, String pwd) {\n this.user... | null | [] | package com.einevault.users.model;
/**
* Created by einevea on 16/08/15.
*/
public class UserPWD {
public transient final static UserPWD ANONYMOUS = new UserPWD("","");
private final String username;
private final String pwd;
public UserPWD(String username, String pwd) {
this.username = username;
this.pwd = pwd;
}
public String getUsername() {
return username;
}
public String getPwd() {
return pwd;
}
}
| 480 | 0.625 | 0.6125 | 23 | 19.869566 | 18.608797 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.434783 | false | false | 10 |
b8a2323856b22b36cb3956f0e0850079a9c61320 | 7,773,890,839,959 | 19971beaf3f93a10c5029e4c3083151980022868 | /PatronesDsgApp/src/com/kaboom/strategy/Duck.java | f1e99eded6793c9a8be98e3b8f0e90a420c2ecc3 | [] | no_license | pabloantonio/glm_sw | https://github.com/pabloantonio/glm_sw | ee7253209539bc4560c39d48c2cbe06f14802e14 | 602ba0c5550e03f8632dfef176c692e8dfea4824 | refs/heads/master | 2021-01-17T17:07:12.770000 | 2013-09-18T21:47:42 | 2013-09-18T21:47:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package com.kaboom.strategy;
import com.kabom.interfaces.FlyBehavior;
import com.kabom.interfaces.QuakBehavior;
/**
* @author pablo
*
*/
public abstract class Duck {
FlyBehavior flyBehavior;
QuakBehavior quakBehavior;
public abstract void swim();
public abstract void display();
public abstract void performQuak();
public abstract void performFly();
public FlyBehavior getFlyBehavior() {
return flyBehavior;
}
public void setFlyBehavior(FlyBehavior flyBehavior) {
this.flyBehavior = flyBehavior;
}
public QuakBehavior getQuakBehavior() {
return quakBehavior;
}
public void setQuakBehavior(QuakBehavior quakBehavior) {
this.quakBehavior = quakBehavior;
}
}
| UTF-8 | Java | 724 | java | Duck.java | Java | [
{
"context": "com.kabom.interfaces.QuakBehavior;\n\n/**\n * @author pablo\n *\n */\npublic abstract class Duck {\n\t\n\t\n\t FlyBeha",
"end": 146,
"score": 0.7566400170326233,
"start": 141,
"tag": "USERNAME",
"value": "pablo"
}
] | null | [] | /**
*
*/
package com.kaboom.strategy;
import com.kabom.interfaces.FlyBehavior;
import com.kabom.interfaces.QuakBehavior;
/**
* @author pablo
*
*/
public abstract class Duck {
FlyBehavior flyBehavior;
QuakBehavior quakBehavior;
public abstract void swim();
public abstract void display();
public abstract void performQuak();
public abstract void performFly();
public FlyBehavior getFlyBehavior() {
return flyBehavior;
}
public void setFlyBehavior(FlyBehavior flyBehavior) {
this.flyBehavior = flyBehavior;
}
public QuakBehavior getQuakBehavior() {
return quakBehavior;
}
public void setQuakBehavior(QuakBehavior quakBehavior) {
this.quakBehavior = quakBehavior;
}
}
| 724 | 0.727901 | 0.727901 | 46 | 14.73913 | 17.121605 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.043478 | false | false | 10 |
b2bfb0f4bb403497af284f48b96419ec0fa4b5d5 | 31,791,347,977,149 | 3b6cd6723c32138850993310a232682969ce57b5 | /app/src/main/java/com/example/carritocomprasfranz/PaginaPrincipal.java | 11e0d3ad184a41c6b330b912d870e9ae40cb9a70 | [] | no_license | fmamanim/inefmamanim | https://github.com/fmamanim/inefmamanim | dbaa1bdd03b2ab5db13f5e41731d322a86817318 | bf38481756dd31d4a343692aea33eff7539eba60 | refs/heads/master | 2021-01-01T04:00:22.452000 | 2016-04-19T20:48:11 | 2016-04-19T20:48:11 | 56,090,614 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.carritocomprasfranz;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.Button;
import android.widget.Toast;
public class PaginaPrincipal extends AppCompatActivity {
//private
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_menu_principal);
setContentView(R.layout.activity_menu_principal);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Recibimos los datos
Intent b=getIntent();
String[] datos_recibidos=new String[2];
datos_recibidos=b.getStringArrayExtra("datos_usuario");
Toast.makeText(this,"Bienvenido "+datos_recibidos[0],Toast.LENGTH_SHORT).show();
}
}
| UTF-8 | Java | 925 | java | PaginaPrincipal.java | Java | [] | null | [] | package com.example.carritocomprasfranz;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.widget.Button;
import android.widget.Toast;
public class PaginaPrincipal extends AppCompatActivity {
//private
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.activity_menu_principal);
setContentView(R.layout.activity_menu_principal);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
//Recibimos los datos
Intent b=getIntent();
String[] datos_recibidos=new String[2];
datos_recibidos=b.getStringArrayExtra("datos_usuario");
Toast.makeText(this,"Bienvenido "+datos_recibidos[0],Toast.LENGTH_SHORT).show();
}
}
| 925 | 0.728649 | 0.724324 | 29 | 30.896551 | 24.297503 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62069 | false | false | 10 |
bc7ff1938e6e9317800d6342fecec16b5fa8c5e0 | 360,777,314,226 | 0a455525ba5d492d5c04c9e171829a10976117f0 | /src/com/mybatis/entity/Answer.java | eae4dee5ef386bada9a601c8caf0d81ace42fce6 | [] | no_license | xu984386604/hiyouther | https://github.com/xu984386604/hiyouther | bc94a968743ef8c570c59e5dd08d7c03c210bb66 | a6241e2f950046a56726b4e3c1097d2c8785898b | refs/heads/master | 2020-12-25T08:58:50.799000 | 2016-06-14T11:34:28 | 2016-06-14T11:34:28 | 61,117,711 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mybatis.entity;
import java.util.Date;
public class Answer {
private Integer anid;
private Integer cid;
private Date antime;
private Integer listenerid;
private Integer speakerid;
private String type;
private String listener;
private String speaker;
private String ccontent;
public Integer getAnid() {
return anid;
}
public void setAnid(Integer anid) {
this.anid = anid;
}
public Integer getCid() {
return cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public Date getAntime() {
return antime;
}
public void setAntime(Date antime) {
this.antime = antime;
}
public Integer getListenerid() {
return listenerid;
}
public void setListenerid(Integer listenerid) {
this.listenerid = listenerid;
}
public Integer getSpeakerid() {
return speakerid;
}
public void setSpeakerid(Integer speakerid) {
this.speakerid = speakerid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getListener() {
return listener;
}
public void setListener(String listener) {
this.listener = listener == null ? null : listener.trim();
}
public String getSpeaker() {
return speaker;
}
public void setSpeaker(String speaker) {
this.speaker = speaker == null ? null : speaker.trim();
}
public String getCcontent() {
return ccontent;
}
public void setCcontent(String ccontent) {
this.ccontent = ccontent == null ? null : ccontent.trim();
}
} | UTF-8 | Java | 1,867 | java | Answer.java | Java | [] | null | [] | package com.mybatis.entity;
import java.util.Date;
public class Answer {
private Integer anid;
private Integer cid;
private Date antime;
private Integer listenerid;
private Integer speakerid;
private String type;
private String listener;
private String speaker;
private String ccontent;
public Integer getAnid() {
return anid;
}
public void setAnid(Integer anid) {
this.anid = anid;
}
public Integer getCid() {
return cid;
}
public void setCid(Integer cid) {
this.cid = cid;
}
public Date getAntime() {
return antime;
}
public void setAntime(Date antime) {
this.antime = antime;
}
public Integer getListenerid() {
return listenerid;
}
public void setListenerid(Integer listenerid) {
this.listenerid = listenerid;
}
public Integer getSpeakerid() {
return speakerid;
}
public void setSpeakerid(Integer speakerid) {
this.speakerid = speakerid;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getListener() {
return listener;
}
public void setListener(String listener) {
this.listener = listener == null ? null : listener.trim();
}
public String getSpeaker() {
return speaker;
}
public void setSpeaker(String speaker) {
this.speaker = speaker == null ? null : speaker.trim();
}
public String getCcontent() {
return ccontent;
}
public void setCcontent(String ccontent) {
this.ccontent = ccontent == null ? null : ccontent.trim();
}
} | 1,867 | 0.570434 | 0.570434 | 95 | 17.673685 | 17.771914 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.305263 | false | false | 10 |
bd7fe0de3e227e57d2172167279fa607039661e1 | 10,874,857,207,357 | d5739694a5030d61f515c1d1860be68670038c49 | /spring-hqsm-smt/src/main/java/com/itdy/hqsm/zookeeper/OrderCodeGenerator.java | 97b14ec84d8d505a9b1c69e8af884ddcc78a1564 | [] | no_license | 17347116383/hzh | https://github.com/17347116383/hzh | 76b35bafb3d8dba5b6665b9a0c76453baeef61f5 | f34d4807e131a24594eaf95fe2547b7d41d1bbda | refs/heads/master | 2023-03-26T14:22:17.686000 | 2021-03-28T07:08:27 | 2021-03-28T07:08:27 | 352,245,423 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.itdy.hqsm.zookeeper;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 第一种测试
* @author Administrator
*
*/
public class OrderCodeGenerator {
// 自增长序列
private static int i = 0;
// 按照“年-月-日-小时-分钟-秒-自增长序列”的规则生成订单编号
public String getOrderCode() {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(now) + ++i;
}
}
| UTF-8 | Java | 479 | java | OrderCodeGenerator.java | Java | [
{
"context": "t;\nimport java.util.Date;\n\n/**\n * 第一种测试\n * @author Administrator\n *\n */\npublic class OrderCodeGenerator {\n\n\t// 自增长",
"end": 130,
"score": 0.9443100094795227,
"start": 117,
"tag": "NAME",
"value": "Administrator"
}
] | null | [] | package com.itdy.hqsm.zookeeper;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 第一种测试
* @author Administrator
*
*/
public class OrderCodeGenerator {
// 自增长序列
private static int i = 0;
// 按照“年-月-日-小时-分钟-秒-自增长序列”的规则生成订单编号
public String getOrderCode() {
Date now = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
return sdf.format(now) + ++i;
}
}
| 479 | 0.697789 | 0.695332 | 22 | 17.5 | 16.961855 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 10 |
97586144f5f4dce8b96c4799d8a5ad8db6f12d08 | 4,973,572,133,960 | fa2581b4ff5887271358463207a9df5b2eafbcb0 | /src/JUnit/TestSendChatting.java | d9400419d606245d7f573c8e9af37f6a0b96276c | [
"MIT"
] | permissive | sengeiou/MiniWechat | https://github.com/sengeiou/MiniWechat | 90afb38c964a5f1327279645e6ab482fade47ed1 | 99366d9987b9d462dd6eaf869e5aabb1d85bc861 | refs/heads/master | 2020-07-01T02:07:05.902000 | 2017-12-02T08:47:19 | 2017-12-02T09:35:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package JUnit;
import static org.junit.Assert.*;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import protocol.ProtoHead;
import protocol.Data.ChatData.ChatItem;
import protocol.Data.ChatData.ChatItem.ChatType;
import protocol.Msg.LoginMsg.LoginRsp;
import protocol.Msg.LogoutMsg.LogoutRsp;
import protocol.Msg.ReceiveChatMsg.ReceiveChatSync;
import protocol.Msg.SendChatMsg.SendChatReq;
import protocol.Msg.SendChatMsg.SendChatRsp;
import server.NetworkPacket;
import server.ServerModel;
import tools.Debug;
/**
* 测试发消息功能
*
* @author Feng
*/
public class TestSendChatting {
/**
* 接收一条微信消息
*
* @param clientSocket
* @return
* @throws IOException
* @author Feng
*/
public static List<ChatItem> receiveChatting(ClientSocket clientSocket) throws IOException {
byte[] response = clientSocket.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC);
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
return receiveChatting.getChatDataList();
}
private void showChatItems(List<ChatItem> chatItems) {
for (ChatItem c : chatItems) {
Date date = new Date(c.getDate());
System.out.println("Sender : " + c.getSendUserId()
+ "; receiver : " + c.getReceiveUserId()
+ "; TargetType : " + c.getTargetType()
+ "; ChatType : " + c.getChatType()
+ "; ChatBody : " + c.getChatBody()
+ "; Date : " + (1970 + date.getYear()) + "-"
+ date.getMonth() + "-" + date.getDay() + " " + date.getHours() + ":"
+ date.getMinutes() + ":" + date.getSeconds());
}
}
/**
* 测试双方均在线的场景
*
* @author Feng
* @throws IOException
* @throws UnknownHostException
*/
// @Test
public void test1() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
ClientSocket clientSocket2 = new ClientSocket();
byte[] response;
String userId1 = "c", userId2 = "d", message = "c fuck d";
// String userId1 = "123", userId2 = "1234", message = "c fuck d";
// 登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
System.out.println("test1 登陆成功");
// 发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message);
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
clientSocket1.close();
// 用户2接收消息
List<ChatItem> chatItems = receiveChatting(clientSocket2);
// Debug.log(chatItem.getReceiveUserId() + " 收到 " +
// chatItem.getSendUserId() + " 发来的消息:");
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message);
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景(不同连接)
*
* @throws UnknownHostException
* @throws IOException
*/
// @Test
public void test2() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "a", userId2 = "b", message = "a fuck b";
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message);
// 接收发送结果
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
List<ChatItem> chatItems = receiveChatting(clientSocket2);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message);
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景,消息对发(相同连接)
*
* @throws UnknownHostException
* @throws IOException
*/
@Test
public void test2_2() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "a", userId2 = "b", message1 = "a fuck b", message2 = "b fuck a";
// user1发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user1发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message1);
// user1接收发送回复
response = clientSocket1.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.SEND_CHAT_RSP);
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
assertEquals(LogoutRsp.ResultCode.SUCCESS, clientSocket1.logout());
// user2接收者登陆
clientSocket1 = new ClientSocket();
if (clientSocket1.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user2接收user1发的消息
List<ChatItem> chatItems = receiveChatting(clientSocket1);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message1);
// user2回发
sendChatting(clientSocket1, userId2, userId1, ChatType.TEXT, message2);
response = clientSocket1.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.SEND_CHAT_RSP);
sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println(userId2 + " 向 " + userId1 + " 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
assertEquals(LogoutRsp.ResultCode.SUCCESS, clientSocket1.logout());
// user1发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user2接收user1发的消息
chatItems = receiveChatting(clientSocket1);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message2);
clientSocket1.close();
}
/**
* 测试只有发送者在线的场景(发多条消息)
*
* @throws IOException
* @throws UnknownHostException
*/
// @Test
public void test3() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "e", userId2 = "f", message = "e fuck f ";
int times = 5;
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
for (int i = 0; i < times; i++) {
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message + (i + ""));
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("e 向 f 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
while (true) {
response = clientSocket2.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
continue;
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
List<ChatItem> chatItems = receiveChatting.getChatDataList();
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message + (0 + ""));
// 回复
clientSocket2.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC_VALUE,
NetworkPacket.getMessageID(response), new byte[0]));
break;
}
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景(发多条消息),接受者上线后接收后不返回(装断线),然后再上线,测试服务器是否保存
*
* @throws UnknownHostException
* @throws IOException
* @throws InterruptedException
*/
// @Test
public void test4() throws UnknownHostException, IOException, InterruptedException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "g", userId2 = "h", message = "e fuck f ";
int times = 5;
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
for (int i = 0; i < times; i++) {
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message + (i + ""));
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println("g 向 h 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// while (true) {
// response = clientSocket2.readFromServerWithoutKeepAlive();
// if (NetworkPacket.getMessageType(response) !=
// ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
// continue;
//
// ReceiveChatSync receiveChatting =
// ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
// ChatItem chatItem;
//
// for (int i = 0; i < times; i++) {
// chatItem = receiveChatting.getChatData(i);
// Debug.log(chatItem.getReceiveUserId() + " 收到 " +
// chatItem.getSendUserId() + " 发来的消息:" + chatItem.getChatType() + " "
// + chatItem.getChatBody());
// assertEquals(chatItem.getChatBody(), message + (i + ""));
// }
//
// Debug.log("接受者不回复!下线");
// break;
// }
// // 等待服务器把自己踢下线
// Thread.sleep(ServerModel.KEEP_ALIVE_PACKET_TIME +
// ServerModel.CHECK_WAIT_CLIENT_RESPONSE_DELTA_TIME);
// Thread.sleep(9*1000);
// 重新连接,登录,接收消息
clientSocket2.close();
clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
while (true) {
response = clientSocket2.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
continue;
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
List<ChatItem> chatItems = receiveChatting.getChatDataList();
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message + (0 + ""));
// 回复
clientSocket2.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC_VALUE,
NetworkPacket.getMessageID(response), new byte[0]));
break;
}
clientSocket2.close();
}
/**
* 发送一条聊天
*
* @param clientSocket
* @param senderUserId
* @param receiveUserId
* @param type
* @param messageBody
* @author Feng
* @throws IOException
*/
private void sendChatting(ClientSocket clientSocket, String senderUserId, String receiveUserId, ChatItem.ChatType type,
String messageBody) throws IOException {
ChatItem.Builder chatItem = ChatItem.newBuilder();
chatItem.setTargetType(ChatItem.TargetType.INDIVIDUAL);
chatItem.setSendUserId(senderUserId);
chatItem.setReceiveUserId(receiveUserId);
chatItem.setChatType(type);
chatItem.setChatBody(messageBody);
SendChatReq.Builder sendChatBuilder = SendChatReq.newBuilder();
sendChatBuilder.setChatData(chatItem);
clientSocket.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.SEND_CHAT_REQ_VALUE, sendChatBuilder
.build().toByteArray()));
}
}
| UTF-8 | Java | 13,677 | java | TestSendChatting.java | Java | [
{
"context": "import tools.Debug;\n\n/**\n * 测试发消息功能\n * \n * @author Feng\n */\npublic class TestSendChatting {\n\n\t/**\n\t * 接收一",
"end": 662,
"score": 0.9996035099029541,
"start": 658,
"tag": "NAME",
"value": "Feng"
},
{
"context": "et\n\t * @return\n\t * @throws IOException\n\t ... | null | [] | package JUnit;
import static org.junit.Assert.*;
import java.io.IOException;
import java.net.UnknownHostException;
import java.util.Date;
import java.util.List;
import org.junit.Ignore;
import org.junit.Test;
import protocol.ProtoHead;
import protocol.Data.ChatData.ChatItem;
import protocol.Data.ChatData.ChatItem.ChatType;
import protocol.Msg.LoginMsg.LoginRsp;
import protocol.Msg.LogoutMsg.LogoutRsp;
import protocol.Msg.ReceiveChatMsg.ReceiveChatSync;
import protocol.Msg.SendChatMsg.SendChatReq;
import protocol.Msg.SendChatMsg.SendChatRsp;
import server.NetworkPacket;
import server.ServerModel;
import tools.Debug;
/**
* 测试发消息功能
*
* @author Feng
*/
public class TestSendChatting {
/**
* 接收一条微信消息
*
* @param clientSocket
* @return
* @throws IOException
* @author Feng
*/
public static List<ChatItem> receiveChatting(ClientSocket clientSocket) throws IOException {
byte[] response = clientSocket.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC);
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
return receiveChatting.getChatDataList();
}
private void showChatItems(List<ChatItem> chatItems) {
for (ChatItem c : chatItems) {
Date date = new Date(c.getDate());
System.out.println("Sender : " + c.getSendUserId()
+ "; receiver : " + c.getReceiveUserId()
+ "; TargetType : " + c.getTargetType()
+ "; ChatType : " + c.getChatType()
+ "; ChatBody : " + c.getChatBody()
+ "; Date : " + (1970 + date.getYear()) + "-"
+ date.getMonth() + "-" + date.getDay() + " " + date.getHours() + ":"
+ date.getMinutes() + ":" + date.getSeconds());
}
}
/**
* 测试双方均在线的场景
*
* @author Feng
* @throws IOException
* @throws UnknownHostException
*/
// @Test
public void test1() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
ClientSocket clientSocket2 = new ClientSocket();
byte[] response;
String userId1 = "c", userId2 = "d", message = "c fuck d";
// String userId1 = "123", userId2 = "1234", message = "c fuck d";
// 登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
System.out.println("test1 登陆成功");
// 发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message);
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
clientSocket1.close();
// 用户2接收消息
List<ChatItem> chatItems = receiveChatting(clientSocket2);
// Debug.log(chatItem.getReceiveUserId() + " 收到 " +
// chatItem.getSendUserId() + " 发来的消息:");
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message);
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景(不同连接)
*
* @throws UnknownHostException
* @throws IOException
*/
// @Test
public void test2() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "a", userId2 = "b", message = "a fuck b";
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message);
// 接收发送结果
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
List<ChatItem> chatItems = receiveChatting(clientSocket2);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message);
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景,消息对发(相同连接)
*
* @throws UnknownHostException
* @throws IOException
*/
@Test
public void test2_2() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "a", userId2 = "b", message1 = "a fuck b", message2 = "b fuck a";
// user1发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user1发消息
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message1);
// user1接收发送回复
response = clientSocket1.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.SEND_CHAT_RSP);
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println("a 向 b 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
assertEquals(LogoutRsp.ResultCode.SUCCESS, clientSocket1.logout());
// user2接收者登陆
clientSocket1 = new ClientSocket();
if (clientSocket1.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user2接收user1发的消息
List<ChatItem> chatItems = receiveChatting(clientSocket1);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message1);
// user2回发
sendChatting(clientSocket1, userId2, userId1, ChatType.TEXT, message2);
response = clientSocket1.readFromServerWithoutKeepAlive(ProtoHead.ENetworkMessage.SEND_CHAT_RSP);
sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println(userId2 + " 向 " + userId1 + " 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
assertEquals(LogoutRsp.ResultCode.SUCCESS, clientSocket1.logout());
// user1发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// user2接收user1发的消息
chatItems = receiveChatting(clientSocket1);
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message2);
clientSocket1.close();
}
/**
* 测试只有发送者在线的场景(发多条消息)
*
* @throws IOException
* @throws UnknownHostException
*/
// @Test
public void test3() throws UnknownHostException, IOException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "e", userId2 = "f", message = "e fuck f ";
int times = 5;
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
for (int i = 0; i < times; i++) {
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message + (i + ""));
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
Debug.log("e 向 f 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
while (true) {
response = clientSocket2.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
continue;
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
List<ChatItem> chatItems = receiveChatting.getChatDataList();
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message + (0 + ""));
// 回复
clientSocket2.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC_VALUE,
NetworkPacket.getMessageID(response), new byte[0]));
break;
}
clientSocket2.close();
}
/**
* 测试只有发送者在线的场景(发多条消息),接受者上线后接收后不返回(装断线),然后再上线,测试服务器是否保存
*
* @throws UnknownHostException
* @throws IOException
* @throws InterruptedException
*/
// @Test
public void test4() throws UnknownHostException, IOException, InterruptedException {
ClientSocket clientSocket1 = new ClientSocket();
byte[] response;
String userId1 = "g", userId2 = "h", message = "e fuck f ";
int times = 5;
// 发送者登陆
if (clientSocket1.login(userId1, userId1) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// 发消息
for (int i = 0; i < times; i++) {
sendChatting(clientSocket1, userId1, userId2, ChatType.TEXT, message + (i + ""));
// 接收回复
while (true) {
response = clientSocket1.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.SEND_CHAT_RSP)
continue;
SendChatRsp sendChattingResponse = SendChatRsp.parseFrom(NetworkPacket.getMessageObjectBytes(response));
System.out.println("g 向 h 发送消息的服务器回复:" + sendChattingResponse.getResultCode().toString());
assertEquals(sendChattingResponse.getResultCode().getNumber(), SendChatRsp.ResultCode.SUCCESS_VALUE);
break;
}
}
clientSocket1.close();
// 接收者登陆
ClientSocket clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
// while (true) {
// response = clientSocket2.readFromServerWithoutKeepAlive();
// if (NetworkPacket.getMessageType(response) !=
// ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
// continue;
//
// ReceiveChatSync receiveChatting =
// ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
// ChatItem chatItem;
//
// for (int i = 0; i < times; i++) {
// chatItem = receiveChatting.getChatData(i);
// Debug.log(chatItem.getReceiveUserId() + " 收到 " +
// chatItem.getSendUserId() + " 发来的消息:" + chatItem.getChatType() + " "
// + chatItem.getChatBody());
// assertEquals(chatItem.getChatBody(), message + (i + ""));
// }
//
// Debug.log("接受者不回复!下线");
// break;
// }
// // 等待服务器把自己踢下线
// Thread.sleep(ServerModel.KEEP_ALIVE_PACKET_TIME +
// ServerModel.CHECK_WAIT_CLIENT_RESPONSE_DELTA_TIME);
// Thread.sleep(9*1000);
// 重新连接,登录,接收消息
clientSocket2.close();
clientSocket2 = new ClientSocket();
if (clientSocket2.login(userId2, userId2) != LoginRsp.ResultCode.SUCCESS)
fail("登陆结果错误!");
while (true) {
response = clientSocket2.readFromServerWithoutKeepAlive();
if (NetworkPacket.getMessageType(response) != ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC)
continue;
ReceiveChatSync receiveChatting = ReceiveChatSync.parseFrom(NetworkPacket.getMessageObjectBytes(response));
List<ChatItem> chatItems = receiveChatting.getChatDataList();
showChatItems(chatItems);
assertEquals(chatItems.get(0).getChatBody(), message + (0 + ""));
// 回复
clientSocket2.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.RECEIVE_CHAT_SYNC_VALUE,
NetworkPacket.getMessageID(response), new byte[0]));
break;
}
clientSocket2.close();
}
/**
* 发送一条聊天
*
* @param clientSocket
* @param senderUserId
* @param receiveUserId
* @param type
* @param messageBody
* @author Feng
* @throws IOException
*/
private void sendChatting(ClientSocket clientSocket, String senderUserId, String receiveUserId, ChatItem.ChatType type,
String messageBody) throws IOException {
ChatItem.Builder chatItem = ChatItem.newBuilder();
chatItem.setTargetType(ChatItem.TargetType.INDIVIDUAL);
chatItem.setSendUserId(senderUserId);
chatItem.setReceiveUserId(receiveUserId);
chatItem.setChatType(type);
chatItem.setChatBody(messageBody);
SendChatReq.Builder sendChatBuilder = SendChatReq.newBuilder();
sendChatBuilder.setChatData(chatItem);
clientSocket.writeToServer(NetworkPacket.packMessage(ProtoHead.ENetworkMessage.SEND_CHAT_REQ_VALUE, sendChatBuilder
.build().toByteArray()));
}
}
| 13,677 | 0.726767 | 0.714163 | 385 | 32.176624 | 31.625732 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.353247 | false | false | 10 |
6c0a2753304f2e406ec770fb028605878ab098b1 | 29,051,158,839,328 | 250713e8ee2ec893df548024ef89d06f60b16dd5 | /2.0.0/CN-App-User-5000/src/main/java/org/zmsoft/config/MyJsonConfiger.java | 96030d2ff65729d3d9ba021e19bb2da887f28384 | [
"BSD-3-Clause-Clear"
] | permissive | moutainhigh/cnsoft | https://github.com/moutainhigh/cnsoft | 5ecda93285476041cde6711b8fa46dc7e7354a7d | b9b921d43ea9b06c881121ab5d98ce18e14df87d | refs/heads/master | 2023-07-31T23:20:56.388000 | 2021-04-30T03:50:46 | 2021-04-30T03:50:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.zmsoft.config;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
/**
* 启用FastJson
* @author spookfcy
* @see https://www.cnblogs.com/skyblue-li/p/5946117.html
*/
@Configuration
public class MyJsonConfiger {
/**
* 通过@Bean注解
*
* @return
*/
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
// 1.定义一个消息转换对象convert
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
// 2.添加fastJson配置信息,是否需要格式化
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
// 3.在convert添加配置信息
fastConverter.setFastJsonConfig(fastJsonConfig);
// 4.将convert添加到converters中
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
}
| UTF-8 | Java | 1,290 | java | MyJsonConfiger.java | Java | [
{
"context": "ttpMessageConverter;\n\n/**\n * 启用FastJson\n * @author spookfcy\n * @see https://www.cnblogs.com/skyblue-li/p/5946",
"end": 508,
"score": 0.9997074604034424,
"start": 500,
"tag": "USERNAME",
"value": "spookfcy"
},
{
"context": " @author spookfcy\n * @see https://www.cnb... | null | [] | package org.zmsoft.config;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
/**
* 启用FastJson
* @author spookfcy
* @see https://www.cnblogs.com/skyblue-li/p/5946117.html
*/
@Configuration
public class MyJsonConfiger {
/**
* 通过@Bean注解
*
* @return
*/
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
// 1.定义一个消息转换对象convert
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
// 2.添加fastJson配置信息,是否需要格式化
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(SerializerFeature.PrettyFormat);
// 3.在convert添加配置信息
fastConverter.setFastJsonConfig(fastJsonConfig);
// 4.将convert添加到converters中
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
}
| 1,290 | 0.806799 | 0.797678 | 41 | 28.414635 | 26.531137 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.02439 | false | false | 10 |
08d4603c7160913928416d9cf67f9987edf289cb | 35,828,617,195,397 | 8f80fa489cf5b13b504b79dc75a933f618ac2717 | /src/main/java/com/whjx/dao/SaveInfoMapper.java | 551e7e01b7d7c3ab28b448cea1b32d57ee8d7494 | [] | no_license | Zhang-xaio/FiveFlowers-2 | https://github.com/Zhang-xaio/FiveFlowers-2 | c3e272db91a6dae38167be71e6a914fb7121e2a0 | 831a4b9778a88656da111ced063ec4fa071321c4 | refs/heads/master | 2020-12-27T13:20:29.896000 | 2020-02-02T05:51:42 | 2020-02-02T05:51:42 | 237,916,391 | 1 | 0 | null | true | 2020-02-03T08:18:17 | 2020-02-03T08:18:16 | 2020-02-02T05:52:44 | 2020-02-02T05:52:42 | 47,034 | 0 | 0 | 0 | null | false | false | package com.whjx.dao;
import com.whjx.pojo.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface SaveInfoMapper {
int saveInfo(@Param("ui") UserInfo userInfo);
UserInfo selectUser(@Param("openid") String openid);
}
| UTF-8 | Java | 304 | java | SaveInfoMapper.java | Java | [] | null | [] | package com.whjx.dao;
import com.whjx.pojo.UserInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@Repository
public interface SaveInfoMapper {
int saveInfo(@Param("ui") UserInfo userInfo);
UserInfo selectUser(@Param("openid") String openid);
}
| 304 | 0.779605 | 0.779605 | 11 | 26.636364 | 20.303482 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 10 |
4dc7ce321de63d246465e10137d19f88f9d37b53 | 37,941,741,094,951 | 98a15bb6b79086d17a1f74f92e09d54530efec52 | /Pre-Exam-Coding/src/experiments/TestSortedMap.java | 97a048e25027835f1a71c6389d68eaafa61236ba | [] | no_license | christopher-clark/Pre-Exam-Coding | https://github.com/christopher-clark/Pre-Exam-Coding | 9db60395a7eff63392292b81867a1c31408b9d05 | 28337701e3fd8cddb78ea1c863464abed4a2d953 | refs/heads/master | 2020-12-21T19:44:52.625000 | 2016-08-11T07:55:07 | 2016-08-11T07:55:07 | 58,253,486 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package experiments;
import java.util.*;
public class TestSortedMap {
private static String[] data = {"Chris","Georgie","Liam","Antony","Lil","Brendan","Baka","Snez","Zebedee"};
public static void main(String[] args) {
TreeMap<Integer,String> myTreeMap = new TreeMap<Integer,String>();
for(int i = 0;i < data.length;i++){
myTreeMap.put(i, data[i]);
}
System.out.println("TreeMap = " + myTreeMap);
SortedMap<Integer,String> sMap = myTreeMap.subMap(3, 6);
System.out.println("TreeMap = " + myTreeMap);
System.out.println("SubMap = " + sMap);
SortedMap<Integer,String> sMap1 = myTreeMap;
System.out.println("sMap1 = " + sMap1);
System.out.println("myTreeMap CeilingValue 3 = " + myTreeMap.ceilingEntry(3));
System.out.println("myTreeMap lowerValue 3 = " + myTreeMap.lowerEntry(3));
System.out.println("myTreeMap higherValue 3 = " + myTreeMap.higherEntry(3));
System.out.println("myTreeMap CeilingKey 5 = " + myTreeMap.ceilingKey(5));
System.out.println("myTreeMap lowerValue 3 = " + myTreeMap.lowerEntry(3));
System.out.println("myTreeMap higherKey 3 = " + myTreeMap.higherKey(3));
}
}
| UTF-8 | Java | 1,170 | java | TestSortedMap.java | Java | [
{
"context": "tSortedMap {\r\n\r\n\tprivate static String[] data = {\"Chris\",\"Georgie\",\"Liam\",\"Antony\",\"Lil\",\"Brendan\",\"Baka\"",
"end": 116,
"score": 0.9998034834861755,
"start": 111,
"tag": "NAME",
"value": "Chris"
},
{
"context": "ap {\r\n\r\n\tprivate static String[] d... | null | [] | package experiments;
import java.util.*;
public class TestSortedMap {
private static String[] data = {"Chris","Georgie","Liam","Antony","Lil","Brendan","Baka","Snez","Zebedee"};
public static void main(String[] args) {
TreeMap<Integer,String> myTreeMap = new TreeMap<Integer,String>();
for(int i = 0;i < data.length;i++){
myTreeMap.put(i, data[i]);
}
System.out.println("TreeMap = " + myTreeMap);
SortedMap<Integer,String> sMap = myTreeMap.subMap(3, 6);
System.out.println("TreeMap = " + myTreeMap);
System.out.println("SubMap = " + sMap);
SortedMap<Integer,String> sMap1 = myTreeMap;
System.out.println("sMap1 = " + sMap1);
System.out.println("myTreeMap CeilingValue 3 = " + myTreeMap.ceilingEntry(3));
System.out.println("myTreeMap lowerValue 3 = " + myTreeMap.lowerEntry(3));
System.out.println("myTreeMap higherValue 3 = " + myTreeMap.higherEntry(3));
System.out.println("myTreeMap CeilingKey 5 = " + myTreeMap.ceilingKey(5));
System.out.println("myTreeMap lowerValue 3 = " + myTreeMap.lowerEntry(3));
System.out.println("myTreeMap higherKey 3 = " + myTreeMap.higherKey(3));
}
}
| 1,170 | 0.667521 | 0.652137 | 33 | 33.454544 | 31.798695 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.333333 | false | false | 10 |
48c45630bba31f00bd0938041deae84b261f5eab | 37,160,057,053,813 | ca030864a3a1c24be6b9d1802c2353da4ca0d441 | /classes2.dex_source_from_JADX/com/facebook/apptab/ui/BadgableGlyphView.java | cb7edc9c57e9bdff014ec31cf43b12156840cfa7 | [] | no_license | pxson001/facebook-app | https://github.com/pxson001/facebook-app | 87aa51e29195eeaae69adeb30219547f83a5b7b1 | 640630f078980f9818049625ebc42569c67c69f7 | refs/heads/master | 2020-04-07T20:36:45.758000 | 2018-03-07T09:04:57 | 2018-03-07T09:04:57 | 124,208,458 | 4 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.facebook.apptab.ui;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.View.MeasureSpec;
import com.facebook.apptab.ui.CaspianTabViewUtil.Theme;
import com.facebook.fbui.glyph.GlyphColorizer;
import com.facebook.inject.FbInjector;
import com.facebook.inject.IdBasedLazy;
import com.facebook.inject.InjectorLike;
import com.facebook.inject.Lazy;
import com.facebook.springs.SimpleSpringListener;
import com.facebook.springs.Spring;
import com.facebook.springs.SpringConfig;
import com.facebook.springs.SpringListener;
import com.facebook.springs.SpringSystem;
import com.facebook.widget.text.CustomFontHelper;
import com.facebook.widget.text.CustomFontHelper.FontFamily;
import com.facebook.widget.text.CustomFontHelper.FontWeight;
import com.google.common.base.Strings;
import javax.annotation.Nullable;
import javax.inject.Inject;
/* compiled from: research.facebook.com */
public class BadgableGlyphView extends View {
protected final Rect f7157a;
protected Drawable f7158b;
public int f7159c;
public boolean f7160d;
@Inject
CaspianTabViewUtil f7161e;
@Inject
GlyphColorizer f7162f;
@Inject
Lazy<SpringSystem> f7163g;
private final int f7164h;
private final int f7165i;
private final int f7166j;
private final int f7167k;
private final int[] f7168l;
private final Rect f7169m;
private final Paint f7170n;
private final float f7171o;
private final SpringListener f7172p;
private final SpringListener f7173q;
private int f7174r;
private int f7175s;
private GradientDrawable f7176t;
public float f7177u;
private float f7178v;
private String f7179w;
private Spring f7180x;
private Spring f7181y;
private Integer f7182z;
/* compiled from: research.facebook.com */
class BadgeSpringListener extends SimpleSpringListener {
final /* synthetic */ BadgableGlyphView f7197a;
public BadgeSpringListener(BadgableGlyphView badgableGlyphView) {
this.f7197a = badgableGlyphView;
}
public final void mo1160a(Spring spring) {
this.f7197a.f7177u = (float) spring.m7821d();
this.f7197a.invalidate();
}
public final void mo1161b(Spring spring) {
if (spring.m7821d() == 0.0d) {
this.f7197a.f7159c = 0;
}
}
}
/* compiled from: research.facebook.com */
class SelectionSpringListener extends SimpleSpringListener {
final /* synthetic */ BadgableGlyphView f7198a;
public SelectionSpringListener(BadgableGlyphView badgableGlyphView) {
this.f7198a = badgableGlyphView;
}
public final void mo1160a(Spring spring) {
int i;
this.f7198a.f7158b.setColorFilter(this.f7198a.f7161e.m7809a(spring.m7821d()));
BadgableGlyphView badgableGlyphView = this.f7198a;
if (this.f7198a.f7161e.f4213d == Theme.LIGHT) {
i = -1;
} else {
i = -16777216;
}
badgableGlyphView.setBadgeOutlineColor(i);
this.f7198a.invalidate(this.f7198a.f7157a);
}
}
private static <T extends View> void m11626a(Class<T> cls, T t) {
m11627a((Object) t, t.getContext());
}
private static void m11627a(Object obj, Context context) {
InjectorLike injectorLike = FbInjector.get(context);
((BadgableGlyphView) obj).m11625a(CaspianTabViewUtil.m7806a(injectorLike), GlyphColorizer.m11486a(injectorLike), IdBasedLazy.m1808a(injectorLike, 3433));
}
public BadgableGlyphView(Context context) {
this(context, null);
}
public BadgableGlyphView(Context context, @Nullable AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public BadgableGlyphView(Context context, @Nullable AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.f7157a = new Rect();
this.f7168l = new int[2];
this.f7169m = new Rect();
this.f7172p = new BadgeSpringListener(this);
this.f7173q = new SelectionSpringListener(this);
m11626a(BadgableGlyphView.class, (View) this);
Resources resources = context.getResources();
this.f7164h = resources.getDimensionPixelSize(2131428120);
this.f7165i = resources.getDimensionPixelSize(2131428121);
this.f7166j = resources.getDimensionPixelSize(2131428122);
this.f7167k = resources.getDimensionPixelSize(2131428124);
this.f7176t = (GradientDrawable) resources.getDrawable(2130843535);
this.f7170n = new Paint();
this.f7170n.setTextSize((float) resources.getDimensionPixelSize(2131428123));
this.f7170n.setColor(-1);
this.f7170n.setTypeface(CustomFontHelper.m11813a(context, FontFamily.ROBOTO, FontWeight.BOLD, this.f7170n.getTypeface()));
this.f7170n.setAntiAlias(true);
this.f7170n.setTextAlign(Align.CENTER);
this.f7171o = ((this.f7170n.descent() - this.f7170n.ascent()) / 2.0f) - this.f7170n.descent();
}
private void m11625a(CaspianTabViewUtil caspianTabViewUtil, GlyphColorizer glyphColorizer, Lazy<SpringSystem> lazy) {
this.f7161e = caspianTabViewUtil;
this.f7162f = glyphColorizer;
this.f7163g = lazy;
}
public void setBadgeOutlineColor(int i) {
if (this.f7182z == null || this.f7182z.intValue() != i) {
this.f7182z = Integer.valueOf(i);
this.f7176t.mutate();
this.f7176t.setStroke((int) TypedValue.applyDimension(1, 1.0f, getResources().getDisplayMetrics()), i);
}
}
public void setBadgeColor(int i) {
this.f7176t.mutate();
this.f7176t.setColor(i);
}
public void setSelected(boolean z) {
getSelectionSpring().m7818b(z ? 1.0d : 0.0d);
}
public void setSelectionPercentage(float f) {
getSelectionSpring().m7818b((double) f).m7813a((double) f).m7830l();
}
public final void m11628a(Drawable drawable, int i) {
drawable.setColorFilter(this.f7162f.m11488a(i));
setGlyphImage(drawable);
}
public void setGlyphImage(Drawable drawable) {
this.f7158b = drawable;
int i = this.f7174r;
int i2 = this.f7175s;
this.f7174r = this.f7158b.getIntrinsicWidth();
this.f7175s = this.f7158b.getIntrinsicHeight();
if (!(this.f7174r == i && this.f7175s == i2)) {
requestLayout();
}
this.f7158b.setCallback(this);
}
public void setTabIconImageResource(int i) {
setGlyphImage(getResources().getDrawable(i));
}
public void setUnreadCount(int i) {
if (this.f7159c != i) {
Spring a;
if (i > 0) {
if (this.f7159c <= 0) {
a = getBadgeSpring().m7813a(0.0d);
a.f4216c = false;
a.m7818b(1.0d);
} else {
getBadgeSpring().m7820c(5.0d);
}
this.f7159c = i;
} else {
a = getBadgeSpring();
a.f4216c = true;
a.m7818b(0.0d);
}
requestLayout();
}
}
public int getUnreadCount() {
return this.f7159c;
}
public void setUseSmallUnreadCountCap(boolean z) {
this.f7160d = z;
}
protected void onMeasure(int i, int i2) {
int size = MeasureSpec.getSize(i);
int size2 = MeasureSpec.getSize(i2);
int i3 = size / 2;
int i4 = size2 / 2;
this.f7157a.left = i3 - (this.f7174r / 2);
this.f7157a.right = i3 + (this.f7174r / 2);
this.f7157a.top = i4 - (this.f7175s / 2);
this.f7157a.bottom = i4 + (this.f7175s / 2);
if (this.f7159c > 0) {
int i5;
CaspianTabViewUtil caspianTabViewUtil = this.f7161e;
i4 = this.f7159c;
boolean z = this.f7160d;
if (z) {
i5 = 9;
} else {
i5 = 99;
}
String valueOf = i4 > i5 ? z ? caspianTabViewUtil.f4211b : caspianTabViewUtil.f4212c : String.valueOf(i4);
this.f7179w = valueOf;
i3 = Math.max(this.f7166j * 2, ((int) this.f7170n.measureText(this.f7179w)) + this.f7167k) / 2;
this.f7168l[0] = this.f7157a.right + this.f7164h;
this.f7168l[1] = this.f7157a.top + this.f7165i;
this.f7169m.left = this.f7168l[0] - i3;
this.f7169m.top = this.f7168l[1] - this.f7166j;
this.f7169m.right = i3 + this.f7168l[0];
this.f7169m.bottom = this.f7168l[1] + this.f7166j;
this.f7178v = ((float) this.f7168l[1]) + this.f7171o;
}
setMeasuredDimension(size, size2);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
this.f7158b.setBounds(this.f7157a);
this.f7158b.draw(canvas);
if (this.f7177u > 0.0f && !Strings.isNullOrEmpty(this.f7179w)) {
float f = 40.0f - (this.f7177u * 40.0f);
canvas.save();
canvas.scale(this.f7177u, this.f7177u, (float) this.f7168l[0], (float) this.f7168l[1]);
canvas.rotate(f, (float) this.f7168l[0], (float) this.f7168l[1]);
this.f7176t.setBounds(this.f7169m);
this.f7176t.draw(canvas);
canvas.drawText(this.f7179w, (float) this.f7168l[0], this.f7178v, this.f7170n);
canvas.restore();
}
}
public void invalidateDrawable(Drawable drawable) {
super.invalidateDrawable(drawable);
if (drawable == this.f7158b) {
invalidate(drawable.getBounds());
}
}
protected boolean verifyDrawable(Drawable drawable) {
return this.f7158b == drawable || super.verifyDrawable(drawable);
}
private synchronized Spring getBadgeSpring() {
Spring spring;
if (this.f7181y != null) {
spring = this.f7181y;
} else {
this.f7181y = ((SpringSystem) this.f7163g.get()).m7838a().m7814a(SpringConfig.m7843b(13.0d, 15.0d)).m7813a(0.0d).m7818b(0.0d).m7824e(0.01d).m7822d(1.0d).m7830l();
this.f7181y.m7815a(this.f7172p);
spring = this.f7181y;
}
return spring;
}
private synchronized Spring getSelectionSpring() {
Spring spring;
if (this.f7180x != null) {
spring = this.f7180x;
} else {
this.f7180x = ((SpringSystem) this.f7163g.get()).m7838a().m7814a(SpringConfig.m7842a(40.0d, 4.0d)).m7813a(0.0d).m7818b(0.0d).m7830l().m7824e(0.01d).m7822d(0.2d).m7816a(true);
this.f7180x.m7815a(this.f7173q);
spring = this.f7180x;
}
return spring;
}
}
| UTF-8 | Java | 11,155 | java | BadgableGlyphView.java | Java | [] | null | [] | package com.facebook.apptab.ui;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.View.MeasureSpec;
import com.facebook.apptab.ui.CaspianTabViewUtil.Theme;
import com.facebook.fbui.glyph.GlyphColorizer;
import com.facebook.inject.FbInjector;
import com.facebook.inject.IdBasedLazy;
import com.facebook.inject.InjectorLike;
import com.facebook.inject.Lazy;
import com.facebook.springs.SimpleSpringListener;
import com.facebook.springs.Spring;
import com.facebook.springs.SpringConfig;
import com.facebook.springs.SpringListener;
import com.facebook.springs.SpringSystem;
import com.facebook.widget.text.CustomFontHelper;
import com.facebook.widget.text.CustomFontHelper.FontFamily;
import com.facebook.widget.text.CustomFontHelper.FontWeight;
import com.google.common.base.Strings;
import javax.annotation.Nullable;
import javax.inject.Inject;
/* compiled from: research.facebook.com */
public class BadgableGlyphView extends View {
protected final Rect f7157a;
protected Drawable f7158b;
public int f7159c;
public boolean f7160d;
@Inject
CaspianTabViewUtil f7161e;
@Inject
GlyphColorizer f7162f;
@Inject
Lazy<SpringSystem> f7163g;
private final int f7164h;
private final int f7165i;
private final int f7166j;
private final int f7167k;
private final int[] f7168l;
private final Rect f7169m;
private final Paint f7170n;
private final float f7171o;
private final SpringListener f7172p;
private final SpringListener f7173q;
private int f7174r;
private int f7175s;
private GradientDrawable f7176t;
public float f7177u;
private float f7178v;
private String f7179w;
private Spring f7180x;
private Spring f7181y;
private Integer f7182z;
/* compiled from: research.facebook.com */
class BadgeSpringListener extends SimpleSpringListener {
final /* synthetic */ BadgableGlyphView f7197a;
public BadgeSpringListener(BadgableGlyphView badgableGlyphView) {
this.f7197a = badgableGlyphView;
}
public final void mo1160a(Spring spring) {
this.f7197a.f7177u = (float) spring.m7821d();
this.f7197a.invalidate();
}
public final void mo1161b(Spring spring) {
if (spring.m7821d() == 0.0d) {
this.f7197a.f7159c = 0;
}
}
}
/* compiled from: research.facebook.com */
class SelectionSpringListener extends SimpleSpringListener {
final /* synthetic */ BadgableGlyphView f7198a;
public SelectionSpringListener(BadgableGlyphView badgableGlyphView) {
this.f7198a = badgableGlyphView;
}
public final void mo1160a(Spring spring) {
int i;
this.f7198a.f7158b.setColorFilter(this.f7198a.f7161e.m7809a(spring.m7821d()));
BadgableGlyphView badgableGlyphView = this.f7198a;
if (this.f7198a.f7161e.f4213d == Theme.LIGHT) {
i = -1;
} else {
i = -16777216;
}
badgableGlyphView.setBadgeOutlineColor(i);
this.f7198a.invalidate(this.f7198a.f7157a);
}
}
private static <T extends View> void m11626a(Class<T> cls, T t) {
m11627a((Object) t, t.getContext());
}
private static void m11627a(Object obj, Context context) {
InjectorLike injectorLike = FbInjector.get(context);
((BadgableGlyphView) obj).m11625a(CaspianTabViewUtil.m7806a(injectorLike), GlyphColorizer.m11486a(injectorLike), IdBasedLazy.m1808a(injectorLike, 3433));
}
public BadgableGlyphView(Context context) {
this(context, null);
}
public BadgableGlyphView(Context context, @Nullable AttributeSet attributeSet) {
this(context, attributeSet, 0);
}
public BadgableGlyphView(Context context, @Nullable AttributeSet attributeSet, int i) {
super(context, attributeSet, i);
this.f7157a = new Rect();
this.f7168l = new int[2];
this.f7169m = new Rect();
this.f7172p = new BadgeSpringListener(this);
this.f7173q = new SelectionSpringListener(this);
m11626a(BadgableGlyphView.class, (View) this);
Resources resources = context.getResources();
this.f7164h = resources.getDimensionPixelSize(2131428120);
this.f7165i = resources.getDimensionPixelSize(2131428121);
this.f7166j = resources.getDimensionPixelSize(2131428122);
this.f7167k = resources.getDimensionPixelSize(2131428124);
this.f7176t = (GradientDrawable) resources.getDrawable(2130843535);
this.f7170n = new Paint();
this.f7170n.setTextSize((float) resources.getDimensionPixelSize(2131428123));
this.f7170n.setColor(-1);
this.f7170n.setTypeface(CustomFontHelper.m11813a(context, FontFamily.ROBOTO, FontWeight.BOLD, this.f7170n.getTypeface()));
this.f7170n.setAntiAlias(true);
this.f7170n.setTextAlign(Align.CENTER);
this.f7171o = ((this.f7170n.descent() - this.f7170n.ascent()) / 2.0f) - this.f7170n.descent();
}
private void m11625a(CaspianTabViewUtil caspianTabViewUtil, GlyphColorizer glyphColorizer, Lazy<SpringSystem> lazy) {
this.f7161e = caspianTabViewUtil;
this.f7162f = glyphColorizer;
this.f7163g = lazy;
}
public void setBadgeOutlineColor(int i) {
if (this.f7182z == null || this.f7182z.intValue() != i) {
this.f7182z = Integer.valueOf(i);
this.f7176t.mutate();
this.f7176t.setStroke((int) TypedValue.applyDimension(1, 1.0f, getResources().getDisplayMetrics()), i);
}
}
public void setBadgeColor(int i) {
this.f7176t.mutate();
this.f7176t.setColor(i);
}
public void setSelected(boolean z) {
getSelectionSpring().m7818b(z ? 1.0d : 0.0d);
}
public void setSelectionPercentage(float f) {
getSelectionSpring().m7818b((double) f).m7813a((double) f).m7830l();
}
public final void m11628a(Drawable drawable, int i) {
drawable.setColorFilter(this.f7162f.m11488a(i));
setGlyphImage(drawable);
}
public void setGlyphImage(Drawable drawable) {
this.f7158b = drawable;
int i = this.f7174r;
int i2 = this.f7175s;
this.f7174r = this.f7158b.getIntrinsicWidth();
this.f7175s = this.f7158b.getIntrinsicHeight();
if (!(this.f7174r == i && this.f7175s == i2)) {
requestLayout();
}
this.f7158b.setCallback(this);
}
public void setTabIconImageResource(int i) {
setGlyphImage(getResources().getDrawable(i));
}
public void setUnreadCount(int i) {
if (this.f7159c != i) {
Spring a;
if (i > 0) {
if (this.f7159c <= 0) {
a = getBadgeSpring().m7813a(0.0d);
a.f4216c = false;
a.m7818b(1.0d);
} else {
getBadgeSpring().m7820c(5.0d);
}
this.f7159c = i;
} else {
a = getBadgeSpring();
a.f4216c = true;
a.m7818b(0.0d);
}
requestLayout();
}
}
public int getUnreadCount() {
return this.f7159c;
}
public void setUseSmallUnreadCountCap(boolean z) {
this.f7160d = z;
}
protected void onMeasure(int i, int i2) {
int size = MeasureSpec.getSize(i);
int size2 = MeasureSpec.getSize(i2);
int i3 = size / 2;
int i4 = size2 / 2;
this.f7157a.left = i3 - (this.f7174r / 2);
this.f7157a.right = i3 + (this.f7174r / 2);
this.f7157a.top = i4 - (this.f7175s / 2);
this.f7157a.bottom = i4 + (this.f7175s / 2);
if (this.f7159c > 0) {
int i5;
CaspianTabViewUtil caspianTabViewUtil = this.f7161e;
i4 = this.f7159c;
boolean z = this.f7160d;
if (z) {
i5 = 9;
} else {
i5 = 99;
}
String valueOf = i4 > i5 ? z ? caspianTabViewUtil.f4211b : caspianTabViewUtil.f4212c : String.valueOf(i4);
this.f7179w = valueOf;
i3 = Math.max(this.f7166j * 2, ((int) this.f7170n.measureText(this.f7179w)) + this.f7167k) / 2;
this.f7168l[0] = this.f7157a.right + this.f7164h;
this.f7168l[1] = this.f7157a.top + this.f7165i;
this.f7169m.left = this.f7168l[0] - i3;
this.f7169m.top = this.f7168l[1] - this.f7166j;
this.f7169m.right = i3 + this.f7168l[0];
this.f7169m.bottom = this.f7168l[1] + this.f7166j;
this.f7178v = ((float) this.f7168l[1]) + this.f7171o;
}
setMeasuredDimension(size, size2);
}
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
this.f7158b.setBounds(this.f7157a);
this.f7158b.draw(canvas);
if (this.f7177u > 0.0f && !Strings.isNullOrEmpty(this.f7179w)) {
float f = 40.0f - (this.f7177u * 40.0f);
canvas.save();
canvas.scale(this.f7177u, this.f7177u, (float) this.f7168l[0], (float) this.f7168l[1]);
canvas.rotate(f, (float) this.f7168l[0], (float) this.f7168l[1]);
this.f7176t.setBounds(this.f7169m);
this.f7176t.draw(canvas);
canvas.drawText(this.f7179w, (float) this.f7168l[0], this.f7178v, this.f7170n);
canvas.restore();
}
}
public void invalidateDrawable(Drawable drawable) {
super.invalidateDrawable(drawable);
if (drawable == this.f7158b) {
invalidate(drawable.getBounds());
}
}
protected boolean verifyDrawable(Drawable drawable) {
return this.f7158b == drawable || super.verifyDrawable(drawable);
}
private synchronized Spring getBadgeSpring() {
Spring spring;
if (this.f7181y != null) {
spring = this.f7181y;
} else {
this.f7181y = ((SpringSystem) this.f7163g.get()).m7838a().m7814a(SpringConfig.m7843b(13.0d, 15.0d)).m7813a(0.0d).m7818b(0.0d).m7824e(0.01d).m7822d(1.0d).m7830l();
this.f7181y.m7815a(this.f7172p);
spring = this.f7181y;
}
return spring;
}
private synchronized Spring getSelectionSpring() {
Spring spring;
if (this.f7180x != null) {
spring = this.f7180x;
} else {
this.f7180x = ((SpringSystem) this.f7163g.get()).m7838a().m7814a(SpringConfig.m7842a(40.0d, 4.0d)).m7813a(0.0d).m7818b(0.0d).m7830l().m7824e(0.01d).m7822d(0.2d).m7816a(true);
this.f7180x.m7815a(this.f7173q);
spring = this.f7180x;
}
return spring;
}
}
| 11,155 | 0.626535 | 0.532586 | 307 | 35.335506 | 27.821466 | 186 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.713355 | false | false | 10 |
ca42cd5473049df0bcf7725c50f434d39175f2f6 | 38,637,525,795,997 | 813d2cd6eed1ceb60b87023c6baaed23dfd7ce0a | /web-backend-workSeacher/src/main/java/com/workSearcher/backend/models/services/interfaces/IOfertaEmpleoService.java | 1e5f693079d6f95b3f932f7c3418c0f7fe3843ac | [] | no_license | JosueFerrin20/web-workSearcher | https://github.com/JosueFerrin20/web-workSearcher | 00d5d0f2b381318f350cdb47f5b3f643fecd62ad | 06d2ca706db786540ef1356d59b066e07755383e | refs/heads/main | 2023-07-17T00:07:44.263000 | 2021-09-02T16:40:28 | 2021-09-02T16:40:28 | 402,492,138 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.workSearcher.backend.models.services.interfaces;
import java.util.List;
import java.util.Optional;
import com.workSearcher.backend.models.entities.ofertaEmpleo;
public interface IOfertaEmpleoService {
public void save(ofertaEmpleo oferta);//guardar -> create/update
public Optional <ofertaEmpleo> findById(Integer id);//consultar -> retrieve
public void delete(Integer id);//Borrar -> delete
public List<ofertaEmpleo> findAll();//consultar en conjunto -> List
}
| UTF-8 | Java | 484 | java | IOfertaEmpleoService.java | Java | [] | null | [] | package com.workSearcher.backend.models.services.interfaces;
import java.util.List;
import java.util.Optional;
import com.workSearcher.backend.models.entities.ofertaEmpleo;
public interface IOfertaEmpleoService {
public void save(ofertaEmpleo oferta);//guardar -> create/update
public Optional <ofertaEmpleo> findById(Integer id);//consultar -> retrieve
public void delete(Integer id);//Borrar -> delete
public List<ofertaEmpleo> findAll();//consultar en conjunto -> List
}
| 484 | 0.789256 | 0.789256 | 14 | 33.57143 | 28.637424 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.928571 | false | false | 10 |
ac4aa04c8b0295c1afff6268dc1f95306b2d5ee8 | 35,253,091,594,768 | b046f35cc7b7c5ba2069fc3a828741331a640c11 | /src/main/java/ar/edu/um/programacion2_2018/tp10/controller/TareaController.java | 2eb8d05f96a3b0e9f46bd41af9301c8733797e8a | [] | no_license | Matinho/Programacion-2.Trabajo-Practico-10 | https://github.com/Matinho/Programacion-2.Trabajo-Practico-10 | 5af8f9e52ec3cfe9b8c761ec7ee5594bf493d929 | 1a70afa6c390b7d2481216223c4f35ace71d5d29 | refs/heads/master | 2020-03-29T07:23:07.953000 | 2018-09-20T20:33:53 | 2018-09-20T20:33:53 | 149,662,968 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ar.edu.um.programacion2_2018.tp10.controller;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ar.edu.um.programacion2_2018.tp10.exception.ResourceNotFoundException;
import ar.edu.um.programacion2_2018.tp10.model.Tarea;
import ar.edu.um.programacion2_2018.tp10.repository.TareaRepository;
@RestController
@RequestMapping("/api")
public class TareaController {
@Autowired
TareaRepository tareaRepository;
// Traer Todas las tareas
@GetMapping("/tareas")
public List<Tarea> getAllTareas() {
return tareaRepository.findAll();
}
// Traer una tarea especifica por ID
@GetMapping("/tareas/{id}")
public Tarea getTareaById(@PathVariable(value = "id") Long tareaId) {
return tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
}
// Insertar Tarea
@PostMapping("/tareas")
public Tarea createTarea(@Valid @RequestBody Tarea tarea) {
return tareaRepository.save(tarea);
}
// Eliminar Tarea
@DeleteMapping("/tareas/{id}")
public ResponseEntity<?> deleteTarea(@PathVariable(value = "id") Long tareaId){
Tarea tarea = tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
tareaRepository.delete(tarea);
return ResponseEntity.ok().build();
}
// Actualizar Tarea
@PutMapping("/tareas/{id}")
public Tarea updateTarea( @PathVariable(value = "id") Long tareaId,
@Valid @RequestBody Tarea detallesTarea) {
Tarea tarea = tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
tarea.setDescripcion(detallesTarea.getDescripcion());
tarea.setResponsable(detallesTarea.getResponsable());
Tarea actualizarTarea = tareaRepository.save(tarea);
return actualizarTarea;
}
}
| UTF-8 | Java | 2,512 | java | TareaController.java | Java | [] | null | [] | package ar.edu.um.programacion2_2018.tp10.controller;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ar.edu.um.programacion2_2018.tp10.exception.ResourceNotFoundException;
import ar.edu.um.programacion2_2018.tp10.model.Tarea;
import ar.edu.um.programacion2_2018.tp10.repository.TareaRepository;
@RestController
@RequestMapping("/api")
public class TareaController {
@Autowired
TareaRepository tareaRepository;
// Traer Todas las tareas
@GetMapping("/tareas")
public List<Tarea> getAllTareas() {
return tareaRepository.findAll();
}
// Traer una tarea especifica por ID
@GetMapping("/tareas/{id}")
public Tarea getTareaById(@PathVariable(value = "id") Long tareaId) {
return tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
}
// Insertar Tarea
@PostMapping("/tareas")
public Tarea createTarea(@Valid @RequestBody Tarea tarea) {
return tareaRepository.save(tarea);
}
// Eliminar Tarea
@DeleteMapping("/tareas/{id}")
public ResponseEntity<?> deleteTarea(@PathVariable(value = "id") Long tareaId){
Tarea tarea = tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
tareaRepository.delete(tarea);
return ResponseEntity.ok().build();
}
// Actualizar Tarea
@PutMapping("/tareas/{id}")
public Tarea updateTarea( @PathVariable(value = "id") Long tareaId,
@Valid @RequestBody Tarea detallesTarea) {
Tarea tarea = tareaRepository.findById(tareaId)
.orElseThrow(() -> new ResourceNotFoundException("Tarea", "id", tareaId));
tarea.setDescripcion(detallesTarea.getDescripcion());
tarea.setResponsable(detallesTarea.getResponsable());
Tarea actualizarTarea = tareaRepository.save(tarea);
return actualizarTarea;
}
}
| 2,512 | 0.745223 | 0.734076 | 72 | 32.888889 | 26.196138 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.5 | false | false | 10 |
eb1050f28b7a7b1b23f24c2923d9c01dd0fcd3a6 | 33,973,191,350,130 | a216c3b12aee66c2c5709d033bb7353177999feb | /src/com/sample/xpressapply/handlers/ReviseOfferCompletedIntentHandler.java | 397f64994d78b4d36b90b8e4523d97412139a523 | [] | no_license | nikhilnicks/xpressapply | https://github.com/nikhilnicks/xpressapply | 4218c2266079f3b574243d5d057ed28109004847 | 2bcc71c4a0df66a4eaf9641b4dd2fd8f01fb53fd | refs/heads/master | 2020-03-27T14:02:10.288000 | 2018-08-30T13:19:03 | 2018-08-30T13:19:03 | 146,640,818 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.sample.xpressapply.handlers;
import static com.amazon.ask.request.Predicates.intentName;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.DialogState;
import com.amazon.ask.model.Intent;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Request;
import com.amazon.ask.model.Response;
import com.amazon.ask.model.Slot;
import java.util.Map;
import java.util.Optional;
public class ReviseOfferCompletedIntentHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
System.out.println("Request Type : " + input.getRequestEnvelope().getRequest().getType());
System.out.print("trying complete , state : " + (
input.getRequestEnvelope().getRequest().getType().matches("IntentRequest")
? ((IntentRequest) input.getRequestEnvelope().getRequest()).getDialogState() : ""));
return input.getRequestEnvelope().getRequest().getType().matches("IntentRequest") &&
input.matches(intentName("ReviseOffer"))
&& ((IntentRequest) input.getRequestEnvelope().getRequest()).getDialogState()
.equals(DialogState.COMPLETED);
}
@Override
public Optional<Response> handle(HandlerInput input) {
Request request = input.getRequestEnvelope().getRequest();
IntentRequest intentRequest = (IntentRequest) request;
Intent intent = intentRequest.getIntent();
Map<String, Slot> slots = intent.getSlots();
System.out.print("handling complete request");
boolean restart = false;
// System.out.println(slots);
String speechText;
String amount = slots
.get("amount").getValue();
String terms = slots
.get("terms").getValue();
String apr = slots
.get("apr").getValue();
restart = Integer.valueOf(amount) < 50000;
//TODO: identify the flag and speech text accordingly.
{
if (restart) {
speechText = "<speak>You loan is approved for " + amount
+ " for <say-as interpret-as='spell-out'>APR</say-as> " + apr + "% under terms of "
+ terms + " </speak>";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("ApplySession", speechText)
.withShouldEndSession(false)
//.addDelegateDirective(Intent.builder().withName("processoffer").withConfirmationStatus(IntentConfirmationStatus.NONE).build())
.build();
} else {
System.out.println("Trying to restart the intent again after completion");
speechText =
"<speak>We are unable to approve the loan amount that you have requested for the terms and <say-as interpret-as='spell-out'>APR</say-as> at the moment. "
+ "Please Say <emphasis level='strong'>Start Over</emphasis> to restart your application</speak>";
return input.getResponseBuilder()
.withSpeech(speechText)
.withShouldEndSession(false)
.withSimpleCard("ApplySession", speechText)
.build();
}
}
}
}
| UTF-8 | Java | 3,719 | java | ReviseOfferCompletedIntentHandler.java | Java | [] | null | [] | /*
Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
the specific language governing permissions and limitations under the License.
*/
package com.sample.xpressapply.handlers;
import static com.amazon.ask.request.Predicates.intentName;
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
import com.amazon.ask.model.DialogState;
import com.amazon.ask.model.Intent;
import com.amazon.ask.model.IntentRequest;
import com.amazon.ask.model.Request;
import com.amazon.ask.model.Response;
import com.amazon.ask.model.Slot;
import java.util.Map;
import java.util.Optional;
public class ReviseOfferCompletedIntentHandler implements RequestHandler {
@Override
public boolean canHandle(HandlerInput input) {
System.out.println("Request Type : " + input.getRequestEnvelope().getRequest().getType());
System.out.print("trying complete , state : " + (
input.getRequestEnvelope().getRequest().getType().matches("IntentRequest")
? ((IntentRequest) input.getRequestEnvelope().getRequest()).getDialogState() : ""));
return input.getRequestEnvelope().getRequest().getType().matches("IntentRequest") &&
input.matches(intentName("ReviseOffer"))
&& ((IntentRequest) input.getRequestEnvelope().getRequest()).getDialogState()
.equals(DialogState.COMPLETED);
}
@Override
public Optional<Response> handle(HandlerInput input) {
Request request = input.getRequestEnvelope().getRequest();
IntentRequest intentRequest = (IntentRequest) request;
Intent intent = intentRequest.getIntent();
Map<String, Slot> slots = intent.getSlots();
System.out.print("handling complete request");
boolean restart = false;
// System.out.println(slots);
String speechText;
String amount = slots
.get("amount").getValue();
String terms = slots
.get("terms").getValue();
String apr = slots
.get("apr").getValue();
restart = Integer.valueOf(amount) < 50000;
//TODO: identify the flag and speech text accordingly.
{
if (restart) {
speechText = "<speak>You loan is approved for " + amount
+ " for <say-as interpret-as='spell-out'>APR</say-as> " + apr + "% under terms of "
+ terms + " </speak>";
return input.getResponseBuilder()
.withSpeech(speechText)
.withSimpleCard("ApplySession", speechText)
.withShouldEndSession(false)
//.addDelegateDirective(Intent.builder().withName("processoffer").withConfirmationStatus(IntentConfirmationStatus.NONE).build())
.build();
} else {
System.out.println("Trying to restart the intent again after completion");
speechText =
"<speak>We are unable to approve the loan amount that you have requested for the terms and <say-as interpret-as='spell-out'>APR</say-as> at the moment. "
+ "Please Say <emphasis level='strong'>Start Over</emphasis> to restart your application</speak>";
return input.getResponseBuilder()
.withSpeech(speechText)
.withShouldEndSession(false)
.withSimpleCard("ApplySession", speechText)
.build();
}
}
}
}
| 3,719 | 0.686206 | 0.68271 | 90 | 40.322224 | 34.490845 | 165 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 10 |
eb36b282460fcfe107d175c0ff9f07d2c19cd646 | 15,418,932,650,428 | 215ecc382272b863ce043b14a595a98ecb7a8039 | /src/interviewquestions/easy/LinkedListCycle.java | 4d440549393c0f991af76316615e81548f3dc32d | [] | no_license | tianya2010/AlgoDS | https://github.com/tianya2010/AlgoDS | 0ed214b2af65ad2b655fc1b138cfe6e136bac58b | 1d56fe4587bf223a8ecc8f125815ca1478d553d8 | refs/heads/master | 2021-01-22T08:18:55.615000 | 2017-02-13T04:53:57 | 2017-02-13T04:53:57 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package interviewquestions.easy;
import interviewquestions.utils.ListNode;
/**
* Created by sherxon on 12/28/16.
*/
public class LinkedListCycle {
public boolean hasCycle(ListNode x) {
if(x==null || x.next==null)return false;
ListNode fast=x.next.next;
while(fast!=null && fast.next!=null && x.next!=null){
x=x.next;
fast=fast.next.next;
if(x==fast)return true;
}
return false;
}
}
/*
class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
* */ | UTF-8 | Java | 617 | java | LinkedListCycle.java | Java | [
{
"context": "erviewquestions.utils.ListNode;\n\n/**\n * Created by sherxon on 12/28/16.\n */\npublic class LinkedListCycle {\n ",
"end": 102,
"score": 0.9996381402015686,
"start": 95,
"tag": "USERNAME",
"value": "sherxon"
}
] | null | [] | package interviewquestions.easy;
import interviewquestions.utils.ListNode;
/**
* Created by sherxon on 12/28/16.
*/
public class LinkedListCycle {
public boolean hasCycle(ListNode x) {
if(x==null || x.next==null)return false;
ListNode fast=x.next.next;
while(fast!=null && fast.next!=null && x.next!=null){
x=x.next;
fast=fast.next.next;
if(x==fast)return true;
}
return false;
}
}
/*
class ListNode {
* int val;
* ListNode next;
* ListNode(int x) {
* val = x;
* next = null;
* }
* }
* */ | 617 | 0.539708 | 0.529984 | 31 | 18.935484 | 16.315311 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.451613 | false | false | 10 |
a552b1bc182a7a5853f47ddf22d86b0c1e8f3e05 | 34,351,148,490,486 | 9780466dcf358ca1204b8c775815cfc98b971403 | /src/de/dimm/vsm/fsutils/VfsProxyFile.java | dbd9d7343da5d4419e644a8b0f624ca9ea195c55 | [
"Apache-2.0"
] | permissive | markymarkmk2/VSMFS | https://github.com/markymarkmk2/VSMFS | 0c855a63761e9dddf0199bf7bfe4f02bc1e96e05 | ac14572beb2ae0debd02843221733db65a622402 | refs/heads/master | 2021-01-12T04:34:50.479000 | 2017-01-03T12:30:59 | 2017-01-03T12:30:59 | 77,679,404 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.dimm.vsm.fsutils;
import de.dimm.vsm.net.RemoteFSElem;
import de.dimm.vsm.vfs.IBufferedEventProcessor;
import java.io.IOException;
/**
*
* @author Administrator
*/
public class VfsProxyFile implements IVirtualFSFile
{
IVirtualFSFile delegate;
RemoteFSElem elem;
IBufferedEventProcessor processor;
public VfsProxyFile( RemoteFSElem elem, IBufferedEventProcessor processor )
{
this.elem = elem;
this.processor = processor;
}
public void setDelegate( IVirtualFSFile delegate )
{
this.delegate = delegate;
}
public IVirtualFSFile getDelegate()
{
return delegate;
}
@Override
public RemoteFSElem getElem()
{
return elem;
}
@Override
public void abort()
{
delegate.abort();
}
@Override
public boolean closeRead()
{
return delegate.closeRead();
}
private void checkDelegate()
{
if (delegate == null)
{
delegate = processor.createDelegate(elem);
}
}
@Override
public void closeWrite() throws IOException
{
checkDelegate();
delegate.closeWrite();
}
@Override
public void create()
{
}
@Override
public boolean delete()
{
checkDelegate();
return delegate.delete();
}
@Override
public boolean exists()
{
return delegate.exists();
}
@Override
public boolean existsBlock( long offset, int size )
{
return delegate.existsBlock(offset, size);
}
@Override
public void force( boolean b )
{
checkDelegate();
delegate.force(b);
}
@Override
public long length()
{
return elem.getDataSize();
}
@Override
public int read( byte[] b, int length, long offset )
{
return delegate.read(b, length, offset);
}
@Override
public byte[] read( int length, long offset )
{
return delegate.read(length, offset);
}
@Override
public byte[] fetchBlock( long offset, int size ) throws IOException
{
return delegate.fetchBlock(offset, size);
}
@Override
public void writeFile( byte[] b, int length, long offset ) throws IOException
{
checkDelegate();
delegate.writeFile(b, length, offset);
}
@Override
public void truncateFile( long size )
{
elem.setDataSize(size);
checkDelegate();
}
}
| UTF-8 | Java | 2,798 | java | VfsProxyFile.java | Java | [
{
"context": "import java.io.IOException;\r\n\r\n/**\r\n *\r\n * @author Administrator\r\n */\r\npublic class VfsProxyFile implements IVirtu",
"end": 287,
"score": 0.6696398854255676,
"start": 274,
"tag": "NAME",
"value": "Administrator"
}
] | null | [] | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package de.dimm.vsm.fsutils;
import de.dimm.vsm.net.RemoteFSElem;
import de.dimm.vsm.vfs.IBufferedEventProcessor;
import java.io.IOException;
/**
*
* @author Administrator
*/
public class VfsProxyFile implements IVirtualFSFile
{
IVirtualFSFile delegate;
RemoteFSElem elem;
IBufferedEventProcessor processor;
public VfsProxyFile( RemoteFSElem elem, IBufferedEventProcessor processor )
{
this.elem = elem;
this.processor = processor;
}
public void setDelegate( IVirtualFSFile delegate )
{
this.delegate = delegate;
}
public IVirtualFSFile getDelegate()
{
return delegate;
}
@Override
public RemoteFSElem getElem()
{
return elem;
}
@Override
public void abort()
{
delegate.abort();
}
@Override
public boolean closeRead()
{
return delegate.closeRead();
}
private void checkDelegate()
{
if (delegate == null)
{
delegate = processor.createDelegate(elem);
}
}
@Override
public void closeWrite() throws IOException
{
checkDelegate();
delegate.closeWrite();
}
@Override
public void create()
{
}
@Override
public boolean delete()
{
checkDelegate();
return delegate.delete();
}
@Override
public boolean exists()
{
return delegate.exists();
}
@Override
public boolean existsBlock( long offset, int size )
{
return delegate.existsBlock(offset, size);
}
@Override
public void force( boolean b )
{
checkDelegate();
delegate.force(b);
}
@Override
public long length()
{
return elem.getDataSize();
}
@Override
public int read( byte[] b, int length, long offset )
{
return delegate.read(b, length, offset);
}
@Override
public byte[] read( int length, long offset )
{
return delegate.read(length, offset);
}
@Override
public byte[] fetchBlock( long offset, int size ) throws IOException
{
return delegate.fetchBlock(offset, size);
}
@Override
public void writeFile( byte[] b, int length, long offset ) throws IOException
{
checkDelegate();
delegate.writeFile(b, length, offset);
}
@Override
public void truncateFile( long size )
{
elem.setDataSize(size);
checkDelegate();
}
}
| 2,798 | 0.555039 | 0.555039 | 139 | 18.129496 | 18.50951 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.345324 | false | false | 10 |
172f349d1b960b7c8e712bc4e8daaceda56771b5 | 39,548,058,861,601 | 1b8affd6df1e12270f8c9fedfacc2d6c45cea2f7 | /app/src/main/java/com/inventure/childcomunication/model/ModelOfData.java | b0225d4f37e1448fc0e2712633bbb95973eeebab | [] | no_license | magdy0000/ChildComunication | https://github.com/magdy0000/ChildComunication | 37680cba6342e69ed7d3a92d9e68beb2c0d7dabd | 3f413cb69e2a113af8ed550192b2a2abd6dc14a9 | refs/heads/master | 2023-07-11T20:37:57.664000 | 2021-08-18T09:36:30 | 2021-08-18T09:36:30 | 299,383,604 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.inventure.childcomunication.model;
import java.util.ArrayList;
import java.util.List;
public class ModelOfData {
String names [] ;
int [] icon ;
int [] voice ;
public ModelOfData(String[] names, int[] icon, int[] voice) {
this.names = names;
this.icon = icon;
this.voice = voice;
}
public String[] getNames() {
return names;
}
public void setNames(String[] names) {
this.names = names;
}
public int[] getIcon() {
return icon;
}
public void setIcon(int[] icon) {
this.icon = icon;
}
public int[] getVoice() {
return voice;
}
public void setVoice(int[] voice) {
this.voice = voice;
}
}
| UTF-8 | Java | 741 | java | ModelOfData.java | Java | [] | null | [] | package com.inventure.childcomunication.model;
import java.util.ArrayList;
import java.util.List;
public class ModelOfData {
String names [] ;
int [] icon ;
int [] voice ;
public ModelOfData(String[] names, int[] icon, int[] voice) {
this.names = names;
this.icon = icon;
this.voice = voice;
}
public String[] getNames() {
return names;
}
public void setNames(String[] names) {
this.names = names;
}
public int[] getIcon() {
return icon;
}
public void setIcon(int[] icon) {
this.icon = icon;
}
public int[] getVoice() {
return voice;
}
public void setVoice(int[] voice) {
this.voice = voice;
}
}
| 741 | 0.562753 | 0.562753 | 41 | 17.073172 | 15.678773 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.414634 | false | false | 10 |
10a8938cc0cab3dd039e8342d6a1bb104f298902 | 34,969,623,772,483 | b3981085ab63644954c6657c767de9a49aa915c4 | /src/inventory/CornerMatrix.java | 407ca81418edf5cc73674df82bc54fd509951fba | [] | no_license | leelizk/PathOfExile | https://github.com/leelizk/PathOfExile | 6d13036d8c8f7096190b3ce15951617775bf4d4a | 65cf3ef0651af1397f7f1b9be1b93789b6cfed1e | refs/heads/master | 2020-12-29T20:04:02.684000 | 2014-01-30T08:52:04 | 2014-01-30T08:52:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package inventory;
import java.awt.Point;
import java.util.ArrayList;
public class CornerMatrix
{
private ArrayList<Integer> rows = new ArrayList<Integer>();
private ArrayList<Integer> columns = new ArrayList<Integer>();
private Point[][] topLeftCorners; public Point getTLCorner(int x, int y) { return topLeftCorners[x][y]; }
private Point[][] bottomRightCorners; public Point getBRCorner(int x, int y) { return bottomRightCorners[x][y]; }
CornerMatrix()
{
presetRowsAndColumns();
topLeftCorners = findTopLeftCorners();
bottomRightCorners = findBottomRightCorners();
}
CornerMatrix(ItemGrid grid)
{
presetRowsAndColumns(grid.getColumnData(), grid.getRowData());
topLeftCorners = findTopLeftCorners();
bottomRightCorners = findBottomRightCorners();
}
/**
*
* Later will reflect whether the image analysis was properly done
*
* @return
*/
public boolean properlyBuilt()
{
return columns.size() == 2 * Inventory.INVENTORY_WIDTH && rows.size() == 2 * Inventory.INVENTORY_HEIGHT;
}
public void presetRowsAndColumns(int[] columnData, int[] rowData)
{
for(int r : rowData)
{
rows.add(r);
}
for(int c : columnData)
{
columns.add(c);
}
}
private void presetRowsAndColumns()
{
//WTF?! -- far more confusing than crop circles or stonehenge
int[] columnNums = { 0, 28, 29, 57, 58, 86, 87, 116, 117, 145, 146, 174, 175, 203, 204, 233, 234, 262, 263, 291, 292, 320, 321, 350 };
int[] rowNums = { 0, 28, 29, 58, 59, 87, 88, 116, 117, 145 };
for(int c : columnNums)
{
columns.add(c);
}
for(int r : rowNums)
{
rows.add(r);
}
}
private Point[][] findTopLeftCorners()
{
Point[][] corners = new Point[Inventory.INVENTORY_WIDTH][Inventory.INVENTORY_HEIGHT];
for(int a=0; a < Inventory.INVENTORY_WIDTH ; a++)
{
for(int b=0; b < Inventory.INVENTORY_HEIGHT ; b++)
{
//System.out.println(new Point(a,b));
corners[a][b] = new Point(columns.get(2*a) + 1, rows.get(2*b) + 1);
}
}
return corners;
}
private Point[][] findBottomRightCorners()
{
Point[][] corners = new Point[Inventory.INVENTORY_WIDTH][Inventory.INVENTORY_HEIGHT];
for(int a = 0; a < Inventory.INVENTORY_WIDTH ; a++)
{
for(int b = 0; b < Inventory.INVENTORY_HEIGHT ; b++)
{
corners[a][b] = new Point(columns.get(2*a + 1) - 1, rows.get(2*b + 1) - 1);
}
}
return corners;
}
}
| UTF-8 | Java | 2,373 | java | CornerMatrix.java | Java | [] | null | [] | package inventory;
import java.awt.Point;
import java.util.ArrayList;
public class CornerMatrix
{
private ArrayList<Integer> rows = new ArrayList<Integer>();
private ArrayList<Integer> columns = new ArrayList<Integer>();
private Point[][] topLeftCorners; public Point getTLCorner(int x, int y) { return topLeftCorners[x][y]; }
private Point[][] bottomRightCorners; public Point getBRCorner(int x, int y) { return bottomRightCorners[x][y]; }
CornerMatrix()
{
presetRowsAndColumns();
topLeftCorners = findTopLeftCorners();
bottomRightCorners = findBottomRightCorners();
}
CornerMatrix(ItemGrid grid)
{
presetRowsAndColumns(grid.getColumnData(), grid.getRowData());
topLeftCorners = findTopLeftCorners();
bottomRightCorners = findBottomRightCorners();
}
/**
*
* Later will reflect whether the image analysis was properly done
*
* @return
*/
public boolean properlyBuilt()
{
return columns.size() == 2 * Inventory.INVENTORY_WIDTH && rows.size() == 2 * Inventory.INVENTORY_HEIGHT;
}
public void presetRowsAndColumns(int[] columnData, int[] rowData)
{
for(int r : rowData)
{
rows.add(r);
}
for(int c : columnData)
{
columns.add(c);
}
}
private void presetRowsAndColumns()
{
//WTF?! -- far more confusing than crop circles or stonehenge
int[] columnNums = { 0, 28, 29, 57, 58, 86, 87, 116, 117, 145, 146, 174, 175, 203, 204, 233, 234, 262, 263, 291, 292, 320, 321, 350 };
int[] rowNums = { 0, 28, 29, 58, 59, 87, 88, 116, 117, 145 };
for(int c : columnNums)
{
columns.add(c);
}
for(int r : rowNums)
{
rows.add(r);
}
}
private Point[][] findTopLeftCorners()
{
Point[][] corners = new Point[Inventory.INVENTORY_WIDTH][Inventory.INVENTORY_HEIGHT];
for(int a=0; a < Inventory.INVENTORY_WIDTH ; a++)
{
for(int b=0; b < Inventory.INVENTORY_HEIGHT ; b++)
{
//System.out.println(new Point(a,b));
corners[a][b] = new Point(columns.get(2*a) + 1, rows.get(2*b) + 1);
}
}
return corners;
}
private Point[][] findBottomRightCorners()
{
Point[][] corners = new Point[Inventory.INVENTORY_WIDTH][Inventory.INVENTORY_HEIGHT];
for(int a = 0; a < Inventory.INVENTORY_WIDTH ; a++)
{
for(int b = 0; b < Inventory.INVENTORY_HEIGHT ; b++)
{
corners[a][b] = new Point(columns.get(2*a + 1) - 1, rows.get(2*b + 1) - 1);
}
}
return corners;
}
}
| 2,373 | 0.655289 | 0.612305 | 89 | 25.662922 | 30.977318 | 136 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.52809 | false | false | 10 |
4de66a98e5fd86025bb087ac190ff63b27549552 | 17,918,603,626,191 | 6ca76c60f8cc9e42ce42a7a4f6996916b8a969ea | /src/main/java/cn/classyex/learn/jpademo/service/WxUserServiceImpl.java | 69e8e7e54b75686d20948a5dd5ebe2eac55bd9e7 | [] | no_license | classyex/jpa_demo | https://github.com/classyex/jpa_demo | c169ba2e01cc708e4bcb6c018565f94c66bc2f89 | 1ac66dfd48a242a9005d35ef601d6eebf210d6af | refs/heads/master | 2022-06-21T23:57:06.072000 | 2020-04-06T11:22:49 | 2020-04-06T11:22:49 | 253,472,573 | 0 | 1 | null | false | 2022-06-17T03:02:36 | 2020-04-06T11:06:36 | 2020-04-06T11:22:53 | 2022-06-17T03:02:35 | 66 | 0 | 0 | 1 | Java | false | false | package cn.classyex.learn.jpademo.service;
import cn.classyex.learn.jpademo.domain.QWxUser;
import cn.classyex.learn.jpademo.domain.WxUser;
import cn.classyex.learn.jpademo.model.WxUserVO;
import cn.classyex.learn.jpademo.repo.WxUserRepo;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author yex
* @date 2020/4/6 17:07
*/
@Service
@AllArgsConstructor
public class WxUserServiceImpl implements WxUserService {
private WxUserRepo wxUserRepo;
private JPAQueryFactory jpaQueryFactory;
@Override
public List<WxUser> list(WxUserVO vo) {
QWxUser qWxUser = QWxUser.wxUser;
PageRequest pageRequest = vo.toPageRequest();
List<WxUser> fetch = jpaQueryFactory.selectFrom(qWxUser).where(vo.buildPredicate())
.offset(pageRequest.getOffset())
.limit(pageRequest.getPageSize())
.orderBy(qWxUser.createTime.asc()).fetch();
return fetch;
}
}
| UTF-8 | Java | 1,095 | java | WxUserServiceImpl.java | Java | [
{
"context": "e.Service;\n\nimport java.util.List;\n\n/**\n * @author yex\n * @date 2020/4/6 17:07\n */\n@Service\n@AllArgsCons",
"end": 462,
"score": 0.9996964931488037,
"start": 459,
"tag": "USERNAME",
"value": "yex"
}
] | null | [] | package cn.classyex.learn.jpademo.service;
import cn.classyex.learn.jpademo.domain.QWxUser;
import cn.classyex.learn.jpademo.domain.WxUser;
import cn.classyex.learn.jpademo.model.WxUserVO;
import cn.classyex.learn.jpademo.repo.WxUserRepo;
import com.querydsl.jpa.impl.JPAQueryFactory;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @author yex
* @date 2020/4/6 17:07
*/
@Service
@AllArgsConstructor
public class WxUserServiceImpl implements WxUserService {
private WxUserRepo wxUserRepo;
private JPAQueryFactory jpaQueryFactory;
@Override
public List<WxUser> list(WxUserVO vo) {
QWxUser qWxUser = QWxUser.wxUser;
PageRequest pageRequest = vo.toPageRequest();
List<WxUser> fetch = jpaQueryFactory.selectFrom(qWxUser).where(vo.buildPredicate())
.offset(pageRequest.getOffset())
.limit(pageRequest.getPageSize())
.orderBy(qWxUser.createTime.asc()).fetch();
return fetch;
}
}
| 1,095 | 0.73242 | 0.723288 | 35 | 30.285715 | 22.769115 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.457143 | false | false | 10 |
1a6719a9f8c3f453351c192f4f3aac3c139d7181 | 39,144,331,972,034 | eec11851679b77a13fba9f079cd46b2aa543e523 | /L3PAY_/src/controlador/EnviosDAO.java | 6534ff4064e81474f5c4f1082da08326b059fbcf | [] | no_license | agarcl16/L3PAY2 | https://github.com/agarcl16/L3PAY2 | 631b7c2610440e1d3b3686bd7a032efd83d21947 | 2f22889f775696354f4ab5a49c0ac14227196cbd | refs/heads/master | 2020-12-01T21:00:43.709000 | 2020-02-05T11:41:57 | 2020-02-05T11:41:57 | 230,768,710 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package controlador;
public class EnviosDAO {
private String sendUser;
private String receiveUser;
private double dinero;
private int cuentaEnvia;
private int cuentaRecibe;
private double dineroEnvia;
private double dineroRecibe;
private double newDineroEnvia;
private double newDineroRecibe;
public EnviosDAO() {
}
public boolean enviarDinero(String userEnvia, String UserRecibe, String cantidad) {
EnviosVO envia = new EnviosVO();
this.sendUser = userEnvia;
this.receiveUser = UserRecibe;
try {
dinero = Double.parseDouble(cantidad);
if(dinero<=0) {
return false;
}
//Ahora sacamos los numero de cuenta de ambos usuarios
cuentaEnvia = envia.getCuenta(this.sendUser);
cuentaRecibe = envia.getCuenta(this.receiveUser);
if(cuentaEnvia == -1 || cuentaRecibe == -1) {
return false;
}
dineroEnvia = envia.getDinero(cuentaEnvia);
dineroRecibe = envia.getDinero(cuentaRecibe);
if(dineroEnvia - dinero < 0) {
return false;
}
newDineroEnvia = dineroEnvia - dinero;
newDineroRecibe = dineroRecibe + dinero;
if(envia.enviarDinero(cuentaEnvia, newDineroEnvia)==false || envia.enviarDinero(cuentaRecibe, newDineroRecibe) == false){
return false;
}
//aniadimos movimientos
if((!envia.aniadirMovimiento("pago a "+this.receiveUser, cuentaEnvia, 0-dinero))||(!envia.aniadirMovimiento("pago de "+this.sendUser, cuentaRecibe, dinero))) {
return false;
}
return true;
}catch(Exception e) {
return false;
}
}
}
| UTF-8 | Java | 1,575 | java | EnviosDAO.java | Java | [] | null | [] | package controlador;
public class EnviosDAO {
private String sendUser;
private String receiveUser;
private double dinero;
private int cuentaEnvia;
private int cuentaRecibe;
private double dineroEnvia;
private double dineroRecibe;
private double newDineroEnvia;
private double newDineroRecibe;
public EnviosDAO() {
}
public boolean enviarDinero(String userEnvia, String UserRecibe, String cantidad) {
EnviosVO envia = new EnviosVO();
this.sendUser = userEnvia;
this.receiveUser = UserRecibe;
try {
dinero = Double.parseDouble(cantidad);
if(dinero<=0) {
return false;
}
//Ahora sacamos los numero de cuenta de ambos usuarios
cuentaEnvia = envia.getCuenta(this.sendUser);
cuentaRecibe = envia.getCuenta(this.receiveUser);
if(cuentaEnvia == -1 || cuentaRecibe == -1) {
return false;
}
dineroEnvia = envia.getDinero(cuentaEnvia);
dineroRecibe = envia.getDinero(cuentaRecibe);
if(dineroEnvia - dinero < 0) {
return false;
}
newDineroEnvia = dineroEnvia - dinero;
newDineroRecibe = dineroRecibe + dinero;
if(envia.enviarDinero(cuentaEnvia, newDineroEnvia)==false || envia.enviarDinero(cuentaRecibe, newDineroRecibe) == false){
return false;
}
//aniadimos movimientos
if((!envia.aniadirMovimiento("pago a "+this.receiveUser, cuentaEnvia, 0-dinero))||(!envia.aniadirMovimiento("pago de "+this.sendUser, cuentaRecibe, dinero))) {
return false;
}
return true;
}catch(Exception e) {
return false;
}
}
}
| 1,575 | 0.687619 | 0.684444 | 55 | 26.636364 | 28.877398 | 162 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.945455 | false | false | 10 |
4d5761eeca4298aa1f1ee128266116459a477bd9 | 34,445,637,774,616 | fccb4acf1585b4f7d578dd6687a2816dbcb38e15 | /src/test/java/org/ehony/dsl/SpringIntegrationTest.java | 101b83a7ff2f481f5ba5c351f9ffd267d3962502 | [
"MIT"
] | permissive | smikhalevski/dsl-backbone | https://github.com/smikhalevski/dsl-backbone | b88c0861bd1cb5e49478f99977b87d583d309a87 | afc0604784646568989256c6f96f9f13a57406e5 | refs/heads/master | 2021-01-01T19:30:13.157000 | 2014-08-28T13:32:06 | 2014-08-28T13:32:06 | 16,995,343 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* ┌──┐
* │ │
* │Eh│ony
* └──┘
*/
package org.ehony.dsl;
import org.example.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static junit.framework.Assert.*;
public class SpringIntegrationTest
{
@Test
public void testTagLookup() throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/test-context.xml");
Car car = context.getBean("my-car", Car.class);
assertNotNull("Could not retrieve car from context.", car);
Engine engine = (Engine) car.getChildren().get(0);
assertEquals("Spring proxy failed to find bean.", engine.resolveContext().getBean("my-car", Car.class), car);
assertNotNull("Failed to build parent-child relation.", engine.getParentTag());
assertEquals(engine.toString(), "engine#M28.01{\n\tcontext = null\n}");
}
}
| UTF-8 | Java | 988 | java | SpringIntegrationTest.java | Java | [] | null | [] | /*
* ┌──┐
* │ │
* │Eh│ony
* └──┘
*/
package org.ehony.dsl;
import org.example.*;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import static junit.framework.Assert.*;
public class SpringIntegrationTest
{
@Test
public void testTagLookup() throws Exception {
ApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/test-context.xml");
Car car = context.getBean("my-car", Car.class);
assertNotNull("Could not retrieve car from context.", car);
Engine engine = (Engine) car.getChildren().get(0);
assertEquals("Spring proxy failed to find bean.", engine.resolveContext().getBean("my-car", Car.class), car);
assertNotNull("Failed to build parent-child relation.", engine.getParentTag());
assertEquals(engine.toString(), "engine#M28.01{\n\tcontext = null\n}");
}
}
| 988 | 0.695021 | 0.689834 | 31 | 30.096775 | 34.099812 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.645161 | false | false | 10 |
b6cc5cf4c00c07385baa16d93e903e094d09fc9f | 34,445,637,776,554 | 8a9a2734a027db90f8675bc19c61662a53ab7f94 | /src/com/collections/list/ListSorting.java | c4e7f13c542cbdba040cd76d3a68429b7fd7bc1b | [] | no_license | pavanvejju/MySamples | https://github.com/pavanvejju/MySamples | b6de25efacca2045c6550491d3d1f11b45948810 | 3ed8dfb976a8e3f1419b2b7f6f84358bc9120c99 | refs/heads/master | 2020-03-23T07:59:27.370000 | 2019-02-18T01:52:50 | 2019-02-18T01:52:50 | 141,301,992 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.collections.list;
import java.util.ArrayList;
import java.util.Collections;
/**
* list sorting with reverse order
* */
public class ListSorting {
public static void main(String args[]) {
ArrayList<String> arraylist = new ArrayList<String>();
arraylist.add("AA");
arraylist.add("ZZ");
arraylist.add("CC");
arraylist.add("FF");
/* Unsorted List: ArrayList content before sorting */
System.out.println("Before Sorting:"+arraylist);
//Collections.sort(arraylist);
/* Sorting in descending order */
Collections.sort(arraylist, Collections.reverseOrder());
System.out.println("ArrayList in descending order:"+arraylist);
}
}
| UTF-8 | Java | 670 | java | ListSorting.java | Java | [] | null | [] | package com.collections.list;
import java.util.ArrayList;
import java.util.Collections;
/**
* list sorting with reverse order
* */
public class ListSorting {
public static void main(String args[]) {
ArrayList<String> arraylist = new ArrayList<String>();
arraylist.add("AA");
arraylist.add("ZZ");
arraylist.add("CC");
arraylist.add("FF");
/* Unsorted List: ArrayList content before sorting */
System.out.println("Before Sorting:"+arraylist);
//Collections.sort(arraylist);
/* Sorting in descending order */
Collections.sort(arraylist, Collections.reverseOrder());
System.out.println("ArrayList in descending order:"+arraylist);
}
}
| 670 | 0.708955 | 0.708955 | 28 | 22.928572 | 20.582462 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.535714 | false | false | 10 |
5f295880da249cbefe241732eac75806550c96dc | 37,005,438,261,677 | 6a45f47a38c061475388c20a6554dbdf98c7f0d1 | /Week_03/src/Permutationsii.java | 7118c1151fda9d6e43e20c8af51deb861e97a6f4 | [] | no_license | xiguababa666/-algorithm015 | https://github.com/xiguababa666/-algorithm015 | b582b4b5dd7b77d6f76fbc5a50a038a384673612 | 3a844fff483617207e018eed0e0896497687cf7e | refs/heads/master | 2023-01-19T07:27:27.093000 | 2020-11-01T13:03:45 | 2020-11-01T13:03:45 | 289,673,901 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.*;
/**
* 47. 全排列 II
*
* https://leetcode-cn.com/problems/permutations-ii/
*
* @author xyx
* @date 2020/9/13 15:28
*/
public class Permutationsii {
public static void main(String[] args) {
System.out.println(new Permutationsii().permuteUnique(
new int[] {1,1,2}));
}
/**
* 版本1 全排列后用set去重,有点丑,可以剪枝,但不知道怎么剪
* */
public List<List<Integer>> permuteUnique1(int[] nums) {
Set<List<Integer>> res = new HashSet<>();
permuteUnique1(nums, res, new LinkedList<>(), new boolean[nums.length]);
return new LinkedList<>(res);
}
public void permuteUnique1(int[] nums, Set<List<Integer>> res, LinkedList<Integer> selected, boolean[] used) {
// 递归终止条件
if (selected.size() == nums.length) {
res.add(new ArrayList<>(selected));
return;
}
for (int i = 0; i < nums.length; i++) {
if (used[i]) {
continue;
}
selected.add(nums[i]);
used[i] = true;
permuteUnique1(nums, res, selected, used);
used[i] = false;
selected.removeLast();
}
}
/**
* 版本2 看题解,剪枝
* */
public List<List<Integer>> permuteUnique(int[] nums) {
Arrays.sort(nums);
List<List<Integer>> res = new LinkedList<>();
permuteUnique(nums, res, new LinkedList<>(), new boolean[nums.length]);
return res;
}
public void permuteUnique(int[] nums, List<List<Integer>> res, LinkedList<Integer> selected, boolean[] used) {
// 递归终止条件
if (selected.size() == nums.length) {
res.add(new ArrayList<>(selected));
return;
}
for (int i = 0; i < nums.length; i++) {
if (used[i]) {
continue;
}
if (i > 0 && nums[i] == nums[i - 1] && used[i - 1]) {
// 剪枝
continue;
}
selected.add(nums[i]);
used[i] = true;
permuteUnique(nums, res, selected, used);
used[i] = false;
selected.removeLast();
}
}
}
| UTF-8 | Java | 2,283 | java | Permutationsii.java | Java | [
{
"context": "ode-cn.com/problems/permutations-ii/\n *\n * @author xyx\n * @date 2020/9/13 15:28\n */\npublic class Permuta",
"end": 112,
"score": 0.9996331930160522,
"start": 109,
"tag": "USERNAME",
"value": "xyx"
}
] | null | [] | import java.util.*;
/**
* 47. 全排列 II
*
* https://leetcode-cn.com/problems/permutations-ii/
*
* @author xyx
* @date 2020/9/13 15:28
*/
public class Permutationsii {
public static void main(String[] args) {
System.out.println(new Permutationsii().permuteUnique(
new int[] {1,1,2}));
}
/**
* 版本1 全排列后用set去重,有点丑,可以剪枝,但不知道怎么剪
* */
public List<List<Integer>> permuteUnique1(int[] nums) {
Set<List<Integer>> res = new HashSet<>();
permuteUnique1(nums, res, new LinkedList<>(), new boolean[nums.length]);
return new LinkedList<>(res);
}
public void permuteUnique1(int[] nums, Set<List<Integer>> res, LinkedList<Integer> selected, boolean[] used) {
// 递归终止条件
if (selected.size() == nums.length) {
res.add(new ArrayList<>(selected));
return;
}
for (int i = 0; i < nums.length; i++) {
if (used[i]) {
continue;
}
selected.add(nums[i]);
used[i] = true;
permuteUnique1(nums, res, selected, used);
used[i] = false;
selected.removeLast();
}
}
/**
* 版本2 看题解,剪枝
* */
public List<List<Integer>> permuteUnique(int[] nums) {
Arrays.sort(nums);
List<List<Integer>> res = new LinkedList<>();
permuteUnique(nums, res, new LinkedList<>(), new boolean[nums.length]);
return res;
}
public void permuteUnique(int[] nums, List<List<Integer>> res, LinkedList<Integer> selected, boolean[] used) {
// 递归终止条件
if (selected.size() == nums.length) {
res.add(new ArrayList<>(selected));
return;
}
for (int i = 0; i < nums.length; i++) {
if (used[i]) {
continue;
}
if (i > 0 && nums[i] == nums[i - 1] && used[i - 1]) {
// 剪枝
continue;
}
selected.add(nums[i]);
used[i] = true;
permuteUnique(nums, res, selected, used);
used[i] = false;
selected.removeLast();
}
}
}
| 2,283 | 0.498395 | 0.486016 | 84 | 24.964285 | 24.701284 | 114 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.595238 | false | false | 10 |
41847310736a6f529db8f4adad5fcf6fa5f1cba7 | 39,651,138,103,913 | b28dc86becbcbdfdcdf40228893c491f743a2b37 | /designPatterns/src/designPatterns/chainofresponsibilitie/ClaculadorDesconto.java | 1c03099821b98a4cc66979aa56a1c71171addca6 | [] | no_license | diogofvieira/ModelsDP | https://github.com/diogofvieira/ModelsDP | eda1bfff7951450043e3d0fbeee364623fd35eca | d2f83bcfbf29a02a2d35d67123c3427895417446 | refs/heads/master | 2020-03-27T08:13:05.690000 | 2018-09-01T03:14:13 | 2018-09-01T03:14:13 | 146,232,818 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package designPatterns.chainofresponsibilitie;
import designPatterns.strategy.Orcamento;
public class ClaculadorDesconto {
public double calcula(Orcamento orcamento){
Desconto d1 = new DescontoCincoItens();
Desconto d2 = new DescontoQuinhentos();
Desconto d3 = new SemDesconto();
d1.setProximo(d2);
d2.setProximo(d3);
return d1.desconto(orcamento);
}
}
| UTF-8 | Java | 401 | java | ClaculadorDesconto.java | Java | [] | null | [] | package designPatterns.chainofresponsibilitie;
import designPatterns.strategy.Orcamento;
public class ClaculadorDesconto {
public double calcula(Orcamento orcamento){
Desconto d1 = new DescontoCincoItens();
Desconto d2 = new DescontoQuinhentos();
Desconto d3 = new SemDesconto();
d1.setProximo(d2);
d2.setProximo(d3);
return d1.desconto(orcamento);
}
}
| 401 | 0.710723 | 0.690773 | 19 | 19.105263 | 18.36729 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.473684 | false | false | 10 |
59888c8caf846b0ab26899a9ad1b7768e34045b9 | 34,471,407,573,715 | b1c48279a1bfac0925e8c8a4591fc8960cbd9706 | /src/main/java/br/com/vilapagode/web/jogo/InstrumentoController.java | 98202c63398ae10c5c96083da583dd3f95930bb5 | [] | no_license | luisribeiro/VilaPagode | https://github.com/luisribeiro/VilaPagode | 50f537b96e9490eee359f75dad7a75bd1b795ca4 | b833046c735b95a72687e2a05d7c90c7004e8f1d | refs/heads/master | 2019-07-29T08:52:46.504000 | 2014-12-25T17:36:18 | 2014-12-25T17:36:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.vilapagode.web.jogo;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import org.json.JSONArray;
import org.json.JSONObject;
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 br.com.vilapagode.service.InstrumentoService;
@Controller
public class InstrumentoController {
@Autowired
private InstrumentoService service;
@RequestMapping("/jogo/instrumentos")
public ModelAndView informacoes() throws ServletException, IOException {
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("result", (new JSONArray(service.getList())).toString());
return new ModelAndView("servico.jsp", "model", myModel);
}
}
| UTF-8 | Java | 926 | java | InstrumentoController.java | Java | [] | null | [] | package br.com.vilapagode.web.jogo;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import org.json.JSONArray;
import org.json.JSONObject;
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 br.com.vilapagode.service.InstrumentoService;
@Controller
public class InstrumentoController {
@Autowired
private InstrumentoService service;
@RequestMapping("/jogo/instrumentos")
public ModelAndView informacoes() throws ServletException, IOException {
Map<String, Object> myModel = new HashMap<String, Object>();
myModel.put("result", (new JSONArray(service.getList())).toString());
return new ModelAndView("servico.jsp", "model", myModel);
}
}
| 926 | 0.785097 | 0.785097 | 38 | 23.368422 | 24.394156 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.184211 | false | false | 10 |
6ac58010ce2a0fc29f22f1edfcce8025e21b7f23 | 34,557,306,924,525 | ef159551ac7a1433510713344740b3d73efd95ae | /MyApplication2/app/src/main/java/com/example/suvam/myapplication/PhotoHandler.java | 0205602579f4c854601cd3ad4614480c59c4a13c | [] | no_license | kartikeyagup/SURA-Work | https://github.com/kartikeyagup/SURA-Work | 45966dc159a8bb14c3ba07880d941304982a8183 | 87bf1e0aacc7f1853b2f803e2dbf46518c24d949 | refs/heads/master | 2021-01-09T07:10:57.904000 | 2015-11-24T18:09:56 | 2015-11-24T18:09:56 | 28,535,540 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.suvam.myapplication;
import java.io.File;
import java.io.FileOutputStream;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.os.Environment;
import android.widget.Toast;
public class PhotoHandler implements PictureCallback {
private final Context context;
private int imid;
private String baseName;
private int lagFlag[];
public PhotoHandler(Context context, int id, String bn, int [] lf) {
this.context = context;
this.imid = id;
this.baseName = bn;
this.lagFlag = lf;
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFileDir = new File (Environment.getExternalStorageDirectory().getAbsolutePath() + "/SensorFusion3");
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs())
{
Toast.makeText(context, "Can't create directory to save image.",
Toast.LENGTH_LONG).show();
return;
}
String photoFile = "SensorFusion3" + imid + ".jpg";
String filename = pictureFileDir +"/" + photoFile;
File pictureFile = new File(filename);
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
lagFlag[0] = 0;
Toast.makeText(context, "Image ID " + imid + " saved",
Toast.LENGTH_SHORT).show();
} catch (Exception error) {
Toast.makeText(context, "Unable to save the clicked image.",
Toast.LENGTH_SHORT).show();
}
camera.startPreview();
}
}
| UTF-8 | Java | 1,769 | java | PhotoHandler.java | Java | [] | null | [] | package com.example.suvam.myapplication;
import java.io.File;
import java.io.FileOutputStream;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.os.Environment;
import android.widget.Toast;
public class PhotoHandler implements PictureCallback {
private final Context context;
private int imid;
private String baseName;
private int lagFlag[];
public PhotoHandler(Context context, int id, String bn, int [] lf) {
this.context = context;
this.imid = id;
this.baseName = bn;
this.lagFlag = lf;
}
@Override
public void onPictureTaken(byte[] data, Camera camera) {
File pictureFileDir = new File (Environment.getExternalStorageDirectory().getAbsolutePath() + "/SensorFusion3");
if (!pictureFileDir.exists() && !pictureFileDir.mkdirs())
{
Toast.makeText(context, "Can't create directory to save image.",
Toast.LENGTH_LONG).show();
return;
}
String photoFile = "SensorFusion3" + imid + ".jpg";
String filename = pictureFileDir +"/" + photoFile;
File pictureFile = new File(filename);
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
fos.write(data);
fos.close();
lagFlag[0] = 0;
Toast.makeText(context, "Image ID " + imid + " saved",
Toast.LENGTH_SHORT).show();
} catch (Exception error) {
Toast.makeText(context, "Unable to save the clicked image.",
Toast.LENGTH_SHORT).show();
}
camera.startPreview();
}
}
| 1,769 | 0.598643 | 0.596382 | 56 | 29.589285 | 25.615828 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.696429 | false | false | 10 |
c872535035ac27261513e998575ddc489bfe129a | 2,980,707,361,922 | f1ac8d2c5ee86b5c52d67ef902eec16ff2db9ca4 | /allight/src/main/java/com/all/light/dto/OrderDTO.java | 66be7014ca7b7c7ddcd465759c549fd53a4e32d5 | [] | no_license | dev-jiyoung-oh/allight | https://github.com/dev-jiyoung-oh/allight | adbbac79761c19e7d5fd9d227bfba87e66e0a18e | affa8edf719062f573d3ed51411adfd183a2a664 | refs/heads/master | 2023-07-18T04:26:45.169000 | 2021-08-28T14:12:47 | 2021-08-28T14:12:47 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.all.light.dto;
import java.sql.Date;
public class OrderDTO {
private int ono;//주문번호seq
private String mid;
private int mno;
private Date odate;//주문날짜
private String oaddno;//우편번호
private String oaddress1;//주소
private String oaddress2;//상세주소
private String otel;
private String oreceiver;
private String orequirethings;//요구사항
private String opayment;//결제수단
private String opaydate;//결제일
private int osum;//총합
private Date searchdate;//찾는 날짜
private String ordernum;
private String sodate;//주문날짜
private String type;
private int sum;
public int getOno() {
return ono;
}
public void setOno(int ono) {
this.ono = ono;
}
public String getMid() {
return mid;
}
public void setMid(String mid) {
this.mid = mid;
}
public Date getOdate() {
return odate;
}
public void setOdate(Date odate) {
this.odate = odate;
}
public String getOaddno() {
return oaddno;
}
public void setOaddno(String oaddno) {
this.oaddno = oaddno;
}
public String getOaddress1() {
return oaddress1;
}
public void setOaddress1(String oaddress1) {
this.oaddress1 = oaddress1;
}
public String getOaddress2() {
return oaddress2;
}
public void setOaddress2(String oaddress2) {
this.oaddress2 = oaddress2;
}
public String getOtel() {
return otel;
}
public void setOtel(String otel) {
this.otel = otel;
}
public String getOreceiver() {
return oreceiver;
}
public void setOreceiver(String oreceiver) {
this.oreceiver = oreceiver;
}
public String getOrequirethings() {
return orequirethings;
}
public void setOrequirethings(String orequirethings) {
this.orequirethings = orequirethings;
}
public Date getSearchdate() {
return searchdate;
}
public void setSearchdate(Date searchdate) {
this.searchdate = searchdate;
}
public int getMno() {
return mno;
}
public void setMno(int mno) {
this.mno = mno;
}
public String getOrdernum() {
return ordernum;
}
public void setOrdernum(String ordernum) {
this.ordernum = ordernum;
}
public String getSodate() {
return sodate;
}
public void setSodate(String string) {
this.sodate = string;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getOsum() {
return osum;
}
public void setOsum(int osum) {
this.osum = osum;
}
public String getOpayment() {
return opayment;
}
public void setOpayment(String opayment) {
this.opayment = opayment;
}
public String getOpaydate() {
return opaydate;
}
public void setOpaydate(String opaydate) {
this.opaydate = opaydate;
}
@Override
public String toString() {
return "OrderDTO [ono=" + ono + ", mid=" + mid + ", mno=" + mno + ", odate=" + odate + ", oaddno=" + oaddno
+ ", oaddress1=" + oaddress1 + ", oaddress2=" + oaddress2 + ", otel=" + otel + ", oreceiver="
+ oreceiver + ", orequirethings=" + orequirethings + ", opayment=" + opayment + ", opaydate=" + opaydate
+ ", osum=" + osum + ", searchdate=" + searchdate + ", ordernum=" + ordernum + ", sodate=" + sodate
+ ", type=" + type + "]";
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
| UTF-8 | Java | 3,254 | java | OrderDTO.java | Java | [] | null | [] | package com.all.light.dto;
import java.sql.Date;
public class OrderDTO {
private int ono;//주문번호seq
private String mid;
private int mno;
private Date odate;//주문날짜
private String oaddno;//우편번호
private String oaddress1;//주소
private String oaddress2;//상세주소
private String otel;
private String oreceiver;
private String orequirethings;//요구사항
private String opayment;//결제수단
private String opaydate;//결제일
private int osum;//총합
private Date searchdate;//찾는 날짜
private String ordernum;
private String sodate;//주문날짜
private String type;
private int sum;
public int getOno() {
return ono;
}
public void setOno(int ono) {
this.ono = ono;
}
public String getMid() {
return mid;
}
public void setMid(String mid) {
this.mid = mid;
}
public Date getOdate() {
return odate;
}
public void setOdate(Date odate) {
this.odate = odate;
}
public String getOaddno() {
return oaddno;
}
public void setOaddno(String oaddno) {
this.oaddno = oaddno;
}
public String getOaddress1() {
return oaddress1;
}
public void setOaddress1(String oaddress1) {
this.oaddress1 = oaddress1;
}
public String getOaddress2() {
return oaddress2;
}
public void setOaddress2(String oaddress2) {
this.oaddress2 = oaddress2;
}
public String getOtel() {
return otel;
}
public void setOtel(String otel) {
this.otel = otel;
}
public String getOreceiver() {
return oreceiver;
}
public void setOreceiver(String oreceiver) {
this.oreceiver = oreceiver;
}
public String getOrequirethings() {
return orequirethings;
}
public void setOrequirethings(String orequirethings) {
this.orequirethings = orequirethings;
}
public Date getSearchdate() {
return searchdate;
}
public void setSearchdate(Date searchdate) {
this.searchdate = searchdate;
}
public int getMno() {
return mno;
}
public void setMno(int mno) {
this.mno = mno;
}
public String getOrdernum() {
return ordernum;
}
public void setOrdernum(String ordernum) {
this.ordernum = ordernum;
}
public String getSodate() {
return sodate;
}
public void setSodate(String string) {
this.sodate = string;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public int getOsum() {
return osum;
}
public void setOsum(int osum) {
this.osum = osum;
}
public String getOpayment() {
return opayment;
}
public void setOpayment(String opayment) {
this.opayment = opayment;
}
public String getOpaydate() {
return opaydate;
}
public void setOpaydate(String opaydate) {
this.opaydate = opaydate;
}
@Override
public String toString() {
return "OrderDTO [ono=" + ono + ", mid=" + mid + ", mno=" + mno + ", odate=" + odate + ", oaddno=" + oaddno
+ ", oaddress1=" + oaddress1 + ", oaddress2=" + oaddress2 + ", otel=" + otel + ", oreceiver="
+ oreceiver + ", orequirethings=" + orequirethings + ", opayment=" + opayment + ", opaydate=" + opaydate
+ ", osum=" + osum + ", searchdate=" + searchdate + ", ordernum=" + ordernum + ", sodate=" + sodate
+ ", type=" + type + "]";
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
| 3,254 | 0.679156 | 0.673489 | 146 | 20.753426 | 19.437487 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.80137 | false | false | 10 |
68049c55369d81c33637a43db6566a3da2d74006 | 23,931,557,790,003 | 0b31f761cfc1fada7edfc116c515ed42fc817a4f | /src/main/java/thymeleafexamples/stsm/business/services/UserConversionService.java | 0a4a3313a462c73fb363a460d0f65f297f04d20f | [
"Apache-2.0"
] | permissive | flying-Pikachu/thymeleafexamples-stsm | https://github.com/flying-Pikachu/thymeleafexamples-stsm | dc8b914f8b3d2127ae6c719ff9b9a6e5793a5b7b | 1afa410db89787a6e6587986ff8257f82372c5fa | refs/heads/master | 2020-03-28T10:30:18.105000 | 2018-09-11T07:07:53 | 2018-09-11T07:07:53 | 148,115,181 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package thymeleafexamples.stsm.business.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import thymeleafexamples.stsm.business.entities.User;
/**
* @ Author ?xzp.
* @ Date ?Created in 2:12 PM 11/09/2018
* @ Description?${description}
*/
@Component
public final class UserConversionService implements Converter<String, User> {
private UserService userService = new UserService();
@Override
public User convert(String s) {
return userService.find(s);
}
}
| UTF-8 | Java | 630 | java | UserConversionService.java | Java | [
{
"context": "tsm.business.entities.User;\n\n/**\n * @ Author ?xzp.\n * @ Date ?Created in 2:12 PM 11/09/2018\n ",
"end": 303,
"score": 0.7643311023712158,
"start": 300,
"tag": "USERNAME",
"value": "xzp"
}
] | null | [] | package thymeleafexamples.stsm.business.services;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;
import thymeleafexamples.stsm.business.entities.User;
/**
* @ Author ?xzp.
* @ Date ?Created in 2:12 PM 11/09/2018
* @ Description?${description}
*/
@Component
public final class UserConversionService implements Converter<String, User> {
private UserService userService = new UserService();
@Override
public User convert(String s) {
return userService.find(s);
}
}
| 630 | 0.747619 | 0.730159 | 22 | 27.636364 | 24.772686 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 10 |
b4d4db3a686f203f1abe3440772576d5cb71e339 | 4,114,578,696,850 | 113d7347fa3e0b9981f2bbf414b974880e1dd73b | /app/src/main/java/com/example/android/brutaljuices/Usuario.java | 0a1132dd0c2fbb6c20b06d6f45ecc6ab0faf6516 | [] | no_license | danielnietoperez/Proyecto | https://github.com/danielnietoperez/Proyecto | b9dfd2d1ab07169ea6bbe143f06540b7422585c3 | 0aee5d3d16024baf49d5de5bc183c3347e404e5b | refs/heads/master | 2020-03-02T13:40:14.785000 | 2017-05-31T00:10:15 | 2017-05-31T00:10:15 | 91,926,492 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.android.brutaljuices;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
/**
* Created by Android on 18/05/2017.
*/
public class Usuario {
private String identificacion;
private String usuario;
private String contraseña;
private String nombre;
private String primerapellido;
private String segundoapellido;
private String sexo;
private String fecha;
private String correo;
private String celular;
public Usuario(String identificacion, String usuario, String contraseña, String nombre, String primerapellido, String segundoapellido, String sexo, String fecha, String correo, String celular) {
this.identificacion = identificacion;
this.usuario = usuario;
this.contraseña = contraseña;
this.nombre = nombre;
this.primerapellido = primerapellido;
this.segundoapellido = segundoapellido;
this.sexo = sexo;
this.fecha = fecha;
this.correo = correo;
this.celular = celular;
}
public String getIdentificacion() {
return identificacion;
}
public void setIdentificacion(String identificacion) {
this.identificacion = identificacion;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getContraseña() {
return contraseña;
}
public void setContraseña(String contraseña) {
this.contraseña = contraseña;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getPrimerapellido() {
return primerapellido;
}
public void setPrimerapellido(String primerapellido) {
this.primerapellido = primerapellido;
}
public String getSegundoapellido() {
return segundoapellido;
}
public void setSegundoapellido(String segundoapellido) {
this.segundoapellido = segundoapellido;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getCelular() {
return celular;
}
public void setCelular(String celular) {
this.celular = celular;
}
public void guardar(Context contexto){
SQLiteDatabase db;
String sql;
DBSQLiteOpenHelper aux = new DBSQLiteOpenHelper(contexto, "DBJugos",null,Datos.version);
db = aux.getWritableDatabase();
sql = "INSERT INTO Usuarios values ('"
+this.getIdentificacion()+"','"
+this.getUsuario()+"','"
+this.getContraseña()+"','"
+this.getNombre()+"','"
+this.getPrimerapellido()+"','"
+this.getSegundoapellido()+"','"
+this.getSexo()+"','"
+this.getFecha()+"','"
+this.getCorreo()+"','"
+this.getCelular()+"')";
db.execSQL(sql);
db.close();
}
}
| UTF-8 | Java | 3,377 | java | Usuario.java | Java | [] | null | [] | package com.example.android.brutaljuices;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
/**
* Created by Android on 18/05/2017.
*/
public class Usuario {
private String identificacion;
private String usuario;
private String contraseña;
private String nombre;
private String primerapellido;
private String segundoapellido;
private String sexo;
private String fecha;
private String correo;
private String celular;
public Usuario(String identificacion, String usuario, String contraseña, String nombre, String primerapellido, String segundoapellido, String sexo, String fecha, String correo, String celular) {
this.identificacion = identificacion;
this.usuario = usuario;
this.contraseña = contraseña;
this.nombre = nombre;
this.primerapellido = primerapellido;
this.segundoapellido = segundoapellido;
this.sexo = sexo;
this.fecha = fecha;
this.correo = correo;
this.celular = celular;
}
public String getIdentificacion() {
return identificacion;
}
public void setIdentificacion(String identificacion) {
this.identificacion = identificacion;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getContraseña() {
return contraseña;
}
public void setContraseña(String contraseña) {
this.contraseña = contraseña;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getPrimerapellido() {
return primerapellido;
}
public void setPrimerapellido(String primerapellido) {
this.primerapellido = primerapellido;
}
public String getSegundoapellido() {
return segundoapellido;
}
public void setSegundoapellido(String segundoapellido) {
this.segundoapellido = segundoapellido;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
public String getCorreo() {
return correo;
}
public void setCorreo(String correo) {
this.correo = correo;
}
public String getCelular() {
return celular;
}
public void setCelular(String celular) {
this.celular = celular;
}
public void guardar(Context contexto){
SQLiteDatabase db;
String sql;
DBSQLiteOpenHelper aux = new DBSQLiteOpenHelper(contexto, "DBJugos",null,Datos.version);
db = aux.getWritableDatabase();
sql = "INSERT INTO Usuarios values ('"
+this.getIdentificacion()+"','"
+this.getUsuario()+"','"
+this.getContraseña()+"','"
+this.getNombre()+"','"
+this.getPrimerapellido()+"','"
+this.getSegundoapellido()+"','"
+this.getSexo()+"','"
+this.getFecha()+"','"
+this.getCorreo()+"','"
+this.getCelular()+"')";
db.execSQL(sql);
db.close();
}
}
| 3,377 | 0.614676 | 0.612299 | 142 | 22.704226 | 23.623154 | 198 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 10 |
44f9c22b5fffac9f4ddd29bb81255ca823232c64 | 4,114,578,694,712 | 8c39e26d7477a0e98944ff019b9dbb142063fc5e | /college/src/practicals/Account.java | 2decacdd1c481199ba28e3019bb21bd822107038 | [] | no_license | nijatullahmansoor/JavaProject | https://github.com/nijatullahmansoor/JavaProject | 3710cb7a8adbb1c4c05d3b8628abf248767b0619 | dac52b69b555de387832f85cf9d6668577b16cc5 | refs/heads/master | 2020-08-03T03:04:03.962000 | 2019-09-29T10:52:10 | 2019-09-29T10:52:10 | 211,606,688 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package practicals;
import java.util.*;
public class Account {
Scanner sc=new Scanner(System.in);
String cust_name;
int acc_no;
double bal;
String acc_type;
Account(String custname,int acno,double bal,String accType){
this.cust_name=custname;
this.acc_no=acno;
this.bal=bal;
this.acc_type=accType;
}
public void deposit() {
System.out.println("Enter How much you want to deposite:");
double depo=sc.nextDouble();
this.bal=depo+bal;
System.out.println("your total amount now is:"+this.bal);
}
public void withdrawal() {
System.out.println("Enter how much you want to withdraw:");
double width=sc.nextDouble();
if(this.bal<width) {
System.out.println("Sorry you don't have suficient mony:");
}
else {
this.bal=bal-width;
System.out.println("you widthraw "+width+"your amont is now "+this.bal);
}
}
public void display() {
System.out.println("The coustomer name is:"+this.cust_name);
System.out.println("Your balance is "+this.bal);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Account obj=new Account("Nijatullah Mansoor",100,1000,"Sawing Account");
obj.display();
obj.deposit();
obj.withdrawal();
}
}
| UTF-8 | Java | 1,269 | java | Account.java | Java | [
{
"context": "generated method stub\r\n\t\tAccount obj=new Account(\"Nijatullah Mansoor\",100,1000,\"Sawing Account\");\r\n\t\tobj.display();\r\n\t",
"end": 1166,
"score": 0.9998791217803955,
"start": 1148,
"tag": "NAME",
"value": "Nijatullah Mansoor"
}
] | null | [] | package practicals;
import java.util.*;
public class Account {
Scanner sc=new Scanner(System.in);
String cust_name;
int acc_no;
double bal;
String acc_type;
Account(String custname,int acno,double bal,String accType){
this.cust_name=custname;
this.acc_no=acno;
this.bal=bal;
this.acc_type=accType;
}
public void deposit() {
System.out.println("Enter How much you want to deposite:");
double depo=sc.nextDouble();
this.bal=depo+bal;
System.out.println("your total amount now is:"+this.bal);
}
public void withdrawal() {
System.out.println("Enter how much you want to withdraw:");
double width=sc.nextDouble();
if(this.bal<width) {
System.out.println("Sorry you don't have suficient mony:");
}
else {
this.bal=bal-width;
System.out.println("you widthraw "+width+"your amont is now "+this.bal);
}
}
public void display() {
System.out.println("The coustomer name is:"+this.cust_name);
System.out.println("Your balance is "+this.bal);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Account obj=new Account("<NAME>",100,1000,"Sawing Account");
obj.display();
obj.deposit();
obj.withdrawal();
}
}
| 1,257 | 0.659574 | 0.654058 | 52 | 22.403847 | 21.519455 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.057692 | false | false | 10 |
4b7d431e59ddaeb0331f906a4ca01652cd91c1b6 | 23,098,334,157,691 | 8204ff6fbe8e2c34559ed807488534a5e9b1fee2 | /src/com/juuda/droidmock/network/HttpUtils.java | 94eee3945aa84b2b7a8ac716d8b5724e19faf571 | [] | no_license | X2ools/droidMock | https://github.com/X2ools/droidMock | 82e74d0859d88a062c19349f1bd3aaba6b37526d | e0fba88d10d55a4b7358fefedd35dc04d31f4267 | refs/heads/master | 2021-01-12T20:57:08.658000 | 2014-06-21T06:00:42 | 2014-06-21T06:00:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.juuda.droidmock.network;
import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import android.util.Log;
import com.juuda.droidmock.mock.MockUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import java.io.DataInputStream;
import java.io.IOException;
public class HttpUtils {
private static final String TAG = "HttpUtils";
public static void requestUrl(final Context context, final String url) {
new AsyncTask<Void,Void,Void>() {
@Override
protected Void doInBackground(Void... params) {
requestUrlInner(context, url);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static void requestUrlInner(final Context context, final String url) {
AndroidHttpClient httpClient = AndroidHttpClient.newInstance("jdsong", context);
HttpUriRequest request = new HttpGet(url);
try {
httpClient.execute(request,
new ResponseHandler<Void>(){
@Override
public Void handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
StatusLine status = response.getStatusLine();
MockUtils.Toast(context, TAG, "statusCode " + status.getStatusCode());
HttpEntity entity = response.getEntity();
byte[] body = null;
if (entity != null) {
try {
if (entity.getContentLength() > 0) {
body = new byte[(int) entity.getContentLength()];
DataInputStream dis = new DataInputStream(entity.getContent());
try {
dis.readFully(body);
Log.e(TAG, "nihao" + new String(body));
} finally {
try {
dis.close();
} catch (IOException e) {
Log.e(TAG, "Unexpected IOException.", e);
}
}
}
} finally {
if (entity != null) {
entity.consumeContent();
}
}
}
return null;
}
});
}
catch (IOException e) {
MockUtils.Toast(context, TAG, "error" + Log.getStackTraceString(e));
}
finally {
httpClient.close();
}
}
}
| UTF-8 | Java | 3,392 | java | HttpUtils.java | Java | [] | null | [] | package com.juuda.droidmock.network;
import android.content.Context;
import android.net.http.AndroidHttpClient;
import android.os.AsyncTask;
import android.util.Log;
import com.juuda.droidmock.mock.MockUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import java.io.DataInputStream;
import java.io.IOException;
public class HttpUtils {
private static final String TAG = "HttpUtils";
public static void requestUrl(final Context context, final String url) {
new AsyncTask<Void,Void,Void>() {
@Override
protected Void doInBackground(Void... params) {
requestUrlInner(context, url);
return null;
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
public static void requestUrlInner(final Context context, final String url) {
AndroidHttpClient httpClient = AndroidHttpClient.newInstance("jdsong", context);
HttpUriRequest request = new HttpGet(url);
try {
httpClient.execute(request,
new ResponseHandler<Void>(){
@Override
public Void handleResponse(HttpResponse response)
throws ClientProtocolException, IOException {
StatusLine status = response.getStatusLine();
MockUtils.Toast(context, TAG, "statusCode " + status.getStatusCode());
HttpEntity entity = response.getEntity();
byte[] body = null;
if (entity != null) {
try {
if (entity.getContentLength() > 0) {
body = new byte[(int) entity.getContentLength()];
DataInputStream dis = new DataInputStream(entity.getContent());
try {
dis.readFully(body);
Log.e(TAG, "nihao" + new String(body));
} finally {
try {
dis.close();
} catch (IOException e) {
Log.e(TAG, "Unexpected IOException.", e);
}
}
}
} finally {
if (entity != null) {
entity.consumeContent();
}
}
}
return null;
}
});
}
catch (IOException e) {
MockUtils.Toast(context, TAG, "error" + Log.getStackTraceString(e));
}
finally {
httpClient.close();
}
}
}
| 3,392 | 0.462264 | 0.461969 | 81 | 40.876545 | 25.860682 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62963 | false | false | 10 |
4660a52a32908d0fe90221062471c690e30a5a6b | 893,353,261,300 | 3b7996e7dcf67506cd62af48008ebbf164282443 | /GameAi/src/agent/cosi/OpKi.java | 4055fc2ca3a0ada025bad8853d1d549dea3825e1 | [] | no_license | matteoc99/AI4j | https://github.com/matteoc99/AI4j | 517444a1d3fad3a51c6081c83e28804673829c11 | 414674ecf044730c3ffe26230f9ba7af3d3219a4 | refs/heads/master | 2020-12-30T14:19:53.425000 | 2018-07-10T16:50:26 | 2018-07-10T16:50:26 | 91,308,575 | 2 | 2 | null | false | 2018-04-11T15:12:19 | 2017-05-15T07:37:22 | 2017-08-08T19:59:20 | 2018-04-11T15:12:20 | 346 | 0 | 1 | 0 | Java | false | null | package agent.cosi;
import agent.Agent;
import network.Network;
/**
* @author Matteo Cosi
* @since 25.05.2017
*/
public class OpKi extends Agent {
public OpKi(Network net) {
super(net);
}
public double[] processData(double[] in) {
if (in[0] > in[1])
return new double[]{-1};
else
return new double[]{1};
}
}
| UTF-8 | Java | 379 | java | OpKi.java | Java | [
{
"context": "ent.Agent;\nimport network.Network;\n\n/**\n * @author Matteo Cosi\n * @since 25.05.2017\n */\npublic class OpKi extend",
"end": 92,
"score": 0.9998700022697449,
"start": 81,
"tag": "NAME",
"value": "Matteo Cosi"
}
] | null | [] | package agent.cosi;
import agent.Agent;
import network.Network;
/**
* @author <NAME>
* @since 25.05.2017
*/
public class OpKi extends Agent {
public OpKi(Network net) {
super(net);
}
public double[] processData(double[] in) {
if (in[0] > in[1])
return new double[]{-1};
else
return new double[]{1};
}
}
| 374 | 0.556728 | 0.525066 | 22 | 16.227272 | 13.846338 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 10 |
d8333201b336d7943ebc743812e60be3544b45e1 | 11,407,433,199,811 | 3dd2b34c0331eca3791a6ad5592f68f8788f866f | /token-mj/src/main/java/cc/stbl/token/innerdisc/modules/basic/entity/VrUserLRValue.java | 8c9b2ae09652e68bc9b1ca57a4bc9cffecd89744 | [] | no_license | favorbob/qklproject | https://github.com/favorbob/qklproject | 1da6072fc76b4e30503584d6926baf32c042d539 | 71c15f3a12206d0fb946158b1a156403ce955859 | refs/heads/master | 2020-04-10T17:46:39.516000 | 2018-12-11T12:19:11 | 2018-12-11T12:19:11 | 161,183,704 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cc.stbl.token.innerdisc.modules.basic.entity;
import java.util.Date;
/**
* create by framework, create date 2018/10/10 16:10:20
*/
public class VrUserLRValue {
/**
* 字段:vr_user_lrvalue.user_id;备注:用户id
*/
private String userId;
/**
* 字段:vr_user_lrvalue.pid;备注:上级id
*/
private String pid;
/**
* 字段:vr_user_lrvalue.lft;备注:左值
*/
private Integer lft;
/**
* 字段:vr_user_lrvalue.rgt;备注:右值
*/
private Integer rgt;
/**
* 字段:vr_user_lrvalue.user_level;备注:用户层级,顶级用户为1
*/
private Integer userLevel;
/**
* 字段:vr_user_lrvalue.area;备注:所在区域,目前为 A或B
*/
private String area;
/**
* 字段:vr_user_lrvalue.tree_id;备注:用户所在树标识
*/
private String treeId;
private Integer status;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
/**
* 字段:vr_user_lrvalue.create_date;备注:
*/
private Date createDate;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Integer getLft() {
return lft;
}
public void setLft(Integer lft) {
this.lft = lft;
}
public Integer getRgt() {
return rgt;
}
public void setRgt(Integer rgt) {
this.rgt = rgt;
}
public Integer getUserLevel() {
return userLevel;
}
public void setUserLevel(Integer userLevel) {
this.userLevel = userLevel;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getTreeId() {
return treeId;
}
public void setTreeId(String treeId) {
this.treeId = treeId;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
} | UTF-8 | Java | 2,324 | java | VrUserLRValue.java | Java | [] | null | [] | package cc.stbl.token.innerdisc.modules.basic.entity;
import java.util.Date;
/**
* create by framework, create date 2018/10/10 16:10:20
*/
public class VrUserLRValue {
/**
* 字段:vr_user_lrvalue.user_id;备注:用户id
*/
private String userId;
/**
* 字段:vr_user_lrvalue.pid;备注:上级id
*/
private String pid;
/**
* 字段:vr_user_lrvalue.lft;备注:左值
*/
private Integer lft;
/**
* 字段:vr_user_lrvalue.rgt;备注:右值
*/
private Integer rgt;
/**
* 字段:vr_user_lrvalue.user_level;备注:用户层级,顶级用户为1
*/
private Integer userLevel;
/**
* 字段:vr_user_lrvalue.area;备注:所在区域,目前为 A或B
*/
private String area;
/**
* 字段:vr_user_lrvalue.tree_id;备注:用户所在树标识
*/
private String treeId;
private Integer status;
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
/**
* 字段:vr_user_lrvalue.create_date;备注:
*/
private Date createDate;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public Integer getLft() {
return lft;
}
public void setLft(Integer lft) {
this.lft = lft;
}
public Integer getRgt() {
return rgt;
}
public void setRgt(Integer rgt) {
this.rgt = rgt;
}
public Integer getUserLevel() {
return userLevel;
}
public void setUserLevel(Integer userLevel) {
this.userLevel = userLevel;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
public String getTreeId() {
return treeId;
}
public void setTreeId(String treeId) {
this.treeId = treeId;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
} | 2,324 | 0.567164 | 0.560168 | 122 | 16.581966 | 15.582588 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.245902 | false | false | 10 |
f24372419e5cc6cf530dbb9211d0e44135bec8e4 | 26,405,458,977,765 | c0c62f9075338ae359396d2135ca44af5606d8f2 | /app/src/main/java/com/example/dharkael/tweeter/dagger/ViewModelSubComponent.java | 17b866a399f3d65ed46e53ddbd68fbc47ed5c9cc | [] | no_license | dharkael/tweeter | https://github.com/dharkael/tweeter | eb085a4c3daa51162159a5df8fecf3107dd57322 | 3e3cfc8bd95122a3196e0608792a60f49c055da7 | refs/heads/master | 2021-01-09T22:38:27.668000 | 2017-05-30T21:18:18 | 2017-05-30T21:18:18 | 92,736,027 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.dharkael.tweeter.dagger;
import com.example.dharkael.tweeter.ui.login.LoginViewModel;
import com.example.dharkael.tweeter.ui.tweets.TweetsViewModel;
import dagger.Subcomponent;
@SuppressWarnings({"UnusedDeclaration"})
@Subcomponent
public interface ViewModelSubComponent {
@Subcomponent.Builder
interface Builder {
ViewModelSubComponent build();
}
LoginViewModel loginViewModel();
TweetsViewModel tweetsViewModel();
}
| UTF-8 | Java | 472 | java | ViewModelSubComponent.java | Java | [
{
"context": "mple.dharkael.tweeter.dagger;\n\nimport com.example.dharkael.tweeter.ui.login.LoginViewModel;\nimport com.examp",
"end": 73,
"score": 0.6756351590156555,
"start": 65,
"tag": "USERNAME",
"value": "dharkael"
},
{
"context": "ter.ui.login.LoginViewModel;\nimport com.exampl... | null | [] | package com.example.dharkael.tweeter.dagger;
import com.example.dharkael.tweeter.ui.login.LoginViewModel;
import com.example.dharkael.tweeter.ui.tweets.TweetsViewModel;
import dagger.Subcomponent;
@SuppressWarnings({"UnusedDeclaration"})
@Subcomponent
public interface ViewModelSubComponent {
@Subcomponent.Builder
interface Builder {
ViewModelSubComponent build();
}
LoginViewModel loginViewModel();
TweetsViewModel tweetsViewModel();
}
| 472 | 0.779661 | 0.779661 | 20 | 22.6 | 20.768726 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.35 | false | false | 10 |
5d51434f2a0bf1a83b5e80ab1a58df7eef3653e4 | 26,405,458,975,003 | 092c8235f62e92bbd340a0ed833b095b085daa72 | /code/mydemo/src/main/java/com/example/starterapp/controller/TestController.java | 9dbcf81497760599900e1b96c5f6ad54ee3f9494 | [] | no_license | flyflash/blog | https://github.com/flyflash/blog | 14008fb77ef7355fcd88fe4dd6a11d26f8e98ec6 | 96a758357cc61b3c2b43d4131ae267d6c3322f74 | refs/heads/master | 2022-07-02T06:27:21.891000 | 2019-09-09T07:34:17 | 2019-09-09T07:34:17 | 203,106,570 | 1 | 0 | null | false | 2021-04-26T19:26:24 | 2019-08-19T05:49:51 | 2020-03-16T07:14:38 | 2021-04-26T19:26:24 | 70 | 0 | 0 | 2 | Java | false | false | package com.example.starterapp.controller;
import com.example.starterapp.commons.ServerResponse;
import com.example.starterapp.enums.ResponseCode;
import com.example.starterapp.exception.CustomException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
@Slf4j
@RestController
@RequestMapping("/test")
@Api(value = "测试", tags = "测试")
public class TestController {
@ApiOperation(value = "文件上传",
notes = "文件上传(图片)",
response = ServerResponse.class)
@PostMapping("/importSql")
public ServerResponse<String> importSql(@RequestParam("file")MultipartFile file){
if (file.isEmpty()){
log.error("上传文件为空");
throw new CustomException(ResponseCode.FILE_IS_NULL);
}
long size = file.getSize() / 1024; //单位kb
if (size > 1024 || size < 10){
throw new CustomException(ResponseCode.FILE_SIZE_NOT_SUITABLE);
}
try{
BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
if (bufferedImage == null){
log.error("上传文件格式错误");
throw new CustomException(ResponseCode.FILE_FORMAT_ERROR);
}
log.info("图片大小:[{}]高:[{}]宽:[{}]", size, bufferedImage.getHeight(), bufferedImage.getWidth());
}catch (IOException e){}
String filename = file.getOriginalFilename();
// if (!filename.endsWith(".sql")){
// log.error("上传文件格式错误");
// return ServerResponse.createByErrorCodeMessage(ResponseCode.FILE_FORMAT_ERROR.getCode(),
// ResponseCode.FILE_FORMAT_ERROR.getMsg());
// }
return ServerResponse.createBySuccessMessage(filename);
}
}
| UTF-8 | Java | 2,062 | java | TestController.java | Java | [] | null | [] | package com.example.starterapp.controller;
import com.example.starterapp.commons.ServerResponse;
import com.example.starterapp.enums.ResponseCode;
import com.example.starterapp.exception.CustomException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;
@Slf4j
@RestController
@RequestMapping("/test")
@Api(value = "测试", tags = "测试")
public class TestController {
@ApiOperation(value = "文件上传",
notes = "文件上传(图片)",
response = ServerResponse.class)
@PostMapping("/importSql")
public ServerResponse<String> importSql(@RequestParam("file")MultipartFile file){
if (file.isEmpty()){
log.error("上传文件为空");
throw new CustomException(ResponseCode.FILE_IS_NULL);
}
long size = file.getSize() / 1024; //单位kb
if (size > 1024 || size < 10){
throw new CustomException(ResponseCode.FILE_SIZE_NOT_SUITABLE);
}
try{
BufferedImage bufferedImage = ImageIO.read(file.getInputStream());
if (bufferedImage == null){
log.error("上传文件格式错误");
throw new CustomException(ResponseCode.FILE_FORMAT_ERROR);
}
log.info("图片大小:[{}]高:[{}]宽:[{}]", size, bufferedImage.getHeight(), bufferedImage.getWidth());
}catch (IOException e){}
String filename = file.getOriginalFilename();
// if (!filename.endsWith(".sql")){
// log.error("上传文件格式错误");
// return ServerResponse.createByErrorCodeMessage(ResponseCode.FILE_FORMAT_ERROR.getCode(),
// ResponseCode.FILE_FORMAT_ERROR.getMsg());
// }
return ServerResponse.createBySuccessMessage(filename);
}
}
| 2,062 | 0.743147 | 0.736548 | 58 | 32.965519 | 25.149872 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 10 |
62d1cb7bcb2d7295073ba7306561739669deab5f | 25,933,012,581,928 | 79951dc47cb4c20a1640b4cd8ad446fd4c877926 | /styx-scheduler-service/src/test/java/com/spotify/styx/StateInitializingTriggerTest.java | 844d8da783b4f7874668fce70e95d987651d410e | [
"Apache-2.0"
] | permissive | zatine/styx | https://github.com/zatine/styx | b70086b40ae1e476c86de6cb41625e61741f2664 | ec10327fc2c2cb51c0c85d6ad46918a3eb17e2b4 | refs/heads/master | 2021-07-23T07:48:00.406000 | 2017-11-02T15:51:03 | 2017-11-02T15:51:03 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*-
* -\-\-
* Spotify Styx Scheduler Service
* --
* Copyright (C) 2016 Spotify AB
* --
* 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.spotify.styx;
import static com.github.npathai.hamcrestopt.OptionalMatchers.hasValue;
import static com.spotify.styx.model.Schedule.DAYS;
import static com.spotify.styx.model.Schedule.HOURS;
import static com.spotify.styx.model.Schedule.MONTHS;
import static com.spotify.styx.model.Schedule.WEEKS;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.spotify.styx.model.Schedule;
import com.spotify.styx.model.Workflow;
import com.spotify.styx.model.WorkflowConfiguration;
import com.spotify.styx.model.WorkflowId;
import com.spotify.styx.model.WorkflowInstance;
import com.spotify.styx.state.RunState;
import com.spotify.styx.state.SyncStateManager;
import com.spotify.styx.state.Trigger;
import com.spotify.styx.storage.Storage;
import com.spotify.styx.testdata.TestData;
import com.spotify.styx.util.TriggerUtil;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
import org.junit.Test;
public class StateInitializingTriggerTest {
private static final Instant TIME = Instant.parse("2016-01-18T09:11:22.333Z");
private static final Trigger NATURAL_TRIGGER = Trigger.natural();
private static final Trigger BACKFILL_TRIGGER = Trigger.backfill("trig");
private static final Map<Schedule, String> SCHEDULE_ARG_EXPECTS =
ImmutableMap.of(
WEEKS, "2016-01-18",
DAYS, "2016-01-18",
HOURS, "2016-01-18T09",
MONTHS, "2016-01"
);
private SyncStateManager stateManager = new SyncStateManager();
private Storage storage = mock(Storage.class);
private TriggerListener
trigger = new StateInitializingTrigger(RunState::fresh, stateManager, storage);
@Test
public void shouldInitializeWorkflowInstance() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
assertThat(stateManager.activeStatesSize(), is(1));
}
@Test
public void shouldInjectTriggerExecutionEventWithNaturalTrigger() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
WorkflowInstance expectedInstance = WorkflowInstance.create(workflow.id(), "2016-01-18T09");
RunState state = stateManager.get(expectedInstance);
assertThat(state.state(), is(RunState.State.QUEUED));
assertThat(state.data().triggerId(), hasValue(TriggerUtil.NATURAL_TRIGGER_ID));
assertThat(state.data().trigger(), hasValue(Trigger.natural()));
}
@Test
public void shouldInjectTriggerExecutionEventWithBackfillTrigger() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, BACKFILL_TRIGGER, TIME);
WorkflowInstance expectedInstance = WorkflowInstance.create(workflow.id(), "2016-01-18T09");
RunState state = stateManager.get(expectedInstance);
assertThat(state.state(), is(RunState.State.QUEUED));
assertThat(state.data().triggerId(), hasValue("trig"));
assertThat(state.data().trigger(), hasValue(Trigger.backfill("trig")));
}
@Test
public void shouldDoNothingIfDockerInfoMissing() throws Exception {
Workflow workflow = Workflow.create("id", TestData.DAILY_WORKFLOW_CONFIGURATION);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
assertThat(stateManager.activeStatesSize(), is(0));
}
@Test
public void shouldCreateWorkflowInstanceParameter() throws Exception {
for (Map.Entry<Schedule, String> scheduleCase : SCHEDULE_ARG_EXPECTS.entrySet()) {
WorkflowConfiguration
workflowConfiguration = schedule(scheduleCase.getKey(), "--date", "{}", "--bar");
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
RunState runState =
stateManager.get(WorkflowInstance.create(workflow.id(), scheduleCase.getValue()));
assertThat(runState, is(notNullValue()));
assertThat(runState.workflowInstance().parameter(), is(scheduleCase.getValue()));
}
}
@Test
public void testsShouldCoverAllScheduleCases() throws Exception {
assertThat(SCHEDULE_ARG_EXPECTS.keySet(), is(Sets.newHashSet(Schedule.values())));
}
private WorkflowConfiguration schedule(Schedule schedule, String... args) {
return WorkflowConfiguration.builder()
.id("styx.TestEndpoint")
.schedule(schedule)
.dockerImage("busybox")
.dockerArgs(ImmutableList.copyOf(args))
.build();
}
// todo: do not use deprecated getDockerImage method
private void setDockerImage(WorkflowId workflowId, WorkflowConfiguration workflowConfiguration) throws IOException {
when(storage.getDockerImage(workflowId)).thenReturn(workflowConfiguration.dockerImage());
}
}
| UTF-8 | Java | 6,240 | java | StateInitializingTriggerTest.java | Java | [
{
"context": "kage com.spotify.styx;\n\nimport static com.github.npathai.hamcrestopt.OptionalMatchers.hasValue;\nimport sta",
"end": 723,
"score": 0.7257605791091919,
"start": 717,
"tag": "USERNAME",
"value": "pathai"
}
] | null | [] | /*-
* -\-\-
* Spotify Styx Scheduler Service
* --
* Copyright (C) 2016 Spotify AB
* --
* 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.spotify.styx;
import static com.github.npathai.hamcrestopt.OptionalMatchers.hasValue;
import static com.spotify.styx.model.Schedule.DAYS;
import static com.spotify.styx.model.Schedule.HOURS;
import static com.spotify.styx.model.Schedule.MONTHS;
import static com.spotify.styx.model.Schedule.WEEKS;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.spotify.styx.model.Schedule;
import com.spotify.styx.model.Workflow;
import com.spotify.styx.model.WorkflowConfiguration;
import com.spotify.styx.model.WorkflowId;
import com.spotify.styx.model.WorkflowInstance;
import com.spotify.styx.state.RunState;
import com.spotify.styx.state.SyncStateManager;
import com.spotify.styx.state.Trigger;
import com.spotify.styx.storage.Storage;
import com.spotify.styx.testdata.TestData;
import com.spotify.styx.util.TriggerUtil;
import java.io.IOException;
import java.time.Instant;
import java.util.Map;
import org.junit.Test;
public class StateInitializingTriggerTest {
private static final Instant TIME = Instant.parse("2016-01-18T09:11:22.333Z");
private static final Trigger NATURAL_TRIGGER = Trigger.natural();
private static final Trigger BACKFILL_TRIGGER = Trigger.backfill("trig");
private static final Map<Schedule, String> SCHEDULE_ARG_EXPECTS =
ImmutableMap.of(
WEEKS, "2016-01-18",
DAYS, "2016-01-18",
HOURS, "2016-01-18T09",
MONTHS, "2016-01"
);
private SyncStateManager stateManager = new SyncStateManager();
private Storage storage = mock(Storage.class);
private TriggerListener
trigger = new StateInitializingTrigger(RunState::fresh, stateManager, storage);
@Test
public void shouldInitializeWorkflowInstance() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
assertThat(stateManager.activeStatesSize(), is(1));
}
@Test
public void shouldInjectTriggerExecutionEventWithNaturalTrigger() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
WorkflowInstance expectedInstance = WorkflowInstance.create(workflow.id(), "2016-01-18T09");
RunState state = stateManager.get(expectedInstance);
assertThat(state.state(), is(RunState.State.QUEUED));
assertThat(state.data().triggerId(), hasValue(TriggerUtil.NATURAL_TRIGGER_ID));
assertThat(state.data().trigger(), hasValue(Trigger.natural()));
}
@Test
public void shouldInjectTriggerExecutionEventWithBackfillTrigger() throws Exception {
WorkflowConfiguration workflowConfiguration = schedule(HOURS);
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, BACKFILL_TRIGGER, TIME);
WorkflowInstance expectedInstance = WorkflowInstance.create(workflow.id(), "2016-01-18T09");
RunState state = stateManager.get(expectedInstance);
assertThat(state.state(), is(RunState.State.QUEUED));
assertThat(state.data().triggerId(), hasValue("trig"));
assertThat(state.data().trigger(), hasValue(Trigger.backfill("trig")));
}
@Test
public void shouldDoNothingIfDockerInfoMissing() throws Exception {
Workflow workflow = Workflow.create("id", TestData.DAILY_WORKFLOW_CONFIGURATION);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
assertThat(stateManager.activeStatesSize(), is(0));
}
@Test
public void shouldCreateWorkflowInstanceParameter() throws Exception {
for (Map.Entry<Schedule, String> scheduleCase : SCHEDULE_ARG_EXPECTS.entrySet()) {
WorkflowConfiguration
workflowConfiguration = schedule(scheduleCase.getKey(), "--date", "{}", "--bar");
Workflow workflow = Workflow.create("id", workflowConfiguration);
setDockerImage(workflow.id(), workflow.configuration());
trigger.event(workflow, NATURAL_TRIGGER, TIME);
RunState runState =
stateManager.get(WorkflowInstance.create(workflow.id(), scheduleCase.getValue()));
assertThat(runState, is(notNullValue()));
assertThat(runState.workflowInstance().parameter(), is(scheduleCase.getValue()));
}
}
@Test
public void testsShouldCoverAllScheduleCases() throws Exception {
assertThat(SCHEDULE_ARG_EXPECTS.keySet(), is(Sets.newHashSet(Schedule.values())));
}
private WorkflowConfiguration schedule(Schedule schedule, String... args) {
return WorkflowConfiguration.builder()
.id("styx.TestEndpoint")
.schedule(schedule)
.dockerImage("busybox")
.dockerArgs(ImmutableList.copyOf(args))
.build();
}
// todo: do not use deprecated getDockerImage method
private void setDockerImage(WorkflowId workflowId, WorkflowConfiguration workflowConfiguration) throws IOException {
when(storage.getDockerImage(workflowId)).thenReturn(workflowConfiguration.dockerImage());
}
}
| 6,240 | 0.748878 | 0.736218 | 156 | 39 | 29.757782 | 118 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.820513 | false | false | 10 |
5552cbacd395c95a7a3864304c471044791d6e8f | 30,520,037,653,868 | faea4aac6fc942fc85c06efff9e9f1b38e7ce8cc | /src/main/java/com/adapter/api/token/AccessToken.java | e2e5f9e3d6db080cebcadc0f3e019225d53d2cbd | [] | no_license | cham0919/Greengrocery-Adapter-Server | https://github.com/cham0919/Greengrocery-Adapter-Server | 89c215a6411114e73790432c4ec6eae0f80551a2 | 19de8667cac3ca285e00a7ab3210e6250bf19729 | refs/heads/main | 2023-06-29T00:14:38.026000 | 2021-07-10T13:23:54 | 2021-07-10T13:23:54 | 383,634,931 | 1 | 0 | null | false | 2021-07-07T01:01:52 | 2021-07-07T00:56:08 | 2021-07-07T00:56:11 | 2021-07-07T01:01:52 | 0 | 0 | 0 | 0 | null | false | false | package com.adapter.api.token;
import lombok.Getter;
import lombok.Setter;
public class AccessToken {
@Getter @Setter
private static String fruitAccessToken;
@Getter @Setter
private static String vegetableAccessToken;
}
| UTF-8 | Java | 240 | java | AccessToken.java | Java | [] | null | [] | package com.adapter.api.token;
import lombok.Getter;
import lombok.Setter;
public class AccessToken {
@Getter @Setter
private static String fruitAccessToken;
@Getter @Setter
private static String vegetableAccessToken;
}
| 240 | 0.754167 | 0.754167 | 13 | 17.461538 | 15.872644 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.384615 | false | false | 10 |
7f5b8e46617e30aefa24310c6363b007aeec2abb | 30,391,188,621,856 | 38acd8fe1e34a37b631b36068de2cbf7f8dc3665 | /src/Lintcode/Array/String/DP/Backpack_I.java | bba1a0021ca38b65d59dda0fe1c339fd194bfd4f | [] | no_license | Yiming686/leetcode-project | https://github.com/Yiming686/leetcode-project | 1cfdfdcd84389a3a435503fbd5130e1b6904fd43 | dc65ff0438d3a65196570c4e9d95e5c7c37796c9 | refs/heads/master | 2022-02-22T01:55:01.154000 | 2022-02-18T00:29:36 | 2022-02-18T00:29:36 | 44,041,371 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Lintcode.Array.String.DP;
import java.util.Arrays;
import java.util.Iterator;
import java.util.TreeSet;
import org.omg.PortableServer.POA;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
import Lintcode.Matrix.Matrix;
/**
Backpack I
Problem 单次选择+最大体积
Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack?
Have you met this question in a real interview? Yes
Example
If we have 4 items with size [2, 3, 5, 7], the backpack size is 11, we can select [2, 3, 5], so that the max size we can fill this backpack is 10. If the backpack size is 12. we can select [2, 3, 7] so that we can fulfill the backpack.
You function should return the max size we can fill in the given backpack.
Note
You can not divide any item into small pieces.
Challenge
O(n x m) time and O(m) memory.
O(n x m) memory is also acceptable if you do not know how to optimize memory.
Tags Expand
LintCode Copyright Dynamic Programming Backpack
Related Problems Expand
Medium Backpack II *
*/
public class Backpack_I {
public static int backPack44(int target, int[] sizes) {
if (sizes.length==0) return 0;
int len = sizes.length;
int[] max = new int[target+1];
// max[0] = 0;
for (int i=0;i<len;i++){ //开启第i的天空,过去值即第i-1天的情形
int size = sizes[i];
// for (int j=0;j<=m;j++){ //wrong here
for (int j=target;j>=0;j--){ //not easy to understand here
if (j-size>=0){ //A[i-1]为带装物品大小
max[j] = Math.max(max[j], max[j-size]+size); //此时得到的上一轮的值,更新前看到了什么,
}
System.out.println("i:j "+ i + ":"+j+" "+Arrays.toString(max));
}
System.out.println();
}
return max[target];
}
//1.不可重复取用,如果袋子大于全体和,直接返回
//2.每件东西两种情况,放或者不放,所以必须比较Math.max()
//3.求放进袋子最大体积,添加一个虚拟物品体积为0,虚拟袋子体积为0,初始化为0,但是循环不遍历他们,
public static void main(String[] args) {
// TODO Auto-generated method stub
// int[] arr = {3,4,8,5};
int k = 20;
int[] arr = {2,3,5,7};
// int[] arr = {3,7,8,5};
// int k = 20;
System.out.println("num:"+backPack44(k, arr));
// System.out.println(""+p);
// System.out.println("num:"+backPack(k, arr));
System.out.println("++++++++++++++++++++++");
// System.out.println("num:"+backPack3(k, arr));
}
//Best Best solution, not easy to understand
public static int backPack(int m, int[] A) {
if (A.length==0) return 0;
int len = A.length;
boolean[] isFull = new boolean[m+1];
isFull[0] = true;
for (int i=1;i<=len;i++){
for (int j=0;j<=m;j++){ //not easy to understand here
// for (int j=m;j>=0;j--){ //not easy to understand here
if (j-A[i-1]>=0 && isFull[j-A[i-1]])//A[i-1]为带装物品大小
{
System.out.println("i:j:A[i-1] "+ i +".." +j+".." +A[i-1]);
isFull[j] = true;
}
}
}
for (int i=m; i>=0;i--)
if (isFull[i]) return i;
return 0;
}
//solution, worked, O(n x m) time and O( m) memory.
public static int backPack22(int m, int[] A) {
boolean f[][] = new boolean[2][m + 1];
f[0][0] = true;
for (int i = 0; i < A.length; i++) {
for (int j = 0; j <= m; j++) {
f[(i + 1)%2][j] = f[i%2][j];
if (j >= A[i] && f[i%2][j - A[i]]) {
f[(i + 1)%2][j] = true;
}
}
}
for (int i = m; i >= 0; i--) {
if (f[A.length %2][i]) {
return i;
}
}
return 0;
}
//worked, fastest
public static int backPack3(int size, int[] items) {
// it does not matter if change the order of A
// int temp = A[0];
// A[0]= A[A.length-1];
// A[A.length-1] = temp;
//第一步:确定状态,f[i][j],对size为j的袋子,前i个物品能否把他装满,true或者false
boolean isFull[][] = new boolean[items.length + 1][size + 1];
//第二步:状态初始化
isFull[0][0] = true;
for (int i = 1; i <= items.length; i++) {
for (int j = 0; j <= size; j++) {
//第三步:实现递推的状态方程
//初始化数组有了,第一个数组值也有了,就看怎么计算下一行数组了
//这里就是状态方程的实现:f[i-1][j]如何计算出f[i][j]?
//实质:在此block里面如何计算f[i][j]?
//有两种做法: 1, 不把第i-1个物品放入;2,把第i个物品放入
//1, 不把第i-1个物品放入,那么前A[i-1]物品,能组成size为j的包,到下面A[i]物品的也就能
//前A[i-1]物品,不能组成size为j的包,那么默认,到下面A[i]物品的也就能
//2,把第i个物品放入,除非...
isFull[i][j] = isFull[i-1][j];
//除非符合下面的条件,才可以
//什么条件呢?除非size为j的背包,可以装下size为A[i-1]的东西,并且剩余的也是的
//第i行物品的大小是多少?是items[i-1]
if (j - items[i-1] >= 0 && isFull[i-1][j - items[i-1]]) {
isFull[i][j] = true;
}
System.out.println(""+Matrix.fromMatrixToString(isFull));
// isFull[i][j] = Math.max(isFull[i - 1][j - items[i] + items[i], isFull[i-1][j]);
} // for j
} // for i
//第四步:状态方程递推完毕,根据先前确定的状态,找最终结果
System.out.println(""+Matrix.fromMatrixToString(isFull));
for (int i = size; i >= 0; i--) {
if (isFull[items.length][i]) {
return i;
}
}
return 0;
}
// solution, worked, O(n x m) time and O( m) memory.
public static int backPack6(int m, int[] A) {
boolean f[][] = new boolean[2][m + 1];
f[0][0] = true;
for (int i = 0; i < A.length; i++) {
for (int j = 0; j <= m; j++) {
f[1][j] = f[0][j];
if (j >= A[i] && f[0][j - A[i]]) {
f[1][j] = true;
}
}
boolean [] temp = f[0];
f[0] = f[1];
f[1] = temp;
}
for (int i = m; i >= 0; i--) {
if (f[0][i]) {
return i;
}
}
return 0;
}
//worked,but slow
public int backPack9(int m, int[] A) {
TreeSet<Integer> set = new TreeSet<Integer>();
TreeSet<Integer> newSet = new TreeSet<Integer>();
// AAA:
for(int size : A){
for(int el : set){
if(size+el<=m){
newSet.add(size+el);
// break AAA;
// break ;
}
}
set.add(size);
set.addAll(newSet);
newSet.clear();
}
for(Iterator<Integer> iter = set.descendingIterator(); iter.hasNext(); ) {
Integer val = iter.next();
if(val <= m) return val;
}
return 0;
}
}
/*
背包问题是动态规划问题的一种典型题目。 动态规划问题我们一般要考虑下面这四点。
1. 状态 State
2. 方程 Function
3. 初始化 Intialization
4. 答案 Answer
本题是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放,那下面我们来看背包这题动态规划的四点是怎么样的呢?
1. State: dp[i][S] 表示前i个物品,取出一些,能否组成和为S体积的背包
2. Function: f[i][S] = f[i-1][S - A[i]] or f[i-1][S] (A[i]表示第i个物品的大小)
转移方程想得到f[i][S]前i个物品取出一些物品想组成S体积的背包。 那么可以从两个状态转换得到。
(1)f[i-1][S - A[i]] 放入第i个物品,并且前i-1个物品能否取出一些组成和为S-A[i] 体积大小的背包。
(2)f[i-1][S] 不放入第i个物品, 并且前i-1个物品能否取出一些组成和为S 体积大小的背包。
3. Intialize: f[1...n][0] = true; f[0][1... m] = false
初始化 f[1...n][0] 表示前1...n个物品,取出一些能否组成和为0 大小的背包始终为真。
其他初始化为假
4. Answer: 寻找使f[n][S] 值为true的最大的S. (S的取值范围1到m)
由于这道题空间上有一些要求,所以在知道了思路答案过后我们还需要进行优化空间复杂度.先考虑上面讲的基本思路如何实现,肯定是有一个主循环i=1..N,每次算出来二维数组f[i][0..S]的所有值。那么,如果只用一个数组f[0..S],能不能保证第i次循环结束后f[S]中表示的就是我们定义的状态f[i][S]呢?f[i][S]是由 f[i-1][S - a[i]] 和 f[i-1][S] 两个子问题递推而来,能否保证在推f[i][S]时(也即在第i次主循环中推f[S]时)能够得到 f[i-1][S - a[i]] 和 f[i-1][S] 的值呢?事实上,这要求在每次主循环中我们以S=m...0的顺序推f[S],这样才能保证推f[S]时f[S-a[i]]保存的是状态f[i-1][S-a[i]]的值。伪代码如下:
for i=1..N
for S=m...0
f[S]=f[S] or f[S-a[i]];
* */
| GB18030 | Java | 9,722 | java | Backpack_I.java | Java | [] | null | [] | package Lintcode.Array.String.DP;
import java.util.Arrays;
import java.util.Iterator;
import java.util.TreeSet;
import org.omg.PortableServer.POA;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.XsiNilLoader.Array;
import Lintcode.Matrix.Matrix;
/**
Backpack I
Problem 单次选择+最大体积
Given n items with size Ai, an integer m denotes the size of a backpack. How full you can fill this backpack?
Have you met this question in a real interview? Yes
Example
If we have 4 items with size [2, 3, 5, 7], the backpack size is 11, we can select [2, 3, 5], so that the max size we can fill this backpack is 10. If the backpack size is 12. we can select [2, 3, 7] so that we can fulfill the backpack.
You function should return the max size we can fill in the given backpack.
Note
You can not divide any item into small pieces.
Challenge
O(n x m) time and O(m) memory.
O(n x m) memory is also acceptable if you do not know how to optimize memory.
Tags Expand
LintCode Copyright Dynamic Programming Backpack
Related Problems Expand
Medium Backpack II *
*/
public class Backpack_I {
public static int backPack44(int target, int[] sizes) {
if (sizes.length==0) return 0;
int len = sizes.length;
int[] max = new int[target+1];
// max[0] = 0;
for (int i=0;i<len;i++){ //开启第i的天空,过去值即第i-1天的情形
int size = sizes[i];
// for (int j=0;j<=m;j++){ //wrong here
for (int j=target;j>=0;j--){ //not easy to understand here
if (j-size>=0){ //A[i-1]为带装物品大小
max[j] = Math.max(max[j], max[j-size]+size); //此时得到的上一轮的值,更新前看到了什么,
}
System.out.println("i:j "+ i + ":"+j+" "+Arrays.toString(max));
}
System.out.println();
}
return max[target];
}
//1.不可重复取用,如果袋子大于全体和,直接返回
//2.每件东西两种情况,放或者不放,所以必须比较Math.max()
//3.求放进袋子最大体积,添加一个虚拟物品体积为0,虚拟袋子体积为0,初始化为0,但是循环不遍历他们,
public static void main(String[] args) {
// TODO Auto-generated method stub
// int[] arr = {3,4,8,5};
int k = 20;
int[] arr = {2,3,5,7};
// int[] arr = {3,7,8,5};
// int k = 20;
System.out.println("num:"+backPack44(k, arr));
// System.out.println(""+p);
// System.out.println("num:"+backPack(k, arr));
System.out.println("++++++++++++++++++++++");
// System.out.println("num:"+backPack3(k, arr));
}
//Best Best solution, not easy to understand
public static int backPack(int m, int[] A) {
if (A.length==0) return 0;
int len = A.length;
boolean[] isFull = new boolean[m+1];
isFull[0] = true;
for (int i=1;i<=len;i++){
for (int j=0;j<=m;j++){ //not easy to understand here
// for (int j=m;j>=0;j--){ //not easy to understand here
if (j-A[i-1]>=0 && isFull[j-A[i-1]])//A[i-1]为带装物品大小
{
System.out.println("i:j:A[i-1] "+ i +".." +j+".." +A[i-1]);
isFull[j] = true;
}
}
}
for (int i=m; i>=0;i--)
if (isFull[i]) return i;
return 0;
}
//solution, worked, O(n x m) time and O( m) memory.
public static int backPack22(int m, int[] A) {
boolean f[][] = new boolean[2][m + 1];
f[0][0] = true;
for (int i = 0; i < A.length; i++) {
for (int j = 0; j <= m; j++) {
f[(i + 1)%2][j] = f[i%2][j];
if (j >= A[i] && f[i%2][j - A[i]]) {
f[(i + 1)%2][j] = true;
}
}
}
for (int i = m; i >= 0; i--) {
if (f[A.length %2][i]) {
return i;
}
}
return 0;
}
//worked, fastest
public static int backPack3(int size, int[] items) {
// it does not matter if change the order of A
// int temp = A[0];
// A[0]= A[A.length-1];
// A[A.length-1] = temp;
//第一步:确定状态,f[i][j],对size为j的袋子,前i个物品能否把他装满,true或者false
boolean isFull[][] = new boolean[items.length + 1][size + 1];
//第二步:状态初始化
isFull[0][0] = true;
for (int i = 1; i <= items.length; i++) {
for (int j = 0; j <= size; j++) {
//第三步:实现递推的状态方程
//初始化数组有了,第一个数组值也有了,就看怎么计算下一行数组了
//这里就是状态方程的实现:f[i-1][j]如何计算出f[i][j]?
//实质:在此block里面如何计算f[i][j]?
//有两种做法: 1, 不把第i-1个物品放入;2,把第i个物品放入
//1, 不把第i-1个物品放入,那么前A[i-1]物品,能组成size为j的包,到下面A[i]物品的也就能
//前A[i-1]物品,不能组成size为j的包,那么默认,到下面A[i]物品的也就能
//2,把第i个物品放入,除非...
isFull[i][j] = isFull[i-1][j];
//除非符合下面的条件,才可以
//什么条件呢?除非size为j的背包,可以装下size为A[i-1]的东西,并且剩余的也是的
//第i行物品的大小是多少?是items[i-1]
if (j - items[i-1] >= 0 && isFull[i-1][j - items[i-1]]) {
isFull[i][j] = true;
}
System.out.println(""+Matrix.fromMatrixToString(isFull));
// isFull[i][j] = Math.max(isFull[i - 1][j - items[i] + items[i], isFull[i-1][j]);
} // for j
} // for i
//第四步:状态方程递推完毕,根据先前确定的状态,找最终结果
System.out.println(""+Matrix.fromMatrixToString(isFull));
for (int i = size; i >= 0; i--) {
if (isFull[items.length][i]) {
return i;
}
}
return 0;
}
// solution, worked, O(n x m) time and O( m) memory.
public static int backPack6(int m, int[] A) {
boolean f[][] = new boolean[2][m + 1];
f[0][0] = true;
for (int i = 0; i < A.length; i++) {
for (int j = 0; j <= m; j++) {
f[1][j] = f[0][j];
if (j >= A[i] && f[0][j - A[i]]) {
f[1][j] = true;
}
}
boolean [] temp = f[0];
f[0] = f[1];
f[1] = temp;
}
for (int i = m; i >= 0; i--) {
if (f[0][i]) {
return i;
}
}
return 0;
}
//worked,but slow
public int backPack9(int m, int[] A) {
TreeSet<Integer> set = new TreeSet<Integer>();
TreeSet<Integer> newSet = new TreeSet<Integer>();
// AAA:
for(int size : A){
for(int el : set){
if(size+el<=m){
newSet.add(size+el);
// break AAA;
// break ;
}
}
set.add(size);
set.addAll(newSet);
newSet.clear();
}
for(Iterator<Integer> iter = set.descendingIterator(); iter.hasNext(); ) {
Integer val = iter.next();
if(val <= m) return val;
}
return 0;
}
}
/*
背包问题是动态规划问题的一种典型题目。 动态规划问题我们一般要考虑下面这四点。
1. 状态 State
2. 方程 Function
3. 初始化 Intialization
4. 答案 Answer
本题是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放,那下面我们来看背包这题动态规划的四点是怎么样的呢?
1. State: dp[i][S] 表示前i个物品,取出一些,能否组成和为S体积的背包
2. Function: f[i][S] = f[i-1][S - A[i]] or f[i-1][S] (A[i]表示第i个物品的大小)
转移方程想得到f[i][S]前i个物品取出一些物品想组成S体积的背包。 那么可以从两个状态转换得到。
(1)f[i-1][S - A[i]] 放入第i个物品,并且前i-1个物品能否取出一些组成和为S-A[i] 体积大小的背包。
(2)f[i-1][S] 不放入第i个物品, 并且前i-1个物品能否取出一些组成和为S 体积大小的背包。
3. Intialize: f[1...n][0] = true; f[0][1... m] = false
初始化 f[1...n][0] 表示前1...n个物品,取出一些能否组成和为0 大小的背包始终为真。
其他初始化为假
4. Answer: 寻找使f[n][S] 值为true的最大的S. (S的取值范围1到m)
由于这道题空间上有一些要求,所以在知道了思路答案过后我们还需要进行优化空间复杂度.先考虑上面讲的基本思路如何实现,肯定是有一个主循环i=1..N,每次算出来二维数组f[i][0..S]的所有值。那么,如果只用一个数组f[0..S],能不能保证第i次循环结束后f[S]中表示的就是我们定义的状态f[i][S]呢?f[i][S]是由 f[i-1][S - a[i]] 和 f[i-1][S] 两个子问题递推而来,能否保证在推f[i][S]时(也即在第i次主循环中推f[S]时)能够得到 f[i-1][S - a[i]] 和 f[i-1][S] 的值呢?事实上,这要求在每次主循环中我们以S=m...0的顺序推f[S],这样才能保证推f[S]时f[S-a[i]]保存的是状态f[i-1][S-a[i]]的值。伪代码如下:
for i=1..N
for S=m...0
f[S]=f[S] or f[S-a[i]];
* */
| 9,722 | 0.506617 | 0.484347 | 243 | 31.337448 | 33.299385 | 357 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.781893 | false | false | 10 |
ece2b24f322a24cda4194926270a85041fdbec6f | 26,998,164,464,346 | 05830c062520d854382fcabcb4916e5386219a93 | /ZIG-ZAG-CONVERSION-PAPAL/abc.java | c274ef4c52c05e265eaa37b16e6a1988df6887e5 | [] | no_license | somya1212/JAVA-CODES | https://github.com/somya1212/JAVA-CODES | 42d810d88ab360f14d94e96e94c57fc894867f01 | 28ba7ad1fc12ad0bae542b2cbd4d525d76b7a2e9 | refs/heads/master | 2022-12-19T14:21:44.918000 | 2020-06-25T18:59:54 | 2020-06-25T18:59:54 | 275,212,258 | 2 | 0 | null | true | 2020-06-26T17:32:55 | 2020-06-26T17:32:54 | 2020-06-25T20:04:20 | 2020-06-25T20:04:17 | 401 | 0 | 0 | 0 | null | false | false | import java.util.*;
class abc
{
static String zigzag(String s,int numRows)
{
if(numRows==1)
{
return s;
}
ArrayList<String> al=new ArrayList<>();
int i=0,k;
String t;
while(i<s.length())
{
if(i%(numRows-1)==0)
{
al.add(s.substring(i,Math.min(s.length(),i+numRows)));
i+=numRows;
}
else
{
k=i%(numRows-1);
t=String.valueOf(s.charAt(i));
for(int a=0;a<k;a++)
{
t+="*";
}
for(int a=0;a<numRows-k-1;a++)
{
t="*"+t;
}
al.add(t);
i++;
}
}
int y=al.get(al.size()-1).length();
if(numRows>y)
{
String x=String.valueOf(al.get(al.size()-1));
for(int a=0;a<numRows-y;a++)
{
x+="*";
}
al.set(al.size()-1,x);
}
String result="";
for(int j=0;j<numRows;j++)
{
for(int q=0;q<al.size();q++)
{
result+=(al.get(q).charAt(j)!='*')?String.valueOf(al.get(q).charAt(j)):"";
}
}
return result;
}
public static void main(String[] args) {
String s;
int numRows;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string");
s=sc.next();
System.out.println("Enter the number of rows");
numRows=sc.nextInt();
System.out.println("Zig Zag Conversion is: "+zigzag(s,numRows));
sc.close();
}
} | UTF-8 | Java | 1,948 | java | abc.java | Java | [] | null | [] | import java.util.*;
class abc
{
static String zigzag(String s,int numRows)
{
if(numRows==1)
{
return s;
}
ArrayList<String> al=new ArrayList<>();
int i=0,k;
String t;
while(i<s.length())
{
if(i%(numRows-1)==0)
{
al.add(s.substring(i,Math.min(s.length(),i+numRows)));
i+=numRows;
}
else
{
k=i%(numRows-1);
t=String.valueOf(s.charAt(i));
for(int a=0;a<k;a++)
{
t+="*";
}
for(int a=0;a<numRows-k-1;a++)
{
t="*"+t;
}
al.add(t);
i++;
}
}
int y=al.get(al.size()-1).length();
if(numRows>y)
{
String x=String.valueOf(al.get(al.size()-1));
for(int a=0;a<numRows-y;a++)
{
x+="*";
}
al.set(al.size()-1,x);
}
String result="";
for(int j=0;j<numRows;j++)
{
for(int q=0;q<al.size();q++)
{
result+=(al.get(q).charAt(j)!='*')?String.valueOf(al.get(q).charAt(j)):"";
}
}
return result;
}
public static void main(String[] args) {
String s;
int numRows;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the string");
s=sc.next();
System.out.println("Enter the number of rows");
numRows=sc.nextInt();
System.out.println("Zig Zag Conversion is: "+zigzag(s,numRows));
sc.close();
}
} | 1,948 | 0.348563 | 0.341376 | 70 | 26.842857 | 17.646235 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.642857 | false | false | 10 |
03258038f3a8ac452034cebf436ffdafef0e9c7e | 7,808,250,581,850 | bc4ffa3bf17d2e2d68205fab8ce06405d4a793db | /src/main/java/com/hgsoft/system/dao/BusinessAccreditDao.java | 1a3e2ff7742e9b5b06ba15811581cd60223394d1 | [] | no_license | cckmit/RMIServer | https://github.com/cckmit/RMIServer | 64dbd16eb50fb00560f273dd429622bdfb4c57c7 | cb957dc93aeb083048a6f8eb2a13aa374ee3c8b2 | refs/heads/master | 2023-03-15T10:11:22.349000 | 2017-11-04T09:34:18 | 2017-11-04T09:34:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hgsoft.system.dao;
import com.hgsoft.common.dao.BaseDao;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public class BusinessAccreditDao extends BaseDao{
public List<Map<String, Object>> findBusinessAccreditByURL(String url){
String sql="select * from csms_businessaccredit bt where url=? and bt.usestate='2'";
List<Map<String, Object>> list = queryList(sql, url);
return list;
}
public List<Map<String, Object>> findBusinessAccreditByURL(String url, String subuumstemcode){
String sql="select * from csms_businessaccredit bt where url=? and bt.usestate='2' and bt.subuumstemcode = ?";
List<Map<String, Object>> list = queryList(sql, url, subuumstemcode);
return list;
}
public List<Map<String, Object>> BusinessAccreditAdminByName(String staffno,String state,String url, String subuumstemcode) {
String sql="select * from csms_businessaccredit_admin ba join (select b.ID, b.LOGINNAME, b.USERNAME, b.PASSWORD, b.SEX, b.STAFFNO, b.EMAIL, b.PHONE, b.USERSTATE, b.USESTATE, b.IPLIMIT, b.LOGINTIME, b.LOGINIP, b.LASTLOGINTIME, b.LASTLOGINIP, b.REMARK, b.COMPANY, b.DEPARTMENT, b.DENAME, b.CREATEID, b.UPDATEID, b.CREATETIME, b.UPDATETIME, b.CUSTOMPOINT, b.POINTNAME, null as ADMINGROUP, b.CUSTOMPOINTTYPE, b.POINTCODE, a.subuumstem as subuumstemCode from uums_admin_subuumstem a join uums_admin b on a.admin = b.id ) a on ba.admin=a.id join CSMS_BUSINESSACCREDIT b on BA.BUSINESSACCREDIT=b.id where a.staffno=? and b.businessstate=? and b.url=? and b.subuumstemcode = ?";
List<Map<String, Object>> list = queryList(sql, staffno, state, url, subuumstemcode);
return list;
}
}
| UTF-8 | Java | 1,679 | java | BusinessAccreditDao.java | Java | [
{
"context": "credit_admin ba join (select b.ID, b.LOGINNAME, b.USERNAME, b.PASSWORD, b.SEX, b.STAFFNO, b.EMAIL, b.PHONE, ",
"end": 995,
"score": 0.9737815260887146,
"start": 987,
"tag": "USERNAME",
"value": "USERNAME"
}
] | null | [] | package com.hgsoft.system.dao;
import com.hgsoft.common.dao.BaseDao;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Map;
@Repository
public class BusinessAccreditDao extends BaseDao{
public List<Map<String, Object>> findBusinessAccreditByURL(String url){
String sql="select * from csms_businessaccredit bt where url=? and bt.usestate='2'";
List<Map<String, Object>> list = queryList(sql, url);
return list;
}
public List<Map<String, Object>> findBusinessAccreditByURL(String url, String subuumstemcode){
String sql="select * from csms_businessaccredit bt where url=? and bt.usestate='2' and bt.subuumstemcode = ?";
List<Map<String, Object>> list = queryList(sql, url, subuumstemcode);
return list;
}
public List<Map<String, Object>> BusinessAccreditAdminByName(String staffno,String state,String url, String subuumstemcode) {
String sql="select * from csms_businessaccredit_admin ba join (select b.ID, b.LOGINNAME, b.USERNAME, b.PASSWORD, b.SEX, b.STAFFNO, b.EMAIL, b.PHONE, b.USERSTATE, b.USESTATE, b.IPLIMIT, b.LOGINTIME, b.LOGINIP, b.LASTLOGINTIME, b.LASTLOGINIP, b.REMARK, b.COMPANY, b.DEPARTMENT, b.DENAME, b.CREATEID, b.UPDATEID, b.CREATETIME, b.UPDATETIME, b.CUSTOMPOINT, b.POINTNAME, null as ADMINGROUP, b.CUSTOMPOINTTYPE, b.POINTCODE, a.subuumstem as subuumstemCode from uums_admin_subuumstem a join uums_admin b on a.admin = b.id ) a on ba.admin=a.id join CSMS_BUSINESSACCREDIT b on BA.BUSINESSACCREDIT=b.id where a.staffno=? and b.businessstate=? and b.url=? and b.subuumstemcode = ?";
List<Map<String, Object>> list = queryList(sql, staffno, state, url, subuumstemcode);
return list;
}
}
| 1,679 | 0.757594 | 0.756403 | 29 | 56.896553 | 122.822647 | 676 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.931035 | false | false | 10 |
368a50818ea9ad4cc776d734199158de87bae9fc | 28,346,784,211,233 | 706c9202b4ccdba66a272d3df0ae509754036f08 | /src/main/java/com/bhaiti/kela/controllers/UserControllerPOST.java | d045d96c22801136a5a89ced873122af5893befc | [] | no_license | ncezar/user_test | https://github.com/ncezar/user_test | 60684d47ae4c2e0cda92e7632cbe495df61c248d | 1fe3ac6e31a4f40de85aef5f8b9aeae1b23bf146 | refs/heads/master | 2021-05-21T22:36:56.610000 | 2020-04-03T20:38:02 | 2020-04-03T20:38:02 | 252,835,309 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bhaiti.kela.controllers;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bhaiti.kela.beans.User;
import com.bhaiti.kela.beans.UserRegistration;
import com.bhaiti.kela.beans.UserRegistrationReply;
public class UserControllerPOST {
@RequestMapping(method = RequestMethod.POST, value="/register/user")
@ResponseBody
public UserRegistrationReply registerUser(@RequestBody User user) {
System.out.println("In registerUser");
UserRegistrationReply usereply= new UserRegistrationReply();
UserRegistration.getInstance().add(user);
usereply.setEmail(user.getEmail());
usereply.setPass(user.getPass());
usereply.setStatus("Successful");
return usereply;
}
}
| UTF-8 | Java | 1,043 | java | UserControllerPOST.java | Java | [] | null | [] | package com.bhaiti.kela.controllers;
import java.util.List;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.bhaiti.kela.beans.User;
import com.bhaiti.kela.beans.UserRegistration;
import com.bhaiti.kela.beans.UserRegistrationReply;
public class UserControllerPOST {
@RequestMapping(method = RequestMethod.POST, value="/register/user")
@ResponseBody
public UserRegistrationReply registerUser(@RequestBody User user) {
System.out.println("In registerUser");
UserRegistrationReply usereply= new UserRegistrationReply();
UserRegistration.getInstance().add(user);
usereply.setEmail(user.getEmail());
usereply.setPass(user.getPass());
usereply.setStatus("Successful");
return usereply;
}
}
| 1,043 | 0.752637 | 0.752637 | 33 | 30.60606 | 25.575722 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.121212 | false | false | 10 |
a4758a0a02cc4e13da9745b963d8aa41b291a0e5 | 26,723,286,556,573 | c0271005128ccd0998686550bfb65a810550c973 | /IOPkgEx3.java | 913e031baf49891b8d7b1425f3786b152d0c3c82 | [] | no_license | suberadam/Java-programs | https://github.com/suberadam/Java-programs | d150eaad5aee29b064c1ae5ae82f705b9ebe8c93 | 0566ff9e9aa8f566479899397f3549f8df409923 | refs/heads/master | 2022-04-15T20:01:22.627000 | 2020-04-10T17:23:32 | 2020-04-10T17:23:32 | 254,693,545 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // accepting input from user System.in.read();
import java.io.*;
class Sample
{
public static void main(String args[]) throws Exception
{
int i; // accepting single character
FileOutputStream fos=new FileOutputStream("myfile1.txt");
System.out.println(" Type any text and press enter key ");
while ((i=System.in.read())!=-1)
{
fos.write(i);
}
//-1 means ctrl+c (EOF) , 13 means enterkey
fos.close();
}
}
| UTF-8 | Java | 474 | java | IOPkgEx3.java | Java | [] | null | [] | // accepting input from user System.in.read();
import java.io.*;
class Sample
{
public static void main(String args[]) throws Exception
{
int i; // accepting single character
FileOutputStream fos=new FileOutputStream("myfile1.txt");
System.out.println(" Type any text and press enter key ");
while ((i=System.in.read())!=-1)
{
fos.write(i);
}
//-1 means ctrl+c (EOF) , 13 means enterkey
fos.close();
}
}
| 474 | 0.603376 | 0.592827 | 17 | 26.882353 | 22.697195 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false | 10 |
b10aebcd9712994cc66c541d90a23e63f6dba7dd | 31,834,297,639,074 | abf3a88a10f07aae8211f23dc1432bbe52a3d566 | /src/main/java/com/rajkumar/spring/beans/package-info.java | 7f37291ce2d4e41bf3b00592cbf511130cc10ff9 | [] | no_license | rajdhandus/spring-tutorial-5 | https://github.com/rajdhandus/spring-tutorial-5 | dfbbba870e8a9ab85d830dcb10329f3fa4dd6f83 | 76a295295f77a31352218ca81ba4717009b130f5 | refs/heads/master | 2021-01-16T18:55:31.128000 | 2017-12-07T16:15:35 | 2017-12-07T16:15:35 | 100,129,251 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
/**
* @author rajkumarpurushothaman
*
*/
package com.rajkumar.spring.beans; | UTF-8 | Java | 90 | java | package-info.java | Java | [
{
"context": "/**\n * \n */\n/**\n * @author rajkumarpurushothaman\n *\n */\npackage com.rajkumar.spring.beans;",
"end": 48,
"score": 0.7436195015907288,
"start": 27,
"tag": "NAME",
"value": "rajkumarpurushothaman"
}
] | null | [] | /**
*
*/
/**
* @author rajkumarpurushothaman
*
*/
package com.rajkumar.spring.beans; | 90 | 0.622222 | 0.622222 | 8 | 10.375 | 13.076099 | 34 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.125 | false | false | 10 |
b3bc79cfcf161e915e55972be93aacb277eb272b | 33,629,593,973,396 | 447e18d725685c3549947ff9c0fde27b530c8440 | /src/main/java/com/shashank/spring/documentupload/serviceImpl/FileStore.java | 84aa263a6dee788105775d726fdd496d4cb91391 | [] | no_license | Shashank1116/S3-Spring-Document-Upload | https://github.com/Shashank1116/S3-Spring-Document-Upload | e6034f84073ebb8f8b4d929e45d5199a60dd0870 | 66c85e3087f0408ed0c8b189bb825c30b8165e69 | refs/heads/master | 2023-06-17T13:02:05.350000 | 2021-06-29T13:13:27 | 2021-06-29T13:13:27 | 378,218,883 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.shashank.spring.documentupload.serviceImpl;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.*;
import com.amazonaws.util.IOUtils;
import com.shashank.spring.documentupload.config.BucketName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.swing.text.html.Option;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
@Service
public class FileStore {
private final AmazonS3 amazonS3;
@Autowired
FileStore(AmazonS3 amazonS3){
this.amazonS3 = amazonS3;
}
public String upload(MultipartFile file,String path) throws IllegalStateException{
String bucketPath = String.format("%s", BucketName.SHASHANK.getBucketName());
Map<String, String> metaData = new HashMap<>();
metaData.put("Content-Type",file.getContentType());
metaData.put("Content-Length",String.valueOf(file.getSize()));
String filePath = path+"/"+file.getOriginalFilename();
ObjectMetadata objectMetadata = new ObjectMetadata();
metaData.forEach(objectMetadata::addUserMetadata);
try {
amazonS3.putObject(bucketPath, path, file.getInputStream(), objectMetadata);
} catch (AmazonServiceException | IOException exception) {
throw new IllegalStateException("Failed to upload the file", exception);
}
return bucketPath+"/"+path;
}
public byte[] download(String path, String key) {
try {
S3Object object = amazonS3.getObject(path, key);
S3ObjectInputStream objectContent = object.getObjectContent();
return IOUtils.toByteArray(objectContent);
} catch (AmazonServiceException | IOException e) {
throw new IllegalStateException("Failed to download the file", e);
}
}
} | UTF-8 | Java | 2,094 | java | FileStore.java | Java | [] | null | [] | package com.shashank.spring.documentupload.serviceImpl;
import com.amazonaws.AmazonServiceException;
import com.amazonaws.services.s3.AmazonS3;
import com.amazonaws.services.s3.model.*;
import com.amazonaws.util.IOUtils;
import com.shashank.spring.documentupload.config.BucketName;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import javax.swing.text.html.Option;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import java.util.function.BiConsumer;
@Service
public class FileStore {
private final AmazonS3 amazonS3;
@Autowired
FileStore(AmazonS3 amazonS3){
this.amazonS3 = amazonS3;
}
public String upload(MultipartFile file,String path) throws IllegalStateException{
String bucketPath = String.format("%s", BucketName.SHASHANK.getBucketName());
Map<String, String> metaData = new HashMap<>();
metaData.put("Content-Type",file.getContentType());
metaData.put("Content-Length",String.valueOf(file.getSize()));
String filePath = path+"/"+file.getOriginalFilename();
ObjectMetadata objectMetadata = new ObjectMetadata();
metaData.forEach(objectMetadata::addUserMetadata);
try {
amazonS3.putObject(bucketPath, path, file.getInputStream(), objectMetadata);
} catch (AmazonServiceException | IOException exception) {
throw new IllegalStateException("Failed to upload the file", exception);
}
return bucketPath+"/"+path;
}
public byte[] download(String path, String key) {
try {
S3Object object = amazonS3.getObject(path, key);
S3ObjectInputStream objectContent = object.getObjectContent();
return IOUtils.toByteArray(objectContent);
} catch (AmazonServiceException | IOException e) {
throw new IllegalStateException("Failed to download the file", e);
}
}
} | 2,094 | 0.715377 | 0.709169 | 61 | 33.344261 | 27.761209 | 89 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.754098 | false | false | 10 |
c793d19cec841ade6eed5babdb682d788226e9be | 9,423,158,307,522 | ff0c7a1311cfcd6f45f1045b88008e8fc5d0393d | /src/test/java/com/selenium/stepdef/CalculatorTest.java | 97b3aa767d8d570663ae50d89448cf4bbbcbb12d | [] | no_license | prachi1983/automation-cucumber | https://github.com/prachi1983/automation-cucumber | 02409e9cfa8cda17456a05202fd7cfc2e9320bf2 | 7a584226d871a828003d55db2421fa5c1af48df1 | refs/heads/master | 2023-06-21T17:16:35.216000 | 2021-07-11T09:51:31 | 2021-07-11T09:51:31 | 384,911,112 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.selenium.stepdef;
import org.junit.Assert;
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.support.ui.Select;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
public class CalculatorTest {
WebDriver w;
Select sel;
@Before
public void preCondition() {
WebDriverManager.chromedriver().setup();
w = new ChromeDriver();
}
@Given("Application url for testing")
public void application_url_for_testing() {
w.get("https://juliemr.github.io/protractor-demo/");
}
@When("User should enter two enter and perform Addition operation")
public void user_should_enter_two_enter_and_perform_addition_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("7");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("+");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("3");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Addition.")
public void result_should_get_display_and_verify_output_value_for_addition() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("10", actualOutput);
}
@When("User should enter two enter and perform Subtraction operation")
public void user_should_enter_two_enter_and_perform_subtraction_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("4");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("-");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("2");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Subtraction.")
public void result_should_get_display_and_verify_output_value_for_subtraction() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("2", actualOutput);
}
@When("User should enter two enter and perform Multiplication operation")
public void user_should_enter_two_enter_and_perform_multiplication_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("3");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("*");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("4");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Multiplication.")
public void result_should_get_display_and_verify_output_value_for_multiplication() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("12", actualOutput);
}
@When("User should enter two enter and perform Division operation")
public void user_should_enter_two_enter_and_perform_division_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("4");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("/");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("2");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Division.")
public void result_should_get_display_and_verify_output_value_for_division() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("2", actualOutput);
}
@After
public void postCondition() {
w.quit();
}
}
| UTF-8 | Java | 4,167 | java | CalculatorTest.java | Java | [
{
"context": "import io.cucumber.java.en.When;\nimport io.github.bonigarcia.wdm.WebDriverManager;\n\npublic class CalculatorTes",
"end": 449,
"score": 0.9832676649093628,
"start": 439,
"tag": "USERNAME",
"value": "bonigarcia"
}
] | null | [] | package com.selenium.stepdef;
import org.junit.Assert;
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.support.ui.Select;
import io.cucumber.java.After;
import io.cucumber.java.Before;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import io.github.bonigarcia.wdm.WebDriverManager;
public class CalculatorTest {
WebDriver w;
Select sel;
@Before
public void preCondition() {
WebDriverManager.chromedriver().setup();
w = new ChromeDriver();
}
@Given("Application url for testing")
public void application_url_for_testing() {
w.get("https://juliemr.github.io/protractor-demo/");
}
@When("User should enter two enter and perform Addition operation")
public void user_should_enter_two_enter_and_perform_addition_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("7");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("+");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("3");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Addition.")
public void result_should_get_display_and_verify_output_value_for_addition() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("10", actualOutput);
}
@When("User should enter two enter and perform Subtraction operation")
public void user_should_enter_two_enter_and_perform_subtraction_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("4");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("-");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("2");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Subtraction.")
public void result_should_get_display_and_verify_output_value_for_subtraction() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("2", actualOutput);
}
@When("User should enter two enter and perform Multiplication operation")
public void user_should_enter_two_enter_and_perform_multiplication_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("3");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("*");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("4");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Multiplication.")
public void result_should_get_display_and_verify_output_value_for_multiplication() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("12", actualOutput);
}
@When("User should enter two enter and perform Division operation")
public void user_should_enter_two_enter_and_perform_division_operation() {
w.findElement(By.cssSelector("input[ng-model='first']")).sendKeys("4");
WebElement operator = w.findElement(By.cssSelector("select[ng-model='operator']"));
sel = new Select(operator);
sel.selectByVisibleText("/");
w.findElement(By.cssSelector("input[ng-model='second']")).sendKeys("2");
w.findElement(By.id("gobutton")).click();
}
@Then("Result should get display and verify output value for Division.")
public void result_should_get_display_and_verify_output_value_for_division() throws Exception {
Thread.sleep(2000);
String actualOutput = w.findElement(By.cssSelector("h2.ng-binding")).getText();
Assert.assertEquals("2", actualOutput);
}
@After
public void postCondition() {
w.quit();
}
}
| 4,167 | 0.733381 | 0.725222 | 146 | 27.534246 | 31.462996 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.191781 | false | false | 10 |
a79d51fd0d69688c81a847de96972aea55a3eb53 | 8,383,776,211,876 | aff743f2446e8f11a98d899dcc5ad1623c993219 | /src/Fliperamemoria.java | 12f16387b12a14ce5f3d12fc188aadedeaf8ebcd | [] | no_license | pigortekids/Fliperamemoria | https://github.com/pigortekids/Fliperamemoria | 64be0ec22508b9c2be09dcb2d07938a27d591054 | f74ec93ac72163cf503ecc17de04f02c8a30b335 | refs/heads/master | 2021-06-19T21:20:18.528000 | 2017-05-18T02:25:34 | 2017-05-18T02:25:34 | 91,639,447 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class Fliperamemoria {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int linhas = 8;
int colunas = 8;
int quantBarras = (linhas*colunas)/5;
Campo campo = new Campo(linhas, colunas, quantBarras);
campo.fazerCampo(6, 20);
campo.mostrarCampo(false, false);
int x = campo.getBola().getX();
int y = campo.getBola().getY();
campo.setBarrasVisivel(false);
System.out.println("Press Enter to continue...");
scanner.nextLine();
System.out.println();
System.out.println();
campo.mostrarCampo(false, true);
System.out.println("Press Enter to continue...");
scanner.nextLine();
while(campo.getBola().getX()>-1 && campo.getBola().getX()<campo.getTamanhoX() &&
campo.getBola().getY()>-1 && campo.getBola().getY()<campo.getTamanhoY()){
campo.mostrarCampo(true, true);
System.out.println("Press Enter to continue...");
scanner.nextLine();
if(campo.temNoCampo(quantBarras, campo.getBola().getX(), campo.getBola().getY()) == -1){
campo.moveBola();
}
else{
campo.tornarVisivel(campo.getBola().getX(), campo.getBola().getY());
campo.moveBola(campo.getAngulacao(campo.getBola().getX(), campo.getBola().getY()));
}
System.out.println();
System.out.println();
}
System.out.println("ACABOU");
campo.setBarrasVisivel(true);
campo.mostrarCampo(true, true);
}
}
| UTF-8 | Java | 1,704 | java | Fliperamemoria.java | Java | [] | null | [] | import java.util.Scanner;
public class Fliperamemoria {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int linhas = 8;
int colunas = 8;
int quantBarras = (linhas*colunas)/5;
Campo campo = new Campo(linhas, colunas, quantBarras);
campo.fazerCampo(6, 20);
campo.mostrarCampo(false, false);
int x = campo.getBola().getX();
int y = campo.getBola().getY();
campo.setBarrasVisivel(false);
System.out.println("Press Enter to continue...");
scanner.nextLine();
System.out.println();
System.out.println();
campo.mostrarCampo(false, true);
System.out.println("Press Enter to continue...");
scanner.nextLine();
while(campo.getBola().getX()>-1 && campo.getBola().getX()<campo.getTamanhoX() &&
campo.getBola().getY()>-1 && campo.getBola().getY()<campo.getTamanhoY()){
campo.mostrarCampo(true, true);
System.out.println("Press Enter to continue...");
scanner.nextLine();
if(campo.temNoCampo(quantBarras, campo.getBola().getX(), campo.getBola().getY()) == -1){
campo.moveBola();
}
else{
campo.tornarVisivel(campo.getBola().getX(), campo.getBola().getY());
campo.moveBola(campo.getAngulacao(campo.getBola().getX(), campo.getBola().getY()));
}
System.out.println();
System.out.println();
}
System.out.println("ACABOU");
campo.setBarrasVisivel(true);
campo.mostrarCampo(true, true);
}
}
| 1,704 | 0.553404 | 0.548122 | 46 | 36.04348 | 25.239683 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.869565 | false | false | 10 |
8e5156935fffa72d8b28f9bbbe9871ea84485865 | 20,693,152,486,773 | 3a859a920abee10e28b833feda5734f71158ad87 | /src/main/java/com/ningpai/charts/bean/DataVo.java | 92e165f39462dc7a5cbb7c1368a8bde09223fbcd | [] | no_license | okeeper/jietongda | https://github.com/okeeper/jietongda | 84aef7ee2223ee91efc77c76f5fe297b8a97f611 | 9eed9b0d87aa912b40e264bffdd8b5d6ae6a111f | refs/heads/master | 2019-08-29T18:33:04.443000 | 2014-12-12T09:58:43 | 2014-12-12T09:58:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2013 NINGPAI, Inc.All rights reserved.
* NINGPAI PROPRIETARY / CONFIDENTIAL.USE is subject to licence terms.
*/
package com.ningpai.charts.bean;
/**
* 成交量vo
* @version 创建时间:2013年11月25日 上午11:52:35
* @author zhangyue
*/
public class DataVo {
private Integer x;
private Long y;
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Long getY() {
return y;
}
public void setY(Long y) {
this.y = y;
}
}
| UTF-8 | Java | 594 | java | DataVo.java | Java | [
{
"context": "* @version 创建时间:2013年11月25日 上午11:52:35\r\n * @author zhangyue\r\n */\r\npublic class DataVo {\r\n private Integer ",
"end": 243,
"score": 0.9948968291282654,
"start": 235,
"tag": "USERNAME",
"value": "zhangyue"
}
] | null | [] | /*
* Copyright 2013 NINGPAI, Inc.All rights reserved.
* NINGPAI PROPRIETARY / CONFIDENTIAL.USE is subject to licence terms.
*/
package com.ningpai.charts.bean;
/**
* 成交量vo
* @version 创建时间:2013年11月25日 上午11:52:35
* @author zhangyue
*/
public class DataVo {
private Integer x;
private Long y;
public Integer getX() {
return x;
}
public void setX(Integer x) {
this.x = x;
}
public Long getY() {
return y;
}
public void setY(Long y) {
this.y = y;
}
}
| 594 | 0.552817 | 0.521127 | 29 | 17.586206 | 16.140583 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.275862 | false | false | 10 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.