id stringlengths 36 36 | text stringlengths 1 1.25M |
|---|---|
c9d911e5-5b74-41ae-8f8c-514a0a2012a5 | public void destroy() {
// Empty method
} |
c44ac9b8-e5ed-4bda-be0f-7bc6c0903356 | public void doFilter(final ServletRequest req, final ServletResponse resp, final FilterChain chain) throws ServletException, IOException {
final LoggingRequestWrapper requestWrapper = new LoggingRequestWrapper((HttpServletRequest) req);
final LoggingResponseWrapper responseWrapper = new LoggingResponseWrap... |
d839d4f7-e9c5-4dc2-b54d-58fefb562861 | public TeeServletOutputStream(OutputStream outOne, OutputStream outTwo) {
target = new TeeOutputStream(outOne, outTwo);
} |
eac32a7c-faef-4c39-b55a-7b7863f1da33 | @Override
public void write(int b) throws IOException {
target.write(b);
} |
f59cd5e4-13a7-4040-b874-233050c60132 | @Override
public void close() throws IOException {
target.close();
} |
2473d698-e071-49cf-8e85-8a7cb3a61d57 | @Override
public void flush() throws IOException {
target.flush();
} |
5e0e8ee1-43a1-41ed-8959-41aed93a279a | @Override
public void write(byte[] b, int off, int len) throws IOException {
target.write(b, off, len);
} |
b4232c75-97cd-440e-9f0b-43dd9a2a6229 | @Override
public void write(byte[] b) throws IOException {
target.write(b);
} |
54b31aad-904f-4c64-b27f-d43fb25e866e | public LoggingRequestWrapper(HttpServletRequest request) throws IOException {
super(request);
// Call get parameter first to ensure that form data (application/x-www-form-urlencoded) gets
// parsed and put in request map
request.getParameterMap();
StringBuilder stringBuilder = new StringBuilder();
Buffe... |
cf513b64-cf89-45c7-9453-5eaf3531e369 | @Override
public ServletInputStream getInputStream() throws IOException {
final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body.getBytes());
ServletInputStream servletInputStream = new ServletInputStream() {
public int read() throws IOException {
return byteArrayInputStream.read();... |
f976e887-7044-4a17-8509-4a9aac122f55 | public int read() throws IOException {
return byteArrayInputStream.read();
} |
949636aa-68c1-45d9-bf6b-be462765e94a | @Override
public BufferedReader getReader() throws IOException {
return new BufferedReader(new InputStreamReader(this.getInputStream()));
} |
57985c6c-9c4c-43cd-9dec-2782ac680cb4 | public String getBody() {
return body;
} |
7aa89364-845e-4b0f-8675-ebb17a1100be | public TeeWriter(PrintWriter writer1, Writer writer2) {
super(writer2);
writer = writer1;
} |
22c9865b-83d1-4637-b127-b2b3319adf7c | @Override
public void flush() {
super.flush();
writer.flush();
} |
42b4e33b-e1fa-4a9d-8689-d9e2c5bce90d | public void write(int c) {
super.write(c);
writer.write(c);
} |
7619dee8-77f2-4180-bb06-d32b5fbed875 | public void write(char[] buf, int offset, int len) {
super.write(buf, offset, len);
writer.write(buf, offset, len);
} |
f39db373-907e-4bad-a0f7-d0ccdfe6766d | public void write(String str, int offset, int len) {
super.write(str, offset, len);
writer.write(str, offset, len);
} |
401f2981-b8b0-488b-86be-1ab15885923c | public PrintWriter format(String format, Object... args) {
super.format(format, args);
writer.format(format, args);
return this;
} |
1c2fb548-2a0b-4abf-8c9c-499a07e1ac5f | public PrintWriter format(Locale locale, String format, Object... args) {
super.format(locale, format, args);
writer.format(locale, format, args);
return this;
} |
97612289-8d28-4f69-9c34-e6fcd3bd1bcf | public LoggingResponseWrapper(HttpServletResponse response)
throws IOException {
super(response);
baOut = new ByteArrayOutputStream();
} |
eb39ccef-ce7e-4c27-8dbb-1cdace0bc900 | @Override
public ServletOutputStream getOutputStream() throws IOException {
return new TeeServletOutputStream(super.getOutputStream(), baOut);
} |
8c0654c1-8704-49fb-ae2d-0e079ca89609 | @Override
public PrintWriter getWriter() throws IOException {
return new TeeWriter(super.getWriter(), new PrintWriter(baOut, true));
} |
a31048f6-7acc-4bef-ba6c-c2f0b1ffdcf9 | public String getBody() {
return baOut.toString();
} |
d6a97600-89e5-495b-af73-78efd3250232 | @RequestMapping
public String getProductUpsells() {
return "ok";
} |
ef06367b-3cd7-40ba-8eb8-922c7cfe1c09 | public static void main(String[] args) {
SpringApplication.run(Application.class, args);
} |
0bc962b7-9e47-4491-83c4-6f109c9afedf | @Bean
public ServletRequestListener requestListener() {
return new RequestContextListener();
} |
715126fd-3dfa-4d91-abd0-a23728fa3cf2 | @Bean
public Filter loggingFilter() throws Exception {
return new RequestLoggingFilter();
} |
65acf0f7-e8c6-4035-b7cb-5d431e17328f | @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
} |
0737dc38-6036-4784-b15b-7740210dc444 | private DownloadManagerService() {
} |
e2454314-bf50-4447-bb4d-632501267d5e | @Override
public void setDownloadManagerStatus(String uri, String status) {
//To change body of implemented methods use File | Settings | File Templates.
} |
98b7d9a7-f375-4a87-88bf-10a4e60cc3f3 | @Override
public boolean removeDownload(String uri) {
return false; //To change body of implemented methods use File | Settings | File Templates.
} |
2fafff99-73fd-4ecc-a7a4-b6c33fdc286f | @Override
public Download addDownload(String uri, String directoryPath) {
Download download = new DownloadProcessor(directoryPath, uri);
downloadsPool.put(uri, download);
try {
download.onStart();
} catch (DownloadManagerException e) {
}
return download;... |
7cdc7d18-dc4d-440f-949e-180effad8643 | public static DownloadManagerService getInstance() {
if (instance == null) {
synchronized (DownloadManagerService.class) {
instance = new DownloadManagerService();
}
}
return instance;
} |
f60af3b5-4f62-4a12-97f5-b6d60aff1dc3 | public DownloadManagerException(String description) {
this(description, null);
} |
bce4ae23-600c-4a75-84fa-71661597a417 | public DownloadManagerException(String description, Throwable throwable) {
this.description = description;
this.throwable = throwable;
} |
2fc69c3d-30d7-473e-93dc-9c1bb5a6a026 | @Override
public String toString() {
return "DownloadManagerException{" +
"description='" + description + '\'' +
", throwable=" + throwable +
'}';
} |
ed52fb14-9718-40e0-b55c-8ff8f5718035 | public static String getFileNameFromUrl(URL url) {
if (url == null) {
throw new IllegalArgumentException("Input URL is null!");
}
String fileName = url.getFile();
return fileName.substring(fileName.lastIndexOf("/") + 1);
} |
7f02b426-a891-4038-9d06-b4089f9181ae | public DownloadProcessor(String directoryPath, String fileUrl) {
this.directoryPath = directoryPath;
this.fileUrl = fileUrl;
} |
9458e6bb-4589-40f3-8922-b9fda1004b09 | @Override
public void onStart() {
if (downloadStatus == DownloadManager.DownloadStatus.DOWNLOADING ||
downloadStatus == DownloadManager.DownloadStatus.DOWNLOADED) {
throw new DownloadManagerException(String.format("Cant start %s download, because download status: %s",
... |
38a30d3d-cc91-4787-84ef-13ba8db83b84 | @Override
public void onPause() {
downloadStatus = DownloadManager.DownloadStatus.STOP;
downloadBytesCounter = 0;
if (currentThread.isAlive()) {
currentThread.interrupt();
}
} |
fbc5633f-1b5a-4db5-943c-cfcf0f706533 | @Override
public void onStop() {
downloadStatus = DownloadManager.DownloadStatus.STOP;
downloadBytesCounter = 0;
if (currentThread.isAlive()) currentThread.interrupt();
} |
767eb7a4-d565-4e64-a077-1f09086c6ec9 | @Override
public void setDownloadStatus(DownloadManager.DownloadStatus downloadStatus) {
this.downloadStatus = downloadStatus;
} |
ba835af7-13f2-471f-8896-4b6d65dbee5b | @Override
public DownloadManager.DownloadStatus getDownloadStatus() {
return downloadStatus;
} |
9b48faab-87dd-46bf-a790-d2387cfd907d | @Override
public void run() {
RandomAccessFile file = null;
InputStream inputStream = null;
try {
URL url = new URL(fileUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
/*
Here we send to server count of bytes wh... |
52f18d8f-5a64-430d-b701-c401ad0441b5 | @Override
public String toString() {
return "DownloadProcessor{" +
"downloadBytesCounter=" + downloadBytesCounter +
", contentSize=" + contentSize +
", directoryPath='" + directoryPath + '\'' +
", fileUrl='" + fileUrl + '\'' +
"... |
736e68c0-799c-428f-a2a9-1928fbb0ced5 | void onStart(); |
525c951d-34e7-41e4-aaa5-49e10ea685dc | void onPause(); |
13e0f29d-0a7e-46f9-a8c2-3d64b718eae7 | void onStop(); |
7bc3dcd5-a5b0-4c37-b38d-f1d4f6c677f1 | void setDownloadStatus(DownloadManager.DownloadStatus downloadStatus); |
c01b2ebf-eeeb-4a5b-aa2f-aa854fb2dffe | DownloadManager.DownloadStatus getDownloadStatus(); |
38aea254-ca0d-4ce5-99cb-c2d01688e278 | void setDownloadManagerStatus(String uri, String status); |
793179d3-0440-4e67-96ce-885893672423 | boolean removeDownload(String uri); |
af9196bb-4b29-4fcb-9b23-215fff4e27e7 | Download addDownload(String uri, String directoryPath); |
34109973-b9ab-4548-b7ca-56a8c53863f2 | @Before
public void setUp() {
} |
71ee247f-47d4-49b5-9f16-f9ba867f54d9 | @Test
public void shouldPutDownloadInPollWhenAddDownloadAction() {
String uri = "test";
String directory = "test";
service.addDownload(uri, directory);
verify(downloadsPool).put(anyString(), Matchers.<Download>anyObject());
} |
6e1bd6a9-adec-4783-9def-84e707248f01 | @Test
public void shouldReturnDownloadInAddDownloadAction() {
String uri = "test";
String directory = "test";
Download download = service.addDownload(uri, directory);
assertNotNull(download);
} |
05f1f691-a83d-4209-859d-f24451fcdd29 | public PlayerProtocol() {
// no entry means empty cell
// 0 means 0 for this combination
} |
87a5f8f8-9f31-4dee-bf16-709bf3bc94cb | public int getSum() {
int sum = 0;
for (Integer i : values.values()) {
sum += i;
}
Integer one = values.get(Combination.ONE);
Integer two = values.get(Combination.TWO);
Integer three = values.get(Combination.THREE);
Integer four = values.get(Combinati... |
1d2550d3-d7a0-493c-ae31-dd045eb1102a | public void put(Combination c, int i) {
values.put(c, i);
} |
cd7a2571-f206-4890-a239-9ae380f1ee5a | Server() {
setTitle("ะััะธ Server");
setSize(300, 300);
final JTextArea messages = new JTextArea();
add(messages);
addWindowListener(new WindowAdapter(){
@Override
public void windowClosing(WindowEvent e) {
System.exit(0);
}
... |
762397c6-e842-431b-abd5-5aa721324de6 | @Override
public void windowClosing(WindowEvent e) {
System.exit(0);
} |
112f3774-f0cf-4bb4-af92-d551e80ae57b | @Override
public void actionPerformed(ActionEvent e) {
} |
35c8edd3-ecf1-4312-b5bd-f95ac0648b4c | public static void main(String[] args) {
new Server();
} |
9df7aa83-aecd-4c03-ae4e-38dc7cb84e29 | public static int getSum(int[] nums, Combination c) {
switch (c) {
case ECCI:
int num = nums[0];
for (int i = 1; i < nums.length; i++) {
if (nums[i] != num) {
return 0;
}
}
... |
1b32282a-a7f6-4434-9c8d-ba9d438c3f1a | private static int[] getQuantityArray(int[] nums, Combination c) {
int[] qArray = new int[7]; // 1..6 are actually used
for (int i = 0; i < nums.length; i++) {
++qArray[nums[i]];
}
return qArray;
} |
d9fc81fd-b6b3-4f34-887f-387f33ae666c | private static int countNumberCombination(int[] nums, Combination c) {
int number;
int sum = 0;
switch (c) {
case ONE:
number = 1;
break;
case TWO:
number = 2;
break;
case THREE:
n... |
665f708c-0e9c-433f-92f5-bb682f0cfc03 | public SocketThread(Socket playerSocket, JTextArea messages) {
this.playerSocket = playerSocket;
this.messages = messages;
} |
dbfad54f-5598-4038-bf33-89dbcaa4541d | @Override
public void run() {
try {
in = new Scanner(playerSocket.getInputStream());
out = new PrintWriter(playerSocket.getOutputStream());
out.println("What is your name?");
out.flush();
boolean isName = true;
while (isName) {
... |
7d07f638-c701-4f77-9577-496e74c5287a | @Before
public void setUp() {
game = new LadderGameController();
} |
d3684987-70a2-489a-8633-c13bd27aa783 | @Test(expected = RuntimeException.class)
public void testInvalidPlayer() {
int player = 0;
game.init(player, TEST_ROW_SMALL_SIZE);
} |
87e6e481-ea9f-4e30-96df-49c3eced6582 | @Test(expected = RuntimeException.class)
public void testInvalidEndRow() {
int player = 3;
game.init(player, 0);
} |
2222e3bf-072a-43b5-9641-9b48e0e1d988 | @Test
public void testRunWithOnePlayer() {
int player = 1;
game.setUserLadderInfo(getSamepleLadderInfoByOnePlayer());
game.init(player, TEST_ROW_SMALL_SIZE);
assertThat(game.run(player), is(1));
} |
6b6c7b48-9947-4c6d-aeb4-ca2e4405d3e4 | @Test
public void testRunWithTwoPlayer() {
int player = 2;
game.setUserLadderInfo(getSampleLadderInfoByTwoPlayer());
game.init(player, TEST_ROW_SMALL_SIZE);
int playerNo = 1;
assertThat(game.run(playerNo), is(2));
playerNo = 2;
assertThat(game.run(playerNo), is(1));
} |
cba31ce7-b45c-4475-81be-e8b4cd758a1d | @Test
public void testRunWithThreePlayer() {
int player = 3;
game.setUserLadderInfo(getSampleLadderInfoByThreePlayer());
game.init(player, TEST_ROW_SMALL_SIZE);
int playerNo = 1;
assertThat(game.run(playerNo), is(2));
playerNo = 2;
assertThat(game.run(playerNo), is(1));
playerNo = 3;
assertThat(ga... |
930ee2c6-9b27-486b-97a3-c53f1437d31a | @Test
public void testRunWithLadderGameInRequesteInfo() {
int player = 6;
game.setUserLadderInfo(getSampleLadderInfoByRequest());
game.init(player, TEST_ROW_BIG_SIZE);
int playerNo = 1;
assertThat(game.run(playerNo), is(6));
playerNo = 2;
assertThat(game.run(playerNo), is(4));
playerNo = 3;
assert... |
2d435c80-5727-4e15-87d6-113d4fec53b7 | @Test
public void testRandomLadderGame() {
int player = 6;
game.init(player, TEST_ROW_BIG_SIZE);
int[] actualResult = new int[player];
for (int i = 1; i < player + 1; i++) {
int resultNo = game.run(i);
actualResult[resultNo - 1] = 1;
}
for (int num : actualResult) {
assertThat(num, is(1))... |
3779d655-72a8-4177-8e92-79858a6e183b | private int[][] getSamepleLadderInfoByOnePlayer() {
int[][] sampleLadder = { { 0 }, { 0 }, { 0 }, { 0 }, { 0 }};
return sampleLadder;
} |
914a6926-824f-4ed4-8271-63bb8165c4e9 | private int[][] getSampleLadderInfoByTwoPlayer() {
int[][] sampleLadder = { { 0, 0 }, { 1, -1 }, { 0, 0 }, { 1, -1 }, { 1, -1 } };
return sampleLadder;
} |
f8df78bb-7af9-41a8-b3d0-9612b101d8a0 | private int[][] getSampleLadderInfoByThreePlayer() {
int[][] sampleLadder = { { 0, 1, -1 },
{ 1, -1, 0 },
{ 1, -1, 0 },
{ 0, 1, -1 },
{ 1, -1, 0 } };
return sampleLadder;
} |
245a241c-204c-4b6a-9749-31f81ecf83d7 | private int[][] getSampleLadderInfoByRequest() {
int[][] sampleLadder = { { 1, -1, 0, 0, 0, 0 },
{ 0, 0, 0, 1, -1, 0 },
{ 0, 1, -1, 0, 1, -1 },
{ 0, 0, 1, -1, 0, 0 },
{ 0, 1, -1, 0, 1, -1 },
{ 1, -1, 0, 1, -1, 0 },
{ 0, 0, 1, -1, 1, -1 },
... |
8c91edea-76c1-4cd7-a94f-bf8584944469 | public int[][] getLadderInfo() {
return ladderInfo;
} |
65be5b7c-7e85-4eed-8be0-61357530b152 | public void setLadderInfo(int[][] ladderInfo) {
this.ladderInfo = ladderInfo;
} |
42c7af88-8fe0-4f26-9606-55d1b6b21d3b | public int getTotalRow() {
return totalRow;
} |
59b096c2-c2f1-4097-862b-7150f75fe6dc | public void setTotalRow(int totalRow) {
this.totalRow = totalRow;
} |
96c47922-e555-436a-985a-51e1866e0a24 | public int getPlayer() {
return player;
} |
86024f98-a1e2-49bb-99ee-97b68e7450f8 | public void setPlayer(int player) {
this.player = player;
} |
5158a78d-fc4a-496f-b3d8-69c539202652 | public void init(int player, int totalRow) {
view = new LadderGameView();
ladderGameBO = new LadderGameBO();
if (ladderGameBO.isInvalidPlayer(player) || ladderGameBO.isInvalidTotalRow(totalRow)) {
throw new RuntimeException();
}
ladderGameBO.setPlayer(player);
ladderGameBO.setTotalRow(totalRow);
... |
50d7df06-2d80-45e6-a271-89ecbe7dfb6b | public int run(int playerNo) {
view.printLadderGameInfo(playerNo);
if (ladderGameBO.getPlayer() == 1) {
view.printLadderGameResult(playerNo);
return playerNo;
}
int result = ladderGameBO.getLadderGameResult(playerNo, view);
view.printLadderGameResult(result);
return result;
} |
c3e99217-b449-4bb3-b15a-62ec881d859a | public void setUserLadderInfo(int[][] userLadderInfo) {
this.userLadderInfo = userLadderInfo;
} |
35ba5d4b-cd2a-4c80-9c93-be7ed9ee24e5 | public void printLadderInfo(int totalRow,int player, int playerNo, int currentRow, int[][] ladderInfo) {
System.out.println("**** ์ฌ๋ค๋ฆฌ ์์น ๋ก๊ทธ ****");
for (int i = 0; i < totalRow; i++) {
for (int j = 0; j < player; j++) {
System.out.printf("%3d",ladderInfo[i][j]);
printCurrentLocation(playerNo, currentRow... |
638b8703-7964-4553-90a2-8925e50a91bc | public void printCurrentLocation(int playerNo, int currentRow, int i, int j) {
if ((playerNo == j) && (currentRow == i)) {
System.out.print("*");
return;
}
System.out.print(" ");
} |
91bf4449-c8f7-409b-8da3-609a6a6ba734 | public void printLadderGameInfo(int playerNo) {
System.out.println("**** ์ฌ๋ค๋ฆฌ ๊ฒ์์ ์์ํฉ๋๋ค. ****");
System.out.println("ํ์ฌ playerNo : " + playerNo + "\n");
} |
aff24ff2-9e83-4aa5-9f99-733a820486e1 | public void printLadderGameResult(int playerNo) {
System.out.println("***** ์ฌ๋ค๋ฆฌ ๊ฒ์ ๊ฒฐ๊ณผ์
๋๋ค. ****");
System.out.println("๋์ฐฉ ์ง์ : " + playerNo + "\n");
} |
abcc435f-a32a-470e-ac7f-e652a75c5ce1 | public LadderGameBO() {
if (this.ladderGameInfo == null) {
ladderGameInfo = new LadderGameInfo();
}
} |
743a3a9f-d1bf-4466-ae6e-8659f7892d6b | public void setPlayer(int player) {
ladderGameInfo.setPlayer(player);
} |
1b6822ac-51b3-4d8f-99d9-5373f1436bbb | public void setTotalRow(int totalRow) {
ladderGameInfo.setTotalRow(totalRow);
} |
a6d3cc6d-bfd6-4f75-bcf4-de0db5c35eea | public void setLadderInfo(int[][] userLadderInfo) {
if (userLadderInfo == null) {
ladderGameInfo.setLadderInfo(getRandomLadderInfo());
return;
}
ladderGameInfo.setLadderInfo(userLadderInfo);
} |
9e6cbb96-3d2b-4658-afc5-8bccc1a40b90 | public boolean isInvalidPlayer(int player) {
if (player < 1) {
return true;
}
return false;
} |
af870c72-9294-4c95-877d-0285cbae9321 | public boolean isInvalidTotalRow(int totalRow) {
if (totalRow > 10 || totalRow < 1) {
return true;
}
return false;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.