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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3ad2c38490b2f829157653f718b451a923422103 | 11,613,591,588,042 | eb9f655206c43c12b497c667ba56a0d358b6bc3a | /java/java-tests/testData/codeInsight/completion/normal/SecondTypeParameterExtends.java | 7d5a3c2d8b62448e86c37325ed1e4056e2c9cfc1 | [
"Apache-2.0"
]
| permissive | JetBrains/intellij-community | https://github.com/JetBrains/intellij-community | 2ed226e200ecc17c037dcddd4a006de56cd43941 | 05dbd4575d01a213f3f4d69aa4968473f2536142 | refs/heads/master | 2023-09-03T17:06:37.560000 | 2023-09-03T11:51:00 | 2023-09-03T12:12:27 | 2,489,216 | 16,288 | 6,635 | Apache-2.0 | false | 2023-09-12T07:41:58 | 2011-09-30T13:33:05 | 2023-09-12T03:37:30 | 2023-09-12T06:46:46 | 4,523,919 | 15,754 | 4,972 | 237 | null | false | false | interface Foo<T,V> {}
class Bar<T,V> {
Bar(Foo<? extends T, ? ext<caret>> foo) {}
}
| UTF-8 | Java | 94 | java | SecondTypeParameterExtends.java | Java | []
| null | []
| interface Foo<T,V> {}
class Bar<T,V> {
Bar(Foo<? extends T, ? ext<caret>> foo) {}
}
| 94 | 0.521277 | 0.521277 | 5 | 17.6 | 16.378035 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 15 |
3e3c85df3cc47b5b075b1aba07446950b6a0aff3 | 14,027,363,199,080 | 3852974e985dbb25c185b398c095513c148843ac | /src/com/prog32758/Heuristic.java | 96674250d29d2d86e111cebadacc5448b27b7614 | []
| no_license | LukaDL/KnightsTour | https://github.com/LukaDL/KnightsTour | 08e0e7f61511cedafbf22a8f312c42253e17320b | 14b7bfd0db574d2bb2bc9ed598f4cfebd368ea37 | refs/heads/master | 2020-04-14T13:49:14.761000 | 2019-01-02T19:14:55 | 2019-01-02T19:14:55 | 163,879,670 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.prog32758;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
public class Heuristic extends ChessBoard {
// Giving the board spaces the values for the heuristic method
public static int[][] heuristicBoard() {
int[][] spaces = new int[8][8];
for (int i = 0; i < 8; i+=7) {
spaces[i][0] = 2;
spaces[i][1] = 3;
spaces[i][2] = 4;
spaces[i][3] = 4;
spaces[i][4] = 4;
spaces[i][5] = 4;
spaces[i][6] = 3;
spaces[i][7] = 2;
}
for (int i = 1; i < 7; i+=5) {
spaces[i][0] = 3;
spaces[i][1] = 4;
spaces[i][2] = 6;
spaces[i][3] = 6;
spaces[i][4] = 6;
spaces[i][5] = 6;
spaces[i][6] = 4;
spaces[i][7] = 3;
}
for (int i = 2; i < 6; i++) {
spaces[i][0] = 4;
spaces[i][1] = 6;
spaces[i][2] = 8;
spaces[i][3] = 8;
spaces[i][4] = 8;
spaces[i][5] = 8;
spaces[i][6] = 6;
spaces[i][7] = 4;
}
return spaces;
}
// The static heuristic method
public static String runGame(int runTimes, int startX, int startY, String path) throws IOException {
// Adding string that will output the web page content
String output = "";
// Creating the file to write to
File file = new File(path + "/LekoLukaHeuristictMethod.txt");
file.createNewFile();
PrintWriter writer = new PrintWriter(file);
for (int trial = 1; trial <= runTimes; trial++) {
// Values for current place on the board
int currentX = startX;
int currentY = startY;
// Counter to display how many moves have been made
int moves = 0;
// Creating move directions
int[][] directions = moveOptions();
// Setting spaces to default number
int[][] spaces = blankBoard();
// Setting up values of the heuristic board
int[][] heuristicBoard = heuristicBoard();
boolean canGo = true;
// Run heuristic method
for (int i = 1; i < 65 && canGo; i++) {
spaces[currentY][currentX] = i;
// Selecting next random first move and will increment from there if the move is not possible
int randomMove = (int)(Math.random() * 8);
// Creating best move default value
int bestMove = 10;
// Creating best move index value
int bestIndex = 0;
// A check for individual moves
boolean check = false;
// Checking the location of the next move
for (int j = 0; j < 8; j++) {
int newX = directions[0][randomMove%8] + currentX;
int newY = directions[1][randomMove%8] + currentY;
// Check to see if the move is in bounds of the board
if (newX >= 0 && newY >= 0 && newX <= 7 && newY <= 7) {
// If the move is in bounds, check the current spaces heuristic value is less than previous one.
// If so, it will keep the heuristic value and the index of that value.
if (heuristicBoard[newY][newX] < bestMove && spaces[newY][newX] == 0) {
bestMove = heuristicBoard[newY][newX];
bestIndex = randomMove%8;
check = true;
}
}
randomMove++;
}
// Checking to see if a move was available
if (check) {
moves++;
} else {
canGo = false;
}
// Moving the knight to the best spot
currentX += directions[0][bestIndex];
currentY += directions[1][bestIndex];
}
// Writing to the file and adding to the html string
writer.println("Trial " + trial + ": The knight was able to successfully touch " + (moves+1) + " squares.");
output += "Trial " + trial + ": The knight was able to successfully touch " + (moves+1) + " squares.<br>";
// If there is only one trial, then the board is also displayed in both the text file and HTML
if (runTimes == 1) {
writer.printf(displayBoardValues(spaces));
output += pageDisplayBoardValues(spaces);
}
}
writer.close();
return output;
}
} | UTF-8 | Java | 4,033 | java | Heuristic.java | Java | []
| null | []
| package com.prog32758;
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.http.HttpServlet;
public class Heuristic extends ChessBoard {
// Giving the board spaces the values for the heuristic method
public static int[][] heuristicBoard() {
int[][] spaces = new int[8][8];
for (int i = 0; i < 8; i+=7) {
spaces[i][0] = 2;
spaces[i][1] = 3;
spaces[i][2] = 4;
spaces[i][3] = 4;
spaces[i][4] = 4;
spaces[i][5] = 4;
spaces[i][6] = 3;
spaces[i][7] = 2;
}
for (int i = 1; i < 7; i+=5) {
spaces[i][0] = 3;
spaces[i][1] = 4;
spaces[i][2] = 6;
spaces[i][3] = 6;
spaces[i][4] = 6;
spaces[i][5] = 6;
spaces[i][6] = 4;
spaces[i][7] = 3;
}
for (int i = 2; i < 6; i++) {
spaces[i][0] = 4;
spaces[i][1] = 6;
spaces[i][2] = 8;
spaces[i][3] = 8;
spaces[i][4] = 8;
spaces[i][5] = 8;
spaces[i][6] = 6;
spaces[i][7] = 4;
}
return spaces;
}
// The static heuristic method
public static String runGame(int runTimes, int startX, int startY, String path) throws IOException {
// Adding string that will output the web page content
String output = "";
// Creating the file to write to
File file = new File(path + "/LekoLukaHeuristictMethod.txt");
file.createNewFile();
PrintWriter writer = new PrintWriter(file);
for (int trial = 1; trial <= runTimes; trial++) {
// Values for current place on the board
int currentX = startX;
int currentY = startY;
// Counter to display how many moves have been made
int moves = 0;
// Creating move directions
int[][] directions = moveOptions();
// Setting spaces to default number
int[][] spaces = blankBoard();
// Setting up values of the heuristic board
int[][] heuristicBoard = heuristicBoard();
boolean canGo = true;
// Run heuristic method
for (int i = 1; i < 65 && canGo; i++) {
spaces[currentY][currentX] = i;
// Selecting next random first move and will increment from there if the move is not possible
int randomMove = (int)(Math.random() * 8);
// Creating best move default value
int bestMove = 10;
// Creating best move index value
int bestIndex = 0;
// A check for individual moves
boolean check = false;
// Checking the location of the next move
for (int j = 0; j < 8; j++) {
int newX = directions[0][randomMove%8] + currentX;
int newY = directions[1][randomMove%8] + currentY;
// Check to see if the move is in bounds of the board
if (newX >= 0 && newY >= 0 && newX <= 7 && newY <= 7) {
// If the move is in bounds, check the current spaces heuristic value is less than previous one.
// If so, it will keep the heuristic value and the index of that value.
if (heuristicBoard[newY][newX] < bestMove && spaces[newY][newX] == 0) {
bestMove = heuristicBoard[newY][newX];
bestIndex = randomMove%8;
check = true;
}
}
randomMove++;
}
// Checking to see if a move was available
if (check) {
moves++;
} else {
canGo = false;
}
// Moving the knight to the best spot
currentX += directions[0][bestIndex];
currentY += directions[1][bestIndex];
}
// Writing to the file and adding to the html string
writer.println("Trial " + trial + ": The knight was able to successfully touch " + (moves+1) + " squares.");
output += "Trial " + trial + ": The knight was able to successfully touch " + (moves+1) + " squares.<br>";
// If there is only one trial, then the board is also displayed in both the text file and HTML
if (runTimes == 1) {
writer.printf(displayBoardValues(spaces));
output += pageDisplayBoardValues(spaces);
}
}
writer.close();
return output;
}
} | 4,033 | 0.572279 | 0.550211 | 143 | 26.216784 | 23.985176 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.573426 | false | false | 15 |
3cf98c9cb7e60a569018f4a97df5f9b52b9a9e40 | 17,523,466,592,667 | ef6dce3cc9fb175b47a9c0ccec91a1ae4ccbf82c | /qa/test-db-util/src/main/java/org/camunda/bpm/qa/upgrade/util/ThrowBpmnErrorDelegate.java | 2265f17881e050f0d6b50556cd5e76178d5513ea | [
"Apache-2.0"
]
| permissive | camunda/camunda-bpm-platform | https://github.com/camunda/camunda-bpm-platform | a0cc0e65bab4fa890d050c77cfd56ce27caf2b04 | 391aebd914f365bcf4d8cdbd68d96af41335e0a9 | refs/heads/master | 2023-09-03T15:41:36.318000 | 2023-08-30T15:44:16 | 2023-08-30T15:44:16 | 7,420,937 | 3,545 | 1,592 | Apache-2.0 | false | 2023-09-14T07:42:23 | 2013-01-03T10:10:31 | 2023-09-14T06:45:05 | 2023-09-14T07:42:23 | 141,653 | 3,513 | 1,395 | 874 | Java | false | false | /*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.qa.upgrade.util;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.camunda.bpm.engine.delegate.JavaDelegate;
/**
* @author Thorben Lindhauer
*
*/
public class ThrowBpmnErrorDelegate implements JavaDelegate, ExecutionListener {
public static final String ERROR_INDICATOR_VARIABLE = "throwError";
public static final String ERROR_NAME_VARIABLE = "errorName";
public static final String EXCEPTION_INDICATOR_VARIABLE = "throwException";
public static final String EXCEPTION_MESSAGE_VARIABLE = "exceptionMessage";
public static final String DEFAULT_ERROR_NAME = ThrowBpmnErrorDelegate.class.getSimpleName();
public static final String DEFAULT_EXCEPTION_MESSAGE = DEFAULT_ERROR_NAME;
@Override
public void execute(DelegateExecution execution) throws Exception {
throwErrorIfRequested(execution);
throwExceptionIfRequested(execution);
}
@Override
public void notify(DelegateExecution execution) throws Exception {
execute(execution);
}
protected void throwErrorIfRequested(DelegateExecution execution) {
Boolean shouldThrowError = (Boolean) execution.getVariable(ERROR_INDICATOR_VARIABLE);
if (Boolean.TRUE.equals(shouldThrowError)) {
String errorName = (String) execution.getVariable(ERROR_NAME_VARIABLE);
if (errorName == null) {
errorName = DEFAULT_ERROR_NAME;
}
throw new BpmnError(errorName);
}
}
protected void throwExceptionIfRequested(DelegateExecution execution) {
Boolean shouldThrowException = (Boolean) execution.getVariable(EXCEPTION_INDICATOR_VARIABLE);
if (Boolean.TRUE.equals(shouldThrowException)) {
String exceptionMessage = (String) execution.getVariable(EXCEPTION_MESSAGE_VARIABLE);
if (exceptionMessage == null) {
exceptionMessage = DEFAULT_EXCEPTION_MESSAGE;
}
throw new ThrowBpmnErrorDelegateException(exceptionMessage);
}
}
public static class ThrowBpmnErrorDelegateException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ThrowBpmnErrorDelegateException(String message) {
super(message);
}
}
}
| UTF-8 | Java | 3,082 | java | ThrowBpmnErrorDelegate.java | Java | [
{
"context": ".bpm.engine.delegate.JavaDelegate;\n\n/**\n * @author Thorben Lindhauer\n *\n */\npublic class ThrowBpmnErrorDelegate implem",
"end": 1102,
"score": 0.9998524785041809,
"start": 1085,
"tag": "NAME",
"value": "Thorben Lindhauer"
}
]
| null | []
| /*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.qa.upgrade.util;
import org.camunda.bpm.engine.delegate.BpmnError;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.ExecutionListener;
import org.camunda.bpm.engine.delegate.JavaDelegate;
/**
* @author <NAME>
*
*/
public class ThrowBpmnErrorDelegate implements JavaDelegate, ExecutionListener {
public static final String ERROR_INDICATOR_VARIABLE = "throwError";
public static final String ERROR_NAME_VARIABLE = "errorName";
public static final String EXCEPTION_INDICATOR_VARIABLE = "throwException";
public static final String EXCEPTION_MESSAGE_VARIABLE = "exceptionMessage";
public static final String DEFAULT_ERROR_NAME = ThrowBpmnErrorDelegate.class.getSimpleName();
public static final String DEFAULT_EXCEPTION_MESSAGE = DEFAULT_ERROR_NAME;
@Override
public void execute(DelegateExecution execution) throws Exception {
throwErrorIfRequested(execution);
throwExceptionIfRequested(execution);
}
@Override
public void notify(DelegateExecution execution) throws Exception {
execute(execution);
}
protected void throwErrorIfRequested(DelegateExecution execution) {
Boolean shouldThrowError = (Boolean) execution.getVariable(ERROR_INDICATOR_VARIABLE);
if (Boolean.TRUE.equals(shouldThrowError)) {
String errorName = (String) execution.getVariable(ERROR_NAME_VARIABLE);
if (errorName == null) {
errorName = DEFAULT_ERROR_NAME;
}
throw new BpmnError(errorName);
}
}
protected void throwExceptionIfRequested(DelegateExecution execution) {
Boolean shouldThrowException = (Boolean) execution.getVariable(EXCEPTION_INDICATOR_VARIABLE);
if (Boolean.TRUE.equals(shouldThrowException)) {
String exceptionMessage = (String) execution.getVariable(EXCEPTION_MESSAGE_VARIABLE);
if (exceptionMessage == null) {
exceptionMessage = DEFAULT_EXCEPTION_MESSAGE;
}
throw new ThrowBpmnErrorDelegateException(exceptionMessage);
}
}
public static class ThrowBpmnErrorDelegateException extends RuntimeException {
private static final long serialVersionUID = 1L;
public ThrowBpmnErrorDelegateException(String message) {
super(message);
}
}
}
| 3,071 | 0.762816 | 0.761194 | 86 | 34.837208 | 32.456718 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.348837 | false | false | 15 |
b17d1ec79b549e60af95084e52494df232d7e023 | 17,523,466,594,898 | 0d47372d99db5c3b09f4dd65149d18d15f739d20 | /src/main/java/egovframework/injeinc/boffice/sy/fileupload/vo/FileUploadVo.java | a501d8ddbde00b65d9b0bd54aa6b16af50f32114 | []
| no_license | siwon95/nia | https://github.com/siwon95/nia | 52a059225756304308af2997bc7043dad8cfc970 | 1b6ccffd386f2a66ed300c4a9efb28053989b72b | refs/heads/master | 2022-12-26T17:15:37.919000 | 2020-09-25T09:13:10 | 2020-09-25T09:13:10 | 297,583,436 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package egovframework.injeinc.boffice.sy.fileupload.vo;
import egovframework.cmm.ComDefaultVO;
@SuppressWarnings("serial")
public class FileUploadVo extends ComDefaultVO{
private String fuIdx = "";
private String fuGroup = "";
private String fuPkidx = "";
private String fuPath = "";
private String fuName = "";
private String fuRename = "";
private String fuSize = "";
private String fuMime = "";
private String fuFormat = "";
private int fuDown = 0;
private String useYn = "";
private String regDt = "";
private String regId = "";
private String modDt = "";
private String modId = "";
public String getFuIdx() {
return fuIdx;
}
public void setFuIdx(String fuIdx) {
this.fuIdx = fuIdx;
}
public String getFuGroup() {
return fuGroup;
}
public void setFuGroup(String fuGroup) {
this.fuGroup = fuGroup;
}
public String getFuPkidx() {
return fuPkidx;
}
public void setFuPkidx(String fuPkidx) {
this.fuPkidx = fuPkidx;
}
public String getFuPath() {
return fuPath;
}
public void setFuPath(String fuPath) {
this.fuPath = fuPath;
}
public String getFuName() {
return fuName;
}
public void setFuName(String fuName) {
this.fuName = fuName;
}
public String getFuRename() {
return fuRename;
}
public void setFuRename(String fuRename) {
this.fuRename = fuRename;
}
public String getFuSize() {
return fuSize;
}
public void setFuSize(String fuSize) {
this.fuSize = fuSize;
}
public String getFuMime() {
return fuMime;
}
public void setFuMime(String fuMime) {
this.fuMime = fuMime;
}
public String getFuFormat() {
return fuFormat;
}
public void setFuFormat(String fuFormat) {
this.fuFormat = fuFormat;
}
public int getFuDown() {
return fuDown;
}
public void setFuDown(int fuDown) {
this.fuDown = fuDown;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
public String getRegDt() {
return regDt;
}
public void setRegDt(String regDt) {
this.regDt = regDt;
}
public String getRegId() {
return regId;
}
public void setRegId(String regId) {
this.regId = regId;
}
public String getModDt() {
return modDt;
}
public void setModDt(String modDt) {
this.modDt = modDt;
}
public String getModId() {
return modId;
}
public void setModId(String modId) {
this.modId = modId;
}
}
| UTF-8 | Java | 2,366 | java | FileUploadVo.java | Java | []
| null | []
| package egovframework.injeinc.boffice.sy.fileupload.vo;
import egovframework.cmm.ComDefaultVO;
@SuppressWarnings("serial")
public class FileUploadVo extends ComDefaultVO{
private String fuIdx = "";
private String fuGroup = "";
private String fuPkidx = "";
private String fuPath = "";
private String fuName = "";
private String fuRename = "";
private String fuSize = "";
private String fuMime = "";
private String fuFormat = "";
private int fuDown = 0;
private String useYn = "";
private String regDt = "";
private String regId = "";
private String modDt = "";
private String modId = "";
public String getFuIdx() {
return fuIdx;
}
public void setFuIdx(String fuIdx) {
this.fuIdx = fuIdx;
}
public String getFuGroup() {
return fuGroup;
}
public void setFuGroup(String fuGroup) {
this.fuGroup = fuGroup;
}
public String getFuPkidx() {
return fuPkidx;
}
public void setFuPkidx(String fuPkidx) {
this.fuPkidx = fuPkidx;
}
public String getFuPath() {
return fuPath;
}
public void setFuPath(String fuPath) {
this.fuPath = fuPath;
}
public String getFuName() {
return fuName;
}
public void setFuName(String fuName) {
this.fuName = fuName;
}
public String getFuRename() {
return fuRename;
}
public void setFuRename(String fuRename) {
this.fuRename = fuRename;
}
public String getFuSize() {
return fuSize;
}
public void setFuSize(String fuSize) {
this.fuSize = fuSize;
}
public String getFuMime() {
return fuMime;
}
public void setFuMime(String fuMime) {
this.fuMime = fuMime;
}
public String getFuFormat() {
return fuFormat;
}
public void setFuFormat(String fuFormat) {
this.fuFormat = fuFormat;
}
public int getFuDown() {
return fuDown;
}
public void setFuDown(int fuDown) {
this.fuDown = fuDown;
}
public String getUseYn() {
return useYn;
}
public void setUseYn(String useYn) {
this.useYn = useYn;
}
public String getRegDt() {
return regDt;
}
public void setRegDt(String regDt) {
this.regDt = regDt;
}
public String getRegId() {
return regId;
}
public void setRegId(String regId) {
this.regId = regId;
}
public String getModDt() {
return modDt;
}
public void setModDt(String modDt) {
this.modDt = modDt;
}
public String getModId() {
return modId;
}
public void setModId(String modId) {
this.modId = modId;
}
}
| 2,366 | 0.685968 | 0.685545 | 118 | 19.050848 | 14.051267 | 55 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.838983 | false | false | 15 |
8e3d39d24533ff7ee32e91574cccf067f6db540a | 19,524,921,363,047 | 2412ff063a54fd5d1590570e824b7fdd39002467 | /Node.java | 346cce590bcbd792ebbdbf5ece49ad92e103f688 | []
| no_license | Aics7/DSA | https://github.com/Aics7/DSA | 69ee771d09598af5f4cf33839a3311286f298d00 | 6625ac5f91447956b75fb2d181c77b29d0ea52fb | refs/heads/master | 2020-04-16T14:37:25.657000 | 2019-01-21T10:30:50 | 2019-01-21T10:30:50 | 165,674,341 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.company;
/**
* A Node class to set parameters for inserting into the tree
*/
public class Node {
private double score;
private Stack left, right;
public Node (double score){
this.score = score;
this.left=new Stack(50);
this.right=new Stack(50);
}
public Node(){}
public void setLeft(Stack left) {
this.left = left;
}
public void setRight(Stack right) {
this.right = right;
}
public double getScore() {
return score;
}
public Stack getLeft() {
return left;
}
public Stack getRight() {
return right;
}
public void addLeft(Applicant student){
left.push(student);
}
public void addRight(Applicant student){
right.push(student);
}
}
| UTF-8 | Java | 840 | java | Node.java | Java | []
| null | []
| package com.company;
/**
* A Node class to set parameters for inserting into the tree
*/
public class Node {
private double score;
private Stack left, right;
public Node (double score){
this.score = score;
this.left=new Stack(50);
this.right=new Stack(50);
}
public Node(){}
public void setLeft(Stack left) {
this.left = left;
}
public void setRight(Stack right) {
this.right = right;
}
public double getScore() {
return score;
}
public Stack getLeft() {
return left;
}
public Stack getRight() {
return right;
}
public void addLeft(Applicant student){
left.push(student);
}
public void addRight(Applicant student){
right.push(student);
}
}
| 840 | 0.557143 | 0.552381 | 39 | 20.512821 | 15.504956 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.358974 | false | false | 15 |
d52cdaac0793390d8037d64f19a511568a323bff | 5,093,831,253,406 | 9333c33ee3e90f62fe6703c040dfb20adebacd9d | /MonitoringFiles/src/main/java/com/br/ilegra/MonitoringFiles/dto/DadosVendaDTO.java | ff26423f2822f427cb4c71f3947f685330bd5957 | []
| no_license | isaelfariajr/ilegra | https://github.com/isaelfariajr/ilegra | 3b4cb1f49780716f87ae569ffbd80491746c88e3 | 1d2fd74375f546fcaab0f521861b7e555870cb60 | refs/heads/main | 2023-01-13T02:45:40.839000 | 2020-11-15T23:49:51 | 2020-11-15T23:49:51 | 313,146,070 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.br.ilegra.MonitoringFiles.dto;
import java.util.List;
import lombok.Data;
@Data
public class DadosVendaDTO {
private Long sale;
private List<DadosVendaItensDTO> itens;
private String salesmanName;
}
| UTF-8 | Java | 218 | java | DadosVendaDTO.java | Java | []
| null | []
| package com.br.ilegra.MonitoringFiles.dto;
import java.util.List;
import lombok.Data;
@Data
public class DadosVendaDTO {
private Long sale;
private List<DadosVendaItensDTO> itens;
private String salesmanName;
}
| 218 | 0.788991 | 0.788991 | 13 | 15.769231 | 15.161458 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 15 |
fadc859a8ea62e42faffc7264ad192716ee5c60d | 27,573,690,087,685 | f8711ff36fd9a9adc6f4a9821705433811edd633 | /ykb.java.train/src/main/java/ykb/com/ykb/java/train/exceptions/MyException.java | b950ffed9771544608b045beceb10db50c6a568d | []
| no_license | osmanyaycioglu/ykbjava8 | https://github.com/osmanyaycioglu/ykbjava8 | 2dbcd1dec2d55e055ccb4719ca44a223b1d7985e | 74a3f1144a9b676a832bf8d6b3778e1a85c68e7b | refs/heads/master | 2021-03-11T19:40:16.471000 | 2020-03-11T13:40:51 | 2020-03-11T13:40:51 | 246,555,251 | 0 | 0 | null | false | 2020-10-13T20:16:58 | 2020-03-11T11:39:40 | 2020-03-11T13:41:12 | 2020-10-13T20:16:57 | 28 | 0 | 0 | 1 | Java | false | false | package ykb.com.ykb.java.train.exceptions;
public class MyException extends Exception {
private static final long serialVersionUID = 1497356554521937312L;
private String mesaj;
public MyException(String mesaj) {
super();
this.setMesaj(mesaj);
}
public String getMesaj() {
return mesaj;
}
public void setMesaj(String mesaj) {
this.mesaj = mesaj;
}
}
| UTF-8 | Java | 399 | java | MyException.java | Java | []
| null | []
| package ykb.com.ykb.java.train.exceptions;
public class MyException extends Exception {
private static final long serialVersionUID = 1497356554521937312L;
private String mesaj;
public MyException(String mesaj) {
super();
this.setMesaj(mesaj);
}
public String getMesaj() {
return mesaj;
}
public void setMesaj(String mesaj) {
this.mesaj = mesaj;
}
}
| 399 | 0.684211 | 0.636591 | 23 | 15.347826 | 18.520514 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.130435 | false | false | 15 |
c2b308517b7e796e90edc8c470d3e3e7cf1aeef0 | 19,456,201,921,573 | 1f40a873af1ee5589275d6bc971f0c7843b4dbf2 | /src/main/java/org/vinz243/tesa/masks/ComposedMask.java | 0b7679e4ecb802310b9640dd78ad32498c991b24 | []
| no_license | vinz243/chiseledit | https://github.com/vinz243/chiseledit | 1f004781884485c8885be233b863985ca37f13c7 | 2fb4710f87e4ba67eb3bcc9b04851ad835263ee3 | refs/heads/master | 2020-04-02T15:42:54.652000 | 2018-11-30T19:52:23 | 2018-11-30T19:52:23 | 154,580,376 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.vinz243.tesa.masks;
public abstract class ComposedMask implements Mask {
Mask a, b;
public ComposedMask(Mask a, Mask b) {
this.a = a;
this.b = b;
}
}
| UTF-8 | Java | 192 | java | ComposedMask.java | Java | [
{
"context": "package org.vinz243.tesa.masks;\n\npublic abstract class ComposedMas",
"end": 16,
"score": 0.6130374073982239,
"start": 15,
"tag": "USERNAME",
"value": "z"
},
{
"context": "package org.vinz243.tesa.masks;\n\npublic abstract class ComposedMask ",
"end": 18,
"score": 0.5132733583450317,
"start": 17,
"tag": "USERNAME",
"value": "4"
}
]
| null | []
| package org.vinz243.tesa.masks;
public abstract class ComposedMask implements Mask {
Mask a, b;
public ComposedMask(Mask a, Mask b) {
this.a = a;
this.b = b;
}
}
| 192 | 0.609375 | 0.59375 | 10 | 18.200001 | 17.255724 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 15 |
25753000c07acbc1c45b9977bc573c154281cc19 | 25,074,019,138,214 | 3e99295c069fd005ee9d18e32c8dc91cb5a2ed7d | /core/src/com/sgroup/jqkpro/object/ProductID.java | 30741b4fc6e8572efbfa16368a57e92d1cfadcf8 | []
| no_license | khnguyendinh/Babylon | https://github.com/khnguyendinh/Babylon | 697dc7dbe536e2f9fc9cac289d4ce0ccd4897bfe | d5af036e604dafd243e07eb6ffa1e6794698232c | refs/heads/master | 2016-04-30T21:33:51.973000 | 2016-02-04T04:30:19 | 2016-02-04T04:30:19 | 50,343,542 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sgroup.jqkpro.object;
public class ProductID {
public String productid;
public int xu;
public int price;
} | UTF-8 | Java | 122 | java | ProductID.java | Java | []
| null | []
| package com.sgroup.jqkpro.object;
public class ProductID {
public String productid;
public int xu;
public int price;
} | 122 | 0.770492 | 0.770492 | 7 | 16.571428 | 11.44998 | 33 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 15 |
b2285186b4b67c3b4c9d26a3c409dcbd4d787022 | 28,673,201,698,305 | 4b85a87dbae68997d0e0a16d2cae51bad7c9da86 | /ProgrammerI_1Z0-808-master/cp4.MethodsAndEncapsulation/lambdaExpressions/Bunnies.java | f9aba2cb64c95d50ab2a7ef8333546184adf375c | []
| no_license | radhikari54/OCA_1Z0-808 | https://github.com/radhikari54/OCA_1Z0-808 | 349166bba9705305d922bdbec743ea6afdab84ec | 360c2a5460acd9cd78961237a1c454bd636a2252 | refs/heads/master | 2020-03-06T19:20:52.311000 | 2017-02-16T22:13:10 | 2017-02-16T22:13:10 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package lambdaExpressions;
import java.util.ArrayList;
import java.util.List;
public class Bunnies {
//Imaginge que você tenha uma lista de nomes e queira apenas imprimir o que comece com a letra "h". Isso com expressão lambda seria feito facilmente em apenas uma linha de código.
public static void main(String[] args){
List<String> bunnies = new ArrayList<>();
bunnies.add("long ear");
bunnies.add("floppy");
bunnies.add("hoppy");
//Expressão Lambda
bunnies.removeIf(s -> s.charAt(0) != 'h');
System.out.println(bunnies);
}
} | UTF-8 | Java | 572 | java | Bunnies.java | Java | []
| null | []
| package lambdaExpressions;
import java.util.ArrayList;
import java.util.List;
public class Bunnies {
//Imaginge que você tenha uma lista de nomes e queira apenas imprimir o que comece com a letra "h". Isso com expressão lambda seria feito facilmente em apenas uma linha de código.
public static void main(String[] args){
List<String> bunnies = new ArrayList<>();
bunnies.add("long ear");
bunnies.add("floppy");
bunnies.add("hoppy");
//Expressão Lambda
bunnies.removeIf(s -> s.charAt(0) != 'h');
System.out.println(bunnies);
}
} | 572 | 0.695423 | 0.693662 | 19 | 28 | 38.629143 | 180 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.473684 | false | false | 15 |
ebc5b9d7a7c6be2cf814a4c87c5127d425df2b40 | 32,332,513,868,780 | a9db217f35e65aab6f8268f94d876d9902d3bf1e | /src/com/RectangleAttack/main/Game.java | 2f2e3b2bcdb3e7978118d05ebe18828aac8094e6 | []
| no_license | MantasMikal/RectangleAttack | https://github.com/MantasMikal/RectangleAttack | fb2ff21350f589e5724d613c300f82379118bfe1 | 31b75fa0f707b619be5037999efa685de54be09e | refs/heads/master | 2018-12-20T14:11:17.076000 | 2018-11-26T19:11:14 | 2018-11-26T19:11:14 | 107,276,354 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.RectangleAttack.main;
import com.RectangleAttack.main.Engine.*;
import com.RectangleAttack.main.Engine.Window;
import com.RectangleAttack.main.Events.EventHandler;
import com.RectangleAttack.main.LevelConstruction.Levels;
import com.RectangleAttack.main.Object.ID;
import com.RectangleAttack.main.Object.Particle;
import com.RectangleAttack.main.Object.UI.EnemyHUD;
import com.RectangleAttack.main.Object.UI.HUD;
import com.RectangleAttack.main.Object.UI.Shop;
import com.RectangleAttack.main.Object.UI.Menu;
import java.awt.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
public class Game extends Canvas implements Runnable{
public static Game.STATE gameState = STATE.Menu;
public static BufferedImage sprite_sheet;
public static boolean paused = false;
private Thread thread;
private boolean running;
private Handler handler;
private HUD hud;
private Levels levels;
private Menu menu;
private Shop shop;
private EnemyHUD enemyHUD;
private Shooting shooting;
private EventHandler eventHandler;
public Game(){
this.handler = new Handler();
this.menu = new Menu(this.handler);
this.hud = new HUD();
this.shop = new Shop();
this.enemyHUD = new EnemyHUD();
this.shooting = new Shooting(handler);
this.addMouseListener(this.shooting);
this.addMouseMotionListener(this.shooting);
this.addMouseListener(this.menu);
this.addMouseListener(this.shop);
this.addKeyListener(new Input(this.handler));
this.addKeyListener(this.shooting);
this.eventHandler = new EventHandler();
//MUSIC SWITCH
//AudioPlayer.load();
//AudioPlayer.getMusic("music").loop();
//SPRITES
BufferedImageLoader loader = new BufferedImageLoader();
sprite_sheet = loader.loadimage("/guste_Boss.png");
new Window(1024, 768, "RectangleAttack", this);
this.levels = new Levels(this.handler, enemyHUD, eventHandler);
}
public static float clamp(float var, float min, float max){
return var >= max ? max : (var <= min ? min : var);
}
public static void main(String[] args){
new Game();
}
public synchronized void start(){
this.thread = new Thread(this);
this.thread.start();
this.running = true;
}
private synchronized void stop(){
try{
this.thread.join();
this.running = false;
} catch(Exception var2){
var2.printStackTrace();
}
}
public void run(){
this.requestFocus();
long lastTime = System.nanoTime();
double amountOfTicks = 60.0D;
double ns = 1.0E9D / amountOfTicks;
double delta = 0.0D;
long timer = System.currentTimeMillis();
int frames = 0;
while(this.running){
long now = System.nanoTime();
delta += (double) (now - lastTime) / ns;
for(lastTime = now; delta >= 1.0D; --delta){
this.tick();
}
if(this.running){
this.render();
}
++frames;
if(System.currentTimeMillis() - timer > 1000L){
timer += 1000L;
System.out.println(frames);
frames = 0;
}
}
this.stop();
}
private void tick(){
if(!paused){
if(gameState == Game.STATE.Game){
this.hud.tick();
this.levels.tick();
this.handler.tick();
this.enemyHUD.tick();
this.shooting.tick();
//GAME OVER
if(HUD.HEALTH <= 0){
handler.removeObjects();
gameState = STATE.GameOver;
HUD.reset(); //RESETS STATS
for(int i = 0; i < 20; i++){
this.handler.addObject(new Particle(1 + (int) (Math.random() * 1000.0D), 1 + (int) (Math
.random() * 1000.0D), ID.Particle));
}
}
} else if(gameState == Game.STATE.Menu || gameState == STATE.Help || gameState == STATE.GameOver){
this.menu.tick();
this.handler.tick();
//SHOP MODE
} else if(gameState == STATE.Shop){
this.shop.tick();
this.handler.tick();
}
}
}
private void render(){
BufferStrategy bs = this.getBufferStrategy();
if(bs == null){
this.createBufferStrategy(3);
} else{
Graphics2D g = (Graphics2D) bs.getDrawGraphics();
//g.scale(1, 1);
g.setColor(Color.WHITE);
g.fillRect(0, 0, 1024, 768);
if(paused){
g.setColor(Color.black);
g.drawString("PAUSE", 505, 205);
}
if(gameState == Game.STATE.Game){
// System.out.println("GAME STATE");
this.hud.render(g);
this.handler.render(g);
this.enemyHUD.render(g);
} else if(gameState == Game.STATE.Menu || gameState == STATE.Help || gameState == STATE.GameOver){
this.menu.render(g);
this.handler.render(g);
//System.out.println("MENU STATE");
} else if(gameState == Game.STATE.Shop){
paused = true;
// System.out.println("SHOP STATE");
this.handler.render(g);
g.setColor(Color.WHITE);
g.fillRect(0, 0, 1024, 768);
this.shop.render(g);
this.hud.render(g);
}
g.dispose();
bs.show();
}
}
public enum STATE{
Menu,
Game,
Help,
GameOver,
Shop
}
}
| UTF-8 | Java | 5,984 | java | Game.java | Java | []
| null | []
| package com.RectangleAttack.main;
import com.RectangleAttack.main.Engine.*;
import com.RectangleAttack.main.Engine.Window;
import com.RectangleAttack.main.Events.EventHandler;
import com.RectangleAttack.main.LevelConstruction.Levels;
import com.RectangleAttack.main.Object.ID;
import com.RectangleAttack.main.Object.Particle;
import com.RectangleAttack.main.Object.UI.EnemyHUD;
import com.RectangleAttack.main.Object.UI.HUD;
import com.RectangleAttack.main.Object.UI.Shop;
import com.RectangleAttack.main.Object.UI.Menu;
import java.awt.*;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
public class Game extends Canvas implements Runnable{
public static Game.STATE gameState = STATE.Menu;
public static BufferedImage sprite_sheet;
public static boolean paused = false;
private Thread thread;
private boolean running;
private Handler handler;
private HUD hud;
private Levels levels;
private Menu menu;
private Shop shop;
private EnemyHUD enemyHUD;
private Shooting shooting;
private EventHandler eventHandler;
public Game(){
this.handler = new Handler();
this.menu = new Menu(this.handler);
this.hud = new HUD();
this.shop = new Shop();
this.enemyHUD = new EnemyHUD();
this.shooting = new Shooting(handler);
this.addMouseListener(this.shooting);
this.addMouseMotionListener(this.shooting);
this.addMouseListener(this.menu);
this.addMouseListener(this.shop);
this.addKeyListener(new Input(this.handler));
this.addKeyListener(this.shooting);
this.eventHandler = new EventHandler();
//MUSIC SWITCH
//AudioPlayer.load();
//AudioPlayer.getMusic("music").loop();
//SPRITES
BufferedImageLoader loader = new BufferedImageLoader();
sprite_sheet = loader.loadimage("/guste_Boss.png");
new Window(1024, 768, "RectangleAttack", this);
this.levels = new Levels(this.handler, enemyHUD, eventHandler);
}
public static float clamp(float var, float min, float max){
return var >= max ? max : (var <= min ? min : var);
}
public static void main(String[] args){
new Game();
}
public synchronized void start(){
this.thread = new Thread(this);
this.thread.start();
this.running = true;
}
private synchronized void stop(){
try{
this.thread.join();
this.running = false;
} catch(Exception var2){
var2.printStackTrace();
}
}
public void run(){
this.requestFocus();
long lastTime = System.nanoTime();
double amountOfTicks = 60.0D;
double ns = 1.0E9D / amountOfTicks;
double delta = 0.0D;
long timer = System.currentTimeMillis();
int frames = 0;
while(this.running){
long now = System.nanoTime();
delta += (double) (now - lastTime) / ns;
for(lastTime = now; delta >= 1.0D; --delta){
this.tick();
}
if(this.running){
this.render();
}
++frames;
if(System.currentTimeMillis() - timer > 1000L){
timer += 1000L;
System.out.println(frames);
frames = 0;
}
}
this.stop();
}
private void tick(){
if(!paused){
if(gameState == Game.STATE.Game){
this.hud.tick();
this.levels.tick();
this.handler.tick();
this.enemyHUD.tick();
this.shooting.tick();
//GAME OVER
if(HUD.HEALTH <= 0){
handler.removeObjects();
gameState = STATE.GameOver;
HUD.reset(); //RESETS STATS
for(int i = 0; i < 20; i++){
this.handler.addObject(new Particle(1 + (int) (Math.random() * 1000.0D), 1 + (int) (Math
.random() * 1000.0D), ID.Particle));
}
}
} else if(gameState == Game.STATE.Menu || gameState == STATE.Help || gameState == STATE.GameOver){
this.menu.tick();
this.handler.tick();
//SHOP MODE
} else if(gameState == STATE.Shop){
this.shop.tick();
this.handler.tick();
}
}
}
private void render(){
BufferStrategy bs = this.getBufferStrategy();
if(bs == null){
this.createBufferStrategy(3);
} else{
Graphics2D g = (Graphics2D) bs.getDrawGraphics();
//g.scale(1, 1);
g.setColor(Color.WHITE);
g.fillRect(0, 0, 1024, 768);
if(paused){
g.setColor(Color.black);
g.drawString("PAUSE", 505, 205);
}
if(gameState == Game.STATE.Game){
// System.out.println("GAME STATE");
this.hud.render(g);
this.handler.render(g);
this.enemyHUD.render(g);
} else if(gameState == Game.STATE.Menu || gameState == STATE.Help || gameState == STATE.GameOver){
this.menu.render(g);
this.handler.render(g);
//System.out.println("MENU STATE");
} else if(gameState == Game.STATE.Shop){
paused = true;
// System.out.println("SHOP STATE");
this.handler.render(g);
g.setColor(Color.WHITE);
g.fillRect(0, 0, 1024, 768);
this.shop.render(g);
this.hud.render(g);
}
g.dispose();
bs.show();
}
}
public enum STATE{
Menu,
Game,
Help,
GameOver,
Shop
}
}
| 5,984 | 0.536598 | 0.524231 | 205 | 28.190245 | 21.216835 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.687805 | false | false | 15 |
65bc8b9b67b0d78879b7a593901fa671ecb92f75 | 9,852,655,034,605 | 89373ecbae499757319551ed5f007e5041000c99 | /demo07/src/test/java/com/zjitc/AspectTest.java | e85fa322558d93fdc907be9bcc74121dc923e37f | []
| no_license | CrazyCodeOrg/company_fire | https://github.com/CrazyCodeOrg/company_fire | 75bf8fa3a0883d9fdc9d6e13d9213190dc878a4c | 8b3f64641f5b3b8916e6ae326fa2ffcb5280d2d3 | refs/heads/master | 2021-09-09T07:36:57.770000 | 2018-03-14T08:47:12 | 2018-03-14T08:47:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zjitc;
import com.zjitc.p1.obj.A;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Create by IntelliJ IDEA
*
* @author: jsonor
* @date-Time: 2018/3/14 14:43
* @description:
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:aspect-config.xml")
public class AspectTest {
@Autowired
A a;
@Test
public void aspectA() {
a.a();
}
}
| UTF-8 | Java | 610 | java | AspectTest.java | Java | [
{
"context": "er;\n\n/**\n * Create by IntelliJ IDEA\n *\n * @author: jsonor\n * @date-Time: 2018/3/14 14:43\n * @description:\n ",
"end": 353,
"score": 0.9996355772018433,
"start": 347,
"tag": "USERNAME",
"value": "jsonor"
}
]
| null | []
| package com.zjitc;
import com.zjitc.p1.obj.A;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
/**
* Create by IntelliJ IDEA
*
* @author: jsonor
* @date-Time: 2018/3/14 14:43
* @description:
*/
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath:aspect-config.xml")
public class AspectTest {
@Autowired
A a;
@Test
public void aspectA() {
a.a();
}
}
| 610 | 0.752459 | 0.727869 | 28 | 20.785715 | 21.044777 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.321429 | false | false | 15 |
dab9ba8887c49cacd49ca8baaec068de09e68738 | 19,146,964,214,038 | 4609b0075af5089d649d96fddf86310e47836c4f | /babbler/src/main/java/ru/sberbank/final_task/babbler/service/internal/UserServiceImpl.java | 168206a62ed6f7d82b3aed23407bc1358e17def7 | []
| no_license | youhavebeenforked/SimpleChat | https://github.com/youhavebeenforked/SimpleChat | 52902ca8dcc55b562b9d51eea03dc26bf3fa43d5 | c95d9b298b9aab77131980256aeee19b0c856ad5 | refs/heads/master | 2020-06-17T01:32:17.258000 | 2018-04-27T14:55:21 | 2018-04-27T14:55:21 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ru.sberbank.final_task.babbler.service.internal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import ru.sberbank.final_task.babbler.domain.auth.User;
import ru.sberbank.final_task.babbler.repository.auth.UserRepository;
import ru.sberbank.final_task.babbler.service.UserService;
import ru.sberbank.final_task.babbler.web.dto.UserRegistrationDto;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserRepository userRepository;
@Autowired
private BCryptPasswordEncoder passwordEncoder;
public User findByEmail(String email) {
return userRepository.findByEmail(email);
}
public User findByLogin(String login) {
return userRepository.findByLogin(login);
}
public List<User> findUsersByLogin(String login) {
return userRepository.searchUsersByLogin(login);
}
@Override
public User findById(Long id) {
return userRepository.getOne(id);
}
public User save(UserRegistrationDto userDto) {
User user = new User();
user.setFirstName(userDto.getFirstName());
user.setLastName(userDto.getLastName());
user.setEmail(userDto.getEmail());
user.setLogin(userDto.getLogin());
user.setPassword(passwordEncoder.encode(userDto.getPassword()));
user.setLastSeen(LocalDateTime.now());
user.setStatus("online");
return userRepository.save(user);
}
@Override
public User updateUser(UserRegistrationDto userDto) {
User user = userRepository.findByEmail(userDto.getEmail());
String email = user.getEmail();
String firstName = userDto.getFirstName().equals("") ? user.getFirstName() : userDto.getFirstName();
String lastName = userDto.getLastName().equals("") ? user.getLastName() : userDto.getLastName();
String login = userDto.getLogin().equals("") ? user.getLogin() : userDto.getLogin();
String password = userDto.getPassword().equals("") ? user.getPassword() : passwordEncoder.encode(userDto.getPassword());
try {
byte[] avatar = userDto.getAvatar().isEmpty() ? user.getAvatar() : userDto.getAvatar().getBytes();
String avatarType = userDto.getAvatar().isEmpty()
? user.getAvatarType()
: "." + userDto.getAvatar().getContentType().substring(userDto.getAvatar().getContentType().indexOf("/") + 1);
userRepository.updateUserInfo(email, firstName, lastName, login, password, avatar, avatarType);
} catch (IOException e) {
}
return userRepository.findByEmail(email);
}
// @Override
// public void updateUserContacts(User user, Set<User> contacts) {
// userRepository.updateUserContacts(user.getId(), contacts);
// }
@Override
public void updateLastSeen(String email, LocalDateTime lastSeen, String status) {
userRepository.updateLastSeen(email, lastSeen, status);
}
@Override
public User save(User user) {
return userRepository.save(user);
}
@Override
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
User user = userRepository.findByEmail(email);
if (user == null) {
throw new UsernameNotFoundException("Invalid username or password.");
}
return new org.springframework.security.core.userdetails.User(user.getEmail(),
user.getPassword(),new HashSet<GrantedAuthority>());
}
}
| UTF-8 | Java | 3,956 | java | UserServiceImpl.java | Java | []
| null | []
| package ru.sberbank.final_task.babbler.service.internal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import ru.sberbank.final_task.babbler.domain.auth.User;
import ru.sberbank.final_task.babbler.repository.auth.UserRepository;
import ru.sberbank.final_task.babbler.service.UserService;
import ru.sberbank.final_task.babbler.web.dto.UserRegistrationDto;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.HashSet;
import java.util.List;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserRepository userRepository;
@Autowired
private BCryptPasswordEncoder passwordEncoder;
public User findByEmail(String email) {
return userRepository.findByEmail(email);
}
public User findByLogin(String login) {
return userRepository.findByLogin(login);
}
public List<User> findUsersByLogin(String login) {
return userRepository.searchUsersByLogin(login);
}
@Override
public User findById(Long id) {
return userRepository.getOne(id);
}
public User save(UserRegistrationDto userDto) {
User user = new User();
user.setFirstName(userDto.getFirstName());
user.setLastName(userDto.getLastName());
user.setEmail(userDto.getEmail());
user.setLogin(userDto.getLogin());
user.setPassword(passwordEncoder.encode(userDto.getPassword()));
user.setLastSeen(LocalDateTime.now());
user.setStatus("online");
return userRepository.save(user);
}
@Override
public User updateUser(UserRegistrationDto userDto) {
User user = userRepository.findByEmail(userDto.getEmail());
String email = user.getEmail();
String firstName = userDto.getFirstName().equals("") ? user.getFirstName() : userDto.getFirstName();
String lastName = userDto.getLastName().equals("") ? user.getLastName() : userDto.getLastName();
String login = userDto.getLogin().equals("") ? user.getLogin() : userDto.getLogin();
String password = userDto.getPassword().equals("") ? user.getPassword() : passwordEncoder.encode(userDto.getPassword());
try {
byte[] avatar = userDto.getAvatar().isEmpty() ? user.getAvatar() : userDto.getAvatar().getBytes();
String avatarType = userDto.getAvatar().isEmpty()
? user.getAvatarType()
: "." + userDto.getAvatar().getContentType().substring(userDto.getAvatar().getContentType().indexOf("/") + 1);
userRepository.updateUserInfo(email, firstName, lastName, login, password, avatar, avatarType);
} catch (IOException e) {
}
return userRepository.findByEmail(email);
}
// @Override
// public void updateUserContacts(User user, Set<User> contacts) {
// userRepository.updateUserContacts(user.getId(), contacts);
// }
@Override
public void updateLastSeen(String email, LocalDateTime lastSeen, String status) {
userRepository.updateLastSeen(email, lastSeen, status);
}
@Override
public User save(User user) {
return userRepository.save(user);
}
@Override
public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
User user = userRepository.findByEmail(email);
if (user == null) {
throw new UsernameNotFoundException("Invalid username or password.");
}
return new org.springframework.security.core.userdetails.User(user.getEmail(),
user.getPassword(),new HashSet<GrantedAuthority>());
}
}
| 3,956 | 0.702477 | 0.702224 | 102 | 37.784313 | 32.705948 | 130 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.588235 | false | false | 15 |
ff99f2bdb05bc469e82c95ba713bdf55f0fbaf10 | 5,634,997,122,925 | de622776257f5c1f1360151d94f5522fcfe1f0d3 | /Data/src/main/java/com/sunzequn/geo/data/alignment/bean/GeonamesClass.java | 748081df9ed852d5900522122f54463f02d916d8 | []
| no_license | sunzequn/Geo | https://github.com/sunzequn/Geo | c83fad7312f9f1021ff332747ef82a4c0616b645 | 29e29e7442792255fb490b6cfd8a28806fc3142f | refs/heads/master | 2020-12-28T21:18:10.486000 | 2016-12-06T02:44:21 | 2016-12-06T02:44:21 | 48,304,121 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sunzequn.geo.data.alignment.bean;
import java.util.List;
/**
* Created by Sloriac on 16/2/28.
*/
public class GeonamesClass implements Comparable<GeonamesClass> {
//geonames概念代码
private String uri2;
//所有的边的权重的和
private int weight;
private List<Relation> relatedDbpedias;
public GeonamesClass() {
}
public String getUri2() {
return uri2;
}
public void setUri2(String uri2) {
this.uri2 = uri2;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public List<Relation> getRelatedDbpedias() {
return relatedDbpedias;
}
public void setRelatedDbpedias(List<Relation> relatedDbpedias) {
this.relatedDbpedias = relatedDbpedias;
}
@Override
public String toString() {
return "GeonamesClass{" +
"uri2='" + uri2 + '\'' +
", weight=" + weight +
", relatedDbpedias=" + relatedDbpedias +
'}';
}
@Override
public int compareTo(GeonamesClass o) {
return o.getWeight() - this.weight;
}
}
| UTF-8 | Java | 1,205 | java | GeonamesClass.java | Java | [
{
"context": "t.bean;\n\nimport java.util.List;\n\n/**\n * Created by Sloriac on 16/2/28.\n */\npublic class GeonamesClass implem",
"end": 96,
"score": 0.957756757736206,
"start": 89,
"tag": "USERNAME",
"value": "Sloriac"
}
]
| null | []
| package com.sunzequn.geo.data.alignment.bean;
import java.util.List;
/**
* Created by Sloriac on 16/2/28.
*/
public class GeonamesClass implements Comparable<GeonamesClass> {
//geonames概念代码
private String uri2;
//所有的边的权重的和
private int weight;
private List<Relation> relatedDbpedias;
public GeonamesClass() {
}
public String getUri2() {
return uri2;
}
public void setUri2(String uri2) {
this.uri2 = uri2;
}
public int getWeight() {
return weight;
}
public void setWeight(int weight) {
this.weight = weight;
}
public List<Relation> getRelatedDbpedias() {
return relatedDbpedias;
}
public void setRelatedDbpedias(List<Relation> relatedDbpedias) {
this.relatedDbpedias = relatedDbpedias;
}
@Override
public String toString() {
return "GeonamesClass{" +
"uri2='" + uri2 + '\'' +
", weight=" + weight +
", relatedDbpedias=" + relatedDbpedias +
'}';
}
@Override
public int compareTo(GeonamesClass o) {
return o.getWeight() - this.weight;
}
}
| 1,205 | 0.588634 | 0.57676 | 58 | 19.327587 | 18.722464 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.258621 | false | false | 15 |
3426c849eea68b9cb9ab81ce2ab7699672117009 | 33,861,522,178,926 | 254ef555d1feab2a4c4cc3cc3acd7eb6952995be | /app/src/main/java/app/everydayempire/tv/common/VideoFilter.java | 4569a98ea51e41b2effad0775cc3bf88c9ffbca2 | []
| no_license | whitetiger1002/EverydayEmpire_android | https://github.com/whitetiger1002/EverydayEmpire_android | 03179e5f26f5fc9174b57e7f53e19ba43ab0f699 | de8ba9e98cb54290776916b596802d297eb7cac9 | refs/heads/master | 2023-04-04T03:13:23.110000 | 2021-04-20T20:08:50 | 2021-04-20T20:08:50 | 359,101,859 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package app.everydayempire.tv.common;
public enum VideoFilter {
NONE,
BRIGHTNESS,
EXPOSURE,
GAMMA,
GRAYSCALE,
HAZE,
INVERT,
MONOCHROME,
PIXELATED,
POSTERIZE,
SEPIA,
SHARP,
SOLARIZE,
VIGNETTE,
}
| UTF-8 | Java | 252 | java | VideoFilter.java | Java | []
| null | []
| package app.everydayempire.tv.common;
public enum VideoFilter {
NONE,
BRIGHTNESS,
EXPOSURE,
GAMMA,
GRAYSCALE,
HAZE,
INVERT,
MONOCHROME,
PIXELATED,
POSTERIZE,
SEPIA,
SHARP,
SOLARIZE,
VIGNETTE,
}
| 252 | 0.607143 | 0.607143 | 19 | 12.263158 | 8.161798 | 37 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.789474 | false | false | 15 |
c10458a235a4af7477062ffd1bf080ce93937ef6 | 33,002,528,729,677 | 129abbb522fa9cd3a43d4609a5a6347eaf8591dc | /poc_backend_pI/src/br/com/grupodimed/java8/defaultinterface/patternstrategy/AceleracaoMotorV8.java | 01268eff7f63eddaac469ee6df06cd44d971e9a3 | []
| no_license | RonaldoGuastalli/features-java-8-11 | https://github.com/RonaldoGuastalli/features-java-8-11 | 9dc0ccbd263bc9270aaa34e831e09c2bbac8525d | 516cbd9d538d1044e005a2e49fdb78a5982b0b68 | refs/heads/master | 2020-06-02T08:00:53.820000 | 2019-06-17T17:32:01 | 2019-06-17T17:32:01 | 191,091,078 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.grupodimed.java8.defaultinterface.patternstrategy;
public class AceleracaoMotorV8 implements IAceleracao{
@Override
public String acelerar() {
return "Aceleração Super Rápida";
}
@Override
public String desacelerar() {
return "Desaceleração Lenta";
}
}
| UTF-8 | Java | 315 | java | AceleracaoMotorV8.java | Java | []
| null | []
| package br.com.grupodimed.java8.defaultinterface.patternstrategy;
public class AceleracaoMotorV8 implements IAceleracao{
@Override
public String acelerar() {
return "Aceleração Super Rápida";
}
@Override
public String desacelerar() {
return "Desaceleração Lenta";
}
}
| 315 | 0.7 | 0.693548 | 13 | 22.846153 | 21.092638 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.230769 | false | false | 15 |
499095db9807ad2807629da170e2564dce7362f0 | 6,365,141,583,898 | 6a6b81bce5513ce981afb6f2c23f8019d36b356a | /app/src/main/java/com/roodapps/ispy/utility/Letter.java | e1667c4eaee88bd884ab43da5fb9131e66145b87 | []
| no_license | kanroo/ISpy | https://github.com/kanroo/ISpy | 247601e6662d93598da45e07bef660c81eef8d3a | 756feae938d1301046bf21a5449007cafc46422e | refs/heads/master | 2020-12-30T23:08:34.669000 | 2017-03-04T00:51:26 | 2017-03-04T00:51:26 | 80,615,810 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.roodapps.ispy.utility;
public class Letter
{
public char character;
public float origX;
public float origY;
public int size;
public int position;
public boolean isMounted;
// Letter Class holds all necessary variables of a letter
public Letter(char character, float origX, float origY, int size, int position, boolean isMounted)
{
this.character = character;
this.origX = origX;
this.origY = origY;
this.size = size;
this.position = position;
this.isMounted = isMounted;
}
}
| UTF-8 | Java | 578 | java | Letter.java | Java | []
| null | []
| package com.roodapps.ispy.utility;
public class Letter
{
public char character;
public float origX;
public float origY;
public int size;
public int position;
public boolean isMounted;
// Letter Class holds all necessary variables of a letter
public Letter(char character, float origX, float origY, int size, int position, boolean isMounted)
{
this.character = character;
this.origX = origX;
this.origY = origY;
this.size = size;
this.position = position;
this.isMounted = isMounted;
}
}
| 578 | 0.653979 | 0.653979 | 22 | 25.272728 | 22.297945 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.818182 | false | false | 15 |
787d6959b8872735bb32eb6cb5eb02da91d7ac69 | 6,992,206,795,464 | a7ef21be514e75e3bb3bd33e1b58702813245d0b | /src/net/appshot/project/content/BKContentActivity.java | cc6b2cf42755c82c37ca44838998bea79d6312eb | []
| no_license | okskygo/rexforgamebase | https://github.com/okskygo/rexforgamebase | a9c3421b9ca50a3e8545d8904beb4f9345bc6626 | b450d717478254fcfb4decfafbd4c2eabb74d1cc | refs/heads/master | 2016-09-06T23:08:13.501000 | 2014-03-31T11:01:00 | 2014-03-31T11:01:00 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.appshot.project.content;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import net.appshot.project.alluse.CheckHavePreAndStart;
import net.appshot.project.forgamebase.R;
import net.appshot.project.major.MainActivity;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* 主要內容頁面
*
* @author Rex
*
* 2014/1/28 下午3:57:07
*/
public class BKContentActivity extends SherlockFragmentActivity {
private static ActionBar actionBar;
private final String homeString = "新聞";
private final String textFragmentTag = "text";
private final String replyFragmentTag = "reply";
private boolean closeA = false;
private TextFragment textFragment;
private ReplyFragment replyfragment;
private static boolean textMode;
private static boolean replyMode;
//背面的View
private View reverse;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
/*
ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager);
//这里因为是3.0一下版本,所以需继承FragmentActivity,通过getSupportFragmentManager()获取FragmentManager
//3.0及其以上版本,只需继承Activity,通过getFragmentManager获取事物
FragmentManager fm = getSupportFragmentManager();
//初始化自定义适配器
ContentFragmentPageAdapter mAdapter = new ContentFragmentPageAdapter(fm);
//绑定自定义适配器
mViewPager.setAdapter(mAdapter);
*/
selectFragment(getIntent().getIntExtra(MainActivity.contentFragmentKey, MainActivity.textFragmentValue), true);
actionBarSetting();
//bottomViewSetting();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, R.id.right_button, 2, "功能")
.setIcon(R.drawable.ic_action_overflow)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
/*
if(replyMode){
menu.add(0, R.id.right_button2, 1, "回覆")
.setIcon(R.drawable.ic_action_labels)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}*/
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case android.R.id.home:
onBackPressed();
break;
}
return super.onOptionsItemSelected(item);
}
/**
* 主要
* @param fragmentKey 來確認第一次顯示哪個頁面
* @param isFisrt 是否第一次使用
*/
public void selectFragment(int fragmentKey, boolean isFirst){
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
switch(fragmentKey){
case MainActivity.textFragmentValue:
if(textFragment == null){
textFragment = new TextFragment();
ft.add(R.id.frameLayout, textFragment);
}
if(isFirst){
//ft.add(R.id.frameLayout, textFragment);
}else{
ft.setCustomAnimations(R.anim.top_in, R.anim.bottom_out);
ft.hide(replyfragment);
ft.show(textFragment);
}
replyMode = false;
//ftAddOrReplace(ft, isFirst, textFragmentTag, textFragment);
break;
case MainActivity.replyFragmentValue:
if(replyfragment == null){
replyfragment = new ReplyFragment();
ft.add(R.id.frameLayout, replyfragment);
}
if(isFirst){
//ft.add(R.id.frameLayout, replyfragment);
}else{
ft.setCustomAnimations(R.anim.bottom_in, R.anim.top_out);
ft.hide(textFragment);
ft.show(replyfragment);
//ft.show(replyfragment);
}
//ftAddOrReplace(ft, isFirst, replyFragmentTag, replyfragment);
replyMode = true;
break;
}
//ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
invalidateOptionsMenu();
}
/**
* 設定Action Bar
*/
private void actionBarSetting(){
BKContentActivity.actionBar = getSupportActionBar();
//自訂view
//actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//actionBar.setCustomView(R.layout.activity_content_actionbar_layout);
//左邊HomeButton
actionBar.setTitle(homeString);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
SharedPreferences settings = getSharedPreferences("SETTING", 0);
boolean closeAlert = settings.getBoolean("CLOSE_GOOD_ALERT", false);
if(!closeAlert){
openAlert();
}else{
super.onBackPressed();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
}
}
private void openAlert(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("您覺得這則新聞重要嗎?")
.setMultiChoiceItems(new String[]{"以後不在提醒我"}, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
if(arg2){
closeA = true;
}else{
closeA = false;
}
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// TODO Auto-generated method stub
closeActivity();
}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
closeActivity();
}
});
builder.create().show();
}
private void closeActivity(){
if(closeA){
SharedPreferences settings = getSharedPreferences ("SETTING", 0);
SharedPreferences.Editor PE = settings.edit();
PE.putBoolean("CLOSE_GOOD_ALERT", true);
PE.commit();
}
BKContentActivity.this.finish();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
}
}
| UTF-8 | Java | 6,801 | java | BKContentActivity.java | Java | [
{
"context": "nt.SharedPreferences;\n/**\n * 主要內容頁面\n * \n * @author Rex\n *\n * 2014/1/28 下午3:57:07\n */\npublic class BKCont",
"end": 1099,
"score": 0.9787601232528687,
"start": 1096,
"tag": "USERNAME",
"value": "Rex"
}
]
| null | []
| package net.appshot.project.content;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.app.SherlockFragmentActivity;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;
import com.actionbarsherlock.view.Window;
import net.appshot.project.alluse.CheckHavePreAndStart;
import net.appshot.project.forgamebase.R;
import net.appshot.project.major.MainActivity;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.view.ViewPager;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
/**
* 主要內容頁面
*
* @author Rex
*
* 2014/1/28 下午3:57:07
*/
public class BKContentActivity extends SherlockFragmentActivity {
private static ActionBar actionBar;
private final String homeString = "新聞";
private final String textFragmentTag = "text";
private final String replyFragmentTag = "reply";
private boolean closeA = false;
private TextFragment textFragment;
private ReplyFragment replyfragment;
private static boolean textMode;
private static boolean replyMode;
//背面的View
private View reverse;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_content);
/*
ViewPager mViewPager = (ViewPager) findViewById(R.id.viewpager);
//这里因为是3.0一下版本,所以需继承FragmentActivity,通过getSupportFragmentManager()获取FragmentManager
//3.0及其以上版本,只需继承Activity,通过getFragmentManager获取事物
FragmentManager fm = getSupportFragmentManager();
//初始化自定义适配器
ContentFragmentPageAdapter mAdapter = new ContentFragmentPageAdapter(fm);
//绑定自定义适配器
mViewPager.setAdapter(mAdapter);
*/
selectFragment(getIntent().getIntExtra(MainActivity.contentFragmentKey, MainActivity.textFragmentValue), true);
actionBarSetting();
//bottomViewSetting();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, R.id.right_button, 2, "功能")
.setIcon(R.drawable.ic_action_overflow)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
/*
if(replyMode){
menu.add(0, R.id.right_button2, 1, "回覆")
.setIcon(R.drawable.ic_action_labels)
.setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
}*/
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch(item.getItemId()){
case android.R.id.home:
onBackPressed();
break;
}
return super.onOptionsItemSelected(item);
}
/**
* 主要
* @param fragmentKey 來確認第一次顯示哪個頁面
* @param isFisrt 是否第一次使用
*/
public void selectFragment(int fragmentKey, boolean isFirst){
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
switch(fragmentKey){
case MainActivity.textFragmentValue:
if(textFragment == null){
textFragment = new TextFragment();
ft.add(R.id.frameLayout, textFragment);
}
if(isFirst){
//ft.add(R.id.frameLayout, textFragment);
}else{
ft.setCustomAnimations(R.anim.top_in, R.anim.bottom_out);
ft.hide(replyfragment);
ft.show(textFragment);
}
replyMode = false;
//ftAddOrReplace(ft, isFirst, textFragmentTag, textFragment);
break;
case MainActivity.replyFragmentValue:
if(replyfragment == null){
replyfragment = new ReplyFragment();
ft.add(R.id.frameLayout, replyfragment);
}
if(isFirst){
//ft.add(R.id.frameLayout, replyfragment);
}else{
ft.setCustomAnimations(R.anim.bottom_in, R.anim.top_out);
ft.hide(textFragment);
ft.show(replyfragment);
//ft.show(replyfragment);
}
//ftAddOrReplace(ft, isFirst, replyFragmentTag, replyfragment);
replyMode = true;
break;
}
//ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.commit();
invalidateOptionsMenu();
}
/**
* 設定Action Bar
*/
private void actionBarSetting(){
BKContentActivity.actionBar = getSupportActionBar();
//自訂view
//actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
//actionBar.setCustomView(R.layout.activity_content_actionbar_layout);
//左邊HomeButton
actionBar.setTitle(homeString);
actionBar.setDisplayShowHomeEnabled(false);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
}
@Override
public void onBackPressed() {
// TODO Auto-generated method stub
SharedPreferences settings = getSharedPreferences("SETTING", 0);
boolean closeAlert = settings.getBoolean("CLOSE_GOOD_ALERT", false);
if(!closeAlert){
openAlert();
}else{
super.onBackPressed();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
}
}
private void openAlert(){
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("您覺得這則新聞重要嗎?")
.setMultiChoiceItems(new String[]{"以後不在提醒我"}, null, new DialogInterface.OnMultiChoiceClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1, boolean arg2) {
// TODO Auto-generated method stub
if(arg2){
closeA = true;
}else{
closeA = false;
}
}
})
.setNegativeButton("No", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
// TODO Auto-generated method stub
closeActivity();
}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
// TODO Auto-generated method stub
closeActivity();
}
});
builder.create().show();
}
private void closeActivity(){
if(closeA){
SharedPreferences settings = getSharedPreferences ("SETTING", 0);
SharedPreferences.Editor PE = settings.edit();
PE.putBoolean("CLOSE_GOOD_ALERT", true);
PE.commit();
}
BKContentActivity.this.finish();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
}
}
| 6,801 | 0.709393 | 0.704826 | 238 | 26.60084 | 22.94944 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.491597 | false | false | 15 |
bc568208dc010ec3da2c3ca8b5d2896afbf0c480 | 17,068,200,081,726 | 3f52ed1a1c736b5716b729e3898a60ecea3aac4f | /app/src/main/java/com/oxapps/tradenotifications/main/MainActivity.java | 18a8ac63237484ebf6b1e84195b06a4c1d9d679a | [
"Apache-2.0"
]
| permissive | flynnvo/Trade-Notifications-for-Steam | https://github.com/flynnvo/Trade-Notifications-for-Steam | 28362aedab172a31b581af8d4777012860a10d61 | 3327385d086e51b13c2388f8a2fd93acf36830fa | refs/heads/master | 2021-09-06T21:03:21.212000 | 2018-02-11T09:52:09 | 2018-02-11T10:05:00 | 60,454,197 | 1 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2017 Flynn van Os
*
* 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.oxapps.tradenotifications.main;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.oxapps.tradenotifications.DelayDialogFragment;
import com.oxapps.tradenotifications.R;
import com.oxapps.tradenotifications.apikey.ApiKeyActivity;
import com.oxapps.tradenotifications.model.ApplicationSettingsImpl;
import com.oxapps.tradenotifications.model.BackgroundTaskScheduler;
import com.oxapps.tradenotifications.model.ConnectionUtils;
import com.oxapps.tradenotifications.model.IntentConsts;
public class MainActivity extends AppCompatActivity implements MainActivityView, DelayDialogFragment.OnDelaySetListener {
/**
* Presenter associated with this activity
*/
private MainActivityPresenter presenter;
private static final String TRADE_URL = "https://steamcommunity.com/tradeoffer/new/?partner=72233084&token=NWnuxGBb";
/**
* Text field holding the API Key
*/
private EditText apiKeyView;
/**
* TextView holding the delay text
*/
private TextView delayView;
/**
* Button for API Key logic
*/
private Button apiKeyButton;
/**
* API Key text field's locked status
*/
private boolean apiKeyLocked;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
presenter = new MainActivityPresenter(this, new ApplicationSettingsImpl(this), new ConnectionUtils(this));
presenter.initialize();
}
/**
* Initialise views used
*/
@Override
public void initViews() {
apiKeyView = (EditText) findViewById(R.id.et_api_key);
apiKeyButton = (Button) findViewById(R.id.button_get_api_key);
delayView = (TextView) findViewById(R.id.tv_delay);
apiKeyView.addTextChangedListener(mApiKeyErrorWatcher);
}
/**
* Changes the API Key view
*
* @param apiKey the text to display
*/
@Override
public void showApiKey(String apiKey) {
apiKeyView.setText(apiKey);
}
/**
* Changes the refresh delay view
*
* @param refreshDelay the text to display
*/
@Override
public void showRefreshDelay(long refreshDelay) {
delayView.setText(getDelayText(refreshDelay));
}
/**
* Changes a delay time to a human-readable format
*
* @param delay the delay to convert
* @return a human-readable version of the delay
*/
private String getDelayText(long delay) {
if (delay == 0) {
return getString(R.string.disabled);
} else if (delay < (120 * 60)) {
return getString(R.string.delay_min, delay / 60);
} else {
return getString(R.string.delay_hours, delay / 3600);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IntentConsts.API_KEY_REQUEST) {
if (resultCode == RESULT_OK) {
String apiKey = data.getStringExtra(IntentConsts.API_KEY);
presenter.updateApiKey(apiKey);
} else {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), R.string.api_key_error, Snackbar.LENGTH_LONG);
snackbar.show();
}
}
}
/**
* Handles clicking of the Get API Key button
*
* @param view the clicked view
*/
public void onGetApiKeyClicked(View view) {
presenter.onGetApiKeyClicked();
}
/**
* Toggles the locking of the API Key text field
*
* @param shouldLock whether or not the field should be locked
*/
@Override
public void lockApiKeyText(boolean shouldLock) {
apiKeyLocked = shouldLock;
apiKeyView.setFocusable(!shouldLock);
apiKeyView.setFocusableInTouchMode(!shouldLock);
apiKeyView.setEnabled(!shouldLock);
int buttonTextRes = shouldLock ? R.string.api_key_edit : R.string.api_key_get;
apiKeyButton.setText(buttonTextRes);
}
/**
* Launches the API Key retrieval activity
*/
@Override
public void startApiKeyActivity() {
Intent intent = new Intent(this, ApiKeyActivity.class);
startActivityForResult(intent, IntentConsts.API_KEY_REQUEST);
}
/**
* Displays a {@link Snackbar} with a given message
*
* @param message the message to display
*/
@Override
public void showSnackbar(String message) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT);
snackbar.show();
}
/**
* Displays a {@link Snackbar} with a given message
*
* @param messageResId the string id of the message to display
*/
@Override
public void showSnackbar(int messageResId) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), messageResId, Snackbar.LENGTH_SHORT);
snackbar.show();
}
/**
* Toggles the error message on the API Key field
*
* @param showError
*/
@Override
public void showInvalidApiKeyError(boolean showError) {
String error = showError ? getString(R.string.invalid_api_key) : null;
apiKeyView.setError(error);
}
/**
* @return whether the API Key text field is locked
*/
@Override
public boolean isApiKeyLocked() {
return apiKeyLocked;
}
/**
* @return the text of the API Key textfield
*/
@Override
public String getApiKeyText() {
return apiKeyView.getText().toString().trim();
}
/**
* Shows the interval selector dialog
*
* @param v the view that was clicked
*/
public void showIntervalDialog(View v) {
DelayDialogFragment ddf = new DelayDialogFragment();
ddf.setOnDelaySetListener(MainActivity.this);
ddf.show(getSupportFragmentManager(), "tag");
}
/**
* Handles the delay being set from the dialog
*
* @param delay the delay that was set
*/
@Override
public void onDelaySet(long delay) {
presenter.updateDelay(delay);
}
/**
* Handles the donation button click
*
* @param view the view that was clicked
*/
public void onDonationClicked(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse(TRADE_URL));
startActivity(browserIntent);
}
@Override
protected void onPause() {
presenter.setBackgroundTaskScheduler(new BackgroundTaskScheduler(this));
presenter.onActivityExiting();
super.onPause();
}
private void showInvalidApiKeyDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(R.string.invalid_api_key)
.setMessage(R.string.invalid_api_key_message)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
/**
* TextWatcher for the API Key text field
*/
private TextWatcher mApiKeyErrorWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
presenter.onApiKeyTextUpdated(editable);
}
};
}
| UTF-8 | Java | 9,159 | java | MainActivity.java | Java | [
{
"context": "/*\n * Copyright 2017 Flynn van Os\n *\n * Licensed under the Apache License, Version ",
"end": 33,
"score": 0.9998607039451599,
"start": 21,
"tag": "NAME",
"value": "Flynn van Os"
},
{
"context": "munity.com/tradeoffer/new/?partner=72233084&token=NWnuxGBb\";\n\n /**\n * Text field holding the API Key\n",
"end": 1850,
"score": 0.6989709138870239,
"start": 1842,
"tag": "KEY",
"value": "NWnuxGBb"
}
]
| null | []
| /*
* Copyright 2017 <NAME>
*
* 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.oxapps.tradenotifications.main;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.text.Editable;
import android.text.TextWatcher;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import com.oxapps.tradenotifications.DelayDialogFragment;
import com.oxapps.tradenotifications.R;
import com.oxapps.tradenotifications.apikey.ApiKeyActivity;
import com.oxapps.tradenotifications.model.ApplicationSettingsImpl;
import com.oxapps.tradenotifications.model.BackgroundTaskScheduler;
import com.oxapps.tradenotifications.model.ConnectionUtils;
import com.oxapps.tradenotifications.model.IntentConsts;
public class MainActivity extends AppCompatActivity implements MainActivityView, DelayDialogFragment.OnDelaySetListener {
/**
* Presenter associated with this activity
*/
private MainActivityPresenter presenter;
private static final String TRADE_URL = "https://steamcommunity.com/tradeoffer/new/?partner=72233084&token=NWnuxGBb";
/**
* Text field holding the API Key
*/
private EditText apiKeyView;
/**
* TextView holding the delay text
*/
private TextView delayView;
/**
* Button for API Key logic
*/
private Button apiKeyButton;
/**
* API Key text field's locked status
*/
private boolean apiKeyLocked;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
presenter = new MainActivityPresenter(this, new ApplicationSettingsImpl(this), new ConnectionUtils(this));
presenter.initialize();
}
/**
* Initialise views used
*/
@Override
public void initViews() {
apiKeyView = (EditText) findViewById(R.id.et_api_key);
apiKeyButton = (Button) findViewById(R.id.button_get_api_key);
delayView = (TextView) findViewById(R.id.tv_delay);
apiKeyView.addTextChangedListener(mApiKeyErrorWatcher);
}
/**
* Changes the API Key view
*
* @param apiKey the text to display
*/
@Override
public void showApiKey(String apiKey) {
apiKeyView.setText(apiKey);
}
/**
* Changes the refresh delay view
*
* @param refreshDelay the text to display
*/
@Override
public void showRefreshDelay(long refreshDelay) {
delayView.setText(getDelayText(refreshDelay));
}
/**
* Changes a delay time to a human-readable format
*
* @param delay the delay to convert
* @return a human-readable version of the delay
*/
private String getDelayText(long delay) {
if (delay == 0) {
return getString(R.string.disabled);
} else if (delay < (120 * 60)) {
return getString(R.string.delay_min, delay / 60);
} else {
return getString(R.string.delay_hours, delay / 3600);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == IntentConsts.API_KEY_REQUEST) {
if (resultCode == RESULT_OK) {
String apiKey = data.getStringExtra(IntentConsts.API_KEY);
presenter.updateApiKey(apiKey);
} else {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), R.string.api_key_error, Snackbar.LENGTH_LONG);
snackbar.show();
}
}
}
/**
* Handles clicking of the Get API Key button
*
* @param view the clicked view
*/
public void onGetApiKeyClicked(View view) {
presenter.onGetApiKeyClicked();
}
/**
* Toggles the locking of the API Key text field
*
* @param shouldLock whether or not the field should be locked
*/
@Override
public void lockApiKeyText(boolean shouldLock) {
apiKeyLocked = shouldLock;
apiKeyView.setFocusable(!shouldLock);
apiKeyView.setFocusableInTouchMode(!shouldLock);
apiKeyView.setEnabled(!shouldLock);
int buttonTextRes = shouldLock ? R.string.api_key_edit : R.string.api_key_get;
apiKeyButton.setText(buttonTextRes);
}
/**
* Launches the API Key retrieval activity
*/
@Override
public void startApiKeyActivity() {
Intent intent = new Intent(this, ApiKeyActivity.class);
startActivityForResult(intent, IntentConsts.API_KEY_REQUEST);
}
/**
* Displays a {@link Snackbar} with a given message
*
* @param message the message to display
*/
@Override
public void showSnackbar(String message) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), message, Snackbar.LENGTH_SHORT);
snackbar.show();
}
/**
* Displays a {@link Snackbar} with a given message
*
* @param messageResId the string id of the message to display
*/
@Override
public void showSnackbar(int messageResId) {
Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), messageResId, Snackbar.LENGTH_SHORT);
snackbar.show();
}
/**
* Toggles the error message on the API Key field
*
* @param showError
*/
@Override
public void showInvalidApiKeyError(boolean showError) {
String error = showError ? getString(R.string.invalid_api_key) : null;
apiKeyView.setError(error);
}
/**
* @return whether the API Key text field is locked
*/
@Override
public boolean isApiKeyLocked() {
return apiKeyLocked;
}
/**
* @return the text of the API Key textfield
*/
@Override
public String getApiKeyText() {
return apiKeyView.getText().toString().trim();
}
/**
* Shows the interval selector dialog
*
* @param v the view that was clicked
*/
public void showIntervalDialog(View v) {
DelayDialogFragment ddf = new DelayDialogFragment();
ddf.setOnDelaySetListener(MainActivity.this);
ddf.show(getSupportFragmentManager(), "tag");
}
/**
* Handles the delay being set from the dialog
*
* @param delay the delay that was set
*/
@Override
public void onDelaySet(long delay) {
presenter.updateDelay(delay);
}
/**
* Handles the donation button click
*
* @param view the view that was clicked
*/
public void onDonationClicked(View view) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse(TRADE_URL));
startActivity(browserIntent);
}
@Override
protected void onPause() {
presenter.setBackgroundTaskScheduler(new BackgroundTaskScheduler(this));
presenter.onActivityExiting();
super.onPause();
}
private void showInvalidApiKeyDialog() {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setTitle(R.string.invalid_api_key)
.setMessage(R.string.invalid_api_key_message)
.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
finish();
}
})
.setNegativeButton(R.string.no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
/**
* TextWatcher for the API Key text field
*/
private TextWatcher mApiKeyErrorWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void afterTextChanged(Editable editable) {
presenter.onApiKeyTextUpdated(editable);
}
};
}
| 9,153 | 0.646686 | 0.642974 | 298 | 29.7349 | 27.066166 | 132 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.379195 | false | false | 15 |
2e84ff868e228ceb1d6e2a1f0d78b838b66e9978 | 35,485,019,811,022 | 1b501a82f796e6d45de603c32bc47a5b26cf0041 | /src/main/java/com/flyingwolf/javacode/socket/InetAddressDemo.java | 5f6320223b1eb72cd2db403532baaa6e5fea57ed | []
| no_license | flying-wolf/learn | https://github.com/flying-wolf/learn | 92a4b7a4125be68b62823ecf989f683fa6e764e8 | b12e5db4f43d7e98f71d4272bacc834498204e87 | refs/heads/master | 2021-01-19T12:29:35.167000 | 2017-05-22T10:18:48 | 2017-05-22T10:18:48 | 88,033,054 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.flyingwolf.javacode.socket;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* InetAddress类用于标识网络上的硬件资源,标识互联网协议(IP)地址。
*
*/
public class InetAddressDemo {
/**
* 显示本机IP信息
*/
public static void viewLocalHost(){
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println("pc-name:"+address.getHostName());
System.out.println("ip:"+address.getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
/**
* 根据传入参数显示IP信息
*/
public static void viewHostByName(String name){
try {
InetAddress address = InetAddress.getByName(name);
System.out.println("pc-name:"+address.getHostName());
System.out.println("ip:"+address.getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
viewLocalHost();
viewHostByName("192.168.1.235");
}
}
| UTF-8 | Java | 1,044 | java | InetAddressDemo.java | Java | [
{
"context": "[] args) {\r\n\t\tviewLocalHost();\r\n\t\tviewHostByName(\"192.168.1.235\");\r\n\t}\r\n\t\r\n}\r\n",
"end": 949,
"score": 0.9997104406356812,
"start": 936,
"tag": "IP_ADDRESS",
"value": "192.168.1.235"
}
]
| null | []
| package com.flyingwolf.javacode.socket;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* InetAddress类用于标识网络上的硬件资源,标识互联网协议(IP)地址。
*
*/
public class InetAddressDemo {
/**
* 显示本机IP信息
*/
public static void viewLocalHost(){
try {
InetAddress address = InetAddress.getLocalHost();
System.out.println("pc-name:"+address.getHostName());
System.out.println("ip:"+address.getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
/**
* 根据传入参数显示IP信息
*/
public static void viewHostByName(String name){
try {
InetAddress address = InetAddress.getByName(name);
System.out.println("pc-name:"+address.getHostName());
System.out.println("ip:"+address.getHostAddress());
} catch (UnknownHostException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
viewLocalHost();
viewHostByName("192.168.1.235");
}
}
| 1,044 | 0.662863 | 0.65249 | 43 | 20.418604 | 19.916374 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.581395 | false | false | 15 |
d9362f72907bb262f87d5cc99f49de45151c6409 | 33,844,342,306,842 | a17bca598972424745eec9080645afec93f62b77 | /hw4-service-billing-serenatse/src/main/java/edu/uci/ics/sctse/service/billing/database/CustomerDatabase.java | 6279f7a08373447452c36745d0d4c62dc63fbfd6 | []
| no_license | serenatse98/Fabflix | https://github.com/serenatse98/Fabflix | cf979e1b89a81d0de6932f356b177f9d77e2b155 | e208ce151e047d8def2295bd2183ae73135427c2 | refs/heads/master | 2022-04-10T18:02:08.659000 | 2020-02-23T01:17:17 | 2020-02-23T01:17:17 | 242,426,065 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package edu.uci.ics.sctse.service.billing.database;
import edu.uci.ics.sctse.service.billing.BillingService;
import edu.uci.ics.sctse.service.billing.logger.ServiceLogger;
import edu.uci.ics.sctse.service.billing.objects.Customer;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class CustomerDatabase
{
public static void insertCustomerIntoDB(String email, String firstName, String lastName, String ccid, String address)
throws SQLException
{
ServiceLogger.LOGGER.info("Inserting customer into DB...");
String query = "INSERT INTO customers (email, firstName, lastName, ccId, address) " +
"VALUES (?, ?, ?, ?, ?);";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ps.setString(2, firstName);
ps.setString(3, lastName);
ps.setString(4, ccid);
ps.setString(5, address);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ps.execute();
ServiceLogger.LOGGER.info("Query succeeded");
}
public static boolean isCustomerInDB(String email)
throws SQLException
{
ServiceLogger.LOGGER.info("Checking if user's email is in DB...");
String query = "SELECT * FROM customers WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ResultSet rs = ps.executeQuery();
ServiceLogger.LOGGER.info("Query succeeded");
return rs.next();
}
public static void updateCustomerInDB(String email, String firstName, String lastName, String ccid, String address)
throws SQLException
{
ServiceLogger.LOGGER.info("Updating customer...");
String query = "UPDATE customers SET firstName = ?, lastName = ?, ccId = ?, address = ? WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, firstName);
ps.setString(2, lastName);
ps.setString(3, ccid);
ps.setString(4, address);
ps.setString(5, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ps.execute();
ServiceLogger.LOGGER.info("Query succeeded");
}
public static Customer getCustomerFromDB(String email)
throws SQLException
{
ServiceLogger.LOGGER.info("Retrieving customer from DB...");
String query = "SELECT email, firstName, lastName, ccId, address FROM customers WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ResultSet rs = ps.executeQuery();
ServiceLogger.LOGGER.info("Query succeeded");
Customer customer = new Customer();
if (rs.next())
{
customer = new Customer(
rs.getString("email"),
rs.getString("firstName"),
rs.getString("lastName"),
rs.getString("ccId"),
rs.getString("address"));
}
return customer;
}
}
| UTF-8 | Java | 3,343 | java | CustomerDatabase.java | Java | [
{
"context": "tic void insertCustomerIntoDB(String email, String firstName, String lastName, String ccid, String address)\n ",
"end": 432,
"score": 0.9707174897193909,
"start": 423,
"tag": "NAME",
"value": "firstName"
},
{
"context": "tomerIntoDB(String email, String firstName, String lastName, String ccid, String address)\n throws ",
"end": 449,
"score": 0.9216755032539368,
"start": 441,
"tag": "NAME",
"value": "lastName"
},
{
"context": " String query = \"INSERT INTO customers (email, firstName, lastName, ccId, address) \" +\n \"VA",
"end": 650,
"score": 0.9966707825660706,
"start": 641,
"tag": "NAME",
"value": "firstName"
},
{
"context": " query = \"INSERT INTO customers (email, firstName, lastName, ccId, address) \" +\n \"VALUES (?, ?",
"end": 660,
"score": 0.9942597150802612,
"start": 652,
"tag": "NAME",
"value": "lastName"
},
{
"context": " ps.setString(1, email);\n ps.setString(2, firstName);\n ps.setString(3, lastName);\n ps.s",
"end": 869,
"score": 0.9968814849853516,
"start": 860,
"tag": "NAME",
"value": "firstName"
},
{
"context": "s.setString(2, firstName);\n ps.setString(3, lastName);\n ps.setString(4, ccid);\n ps.setSt",
"end": 904,
"score": 0.9924716949462891,
"start": 896,
"tag": "NAME",
"value": "lastName"
},
{
"context": "tatic void updateCustomerInDB(String email, String firstName, String lastName, String ccid, String address)\n ",
"end": 1745,
"score": 0.973365068435669,
"start": 1736,
"tag": "NAME",
"value": "firstName"
},
{
"context": "ustomerInDB(String email, String firstName, String lastName, String ccid, String address)\n throws ",
"end": 1762,
"score": 0.9293931126594543,
"start": 1754,
"tag": "NAME",
"value": "lastName"
},
{
"context": ").prepareStatement(query);\n ps.setString(1, firstName);\n ps.setString(2, lastName);\n ps.s",
"end": 2119,
"score": 0.9938592314720154,
"start": 2110,
"tag": "NAME",
"value": "firstName"
},
{
"context": "s.setString(1, firstName);\n ps.setString(2, lastName);\n ps.setString(3, ccid);\n ps.setSt",
"end": 2154,
"score": 0.9655523896217346,
"start": 2146,
"tag": "NAME",
"value": "lastName"
},
{
"context": "om DB...\");\n\n String query = \"SELECT email, firstName, lastName, ccId, address FROM customers WHERE ema",
"end": 2621,
"score": 0.9988418817520142,
"start": 2612,
"tag": "NAME",
"value": "firstName"
},
{
"context": "\n\n String query = \"SELECT email, firstName, lastName, ccId, address FROM customers WHERE email = ?;\";\n",
"end": 2631,
"score": 0.9990214109420776,
"start": 2623,
"tag": "NAME",
"value": "lastName"
},
{
"context": "tring(\"email\"),\n rs.getString(\"firstName\"),\n rs.getString(\"lastName\"),\n",
"end": 3160,
"score": 0.9989156723022461,
"start": 3151,
"tag": "NAME",
"value": "firstName"
},
{
"context": "g(\"firstName\"),\n rs.getString(\"lastName\"),\n rs.getString(\"ccId\"),\n ",
"end": 3206,
"score": 0.9990254640579224,
"start": 3198,
"tag": "NAME",
"value": "lastName"
}
]
| null | []
| package edu.uci.ics.sctse.service.billing.database;
import edu.uci.ics.sctse.service.billing.BillingService;
import edu.uci.ics.sctse.service.billing.logger.ServiceLogger;
import edu.uci.ics.sctse.service.billing.objects.Customer;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class CustomerDatabase
{
public static void insertCustomerIntoDB(String email, String firstName, String lastName, String ccid, String address)
throws SQLException
{
ServiceLogger.LOGGER.info("Inserting customer into DB...");
String query = "INSERT INTO customers (email, firstName, lastName, ccId, address) " +
"VALUES (?, ?, ?, ?, ?);";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ps.setString(2, firstName);
ps.setString(3, lastName);
ps.setString(4, ccid);
ps.setString(5, address);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ps.execute();
ServiceLogger.LOGGER.info("Query succeeded");
}
public static boolean isCustomerInDB(String email)
throws SQLException
{
ServiceLogger.LOGGER.info("Checking if user's email is in DB...");
String query = "SELECT * FROM customers WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ResultSet rs = ps.executeQuery();
ServiceLogger.LOGGER.info("Query succeeded");
return rs.next();
}
public static void updateCustomerInDB(String email, String firstName, String lastName, String ccid, String address)
throws SQLException
{
ServiceLogger.LOGGER.info("Updating customer...");
String query = "UPDATE customers SET firstName = ?, lastName = ?, ccId = ?, address = ? WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, firstName);
ps.setString(2, lastName);
ps.setString(3, ccid);
ps.setString(4, address);
ps.setString(5, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ps.execute();
ServiceLogger.LOGGER.info("Query succeeded");
}
public static Customer getCustomerFromDB(String email)
throws SQLException
{
ServiceLogger.LOGGER.info("Retrieving customer from DB...");
String query = "SELECT email, firstName, lastName, ccId, address FROM customers WHERE email = ?;";
PreparedStatement ps = BillingService.getCon().prepareStatement(query);
ps.setString(1, email);
ServiceLogger.LOGGER.info("Trying query: " + ps.toString());
ResultSet rs = ps.executeQuery();
ServiceLogger.LOGGER.info("Query succeeded");
Customer customer = new Customer();
if (rs.next())
{
customer = new Customer(
rs.getString("email"),
rs.getString("firstName"),
rs.getString("lastName"),
rs.getString("ccId"),
rs.getString("address"));
}
return customer;
}
}
| 3,343 | 0.630272 | 0.626683 | 93 | 34.946236 | 30.248564 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.967742 | false | false | 15 |
8f20a0135530c749935233b52633b26583955528 | 2,740,189,170,650 | 52370789b63b959b9e73e652dac172e1e9906201 | /Workspace/F18/src/com/gretb/Cat.java | 90bdcd656a7d86cb77c14a8cab448e8af4239ea0 | []
| no_license | jasonthorne/OCA_JavaProgrammer | https://github.com/jasonthorne/OCA_JavaProgrammer | 3905cb2a3cbe1e501db99205f9cdbe7380c63377 | 6f12d90886e8c06440a97e72f73d3cdd5da1c26a | refs/heads/master | 2021-07-06T02:45:24.049000 | 2020-09-23T21:05:07 | 2020-09-23T21:05:07 | 177,753,950 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gretb;
public class Cat {
int age;
String name;
double weight;
/*
* this is a Cat constructor that takes an int, a String and a double
* if you are creating a cat, you have to pass in arguments in that
* order i.e new Cat(12,"tibbles",2)
* the constructor then takes these three values and assigns them to the
* atributes of the newly created CAt
* so age is 12
* name is tibbles
* weight is 2.3
*/
Cat(int myAge,String myName,double myWeight)
{
//assigns the int sent to the constructor to be the age of the new cat
age=myAge;
//assigns the string sent to the constructor to be the name of the new cat
name=myName;
//assigns the double sent to the construcotr to be the name of the new cat
weight=myWeight;
System.out.println("cat constructor called");
// printMe();
}
//simple eat method that any cat can call
void eat() {
System.out.println(name+" is eating");
}
void printMe() {
System.out.println("printMe method called");
System.out.println("name of cat is "+name);
System.out.println("age of cat is "+age);
System.out.println("weight of Cat is "+weight);
}
}
| UTF-8 | Java | 1,136 | java | Cat.java | Java | [
{
"context": "s in arguments in that \n\t * order i.e new Cat(12,\"tibbles\",2)\n\t * the constructor then takes these three va",
"end": 257,
"score": 0.9595353603363037,
"start": 250,
"tag": "NAME",
"value": "tibbles"
},
{
"context": "the newly created CAt\n\t * so age is 12\n\t * name is tibbles\n\t * weight is 2.3\n\t */\n\tCat(int myAge,String myNa",
"end": 412,
"score": 0.9986646175384521,
"start": 405,
"tag": "NAME",
"value": "tibbles"
},
{
"context": " constructor to be the name of the new cat\n\t\tname=myName;\n\t\t//assigns the double sent to the construco",
"end": 657,
"score": 0.5363239645957947,
"start": 655,
"tag": "NAME",
"value": "my"
}
]
| null | []
| package com.gretb;
public class Cat {
int age;
String name;
double weight;
/*
* this is a Cat constructor that takes an int, a String and a double
* if you are creating a cat, you have to pass in arguments in that
* order i.e new Cat(12,"tibbles",2)
* the constructor then takes these three values and assigns them to the
* atributes of the newly created CAt
* so age is 12
* name is tibbles
* weight is 2.3
*/
Cat(int myAge,String myName,double myWeight)
{
//assigns the int sent to the constructor to be the age of the new cat
age=myAge;
//assigns the string sent to the constructor to be the name of the new cat
name=myName;
//assigns the double sent to the construcotr to be the name of the new cat
weight=myWeight;
System.out.println("cat constructor called");
// printMe();
}
//simple eat method that any cat can call
void eat() {
System.out.println(name+" is eating");
}
void printMe() {
System.out.println("printMe method called");
System.out.println("name of cat is "+name);
System.out.println("age of cat is "+age);
System.out.println("weight of Cat is "+weight);
}
}
| 1,136 | 0.696303 | 0.690141 | 38 | 28.894737 | 24.245226 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.763158 | false | false | 15 |
7df0226daf65d60590e2c550c76142c18f0fa3ca | 9,148,280,343,853 | 81a41c0f631b4756be2ff854e2e03738b3089572 | /tjava/CompoundSet.java | e604cda19155e1b46424afebac9b515f567ba72d | []
| no_license | thomasjeffreyandersontwin/HeroCombatSimulator | https://github.com/thomasjeffreyandersontwin/HeroCombatSimulator | 3d6b42f4c7b40509cd813df214258f633bff6479 | efb019c150f011e319a3c779500329b034f163d7 | refs/heads/master | 2021-05-06T16:28:17.088000 | 2018-03-09T08:02:56 | 2018-03-09T08:02:56 | 113,687,368 | 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 tjava;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
/**
*
* @param <T>
* @author twalker
*/
public class CompoundSet<T> implements Set<T> {
private Set set1;
private Set set2;
public CompoundSet(Set set1, Set set2) {
this.set1 = set1;
this.set2 = set2;
}
@Override
public int size() {
return set1.size() + set2.size();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean contains(Object o) {
return set1.contains(o) || set2.contains(o);
}
@Override
public Iterator<T> iterator() {
return new CompoundIterator<T>(set1.iterator(),set2.iterator());
}
@Override
public Object[] toArray() {
Object[] a = new Object[size()];
int index = 0;
for (T object : this) {
a[index++] = object;
}
return a;
}
@Override
public <X> X[] toArray(X[] a) {
X[] array;
Class componentType = a.getClass().getComponentType();
if (a.length < size()) {
// Make a new array of a's runtime type, but my contents:
array = (X[]) Array.newInstance(componentType, size());
}
else {
array = a;
}
int index = 0;
for (T object : this) {
array[index++] = (X)object;
}
if (array.length > size()) {
array[size()] = null;
}
return array;
}
@Override
public boolean add(T e) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean containsAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addAll(Collection<? extends T> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clear() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String toString() {
return Utilities.toCommaSeparateList(this, "{", "}");
}
}
| UTF-8 | Java | 2,726 | java | CompoundSet.java | Java | [
{
"context": "rt java.util.Set;\n\n/**\n *\n * @param <T>\n * @author twalker\n */\npublic class CompoundSet<T> implements Set<T>",
"end": 267,
"score": 0.9988667368888855,
"start": 260,
"tag": "USERNAME",
"value": "twalker"
}
]
| null | []
| /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package tjava;
import java.lang.reflect.Array;
import java.util.Collection;
import java.util.Iterator;
import java.util.Set;
/**
*
* @param <T>
* @author twalker
*/
public class CompoundSet<T> implements Set<T> {
private Set set1;
private Set set2;
public CompoundSet(Set set1, Set set2) {
this.set1 = set1;
this.set2 = set2;
}
@Override
public int size() {
return set1.size() + set2.size();
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean contains(Object o) {
return set1.contains(o) || set2.contains(o);
}
@Override
public Iterator<T> iterator() {
return new CompoundIterator<T>(set1.iterator(),set2.iterator());
}
@Override
public Object[] toArray() {
Object[] a = new Object[size()];
int index = 0;
for (T object : this) {
a[index++] = object;
}
return a;
}
@Override
public <X> X[] toArray(X[] a) {
X[] array;
Class componentType = a.getClass().getComponentType();
if (a.length < size()) {
// Make a new array of a's runtime type, but my contents:
array = (X[]) Array.newInstance(componentType, size());
}
else {
array = a;
}
int index = 0;
for (T object : this) {
array[index++] = (X)object;
}
if (array.length > size()) {
array[size()] = null;
}
return array;
}
@Override
public boolean add(T e) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean remove(Object o) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean containsAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addAll(Collection<? extends T> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clear() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String toString() {
return Utilities.toCommaSeparateList(this, "{", "}");
}
}
| 2,726 | 0.576302 | 0.570066 | 123 | 21.162601 | 21.255463 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.349593 | false | false | 15 |
7b6cdcca97577dfeac574ee08fd0fa78ff8e19bb | 32,641,751,460,026 | 536d23d5ebf6a3e443accfe44d6cab5e6d2fc935 | /fxgl-samples/src/main/java/sandbox/InitSample.java | 36fea8bd9b84d49589799733f8fa8b6bfcb83526 | [
"MIT"
]
| permissive | Ravanla/FXGL | https://github.com/Ravanla/FXGL | c7612c1f384546f3f4d12dcbf497ff7813ad170f | 25433dbdebb4c358eabe622063fac0ccc8a910f6 | refs/heads/master | 2020-07-15T23:39:22.367000 | 2019-08-06T18:29:33 | 2019-08-06T18:29:33 | 205,673,093 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* FXGL - JavaFX Game Library. The MIT License (MIT).
* Copyright (c) AlmasB (almaslvl@gmail.com).
* See LICENSE for details.
*/
package sandbox;
import com.almasb.fxgl.animation.Interpolators;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.entity.EntityView;
import com.almasb.fxgl.entity.components.CollidableComponent;
import com.almasb.fxgl.input.UserAction;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.HitBox;
import dev.DeveloperWASDControl;
import javafx.geometry.Point2D;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.util.Duration;
import static com.almasb.fxgl.dsl.FXGL.*;
/**
* Shows how to init a basic game object and attach it to the world
* using fluent API.
*
* @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)
*/
public class InitSample extends GameApplication {
// 1. define types of entities in the game using Enum
private enum Type {
PLAYER, NPC
}
@Override
protected void initSettings(GameSettings settings) {
settings.setWidth(800);
settings.setHeight(600);
settings.setTitle("InitSample");
settings.setVersion("0.1");
}
private Entity player;
private double scale = 1.0;
private double scaleY = 1.0;
private double angle = 0;
@Override
protected void initInput() {
getInput().addAction(new UserAction("Change view") {
@Override
protected void onActionBegin() {
//player.setView(new EntityView(new Rectangle(40, 30, Color.BLUE)));
}
}, KeyCode.F);
getInput().addAction(new UserAction("Change view 1") {
@Override
protected void onActionBegin() {
//player.setView(texture("bird.png").toAnimatedTexture(2, Duration.seconds(0.33)).play());
}
}, KeyCode.G);
onKey(KeyCode.Q, () -> {
scale += 0.1;
player.setScaleX(scale);
});
onKey(KeyCode.E, () -> {
scaleY += 0.1;
player.setScaleY(scaleY);
});
onKey(KeyCode.R, () -> {
angle -= 5;
player.setRotation(angle);
});
onKey(KeyCode.T, () -> {
angle += 5;
player.setRotation(angle);
});
}
@Override
protected void initGame() {
player = entityBuilder()
.type(Type.PLAYER)
.at(100, 150)
.viewWithBBox("brick.png")
.with(new CollidableComponent(true), new DeveloperWASDControl())
.zIndex(250)
.buildAndAttach();
player.getTransformComponent().setRotationOrigin(new Point2D(64, 64));
player.getTransformComponent().scaleOriginXProperty().setValue(64);
player.getTransformComponent().scaleOriginYProperty().setValue(64);
Entity player2 = new Entity();
player2.setType(Type.NPC);
player2.setPosition(100, 100);
//player2.setView(new EntityView(new Rectangle(40, 40, Color.RED)));
player2.getBoundingBoxComponent().addHitBox(new HitBox(BoundingShape.box(40, 40)));
player2.addComponent(new CollidableComponent(true));
player2.getTransformComponent().setZ(250);
getGameWorld().addEntity(player2);
animationBuilder().delay(Duration.seconds(0.25))
.duration(Duration.seconds(1))
.interpolator(Interpolators.BOUNCE.EASE_OUT())
//.repeat(2)
.rotate(player2, player)
.from(0)
.to(360)
.buildAndPlay();
//translate(player, new Point2D(560, 300), Duration.seconds(2));
// player.getViewComponent().addClickListener(() -> {
// System.out.println("CLICKED");
// });
// entityBuilder()
// .type(Type.PLAYER)
// .at(120, 120)
// .viewWithBBox(new Rectangle(40, 40, Color.GREEN))
// .with(new CollidableComponent(true))
// .zIndex(100)
// .buildAndAttach();
}
@Override
protected void initPhysics() {
getPhysicsWorld().addCollisionHandler(new CollisionHandler(Type.PLAYER, Type.NPC) {
@Override
protected void onCollisionBegin(Entity a, Entity b) {
t.setText("Collision");
}
@Override
protected void onCollisionEnd(Entity a, Entity b) {
t.setText("No collision");
}
});
}
private Text t;
private GraphicsContext g;
@Override
protected void initUI() {
t = new Text();
t.setTranslateY(100);
getGameScene().addUINode(t);
Canvas canvas = new Canvas(FXGL.getAppWidth(), FXGL.getAppHeight());
g = canvas.getGraphicsContext2D();
g.setFill(Color.YELLOWGREEN);
//getGameScene().addUINode(canvas);
}
@Override
protected void onUpdate(double tpf) {
g.clearRect(0, 0, FXGL.getAppWidth(), FXGL.getAppHeight());
// var points = Debug.INSTANCE.getPoints();
//
// while (!points.isEmpty()) {
// var p = points.poll();
//
// g.fillOval(p.getX() - 2.5, p.getY() - 2.5, 5, 5);
// }
}
public static void main(String[] args) {
launch(args);
}
}
| UTF-8 | Java | 5,751 | java | InitSample.java | Java | [
{
"context": "e Library. The MIT License (MIT).\n * Copyright (c) AlmasB (almaslvl@gmail.com).\n * See LICENSE for details.",
"end": 80,
"score": 0.7751641869544983,
"start": 74,
"tag": "NAME",
"value": "AlmasB"
},
{
"context": ". The MIT License (MIT).\n * Copyright (c) AlmasB (almaslvl@gmail.com).\n * See LICENSE for details.\n */\n\npackage sandbo",
"end": 100,
"score": 0.9999302625656128,
"start": 82,
"tag": "EMAIL",
"value": "almaslvl@gmail.com"
},
{
"context": "it to the world\n * using fluent API.\n *\n * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)\n */\npublic class In",
"end": 1116,
"score": 0.9998992085456848,
"start": 1097,
"tag": "NAME",
"value": "Almas Baimagambetov"
},
{
"context": "ng fluent API.\n *\n * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)\n */\npublic class InitSample",
"end": 1124,
"score": 0.9846145510673523,
"start": 1118,
"tag": "USERNAME",
"value": "AlmasB"
},
{
"context": " API.\n *\n * @author Almas Baimagambetov (AlmasB) (almaslvl@gmail.com)\n */\npublic class InitSample extends GameApplicat",
"end": 1145,
"score": 0.9999271035194397,
"start": 1127,
"tag": "EMAIL",
"value": "almaslvl@gmail.com"
}
]
| null | []
| /*
* FXGL - JavaFX Game Library. The MIT License (MIT).
* Copyright (c) AlmasB (<EMAIL>).
* See LICENSE for details.
*/
package sandbox;
import com.almasb.fxgl.animation.Interpolators;
import com.almasb.fxgl.dsl.FXGL;
import com.almasb.fxgl.app.GameApplication;
import com.almasb.fxgl.entity.Entity;
import com.almasb.fxgl.app.GameSettings;
import com.almasb.fxgl.entity.EntityView;
import com.almasb.fxgl.entity.components.CollidableComponent;
import com.almasb.fxgl.input.UserAction;
import com.almasb.fxgl.physics.BoundingShape;
import com.almasb.fxgl.physics.CollisionHandler;
import com.almasb.fxgl.physics.HitBox;
import dev.DeveloperWASDControl;
import javafx.geometry.Point2D;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.KeyCode;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Text;
import javafx.util.Duration;
import static com.almasb.fxgl.dsl.FXGL.*;
/**
* Shows how to init a basic game object and attach it to the world
* using fluent API.
*
* @author <NAME> (AlmasB) (<EMAIL>)
*/
public class InitSample extends GameApplication {
// 1. define types of entities in the game using Enum
private enum Type {
PLAYER, NPC
}
@Override
protected void initSettings(GameSettings settings) {
settings.setWidth(800);
settings.setHeight(600);
settings.setTitle("InitSample");
settings.setVersion("0.1");
}
private Entity player;
private double scale = 1.0;
private double scaleY = 1.0;
private double angle = 0;
@Override
protected void initInput() {
getInput().addAction(new UserAction("Change view") {
@Override
protected void onActionBegin() {
//player.setView(new EntityView(new Rectangle(40, 30, Color.BLUE)));
}
}, KeyCode.F);
getInput().addAction(new UserAction("Change view 1") {
@Override
protected void onActionBegin() {
//player.setView(texture("bird.png").toAnimatedTexture(2, Duration.seconds(0.33)).play());
}
}, KeyCode.G);
onKey(KeyCode.Q, () -> {
scale += 0.1;
player.setScaleX(scale);
});
onKey(KeyCode.E, () -> {
scaleY += 0.1;
player.setScaleY(scaleY);
});
onKey(KeyCode.R, () -> {
angle -= 5;
player.setRotation(angle);
});
onKey(KeyCode.T, () -> {
angle += 5;
player.setRotation(angle);
});
}
@Override
protected void initGame() {
player = entityBuilder()
.type(Type.PLAYER)
.at(100, 150)
.viewWithBBox("brick.png")
.with(new CollidableComponent(true), new DeveloperWASDControl())
.zIndex(250)
.buildAndAttach();
player.getTransformComponent().setRotationOrigin(new Point2D(64, 64));
player.getTransformComponent().scaleOriginXProperty().setValue(64);
player.getTransformComponent().scaleOriginYProperty().setValue(64);
Entity player2 = new Entity();
player2.setType(Type.NPC);
player2.setPosition(100, 100);
//player2.setView(new EntityView(new Rectangle(40, 40, Color.RED)));
player2.getBoundingBoxComponent().addHitBox(new HitBox(BoundingShape.box(40, 40)));
player2.addComponent(new CollidableComponent(true));
player2.getTransformComponent().setZ(250);
getGameWorld().addEntity(player2);
animationBuilder().delay(Duration.seconds(0.25))
.duration(Duration.seconds(1))
.interpolator(Interpolators.BOUNCE.EASE_OUT())
//.repeat(2)
.rotate(player2, player)
.from(0)
.to(360)
.buildAndPlay();
//translate(player, new Point2D(560, 300), Duration.seconds(2));
// player.getViewComponent().addClickListener(() -> {
// System.out.println("CLICKED");
// });
// entityBuilder()
// .type(Type.PLAYER)
// .at(120, 120)
// .viewWithBBox(new Rectangle(40, 40, Color.GREEN))
// .with(new CollidableComponent(true))
// .zIndex(100)
// .buildAndAttach();
}
@Override
protected void initPhysics() {
getPhysicsWorld().addCollisionHandler(new CollisionHandler(Type.PLAYER, Type.NPC) {
@Override
protected void onCollisionBegin(Entity a, Entity b) {
t.setText("Collision");
}
@Override
protected void onCollisionEnd(Entity a, Entity b) {
t.setText("No collision");
}
});
}
private Text t;
private GraphicsContext g;
@Override
protected void initUI() {
t = new Text();
t.setTranslateY(100);
getGameScene().addUINode(t);
Canvas canvas = new Canvas(FXGL.getAppWidth(), FXGL.getAppHeight());
g = canvas.getGraphicsContext2D();
g.setFill(Color.YELLOWGREEN);
//getGameScene().addUINode(canvas);
}
@Override
protected void onUpdate(double tpf) {
g.clearRect(0, 0, FXGL.getAppWidth(), FXGL.getAppHeight());
// var points = Debug.INSTANCE.getPoints();
//
// while (!points.isEmpty()) {
// var p = points.poll();
//
// g.fillOval(p.getX() - 2.5, p.getY() - 2.5, 5, 5);
// }
}
public static void main(String[] args) {
launch(args);
}
}
| 5,716 | 0.593288 | 0.573118 | 198 | 28.045454 | 23.114187 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.575758 | false | false | 15 |
a060cd4813c1b1313003ac40f600cea4c9d6a8f4 | 11,605,001,664,540 | 8913ea9db9fc798f34071f1fa2f4d675c4dc8701 | /Strings/IsStringRotationOfAnother.java | b7e40d769f163dc7ca8523e19ab40d71e2c472cb | []
| no_license | sajida3010/Code_Base | https://github.com/sajida3010/Code_Base | 9367806807147b9e671700df757b776a289c0e20 | f5d3742337f70683a1fbc32caf97b89a93678fde | refs/heads/master | 2020-04-16T18:59:44.140000 | 2019-01-15T11:56:40 | 2019-01-15T11:56:40 | 165,842,935 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Strings;
public class IsStringRotationOfAnother {
public static void main(String[] args) {
String str1 = "JavaJ2eeStrutsHibernate";
String str2 = "StrutsHibernateJavaJee";
isRotation(str1, str2);
}
public static void isRotation(String s1, String s2){
if(s1.length() != s2.length())
System.out.println("String 2 is not rotated version of String 1");
else{
String s3 = s1 + s1;
if(s3.contains(s2)){
System.out.println("String 2 is rotated version of String 1");
}else {
System.out.println("String 2 is not rotated version of String 1");
}
}
}
}
| UTF-8 | Java | 709 | java | IsStringRotationOfAnother.java | Java | []
| null | []
| package Strings;
public class IsStringRotationOfAnother {
public static void main(String[] args) {
String str1 = "JavaJ2eeStrutsHibernate";
String str2 = "StrutsHibernateJavaJee";
isRotation(str1, str2);
}
public static void isRotation(String s1, String s2){
if(s1.length() != s2.length())
System.out.println("String 2 is not rotated version of String 1");
else{
String s3 = s1 + s1;
if(s3.contains(s2)){
System.out.println("String 2 is rotated version of String 1");
}else {
System.out.println("String 2 is not rotated version of String 1");
}
}
}
}
| 709 | 0.574048 | 0.545839 | 22 | 31.227272 | 25.373451 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.454545 | false | false | 15 |
22a91f9784f4ca396af48cb8a9896b7642422ef7 | 11,020,886,084,343 | 297a679af8887887b806edfa710209e4b0646ec8 | /src/main/java/com/news/servlet/ShowNewInfosServlet.java | 82322f39850690d5b09b3e90a1fd2b672ebc371a | []
| no_license | VERATUM/java_review_beforeSpringboot | https://github.com/VERATUM/java_review_beforeSpringboot | 8597c5147cdc8861739eeaa4b1af38889e3e7dc4 | f10461704371c0a4ce810407af06669fe60cc537 | refs/heads/master | 2020-04-20T11:57:36.432000 | 2019-02-02T12:47:07 | 2019-02-02T12:47:07 | 168,830,732 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.news.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.news.entity.NewInfo;
import com.news.service.NewInfoService;
import com.news.service.impl.NewInfoServiceImpl;
/**
* Servlet implementation class showNewInfosServlet
*/
@WebServlet("/news/ShowNewInfosServlet")
public class ShowNewInfosServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ShowNewInfosServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 访问此servlet可对newinfo进行删除操作
NewInfoService newInfoService = new NewInfoServiceImpl();
List<NewInfo> newInfos = newInfoService.queryNewInfo();
request.setAttribute("list", newInfos);
request.getRequestDispatcher("Gson/delNewSB.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| UTF-8 | Java | 1,640 | java | ShowNewInfosServlet.java | Java | []
| null | []
| package com.news.servlet;
import java.io.IOException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.news.entity.NewInfo;
import com.news.service.NewInfoService;
import com.news.service.impl.NewInfoServiceImpl;
/**
* Servlet implementation class showNewInfosServlet
*/
@WebServlet("/news/ShowNewInfosServlet")
public class ShowNewInfosServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public ShowNewInfosServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// 访问此servlet可对newinfo进行删除操作
NewInfoService newInfoService = new NewInfoServiceImpl();
List<NewInfo> newInfos = newInfoService.queryNewInfo();
request.setAttribute("list", newInfos);
request.getRequestDispatcher("Gson/delNewSB.jsp").forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| 1,640 | 0.750309 | 0.749691 | 50 | 30.360001 | 29.708424 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.04 | false | false | 15 |
3e5f156abc998ed7780912b3a8f740b72092f044 | 103,079,287,058 | e1dc53ff0eab827a86caaabcfe067f67c32edce1 | /src/com/HVSoft/FXframework/Windows.java | 62245ab38673cf161d8f1c97b39f222a398089bf | []
| no_license | HVSoft/HVSFrame | https://github.com/HVSoft/HVSFrame | 1a02ae15d57475fae47fc812fd5d1d9f453420cf | a5ef650ca9a141bab5c05f5643d9755848f2d418 | refs/heads/master | 2021-04-30T12:38:28.197000 | 2018-02-13T21:01:36 | 2018-02-13T21:01:36 | 121,278,364 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
*
*/
package com.HVSoft.FXframework;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Screen;
/**
* @author Harsha_V
* com.HVSoft.FXframework
*/
public class Windows {
Colors col=new Colors();
Texts txt=new Texts();
//Scene properties
private static int sceneWidth=0;
private static int sceneHeight=0;
private static final double screenCornerDelta=0.95;
//Header properties
private static final int headerWidth=100;//in percentage width of window
private static final int headerHeight=5;//in percentage height of window
private static final double headerTextRightPosX=1;//in percentage (0.5-center)
private static final double headerTextRightPosY=0.5;//in percentage (0.5-center)
private static final double headerTextRightFontSize=30;
//Constructor
Windows(){
//to Fullscreen
Screen screen = Screen.getPrimary();
Rectangle2D visualBounds = screen.getVisualBounds();
sceneWidth=(int) (visualBounds.getWidth()*screenCornerDelta);
sceneHeight=(int) (visualBounds.getHeight()*screenCornerDelta);
}
//Adds a header to pre-existing group
public Group addHeader() {
int headerWidthAbsolute=headerWidth*sceneWidth/100;
int headerHeightAbsolute=headerHeight*sceneHeight/100;
int headerTextRightPosXAbsolute=(int) (headerTextRightPosX*headerWidthAbsolute-(headerTextRightFontSize/1.8*txt.getHeaderTextRight().length()));
int headerTextRightPosYAbsolute=(int) (headerTextRightPosY*headerHeightAbsolute+(headerTextRightFontSize/3));
Rectangle headerRect = new Rectangle(0,0,headerWidthAbsolute,headerHeightAbsolute);
headerRect.setFill(col.getHeaderBackgroundColor());
Text headerTextRight=new Text();
headerTextRight.setX(headerTextRightPosXAbsolute);
headerTextRight.setY(headerTextRightPosYAbsolute);
headerTextRight.setText(txt.getHeaderTextRight());
headerTextRight.setStrokeWidth(1);
headerTextRight.setFill(col.getHeaderTextRightColor());
headerTextRight.setFont(Font.font(headerTextRightFontSize));
headerTextRight.setStroke(col.getHeaderTextRightColor());
return new Group(headerRect,headerTextRight);
}
public Scene createScene(Group group) {
return new Scene(group,sceneWidth,sceneHeight);
}
}
| UTF-8 | Java | 2,431 | java | Windows.java | Java | [
{
"context": "t;\r\nimport javafx.stage.Screen;\r\n\r\n/**\r\n * @author Harsha_V\r\n * com.HVSoft.FXframework\r\n */\r\npublic class W",
"end": 298,
"score": 0.6638087034225464,
"start": 292,
"tag": "NAME",
"value": "Harsha"
},
{
"context": "ort javafx.stage.Screen;\r\n\r\n/**\r\n * @author Harsha_V\r\n * com.HVSoft.FXframework\r\n */\r\npublic class Win",
"end": 300,
"score": 0.7421884536743164,
"start": 299,
"tag": "USERNAME",
"value": "V"
}
]
| null | []
| /**
*
*/
package com.HVSoft.FXframework;
import javafx.geometry.Rectangle2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.shape.Rectangle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Screen;
/**
* @author Harsha_V
* com.HVSoft.FXframework
*/
public class Windows {
Colors col=new Colors();
Texts txt=new Texts();
//Scene properties
private static int sceneWidth=0;
private static int sceneHeight=0;
private static final double screenCornerDelta=0.95;
//Header properties
private static final int headerWidth=100;//in percentage width of window
private static final int headerHeight=5;//in percentage height of window
private static final double headerTextRightPosX=1;//in percentage (0.5-center)
private static final double headerTextRightPosY=0.5;//in percentage (0.5-center)
private static final double headerTextRightFontSize=30;
//Constructor
Windows(){
//to Fullscreen
Screen screen = Screen.getPrimary();
Rectangle2D visualBounds = screen.getVisualBounds();
sceneWidth=(int) (visualBounds.getWidth()*screenCornerDelta);
sceneHeight=(int) (visualBounds.getHeight()*screenCornerDelta);
}
//Adds a header to pre-existing group
public Group addHeader() {
int headerWidthAbsolute=headerWidth*sceneWidth/100;
int headerHeightAbsolute=headerHeight*sceneHeight/100;
int headerTextRightPosXAbsolute=(int) (headerTextRightPosX*headerWidthAbsolute-(headerTextRightFontSize/1.8*txt.getHeaderTextRight().length()));
int headerTextRightPosYAbsolute=(int) (headerTextRightPosY*headerHeightAbsolute+(headerTextRightFontSize/3));
Rectangle headerRect = new Rectangle(0,0,headerWidthAbsolute,headerHeightAbsolute);
headerRect.setFill(col.getHeaderBackgroundColor());
Text headerTextRight=new Text();
headerTextRight.setX(headerTextRightPosXAbsolute);
headerTextRight.setY(headerTextRightPosYAbsolute);
headerTextRight.setText(txt.getHeaderTextRight());
headerTextRight.setStrokeWidth(1);
headerTextRight.setFill(col.getHeaderTextRightColor());
headerTextRight.setFont(Font.font(headerTextRightFontSize));
headerTextRight.setStroke(col.getHeaderTextRightColor());
return new Group(headerRect,headerTextRight);
}
public Scene createScene(Group group) {
return new Scene(group,sceneWidth,sceneHeight);
}
}
| 2,431 | 0.76306 | 0.749897 | 72 | 31.763889 | 29.375204 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.736111 | false | false | 15 |
9b4ce562a5bfbdc98a2d88974039b52e394e6311 | 31,808,527,806,169 | c41f77b09cbc6d76b9db54e087d3dcc6ab092598 | /src/main/java/com/zr/elasticsearch/util/RestApi.java | 0dce19241cb9b229486a967fe4d62ae07f1cafef | []
| no_license | nicaide331/elasticsearch | https://github.com/nicaide331/elasticsearch | 63aa9b7d5ba7dfa7adc7173d0d0577b13b2e083d | ce687b788c251de711fcee4551cb3cc463669650 | refs/heads/master | 2022-10-24T09:50:24.868000 | 2020-01-03T02:11:04 | 2020-01-03T02:11:04 | 231,494,138 | 0 | 0 | null | false | 2022-10-05T18:21:07 | 2020-01-03T02:10:57 | 2020-01-03T02:11:48 | 2022-10-05T18:21:05 | 9,072 | 0 | 0 | 4 | Java | false | false | package com.zr.elasticsearch.util;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 描述
*
* @author nicaide
* @date 2019年12月27日 15:06:00
*/
public class RestApi {
public void indexApi() {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("user", "Richard");
jsonMap.put("postDate", new Date());
jsonMap.put("message", "trying out Elasticsearch");
IndexRequest request = new IndexRequest("zr")
.id("1")
.source(jsonMap);
}
public void getElasticSearch (String documentId){
GetRequest request = new GetRequest(Utils.INDEX, documentId);
//不获取数据源数据,默认获取的
// request.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE);
//要返回的字段
String[] includes = {"title", "cast"};
// //排除的字段
String[] excludes = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
request.fetchSourceContext(fetchSourceContext);
// request.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
// request.storedFields("_none_"); // 禁止存储任何字段
//返回的 GetResponse 对象包含要请求的文档数据(包含元数据和字段)
try {
GetResponse getResponse = Connection.getConnection().get(request, RequestOptions.DEFAULT);
if (getResponse.isExists()) {
long version = getResponse.getVersion();
String sourceAsString = getResponse.getSourceAsString(); // string 形式
Map<String, Object> sourceAsMap = getResponse.getSourceAsMap(); // map
byte[] sourceAsBytes = getResponse.getSourceAsBytes(); // 字节形式
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 2,296 | java | RestApi.java | Java | [
{
"context": "ap;\nimport java.util.Map;\n\n/**\n * 描述\n *\n * @author nicaide\n * @date 2019年12月27日 15:06:00\n */\npublic class Re",
"end": 473,
"score": 0.9996912479400635,
"start": 466,
"tag": "USERNAME",
"value": "nicaide"
},
{
"context": "p = new HashMap<>();\n jsonMap.put(\"user\", \"Richard\");\n jsonMap.put(\"postDate\", new Date());\n ",
"end": 652,
"score": 0.9892228245735168,
"start": 645,
"tag": "NAME",
"value": "Richard"
}
]
| null | []
| package com.zr.elasticsearch.util;
import org.elasticsearch.action.get.GetRequest;
import org.elasticsearch.action.get.GetResponse;
import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.common.Strings;
import org.elasticsearch.search.fetch.subphase.FetchSourceContext;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 描述
*
* @author nicaide
* @date 2019年12月27日 15:06:00
*/
public class RestApi {
public void indexApi() {
Map<String, Object> jsonMap = new HashMap<>();
jsonMap.put("user", "Richard");
jsonMap.put("postDate", new Date());
jsonMap.put("message", "trying out Elasticsearch");
IndexRequest request = new IndexRequest("zr")
.id("1")
.source(jsonMap);
}
public void getElasticSearch (String documentId){
GetRequest request = new GetRequest(Utils.INDEX, documentId);
//不获取数据源数据,默认获取的
// request.fetchSourceContext(FetchSourceContext.DO_NOT_FETCH_SOURCE);
//要返回的字段
String[] includes = {"title", "cast"};
// //排除的字段
String[] excludes = Strings.EMPTY_ARRAY;
FetchSourceContext fetchSourceContext = new FetchSourceContext(true, includes, excludes);
request.fetchSourceContext(fetchSourceContext);
// request.fetchSourceContext(new FetchSourceContext(false)); // 禁用 _source 字段
// request.storedFields("_none_"); // 禁止存储任何字段
//返回的 GetResponse 对象包含要请求的文档数据(包含元数据和字段)
try {
GetResponse getResponse = Connection.getConnection().get(request, RequestOptions.DEFAULT);
if (getResponse.isExists()) {
long version = getResponse.getVersion();
String sourceAsString = getResponse.getSourceAsString(); // string 形式
Map<String, Object> sourceAsMap = getResponse.getSourceAsMap(); // map
byte[] sourceAsBytes = getResponse.getSourceAsBytes(); // 字节形式
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 2,296 | 0.655669 | 0.648699 | 60 | 34.866665 | 27.408312 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.683333 | false | false | 15 |
c0b7c7e66ce2b7855aea61fd26697a129b010b69 | 31,473,520,354,137 | 47b9daf34909d23c30615c3186620c8b0e6013d3 | /bdf2-orm-hibernate3/src/main/java/com/bstek/bdf2/core/view/builder/LabelBuilder.java | 0ea8e8d5cc525148d74c036ffe46d4497709c76d | [
"Apache-2.0"
]
| permissive | 294033186/bdf2 | https://github.com/294033186/bdf2 | 5548dc23cd5b5d220558893165e923182dc5387f | 496ccd60feafb9e59b65020fbc2a4199a506fb4f | refs/heads/master | 2020-03-28T05:46:06.446000 | 2017-11-26T03:11:53 | 2017-11-26T03:11:53 | 147,795,504 | 1 | 1 | Apache-2.0 | true | 2018-09-07T08:36:24 | 2018-09-07T08:36:24 | 2018-09-03T06:35:04 | 2017-11-26T03:12:02 | 3,885 | 0 | 0 | 0 | null | false | null | package com.bstek.bdf2.core.view.builder;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import com.bstek.bdf2.core.view.ViewComponent;
import com.bstek.dorado.view.widget.form.Label;
@Component
public class LabelBuilder extends AbstractControlBuilder {
public void build(Object control, ViewComponent parentViewComponent) {
Label label = (Label) control;
String id = label.getId();
ViewComponent component = null;
if (StringUtils.isNotEmpty(id)) {
component = this.generateViewComponent(id, Label.class);
if (StringUtils.isEmpty(label.getText())) {
component.setDesc(label.getText());
}
}else if (StringUtils.isEmpty(label.getText())) {
component = this.generateViewComponent(label.getText(),Label.class);
}
if(component!=null){
if(StringUtils.isEmpty(component.getId())){
component.setEnabled(false);
}
parentViewComponent.addChildren(component);
}
}
public boolean support(Object control) {
return control instanceof Label;
}
}
| UTF-8 | Java | 1,038 | java | LabelBuilder.java | Java | []
| null | []
| package com.bstek.bdf2.core.view.builder;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;
import com.bstek.bdf2.core.view.ViewComponent;
import com.bstek.dorado.view.widget.form.Label;
@Component
public class LabelBuilder extends AbstractControlBuilder {
public void build(Object control, ViewComponent parentViewComponent) {
Label label = (Label) control;
String id = label.getId();
ViewComponent component = null;
if (StringUtils.isNotEmpty(id)) {
component = this.generateViewComponent(id, Label.class);
if (StringUtils.isEmpty(label.getText())) {
component.setDesc(label.getText());
}
}else if (StringUtils.isEmpty(label.getText())) {
component = this.generateViewComponent(label.getText(),Label.class);
}
if(component!=null){
if(StringUtils.isEmpty(component.getId())){
component.setEnabled(false);
}
parentViewComponent.addChildren(component);
}
}
public boolean support(Object control) {
return control instanceof Label;
}
}
| 1,038 | 0.746628 | 0.744701 | 36 | 27.833334 | 22.789495 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.972222 | false | false | 15 |
bc9665dfdee21286ed57e90461bed22d38cbe229 | 14,027,363,191,927 | be5c2623eb4d3e6dca52eb867ab080a4d4574c33 | /server/src/main/java/monitoringapp/Jmxer.java | 6f83f8abd54fe85d4271b59fec654eeb8400acbe | []
| no_license | romansky/monitoring-talk | https://github.com/romansky/monitoring-talk | 166ada32dadd3ea94fe2678368445a5341d83731 | d835127f1ae7846b3f5f081c374c40c711250e38 | refs/heads/master | 2021-01-09T22:40:33.170000 | 2015-08-02T05:48:55 | 2015-08-02T05:48:55 | 39,462,204 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package monitoringapp;
import javax.management.*;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
public class Jmxer {
public static MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
private static ObjectName objectName(String objectName) throws MalformedObjectNameException {
Map<String,String> nameMap = new HashMap<>();
nameMap.put("name",objectName);
return new ObjectName("com.monitoringapp",new Hashtable<>(nameMap));
}
public static void registerMBean(Object obj, String typeName)
throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException,
MBeanRegistrationException {
mBeanServer.registerMBean(obj, objectName(typeName));
}
} | UTF-8 | Java | 792 | java | Jmxer.java | Java | []
| null | []
| package monitoringapp;
import javax.management.*;
import java.lang.management.ManagementFactory;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
public class Jmxer {
public static MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
private static ObjectName objectName(String objectName) throws MalformedObjectNameException {
Map<String,String> nameMap = new HashMap<>();
nameMap.put("name",objectName);
return new ObjectName("com.monitoringapp",new Hashtable<>(nameMap));
}
public static void registerMBean(Object obj, String typeName)
throws MalformedObjectNameException, NotCompliantMBeanException, InstanceAlreadyExistsException,
MBeanRegistrationException {
mBeanServer.registerMBean(obj, objectName(typeName));
}
} | 792 | 0.805556 | 0.805556 | 26 | 29.5 | 30.743668 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.461538 | false | false | 15 |
fe667b24c77cb77f6486f9db5c9816696e367260 | 26,319,559,604,870 | 6a038125fddda61bae8950f7e0b6edb8b6d6a019 | /src/com/ecannetwork/tech/controller/bean/MdttStatViewBean.java | abf6fcac789f458acf24807984513a2003c3db5e | []
| no_license | xiaolin8/vwac | https://github.com/xiaolin8/vwac | f9bca83a5c2ef5f3bb3660622b44e05568592fd6 | 273db6f8472dbe66d814dbc8a895e4c57c317188 | refs/heads/master | 2016-09-13T21:13:22.305000 | 2016-03-15T14:09:03 | 2016-03-15T14:09:03 | 57,036,872 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ecannetwork.tech.controller.bean;
public class MdttStatViewBean
{
private String pkgID;
private String planID;
private String courseName;
private String pkgName;
private String planWeek;
public String getPkgID()
{
return pkgID;
}
public void setPkgID(String pkgID)
{
this.pkgID = pkgID;
}
public String getPlanID()
{
return planID;
}
public void setPlanID(String planID)
{
this.planID = planID;
}
public String getCourseName()
{
return courseName;
}
public void setCourseName(String courseName)
{
this.courseName = courseName;
}
public String getPkgName()
{
return pkgName;
}
public void setPkgName(String pkgName)
{
this.pkgName = pkgName;
}
public String getPlanWeek()
{
return planWeek;
}
public void setPlanWeek(String planWeek)
{
this.planWeek = planWeek;
}
}
| UTF-8 | Java | 835 | java | MdttStatViewBean.java | Java | []
| null | []
| package com.ecannetwork.tech.controller.bean;
public class MdttStatViewBean
{
private String pkgID;
private String planID;
private String courseName;
private String pkgName;
private String planWeek;
public String getPkgID()
{
return pkgID;
}
public void setPkgID(String pkgID)
{
this.pkgID = pkgID;
}
public String getPlanID()
{
return planID;
}
public void setPlanID(String planID)
{
this.planID = planID;
}
public String getCourseName()
{
return courseName;
}
public void setCourseName(String courseName)
{
this.courseName = courseName;
}
public String getPkgName()
{
return pkgName;
}
public void setPkgName(String pkgName)
{
this.pkgName = pkgName;
}
public String getPlanWeek()
{
return planWeek;
}
public void setPlanWeek(String planWeek)
{
this.planWeek = planWeek;
}
}
| 835 | 0.722156 | 0.722156 | 51 | 15.372549 | 14.110156 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.411765 | false | false | 15 |
8af4f4b1311e5f2ee400e5187f842d4da674d027 | 22,488,448,775,259 | 12cbe04050aadee71b538dff9ba3f53b483ac3ec | /src/com/obyhat/controlador/categoria/BotonesCategoria.java | e722b0fb8a49d71ca32d6e5cf3d58eee58680481 | []
| no_license | jeisonjs/gestion-materiales-java | https://github.com/jeisonjs/gestion-materiales-java | 7a2e35cac025e3c5e3283b8f4a515269ce84ee2a | 7af2f74cd1b5da938be884ed1d0d158e86b3b5a7 | refs/heads/master | 2021-09-25T21:53:05.249000 | 2018-10-26T01:44:54 | 2018-10-26T01:44:54 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.obyhat.controlador.categoria;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JOptionPane;
import com.obyhat.modelo.dao.CategoriaDAO;
import com.obyhat.modelo.dto.CategoriaDTO;
import com.obyhat.vista.paneles.PanelCategorias;
public class BotonesCategoria implements ActionListener {
private PanelCategorias PC;
private CategoriaDAO miCategoria;
private String nombre;
private ValidarDatosCategoria validarDatosCategoria;
public BotonesCategoria(PanelCategorias PC) {
this.PC = PC;
this.miCategoria = new CategoriaDAO();
this.validarDatosCategoria = new ValidarDatosCategoria(this.PC);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.PC.getBtnAgregar()) {
System.out.println("Boton 'Agregar Obra' escuchando Rock!");
this.registrarCategoria();
this.PC.vaciarFormulario();
this.obtenerCategorias();
}
if (e.getSource() == this.PC.getBtnActualizar()) {
System.out.println("Boton Actualizar Escuchando");
this.actualizarCategoria();
this.obtenerCategorias();
this.PC.vaciarFormulario();
this.PC.getBtnAgregar().setEnabled(true);
this.PC.getBtnActualizar().setEnabled(false);
}
if (e.getSource() == this.PC.getBtnCancelar()) {
System.out.println("Boton Cancelar Escuchando");
this.PC.vaciarFormulario();
this.obtenerCategorias();
this.PC.getBtnAgregar().setEnabled(true);
this.PC.getBtnActualizar().setEnabled(false);
}
if (e.getSource() == this.PC.getBtnModificar()) {
System.out.println("Boton 'Modificar' escuchando Rock!");
this.eventoModificar();
PC.getBtnAgregar().setEnabled(false);
PC.getBtnActualizar().setEnabled(true);
}
if (e.getSource() == this.PC.getBtnEliminar()) {
System.out.println("Boton 'Eliminar' escuchando Rock!");
this.eliminarCategoria();
this.obtenerCategorias();
}
}
public void registrarCategoria() {
if (validarDatosCategoria.ValidarDatos().equals("")) {
this.miCategoria.Ingresar(this.PC.ObtenerDatos());
} else {
JOptionPane.showMessageDialog(null, "ERROR!! \n"
+ validarDatosCategoria.ValidarDatos(), "Validando Datos",
JOptionPane.ERROR_MESSAGE);
}
}
public void eventoModificar() {
//Obtenet la Fila seleccionada.
int filaSeleccionada = PC.getTablaCategoria().getSelectedRow();
if (filaSeleccionada >= 0) {
String nombreObra = PC.getTablaCategoria().getValueAt(
filaSeleccionada, 0).toString();
int opc = JOptionPane.showConfirmDialog(
null, " ¿Desea modificar la categoria: " + nombreObra + "? ",
"Confirmar modificacion ",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
/*
* Le preguntare al usuario si en realidad desea modificar la categoria.
*/
if (opc == 0) {
PC.getModeloTabla().removeRow(filaSeleccionada);
CategoriaDTO consultarCat = miCategoria.Consultar(nombreObra);
PC.llenarFormulario(consultarCat);
}
} else {
JOptionPane.showMessageDialog(null, "Seleccione la fila a eliminar");
}
}
public void actualizarCategoria() {
if (validarDatosCategoria.ValidarDatos().equals("")) {
miCategoria.Actualizar(this.PC.ObtenerDatos());
} else {
JOptionPane.showMessageDialog(null, "ERROR!! \n"
+ validarDatosCategoria.ValidarDatos(), "Validando Datos",
JOptionPane.ERROR_MESSAGE);
}
}
public void eliminarCategoria() {
int filaSelecionada = PC.getTablaCategoria().getSelectedRow();
if (filaSelecionada != -1) {
String nombreCat = PC.getTablaCategoria().getValueAt(
filaSelecionada, 0).toString();
int opc = JOptionPane.showConfirmDialog(
null, " Desea eliminar la categoria: " + nombreCat + "? ",
"Confirmar eliminacion ",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
/*
* Le preguntare al usuario si en realidad desea eliminar la categoria.
*/
if (opc == 0) {
PC.getModeloTabla().removeRow(filaSelecionada);
this.miCategoria.Eliminar(nombreCat);
}
} else {
JOptionPane.showMessageDialog(null, "Debe seleccionar una fila");
}
}
public void obtenerCategorias() {
List<CategoriaDTO> categorias = this.miCategoria.ConsultarTodos();
PC.limpiarTabla();
for (int i = 1; i < categorias.size(); i++) {
System.out.println(categorias.get(i).getNombreCategoria());
this.PC.insertarTabla(categorias.get(i).toArray());
}
}
}
| UTF-8 | Java | 5,339 | java | BotonesCategoria.java | Java | []
| null | []
| package com.obyhat.controlador.categoria;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JOptionPane;
import com.obyhat.modelo.dao.CategoriaDAO;
import com.obyhat.modelo.dto.CategoriaDTO;
import com.obyhat.vista.paneles.PanelCategorias;
public class BotonesCategoria implements ActionListener {
private PanelCategorias PC;
private CategoriaDAO miCategoria;
private String nombre;
private ValidarDatosCategoria validarDatosCategoria;
public BotonesCategoria(PanelCategorias PC) {
this.PC = PC;
this.miCategoria = new CategoriaDAO();
this.validarDatosCategoria = new ValidarDatosCategoria(this.PC);
}
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == this.PC.getBtnAgregar()) {
System.out.println("Boton 'Agregar Obra' escuchando Rock!");
this.registrarCategoria();
this.PC.vaciarFormulario();
this.obtenerCategorias();
}
if (e.getSource() == this.PC.getBtnActualizar()) {
System.out.println("Boton Actualizar Escuchando");
this.actualizarCategoria();
this.obtenerCategorias();
this.PC.vaciarFormulario();
this.PC.getBtnAgregar().setEnabled(true);
this.PC.getBtnActualizar().setEnabled(false);
}
if (e.getSource() == this.PC.getBtnCancelar()) {
System.out.println("Boton Cancelar Escuchando");
this.PC.vaciarFormulario();
this.obtenerCategorias();
this.PC.getBtnAgregar().setEnabled(true);
this.PC.getBtnActualizar().setEnabled(false);
}
if (e.getSource() == this.PC.getBtnModificar()) {
System.out.println("Boton 'Modificar' escuchando Rock!");
this.eventoModificar();
PC.getBtnAgregar().setEnabled(false);
PC.getBtnActualizar().setEnabled(true);
}
if (e.getSource() == this.PC.getBtnEliminar()) {
System.out.println("Boton 'Eliminar' escuchando Rock!");
this.eliminarCategoria();
this.obtenerCategorias();
}
}
public void registrarCategoria() {
if (validarDatosCategoria.ValidarDatos().equals("")) {
this.miCategoria.Ingresar(this.PC.ObtenerDatos());
} else {
JOptionPane.showMessageDialog(null, "ERROR!! \n"
+ validarDatosCategoria.ValidarDatos(), "Validando Datos",
JOptionPane.ERROR_MESSAGE);
}
}
public void eventoModificar() {
//Obtenet la Fila seleccionada.
int filaSeleccionada = PC.getTablaCategoria().getSelectedRow();
if (filaSeleccionada >= 0) {
String nombreObra = PC.getTablaCategoria().getValueAt(
filaSeleccionada, 0).toString();
int opc = JOptionPane.showConfirmDialog(
null, " ¿Desea modificar la categoria: " + nombreObra + "? ",
"Confirmar modificacion ",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
/*
* Le preguntare al usuario si en realidad desea modificar la categoria.
*/
if (opc == 0) {
PC.getModeloTabla().removeRow(filaSeleccionada);
CategoriaDTO consultarCat = miCategoria.Consultar(nombreObra);
PC.llenarFormulario(consultarCat);
}
} else {
JOptionPane.showMessageDialog(null, "Seleccione la fila a eliminar");
}
}
public void actualizarCategoria() {
if (validarDatosCategoria.ValidarDatos().equals("")) {
miCategoria.Actualizar(this.PC.ObtenerDatos());
} else {
JOptionPane.showMessageDialog(null, "ERROR!! \n"
+ validarDatosCategoria.ValidarDatos(), "Validando Datos",
JOptionPane.ERROR_MESSAGE);
}
}
public void eliminarCategoria() {
int filaSelecionada = PC.getTablaCategoria().getSelectedRow();
if (filaSelecionada != -1) {
String nombreCat = PC.getTablaCategoria().getValueAt(
filaSelecionada, 0).toString();
int opc = JOptionPane.showConfirmDialog(
null, " Desea eliminar la categoria: " + nombreCat + "? ",
"Confirmar eliminacion ",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
/*
* Le preguntare al usuario si en realidad desea eliminar la categoria.
*/
if (opc == 0) {
PC.getModeloTabla().removeRow(filaSelecionada);
this.miCategoria.Eliminar(nombreCat);
}
} else {
JOptionPane.showMessageDialog(null, "Debe seleccionar una fila");
}
}
public void obtenerCategorias() {
List<CategoriaDTO> categorias = this.miCategoria.ConsultarTodos();
PC.limpiarTabla();
for (int i = 1; i < categorias.size(); i++) {
System.out.println(categorias.get(i).getNombreCategoria());
this.PC.insertarTabla(categorias.get(i).toArray());
}
}
}
| 5,339 | 0.589734 | 0.588423 | 172 | 30.034883 | 27.146437 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.459302 | false | false | 15 |
d4d50c083ea737db3fbde55995bd528e48dbe74d | 22,488,448,776,669 | c47504a8ab3fda20de790cb2dfabf3b842cc9b88 | /poker-2013/src/grafica/Orologio.java | 0280a46fd754c6cdf8816edcc1423cbbf3cc0783 | []
| no_license | doncredas/poker-2013 | https://github.com/doncredas/poker-2013 | ca2ea344ddacbfc14f5122f14c188980efb056b8 | ad1ab4ec1176b23aa2f832550b370c93c19341c0 | refs/heads/master | 2021-05-04T11:27:24.267000 | 2015-10-23T13:39:56 | 2015-10-23T13:39:56 | 44,805,527 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package grafica;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import javax.swing.JLabel;
/**
* Implementa il timer nella finestra,e deve risettare un icona ad ogni secondo
* che passa, per simulare i secondi che passano per un turno
*
*/
public class Orologio implements Runnable {
private int i, j;
private boolean flag = true;
private static JLabel time = new JLabel("30");
private static Font orolox = null;
/**
* Crea l'orologio insieme al font
* @param i = tempo dal quale far partire il timer
*/
public Orologio(int i) {
try {
orolox = Font.createFont(Font.TRUETYPE_FONT, Icone.getOrol());
} catch (FontFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
this.i = i;
this.j = i;
time.setText(Integer.toString(i));
time.setVisible(false);
time.setForeground(Color.white);
time.setFont(orolox.deriveFont(Font.PLAIN, 14));
}// Orologio
/**
* resetta il timer
*/
public void restart() {
this.i = j;
flag = true;
time.setText(Integer.toString(i));
time.setVisible(true);
time.setForeground(Color.white);
}// restart
/**
* ritorna il numero attuale del timer
*
* @return
*/
public int getVal() {
return Integer.parseInt(time.getText());
}
/**
* Ritorna la label
*
* @return
*/
public static JLabel getLabel() {
return time;
}// getLabel
@Override
public void run() {
while (true) {
for (this.i = j; i >= 0; i--) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (flag) {
if (this.i <= 20)
time.setForeground(Color.red);
else time.setForeground(Color.white);
time.setText(Integer.toString(this.i));
time.repaint();
}
}// for
stop();
}// while
}// run
public void stop() {
flag = false;
}//stop
}// Orologio
| UTF-8 | Java | 2,025 | java | Orologio.java | Java | []
| null | []
| package grafica;
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.io.IOException;
import javax.swing.JLabel;
/**
* Implementa il timer nella finestra,e deve risettare un icona ad ogni secondo
* che passa, per simulare i secondi che passano per un turno
*
*/
public class Orologio implements Runnable {
private int i, j;
private boolean flag = true;
private static JLabel time = new JLabel("30");
private static Font orolox = null;
/**
* Crea l'orologio insieme al font
* @param i = tempo dal quale far partire il timer
*/
public Orologio(int i) {
try {
orolox = Font.createFont(Font.TRUETYPE_FONT, Icone.getOrol());
} catch (FontFormatException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
this.i = i;
this.j = i;
time.setText(Integer.toString(i));
time.setVisible(false);
time.setForeground(Color.white);
time.setFont(orolox.deriveFont(Font.PLAIN, 14));
}// Orologio
/**
* resetta il timer
*/
public void restart() {
this.i = j;
flag = true;
time.setText(Integer.toString(i));
time.setVisible(true);
time.setForeground(Color.white);
}// restart
/**
* ritorna il numero attuale del timer
*
* @return
*/
public int getVal() {
return Integer.parseInt(time.getText());
}
/**
* Ritorna la label
*
* @return
*/
public static JLabel getLabel() {
return time;
}// getLabel
@Override
public void run() {
while (true) {
for (this.i = j; i >= 0; i--) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (flag) {
if (this.i <= 20)
time.setForeground(Color.red);
else time.setForeground(Color.white);
time.setText(Integer.toString(this.i));
time.repaint();
}
}// for
stop();
}// while
}// run
public void stop() {
flag = false;
}//stop
}// Orologio
| 2,025 | 0.61284 | 0.607407 | 96 | 19.09375 | 16.427288 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.96875 | false | false | 15 |
04d3507520cf363997003eaef9ebceae1c8ecb4d | 16,758,962,404,264 | 91eeaf3c1728c287acf6c3334a026c6558d56dc8 | /module/Post/Elements/PostType.java | 132fa40700d53e566cd37c9234786cb0c05b3588 | []
| no_license | HSPKingdom/instagramAPI | https://github.com/HSPKingdom/instagramAPI | 21f242aee83857b818101febccde35cf53104dc6 | d64f22fedf4cca5a7c3d3f26c2f689bafbf2ed16 | refs/heads/master | 2022-07-01T09:20:04.447000 | 2018-07-27T11:50:32 | 2018-07-27T11:50:32 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hackathon.instagram.module.Post.Elements;
public enum PostType {
IMAGE, VIDEO;
}
| UTF-8 | Java | 98 | java | PostType.java | Java | []
| null | []
| package com.hackathon.instagram.module.Post.Elements;
public enum PostType {
IMAGE, VIDEO;
}
| 98 | 0.755102 | 0.755102 | 5 | 18.6 | 19.252012 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 15 |
8ccd6b25760a8adbb11538c8e4f603aa7da841ab | 26,010,321,958,243 | 92a9dd8fe86778e93f5a10d199e1450c32b62774 | /common/utils/src/main/java/com/github/utils/KafkaUtil.java | 813e5312d28d876a2c7d4882fb9b8d477d26ee8a | []
| no_license | ChinaZer01ne/mall | https://github.com/ChinaZer01ne/mall | b90e534a7d23c94a24a7f0aff80434bd50890005 | 16858db5482481ab820f5a46a6678910a03bf4f7 | refs/heads/master | 2020-04-26T23:40:48.318000 | 2019-08-13T09:56:47 | 2019-08-13T09:56:47 | 173,910,270 | 0 | 0 | null | false | 2020-07-01T22:39:28 | 2019-03-05T08:53:39 | 2019-08-13T09:56:57 | 2020-07-01T22:39:25 | 170 | 0 | 0 | 1 | Java | false | false | package com.github.utils;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture;
import javax.annotation.Resource;
/**
*
* kafka工具类
*
* @author Zer01ne
* @version 1.0
* @date 2019/5/22 11:38
*/
@Component
public class KafkaUtil {
@Resource
private KafkaTemplate kafkaTemplate;
public String sendMessage(String topic, String key, String message){
kafkaTemplate.send(topic, key, message);
return message;
}
}
| UTF-8 | Java | 566 | java | KafkaUtil.java | Java | [
{
"context": "tation.Resource;\n\n/**\n *\n * kafka工具类\n *\n * @author Zer01ne\n * @version 1.0\n * @date 2019/5/22 11:38\n */\n@Com",
"end": 266,
"score": 0.9996713399887085,
"start": 259,
"tag": "USERNAME",
"value": "Zer01ne"
}
]
| null | []
| package com.github.utils;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.concurrent.ListenableFuture;
import javax.annotation.Resource;
/**
*
* kafka工具类
*
* @author Zer01ne
* @version 1.0
* @date 2019/5/22 11:38
*/
@Component
public class KafkaUtil {
@Resource
private KafkaTemplate kafkaTemplate;
public String sendMessage(String topic, String key, String message){
kafkaTemplate.send(topic, key, message);
return message;
}
}
| 566 | 0.730357 | 0.703571 | 28 | 19 | 20.679527 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 15 |
e928deffb49573c803379e49783d4d04031ff1fd | 22,454,089,051,021 | 13bffb162d8bfca6c1d863a210b9587c0b6020f7 | /src/main/java/com/factory/end/model/primary/User.java | a11333ba90a4a7cb992415f5b15b685f75948bc7 | []
| no_license | jchonker/factory-end | https://github.com/jchonker/factory-end | d66656661b8043a5db394980d99f806810bcf66e | 3314ea2abe7db0311670a4119073e9ac48632cae | refs/heads/master | 2023-01-04T18:07:54.922000 | 2020-11-06T02:57:34 | 2020-11-06T02:57:34 | 289,152,907 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.factory.end.model.primary;
import lombok.Data;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* @Author jchonker
* @Date 2020/8/21 15:37
* @Version 1.0
* 模板类
*/
@Data
@Table(name = "pro_User")
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "username")
private String username;
@Column(name = "password")
private String password;
@Column(name = "enable")
private boolean enable;
private boolean credentialsNonExpired;
private boolean accountNonLocked;
private boolean accountNonExpired;
@ManyToMany
@JoinTable(name = "pro_User_Role",uniqueConstraints = {@UniqueConstraint(columnNames = {"uid","rid"})},
joinColumns = {@JoinColumn(name = "uid",referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "rid",referencedColumnName = "id")})
private List<Role> roleList = new ArrayList<>();
}
| UTF-8 | Java | 1,025 | java | User.java | Java | [
{
"context": ".ArrayList;\nimport java.util.List;\n\n/**\n * @Author jchonker\n * @Date 2020/8/21 15:37\n * @Version 1.0\n * 模板类\n ",
"end": 164,
"score": 0.9996663928031921,
"start": 156,
"tag": "USERNAME",
"value": "jchonker"
},
{
"context": "ENTITY)\n private Long id;\n\n @Column(name = \"username\")\n private String username;\n\n @Column(name ",
"end": 391,
"score": 0.9948001503944397,
"start": 383,
"tag": "USERNAME",
"value": "username"
}
]
| null | []
| package com.factory.end.model.primary;
import lombok.Data;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
/**
* @Author jchonker
* @Date 2020/8/21 15:37
* @Version 1.0
* 模板类
*/
@Data
@Table(name = "pro_User")
@Entity
public class User {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "username")
private String username;
@Column(name = "password")
private String password;
@Column(name = "enable")
private boolean enable;
private boolean credentialsNonExpired;
private boolean accountNonLocked;
private boolean accountNonExpired;
@ManyToMany
@JoinTable(name = "pro_User_Role",uniqueConstraints = {@UniqueConstraint(columnNames = {"uid","rid"})},
joinColumns = {@JoinColumn(name = "uid",referencedColumnName = "id")},
inverseJoinColumns = {@JoinColumn(name = "rid",referencedColumnName = "id")})
private List<Role> roleList = new ArrayList<>();
}
| 1,025 | 0.675172 | 0.662414 | 44 | 22.15909 | 24.48278 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.431818 | false | false | 15 |
38984957c6db140c16c67f0975304ef83f5cc7c7 | 19,499,151,539,677 | 3a516329abecad455ed96d9327d8f86fbc4036e2 | /JavaTraining/Pętle/src/OddNumberChecker.java | d33c4a83072476f9abb8bea06f9dea89f19f246b | []
| no_license | yashczoor/JavaStartSzkolenie | https://github.com/yashczoor/JavaStartSzkolenie | d354f3433ad87756889f264b3932a58b92659634 | ed1463a833e2ddc3e65ba4120c355aad58f01cf9 | refs/heads/master | 2022-11-21T04:16:30.509000 | 2020-07-17T10:20:04 | 2020-07-17T10:20:04 | 280,393,177 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Scanner;
public class OddNumberChecker {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int tmp;
for (int i = 0; i < 3; i++) {
System.out.println("Podaj liczbę: ");
tmp = input.nextInt();
if (tmp % 2 == 0) {
System.out.println("Licza " + tmp + " parzystą jest.");
} else {
System.out.println("Liczba " + tmp + " nie jest parzysta!");
}
}
input.close();
}
}
| WINDOWS-1250 | Java | 450 | java | OddNumberChecker.java | Java | []
| null | []
| import java.util.Scanner;
public class OddNumberChecker {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int tmp;
for (int i = 0; i < 3; i++) {
System.out.println("Podaj liczbę: ");
tmp = input.nextInt();
if (tmp % 2 == 0) {
System.out.println("Licza " + tmp + " parzystą jest.");
} else {
System.out.println("Liczba " + tmp + " nie jest parzysta!");
}
}
input.close();
}
}
| 450 | 0.589286 | 0.580357 | 20 | 21.4 | 19.425241 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.35 | false | false | 15 |
528acb8ee631d192dbf6dcce2bd096ee69a0525d | 10,634,339,083,198 | 2f3e65fc35388145eaffb0394c6962c227357b44 | /Leetcode/src/solution/FirstUniqueChar.java | 83d8fac75c38eedf3b72386c78a568cb3e348184 | []
| no_license | yanxyans/Leetcode | https://github.com/yanxyans/Leetcode | 848b6a1b4d8d64ed4f5937e9cf8a11625013cea6 | 438bef3c2df8fd28013010bf12b24f0db0f2d4fe | refs/heads/master | 2021-09-17T22:14:27.700000 | 2018-07-06T01:09:01 | 2018-07-06T01:09:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package solution;
import java.util.HashMap;
import java.util.Map;
public class FirstUniqueChar {
public int firstUniqChar(String s) {
int n = s.length();
Map<Character, Integer> freq = new HashMap<Character, Integer>();
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (freq.containsKey(c))
freq.put(c, freq.get(c) + 1);
else
freq.put(c, 1);
}
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (freq.get(c) == 1)
return i;
}
return -1;
}
}
| UTF-8 | Java | 610 | java | FirstUniqueChar.java | Java | []
| null | []
| package solution;
import java.util.HashMap;
import java.util.Map;
public class FirstUniqueChar {
public int firstUniqChar(String s) {
int n = s.length();
Map<Character, Integer> freq = new HashMap<Character, Integer>();
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (freq.containsKey(c))
freq.put(c, freq.get(c) + 1);
else
freq.put(c, 1);
}
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (freq.get(c) == 1)
return i;
}
return -1;
}
}
| 610 | 0.47377 | 0.463934 | 26 | 22.461538 | 15.978907 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.153846 | false | false | 15 |
44bdc7ade207f48ab2256f84608107dfbaf21aa6 | 10,634,339,082,962 | bd729ef9fcd96ea62e82bb684c831d9917017d0e | /kyptLBSapi/src/java/com/kypt/c2pp/inside/processor/InsideProcessorMap.java | 8e3b33d3ba2c1977ee81fc52fb4fd8c2af6a6232 | []
| no_license | shanghaif/workspace-kepler | https://github.com/shanghaif/workspace-kepler | 849c7de67b1f3ee5e7da55199c05c737f036780c | ac1644be26a21f11a3a4a00319c450eb590c1176 | refs/heads/master | 2023-03-22T03:38:55.103000 | 2018-03-24T02:39:41 | 2018-03-24T02:39:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kypt.c2pp.inside.processor;
import java.util.concurrent.ConcurrentHashMap;
import com.kypt.c2pp.inside.msg.req.DownQuestionReq;
import com.kypt.c2pp.inside.msg.req.DownTextReq;
import com.kypt.c2pp.inside.msg.req.PhotoGraphReq;
import com.kypt.c2pp.inside.msg.req.QueryTerminalParamReq;
import com.kypt.c2pp.inside.msg.req.SetTerminalEventReq;
import com.kypt.c2pp.inside.msg.req.SetTerminalParamReq;
import com.kypt.c2pp.inside.msg.req.TerminalListenerSeq;
import com.kypt.c2pp.inside.msg.resp.ActiveTestResp;
import com.kypt.c2pp.inside.msg.resp.BindResp;
import com.kypt.c2pp.inside.msg.resp.LoginResp;
import com.kypt.c2pp.inside.processor.req.DownQuestionReqProcessor;
import com.kypt.c2pp.inside.processor.req.DownTextReqProcessor;
import com.kypt.c2pp.inside.processor.req.PhotoGraphReqProcessor;
import com.kypt.c2pp.inside.processor.req.QueryTerminalParamReqProcessor;
import com.kypt.c2pp.inside.processor.req.SetTerminalEventReqProcessor;
import com.kypt.c2pp.inside.processor.req.SetTerminalParamReqProcessor;
import com.kypt.c2pp.inside.processor.req.TerminalListenerSeqProcessor;
import com.kypt.c2pp.inside.processor.resp.ActiveTestRespProcessor;
import com.kypt.c2pp.inside.processor.resp.BindRespProcessor;
import com.kypt.c2pp.inside.processor.resp.LoginRespProcessor;
public final class InsideProcessorMap {
private static final InsideProcessorMap PROCESSOR_MAP = new InsideProcessorMap();
@SuppressWarnings("unchecked")
private ConcurrentHashMap<String, IInsideProcessor> map = new ConcurrentHashMap<String, IInsideProcessor>();
private InsideProcessorMap() {
map.put(BindResp.COMMAND, BindRespProcessor.getInstance());
map.put(LoginResp.COMMAND, LoginRespProcessor.getInstance());
map.put(ActiveTestResp.COMMAND, ActiveTestRespProcessor.getInstance());
map.put(SetTerminalParamReq.COMMAND, SetTerminalParamReqProcessor.getInstance());
map.put(SetTerminalEventReq.COMMAND, SetTerminalEventReqProcessor.getInstance());
map.put(QueryTerminalParamReq.COMMAND, QueryTerminalParamReqProcessor.getInstance());
map.put(DownTextReq.COMMAND, DownTextReqProcessor.getInstance());
map.put(DownQuestionReq.COMMAND, DownQuestionReqProcessor.getInstance());
map.put(PhotoGraphReq.COMMAND, PhotoGraphReqProcessor.getInstance());
map.put(TerminalListenerSeq.COMMAND, TerminalListenerSeqProcessor.getInstance());
}
public static InsideProcessorMap getInstance() {
return PROCESSOR_MAP;
}
@SuppressWarnings("unchecked")
public IInsideProcessor getProcessor(String command) throws Exception {
if (!map.containsKey(command)) {
throw new Exception("processor is not exist.");
}
return map.get(command);
}
}
| UTF-8 | Java | 2,669 | java | InsideProcessorMap.java | Java | []
| null | []
| package com.kypt.c2pp.inside.processor;
import java.util.concurrent.ConcurrentHashMap;
import com.kypt.c2pp.inside.msg.req.DownQuestionReq;
import com.kypt.c2pp.inside.msg.req.DownTextReq;
import com.kypt.c2pp.inside.msg.req.PhotoGraphReq;
import com.kypt.c2pp.inside.msg.req.QueryTerminalParamReq;
import com.kypt.c2pp.inside.msg.req.SetTerminalEventReq;
import com.kypt.c2pp.inside.msg.req.SetTerminalParamReq;
import com.kypt.c2pp.inside.msg.req.TerminalListenerSeq;
import com.kypt.c2pp.inside.msg.resp.ActiveTestResp;
import com.kypt.c2pp.inside.msg.resp.BindResp;
import com.kypt.c2pp.inside.msg.resp.LoginResp;
import com.kypt.c2pp.inside.processor.req.DownQuestionReqProcessor;
import com.kypt.c2pp.inside.processor.req.DownTextReqProcessor;
import com.kypt.c2pp.inside.processor.req.PhotoGraphReqProcessor;
import com.kypt.c2pp.inside.processor.req.QueryTerminalParamReqProcessor;
import com.kypt.c2pp.inside.processor.req.SetTerminalEventReqProcessor;
import com.kypt.c2pp.inside.processor.req.SetTerminalParamReqProcessor;
import com.kypt.c2pp.inside.processor.req.TerminalListenerSeqProcessor;
import com.kypt.c2pp.inside.processor.resp.ActiveTestRespProcessor;
import com.kypt.c2pp.inside.processor.resp.BindRespProcessor;
import com.kypt.c2pp.inside.processor.resp.LoginRespProcessor;
public final class InsideProcessorMap {
private static final InsideProcessorMap PROCESSOR_MAP = new InsideProcessorMap();
@SuppressWarnings("unchecked")
private ConcurrentHashMap<String, IInsideProcessor> map = new ConcurrentHashMap<String, IInsideProcessor>();
private InsideProcessorMap() {
map.put(BindResp.COMMAND, BindRespProcessor.getInstance());
map.put(LoginResp.COMMAND, LoginRespProcessor.getInstance());
map.put(ActiveTestResp.COMMAND, ActiveTestRespProcessor.getInstance());
map.put(SetTerminalParamReq.COMMAND, SetTerminalParamReqProcessor.getInstance());
map.put(SetTerminalEventReq.COMMAND, SetTerminalEventReqProcessor.getInstance());
map.put(QueryTerminalParamReq.COMMAND, QueryTerminalParamReqProcessor.getInstance());
map.put(DownTextReq.COMMAND, DownTextReqProcessor.getInstance());
map.put(DownQuestionReq.COMMAND, DownQuestionReqProcessor.getInstance());
map.put(PhotoGraphReq.COMMAND, PhotoGraphReqProcessor.getInstance());
map.put(TerminalListenerSeq.COMMAND, TerminalListenerSeqProcessor.getInstance());
}
public static InsideProcessorMap getInstance() {
return PROCESSOR_MAP;
}
@SuppressWarnings("unchecked")
public IInsideProcessor getProcessor(String command) throws Exception {
if (!map.containsKey(command)) {
throw new Exception("processor is not exist.");
}
return map.get(command);
}
}
| 2,669 | 0.824279 | 0.816411 | 59 | 44.237289 | 29.847828 | 109 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.525424 | false | false | 15 |
7407e096f58c22ee49ddabd8436d678bb14843fd | 17,910,013,631,976 | df64f2cbd396c98dda440e425c9e6295b15be64f | /Location/src/com/codecool/kruppa/gmap/Vehicle.java | 83ea777fa9828fa92d5d52306782dafc290e6318 | []
| no_license | kruppatomi/Java-OOP-exercises | https://github.com/kruppatomi/Java-OOP-exercises | f8cdb24ce22e6bd14f5d2008a8838b19e87044fa | 8b570c5d0cb03c9a8328e9e71ed38e963287a5a0 | refs/heads/master | 2020-12-30T00:48:26.618000 | 2020-04-17T11:41:39 | 2020-04-17T11:41:39 | 238,802,787 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.codecool.kruppa.gmap;
import com.codecool.kruppa.util.Util;
public enum Vehicle {
BIKE(5),
FOOT(2);
private int vehicle;
Vehicle(int vehicle){
this.vehicle = vehicle;
}
public int getVehicle() {
return vehicle;
}
public static Vehicle getRandomVehicle() {
Vehicle[] vehicles = Vehicle.values();
return vehicles[Util.getRandomNumber(1)];
}
}
| UTF-8 | Java | 428 | java | Vehicle.java | Java | []
| null | []
| package com.codecool.kruppa.gmap;
import com.codecool.kruppa.util.Util;
public enum Vehicle {
BIKE(5),
FOOT(2);
private int vehicle;
Vehicle(int vehicle){
this.vehicle = vehicle;
}
public int getVehicle() {
return vehicle;
}
public static Vehicle getRandomVehicle() {
Vehicle[] vehicles = Vehicle.values();
return vehicles[Util.getRandomNumber(1)];
}
}
| 428 | 0.623832 | 0.616822 | 24 | 16.833334 | 16.617428 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 15 |
1fb360096657de311496d081e5b488066057d735 | 23,716,809,464,928 | a6e74f264423fc80cbcdaa94baff550b18047bac | /src/main/java/com/sistr/homemadexx/setup/ModSetup.java | a85979aefcb597010bb1535a11c77745eff65c54 | [
"MIT"
]
| permissive | SistrScarlet/HomemadeXXMod | https://github.com/SistrScarlet/HomemadeXXMod | e3982dcf9ee45d0958b21e078f644041e3e83a4e | e0ab0abc74556ec20d8a99f063eb6c0b4ed802d9 | refs/heads/master | 2023-03-26T12:06:24.389000 | 2021-03-25T10:09:01 | 2021-03-25T10:09:01 | 255,331,189 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sistr.homemadexx.setup;
import com.sistr.homemadexx.HomemadeXXMod;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@Mod.EventBusSubscriber(modid = HomemadeXXMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class ModSetup {
public static final ItemGroup ITEM_GROUP = new ItemGroup("homemadexx") {
@Override
public ItemStack createIcon() {
return new ItemStack(Registration.MUFFLER_ITEM.get());
}
};
public static void init(final FMLCommonSetupEvent event) {
}
}
| UTF-8 | Java | 675 | java | ModSetup.java | Java | []
| null | []
| package com.sistr.homemadexx.setup;
import com.sistr.homemadexx.HomemadeXXMod;
import net.minecraft.item.ItemGroup;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
@Mod.EventBusSubscriber(modid = HomemadeXXMod.MODID, bus = Mod.EventBusSubscriber.Bus.FORGE)
public class ModSetup {
public static final ItemGroup ITEM_GROUP = new ItemGroup("homemadexx") {
@Override
public ItemStack createIcon() {
return new ItemStack(Registration.MUFFLER_ITEM.get());
}
};
public static void init(final FMLCommonSetupEvent event) {
}
}
| 675 | 0.742222 | 0.742222 | 23 | 28.347826 | 28.019571 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.391304 | false | false | 15 |
b88d0393f53a1838dfb32d6d93206226b527ec91 | 5,136,780,909,175 | 157117dadf446ba68ae8018c6a69023464bdfced | /DiscreteDistribution.java | ab8c81ea2eec56c7efcad6ce3326759cf515fc9d | []
| no_license | aashvibusa/Java-Projects | https://github.com/aashvibusa/Java-Projects | fe7dd2fae6204ee105db8e4f186d96a4a6ff39aa | 771cc70bc80e0eaf7027a92cdf36fa67ad4fa5fa | refs/heads/main | 2023-08-28T16:14:26.671000 | 2021-11-08T06:44:43 | 2021-11-08T06:44:43 | 425,722,091 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.lang.Math;
public class DiscreteDistribution {
public static void main (String[] args) {
int count = args.length;
int a[] = new int[count];
int b[] = new int[count];
//System.out.println(count);
int m = Integer.parseInt(args[0]);
// define variable x to hold cumulative sum
int x = 0;
int ri;
for (int i = 0; i < count - 1; i++) {
a[i] = Integer.parseInt(args[i+1]);
//System.out.println(a[i]);
}
//System.out.println("-------");
b[0] = 0;
for (int j = 1; j < count ; j++) {
b[j] = x + a[j-1];
x = b[j];
//System.out.println(b[j]);
}
//System.out.println("-------");
for (int k = 0; k < m; k++) {
double r = Math.random() * (b[count-1]);
ri = (int) r;
//System.out.println("random # = " + r);
//System.out.println("random int # = " + ri);
for (int q = 1; q < count; q++) {
//System.out.println("b[" + (q-1) + "] = " + b[q-1] + "b[" + q + "] = " + b[q]);
if ((ri >= b[q-1]) && (ri < b[q])) {
//System.out.println("b[" + (q-1) + "] = " + b[q-1] + "b[" + q + "] = " + b[q]);
System.out.print(q + " ");
}
}
}
}
}
| UTF-8 | Java | 1,451 | java | DiscreteDistribution.java | Java | []
| null | []
| import java.lang.Math;
public class DiscreteDistribution {
public static void main (String[] args) {
int count = args.length;
int a[] = new int[count];
int b[] = new int[count];
//System.out.println(count);
int m = Integer.parseInt(args[0]);
// define variable x to hold cumulative sum
int x = 0;
int ri;
for (int i = 0; i < count - 1; i++) {
a[i] = Integer.parseInt(args[i+1]);
//System.out.println(a[i]);
}
//System.out.println("-------");
b[0] = 0;
for (int j = 1; j < count ; j++) {
b[j] = x + a[j-1];
x = b[j];
//System.out.println(b[j]);
}
//System.out.println("-------");
for (int k = 0; k < m; k++) {
double r = Math.random() * (b[count-1]);
ri = (int) r;
//System.out.println("random # = " + r);
//System.out.println("random int # = " + ri);
for (int q = 1; q < count; q++) {
//System.out.println("b[" + (q-1) + "] = " + b[q-1] + "b[" + q + "] = " + b[q]);
if ((ri >= b[q-1]) && (ri < b[q])) {
//System.out.println("b[" + (q-1) + "] = " + b[q-1] + "b[" + q + "] = " + b[q]);
System.out.print(q + " ");
}
}
}
}
}
| 1,451 | 0.368022 | 0.356306 | 44 | 30.977272 | 23.250111 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.704545 | false | false | 15 |
f3ab982c9aa5fe0388b4f146b059a49cfbbb4947 | 455,266,538,721 | c858543fdd48b11dfc44199ccb5e3f3220b4c182 | /src/main/java/com/spark/web/view/ui/SwitchButton.java | 8334a0512a8e03760c40d900df67eb59ea6c2fbe | []
| no_license | znjqolf/extdo | https://github.com/znjqolf/extdo | 19b78937d2c8ddb814e6af7667d508bcc0f1512c | 96eeb6a9e0927e5d4e53c48db764e6eff020bd77 | refs/heads/master | 2018-01-14T21:23:01.523000 | 2016-09-19T14:59:03 | 2016-09-19T14:59:03 | 65,282,932 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.spark.web.view.ui;
import java.util.List;
import java.util.Map;
import com.spark.web.view.SparkContext;
import com.spark.web.view.UITag;
import com.spark.web.view.XMap;
@UITag
public class SwitchButton extends ViewComponent {
public static final String PROPERTITY_ITEMS = "items";
public static final String PROPERTITY_ACTIVE_VALUE = "activeValue";
public static final String PROPERTITY_ALIGN = "align";
private static final String DEFAULT_PROPERTITY_ALIGN = "h";
private static final String DEFAULT_TEMPLATES = "switchButton.ftl";
private static final String DEFAULT_CLASSNAME = "s-switch-button";
public String getTemplate() {
return DEFAULT_TEMPLATES;
}
protected String getDefaultClass(XMap view, SparkContext context) {
String className = super.getDefaultClass(view, context);
StringBuilder sb = new StringBuilder();
sb.append(className);
if (!"".equals(className.trim()))
sb.append(" ");
sb.append(DEFAULT_CLASSNAME);
return sb.toString();
}
public void init(XMap view, SparkContext context) throws Exception {
super.init(view, context);
XMap items = view.getChild(PROPERTITY_ITEMS);
String av = view.getString(PROPERTITY_ACTIVE_VALUE);
if (items != null && items.getChilds() != null) {
StringBuilder sb = new StringBuilder();
List<XMap> children = items.getChilds();
int i = 1, len = children.size();
for (XMap item : children) {
String value = item.getString("value", "");
String style = item.getString("style", "");
String text = item.getString("text", "");
sb.append("<li value=\"").append(value).append("\" ");
sb.append("class=\"");
if ((av == null && i == 1) || value.equals(av)) {
context.addJsonConfig(PROPERTITY_ACTIVE_VALUE, (av == null && i == 1) ? value : av);
sb.append("cur");
}
if (i == len) {
sb.append(" last");
}
sb.append("\" ");
if (!"".equals(style)) {
sb.append("style=\"").append(style).append("\"");
}
sb.append(">").append(text).append("</li>");
i++;
}
context.put(PROPERTITY_ITEMS, sb.toString());
}
}
@SuppressWarnings("unchecked")
protected String build(SparkContext context) {
Map map = context.getMap();
StringBuilder sb = new StringBuilder();
sb.append("<ul class=\"").append(get(map, "className")).append("\" style=\"").append(get(map, "style")).append(";\" id=\"").append(get(map, "id"))
.append("\">\r");
sb.append(" ").append(get(map, "items"));
sb.append("</ul>\r");
sb.append("<script>new Spark.SwitchButton(").append(get(map, "config")).append(");</script>\r");
return sb.toString();
}
}
| UTF-8 | Java | 3,074 | java | SwitchButton.java | Java | []
| null | []
| package com.spark.web.view.ui;
import java.util.List;
import java.util.Map;
import com.spark.web.view.SparkContext;
import com.spark.web.view.UITag;
import com.spark.web.view.XMap;
@UITag
public class SwitchButton extends ViewComponent {
public static final String PROPERTITY_ITEMS = "items";
public static final String PROPERTITY_ACTIVE_VALUE = "activeValue";
public static final String PROPERTITY_ALIGN = "align";
private static final String DEFAULT_PROPERTITY_ALIGN = "h";
private static final String DEFAULT_TEMPLATES = "switchButton.ftl";
private static final String DEFAULT_CLASSNAME = "s-switch-button";
public String getTemplate() {
return DEFAULT_TEMPLATES;
}
protected String getDefaultClass(XMap view, SparkContext context) {
String className = super.getDefaultClass(view, context);
StringBuilder sb = new StringBuilder();
sb.append(className);
if (!"".equals(className.trim()))
sb.append(" ");
sb.append(DEFAULT_CLASSNAME);
return sb.toString();
}
public void init(XMap view, SparkContext context) throws Exception {
super.init(view, context);
XMap items = view.getChild(PROPERTITY_ITEMS);
String av = view.getString(PROPERTITY_ACTIVE_VALUE);
if (items != null && items.getChilds() != null) {
StringBuilder sb = new StringBuilder();
List<XMap> children = items.getChilds();
int i = 1, len = children.size();
for (XMap item : children) {
String value = item.getString("value", "");
String style = item.getString("style", "");
String text = item.getString("text", "");
sb.append("<li value=\"").append(value).append("\" ");
sb.append("class=\"");
if ((av == null && i == 1) || value.equals(av)) {
context.addJsonConfig(PROPERTITY_ACTIVE_VALUE, (av == null && i == 1) ? value : av);
sb.append("cur");
}
if (i == len) {
sb.append(" last");
}
sb.append("\" ");
if (!"".equals(style)) {
sb.append("style=\"").append(style).append("\"");
}
sb.append(">").append(text).append("</li>");
i++;
}
context.put(PROPERTITY_ITEMS, sb.toString());
}
}
@SuppressWarnings("unchecked")
protected String build(SparkContext context) {
Map map = context.getMap();
StringBuilder sb = new StringBuilder();
sb.append("<ul class=\"").append(get(map, "className")).append("\" style=\"").append(get(map, "style")).append(";\" id=\"").append(get(map, "id"))
.append("\">\r");
sb.append(" ").append(get(map, "items"));
sb.append("</ul>\r");
sb.append("<script>new Spark.SwitchButton(").append(get(map, "config")).append(");</script>\r");
return sb.toString();
}
}
| 3,074 | 0.556278 | 0.555303 | 79 | 37.911392 | 28.076834 | 154 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.810127 | false | false | 15 |
3ea513a0f03f2bae2761d461e0b7ac3faae32517 | 25,323,127,239,467 | 3934ccb7db96d18b6a3a24deac5aa33a81c926d8 | /Java Labs/src/foodLab/Consumable.java | 808c337ba74f57c9e35c9a7e29d5a39c90db1988 | []
| no_license | OlegBaslak/bsu-rfe-study | https://github.com/OlegBaslak/bsu-rfe-study | c50cc34a755023983f6d40711d63f4c4110745bc | c8d6d31d42da7de28f69b14163a4af0dc15bd432 | refs/heads/master | 2021-01-19T23:48:46.039000 | 2017-04-22T00:27:38 | 2017-04-22T00:27:38 | 89,032,691 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package foodLab;
/**
* Created by Олег on 24.09.2014.
*/
public interface Consumable {
public abstract void consume();
}
| UTF-8 | Java | 133 | java | Consumable.java | Java | [
{
"context": "package foodLab;\n\n/**\n * Created by Олег on 24.09.2014.\n */\n\npublic interface Consumable {",
"end": 40,
"score": 0.9998207688331604,
"start": 36,
"tag": "NAME",
"value": "Олег"
}
]
| null | []
| package foodLab;
/**
* Created by Олег on 24.09.2014.
*/
public interface Consumable {
public abstract void consume();
}
| 133 | 0.674419 | 0.612403 | 9 | 13.333333 | 14.2595 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 15 |
84fc13a37f42ffebdccffd563e45d32af9eba95c | 996,432,433,550 | 774d36285e48bd429017b6901a59b8e3a51d6add | /sources/com/google/android/gms/internal/ads/zzcmg.java | 2cc5648fa02082bbe41246c908fadd7d611c6d9a | []
| no_license | jorge-luque/hb | https://github.com/jorge-luque/hb | 83c086851a409e7e476298ffdf6ba0c8d06911db | b467a9af24164f7561057e5bcd19cdbc8647d2e5 | refs/heads/master | 2023-08-25T09:32:18.793000 | 2020-10-02T11:02:01 | 2020-10-02T11:02:01 | 300,586,541 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.google.android.gms.internal.ads;
import org.json.JSONObject;
/* compiled from: com.google.android.gms:play-services-ads@@19.1.0 */
public final class zzcmg {
/* access modifiers changed from: private */
public final JSONObject zzgcr;
/* access modifiers changed from: private */
public final zzarp zzgcs;
public zzcmg(JSONObject jSONObject, zzarp zzarp) {
this.zzgcr = jSONObject;
this.zzgcs = zzarp;
}
}
| UTF-8 | Java | 460 | java | zzcmg.java | Java | []
| null | []
| package com.google.android.gms.internal.ads;
import org.json.JSONObject;
/* compiled from: com.google.android.gms:play-services-ads@@19.1.0 */
public final class zzcmg {
/* access modifiers changed from: private */
public final JSONObject zzgcr;
/* access modifiers changed from: private */
public final zzarp zzgcs;
public zzcmg(JSONObject jSONObject, zzarp zzarp) {
this.zzgcr = jSONObject;
this.zzgcs = zzarp;
}
}
| 460 | 0.691304 | 0.682609 | 16 | 27.75 | 21.03717 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4375 | false | false | 15 |
736afb996a116ca8a5a813732dd3941f060f2f73 | 14,542,759,298,174 | 41054ba624da47a0c2e963e82c007cf5ec572e98 | /src/main/java/GShildt/Chapter_8/bookpkg/Book.java | 79c2bc55446f830fe715d03f803f8a3e5555ea92 | []
| no_license | turbomann/HF | https://github.com/turbomann/HF | 7120b5067374ba28864bcf3b4068dad6b5e3fee4 | 7aab02a5372a7b3a655e44e18dc78d0cbbda3fff | refs/heads/master | 2022-12-29T00:17:54.851000 | 2019-10-23T19:33:45 | 2019-10-23T19:33:45 | 113,082,395 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package GShildt.Chapter_8.bookpkg;
public class Book {
protected String title;
protected String author;
protected int pubDate;
public Book(String t, String a, int pd) {
title = t;
author = a;
pubDate = pd;
}
public void toShow() {
System.out.println(title);
System.out.println(author);
System.out.println(pubDate);
System.out.println();
}
}
class ExtBook extends Book {
public String getPublisher() {
return publisher;
}
public void setPublisher(String p) {
publisher = p;
}
private String publisher;
public ExtBook(String t, String a, int d, String p) {
super(t, a, d);
publisher = p;
}
public void show(){
super.toShow();
System.out.println(publisher);
System.out.println();
}
public String getTitle(){return title;}
public void setTitle(String t){title =t;}
public String getAuthor(){return author;}
public void setAuthor(String a){author = a;}
public int getPubDate(){return pubDate;}
public void setPubDate(int date){pubDate = date;}
}
| UTF-8 | Java | 1,158 | java | Book.java | Java | []
| null | []
| package GShildt.Chapter_8.bookpkg;
public class Book {
protected String title;
protected String author;
protected int pubDate;
public Book(String t, String a, int pd) {
title = t;
author = a;
pubDate = pd;
}
public void toShow() {
System.out.println(title);
System.out.println(author);
System.out.println(pubDate);
System.out.println();
}
}
class ExtBook extends Book {
public String getPublisher() {
return publisher;
}
public void setPublisher(String p) {
publisher = p;
}
private String publisher;
public ExtBook(String t, String a, int d, String p) {
super(t, a, d);
publisher = p;
}
public void show(){
super.toShow();
System.out.println(publisher);
System.out.println();
}
public String getTitle(){return title;}
public void setTitle(String t){title =t;}
public String getAuthor(){return author;}
public void setAuthor(String a){author = a;}
public int getPubDate(){return pubDate;}
public void setPubDate(int date){pubDate = date;}
}
| 1,158 | 0.601036 | 0.600173 | 55 | 19.872726 | 17.037983 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.581818 | false | false | 15 |
e77a187e349f07c1aecf205b32f43680bbef9445 | 28,930,899,740,073 | a1084ed83078a7ddd3f74726253637889c8916fb | /tianpengaddemo/src/main/java/com/tianpeng/tianpengaddemo/information/InformationImageOnlyActivity.java | b903afbfc30f7de0e0b4cc11be895eb828626d3d | []
| no_license | tianpengco/tianpeng_SDK_for_Android_demo | https://github.com/tianpengco/tianpeng_SDK_for_Android_demo | 6f7ae1fdc4ba0dc969d8242708193578ca1d6598 | 9fe9c8835722d3b44d7c3870d8f3eafb208eb60f | refs/heads/master | 2021-07-21T04:00:19.609000 | 2020-05-20T10:06:13 | 2020-05-20T10:06:13 | 166,759,123 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tianpeng.tianpengaddemo.information;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.tianpeng.tianpengaddemo.MySmartRefreshLayout;
import com.tianpeng.tianpengaddemo.R;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.information.ADMobGenInformation;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.information.IADMobGenInformation;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.listener.SimpleADMobGenInformationAdListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author : ciba
* @date : 2018/6/23
* @description : 信息流广告demo
*/
public class InformationImageOnlyActivity extends Activity implements OnRefreshLoadMoreListener {
private static final String TAG = "InformationActivity";
private RecyclerView mRecyclerView;
private List<Object> mDataList = new ArrayList<>();
private CustomLoadImageOnlyAdapter mAdapter;
private MySmartRefreshLayout refreshLayout;
private ADMobGenInformation adMobGenInformation;
private LinearLayoutManager linearLayoutManager;
private int loadType;
public static void jumpHere(Context context) {
context.startActivity(new Intent(context, InformationImageOnlyActivity.class));
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_information);
refreshLayout = findViewById(R.id.refreshLayout);
mRecyclerView = findViewById(R.id.lvList);
mRecyclerView.setHasFixedSize(true);
linearLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(linearLayoutManager);
mAdapter = new CustomLoadImageOnlyAdapter(mDataList);
mRecyclerView.setAdapter(mAdapter);
adMobGenInformation = new ADMobGenInformation(this);
// 设置纯图信息流
adMobGenInformation.setListener(new SimpleADMobGenInformationAdListener() {
@Override
public void onADExposure(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告展示曝光回调,但不一定是曝光成功了,比如一些网络问题导致上报失败 ::::: ");
}
@Override
public void onADReceiv(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告获取成功 ::::: ");
finishLoad(adMobGenInformation);
}
@Override
public void onADClick(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告被点击 ::::: ");
}
@Override
public void onADFailed(String error) {
Log.e(TAG, "广告数据获取失败时回调 ::::: " + error);
finishLoad(null);
}
});
refreshLayout.setOnRefreshLoadMoreListener(this);
refreshLayout.autoRefresh();
}
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
loadType = MySmartRefreshLayout.TYPE_LOAD_MORE;
loadData();
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
loadType = MySmartRefreshLayout.TYPE_FRESH;
clearData();
loadData();
}
@Override
protected void onDestroy() {
super.onDestroy();
// 广告视图资源释放
clearData();
// 广告资源释放
if (adMobGenInformation != null) {
adMobGenInformation.destroy();
}
}
/**
* 获取结束
*
* @param adMobGenInformation :广告对象
*/
private void finishLoad(IADMobGenInformation adMobGenInformation) {
refreshLayout.finish(loadType, adMobGenInformation != null, false);
if (adMobGenInformation != null) {
mDataList.add(adMobGenInformation);
}
mAdapter.notifyDataSetChanged();
}
/**
* 模拟获取数据
*/
private void loadData() {
for (int i = 0; i < 10; ++i) {
mDataList.add("No." + i + " Normal Data");
}
// 获取广告
adMobGenInformation.loadAd();
}
/**
* 释放广告视图
*/
private void clearData() {
for (int i = 0; i < mDataList.size(); i++) {
Object o = mDataList.get(i);
if (o != null && o instanceof IADMobGenInformation) {
((IADMobGenInformation) o).destroy();
}
}
mDataList.clear();
mAdapter.notifyDataSetChanged();
}
}
| UTF-8 | Java | 4,961 | java | InformationImageOnlyActivity.java | Java | [
{
"context": "rayList;\nimport java.util.List;\n\n\n/**\n * @author : ciba\n * @date : 2018/6/23\n * @description : 信息流广告demo\n",
"end": 925,
"score": 0.9995092153549194,
"start": 921,
"tag": "USERNAME",
"value": "ciba"
}
]
| null | []
| package com.tianpeng.tianpengaddemo.information;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshLoadMoreListener;
import com.tianpeng.tianpengaddemo.MySmartRefreshLayout;
import com.tianpeng.tianpengaddemo.R;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.information.ADMobGenInformation;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.information.IADMobGenInformation;
import com.tianpeng.tp_adsdk.tpadmobsdk.ad.listener.SimpleADMobGenInformationAdListener;
import java.util.ArrayList;
import java.util.List;
/**
* @author : ciba
* @date : 2018/6/23
* @description : 信息流广告demo
*/
public class InformationImageOnlyActivity extends Activity implements OnRefreshLoadMoreListener {
private static final String TAG = "InformationActivity";
private RecyclerView mRecyclerView;
private List<Object> mDataList = new ArrayList<>();
private CustomLoadImageOnlyAdapter mAdapter;
private MySmartRefreshLayout refreshLayout;
private ADMobGenInformation adMobGenInformation;
private LinearLayoutManager linearLayoutManager;
private int loadType;
public static void jumpHere(Context context) {
context.startActivity(new Intent(context, InformationImageOnlyActivity.class));
}
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_information);
refreshLayout = findViewById(R.id.refreshLayout);
mRecyclerView = findViewById(R.id.lvList);
mRecyclerView.setHasFixedSize(true);
linearLayoutManager = new LinearLayoutManager(this);
mRecyclerView.setLayoutManager(linearLayoutManager);
mAdapter = new CustomLoadImageOnlyAdapter(mDataList);
mRecyclerView.setAdapter(mAdapter);
adMobGenInformation = new ADMobGenInformation(this);
// 设置纯图信息流
adMobGenInformation.setListener(new SimpleADMobGenInformationAdListener() {
@Override
public void onADExposure(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告展示曝光回调,但不一定是曝光成功了,比如一些网络问题导致上报失败 ::::: ");
}
@Override
public void onADReceiv(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告获取成功 ::::: ");
finishLoad(adMobGenInformation);
}
@Override
public void onADClick(IADMobGenInformation adMobGenInformation) {
Log.e(TAG, "广告被点击 ::::: ");
}
@Override
public void onADFailed(String error) {
Log.e(TAG, "广告数据获取失败时回调 ::::: " + error);
finishLoad(null);
}
});
refreshLayout.setOnRefreshLoadMoreListener(this);
refreshLayout.autoRefresh();
}
@Override
public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
loadType = MySmartRefreshLayout.TYPE_LOAD_MORE;
loadData();
}
@Override
public void onRefresh(@NonNull RefreshLayout refreshLayout) {
loadType = MySmartRefreshLayout.TYPE_FRESH;
clearData();
loadData();
}
@Override
protected void onDestroy() {
super.onDestroy();
// 广告视图资源释放
clearData();
// 广告资源释放
if (adMobGenInformation != null) {
adMobGenInformation.destroy();
}
}
/**
* 获取结束
*
* @param adMobGenInformation :广告对象
*/
private void finishLoad(IADMobGenInformation adMobGenInformation) {
refreshLayout.finish(loadType, adMobGenInformation != null, false);
if (adMobGenInformation != null) {
mDataList.add(adMobGenInformation);
}
mAdapter.notifyDataSetChanged();
}
/**
* 模拟获取数据
*/
private void loadData() {
for (int i = 0; i < 10; ++i) {
mDataList.add("No." + i + " Normal Data");
}
// 获取广告
adMobGenInformation.loadAd();
}
/**
* 释放广告视图
*/
private void clearData() {
for (int i = 0; i < mDataList.size(); i++) {
Object o = mDataList.get(i);
if (o != null && o instanceof IADMobGenInformation) {
((IADMobGenInformation) o).destroy();
}
}
mDataList.clear();
mAdapter.notifyDataSetChanged();
}
}
| 4,961 | 0.658311 | 0.655572 | 150 | 30.646667 | 24.998436 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.506667 | false | false | 15 |
89cf0f6a09122f5ab12cd43f422edf66e16769df | 9,526,237,481,355 | 6e5fd567097d572952fd2adb5630d17ebf7fe565 | /HW_06/src/main/java/by/dm13y/study/atm/cashService/CashService.java | dbbc6428a3bd10ef8840b10ade2fe4dee89e2848 | []
| no_license | DmitryevichD/otus-java-2017-10-dm13y | https://github.com/DmitryevichD/otus-java-2017-10-dm13y | cf5d38722f7d2867831a68e3f534e6d0811fa731 | c9ea0d742dbec9b286b39a153134d6b3b039f678 | refs/heads/master | 2021-09-09T17:22:19.277000 | 2018-03-18T12:53:02 | 2018-03-18T12:53:02 | 106,913,141 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package by.dm13y.study.atm.cashService;
import by.dm13y.study.atm.money.Banknote;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
public interface CashService{
void setAcceptedBanknotes(@NotNull List<Banknote> acceptedBanknotes);
boolean isAccepted(Banknote banknote);
default Banknote processBanknote(Banknote banknote){
if(isAccepted(banknote)){
return banknote;
}
returnBanknote(banknote);
throw new UnsupportedOperationException("Banknote is not supported");
}
default void returnBanknote(Banknote banknote){}
default void giveBanknotes(List<Banknote> banknotes){}
Banknote setBanknoteEvent() throws Exception;
}
| UTF-8 | Java | 800 | java | CashService.java | Java | []
| null | []
| package by.dm13y.study.atm.cashService;
import by.dm13y.study.atm.money.Banknote;
import org.jetbrains.annotations.NotNull;
import java.util.Collections;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
public interface CashService{
void setAcceptedBanknotes(@NotNull List<Banknote> acceptedBanknotes);
boolean isAccepted(Banknote banknote);
default Banknote processBanknote(Banknote banknote){
if(isAccepted(banknote)){
return banknote;
}
returnBanknote(banknote);
throw new UnsupportedOperationException("Banknote is not supported");
}
default void returnBanknote(Banknote banknote){}
default void giveBanknotes(List<Banknote> banknotes){}
Banknote setBanknoteEvent() throws Exception;
}
| 800 | 0.74625 | 0.74125 | 28 | 27.571428 | 23.197027 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.464286 | false | false | 15 |
7cbbc485e71468cdba92f765549376a2438c3c83 | 17,257,178,638,139 | e2864c5a8ab38f238009b42f3d46c0d4bfa66def | /app/src/main/java/com/magdamiu/firebaseforbeginners/helpers/Utils.java | ed4ed6bcbeb0f08139e28dbc211478a6a5fe281c | []
| no_license | magdamiu/FirebaseForBeginners | https://github.com/magdamiu/FirebaseForBeginners | 88176181f0c6d349f0208cf820159a59f1876fdc | 39134b17836c823c98f74b8a7dd0d335d9ee90d5 | refs/heads/master | 2021-01-22T04:01:17.945000 | 2017-05-25T16:37:51 | 2017-05-25T16:37:51 | 92,421,737 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.magdamiu.firebaseforbeginners.helpers;
/**
* Created by magdamiu on 25/05/17.
*/
public class Utils {
public static boolean isEmpty(String string) {
if (string != null && string.length() > 0)
return true;
else return false;
}
}
| UTF-8 | Java | 281 | java | Utils.java | Java | [
{
"context": "u.firebaseforbeginners.helpers;\n\n/**\n * Created by magdamiu on 25/05/17.\n */\n\npublic class Utils {\n\n publi",
"end": 78,
"score": 0.9994683861732483,
"start": 70,
"tag": "USERNAME",
"value": "magdamiu"
}
]
| null | []
| package com.magdamiu.firebaseforbeginners.helpers;
/**
* Created by magdamiu on 25/05/17.
*/
public class Utils {
public static boolean isEmpty(String string) {
if (string != null && string.length() > 0)
return true;
else return false;
}
}
| 281 | 0.619217 | 0.594306 | 14 | 19.071428 | 19.509939 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.214286 | false | false | 15 |
21abdbc26ec30da1e0740de1e174e7219e72f8d8 | 17,257,178,636,440 | 7150c644e8c8f12b518e286471fbb5c843cc55cc | /2015s-OOP/week2/lab2/inheritance/InvalidBuildingException.java | 5f14602d01ec2cebabeea2f5bb7a9fb339f74c21 | []
| no_license | BenningtonCS/bwalter | https://github.com/BenningtonCS/bwalter | 17eda98f5580b199e17bf41225f93b161c8ad5d7 | fcb259811e9bab2090c0543ed257690a7a04a8e9 | refs/heads/master | 2021-05-03T10:56:24.814000 | 2016-09-12T02:26:16 | 2016-09-12T02:26:16 | 23,851,862 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | class InvalidBuildingException extends Exception { }
| UTF-8 | Java | 54 | java | InvalidBuildingException.java | Java | []
| null | []
| class InvalidBuildingException extends Exception { }
| 54 | 0.833333 | 0.833333 | 1 | 52 | 0 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 15 |
39f3d76c89485af6db363051a155b03643bb078c | 38,792,144,653,276 | e89d4ca3008f4e110866494e686eeb11a03c2099 | /src/main/java/com/cg/onlineadmissionsyst/repository/ICourseRepository.java | a83e162f5a19c6cc49164da60b2a3a617181b775 | []
| no_license | umabharathi13/OnlineAdmissionSystem | https://github.com/umabharathi13/OnlineAdmissionSystem | 96841a8b4289c2ffa90e3f82ad8062da25c73798 | 92a9571bf8329105f3b2e915c77465cf6125c2f2 | refs/heads/master | 2023-05-04T02:49:15.618000 | 2021-05-17T09:45:13 | 2021-05-17T09:45:13 | 366,949,089 | 0 | 0 | null | false | 2021-05-17T10:15:45 | 2021-05-13T05:57:09 | 2021-05-17T09:45:18 | 2021-05-17T10:14:24 | 318 | 0 | 0 | 3 | HTML | false | false | package com.cg.onlineadmissionsyst.repository;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.cg.onlineadmissionsyst.module.Course;
@Repository
public interface ICourseRepository extends JpaRepository<Course,Integer>{
@Query("select c from Course c where c.courseName=:crname")
public Course findByName(@Param("crname") String courseName);
@Query("select c1 from Course c1 where c1.eligibility=:eligibility")
public List<Course> findByEligibility(@Param("eligibility") String eligibility);
//@Modifying
@Query(value = "delete from course where course_name = :course_name",nativeQuery=true)
public void deleteCourseByCourseName(@Param("course_name") String courseName);
/*
@Query(value="DELETE FROM Course c WHERE c.courseName = :name")
Course deleteCourseByCourseName(@Param("name") String courseName);*/
public Optional<Course> findByCourseName(String courseName);
@Query(value = "select * from course inner join college on course.college_id=college.college_reg_id where college.college_name =:n",nativeQuery=true)
public List<Course> findBycollegeName(@Param("n") String collegeName);
}
| UTF-8 | Java | 1,446 | java | ICourseRepository.java | Java | []
| null | []
| package com.cg.onlineadmissionsyst.repository;
import java.util.List;
import java.util.Optional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.cg.onlineadmissionsyst.module.Course;
@Repository
public interface ICourseRepository extends JpaRepository<Course,Integer>{
@Query("select c from Course c where c.courseName=:crname")
public Course findByName(@Param("crname") String courseName);
@Query("select c1 from Course c1 where c1.eligibility=:eligibility")
public List<Course> findByEligibility(@Param("eligibility") String eligibility);
//@Modifying
@Query(value = "delete from course where course_name = :course_name",nativeQuery=true)
public void deleteCourseByCourseName(@Param("course_name") String courseName);
/*
@Query(value="DELETE FROM Course c WHERE c.courseName = :name")
Course deleteCourseByCourseName(@Param("name") String courseName);*/
public Optional<Course> findByCourseName(String courseName);
@Query(value = "select * from course inner join college on course.college_id=college.college_reg_id where college.college_name =:n",nativeQuery=true)
public List<Course> findBycollegeName(@Param("n") String collegeName);
}
| 1,446 | 0.775242 | 0.773167 | 36 | 38.166668 | 36.006557 | 150 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.944444 | false | false | 15 |
522d7b82846b54ed5595e3e8a64849c6a1abac6e | 5,660,766,935,203 | 34c7b13ed4b6fb496292c6145c2cf1ec4421efb7 | /src/test/java/com/tecprotec/BusinessFlow/ProductBusinessFlow.java | a6d351a15cc57cb4c3a75595f3b00d423f8a5643 | []
| no_license | pkumar94/tecprotecAutomation | https://github.com/pkumar94/tecprotecAutomation | 1672533c336ab280856261daa2069af98f039f5e | a9f1d7917ab3762e45eced3ab88d6472aa13176c | refs/heads/master | 2022-07-11T20:25:17.337000 | 2019-08-01T06:36:44 | 2019-08-01T06:36:44 | 199,991,822 | 0 | 0 | null | false | 2022-06-29T17:32:54 | 2019-08-01T06:34:53 | 2019-08-01T06:38:45 | 2022-06-29T17:32:53 | 8,146 | 0 | 0 | 12 | Java | false | false | package com.tecprotec.BusinessFlow;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.tecprotec.Locators.HomePageLocators;
import com.tecprotec.Locators.ProductLocators;
import com.tecprotec.Reporting.Extent_Reporting;
import com.tecprotec.Utilities.Excel_Handling;
import com.tecprotec.Utilities.WrapperMethods;
public class ProductBusinessFlow
{
WebDriver driver;
WrapperMethods method = new WrapperMethods();
public ProductBusinessFlow(WebDriver driver, String TC_ID) throws Throwable
{
System.out.println("ProductBusinessFlow() constructor");
Login_BusinessFlows obj1 = new Login_BusinessFlows();
obj1.login(driver, TC_ID);
}
public void selectProduct(WebDriver driver, String TC_ID) throws Throwable
{
try {
method.Clickbtn(driver, HomePageLocators.btnProduct, "Product");
Extent_Reporting.Log_Pass_with_Screenshot("Products", "view Products", driver);
String Excelproduct = Excel_Handling.Get_Data(TC_ID, "Product");
System.out.println("Product name:: " +Excelproduct);
List<WebElement> productList = method.findElementsInList(driver, ProductLocators.productList, "product list value");
for(WebElement list : productList)
{
String attValue=list.getAttribute("class");
System.out.println("Attribute value is ::" +attValue);
if (attValue.contains(Excelproduct))
{
System.out.println("Selecting propremium product");
method.Clickbtn(driver, ProductLocators.selProductPropremium, "propremium");
Extent_Reporting.Log_with_Screenshot("product selected", driver);
System.out.println(" propremium Selected successfully");
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 1,803 | java | ProductBusinessFlow.java | Java | []
| null | []
| package com.tecprotec.BusinessFlow;
import java.util.List;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import com.tecprotec.Locators.HomePageLocators;
import com.tecprotec.Locators.ProductLocators;
import com.tecprotec.Reporting.Extent_Reporting;
import com.tecprotec.Utilities.Excel_Handling;
import com.tecprotec.Utilities.WrapperMethods;
public class ProductBusinessFlow
{
WebDriver driver;
WrapperMethods method = new WrapperMethods();
public ProductBusinessFlow(WebDriver driver, String TC_ID) throws Throwable
{
System.out.println("ProductBusinessFlow() constructor");
Login_BusinessFlows obj1 = new Login_BusinessFlows();
obj1.login(driver, TC_ID);
}
public void selectProduct(WebDriver driver, String TC_ID) throws Throwable
{
try {
method.Clickbtn(driver, HomePageLocators.btnProduct, "Product");
Extent_Reporting.Log_Pass_with_Screenshot("Products", "view Products", driver);
String Excelproduct = Excel_Handling.Get_Data(TC_ID, "Product");
System.out.println("Product name:: " +Excelproduct);
List<WebElement> productList = method.findElementsInList(driver, ProductLocators.productList, "product list value");
for(WebElement list : productList)
{
String attValue=list.getAttribute("class");
System.out.println("Attribute value is ::" +attValue);
if (attValue.contains(Excelproduct))
{
System.out.println("Selecting propremium product");
method.Clickbtn(driver, ProductLocators.selProductPropremium, "propremium");
Extent_Reporting.Log_with_Screenshot("product selected", driver);
System.out.println(" propremium Selected successfully");
}
}
}
catch (Exception e) {
e.printStackTrace();
}
}
}
| 1,803 | 0.727121 | 0.726012 | 66 | 26.318182 | 28.602373 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.606061 | false | false | 15 |
29574574a17ac05ffcbb6e872ad3c86ae8360f27 | 6,193,342,879,294 | f2ca66c77e603aca2a8425827869c36bec7a4bc6 | /Practica5-6/Practica5-6_IsaiasJerez/src/java/LoginServlet.java | 2d2959517d8057ea2b8fa67f8f76647cd91e147a | []
| no_license | IsaiasJerez/LDOO_EJ_19 | https://github.com/IsaiasJerez/LDOO_EJ_19 | 3aa3381d563df9da4f1abd060889524c7da63cd7 | eb8ca3c2cbebfc19f135ee965e1a327b09f1a2a0 | refs/heads/master | 2020-04-22T13:28:43.625000 | 2019-04-18T22:00:39 | 2019-04-18T22:00:39 | 170,410,721 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet(urlPatterns = {"/LoginServlet"})
public class LoginServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
HttpSession session= request.getSession(true);
String nombrelogin = request.getParameter("nombreLogin");
String passLogin = request.getParameter("passLogin");
if ((passLogin.equals((String)session.getAttribute("pass"))) && (nombrelogin.equals((String)session.getAttribute("nombre")))){
Cookie userCookie = new Cookie("nombre", "nombrelogin");
userCookie.setMaxAge(60*60*24*365);
response.sendRedirect("bienvenido.jsp");
}else{
response.sendRedirect("login.jsp?error=error");
}
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
| UTF-8 | Java | 1,909 | java | LoginServlet.java | Java | []
| null | []
| import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@WebServlet(urlPatterns = {"/LoginServlet"})
public class LoginServlet extends HttpServlet {
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
HttpSession session= request.getSession(true);
String nombrelogin = request.getParameter("nombreLogin");
String passLogin = request.getParameter("passLogin");
if ((passLogin.equals((String)session.getAttribute("pass"))) && (nombrelogin.equals((String)session.getAttribute("nombre")))){
Cookie userCookie = new Cookie("nombre", "nombrelogin");
userCookie.setMaxAge(60*60*24*365);
response.sendRedirect("bienvenido.jsp");
}else{
response.sendRedirect("login.jsp?error=error");
}
}
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
@Override
public String getServletInfo() {
return "Short description";
}
}
| 1,909 | 0.659508 | 0.654269 | 48 | 37.729168 | 28.989754 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625 | false | false | 15 |
d3cceae3c1842e98065d5eeddd2853897556c041 | 6,339,371,775,023 | 52a61700be74ae1a5fd1a7b4d2bdfe632015ecb8 | /src/main/java/org/sarge/jove/platform/vulkan/core/Query.java | 7cda6e72912c4d1fa864f0215de7132ee57bc515 | []
| no_license | stridecolossus/JOVE | https://github.com/stridecolossus/JOVE | 60c248a09171827b049b599e8006a7e558f8b3ba | 690f01a8a4464c967781c3d7a53a8866be00793b | refs/heads/master | 2023-07-20T07:40:09.165000 | 2023-07-08T16:21:22 | 2023-07-08T16:21:22 | 17,083,829 | 1 | 0 | null | false | 2014-03-23T18:00:38 | 2014-02-22T11:51:16 | 2014-03-23T18:00:38 | 2014-03-23T18:00:38 | 412 | 0 | 0 | 0 | Java | null | null | package org.sarge.jove.platform.vulkan.core;
import static org.sarge.jove.platform.vulkan.core.VulkanLibrary.check;
import static org.sarge.lib.util.Check.*;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.function.Consumer;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.sarge.jove.common.Handle;
import org.sarge.jove.platform.vulkan.*;
import org.sarge.jove.platform.vulkan.common.*;
import org.sarge.jove.platform.vulkan.core.Command.Buffer;
import org.sarge.jove.util.BitMask;
import org.sarge.lib.util.Check;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
/**
* A <i>query</i> is used to retrieve statistics from Vulkan during a render pass.
* <p>
* Generally a query is comprised of two commands that wrap a portion of a render sequence, e.g. to perform an {@link VkQueryType#OCCLUSION} query.
* <p>
* Queries are allocated as <i>slots</i> from a {@link Pool} created via the {@link Pool#create(DeviceContext, VkQueryType, int, VkQueryPipelineStatisticFlag...)} factory method.
* Note that a query pool <b>must</b> be reset before each sample <b>outside</b> the render pass.
* <p>
* The {@link ResultBuilder} is used to configure the results of a query and to write the data to a destination buffer.
* <p>
* Example for an occlusion query:
* <p>
* {@snippet :
* // Create an occlusion query pool with two slots
* LogicalDevice dev = ...
* Pool pool = Pool.create(dev, VkQueryType.OCCLUSION, 2);
*
* // Allocate a query for the second slot
* DefaultQuery query = pool.query(1);
*
* // Instrument the render sequence with the query
* FrameBuffer frame = ...
* Command.Buffer buffer = ...
* buffer // @highlight region substring="query" type=highlighted
* .add(query.reset())
* .add(frame.begin())
* .add(query.begin())
* ...
* .add(query.end())
* .add(FrameBuffer#END); // @end
*
* // Retrieve the query results
* ByteBuffer results = ...
* pool.result().build().accept(results);
* }
* <p>
* @author Sarge
*/
public interface Query {
/**
* Convenience method to create a command to reset this query.
* @return Reset command
* @see Pool#reset(int, int)
*/
Command reset();
/**
* Default implementation for a measurement query wrapping a portion of the render sequence.
*/
interface DefaultQuery extends Query {
/**
* Creates a command to begin this query.
* @param flags Control flags
* @return Begin query command
*/
Command begin(VkQueryControlFlag... flags);
/**
* Creates a command to end this query.
* @return End query command
*/
Command end();
}
/**
* Timestamp query.
*/
interface Timestamp extends Query {
/**
* Creates a command to write the device timestamp at the given pipeline stage.
* @param stage Pipeline stage
* @return Timestamp command
*/
Command timestamp(VkPipelineStage stage);
}
/**
* A <i>query pool</i> is comprised of a number of <i>slots</i> used to execute queries.
*/
final class Pool extends VulkanObject {
/**
* Creates a query pool.
* @param dev Device
* @param type Query type
* @param slots Number of slots
* @param stats Pipeline statistics to gather for a {@link VkQueryType#PIPELINE_STATISTICS} query
* @return New query pool
* @throws IllegalArgumentException for a pipeline statistics query with an empty set of flags
*/
public static Pool create(DeviceContext dev, VkQueryType type, int slots, VkQueryPipelineStatisticFlag... stats) {
// Validate
if((type == VkQueryType.PIPELINE_STATISTICS) != (stats.length > 0)) {
throw new IllegalArgumentException("Empty or superfluous pipeline statistics");
}
// Init create descriptor
final var info = new VkQueryPoolCreateInfo();
info.queryType = notNull(type);
info.queryCount = oneOrMore(slots);
info.pipelineStatistics = BitMask.of(stats);
// Instantiate query pool
final PointerByReference ref = dev.factory().pointer();
final VulkanLibrary lib = dev.library();
check(lib.vkCreateQueryPool(dev, info, null, ref));
// Create pool
return new Pool(new Handle(ref), dev, type, slots);
}
private final VkQueryType type;
private final int slots;
/**
* Constructor.
* @param handle Handle
* @param dev Logical device
* @param type Query type
* @param slots Number of query slots
*/
Pool(Handle handle, DeviceContext dev, VkQueryType type, int slots) {
super(handle, dev);
this.type = notNull(type);
this.slots = oneOrMore(slots);
}
/**
* @return Number of slots in this pool
*/
public int slots() {
return slots;
}
/**
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
private void validate(int slot) {
Check.zeroOrMore(slot);
if(slot >= slots) throw new IllegalArgumentException(String.format("Invalid query slot: slot=%d pool=%s", slot, this));
}
/**
* Creates a query.
* @param slot Query slot
* @return New query
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
public DefaultQuery query(int slot) {
validate(slot);
return new DefaultQuery() {
@Override
public Command reset() {
return Pool.this.reset(slot, 1);
}
@Override
public Command begin(VkQueryControlFlag... flags) {
final BitMask<VkQueryControlFlag> mask = BitMask.of(flags);
return (lib, buffer) -> lib.vkCmdBeginQuery(buffer, Pool.this, slot, mask);
}
@Override
public Command end() {
return (lib, buffer) -> lib.vkCmdEndQuery(buffer, Pool.this, slot);
}
};
}
/**
* Creates a timestamp.
* @param slot Query slot
* @return New timestamp
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
public Timestamp timestamp(int slot) {
validate(slot);
return new Timestamp() {
@Override
public Command reset() {
return Pool.this.reset(slot, 1);
}
@Override
public Command timestamp(VkPipelineStage stage) {
Check.notNull(stage);
return (lib, buffer) -> lib.vkCmdWriteTimestamp(buffer, stage, Pool.this, slot);
}
};
}
/**
* Creates a reset command a segment of this pool.
* @param start Starting slot
* @param num Number of slots
* @return Reset command
* @throws IllegalArgumentException if the given range is out-of-bounds for this pool
*/
public Command reset(int start, int num) {
Check.zeroOrMore(start);
validate(start + num - 1);
return (lib, buffer) -> lib.vkCmdResetQueryPool(buffer, this, start, num);
}
/**
* Convenience factory to create a reset command for <b>all</b> slots in this pool.
* @return Reset command
* @see #reset(int, int)
*/
public Command reset() {
return reset(0, slots);
}
/**
* Creates a result builder for this query pool.
* @return New result builder
*/
public ResultBuilder result() {
return new ResultBuilder(this);
}
@Override
protected Destructor<Pool> destructor(VulkanLibrary lib) {
return lib::vkDestroyQueryPool;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.appendSuper(super.toString())
.append(type)
.append("slots", slots)
.build();
}
}
/**
* A <i>result builder</i> is used to configure and retrieve the results of a query.
* <p>
* The results are written to a data buffer which is essentially an array divided into the configured number of {@link ResultBuilder#stride(long)} bytes.
* <p>
* Note that by default the results have an <b>integer</b> data type with contiguous values.
* The {@link VkQueryResultFlag#LONG} flag is used to specify a query with a {@code long} data type.
* Additionally the convenience {@link ResultBuilder#longs()} method configures a query result for {@code long} values with an appropriate stride.
* <p>
* Note this builder provides <b>two</b> build methods variants:
* <ul>
* <li>{@link ResultBuilder#build()} creates an accessor to retrieve query results to an on-demand consumer</li>
* <li>{@link ResultBuilder#build(VulkanBuffer, long)} creates a command that asynchronously writes the results to a destination Vulkan buffer</li>
* </ul>
* <p>
* Example usage for an on-demand buffer:
* <pre>
* // Create a result builder
* ResultBuilder builder = pool.result();
*
* // Construct the accessor
* Consumer<ByteBuffer> accessor = builder
* .start(1)
* .count(2)
* .flag(VkQueryResultFlag.WAIT)
* .build();
*
* // Copy query results to a buffer
* ByteBuffer bb = ...
* accessor.accept(bb);
* </pre>
*/
class ResultBuilder {
private final Pool pool;
private int start;
private int count;
private long stride = Integer.BYTES;
private final Set<VkQueryResultFlag> flags = new HashSet<>();
private ResultBuilder(Pool pool) {
this.pool = pool;
this.count = pool.slots;
}
/**
* Sets the starting slot (default is the <i>first</i> slot).
* @param start Starting slot
* @throws IllegalArgumentException if {@code start} exceeds the number of query slots
*/
public ResultBuilder start(int start) {
pool.validate(start);
this.start = zeroOrMore(start);
return this;
}
/**
* Sets the number of query slots to retrieve (default is <b>all</b> slots in this pool).
* @param count Number of slots
* @throws IllegalArgumentException if {@code count} exceeds the number of query slots
*/
public ResultBuilder count(int count) {
pool.validate(count);
this.count = oneOrMore(count);
return this;
}
/**
* Sets the stride between results within the buffer (default is {@link Integer#BYTES}).
* @param stride Results stride (bytes)
*/
public ResultBuilder stride(long stride) {
this.stride = oneOrMore(stride);
return this;
}
/**
* Adds a flag to this query.
* @param flag Query flag
*/
public ResultBuilder flag(VkQueryResultFlag flag) {
flags.add(notNull(flag));
return this;
}
/**
* Convenience method to configure this builder to retrieve {@code long} query results with a stride of {@link Long#BYTES}.
*/
public ResultBuilder longs() {
flag(VkQueryResultFlag.LONG);
stride(Long.BYTES);
return this;
}
/**
* Constructs an accessor that retrieves the query results on-demand.
* @return Query results accessor
* @throws IllegalArgumentException if the query range is invalid for this pool
* @throws IllegalArgumentException if the stride is not a multiple of the data type of this query
* @throws IllegalArgumentException if the buffer is too small for this query
*/
public Consumer<ByteBuffer> build() {
// Validate query result
final BitMask<VkQueryResultFlag> mask = validate();
// Init library
final DeviceContext dev = pool.device();
final Library lib = dev.library();
// Create accessor
return buffer -> {
// Validate buffer
final int size = buffer.remaining();
if(count * stride > size) throw new IllegalStateException(String.format("Insufficient buffer space for query: query=%s buffer=%s", ResultBuilder.this, buffer));
pool.validate(start + count - 1);
// Execute query
check(lib.vkGetQueryPoolResults(dev, pool, start, count, size, buffer, stride, mask));
};
}
/**
* Constructs a command that asynchronously copies query results to the given buffer.
* @param buffer Vulkan buffer
* @param offset Buffer offset
* @return Query results command
* @throws IllegalArgumentException if the query range is invalid for this pool
* @throws IllegalArgumentException if the stride is not a multiple of the data type of this query
* @throws IllegalStateException if the {@link #offset} is invalid for the given buffer
* @throws IllegalStateException if {@link #buffer} is not a {@link VkBufferUsageFlag#TRANSFER_DST}
*/
public Command build(VulkanBuffer buffer, long offset) {
// Validate buffer
Check.notNull(buffer);
Check.zeroOrMore(offset);
buffer.require(VkBufferUsageFlag.TRANSFER_DST);
buffer.checkOffset(offset - 1 + count * stride);
// Validate query result
final BitMask<VkQueryResultFlag> mask = validate();
// Create results command
return (lib, cmd) -> {
// TODO - rewind?
lib.vkCmdCopyQueryPoolResults(cmd, pool, start, count, buffer, offset, stride, mask);
};
}
/**
* Validates this query result.
* @return Flags bit-field
*/
private BitMask<VkQueryResultFlag> validate() {
// Validate query range
if(start + count > pool.slots) {
throw new IllegalArgumentException(String.format("Invalid query slot range: start=%d count=%d pool=%s", start, count, pool));
}
// Validate stride
final long multiple = flags.contains(VkQueryResultFlag.LONG) ? Long.BYTES : Integer.BYTES;
if((stride % multiple) != 0) {
throw new IllegalArgumentException(String.format("Stride must be a multiple of the data type for this query: multiple=%d stride=%d", multiple, stride));
}
// Build flags mask
return new BitMask<>(flags);
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("start", start)
.append("count", count)
.append("stride", stride)
.append(pool)
.build();
}
}
/**
* Query API.
*/
interface Library {
/**
* Creates a query pool.
* @param device Logical device
* @param pCreateInfo Create descriptor
* @param pAllocator Allocator
* @param pQueryPool Returned query pool
* @return Result
*/
int vkCreateQueryPool(DeviceContext device, VkQueryPoolCreateInfo pCreateInfo, Pointer pAllocator, PointerByReference pQueryPool);
/**
* Destroys a query pool.
* @param device Logical device
* @param queryPool Query pool to destroy
* @param pAllocator Allocator
*/
void vkDestroyQueryPool(DeviceContext device, Pool queryPool, Pointer pAllocator);
/**
* Command to reset a query pool.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to reset
*/
void vkCmdResetQueryPool(Buffer commandBuffer, Pool queryPool, int firstQuery, int queryCount);
/**
* Starts a query.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param query Query slot
* @param flags Flags
*/
void vkCmdBeginQuery(Buffer commandBuffer, Pool queryPool, int query, BitMask<VkQueryControlFlag> flags);
/**
* Ends a query.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param query Query slot
*/
void vkCmdEndQuery(Buffer commandBuffer, Pool queryPool, int query);
/**
* Writes the device timestamp at the given pipeline stage to the query results.
* @param commandBuffer Command buffer
* @param pipelineStage Pipeline stage
* @param queryPool Query pool
* @param query Query slot
*/
void vkCmdWriteTimestamp(Buffer commandBuffer, VkPipelineStage pipelineStage, Pool queryPool, int query);
/**
* Retrieves query results.
* @param device Logical device
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to retrieve
* @param dataSize Size of the data buffer
* @param pData Data buffer
* @param stride Data stride (bytes)
* @param flags Query flags
* @return Result
*/
int vkGetQueryPoolResults(DeviceContext device, Pool queryPool, int firstQuery, int queryCount, long dataSize, ByteBuffer pData, long stride, BitMask<VkQueryResultFlag> flags);
/**
* Writes query results to a Vulkan buffer.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to retrieve
* @param dstBuffer Results buffer
* @param dstOffset Offset
* @param stride Data stride (bytes)
* @param flags Query flags
*/
void vkCmdCopyQueryPoolResults(Buffer commandBuffer, Pool queryPool, int firstQuery, int queryCount, VulkanBuffer dstBuffer, long dstOffset, long stride, BitMask<VkQueryResultFlag> flags);
}
}
| UTF-8 | Java | 16,304 | java | Query.java | Java | [
{
"context": "().build().accept(results);\n * }\n * <p>\n * @author Sarge\n */\npublic interface Query {\n\t/**\n\t * Convenience",
"end": 2062,
"score": 0.8096053600311279,
"start": 2057,
"tag": "USERNAME",
"value": "Sarge"
}
]
| null | []
| package org.sarge.jove.platform.vulkan.core;
import static org.sarge.jove.platform.vulkan.core.VulkanLibrary.check;
import static org.sarge.lib.util.Check.*;
import java.nio.ByteBuffer;
import java.util.*;
import java.util.function.Consumer;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.sarge.jove.common.Handle;
import org.sarge.jove.platform.vulkan.*;
import org.sarge.jove.platform.vulkan.common.*;
import org.sarge.jove.platform.vulkan.core.Command.Buffer;
import org.sarge.jove.util.BitMask;
import org.sarge.lib.util.Check;
import com.sun.jna.Pointer;
import com.sun.jna.ptr.PointerByReference;
/**
* A <i>query</i> is used to retrieve statistics from Vulkan during a render pass.
* <p>
* Generally a query is comprised of two commands that wrap a portion of a render sequence, e.g. to perform an {@link VkQueryType#OCCLUSION} query.
* <p>
* Queries are allocated as <i>slots</i> from a {@link Pool} created via the {@link Pool#create(DeviceContext, VkQueryType, int, VkQueryPipelineStatisticFlag...)} factory method.
* Note that a query pool <b>must</b> be reset before each sample <b>outside</b> the render pass.
* <p>
* The {@link ResultBuilder} is used to configure the results of a query and to write the data to a destination buffer.
* <p>
* Example for an occlusion query:
* <p>
* {@snippet :
* // Create an occlusion query pool with two slots
* LogicalDevice dev = ...
* Pool pool = Pool.create(dev, VkQueryType.OCCLUSION, 2);
*
* // Allocate a query for the second slot
* DefaultQuery query = pool.query(1);
*
* // Instrument the render sequence with the query
* FrameBuffer frame = ...
* Command.Buffer buffer = ...
* buffer // @highlight region substring="query" type=highlighted
* .add(query.reset())
* .add(frame.begin())
* .add(query.begin())
* ...
* .add(query.end())
* .add(FrameBuffer#END); // @end
*
* // Retrieve the query results
* ByteBuffer results = ...
* pool.result().build().accept(results);
* }
* <p>
* @author Sarge
*/
public interface Query {
/**
* Convenience method to create a command to reset this query.
* @return Reset command
* @see Pool#reset(int, int)
*/
Command reset();
/**
* Default implementation for a measurement query wrapping a portion of the render sequence.
*/
interface DefaultQuery extends Query {
/**
* Creates a command to begin this query.
* @param flags Control flags
* @return Begin query command
*/
Command begin(VkQueryControlFlag... flags);
/**
* Creates a command to end this query.
* @return End query command
*/
Command end();
}
/**
* Timestamp query.
*/
interface Timestamp extends Query {
/**
* Creates a command to write the device timestamp at the given pipeline stage.
* @param stage Pipeline stage
* @return Timestamp command
*/
Command timestamp(VkPipelineStage stage);
}
/**
* A <i>query pool</i> is comprised of a number of <i>slots</i> used to execute queries.
*/
final class Pool extends VulkanObject {
/**
* Creates a query pool.
* @param dev Device
* @param type Query type
* @param slots Number of slots
* @param stats Pipeline statistics to gather for a {@link VkQueryType#PIPELINE_STATISTICS} query
* @return New query pool
* @throws IllegalArgumentException for a pipeline statistics query with an empty set of flags
*/
public static Pool create(DeviceContext dev, VkQueryType type, int slots, VkQueryPipelineStatisticFlag... stats) {
// Validate
if((type == VkQueryType.PIPELINE_STATISTICS) != (stats.length > 0)) {
throw new IllegalArgumentException("Empty or superfluous pipeline statistics");
}
// Init create descriptor
final var info = new VkQueryPoolCreateInfo();
info.queryType = notNull(type);
info.queryCount = oneOrMore(slots);
info.pipelineStatistics = BitMask.of(stats);
// Instantiate query pool
final PointerByReference ref = dev.factory().pointer();
final VulkanLibrary lib = dev.library();
check(lib.vkCreateQueryPool(dev, info, null, ref));
// Create pool
return new Pool(new Handle(ref), dev, type, slots);
}
private final VkQueryType type;
private final int slots;
/**
* Constructor.
* @param handle Handle
* @param dev Logical device
* @param type Query type
* @param slots Number of query slots
*/
Pool(Handle handle, DeviceContext dev, VkQueryType type, int slots) {
super(handle, dev);
this.type = notNull(type);
this.slots = oneOrMore(slots);
}
/**
* @return Number of slots in this pool
*/
public int slots() {
return slots;
}
/**
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
private void validate(int slot) {
Check.zeroOrMore(slot);
if(slot >= slots) throw new IllegalArgumentException(String.format("Invalid query slot: slot=%d pool=%s", slot, this));
}
/**
* Creates a query.
* @param slot Query slot
* @return New query
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
public DefaultQuery query(int slot) {
validate(slot);
return new DefaultQuery() {
@Override
public Command reset() {
return Pool.this.reset(slot, 1);
}
@Override
public Command begin(VkQueryControlFlag... flags) {
final BitMask<VkQueryControlFlag> mask = BitMask.of(flags);
return (lib, buffer) -> lib.vkCmdBeginQuery(buffer, Pool.this, slot, mask);
}
@Override
public Command end() {
return (lib, buffer) -> lib.vkCmdEndQuery(buffer, Pool.this, slot);
}
};
}
/**
* Creates a timestamp.
* @param slot Query slot
* @return New timestamp
* @throws IllegalArgumentException if the slot is invalid for this pool
*/
public Timestamp timestamp(int slot) {
validate(slot);
return new Timestamp() {
@Override
public Command reset() {
return Pool.this.reset(slot, 1);
}
@Override
public Command timestamp(VkPipelineStage stage) {
Check.notNull(stage);
return (lib, buffer) -> lib.vkCmdWriteTimestamp(buffer, stage, Pool.this, slot);
}
};
}
/**
* Creates a reset command a segment of this pool.
* @param start Starting slot
* @param num Number of slots
* @return Reset command
* @throws IllegalArgumentException if the given range is out-of-bounds for this pool
*/
public Command reset(int start, int num) {
Check.zeroOrMore(start);
validate(start + num - 1);
return (lib, buffer) -> lib.vkCmdResetQueryPool(buffer, this, start, num);
}
/**
* Convenience factory to create a reset command for <b>all</b> slots in this pool.
* @return Reset command
* @see #reset(int, int)
*/
public Command reset() {
return reset(0, slots);
}
/**
* Creates a result builder for this query pool.
* @return New result builder
*/
public ResultBuilder result() {
return new ResultBuilder(this);
}
@Override
protected Destructor<Pool> destructor(VulkanLibrary lib) {
return lib::vkDestroyQueryPool;
}
@Override
public String toString() {
return new ToStringBuilder(this)
.appendSuper(super.toString())
.append(type)
.append("slots", slots)
.build();
}
}
/**
* A <i>result builder</i> is used to configure and retrieve the results of a query.
* <p>
* The results are written to a data buffer which is essentially an array divided into the configured number of {@link ResultBuilder#stride(long)} bytes.
* <p>
* Note that by default the results have an <b>integer</b> data type with contiguous values.
* The {@link VkQueryResultFlag#LONG} flag is used to specify a query with a {@code long} data type.
* Additionally the convenience {@link ResultBuilder#longs()} method configures a query result for {@code long} values with an appropriate stride.
* <p>
* Note this builder provides <b>two</b> build methods variants:
* <ul>
* <li>{@link ResultBuilder#build()} creates an accessor to retrieve query results to an on-demand consumer</li>
* <li>{@link ResultBuilder#build(VulkanBuffer, long)} creates a command that asynchronously writes the results to a destination Vulkan buffer</li>
* </ul>
* <p>
* Example usage for an on-demand buffer:
* <pre>
* // Create a result builder
* ResultBuilder builder = pool.result();
*
* // Construct the accessor
* Consumer<ByteBuffer> accessor = builder
* .start(1)
* .count(2)
* .flag(VkQueryResultFlag.WAIT)
* .build();
*
* // Copy query results to a buffer
* ByteBuffer bb = ...
* accessor.accept(bb);
* </pre>
*/
class ResultBuilder {
private final Pool pool;
private int start;
private int count;
private long stride = Integer.BYTES;
private final Set<VkQueryResultFlag> flags = new HashSet<>();
private ResultBuilder(Pool pool) {
this.pool = pool;
this.count = pool.slots;
}
/**
* Sets the starting slot (default is the <i>first</i> slot).
* @param start Starting slot
* @throws IllegalArgumentException if {@code start} exceeds the number of query slots
*/
public ResultBuilder start(int start) {
pool.validate(start);
this.start = zeroOrMore(start);
return this;
}
/**
* Sets the number of query slots to retrieve (default is <b>all</b> slots in this pool).
* @param count Number of slots
* @throws IllegalArgumentException if {@code count} exceeds the number of query slots
*/
public ResultBuilder count(int count) {
pool.validate(count);
this.count = oneOrMore(count);
return this;
}
/**
* Sets the stride between results within the buffer (default is {@link Integer#BYTES}).
* @param stride Results stride (bytes)
*/
public ResultBuilder stride(long stride) {
this.stride = oneOrMore(stride);
return this;
}
/**
* Adds a flag to this query.
* @param flag Query flag
*/
public ResultBuilder flag(VkQueryResultFlag flag) {
flags.add(notNull(flag));
return this;
}
/**
* Convenience method to configure this builder to retrieve {@code long} query results with a stride of {@link Long#BYTES}.
*/
public ResultBuilder longs() {
flag(VkQueryResultFlag.LONG);
stride(Long.BYTES);
return this;
}
/**
* Constructs an accessor that retrieves the query results on-demand.
* @return Query results accessor
* @throws IllegalArgumentException if the query range is invalid for this pool
* @throws IllegalArgumentException if the stride is not a multiple of the data type of this query
* @throws IllegalArgumentException if the buffer is too small for this query
*/
public Consumer<ByteBuffer> build() {
// Validate query result
final BitMask<VkQueryResultFlag> mask = validate();
// Init library
final DeviceContext dev = pool.device();
final Library lib = dev.library();
// Create accessor
return buffer -> {
// Validate buffer
final int size = buffer.remaining();
if(count * stride > size) throw new IllegalStateException(String.format("Insufficient buffer space for query: query=%s buffer=%s", ResultBuilder.this, buffer));
pool.validate(start + count - 1);
// Execute query
check(lib.vkGetQueryPoolResults(dev, pool, start, count, size, buffer, stride, mask));
};
}
/**
* Constructs a command that asynchronously copies query results to the given buffer.
* @param buffer Vulkan buffer
* @param offset Buffer offset
* @return Query results command
* @throws IllegalArgumentException if the query range is invalid for this pool
* @throws IllegalArgumentException if the stride is not a multiple of the data type of this query
* @throws IllegalStateException if the {@link #offset} is invalid for the given buffer
* @throws IllegalStateException if {@link #buffer} is not a {@link VkBufferUsageFlag#TRANSFER_DST}
*/
public Command build(VulkanBuffer buffer, long offset) {
// Validate buffer
Check.notNull(buffer);
Check.zeroOrMore(offset);
buffer.require(VkBufferUsageFlag.TRANSFER_DST);
buffer.checkOffset(offset - 1 + count * stride);
// Validate query result
final BitMask<VkQueryResultFlag> mask = validate();
// Create results command
return (lib, cmd) -> {
// TODO - rewind?
lib.vkCmdCopyQueryPoolResults(cmd, pool, start, count, buffer, offset, stride, mask);
};
}
/**
* Validates this query result.
* @return Flags bit-field
*/
private BitMask<VkQueryResultFlag> validate() {
// Validate query range
if(start + count > pool.slots) {
throw new IllegalArgumentException(String.format("Invalid query slot range: start=%d count=%d pool=%s", start, count, pool));
}
// Validate stride
final long multiple = flags.contains(VkQueryResultFlag.LONG) ? Long.BYTES : Integer.BYTES;
if((stride % multiple) != 0) {
throw new IllegalArgumentException(String.format("Stride must be a multiple of the data type for this query: multiple=%d stride=%d", multiple, stride));
}
// Build flags mask
return new BitMask<>(flags);
}
@Override
public String toString() {
return new ToStringBuilder(this)
.append("start", start)
.append("count", count)
.append("stride", stride)
.append(pool)
.build();
}
}
/**
* Query API.
*/
interface Library {
/**
* Creates a query pool.
* @param device Logical device
* @param pCreateInfo Create descriptor
* @param pAllocator Allocator
* @param pQueryPool Returned query pool
* @return Result
*/
int vkCreateQueryPool(DeviceContext device, VkQueryPoolCreateInfo pCreateInfo, Pointer pAllocator, PointerByReference pQueryPool);
/**
* Destroys a query pool.
* @param device Logical device
* @param queryPool Query pool to destroy
* @param pAllocator Allocator
*/
void vkDestroyQueryPool(DeviceContext device, Pool queryPool, Pointer pAllocator);
/**
* Command to reset a query pool.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to reset
*/
void vkCmdResetQueryPool(Buffer commandBuffer, Pool queryPool, int firstQuery, int queryCount);
/**
* Starts a query.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param query Query slot
* @param flags Flags
*/
void vkCmdBeginQuery(Buffer commandBuffer, Pool queryPool, int query, BitMask<VkQueryControlFlag> flags);
/**
* Ends a query.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param query Query slot
*/
void vkCmdEndQuery(Buffer commandBuffer, Pool queryPool, int query);
/**
* Writes the device timestamp at the given pipeline stage to the query results.
* @param commandBuffer Command buffer
* @param pipelineStage Pipeline stage
* @param queryPool Query pool
* @param query Query slot
*/
void vkCmdWriteTimestamp(Buffer commandBuffer, VkPipelineStage pipelineStage, Pool queryPool, int query);
/**
* Retrieves query results.
* @param device Logical device
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to retrieve
* @param dataSize Size of the data buffer
* @param pData Data buffer
* @param stride Data stride (bytes)
* @param flags Query flags
* @return Result
*/
int vkGetQueryPoolResults(DeviceContext device, Pool queryPool, int firstQuery, int queryCount, long dataSize, ByteBuffer pData, long stride, BitMask<VkQueryResultFlag> flags);
/**
* Writes query results to a Vulkan buffer.
* @param commandBuffer Command buffer
* @param queryPool Query pool
* @param firstQuery Index of the first query slot
* @param queryCount Number of query slots to retrieve
* @param dstBuffer Results buffer
* @param dstOffset Offset
* @param stride Data stride (bytes)
* @param flags Query flags
*/
void vkCmdCopyQueryPoolResults(Buffer commandBuffer, Pool queryPool, int firstQuery, int queryCount, VulkanBuffer dstBuffer, long dstOffset, long stride, BitMask<VkQueryResultFlag> flags);
}
}
| 16,304 | 0.686028 | 0.685231 | 518 | 30.474903 | 32.279522 | 190 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.50193 | false | false | 15 |
cda9715c64e604559c8037745855012cfb769c44 | 6,339,371,774,915 | 3aedf39fce77aa36eee9d675bf1ed786e15f3b1c | /src/main/java/animal/animals/Lion.java | 766b4dba252900eeeaf6c4dc9855595a67a92e6b | []
| no_license | Pierre-AntoineCAYLA/maven | https://github.com/Pierre-AntoineCAYLA/maven | 2a2a2d7a10a4c27a7afcf390b416c6bf212cb4c9 | a3e039059e417c90948e9530bf84c6074b394b8c | refs/heads/master | 2020-03-10T07:42:23.727000 | 2018-04-12T15:06:22 | 2018-04-12T15:06:22 | 129,268,865 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package animal.animals;
import animal.regime.Carnivore;
import animals.Animal;
import animals.Deplacer;
public class Lion extends Animal {
private Deplacer deplacer;
//donne les statistique propre au lion
public Lion(int age, float poids, float taille) {
this.age = age;
this.poids = poids;
this.taille = taille;
this.nom = "lion";
this.regime = new Carnivore();
}
public void LionDeplacer() {
this.deplacer = Deplacer.COURIR;
}
} | UTF-8 | Java | 453 | java | Lion.java | Java | [
{
"context": "ds = poids;\n\t\tthis.taille = taille;\n\t\tthis.nom = \"lion\";\n\t\tthis.regime = new Carnivore();\n\t}\n\n\tpublic vo",
"end": 343,
"score": 0.8101946711540222,
"start": 339,
"tag": "NAME",
"value": "lion"
}
]
| null | []
| package animal.animals;
import animal.regime.Carnivore;
import animals.Animal;
import animals.Deplacer;
public class Lion extends Animal {
private Deplacer deplacer;
//donne les statistique propre au lion
public Lion(int age, float poids, float taille) {
this.age = age;
this.poids = poids;
this.taille = taille;
this.nom = "lion";
this.regime = new Carnivore();
}
public void LionDeplacer() {
this.deplacer = Deplacer.COURIR;
}
} | 453 | 0.721854 | 0.721854 | 23 | 18.73913 | 14.844754 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.347826 | false | false | 15 |
33d52e685b953184eee7120af2402437bbb22922 | 15,925,738,777,307 | 4a237d14625dbf03150e9f8d2f2c7b10160261c4 | /addOns/paramminer/src/main/java/org/zaproxy/addon/paramminer/ExtensionParamMiner.java | f642298eb3756e359ade109e89c792386bd4121b | [
"Apache-2.0"
]
| permissive | preetkaran20/zap-extensions | https://github.com/preetkaran20/zap-extensions | 8facb9fece4dd8be97206d172bea8fa275ab20f1 | 5c02cc25dc928d4b8fd74b735a297860eee7765c | refs/heads/master | 2022-07-11T17:26:07.574000 | 2022-06-08T17:33:35 | 2022-06-08T17:33:35 | 202,583,604 | 0 | 0 | Apache-2.0 | true | 2019-08-17T07:18:30 | 2019-08-15T17:25:58 | 2019-08-15T17:26:01 | 2019-08-17T07:18:30 | 893,929 | 0 | 0 | 0 | Java | false | false | /*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2022 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.zaproxy.addon.paramminer;
import javax.swing.ImageIcon;
import org.parosproxy.paros.Constant;
import org.parosproxy.paros.extension.ExtensionAdaptor;
import org.parosproxy.paros.extension.ExtensionHook;
import org.parosproxy.paros.extension.ExtensionPopupMenuItem;
import org.parosproxy.paros.model.SiteNode;
import org.zaproxy.addon.paramminer.gui.ParamMinerDialog;
import org.zaproxy.addon.paramminer.gui.ParamMinerPanel;
import org.zaproxy.addon.paramminer.gui.PopupMenuParamMiner;
import org.zaproxy.zap.model.Target;
import org.zaproxy.zap.utils.DisplayUtils;
import org.zaproxy.zap.view.ZapMenuItem;
public class ExtensionParamMiner extends ExtensionAdaptor {
public static final String NAME = "ExtensionParamMiner";
protected static final String PREFIX = "paramminer";
private static final String RESOURCES = "resources";
private static ImageIcon icon;
private ParamMinerPanel paramMinerPanel;
private ExtensionPopupMenuItem paramMinerDialogPopMenu;
private ZapMenuItem menu;
private ParamMinerAPI api;
private ParamMinerDialog paramMinerDialog;
public ExtensionParamMiner() {
super(NAME);
setI18nPrefix(PREFIX);
}
public static ImageIcon getIcon() {
if (icon == null) {
icon = new ImageIcon(ExtensionParamMiner.class.getResource(RESOURCES + "/pickaxe.png"));
}
return icon;
}
@Override
public void hook(ExtensionHook extensionHook) {
super.hook(extensionHook);
this.api = new ParamMinerAPI();
extensionHook.addApiImplementor(this.api);
if (getView() != null) {
extensionHook.getHookMenu().addToolsMenuItem(getMenu());
extensionHook.getHookView().addStatusPanel(getParamMinerPanel());
extensionHook.getHookMenu().addPopupMenuItem(getPopupMsg());
}
}
private ExtensionPopupMenuItem getPopupMsg() {
if (paramMinerDialogPopMenu == null) {
paramMinerDialogPopMenu =
new PopupMenuParamMiner(
this, Constant.messages.getString(PREFIX + ".popup.title"));
}
return paramMinerDialogPopMenu;
}
@Override
public boolean canUnload() {
return true;
}
@Override
public void unload() {
super.unload();
}
private ParamMinerPanel getParamMinerPanel() {
if (paramMinerPanel == null) {
paramMinerPanel = new ParamMinerPanel(this);
}
return paramMinerPanel;
}
private ZapMenuItem getMenu() {
if (menu == null) {
menu = new ZapMenuItem(PREFIX + ".topmenu.tools.title");
menu.addActionListener(
e -> {
showParamMinerDialog(null);
});
}
return menu;
}
public void showParamMinerDialog(SiteNode node) {
if (paramMinerDialog == null) {
paramMinerDialog =
new ParamMinerDialog(
this,
getView().getMainFrame(),
DisplayUtils.getScaledDimension(700, 500));
}
paramMinerDialog.init(new Target(node));
paramMinerDialog.setVisible(true);
}
@Override
public String getDescription() {
return Constant.messages.getString(PREFIX + ".desc");
}
}
| UTF-8 | Java | 4,148 | java | ExtensionParamMiner.java | Java | []
| null | []
| /*
* Zed Attack Proxy (ZAP) and its related class files.
*
* ZAP is an HTTP/HTTPS proxy for assessing web application security.
*
* Copyright 2022 The ZAP Development Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.zaproxy.addon.paramminer;
import javax.swing.ImageIcon;
import org.parosproxy.paros.Constant;
import org.parosproxy.paros.extension.ExtensionAdaptor;
import org.parosproxy.paros.extension.ExtensionHook;
import org.parosproxy.paros.extension.ExtensionPopupMenuItem;
import org.parosproxy.paros.model.SiteNode;
import org.zaproxy.addon.paramminer.gui.ParamMinerDialog;
import org.zaproxy.addon.paramminer.gui.ParamMinerPanel;
import org.zaproxy.addon.paramminer.gui.PopupMenuParamMiner;
import org.zaproxy.zap.model.Target;
import org.zaproxy.zap.utils.DisplayUtils;
import org.zaproxy.zap.view.ZapMenuItem;
public class ExtensionParamMiner extends ExtensionAdaptor {
public static final String NAME = "ExtensionParamMiner";
protected static final String PREFIX = "paramminer";
private static final String RESOURCES = "resources";
private static ImageIcon icon;
private ParamMinerPanel paramMinerPanel;
private ExtensionPopupMenuItem paramMinerDialogPopMenu;
private ZapMenuItem menu;
private ParamMinerAPI api;
private ParamMinerDialog paramMinerDialog;
public ExtensionParamMiner() {
super(NAME);
setI18nPrefix(PREFIX);
}
public static ImageIcon getIcon() {
if (icon == null) {
icon = new ImageIcon(ExtensionParamMiner.class.getResource(RESOURCES + "/pickaxe.png"));
}
return icon;
}
@Override
public void hook(ExtensionHook extensionHook) {
super.hook(extensionHook);
this.api = new ParamMinerAPI();
extensionHook.addApiImplementor(this.api);
if (getView() != null) {
extensionHook.getHookMenu().addToolsMenuItem(getMenu());
extensionHook.getHookView().addStatusPanel(getParamMinerPanel());
extensionHook.getHookMenu().addPopupMenuItem(getPopupMsg());
}
}
private ExtensionPopupMenuItem getPopupMsg() {
if (paramMinerDialogPopMenu == null) {
paramMinerDialogPopMenu =
new PopupMenuParamMiner(
this, Constant.messages.getString(PREFIX + ".popup.title"));
}
return paramMinerDialogPopMenu;
}
@Override
public boolean canUnload() {
return true;
}
@Override
public void unload() {
super.unload();
}
private ParamMinerPanel getParamMinerPanel() {
if (paramMinerPanel == null) {
paramMinerPanel = new ParamMinerPanel(this);
}
return paramMinerPanel;
}
private ZapMenuItem getMenu() {
if (menu == null) {
menu = new ZapMenuItem(PREFIX + ".topmenu.tools.title");
menu.addActionListener(
e -> {
showParamMinerDialog(null);
});
}
return menu;
}
public void showParamMinerDialog(SiteNode node) {
if (paramMinerDialog == null) {
paramMinerDialog =
new ParamMinerDialog(
this,
getView().getMainFrame(),
DisplayUtils.getScaledDimension(700, 500));
}
paramMinerDialog.init(new Target(node));
paramMinerDialog.setVisible(true);
}
@Override
public String getDescription() {
return Constant.messages.getString(PREFIX + ".desc");
}
}
| 4,148 | 0.658872 | 0.655014 | 128 | 31.40625 | 24.452261 | 100 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.429688 | false | false | 15 |
28054ba096a39b14eaf58810220318326eb2a03a | 19,129,784,384,317 | fc56f47b65d13dc2e2fa6f3233d85af868fad136 | /Program source code/chapterThree/src/com/dingli/wyl/QueryGoods.java | 90c703dcaeef3103a52e0672fa2e9a3bb84d1e21 | []
| no_license | StaticAnn/Warehouse-management-system | https://github.com/StaticAnn/Warehouse-management-system | 14dcb08d2a001d65e77e1e8870d0e585c03c4be9 | f82a17ed8a830b722d19e50f5b93d42c892d89cb | refs/heads/master | 2020-03-27T07:25:04.253000 | 2018-08-26T14:53:54 | 2018-08-26T14:53:54 | 146,189,579 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.dingli.wyl;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class QueryGoods {
private JFrame frame;
private JTable table;
private Object[][] jet;
/**
* Launch the application.
*/
public void run() {
try {
QueryGoods window = new QueryGoods();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public void getJetLength(){
Connection con=Test.getCon();
String sql="select count(*) from [Warehouse management].[dbo].[GDMESS]";
int count=0;
try {
PreparedStatement ps=con.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
while(rs.next())
{
count=rs.getInt(1);
}
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jet=new Object[count][];
}
public void getData(){
Connection con=Test.getCon();
String sql="select * from [Warehouse management].[dbo].[GDMESS]";
try {
PreparedStatement ps=con.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
int index=0;
while(rs.next())
{
String gID=rs.getString(1);
String gName=rs.getString(2);
String gClass=rs.getString(3);
String gStd=rs.getString(4);
float volume=rs.getFloat(5);
String vendor=rs.getString(6);
int quantity=rs.getInt(7);
Object[] p={gID,gName,gClass,gStd,volume,vendor,quantity};
jet[index]=p;
index++;
}
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Create the application.
*/
public QueryGoods() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
getJetLength();
getData();
frame = new JFrame();
frame.setBounds(100, 100, 800, 502);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(0, 0, 782, 455);
frame.getContentPane().add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
jet,
new String[] {
"\u8D27\u7269\u7F16\u53F7", "\u8D27\u7269\u540D\u79F0", "\u8D27\u7269\u79CD\u7C7B", "\u8D27\u7269\u578B\u53F7", "\u5C4F\u5E55\u5927\u5C0F", "\u4F9B\u5E94\u5546", "\u5E93\u5B58\u6570\u91CF"
}
));
table.getColumnModel().getColumn(0).setPreferredWidth(120);
table.getColumnModel().getColumn(1).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(120);
scrollPane.setViewportView(table);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("\u8FD4\u56DE\u4E3B\u754C\u9762");
mnNewMenu.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
MainWindow mw=new MainWindow();
mw.main(null);
}
});
menuBar.add(mnNewMenu);
}
}
| UTF-8 | Java | 3,382 | java | QueryGoods.java | Java | []
| null | []
| package com.dingli.wyl;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import java.awt.BorderLayout;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
public class QueryGoods {
private JFrame frame;
private JTable table;
private Object[][] jet;
/**
* Launch the application.
*/
public void run() {
try {
QueryGoods window = new QueryGoods();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
public void getJetLength(){
Connection con=Test.getCon();
String sql="select count(*) from [Warehouse management].[dbo].[GDMESS]";
int count=0;
try {
PreparedStatement ps=con.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
while(rs.next())
{
count=rs.getInt(1);
}
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
jet=new Object[count][];
}
public void getData(){
Connection con=Test.getCon();
String sql="select * from [Warehouse management].[dbo].[GDMESS]";
try {
PreparedStatement ps=con.prepareStatement(sql);
ResultSet rs=ps.executeQuery();
int index=0;
while(rs.next())
{
String gID=rs.getString(1);
String gName=rs.getString(2);
String gClass=rs.getString(3);
String gStd=rs.getString(4);
float volume=rs.getFloat(5);
String vendor=rs.getString(6);
int quantity=rs.getInt(7);
Object[] p={gID,gName,gClass,gStd,volume,vendor,quantity};
jet[index]=p;
index++;
}
con.close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* Create the application.
*/
public QueryGoods() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
getJetLength();
getData();
frame = new JFrame();
frame.setBounds(100, 100, 800, 502);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBounds(0, 0, 782, 455);
frame.getContentPane().add(scrollPane);
table = new JTable();
table.setModel(new DefaultTableModel(
jet,
new String[] {
"\u8D27\u7269\u7F16\u53F7", "\u8D27\u7269\u540D\u79F0", "\u8D27\u7269\u79CD\u7C7B", "\u8D27\u7269\u578B\u53F7", "\u5C4F\u5E55\u5927\u5C0F", "\u4F9B\u5E94\u5546", "\u5E93\u5B58\u6570\u91CF"
}
));
table.getColumnModel().getColumn(0).setPreferredWidth(120);
table.getColumnModel().getColumn(1).setPreferredWidth(120);
table.getColumnModel().getColumn(2).setPreferredWidth(120);
scrollPane.setViewportView(table);
JMenuBar menuBar = new JMenuBar();
frame.setJMenuBar(menuBar);
JMenu mnNewMenu = new JMenu("\u8FD4\u56DE\u4E3B\u754C\u9762");
mnNewMenu.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
MainWindow mw=new MainWindow();
mw.main(null);
}
});
menuBar.add(mnNewMenu);
}
}
| 3,382 | 0.665287 | 0.624778 | 136 | 23.867647 | 22.657881 | 192 | false | false | 0 | 0 | 30 | 0.051449 | 0 | 0 | 3.323529 | false | false | 15 |
9b4975f089151c5e1f5c6a4128e58877a7b13f56 | 10,290,741,681,364 | 1d0ef932b52e918be5991d3319653a7d371f8381 | /lab/src/main/agh/cs/lab/Vector2d.java | 8ab1954e92045254fea927df18c6efd86f45618d | []
| no_license | szymonSumara/lifeSimulation | https://github.com/szymonSumara/lifeSimulation | fec29d2b0cdb6721fd981de57dd24534b6fb3d8d | e8ef13ab64a070e3b1028532d19dbdbca0945042 | refs/heads/main | 2023-03-29T21:44:02.454000 | 2021-03-29T19:47:57 | 2021-03-29T19:47:57 | 352,756,418 | 0 | 0 | null | false | 2021-03-29T19:47:57 | 2021-03-29T19:09:05 | 2021-03-29T19:09:16 | 2021-03-29T19:47:57 | 0 | 0 | 0 | 0 | null | false | false | package agh.cs.lab;
import java.util.Objects;
public class Vector2d {
public final int x;
public final int y;
public Vector2d(int x,int y){
this.x = x;
this.y = y;
}
public String toString(){
return "( " + x + " , " + y +" )";
}
public boolean precedes( Vector2d other ){
if(this.x <= other.x && this.y <= other.y)
return true;
return false;
}
public boolean follows( Vector2d other ){
if(this.x >= other.x && this.y >= other.y)
return true;
return false;
}
@Override
public int hashCode() {
return Objects.hash(this.x, this.y);
}
public Vector2d upperRight( Vector2d other){
int tmpX = 0;
int tmpY = 0;
if(this.x > other.x)
tmpX = this.x;
else
tmpX = other.x;
if(this.y > other.y)
tmpY = this.y;
else
tmpY = other.y;
return new Vector2d(tmpX,tmpY);
}
public Vector2d lowerLeft( Vector2d other){
int tmpX = 0;
int tmpY = 0;
if(this.x < other.x)
tmpX = this.x;
else
tmpX = other.x;
if(this.y < other.y)
tmpY = this.y;
else
tmpY = other.y;
return new Vector2d(tmpX,tmpY);
}
public Vector2d add(Vector2d other){
return new Vector2d(this.x + other.x,this.y+other.y);
}
public Vector2d subtract(Vector2d other){
return new Vector2d(this.x - other.x,this.y-other.y);
}
public boolean equals(Object other){
if (this == other)
return true;
if (!(other instanceof Vector2d))
return false;
Vector2d that = (Vector2d) other;
if (this.x == that.x && this.y == that.y)
return true;
else
return false;
}
public Vector2d opposite(){
return new Vector2d(-1*this.x,-1*this.y);
}
public Vector2d convertToBounds(Vector2d southWestCorner,Vector2d northEastCorner){
int newXValue = this.x;
int newYValue = this.y;
if(newXValue > southWestCorner.x ){
newXValue = (northEastCorner.x);
}
if(newXValue < northEastCorner.x){
newXValue = (southWestCorner.x);
}
if(newYValue > southWestCorner.y){
newYValue = (northEastCorner.y);
}
if(newYValue < northEastCorner.y){
newYValue = (southWestCorner.y);
}
return new Vector2d(newXValue,newYValue);
}
}
| UTF-8 | Java | 2,715 | java | Vector2d.java | Java | []
| null | []
| package agh.cs.lab;
import java.util.Objects;
public class Vector2d {
public final int x;
public final int y;
public Vector2d(int x,int y){
this.x = x;
this.y = y;
}
public String toString(){
return "( " + x + " , " + y +" )";
}
public boolean precedes( Vector2d other ){
if(this.x <= other.x && this.y <= other.y)
return true;
return false;
}
public boolean follows( Vector2d other ){
if(this.x >= other.x && this.y >= other.y)
return true;
return false;
}
@Override
public int hashCode() {
return Objects.hash(this.x, this.y);
}
public Vector2d upperRight( Vector2d other){
int tmpX = 0;
int tmpY = 0;
if(this.x > other.x)
tmpX = this.x;
else
tmpX = other.x;
if(this.y > other.y)
tmpY = this.y;
else
tmpY = other.y;
return new Vector2d(tmpX,tmpY);
}
public Vector2d lowerLeft( Vector2d other){
int tmpX = 0;
int tmpY = 0;
if(this.x < other.x)
tmpX = this.x;
else
tmpX = other.x;
if(this.y < other.y)
tmpY = this.y;
else
tmpY = other.y;
return new Vector2d(tmpX,tmpY);
}
public Vector2d add(Vector2d other){
return new Vector2d(this.x + other.x,this.y+other.y);
}
public Vector2d subtract(Vector2d other){
return new Vector2d(this.x - other.x,this.y-other.y);
}
public boolean equals(Object other){
if (this == other)
return true;
if (!(other instanceof Vector2d))
return false;
Vector2d that = (Vector2d) other;
if (this.x == that.x && this.y == that.y)
return true;
else
return false;
}
public Vector2d opposite(){
return new Vector2d(-1*this.x,-1*this.y);
}
public Vector2d convertToBounds(Vector2d southWestCorner,Vector2d northEastCorner){
int newXValue = this.x;
int newYValue = this.y;
if(newXValue > southWestCorner.x ){
newXValue = (northEastCorner.x);
}
if(newXValue < northEastCorner.x){
newXValue = (southWestCorner.x);
}
if(newYValue > southWestCorner.y){
newYValue = (northEastCorner.y);
}
if(newYValue < northEastCorner.y){
newYValue = (southWestCorner.y);
}
return new Vector2d(newXValue,newYValue);
}
}
| 2,715 | 0.500921 | 0.489503 | 116 | 21.405172 | 18.316177 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.439655 | false | false | 15 |
a60b5ed39a5ebceaf5e8016a39a399c4d36e7fd8 | 10,574,209,537,917 | 3b96fb6909c7f725a686b953f381c2716c290ed0 | /app/src/main/java/tvcompany/salemanager/activity/ShopActivity.java | 2023a3db5b974b96ad6ebcd91b91a97dbce4409e | []
| no_license | CMingTseng/SaleManager | https://github.com/CMingTseng/SaleManager | 70976e91d02ea692919e76e1bf5fdd27ce233b9c | 76dfa7c52fb8b810b1f6b59eaab0a6168d5dd8de | refs/heads/master | 2020-03-25T02:59:06.342000 | 2016-09-04T15:06:14 | 2016-09-04T15:06:14 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tvcompany.salemanager.activity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import tvcompany.salemanager.R;
import tvcompany.salemanager.controller.login.ShopController;
import tvcompany.salemanager.controller.login.UploadFileController;
import tvcompany.salemanager.controller.login.UserController;
import tvcompany.salemanager.library.GlobalValue;
import tvcompany.salemanager.library.MD5;
import tvcompany.salemanager.library.ValidString;
import tvcompany.salemanager.model.Shop;
public class ShopActivity extends AppCompatActivity {
public static final int PICK_IMAGE = 100;
private ImageView imageView;
private Button btn_Save;
private Shop shop = null;
private Bitmap bm = null;
private EditText shopID, shopName, shopAddress, shopNote;
private ValidString valid;
ShopController shopController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newshop_layout);
imageView = (ImageView) findViewById(R.id.iconNewShop);
shopID = (EditText) findViewById(R.id.shopId);
shopName = (EditText) findViewById(R.id.shopName);
shopAddress = (EditText) findViewById(R.id.shopAddress);
shopNote = (EditText) findViewById(R.id.shopNote);
btn_Save = (Button) findViewById(R.id.btnSaveShop);
valid = new ValidString();
shopController = new ShopController();
Intent intent = getIntent();
shop = (Shop)intent.getExtras().get("Shop");
if(shop == null)
{
shop = new Shop();
}
else
{
try {
shopID.setText(shop.getId());
shopName.setText(shop.getShopName());
shopAddress.setText(shop.getAddress());
shopNote.setText(shop.getNote());
shopID.setText(shop.getId());
shopID.setText(shop.getId());
if(!shop.getImage().equals(""))
{
try {
Picasso.with(this).load(GlobalValue.CONFIG + shop.getImage().replace("::","/")).into(imageView);
}
catch (Exception e){
String s = "e";
}
}
}
catch (Exception e)
{
}
}
btn_Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!valid.CheckValidLengthRegex(shopID.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Mã cửa hàng phải chứa ít nhất 6 ký tự và không có dấu", Toast.LENGTH_LONG).show();
}
else
if(!valid.CheckSpecialCharacter(shopID.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Mã cửa hàng không được chưa ký tự đặc biệt", Toast.LENGTH_LONG).show();
}
if(!valid.CheckValidLength(shopName.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Tên cửa hàng phải chứa ít nhất 6 ký tự", Toast.LENGTH_LONG).show();
}
else
{
shop.setId(valid.ReplaceToValidString(shopID.getText().toString().trim()));
shop.setShopName(shopName.getText().toString().trim());
shop.setAddress(shopAddress.getText().toString().trim());
shop.setNote(shopNote.getText().toString().trim());
shop.setValid(true);
shop.setManager(new String[]{GlobalValue.ID});
shop.setLongitude(200);
shop.setLatitude(200);
//shop.setManager(new UserController().GetUserID(GlobalValue.USERNAME));
if(shop.get_id() != null )
{
if (shopController.updateShop(shop)) {
Toast.makeText(ShopActivity.this, "Cập nhật cửa hàng thành công!", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(ShopActivity.this, "Cửa hàng đã tồn tại. Vui lòng nhập lại mã cửa hàng!", Toast.LENGTH_LONG).show();
}
}
else
{
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String datestr = dateFormat.format(date);
shop.setCreateDate(datestr);
try {
if(bm == null)
{
shop.setImage("");
}
else
{
MD5 md5 = new MD5();
String image = GlobalValue.USERNAME + "::" + md5.getMD5(shop.getId() + datestr) + ".jpg";
shop.setImage(image);
}
} catch (Exception ex) {
}
if (shopController.AddShop(shop)) {
if (bm != null) {
new UploadFileController().uploadFile(bm,shop.getImage());
}
Toast.makeText(ShopActivity.this, "Đăng ký cửa hàng thành công!", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(ShopActivity.this, "Cửa hàng đã tồn tại. Vui lòng nhập lại mã cửa hàng!", Toast.LENGTH_LONG).show();
}
}
}
}
});
if (imageView != null) {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE);
}
});
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE && resultCode == Activity.RESULT_OK) {
android.net.Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
android.database.Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if (cursor == null)
return;
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
File file = new File(filePath);
BitmapFactory.Options bfOptions = new BitmapFactory.Options();
bfOptions.inDither = false;
bfOptions.inPurgeable = true;
bfOptions.inInputShareable = true;
bfOptions.inTempStorage = new byte[32 * 1024];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FileInputStream fs = null;
try {
fs = new FileInputStream(file);
} catch (FileNotFoundException e) {
//TODO do something intelligent
e.printStackTrace();
}
try {
bm = BitmapFactory.decodeFileDescriptor(fs.getFD(), null, bfOptions);
imageView.setImageBitmap(bm);
} catch (Exception ex) {
}
}
}
}
| UTF-8 | Java | 8,802 | java | ShopActivity.java | Java | []
| null | []
| package tvcompany.salemanager.activity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.Toast;
import com.squareup.picasso.Picasso;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import tvcompany.salemanager.R;
import tvcompany.salemanager.controller.login.ShopController;
import tvcompany.salemanager.controller.login.UploadFileController;
import tvcompany.salemanager.controller.login.UserController;
import tvcompany.salemanager.library.GlobalValue;
import tvcompany.salemanager.library.MD5;
import tvcompany.salemanager.library.ValidString;
import tvcompany.salemanager.model.Shop;
public class ShopActivity extends AppCompatActivity {
public static final int PICK_IMAGE = 100;
private ImageView imageView;
private Button btn_Save;
private Shop shop = null;
private Bitmap bm = null;
private EditText shopID, shopName, shopAddress, shopNote;
private ValidString valid;
ShopController shopController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.newshop_layout);
imageView = (ImageView) findViewById(R.id.iconNewShop);
shopID = (EditText) findViewById(R.id.shopId);
shopName = (EditText) findViewById(R.id.shopName);
shopAddress = (EditText) findViewById(R.id.shopAddress);
shopNote = (EditText) findViewById(R.id.shopNote);
btn_Save = (Button) findViewById(R.id.btnSaveShop);
valid = new ValidString();
shopController = new ShopController();
Intent intent = getIntent();
shop = (Shop)intent.getExtras().get("Shop");
if(shop == null)
{
shop = new Shop();
}
else
{
try {
shopID.setText(shop.getId());
shopName.setText(shop.getShopName());
shopAddress.setText(shop.getAddress());
shopNote.setText(shop.getNote());
shopID.setText(shop.getId());
shopID.setText(shop.getId());
if(!shop.getImage().equals(""))
{
try {
Picasso.with(this).load(GlobalValue.CONFIG + shop.getImage().replace("::","/")).into(imageView);
}
catch (Exception e){
String s = "e";
}
}
}
catch (Exception e)
{
}
}
btn_Save.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(!valid.CheckValidLengthRegex(shopID.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Mã cửa hàng phải chứa ít nhất 6 ký tự và không có dấu", Toast.LENGTH_LONG).show();
}
else
if(!valid.CheckSpecialCharacter(shopID.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Mã cửa hàng không được chưa ký tự đặc biệt", Toast.LENGTH_LONG).show();
}
if(!valid.CheckValidLength(shopName.getText().toString()))
{
Toast.makeText(ShopActivity.this, "Tên cửa hàng phải chứa ít nhất 6 ký tự", Toast.LENGTH_LONG).show();
}
else
{
shop.setId(valid.ReplaceToValidString(shopID.getText().toString().trim()));
shop.setShopName(shopName.getText().toString().trim());
shop.setAddress(shopAddress.getText().toString().trim());
shop.setNote(shopNote.getText().toString().trim());
shop.setValid(true);
shop.setManager(new String[]{GlobalValue.ID});
shop.setLongitude(200);
shop.setLatitude(200);
//shop.setManager(new UserController().GetUserID(GlobalValue.USERNAME));
if(shop.get_id() != null )
{
if (shopController.updateShop(shop)) {
Toast.makeText(ShopActivity.this, "Cập nhật cửa hàng thành công!", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(ShopActivity.this, "Cửa hàng đã tồn tại. Vui lòng nhập lại mã cửa hàng!", Toast.LENGTH_LONG).show();
}
}
else
{
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String datestr = dateFormat.format(date);
shop.setCreateDate(datestr);
try {
if(bm == null)
{
shop.setImage("");
}
else
{
MD5 md5 = new MD5();
String image = GlobalValue.USERNAME + "::" + md5.getMD5(shop.getId() + datestr) + ".jpg";
shop.setImage(image);
}
} catch (Exception ex) {
}
if (shopController.AddShop(shop)) {
if (bm != null) {
new UploadFileController().uploadFile(bm,shop.getImage());
}
Toast.makeText(ShopActivity.this, "Đăng ký cửa hàng thành công!", Toast.LENGTH_LONG).show();
}
else
{
Toast.makeText(ShopActivity.this, "Cửa hàng đã tồn tại. Vui lòng nhập lại mã cửa hàng!", Toast.LENGTH_LONG).show();
}
}
}
}
});
if (imageView != null) {
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(Intent.createChooser(intent, "Select Image"), PICK_IMAGE);
}
});
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PICK_IMAGE && resultCode == Activity.RESULT_OK) {
android.net.Uri selectedImage = data.getData();
String[] filePathColumn = {MediaStore.Images.Media.DATA};
android.database.Cursor cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null);
if (cursor == null)
return;
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
String filePath = cursor.getString(columnIndex);
cursor.close();
File file = new File(filePath);
BitmapFactory.Options bfOptions = new BitmapFactory.Options();
bfOptions.inDither = false;
bfOptions.inPurgeable = true;
bfOptions.inInputShareable = true;
bfOptions.inTempStorage = new byte[32 * 1024];
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FileInputStream fs = null;
try {
fs = new FileInputStream(file);
} catch (FileNotFoundException e) {
//TODO do something intelligent
e.printStackTrace();
}
try {
bm = BitmapFactory.decodeFileDescriptor(fs.getFD(), null, bfOptions);
imageView.setImageBitmap(bm);
} catch (Exception ex) {
}
}
}
}
| 8,802 | 0.533341 | 0.530467 | 212 | 40.028301 | 29.395788 | 143 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.665094 | false | false | 15 |
017e250c75523f4cdae61c72791f01fce0703621 | 23,012,434,814,298 | f95f1a9ebb8358bb05fcd5393294579105801fdb | /src/main/java/cn/mk/ndms/util/RoleVo.java | cf19395ebe249000740e8c35fa089e9ec5e46974 | []
| no_license | gsaneryeeb/fl-web | https://github.com/gsaneryeeb/fl-web | 15829c2f1692a754c547147801a888e12cfdc2c3 | 0a3fa88d60d2bd43b8d37335e62245249fb14f42 | refs/heads/master | 2021-01-21T13:57:53.483000 | 2016-05-09T22:03:21 | 2016-05-09T22:03:21 | 48,095,632 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.mk.ndms.util;
public class RoleVo {
private String id;
private Short availability;
private String cname;
private String ename;
public RoleVo(String id,Short availability,String cname,String ename){
this.id=id;
this.availability=availability;
this.cname=cname;
this.ename=ename;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Short getAvailability() {
return availability;
}
public void setAvailability(Short availability) {
this.availability = availability;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
}
| UTF-8 | Java | 774 | java | RoleVo.java | Java | []
| null | []
| package cn.mk.ndms.util;
public class RoleVo {
private String id;
private Short availability;
private String cname;
private String ename;
public RoleVo(String id,Short availability,String cname,String ename){
this.id=id;
this.availability=availability;
this.cname=cname;
this.ename=ename;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Short getAvailability() {
return availability;
}
public void setAvailability(Short availability) {
this.availability = availability;
}
public String getCname() {
return cname;
}
public void setCname(String cname) {
this.cname = cname;
}
public String getEname() {
return ename;
}
public void setEname(String ename) {
this.ename = ename;
}
}
| 774 | 0.713178 | 0.713178 | 40 | 18.35 | 15.372947 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.7 | false | false | 15 |
d03f663044c9ad09dc936cbfaeb22c1e10da67a3 | 2,559,800,564,095 | 1b5ab622e1c3340a3bf537ba3f5c9d8eee740e29 | /2.JavaCore/src/com/javarush/task/task19/task1925/Solution.java | b29bf82abd0b3e977c001247ff30c2c7b081de45 | []
| no_license | NikonoffSE/JavaRushTasks | https://github.com/NikonoffSE/JavaRushTasks | 1ac1a626708041f36a380e92390f98175f4fd715 | 85c87998d6c8fe94bc888ebb0afe0c08bd41f241 | refs/heads/master | 2020-04-17T11:25:03.116000 | 2019-05-15T08:19:04 | 2019-05-15T08:19:04 | 166,539,702 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.javarush.task.task19.task1925;
/*
Длинные слова
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws Exception {
// BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));
// String fname = bu.readLine();
// bu.close();
BufferedReader buf = new BufferedReader(new FileReader(args[0])); // c:/temp/3.txt
BufferedWriter bur = new BufferedWriter(new FileWriter(args[1]));
String temp = "";
int c = 0;
String[] b;
ArrayList<String> fin = new ArrayList<>();
while (buf.ready()) {
temp = buf.readLine();
b = temp.split(" ");
for (String s : b) {
if (s.length() > 6)
fin.add(s);
}
}
buf.close();
for (int i = 0; i < fin.size() - 1; i++) {
bur.write(fin.get(i) + ",");
}
bur.write(fin.get(fin.size() - 1));
bur.close();
}
}
| UTF-8 | Java | 1,067 | java | Solution.java | Java | []
| null | []
| package com.javarush.task.task19.task1925;
/*
Длинные слова
*/
import java.io.*;
import java.util.ArrayList;
public class Solution {
public static void main(String[] args) throws Exception {
// BufferedReader bu = new BufferedReader(new InputStreamReader(System.in));
// String fname = bu.readLine();
// bu.close();
BufferedReader buf = new BufferedReader(new FileReader(args[0])); // c:/temp/3.txt
BufferedWriter bur = new BufferedWriter(new FileWriter(args[1]));
String temp = "";
int c = 0;
String[] b;
ArrayList<String> fin = new ArrayList<>();
while (buf.ready()) {
temp = buf.readLine();
b = temp.split(" ");
for (String s : b) {
if (s.length() > 6)
fin.add(s);
}
}
buf.close();
for (int i = 0; i < fin.size() - 1; i++) {
bur.write(fin.get(i) + ",");
}
bur.write(fin.get(fin.size() - 1));
bur.close();
}
}
| 1,067 | 0.509953 | 0.496682 | 36 | 28.305555 | 22.843452 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.611111 | false | false | 15 |
6b7d93dc4ebe0244aa77c01662ad4a8ee53f9d0f | 32,504,312,545,529 | 6b3eb51ea3cefa2fd4b9049ff9f69568e93038ba | /src/main/java/com/example/demo/advice/LogMethodExecution.java | ef4347602bdc2c22edcac646089e31d6310f7df4 | []
| no_license | praveeryudi/hr-system | https://github.com/praveeryudi/hr-system | cef367d4a3187f726521f69d51d7ffb4f7d71fa9 | a41d60a7802f9a9aba7167e1d11b1e0e8f47a109 | refs/heads/master | 2021-03-28T18:18:02.787000 | 2021-01-17T15:50:09 | 2021-01-17T15:50:09 | 247,883,892 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.advice;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
@Slf4j
public class LogMethodExecution {
@Around("@annotation(com.example.demo.annotation.LogExecutionTime)")
public Object logMethodExecutionTime(ProceedingJoinPoint pjp) throws Throwable {
long startTime = System.currentTimeMillis();
Object retVal = pjp.proceed();
long endTime = System.currentTimeMillis();
log.info("Time to execute method " + pjp.getSignature() + " :: " + (endTime - startTime));
return retVal;
}
}
| UTF-8 | Java | 741 | java | LogMethodExecution.java | Java | []
| null | []
| package com.example.demo.advice;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
@Aspect
@Component
@Slf4j
public class LogMethodExecution {
@Around("@annotation(com.example.demo.annotation.LogExecutionTime)")
public Object logMethodExecutionTime(ProceedingJoinPoint pjp) throws Throwable {
long startTime = System.currentTimeMillis();
Object retVal = pjp.proceed();
long endTime = System.currentTimeMillis();
log.info("Time to execute method " + pjp.getSignature() + " :: " + (endTime - startTime));
return retVal;
}
}
| 741 | 0.736842 | 0.732794 | 22 | 32.68182 | 27.517574 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
6e4c19342c02b94259606fee7f829aeb189e58f8 | 15,461,882,319,770 | 8bd164b3e85dc859e44ba10f74e29a46e6715fe9 | /app/src/main/java/com/example/vpitard/ppe3_mobile/systeme/visiteAdapter.java | 7c7ae78ab26c357bd2e4dc98d04b103c75b3a601 | []
| no_license | vpitard/PPE3_Mobile | https://github.com/vpitard/PPE3_Mobile | 68ddf5288ae72f12278c86d1599c9bad8e916682 | fa34fe44c18ddc5381c611aa067bbd94c3c206c9 | refs/heads/master | 2020-07-22T15:03:04.151000 | 2017-05-17T11:21:54 | 2017-05-17T11:21:54 | 73,810,915 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.vpitard.ppe3_mobile.systeme;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.vpitard.ppe3_mobile.R;
import java.util.List;
/**
* Created by MAEL on 13/12/2016.
*/
public class visiteAdapter extends BaseAdapter {
private List<Visite> listVisite;
private LayoutInflater inflater;
public visiteAdapter(Context context, List<Visite> listV){
this.inflater=LayoutInflater.from(context);
this.listVisite = listV;
}
@Override
public int getCount(){return this.listVisite.size();}
public Visite getItem(int position) { return this.listVisite.get(position);}
public long getItemId (int position) {return position;}
public View getView(int position, View convertView, ViewGroup parent){
TextView nom_visite;
if (convertView==null){
convertView = this.inflater.inflate(R.layout.visite_vue,parent,false);
nom_visite = (TextView) convertView.findViewById(R.id.nom_visite);
convertView.setTag(R.id.nom_visite,nom_visite);
}
else{
nom_visite = (TextView) convertView.getTag(R.id.nom_visite);
}
Visite visite= this.getItem(position);
nom_visite.setText(visite.getDateVisite());
return convertView;
}
}
| UTF-8 | Java | 1,418 | java | visiteAdapter.java | Java | [
{
"context": "bile.R;\n\nimport java.util.List;\n\n/**\n * Created by MAEL on 13/12/2016.\n */\n\npublic class visiteAdapter ex",
"end": 332,
"score": 0.9981607794761658,
"start": 328,
"tag": "USERNAME",
"value": "MAEL"
}
]
| null | []
| package com.example.vpitard.ppe3_mobile.systeme;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.vpitard.ppe3_mobile.R;
import java.util.List;
/**
* Created by MAEL on 13/12/2016.
*/
public class visiteAdapter extends BaseAdapter {
private List<Visite> listVisite;
private LayoutInflater inflater;
public visiteAdapter(Context context, List<Visite> listV){
this.inflater=LayoutInflater.from(context);
this.listVisite = listV;
}
@Override
public int getCount(){return this.listVisite.size();}
public Visite getItem(int position) { return this.listVisite.get(position);}
public long getItemId (int position) {return position;}
public View getView(int position, View convertView, ViewGroup parent){
TextView nom_visite;
if (convertView==null){
convertView = this.inflater.inflate(R.layout.visite_vue,parent,false);
nom_visite = (TextView) convertView.findViewById(R.id.nom_visite);
convertView.setTag(R.id.nom_visite,nom_visite);
}
else{
nom_visite = (TextView) convertView.getTag(R.id.nom_visite);
}
Visite visite= this.getItem(position);
nom_visite.setText(visite.getDateVisite());
return convertView;
}
}
| 1,418 | 0.70945 | 0.702398 | 50 | 27.360001 | 25.412407 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 15 |
995adb59d107631c4b967d7ce723ab337e15949b | 16,793,322,181,944 | d7130fdaf51db9b45347aeb77188c1ee26d8e56e | /mydoem/app/src/main/java/com/samsung/dialer/d/o.java | 7ff4d13fadf80322f8ad17619475adc3ba21fec5 | []
| no_license | FusionPlmH/Fusion-Project | https://github.com/FusionPlmH/Fusion-Project | 317af268c8bcb2cc6e7c30cf39a9cc3bc62cb84e | 19ac1c5158bc48f3013dce82fe5460d988206103 | refs/heads/master | 2022-04-07T00:36:40.424000 | 2020-03-16T16:06:28 | 2020-03-16T16:06:28 | 247,745,495 | 2 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.samsung.dialer.d;
import android.content.Context;
import android.widget.TextView;
import static com.leo.utils.Constants.getLeoResource;
import static com.os.leo.utils.FontsUtils.setLeoRomFonts;
import static com.os.leo.utils.LeoUserSettings.LeoSettings;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrCallCityFont;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrCityColorEnabled;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityColor;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityData;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityFont;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityLocate;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCitySize;
import static com.os.leo.utils.LeoUtils.getLeoCityData;
public class o {
protected final Context a;
public o(Context a) {
this.a = a;
}
public static boolean mDialingLocation;
public static String setLeoDialingLocation(Context context,String str){
LeoSettings(context);
int style=setLeoUesrDialingCityData;
if(style==0) {
str =com.samsung.dialer.d.c.a(context, str);
} else if (style == 1) {
str=getLeoCityData(context, str);
}
return str;
}
public void setLeoDialingLocation(TextView textView){
LeoSettings(a);
textView.setTextSize(setLeoUesrDialingCitySize);
textView.setTypeface(setLeoRomFonts(0,setLeoUesrDialingCityFont));
int color=setLeoUesrCityColorEnabled;
int dcolor=setLeoUesrDialingCityColor;
if(color==0){
dcolor= a.getColor( a.getResources().getIdentifier("calllog_time_text_color", "color", a.getPackageName()));
}
textView.setTextColor(dcolor);
}
}
| UTF-8 | Java | 2,037 | java | o.java | Java | []
| null | []
| package com.samsung.dialer.d;
import android.content.Context;
import android.widget.TextView;
import static com.leo.utils.Constants.getLeoResource;
import static com.os.leo.utils.FontsUtils.setLeoRomFonts;
import static com.os.leo.utils.LeoUserSettings.LeoSettings;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrCallCityFont;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrCityColorEnabled;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityColor;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityData;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityFont;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCityLocate;
import static com.os.leo.utils.LeoUserSettings.setLeoUesrDialingCitySize;
import static com.os.leo.utils.LeoUtils.getLeoCityData;
public class o {
protected final Context a;
public o(Context a) {
this.a = a;
}
public static boolean mDialingLocation;
public static String setLeoDialingLocation(Context context,String str){
LeoSettings(context);
int style=setLeoUesrDialingCityData;
if(style==0) {
str =com.samsung.dialer.d.c.a(context, str);
} else if (style == 1) {
str=getLeoCityData(context, str);
}
return str;
}
public void setLeoDialingLocation(TextView textView){
LeoSettings(a);
textView.setTextSize(setLeoUesrDialingCitySize);
textView.setTypeface(setLeoRomFonts(0,setLeoUesrDialingCityFont));
int color=setLeoUesrCityColorEnabled;
int dcolor=setLeoUesrDialingCityColor;
if(color==0){
dcolor= a.getColor( a.getResources().getIdentifier("calllog_time_text_color", "color", a.getPackageName()));
}
textView.setTextColor(dcolor);
}
}
| 2,037 | 0.669612 | 0.667648 | 52 | 38.115383 | 29.600971 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.673077 | false | false | 15 |
979cf33ad4ff2cab395843dc940938743573e700 | 32,366,873,601,472 | 40a7c30174823133d97109ab20a9d149c18ad633 | /jd-demo/src/main/java/org/nh/jd/demo/algo/daily10/MaxChunksToSorted.java | 50272303509bc6e8945648576d4761b5c67128a9 | []
| no_license | yindanqing925/demo-parent | https://github.com/yindanqing925/demo-parent | f75291203608bd408ebc4bca1012101c60a9b50c | 70f2848a55ce6352a6ee2bc5477a63b26ff731eb | refs/heads/master | 2023-06-25T13:01:46.098000 | 2023-06-14T02:15:13 | 2023-06-14T02:15:13 | 199,374,234 | 14 | 0 | null | false | 2022-12-10T05:39:11 | 2019-07-29T03:50:00 | 2022-11-01T01:53:42 | 2022-12-10T05:39:10 | 27,876 | 4 | 0 | 1 | Java | false | false | package org.nh.jd.demo.algo.daily10;
/**
* 769. 最多能完成排序的块
*
* @author yindanqing1
* @version 1.0
* @date 2022/10/13 9:03
*/
public class MaxChunksToSorted {
//贪心,加推理,取前缀数组
public int maxChunksToSorted(int[] arr) {
int res = 0, max = 0;
for (int i = 0; i < arr.length; i++) {
max = Math.max(max, arr[i]);
if (max == i) res++;
}
return res;
}
}
| UTF-8 | Java | 461 | java | MaxChunksToSorted.java | Java | [
{
"context": "algo.daily10;\n\n/**\n * 769. 最多能完成排序的块\n *\n * @author yindanqing1\n * @version 1.0\n * @date 2022/10/13 9:03\n */\npubl",
"end": 85,
"score": 0.9995540976524353,
"start": 74,
"tag": "USERNAME",
"value": "yindanqing1"
}
]
| null | []
| package org.nh.jd.demo.algo.daily10;
/**
* 769. 最多能完成排序的块
*
* @author yindanqing1
* @version 1.0
* @date 2022/10/13 9:03
*/
public class MaxChunksToSorted {
//贪心,加推理,取前缀数组
public int maxChunksToSorted(int[] arr) {
int res = 0, max = 0;
for (int i = 0; i < arr.length; i++) {
max = Math.max(max, arr[i]);
if (max == i) res++;
}
return res;
}
}
| 461 | 0.5179 | 0.465394 | 21 | 18.952381 | 15.072763 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.428571 | false | false | 15 |
0551bde3c2a32fac4f46da9e70c84ff89a48d5d4 | 32,366,873,598,853 | 7d71d2fa9297778c3422f4a4a0958edc6f7e781a | /app/src/main/java/com/csjbot/mobileshop/guide_patrol/patrol/patrol_setting/PatrolSettingContract.java | 1bba2aea3fd574e900048ac9297e4613c59fa392 | []
| no_license | MiRobotic/csj-new-demo | https://github.com/MiRobotic/csj-new-demo | 094ccb7415eb6f92febee1903062df770a0dfe83 | a022b29ddbf2240ad6cbe43738fe09b64e91e2c1 | refs/heads/master | 2020-08-08T17:42:55.450000 | 2019-10-09T09:46:33 | 2019-10-09T09:46:33 | 213,880,253 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.csjbot.mobileshop.guide_patrol.patrol.patrol_setting;
import android.widget.Button;
import android.widget.EditText;
import com.csjbot.mobileshop.base.BasePresenter;
import com.csjbot.mobileshop.base.BaseView;
import com.csjbot.mobileshop.global.Constants;
import com.csjbot.mobileshop.guide_patrol.patrol.bean.PatrolBean;
import com.csjbot.mobileshop.model.tcp.bean.Position;
import java.util.List;
/**
* Created by 孙秀艳 on 2019/1/18.
*/
public class PatrolSettingContract {
interface Presenter extends BasePresenter<View> {
void getPosition();//获取当前位置
void getPatrolData();//获取巡视点数据
void addPatrolPoint();//新增巡视点
int getIndexByData(PatrolBean patrolBean);//获取巡视点的索引
void savePatrolPointByPosition(PatrolBean patrolBean, int position);//保存巡视点
void showEdittextDialog(String title, String content, EditText editText, int length);//添加和修改编辑框对话框
void showRecyclerViewDialog(String title, Button editText, Constants.ResourceSuffix.suffix suffix);//选择文件对话框
void removePatrolPointByPosition(int position);//移除巡视点
boolean getPatrolPlan();//获取巡视计划
void savePatrolPlan(boolean isCircle);//获取巡视计划 true 循环巡视 false 单次巡视
void getGuideData();//获取巡视路线的数据
void saveGuideData(List<PatrolBean> patrolBeans);//保存巡视路线数据
void removeGuideData();
boolean isGuideData(int position);//该巡视点是否在巡视路线中
String getMapPatrolName(String name);
void removeNoValidData();//移除不符合规则的数据
}
interface View extends BaseView {
void showPatrolPointMap(List<PatrolBean> patrolBeans);//在地图上显示巡视点
void addPatrolPoint(PatrolBean patrolBean);//地图上新增巡视点
void setPatrolPosition(Position position);
void saveSuccess();//巡视点保存成功
void removePatrolItem(int position);//移除巡视点
void addNotPatrolPoint();
void showGuideData(List<PatrolBean> patrolBeans);
}
}
| UTF-8 | Java | 2,216 | java | PatrolSettingContract.java | Java | [
{
"context": "ition;\n\nimport java.util.List;\n\n/**\n * Created by 孙秀艳 on 2019/1/18.\n */\n\npublic class PatrolSettingCont",
"end": 436,
"score": 0.9989340305328369,
"start": 433,
"tag": "NAME",
"value": "孙秀艳"
}
]
| null | []
| package com.csjbot.mobileshop.guide_patrol.patrol.patrol_setting;
import android.widget.Button;
import android.widget.EditText;
import com.csjbot.mobileshop.base.BasePresenter;
import com.csjbot.mobileshop.base.BaseView;
import com.csjbot.mobileshop.global.Constants;
import com.csjbot.mobileshop.guide_patrol.patrol.bean.PatrolBean;
import com.csjbot.mobileshop.model.tcp.bean.Position;
import java.util.List;
/**
* Created by 孙秀艳 on 2019/1/18.
*/
public class PatrolSettingContract {
interface Presenter extends BasePresenter<View> {
void getPosition();//获取当前位置
void getPatrolData();//获取巡视点数据
void addPatrolPoint();//新增巡视点
int getIndexByData(PatrolBean patrolBean);//获取巡视点的索引
void savePatrolPointByPosition(PatrolBean patrolBean, int position);//保存巡视点
void showEdittextDialog(String title, String content, EditText editText, int length);//添加和修改编辑框对话框
void showRecyclerViewDialog(String title, Button editText, Constants.ResourceSuffix.suffix suffix);//选择文件对话框
void removePatrolPointByPosition(int position);//移除巡视点
boolean getPatrolPlan();//获取巡视计划
void savePatrolPlan(boolean isCircle);//获取巡视计划 true 循环巡视 false 单次巡视
void getGuideData();//获取巡视路线的数据
void saveGuideData(List<PatrolBean> patrolBeans);//保存巡视路线数据
void removeGuideData();
boolean isGuideData(int position);//该巡视点是否在巡视路线中
String getMapPatrolName(String name);
void removeNoValidData();//移除不符合规则的数据
}
interface View extends BaseView {
void showPatrolPointMap(List<PatrolBean> patrolBeans);//在地图上显示巡视点
void addPatrolPoint(PatrolBean patrolBean);//地图上新增巡视点
void setPatrolPosition(Position position);
void saveSuccess();//巡视点保存成功
void removePatrolItem(int position);//移除巡视点
void addNotPatrolPoint();
void showGuideData(List<PatrolBean> patrolBeans);
}
}
| 2,216 | 0.731568 | 0.727934 | 49 | 38.285713 | 28.334734 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.77551 | false | false | 15 |
b3a716c13ba01bcbb1cae34d3519caaff6ac5990 | 28,286,654,671,656 | 646b342eae769d7e9242ecfff559dbf4db515460 | /app/src/main/java/co/megachips/hybridgpsmonitor/sub_activity/custom_view/DR_CustomDraw.java | 457efe147efcf00c47dfd05aec75029b95b4eed3 | []
| no_license | yang-pan/HGM | https://github.com/yang-pan/HGM | b97de33b810231f7f456be9a37bbf4dd5efc4de1 | 45712be7c1cc63341f4aabde4e985603813b51e1 | refs/heads/master | 2021-05-02T08:59:44.511000 | 2016-11-29T01:01:07 | 2016-11-29T01:01:07 | 72,808,793 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*******************************************************************
* @file DR_CustomDraw.java
*
* @par Copyright
* (C) 2014-2015 MegaChips Corporation
*
* @date 2014/02/26
*******************************************************************/
package co.megachips.hybridgpsmonitor.sub_activity.custom_view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View;
import java.util.ArrayList;
import java.util.Timer;
import co.megachips.hybridgpsmonitor.R;
import co.megachips.hybridgpsmonitor.sub_activity.DR;
/**@brief CustomView for DR activity
*/
@SuppressLint("DrawAllocation")
public class DR_CustomDraw extends View{
public ArrayList<DR.DR_packet> drPackets = new ArrayList<DR.DR_packet>();
Context main_context;
private Timer mTimer;
private ScaleGestureDetector _gestureDetector;
private float _scaleFactor = 1.0f;
private float _scaleFactor_temp = 1.0f;
private float FLOAT_SCALE_FACTOR_MAX_CLIP = 2.50f;
private float FLOAT_SCALE_FACTOR_MIN_CLIP = 0.50f;
boolean touch_flag = false;
boolean pinch_flag = false;
public int offset_x = 0;
public int offset_y = 0;
private int touch_base_x = 0;
private int touch_base_y = 0;
public Paint paint = new Paint( Paint.ANTI_ALIAS_FLAG);
/**@brief Constructor of this class.
*/
public DR_CustomDraw(Context context){
super(context);
main_context = context;
_gestureDetector = new ScaleGestureDetector(main_context, _simpleListener);
}
/**@brief Reset internal parameter
*/
public void resetOffset(){
_scaleFactor = 1.0f;
offset_x = 0;
offset_y = 0;
drPackets.clear();
redraw("test");
}
public void timer_Tick(){
redraw("test");
}
/**@brief add DR packet data.
*/
public void addPacket(DR.DR_packet packet){
drPackets.add(packet);
}
private void redraw(String str){
Message valueMsg = new Message();
valueMsg.obj = str;
mHandler.sendMessage(valueMsg);
return;
}
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
//invalidate();
postInvalidate();
}
};
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas){
Bitmap bitmap;
Resources r = this.getResources();
//---------------------------------------
int BUTTON_AREA_RATIO = 30;
int DR_AREA_RATIO = 100 - BUTTON_AREA_RATIO;
int DR_AREA_MARGIN_RATIO_VERTICAL = 2;
int DR_AREA_MARGIN_RATIO_HORIZONTAL = 3;
int DR_BUTTON_AREA_MARGIN_VERTICAL = 2;
int DR_BUTTON_AREA_MARGIN_HORIZONTAL = 2;
//---------------------------------------
int canvas_width = canvas.getWidth();
int canvas_height = canvas.getHeight();
int CANVAS_WIDTH = canvas.getWidth();
int DR_MARGIN_VERTICAL = (canvas_height * DR_AREA_MARGIN_RATIO_VERTICAL) / 100;
int DR_MARGIN_HORIZONTAL = (canvas_width * DR_AREA_MARGIN_RATIO_HORIZONTAL) / 100;
int DR_AREA_HEIGHT = (canvas_height * DR_AREA_RATIO) /100;
int BUTTON_AREA_HEIGHT = (canvas_height * BUTTON_AREA_RATIO) / 100;
int DR_HEIGHT = DR_AREA_HEIGHT - (DR_MARGIN_VERTICAL * 2);
int DR_WIDTH = CANVAS_WIDTH - (DR_MARGIN_HORIZONTAL * 2);
int DR_BASE_X1 = DR_MARGIN_HORIZONTAL;
int DR_BASE_X2 = DR_MARGIN_HORIZONTAL + DR_WIDTH;
int DR_BASE_Y1 = BUTTON_AREA_HEIGHT + DR_MARGIN_VERTICAL;
int DR_BASE_Y2 = BUTTON_AREA_HEIGHT + DR_MARGIN_VERTICAL + DR_HEIGHT;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.graph_background);
bitmap = Bitmap.createScaledBitmap(bitmap, DR_WIDTH, DR_HEIGHT, false);
canvas.drawBitmap(bitmap, DR_BASE_X1, DR_BASE_Y1, null);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int BUTTON_MARGIN_VERTICAL = (canvas_height * DR_BUTTON_AREA_MARGIN_VERTICAL) / 100;
int BUTTON_MARGIN_HORIZONTAL = (canvas_width * DR_BUTTON_AREA_MARGIN_HORIZONTAL) / 100;
int BUTTON_HEIGHT = (BUTTON_AREA_HEIGHT - (BUTTON_MARGIN_VERTICAL * 2)) / 2;
int BUTTON_WIDTH = ( CANVAS_WIDTH - (BUTTON_MARGIN_HORIZONTAL * 3) ) / 2;
int BUTTON1_BASE_X1 = BUTTON_MARGIN_HORIZONTAL;
int BUTTON1_BASE_X2 = BUTTON_MARGIN_HORIZONTAL * 2 + BUTTON_WIDTH;
int BUTTON1_BASE_Y1 = BUTTON_MARGIN_VERTICAL;
int BUTTON1_BASE_Y2 = BUTTON_MARGIN_VERTICAL * 2 + BUTTON_HEIGHT;
int BUTTON2_BASE_X1 = (BUTTON_MARGIN_HORIZONTAL * 2) + BUTTON_WIDTH;
int BUTTON2_BASE_X2 = (BUTTON_MARGIN_HORIZONTAL * 2) + (BUTTON_WIDTH * 2);
int BUTTON2_BASE_Y1 = BUTTON_MARGIN_VERTICAL;
int BUTTON2_BASE_Y2 = BUTTON_MARGIN_VERTICAL + BUTTON_HEIGHT;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.distance2);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X1, BUTTON1_BASE_Y1, null);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.step2);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X1, BUTTON1_BASE_Y2, null);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.degree);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X2, BUTTON1_BASE_Y1, null);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int TEXT_BOTTOM_MARGIN = 20;
int TEXT_RIGHT_MARGIN = 20;
paint.setColor(Color.argb(255, 255, 255, 255));
float textWidth;
float unitWidth;
String disp_string;
paint.setTextSize(20);
disp_string = "m";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
paint.setTextSize(65);
if(drPackets.size()>0){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%.2f", last_packet.oddMeter);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - textWidth - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
//---------------------------------------------------------
paint.setTextSize(20);
disp_string = "degree";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON2_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
paint.setTextSize(65);
if(drPackets.size()>=1){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%.2f", last_packet.angle * 180/3.14);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON2_BASE_X2 - unitWidth - textWidth - TEXT_RIGHT_MARGIN, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
//--------------------------------------------------------------------------------------------
paint.setTextSize(20);
disp_string = "step";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 + BUTTON_HEIGHT , paint);
paint.setTextSize(65);
if(drPackets.size()>0){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%d", last_packet.num_of_steps);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - textWidth - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 + BUTTON_HEIGHT, paint);
int DEVIDE_MIN = 4;
int DEVIDE_MAX = 6;
int SCALE_FACTOR_MIN = 100;
int SCALE_FACTOR_MAX = 500;
int SCALE_FACTOR_MIN_CLIP = 345;
int SCALE_FACTOR_MAX_CLIP = 490;
int SCALE_OFFSET = SCALE_FACTOR_MIN_CLIP - SCALE_FACTOR_MIN;
int SCALE_FACTOR_UNIT = ((DR_HEIGHT/DEVIDE_MIN) - (DR_HEIGHT/DEVIDE_MAX))/(SCALE_FACTOR_MAX - SCALE_FACTOR_MIN);
if(SCALE_FACTOR_UNIT <= 1){
SCALE_FACTOR_UNIT = 1;
}
float scale_factor_temp = (FLOAT_SCALE_FACTOR_MAX_CLIP+FLOAT_SCALE_FACTOR_MIN_CLIP) - _scaleFactor;
int scale = (int)(scale_factor_temp * 100) + SCALE_OFFSET;
if(scale<SCALE_FACTOR_MIN_CLIP){
scale = SCALE_FACTOR_MIN_CLIP;
}else if(scale > SCALE_FACTOR_MAX_CLIP){
scale = SCALE_FACTOR_MAX_CLIP;
}
paint.setColor(Color.argb(255, 220, 220, 220));
paint.setStrokeWidth(3);
int center_x = DR_BASE_X1+(DR_BASE_X2-DR_BASE_X1)/2 + offset_x;
int center_y = DR_BASE_Y1+(DR_BASE_Y2-DR_BASE_Y1)/2 + offset_y;
if(center_x>DR_BASE_X1 && center_x<DR_BASE_X2){
canvas.drawLine(center_x, DR_BASE_Y1, center_x, DR_BASE_Y2, paint);
}
if(center_y>DR_BASE_Y1 && center_y<DR_BASE_Y2){
canvas.drawLine(DR_BASE_X1, center_y, DR_BASE_X2, center_y, paint);
}
paint.setColor(Color.argb(255, 220, 220, 220));
paint.setStrokeWidth(1);
int reversed_scale = (SCALE_FACTOR_MAX-SCALE_FACTOR_MIN)-(scale-SCALE_FACTOR_MIN);
if(reversed_scale<=0){reversed_scale = 1;}
for(int i=1; center_x + (i*reversed_scale*SCALE_FACTOR_UNIT) < DR_BASE_X2; i++){
int temp_pos = center_x + i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos > DR_BASE_X1){
canvas.drawLine(temp_pos, DR_BASE_Y1, temp_pos, DR_BASE_Y2, paint);
}
}
for(int i=1; center_x - (i*reversed_scale*SCALE_FACTOR_UNIT) > DR_BASE_X1; i++){
int temp_pos = center_x - i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos < DR_BASE_X2){
canvas.drawLine(temp_pos, DR_BASE_Y1, temp_pos, DR_BASE_Y2, paint);
}
}
for(int i=1; center_y + (i*reversed_scale*SCALE_FACTOR_UNIT) < DR_BASE_Y2; i++){
int temp_pos = center_y + i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos > DR_BASE_Y1){
canvas.drawLine(DR_BASE_X1, temp_pos, DR_BASE_X2, temp_pos, paint);
}
}
for(int i=1; center_y - (i*reversed_scale*SCALE_FACTOR_UNIT) > DR_BASE_Y1; i++){
int temp_pos = center_y - i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos < DR_BASE_Y2){
canvas.drawLine(DR_BASE_X1, temp_pos, DR_BASE_X2, temp_pos, paint);
}
}
//--------------------------------------------------------------------------------------------
canvas.clipRect(DR_BASE_X1, DR_BASE_Y1, DR_BASE_X2, DR_BASE_Y2);
if(drPackets.size()>1){
paint.setStrokeWidth(12);
paint.setColor(Color.argb(255, 255, 0, 0));
int plotX1 = 0;
int plotY1 = 0;
int plotX2 = 0;
int plotY2 = 0;
DR.DR_packet packet;
for(int i=0; i<drPackets.size()-1; i++){
packet = drPackets.get(i);
plotX1 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY1 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
packet = drPackets.get(i+1);
plotX2 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY2 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
canvas.drawLine(plotX1, plotY1, plotX2, plotY2, paint);
canvas.drawCircle(plotX2, plotY2, 5, paint);
}
canvas.drawCircle(plotX2, plotY2, 9, paint);
}else if(drPackets.size()==1){
paint.setColor(Color.argb(255, 255, 0, 0));
int plotX1 = 0;
int plotY1 = 0;
DR.DR_packet packet;
packet = drPackets.get(drPackets.size()-1);
plotX1 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY1 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
canvas.drawCircle(plotX1, plotY1, 9, paint);
}
//--------------------------------------------------------------------------------------------
paint.setTextSize(20);
paint.setColor(Color.argb(255, 0, 0, 0));
String grid_string = "1grid = 1m";
unitWidth = paint.measureText(grid_string, 0, grid_string.length());
canvas.drawText(grid_string, DR_BASE_X1 + 20, DR_BASE_Y2 - 20, paint);
//--------------------------------------------------------------------------------------------
}
private SimpleOnScaleGestureListener _simpleListener
= new SimpleOnScaleGestureListener() {
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
pinch_flag = true;
redraw("test");
return super.onScaleBegin(detector);
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
_scaleFactor_temp = detector.getScaleFactor();
_scaleFactor *= _scaleFactor_temp;
if(_scaleFactor<FLOAT_SCALE_FACTOR_MIN_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MIN_CLIP;
}else if(_scaleFactor>FLOAT_SCALE_FACTOR_MAX_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MAX_CLIP;
}
redraw("test");
super.onScaleEnd(detector);
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
pinch_flag = true;
_scaleFactor_temp = detector.getScaleFactor();
_scaleFactor *= _scaleFactor_temp;
if(_scaleFactor<FLOAT_SCALE_FACTOR_MIN_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MIN_CLIP;
}else if(_scaleFactor>FLOAT_SCALE_FACTOR_MAX_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MAX_CLIP;
}
redraw("test");
return true;
};
};
public boolean onTouchEvent(MotionEvent e){
int temp_x;
int temp_y;
_gestureDetector.onTouchEvent(e);
switch(e.getAction()){
case MotionEvent.ACTION_DOWN:
touch_flag = true;
touch_base_x = (int)e.getX();
touch_base_y = (int)e.getY();
invalidate();
break;
case MotionEvent.ACTION_MOVE:
if(touch_flag == true && pinch_flag != true){
temp_x = (int)e.getX();
temp_y = (int)e.getY();
offset_x = offset_x + (temp_x - touch_base_x);
offset_y = offset_y + (temp_y - touch_base_y);
touch_base_x = temp_x;
touch_base_y = temp_y;
}
invalidate();
break;
case MotionEvent.ACTION_UP:
pinch_flag = false;
touch_flag = false;
invalidate();
break;
default:
break;
}
return true;
}
}
| UTF-8 | Java | 14,558 | java | DR_CustomDraw.java | Java | []
| null | []
| /*******************************************************************
* @file DR_CustomDraw.java
*
* @par Copyright
* (C) 2014-2015 MegaChips Corporation
*
* @date 2014/02/26
*******************************************************************/
package co.megachips.hybridgpsmonitor.sub_activity.custom_view;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Handler;
import android.os.Message;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.view.ScaleGestureDetector.SimpleOnScaleGestureListener;
import android.view.View;
import java.util.ArrayList;
import java.util.Timer;
import co.megachips.hybridgpsmonitor.R;
import co.megachips.hybridgpsmonitor.sub_activity.DR;
/**@brief CustomView for DR activity
*/
@SuppressLint("DrawAllocation")
public class DR_CustomDraw extends View{
public ArrayList<DR.DR_packet> drPackets = new ArrayList<DR.DR_packet>();
Context main_context;
private Timer mTimer;
private ScaleGestureDetector _gestureDetector;
private float _scaleFactor = 1.0f;
private float _scaleFactor_temp = 1.0f;
private float FLOAT_SCALE_FACTOR_MAX_CLIP = 2.50f;
private float FLOAT_SCALE_FACTOR_MIN_CLIP = 0.50f;
boolean touch_flag = false;
boolean pinch_flag = false;
public int offset_x = 0;
public int offset_y = 0;
private int touch_base_x = 0;
private int touch_base_y = 0;
public Paint paint = new Paint( Paint.ANTI_ALIAS_FLAG);
/**@brief Constructor of this class.
*/
public DR_CustomDraw(Context context){
super(context);
main_context = context;
_gestureDetector = new ScaleGestureDetector(main_context, _simpleListener);
}
/**@brief Reset internal parameter
*/
public void resetOffset(){
_scaleFactor = 1.0f;
offset_x = 0;
offset_y = 0;
drPackets.clear();
redraw("test");
}
public void timer_Tick(){
redraw("test");
}
/**@brief add DR packet data.
*/
public void addPacket(DR.DR_packet packet){
drPackets.add(packet);
}
private void redraw(String str){
Message valueMsg = new Message();
valueMsg.obj = str;
mHandler.sendMessage(valueMsg);
return;
}
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
//invalidate();
postInvalidate();
}
};
@SuppressLint("DrawAllocation")
protected void onDraw(Canvas canvas){
Bitmap bitmap;
Resources r = this.getResources();
//---------------------------------------
int BUTTON_AREA_RATIO = 30;
int DR_AREA_RATIO = 100 - BUTTON_AREA_RATIO;
int DR_AREA_MARGIN_RATIO_VERTICAL = 2;
int DR_AREA_MARGIN_RATIO_HORIZONTAL = 3;
int DR_BUTTON_AREA_MARGIN_VERTICAL = 2;
int DR_BUTTON_AREA_MARGIN_HORIZONTAL = 2;
//---------------------------------------
int canvas_width = canvas.getWidth();
int canvas_height = canvas.getHeight();
int CANVAS_WIDTH = canvas.getWidth();
int DR_MARGIN_VERTICAL = (canvas_height * DR_AREA_MARGIN_RATIO_VERTICAL) / 100;
int DR_MARGIN_HORIZONTAL = (canvas_width * DR_AREA_MARGIN_RATIO_HORIZONTAL) / 100;
int DR_AREA_HEIGHT = (canvas_height * DR_AREA_RATIO) /100;
int BUTTON_AREA_HEIGHT = (canvas_height * BUTTON_AREA_RATIO) / 100;
int DR_HEIGHT = DR_AREA_HEIGHT - (DR_MARGIN_VERTICAL * 2);
int DR_WIDTH = CANVAS_WIDTH - (DR_MARGIN_HORIZONTAL * 2);
int DR_BASE_X1 = DR_MARGIN_HORIZONTAL;
int DR_BASE_X2 = DR_MARGIN_HORIZONTAL + DR_WIDTH;
int DR_BASE_Y1 = BUTTON_AREA_HEIGHT + DR_MARGIN_VERTICAL;
int DR_BASE_Y2 = BUTTON_AREA_HEIGHT + DR_MARGIN_VERTICAL + DR_HEIGHT;
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.graph_background);
bitmap = Bitmap.createScaledBitmap(bitmap, DR_WIDTH, DR_HEIGHT, false);
canvas.drawBitmap(bitmap, DR_BASE_X1, DR_BASE_Y1, null);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int BUTTON_MARGIN_VERTICAL = (canvas_height * DR_BUTTON_AREA_MARGIN_VERTICAL) / 100;
int BUTTON_MARGIN_HORIZONTAL = (canvas_width * DR_BUTTON_AREA_MARGIN_HORIZONTAL) / 100;
int BUTTON_HEIGHT = (BUTTON_AREA_HEIGHT - (BUTTON_MARGIN_VERTICAL * 2)) / 2;
int BUTTON_WIDTH = ( CANVAS_WIDTH - (BUTTON_MARGIN_HORIZONTAL * 3) ) / 2;
int BUTTON1_BASE_X1 = BUTTON_MARGIN_HORIZONTAL;
int BUTTON1_BASE_X2 = BUTTON_MARGIN_HORIZONTAL * 2 + BUTTON_WIDTH;
int BUTTON1_BASE_Y1 = BUTTON_MARGIN_VERTICAL;
int BUTTON1_BASE_Y2 = BUTTON_MARGIN_VERTICAL * 2 + BUTTON_HEIGHT;
int BUTTON2_BASE_X1 = (BUTTON_MARGIN_HORIZONTAL * 2) + BUTTON_WIDTH;
int BUTTON2_BASE_X2 = (BUTTON_MARGIN_HORIZONTAL * 2) + (BUTTON_WIDTH * 2);
int BUTTON2_BASE_Y1 = BUTTON_MARGIN_VERTICAL;
int BUTTON2_BASE_Y2 = BUTTON_MARGIN_VERTICAL + BUTTON_HEIGHT;
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.distance2);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X1, BUTTON1_BASE_Y1, null);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.step2);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X1, BUTTON1_BASE_Y2, null);
// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
bitmap = BitmapFactory.decodeResource(r, R.drawable.degree);
bitmap = Bitmap.createScaledBitmap(bitmap, BUTTON_WIDTH, BUTTON_HEIGHT, false);
canvas.drawBitmap(bitmap, BUTTON1_BASE_X2, BUTTON1_BASE_Y1, null);
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
int TEXT_BOTTOM_MARGIN = 20;
int TEXT_RIGHT_MARGIN = 20;
paint.setColor(Color.argb(255, 255, 255, 255));
float textWidth;
float unitWidth;
String disp_string;
paint.setTextSize(20);
disp_string = "m";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
paint.setTextSize(65);
if(drPackets.size()>0){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%.2f", last_packet.oddMeter);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - textWidth - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
//---------------------------------------------------------
paint.setTextSize(20);
disp_string = "degree";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON2_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
paint.setTextSize(65);
if(drPackets.size()>=1){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%.2f", last_packet.angle * 180/3.14);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON2_BASE_X2 - unitWidth - textWidth - TEXT_RIGHT_MARGIN, BUTTON2_BASE_Y2 - TEXT_BOTTOM_MARGIN, paint);
//--------------------------------------------------------------------------------------------
paint.setTextSize(20);
disp_string = "step";
unitWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 + BUTTON_HEIGHT , paint);
paint.setTextSize(65);
if(drPackets.size()>0){
DR.DR_packet last_packet = drPackets.get(drPackets.size()-1);
disp_string = String.format("%d", last_packet.num_of_steps);
}else{
disp_string = "";
}
textWidth = paint.measureText(disp_string, 0, disp_string.length());
canvas.drawText(disp_string, BUTTON1_BASE_X2 - textWidth - unitWidth - TEXT_RIGHT_MARGIN * 2, BUTTON2_BASE_Y2 + BUTTON_HEIGHT, paint);
int DEVIDE_MIN = 4;
int DEVIDE_MAX = 6;
int SCALE_FACTOR_MIN = 100;
int SCALE_FACTOR_MAX = 500;
int SCALE_FACTOR_MIN_CLIP = 345;
int SCALE_FACTOR_MAX_CLIP = 490;
int SCALE_OFFSET = SCALE_FACTOR_MIN_CLIP - SCALE_FACTOR_MIN;
int SCALE_FACTOR_UNIT = ((DR_HEIGHT/DEVIDE_MIN) - (DR_HEIGHT/DEVIDE_MAX))/(SCALE_FACTOR_MAX - SCALE_FACTOR_MIN);
if(SCALE_FACTOR_UNIT <= 1){
SCALE_FACTOR_UNIT = 1;
}
float scale_factor_temp = (FLOAT_SCALE_FACTOR_MAX_CLIP+FLOAT_SCALE_FACTOR_MIN_CLIP) - _scaleFactor;
int scale = (int)(scale_factor_temp * 100) + SCALE_OFFSET;
if(scale<SCALE_FACTOR_MIN_CLIP){
scale = SCALE_FACTOR_MIN_CLIP;
}else if(scale > SCALE_FACTOR_MAX_CLIP){
scale = SCALE_FACTOR_MAX_CLIP;
}
paint.setColor(Color.argb(255, 220, 220, 220));
paint.setStrokeWidth(3);
int center_x = DR_BASE_X1+(DR_BASE_X2-DR_BASE_X1)/2 + offset_x;
int center_y = DR_BASE_Y1+(DR_BASE_Y2-DR_BASE_Y1)/2 + offset_y;
if(center_x>DR_BASE_X1 && center_x<DR_BASE_X2){
canvas.drawLine(center_x, DR_BASE_Y1, center_x, DR_BASE_Y2, paint);
}
if(center_y>DR_BASE_Y1 && center_y<DR_BASE_Y2){
canvas.drawLine(DR_BASE_X1, center_y, DR_BASE_X2, center_y, paint);
}
paint.setColor(Color.argb(255, 220, 220, 220));
paint.setStrokeWidth(1);
int reversed_scale = (SCALE_FACTOR_MAX-SCALE_FACTOR_MIN)-(scale-SCALE_FACTOR_MIN);
if(reversed_scale<=0){reversed_scale = 1;}
for(int i=1; center_x + (i*reversed_scale*SCALE_FACTOR_UNIT) < DR_BASE_X2; i++){
int temp_pos = center_x + i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos > DR_BASE_X1){
canvas.drawLine(temp_pos, DR_BASE_Y1, temp_pos, DR_BASE_Y2, paint);
}
}
for(int i=1; center_x - (i*reversed_scale*SCALE_FACTOR_UNIT) > DR_BASE_X1; i++){
int temp_pos = center_x - i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos < DR_BASE_X2){
canvas.drawLine(temp_pos, DR_BASE_Y1, temp_pos, DR_BASE_Y2, paint);
}
}
for(int i=1; center_y + (i*reversed_scale*SCALE_FACTOR_UNIT) < DR_BASE_Y2; i++){
int temp_pos = center_y + i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos > DR_BASE_Y1){
canvas.drawLine(DR_BASE_X1, temp_pos, DR_BASE_X2, temp_pos, paint);
}
}
for(int i=1; center_y - (i*reversed_scale*SCALE_FACTOR_UNIT) > DR_BASE_Y1; i++){
int temp_pos = center_y - i*reversed_scale*SCALE_FACTOR_UNIT;
if(temp_pos < DR_BASE_Y2){
canvas.drawLine(DR_BASE_X1, temp_pos, DR_BASE_X2, temp_pos, paint);
}
}
//--------------------------------------------------------------------------------------------
canvas.clipRect(DR_BASE_X1, DR_BASE_Y1, DR_BASE_X2, DR_BASE_Y2);
if(drPackets.size()>1){
paint.setStrokeWidth(12);
paint.setColor(Color.argb(255, 255, 0, 0));
int plotX1 = 0;
int plotY1 = 0;
int plotX2 = 0;
int plotY2 = 0;
DR.DR_packet packet;
for(int i=0; i<drPackets.size()-1; i++){
packet = drPackets.get(i);
plotX1 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY1 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
packet = drPackets.get(i+1);
plotX2 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY2 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
canvas.drawLine(plotX1, plotY1, plotX2, plotY2, paint);
canvas.drawCircle(plotX2, plotY2, 5, paint);
}
canvas.drawCircle(plotX2, plotY2, 9, paint);
}else if(drPackets.size()==1){
paint.setColor(Color.argb(255, 255, 0, 0));
int plotX1 = 0;
int plotY1 = 0;
DR.DR_packet packet;
packet = drPackets.get(drPackets.size()-1);
plotX1 = center_x + (int)((packet.relativeX * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
plotY1 = center_y - (int)((packet.relativeY * 100.0f ) * reversed_scale * SCALE_FACTOR_UNIT ) / 100;
canvas.drawCircle(plotX1, plotY1, 9, paint);
}
//--------------------------------------------------------------------------------------------
paint.setTextSize(20);
paint.setColor(Color.argb(255, 0, 0, 0));
String grid_string = "1grid = 1m";
unitWidth = paint.measureText(grid_string, 0, grid_string.length());
canvas.drawText(grid_string, DR_BASE_X1 + 20, DR_BASE_Y2 - 20, paint);
//--------------------------------------------------------------------------------------------
}
private SimpleOnScaleGestureListener _simpleListener
= new SimpleOnScaleGestureListener() {
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
pinch_flag = true;
redraw("test");
return super.onScaleBegin(detector);
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
_scaleFactor_temp = detector.getScaleFactor();
_scaleFactor *= _scaleFactor_temp;
if(_scaleFactor<FLOAT_SCALE_FACTOR_MIN_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MIN_CLIP;
}else if(_scaleFactor>FLOAT_SCALE_FACTOR_MAX_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MAX_CLIP;
}
redraw("test");
super.onScaleEnd(detector);
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
pinch_flag = true;
_scaleFactor_temp = detector.getScaleFactor();
_scaleFactor *= _scaleFactor_temp;
if(_scaleFactor<FLOAT_SCALE_FACTOR_MIN_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MIN_CLIP;
}else if(_scaleFactor>FLOAT_SCALE_FACTOR_MAX_CLIP){
_scaleFactor=FLOAT_SCALE_FACTOR_MAX_CLIP;
}
redraw("test");
return true;
};
};
public boolean onTouchEvent(MotionEvent e){
int temp_x;
int temp_y;
_gestureDetector.onTouchEvent(e);
switch(e.getAction()){
case MotionEvent.ACTION_DOWN:
touch_flag = true;
touch_base_x = (int)e.getX();
touch_base_y = (int)e.getY();
invalidate();
break;
case MotionEvent.ACTION_MOVE:
if(touch_flag == true && pinch_flag != true){
temp_x = (int)e.getX();
temp_y = (int)e.getY();
offset_x = offset_x + (temp_x - touch_base_x);
offset_y = offset_y + (temp_y - touch_base_y);
touch_base_x = temp_x;
touch_base_y = temp_y;
}
invalidate();
break;
case MotionEvent.ACTION_UP:
pinch_flag = false;
touch_flag = false;
invalidate();
break;
default:
break;
}
return true;
}
}
| 14,558 | 0.63381 | 0.607364 | 438 | 32.237442 | 30.150055 | 141 | false | false | 0 | 0 | 0 | 0 | 81 | 0.032697 | 2.538813 | false | false | 15 |
b99934183cec1780a6a1f4bdd6047756c81dc8d2 | 29,437,705,912,102 | 2e2f049a3c852725517b839048203777d90cfddf | /Exercício 4/NotaFiscal/src/Automovel.java | 7ceaed13fb48e2a27d7d8f774a0c228357cbc240 | []
| no_license | stevreeper/Programa-o-modular | https://github.com/stevreeper/Programa-o-modular | 927421b0265e185b8250e76d5feb4e88400d036a | d706493b93c1c46a26509acfc9bf1a41a5ea1164 | refs/heads/master | 2018-10-25T14:26:56.549000 | 2018-10-03T16:38:30 | 2018-10-03T16:38:30 | 145,478,844 | 1 | 2 | null | false | 2018-08-21T21:31:15 | 2018-08-20T23:00:19 | 2018-08-21T13:02:19 | 2018-08-21T21:31:14 | 54 | 0 | 0 | 0 | Java | false | null | public class Automovel extends Servico{
private String cor;
private String modelo;
private int ano;
public Automovel(String nome, String cor, String modelo, int ano, double preco) {
super(nome, preco);
setCor(cor);
setModelo(modelo);
setAno(ano);
}
public void setCor(String cor) {
this.cor = cor;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public void setAno(int ano) {
this.ano = ano;
}
@Override
public Servico getServico(){
return new Automovel(this.getNome(), this.cor, this.modelo, this.ano, this.getPreco());
}
}
| UTF-8 | Java | 667 | java | Automovel.java | Java | []
| null | []
| public class Automovel extends Servico{
private String cor;
private String modelo;
private int ano;
public Automovel(String nome, String cor, String modelo, int ano, double preco) {
super(nome, preco);
setCor(cor);
setModelo(modelo);
setAno(ano);
}
public void setCor(String cor) {
this.cor = cor;
}
public void setModelo(String modelo) {
this.modelo = modelo;
}
public void setAno(int ano) {
this.ano = ano;
}
@Override
public Servico getServico(){
return new Automovel(this.getNome(), this.cor, this.modelo, this.ano, this.getPreco());
}
}
| 667 | 0.602699 | 0.602699 | 29 | 22 | 22.67613 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.689655 | false | false | 15 |
9746bb64a314d18100167c080e4f0f1b3c90431a | 31,001,073,963,997 | 7138b889d9f0e52803b582879499ab351c0ca748 | /app/src/main/java/sud_tanj/com/phr_android/Health_Data/ActiveHealthDataListLayout/ActiveHealthDataListHolder.java | 1d32b74f182ddb2bc41cc28c05ad21b7dbbe6e3d | []
| no_license | sudtanj/PHR-Android | https://github.com/sudtanj/PHR-Android | 123bd6787c5867b03410e5a6afadee0d30599b67 | 3c90b8630340a3cd7e16c2943e8fa614627c539f | refs/heads/master | 2021-03-27T09:31:08.038000 | 2018-07-21T12:05:27 | 2018-07-21T12:05:27 | 113,633,281 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Create by Sudono Tanjung
* Copyright (c) 2018. All rights reserved.
*
* Last Modified by User on 5/26/18 4:49 PM
*/
package sud_tanj.com.phr_android.Health_Data.ActiveHealthDataListLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import sud_tanj.com.phr_android.Health_Data.ActiveHealthDataListLayout.Interface.ActiveHealthDataListRecyclerViewListener;
import sud_tanj.com.phr_android.R;
/**
* This class is part of PHRAndroid Project
* Any modified within this class without reading the
* manual will cause problem!
* <p>
* Created by Sudono Tanjung on 09/05/2018 - 15:20.
* <p>
* This class last modified by User
*/
public class ActiveHealthDataListHolder extends RecyclerView.ViewHolder {
private TextView title, value;
private ActiveHealthDataListRecyclerViewListener activeHealthDataListRecyclerViewListener;
public ActiveHealthDataListHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.health_sensor_title);
value = (TextView) itemView.findViewById(R.id.health_sensor_value);
activeHealthDataListRecyclerViewListener = new ActiveHealthDataListRecyclerViewListener(getAdapterPosition());
itemView.setOnClickListener(this.activeHealthDataListRecyclerViewListener);
}
public TextView getTitle() {
return title;
}
public TextView getValue() {
return value;
}
public void updateOnClick() {
if (getAdapterPosition() > -1)
this.activeHealthDataListRecyclerViewListener.setSensorPosition(getAdapterPosition());
}
}
| UTF-8 | Java | 1,656 | java | ActiveHealthDataListHolder.java | Java | [
{
"context": "/*\n * Create by Sudono Tanjung\n * Copyright (c) 2018. All rights reserved.\n *\n *",
"end": 30,
"score": 0.9998900890350342,
"start": 16,
"tag": "NAME",
"value": "Sudono Tanjung"
},
{
"context": " * manual will cause problem!\n * <p>\n * Created by Sudono Tanjung on 09/05/2018 - 15:20.\n * <p>\n * This class last ",
"end": 633,
"score": 0.9998896718025208,
"start": 619,
"tag": "NAME",
"value": "Sudono Tanjung"
}
]
| null | []
| /*
* Create by <NAME>
* Copyright (c) 2018. All rights reserved.
*
* Last Modified by User on 5/26/18 4:49 PM
*/
package sud_tanj.com.phr_android.Health_Data.ActiveHealthDataListLayout;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import sud_tanj.com.phr_android.Health_Data.ActiveHealthDataListLayout.Interface.ActiveHealthDataListRecyclerViewListener;
import sud_tanj.com.phr_android.R;
/**
* This class is part of PHRAndroid Project
* Any modified within this class without reading the
* manual will cause problem!
* <p>
* Created by <NAME> on 09/05/2018 - 15:20.
* <p>
* This class last modified by User
*/
public class ActiveHealthDataListHolder extends RecyclerView.ViewHolder {
private TextView title, value;
private ActiveHealthDataListRecyclerViewListener activeHealthDataListRecyclerViewListener;
public ActiveHealthDataListHolder(View itemView) {
super(itemView);
title = (TextView) itemView.findViewById(R.id.health_sensor_title);
value = (TextView) itemView.findViewById(R.id.health_sensor_value);
activeHealthDataListRecyclerViewListener = new ActiveHealthDataListRecyclerViewListener(getAdapterPosition());
itemView.setOnClickListener(this.activeHealthDataListRecyclerViewListener);
}
public TextView getTitle() {
return title;
}
public TextView getValue() {
return value;
}
public void updateOnClick() {
if (getAdapterPosition() > -1)
this.activeHealthDataListRecyclerViewListener.setSensorPosition(getAdapterPosition());
}
}
| 1,640 | 0.746377 | 0.730676 | 51 | 31.470589 | 32.635452 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 15 |
12399d716271a41188a466e7c7cd37f1799f9f60 | 14,285,061,250,223 | 9455d48f79dda81fc60a7fe2a6f1b286ee7dba78 | /zyu-webserver/src/main/java/com/zyu/webserver/controller/WebRequestController.java | 58142823e1ce8b43fdb2e77d00e6d77a6ec6e697 | []
| no_license | zgyiwang/zyu | https://github.com/zgyiwang/zyu | b9b49644f553a75f219b9d9e975e7fed2c886587 | 8534db4ceef117b0eadb580c833dbbf971b81d0c | refs/heads/master | 2023-01-18T21:42:18.358000 | 2020-11-23T03:31:30 | 2020-11-23T03:31:30 | 314,982,616 | 0 | 0 | null | false | 2020-11-22T13:55:25 | 2020-11-22T07:26:39 | 2020-11-22T08:08:28 | 2020-11-22T13:55:24 | 4 | 0 | 0 | 0 | null | false | false | package com.zyu.webserver.controller;
import com.alibaba.fastjson.JSON;
import com.zyu.webserver.service.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zyu.config.ResultVo;
@RestController
public class WebRequestController {
@Autowired
private WebService webService;
@GetMapping("/requestWeb")
public ResultVo requestWeb() {
String a = "123";
JSON.parse(a);
String s = webService.requestWeb();
return new ResultVo(s);
}
}
| UTF-8 | Java | 638 | java | WebRequestController.java | Java | []
| null | []
| package com.zyu.webserver.controller;
import com.alibaba.fastjson.JSON;
import com.zyu.webserver.service.WebService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zyu.config.ResultVo;
@RestController
public class WebRequestController {
@Autowired
private WebService webService;
@GetMapping("/requestWeb")
public ResultVo requestWeb() {
String a = "123";
JSON.parse(a);
String s = webService.requestWeb();
return new ResultVo(s);
}
}
| 638 | 0.744514 | 0.739812 | 22 | 28 | 19.023909 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 15 |
5c8f74f2636b0bf27d4d271349e9a8043fb0e8bd | 19,937,238,213,217 | 4cc6bec9702a19910e71b48ce4d743a95ebcd8c7 | /src/cn/test12/cc/J1223.java | 7514875fe4d838ef301991b0f955ae10b135860d | [
"MIT"
]
| permissive | huaisun/Ahstu-oj | https://github.com/huaisun/Ahstu-oj | 0af5f02b221e2dbdc76e34511ee75893ed08d7b2 | aa977dba33fc178fca34da0aa3cd46512c931117 | refs/heads/master | 2020-03-13T07:39:37.860000 | 2018-07-11T08:14:41 | 2018-07-11T08:14:41 | 131,029,523 | 3 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cn.test12.cc;
import java.util.Scanner;
public class J1223 {
private static String[] ss = new String[10000];
private static int k = 0;
public static void main(String[] args) {
Scanner cn = new Scanner(System.in);
int n = cn.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = cn.nextInt();
permutation(a, 0, n - 1);
if (n < 5) {
for (int i = 0; i < k; i++) {
for (int j = i + 1; j < k; j++) {
if (ss[i].compareTo(ss[j]) > 0) {
String te = ss[j];
ss[j] = ss[i];
ss[i] = te;
}
}
}
for (int i = 0; i < k; i++) {
System.out.println(ss[i]);
}
} else {
for (int i = 0; i < k; i++) {
System.out.println(ss[i]);
}
}
}
public static void permutation(int[] s, int from, int to) {
if (to <= 1)
return;
if (from == to) {
ss[k] = "";
for (int z = 0; z < s.length; z++)
ss[k] += String.valueOf(s[z]);
k++;
} else {
for (int i = from; i <= to; i++) {
swap(s, i, from);
permutation(s, from + 1, to);
swap(s, from, i);
}
}
}
public static void permutation1(int[] s, int from, int to) {
if (to <= 1)
return;
if (from == to) {
for (int z = 0; z < s.length; z++)
System.out.print(s[z]);
System.out.println();
} else {
for (int i = from; i <= to; i++) {
swap(s, i, from);
permutation(s, from + 1, to);
swap(s, from, i);
}
}
}
public static void swap(int[] s, int i, int j) {
int tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
}
| UTF-8 | Java | 1,508 | java | J1223.java | Java | []
| null | []
| package cn.test12.cc;
import java.util.Scanner;
public class J1223 {
private static String[] ss = new String[10000];
private static int k = 0;
public static void main(String[] args) {
Scanner cn = new Scanner(System.in);
int n = cn.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = cn.nextInt();
permutation(a, 0, n - 1);
if (n < 5) {
for (int i = 0; i < k; i++) {
for (int j = i + 1; j < k; j++) {
if (ss[i].compareTo(ss[j]) > 0) {
String te = ss[j];
ss[j] = ss[i];
ss[i] = te;
}
}
}
for (int i = 0; i < k; i++) {
System.out.println(ss[i]);
}
} else {
for (int i = 0; i < k; i++) {
System.out.println(ss[i]);
}
}
}
public static void permutation(int[] s, int from, int to) {
if (to <= 1)
return;
if (from == to) {
ss[k] = "";
for (int z = 0; z < s.length; z++)
ss[k] += String.valueOf(s[z]);
k++;
} else {
for (int i = from; i <= to; i++) {
swap(s, i, from);
permutation(s, from + 1, to);
swap(s, from, i);
}
}
}
public static void permutation1(int[] s, int from, int to) {
if (to <= 1)
return;
if (from == to) {
for (int z = 0; z < s.length; z++)
System.out.print(s[z]);
System.out.println();
} else {
for (int i = from; i <= to; i++) {
swap(s, i, from);
permutation(s, from + 1, to);
swap(s, from, i);
}
}
}
public static void swap(int[] s, int i, int j) {
int tmp = s[i];
s[i] = s[j];
s[j] = tmp;
}
}
| 1,508 | 0.486737 | 0.46817 | 75 | 19.106667 | 14.963576 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.28 | false | false | 15 |
e27a07c55335ec8ba1186e82e7093c423de2f1e5 | 27,539,330,329,698 | 65eeae71704167459df265d5605dfb07f03d5513 | /src/main/java/com/elance/main/Main.java | 24a8ec518ffdd50537a6ced7ee1687f7da690715 | []
| no_license | SurpSG/reports-loader-core | https://github.com/SurpSG/reports-loader-core | 63e5d08d86a21e82df9b9aedd0685a5bdac54491 | a310c58f1d99692a735151f3e2936818f94e517c | refs/heads/master | 2021-01-22T07:03:02.048000 | 2014-12-28T18:37:34 | 2014-12-28T18:37:34 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.elance.main;
import javax.swing.SwingUtilities;
import com.elance.gui.MyFrame;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MyFrame();
}
});
}
}
| UTF-8 | Java | 277 | java | Main.java | Java | []
| null | []
| package com.elance.main;
import javax.swing.SwingUtilities;
import com.elance.gui.MyFrame;
public class Main {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MyFrame();
}
});
}
}
| 277 | 0.67509 | 0.67509 | 19 | 13.578947 | 14.719539 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.315789 | false | false | 15 |
b97cad34d65fc315ef52447675b731b93bd78da2 | 9,809,705,335,731 | 2229f03b14ccef9624936c7b8d535d7f4b6f6364 | /src/main/java/org/niket/xls2csv/core/XlsToXFormat.java | f937466ffedf84e56b8d5005a74ec69f38edbcb5 | []
| no_license | niketkumar/xls2anyformat | https://github.com/niketkumar/xls2anyformat | 986124b0a25d78691c2dc268efd03873cdfd9f96 | a65718b8d40bbb16bea6ee98e01fdb6e1f9f824f | refs/heads/master | 2021-04-26T12:31:21.163000 | 2014-10-02T13:20:04 | 2014-10-02T13:20:04 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.niket.xls2csv.core;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.niket.xls2csv.sandbox.SandBoxedTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Converts the given InputStream of XLS/XLSX content and creates one OutputStream per Sheet.
* <p/>
* Based on Configurable setting: max.sheets.allowed it may throw validation exception.
* <p/>
* Created by niket on 2/10/14.
*/
public class XlsToXFormat<X extends XFormat, S extends OutputStream> implements SandBoxedTask<OutputStreams<S>> {
private static final Logger Log = LoggerFactory.getLogger(XlsToXFormat.class);
private final InputStream sourceInputStream;
private final OutputStreams<S> outputStreams;
private final CoreConfig coreConfig;
private final XlsRowToXFormat<X> converter;
public XlsToXFormat(InputStream sourceInputStream, OutputStreams<S> outputStreams,
CoreConfig coreConfig, XlsRowToXFormat<X> converter) {
this.sourceInputStream = sourceInputStream;
this.outputStreams = outputStreams;
this.coreConfig = coreConfig;
this.converter = converter;
}
@Override
public OutputStreams<S> execute() throws Exception {
Workbook workbook = WorkbookFactory.create(sourceInputStream);
int numberOfSheets = workbook.getNumberOfSheets();
validateNumberOfSheets(numberOfSheets);
for (int i = 0; i < numberOfSheets; i++) {
if (Thread.interrupted()) throw new Exception("Interrupted, stopping...");
Sheet sheet = workbook.getSheetAt(i);
String sheetName = sheet.getSheetName();
Log.info("Parsing Sheet: {}", sheetName);
String uniqueSheetName = sheetName + System.currentTimeMillis();
Log.info("Sheet Unique Name: {}", uniqueSheetName);
final S out = outputStreams.addOutputStream(uniqueSheetName);
sheet.forEach(row -> {
try {
if (Thread.interrupted()) throw new Exception("Interrupted, stopping...");
Log.debug("Parsing Sheet: {}, RowNum: {}", sheetName, row.getRowNum());
out.write(converter.apply(row).toBytes());
} catch (Exception e) {
Log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
});
}
return outputStreams;
}
private void validateNumberOfSheets(int numberOfSheets) {
if (numberOfSheets == 0)
throw new RuntimeException("No Sheet found in the given Workbook");
if (numberOfSheets > coreConfig.getMaxSheetsAllowed())
throw new RuntimeException("Too many Sheets found in the given Workbook. Allowed: "
+ coreConfig.getMaxSheetsAllowed() + ", Found: " + numberOfSheets);
}
}
| UTF-8 | Java | 3,024 | java | XlsToXFormat.java | Java | [
{
"context": " throw validation exception.\n * <p/>\n * Created by niket on 2/10/14.\n */\npublic class XlsToXFormat<X exten",
"end": 557,
"score": 0.9996979832649231,
"start": 552,
"tag": "USERNAME",
"value": "niket"
}
]
| null | []
| package org.niket.xls2csv.core;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.niket.xls2csv.sandbox.SandBoxedTask;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Converts the given InputStream of XLS/XLSX content and creates one OutputStream per Sheet.
* <p/>
* Based on Configurable setting: max.sheets.allowed it may throw validation exception.
* <p/>
* Created by niket on 2/10/14.
*/
public class XlsToXFormat<X extends XFormat, S extends OutputStream> implements SandBoxedTask<OutputStreams<S>> {
private static final Logger Log = LoggerFactory.getLogger(XlsToXFormat.class);
private final InputStream sourceInputStream;
private final OutputStreams<S> outputStreams;
private final CoreConfig coreConfig;
private final XlsRowToXFormat<X> converter;
public XlsToXFormat(InputStream sourceInputStream, OutputStreams<S> outputStreams,
CoreConfig coreConfig, XlsRowToXFormat<X> converter) {
this.sourceInputStream = sourceInputStream;
this.outputStreams = outputStreams;
this.coreConfig = coreConfig;
this.converter = converter;
}
@Override
public OutputStreams<S> execute() throws Exception {
Workbook workbook = WorkbookFactory.create(sourceInputStream);
int numberOfSheets = workbook.getNumberOfSheets();
validateNumberOfSheets(numberOfSheets);
for (int i = 0; i < numberOfSheets; i++) {
if (Thread.interrupted()) throw new Exception("Interrupted, stopping...");
Sheet sheet = workbook.getSheetAt(i);
String sheetName = sheet.getSheetName();
Log.info("Parsing Sheet: {}", sheetName);
String uniqueSheetName = sheetName + System.currentTimeMillis();
Log.info("Sheet Unique Name: {}", uniqueSheetName);
final S out = outputStreams.addOutputStream(uniqueSheetName);
sheet.forEach(row -> {
try {
if (Thread.interrupted()) throw new Exception("Interrupted, stopping...");
Log.debug("Parsing Sheet: {}, RowNum: {}", sheetName, row.getRowNum());
out.write(converter.apply(row).toBytes());
} catch (Exception e) {
Log.error(e.getMessage(), e);
throw new RuntimeException(e);
}
});
}
return outputStreams;
}
private void validateNumberOfSheets(int numberOfSheets) {
if (numberOfSheets == 0)
throw new RuntimeException("No Sheet found in the given Workbook");
if (numberOfSheets > coreConfig.getMaxSheetsAllowed())
throw new RuntimeException("Too many Sheets found in the given Workbook. Allowed: "
+ coreConfig.getMaxSheetsAllowed() + ", Found: " + numberOfSheets);
}
}
| 3,024 | 0.658399 | 0.654762 | 72 | 41 | 30.232893 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.722222 | false | false | 15 |
7b803c2065bd7753cf5c47814314445eaaba860f | 8,134,668,084,616 | 7152068e27b78ea2d1413403ce8ae0acd30577ee | /jaas-api/src/main/java/kz/taimax/tomee/jaas/api/JAASContext.java | 4d0a432763b3c3874bbfb5a60d91a0403140ccaf | []
| no_license | aibar/jaas | https://github.com/aibar/jaas | 5eeac11cc396d784459baecf2862e639b00ffcb2 | ff77b910288c646e01eea3160ab321dd07d63fbf | refs/heads/master | 2020-07-28T18:10:11.252000 | 2016-11-10T17:23:41 | 2016-11-10T17:23:41 | 73,404,757 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kz.taimax.tomee.jaas.api;
import java.util.List;
public interface JAASContext {
String lastLoginException(String username);
int usersCount();
List<String> getLoggedUsers();
boolean isLoggedIn(String user);
boolean isAuthenticationException();
}
| UTF-8 | Java | 279 | java | JAASContext.java | Java | []
| null | []
| package kz.taimax.tomee.jaas.api;
import java.util.List;
public interface JAASContext {
String lastLoginException(String username);
int usersCount();
List<String> getLoggedUsers();
boolean isLoggedIn(String user);
boolean isAuthenticationException();
}
| 279 | 0.734767 | 0.734767 | 15 | 17.6 | 17.37738 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.466667 | false | false | 15 |
1da3a8c7f76aac55b6189906abe4decbbc70721b | 8,160,437,891,060 | 5fedbd8dbf6bd0ccdf0ab068997b33af7f616fb3 | /src/main/java/com/jvs/test/threads/dateformat/ThreadTestDateFormatter.java | c5f2bcd0d14462dca781866d7c503a925827ad04 | []
| no_license | jorgevs/MyThreadSampleProject | https://github.com/jorgevs/MyThreadSampleProject | 03deb2ce7d14a8454ec4a0b8b3689fb2ac1e2012 | 9dc622669eaa0a89fcfa72cfe096820e779a4e0a | refs/heads/master | 2021-01-17T08:12:03.879000 | 2017-04-11T14:13:08 | 2017-04-11T14:13:08 | 63,017,919 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jvs.test.threads.dateformat;
import java.util.Calendar;
import java.util.Date;
public class ThreadTestDateFormatter {
private static final int MAX_NUM_THREADS = 30;
private static Thread[] threads = new Thread[MAX_NUM_THREADS];
public static void main(String[] args) {
System.out.println("Testing date formatter with " + MAX_NUM_THREADS + " threads");
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
//------------------------------------------------------------------------
// You will get 30 rows with: "> enero 15, 1970" and 30 rows with: "> julio 10, 2016"
Date testDate = new Date(Calendar.getInstance().getTimeInMillis());
String newDate = UtilDate.getFormattedDateMMMMdYYYY_ThreadSafe(testDate);
System.out.println("> " + newDate);
Date testDate2 = new Date(1245454545);
String newDate2 = UtilDate.getFormattedDateMMMMdYYYY_ThreadSafe(testDate2);
System.out.println("> " + newDate2);
//------------------------------------------------------------------------
// You will get unexpected results
Date testDate11 = new Date(Calendar.getInstance().getTimeInMillis());
String newDate11 = UtilDate.getFormattedDateMMMMdYYYY_NO_ThreadSafe(testDate11);
System.out.println(">> " + newDate11);
Date testDate22 = new Date(1256565656);
String newDate22 = UtilDate.getFormattedDateMMMMdYYYY_NO_ThreadSafe(testDate22);
System.out.println(">> " + newDate22);
//------------------------------------------------------------------------
}
});
}
for (Thread thread : threads) {
thread.start();
}
}
}
| UTF-8 | Java | 1,744 | java | ThreadTestDateFormatter.java | Java | []
| null | []
| package com.jvs.test.threads.dateformat;
import java.util.Calendar;
import java.util.Date;
public class ThreadTestDateFormatter {
private static final int MAX_NUM_THREADS = 30;
private static Thread[] threads = new Thread[MAX_NUM_THREADS];
public static void main(String[] args) {
System.out.println("Testing date formatter with " + MAX_NUM_THREADS + " threads");
for (int i = 0; i < threads.length; i++) {
threads[i] = new Thread(new Runnable() {
@Override
public void run() {
//------------------------------------------------------------------------
// You will get 30 rows with: "> enero 15, 1970" and 30 rows with: "> julio 10, 2016"
Date testDate = new Date(Calendar.getInstance().getTimeInMillis());
String newDate = UtilDate.getFormattedDateMMMMdYYYY_ThreadSafe(testDate);
System.out.println("> " + newDate);
Date testDate2 = new Date(1245454545);
String newDate2 = UtilDate.getFormattedDateMMMMdYYYY_ThreadSafe(testDate2);
System.out.println("> " + newDate2);
//------------------------------------------------------------------------
// You will get unexpected results
Date testDate11 = new Date(Calendar.getInstance().getTimeInMillis());
String newDate11 = UtilDate.getFormattedDateMMMMdYYYY_NO_ThreadSafe(testDate11);
System.out.println(">> " + newDate11);
Date testDate22 = new Date(1256565656);
String newDate22 = UtilDate.getFormattedDateMMMMdYYYY_NO_ThreadSafe(testDate22);
System.out.println(">> " + newDate22);
//------------------------------------------------------------------------
}
});
}
for (Thread thread : threads) {
thread.start();
}
}
}
| 1,744 | 0.576261 | 0.542431 | 47 | 35.106384 | 30.616526 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.06383 | false | false | 15 |
64c24cf9431bcda0ca37addc03973f8e34248e1b | 29,987,461,686,094 | e17cd97f724cdeab3c6ddb00f48156189672fcd2 | /src/main/java/com/gerenciamento/gerenciamentopessoasrest/mapper/PersonMapper.java | f7610609d1816e70183f47a00a000b818e570272 | []
| no_license | Carla-Daniela/people-managementapi | https://github.com/Carla-Daniela/people-managementapi | 2840eb1b9370cfa8a960c57e7e1c327ac92be1c6 | 39412afd0687a4238dcd3c2a1262e101620ed88e | refs/heads/main | 2023-07-28T03:30:40.998000 | 2021-09-08T14:34:08 | 2021-09-08T14:34:08 | 402,878,280 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gerenciamento.gerenciamentopessoasrest.mapper;
import com.gerenciamento.gerenciamentopessoasrest.Model.Person;
import com.gerenciamento.gerenciamentopessoasrest.dto.request.PersonDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import static org.mapstruct.factory.Mappers.getMapper;
@Mapper
public interface PersonMapper {
PersonMapper INSTANCE = getMapper(PersonMapper.class);
@Mapping(target = "birthDate", source = "birthDate", dateFormat = "dd-MM-yyyy")
Person toModel(PersonDTO personDTO);
PersonDTO toDTO(Person person);
}
| UTF-8 | Java | 615 | java | PersonMapper.java | Java | []
| null | []
| package com.gerenciamento.gerenciamentopessoasrest.mapper;
import com.gerenciamento.gerenciamentopessoasrest.Model.Person;
import com.gerenciamento.gerenciamentopessoasrest.dto.request.PersonDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;
import static org.mapstruct.factory.Mappers.getMapper;
@Mapper
public interface PersonMapper {
PersonMapper INSTANCE = getMapper(PersonMapper.class);
@Mapping(target = "birthDate", source = "birthDate", dateFormat = "dd-MM-yyyy")
Person toModel(PersonDTO personDTO);
PersonDTO toDTO(Person person);
}
| 615 | 0.803252 | 0.803252 | 19 | 31.368422 | 26.970179 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.631579 | false | false | 15 |
17871e85bbce2e005319f1c533f970a31b87400c | 26,499,948,259,963 | e278a2449d9662b3d7932664708396d9dac56446 | /EX13Weather/src/ee/taltech/iti0202/api/agency/Client.java | cb16f1ad86aceef3fd899119357c46200e5136b1 | []
| no_license | karlviik/2019-java-excercises | https://github.com/karlviik/2019-java-excercises | 25c7f3e2a6c1ac59868f5fb730dd94a46143da60 | 74755f3867e07b6e8997689d4a4f023682106abc | refs/heads/master | 2022-04-23T04:07:05.270000 | 2019-05-28T07:33:02 | 2019-05-28T07:33:02 | 256,875,587 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ee.taltech.iti0202.api.agency;
import ee.taltech.iti0202.api.destinations.City;
import ee.taltech.iti0202.api.strategies.CityFinderStrategy;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class Client {
private String name;
private String startingCity;
private CityFinderStrategy choosingStrategy;
private List<String> wantsToVisitCities;
public Client(
String name,
String startingCity,
CityFinderStrategy choosingStrategy) {
this(name, startingCity, choosingStrategy, new ArrayList<>());
}
public Client(
String name,
String startingCity,
CityFinderStrategy choosingStrategy,
List<String> wantsToVisitCities) {
this.name = name;
this.startingCity = startingCity;
this.choosingStrategy = choosingStrategy;
this.wantsToVisitCities = wantsToVisitCities;
}
public String getName() {
return name;
}
public String getStartingCity() {
return startingCity;
}
public CityFinderStrategy getChoosingStrategy() {
return choosingStrategy;
}
public List<String> getCitiesThatWantsToVisit() {
return wantsToVisitCities;
}
public Optional<City> chooseBestCity(List<City> possibleCities) {
// return choosingStrategy.findBestCity(possibleCities);
List<City> wantCities = new ArrayList<>();
for (City city : possibleCities) {
if (wantsToVisitCities.contains(city.getName())) {
wantCities.add(city);
}
}
Optional<City> chosenCity = choosingStrategy.findBestCity(wantCities);
if (chosenCity.isEmpty()) {
return choosingStrategy.findBestCity(possibleCities);
} else {
return chosenCity;
}
}
}
| UTF-8 | Java | 1,709 | java | Client.java | Java | []
| null | []
| package ee.taltech.iti0202.api.agency;
import ee.taltech.iti0202.api.destinations.City;
import ee.taltech.iti0202.api.strategies.CityFinderStrategy;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class Client {
private String name;
private String startingCity;
private CityFinderStrategy choosingStrategy;
private List<String> wantsToVisitCities;
public Client(
String name,
String startingCity,
CityFinderStrategy choosingStrategy) {
this(name, startingCity, choosingStrategy, new ArrayList<>());
}
public Client(
String name,
String startingCity,
CityFinderStrategy choosingStrategy,
List<String> wantsToVisitCities) {
this.name = name;
this.startingCity = startingCity;
this.choosingStrategy = choosingStrategy;
this.wantsToVisitCities = wantsToVisitCities;
}
public String getName() {
return name;
}
public String getStartingCity() {
return startingCity;
}
public CityFinderStrategy getChoosingStrategy() {
return choosingStrategy;
}
public List<String> getCitiesThatWantsToVisit() {
return wantsToVisitCities;
}
public Optional<City> chooseBestCity(List<City> possibleCities) {
// return choosingStrategy.findBestCity(possibleCities);
List<City> wantCities = new ArrayList<>();
for (City city : possibleCities) {
if (wantsToVisitCities.contains(city.getName())) {
wantCities.add(city);
}
}
Optional<City> chosenCity = choosingStrategy.findBestCity(wantCities);
if (chosenCity.isEmpty()) {
return choosingStrategy.findBestCity(possibleCities);
} else {
return chosenCity;
}
}
}
| 1,709 | 0.718549 | 0.711527 | 66 | 24.878788 | 20.77113 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 15 |
f7c83942fdb8cb9d391dfa684cda59ccaa3479b4 | 10,711,648,452,326 | bd5da18110246af1839a3ab98391ed533adcead7 | /src/test/java/com/jinchao/dbdemo/DbdemoApplicationTests.java | dcffa1bae7ad7bf8b6bd9c528c44eec2721e6f70 | []
| no_license | wujc12/dbdemo | https://github.com/wujc12/dbdemo | 6a5e26a4c84ee67875cc825eb9b1385447c94b95 | 896136e6c976afc1ac4cf9dd70760a251e2763d9 | refs/heads/master | 2020-04-05T03:58:02.095000 | 2018-11-11T14:48:24 | 2018-11-11T14:48:24 | 156,533,452 | 0 | 0 | null | false | 2018-11-11T14:48:25 | 2018-11-07T11:02:12 | 2018-11-11T14:01:29 | 2018-11-11T14:48:25 | 1,001 | 0 | 0 | 0 | JavaScript | false | null | package com.jinchao.dbdemo;
import com.jinchao.dbdemo.entity.User;
import com.jinchao.dbdemo.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DbdemoApplicationTests {
@Autowired
UserService userService;
@Test
public void contextLoads() {
}
@Test
public void testUserService() {
/*
User user = userService.findByEmail("wujc12@live.com");
System.out.println("User name: " + user.getName()); */
User user = userService.findByCellPhone("18611454314");
user.setPassword("NewPassword");
userService.save(user);
}
}
| UTF-8 | Java | 869 | java | DbdemoApplicationTests.java | Java | [
{
"context": " /*\n User user = userService.findByEmail(\"wujc12@live.com\");\n System.out.println(\"User name: \" + use",
"end": 654,
"score": 0.999922513961792,
"start": 639,
"tag": "EMAIL",
"value": "wujc12@live.com"
},
{
"context": "llPhone(\"18611454314\");\n user.setPassword(\"NewPassword\");\n userService.save(user);\n\n }\n\n}\n",
"end": 823,
"score": 0.9990835189819336,
"start": 812,
"tag": "PASSWORD",
"value": "NewPassword"
}
]
| null | []
| package com.jinchao.dbdemo;
import com.jinchao.dbdemo.entity.User;
import com.jinchao.dbdemo.service.UserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class DbdemoApplicationTests {
@Autowired
UserService userService;
@Test
public void contextLoads() {
}
@Test
public void testUserService() {
/*
User user = userService.findByEmail("<EMAIL>");
System.out.println("User name: " + user.getName()); */
User user = userService.findByCellPhone("18611454314");
user.setPassword("<PASSWORD>");
userService.save(user);
}
}
| 860 | 0.720368 | 0.704258 | 35 | 23.828571 | 22.188139 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 15 |
c37615f9e55c0d054e2361ed378a5c169f2bcd8f | 10,136,122,826,280 | e6cc642b42ebec4ff77c69af0d78c9c806db26db | /src/main/java/glimpse/models/Destination.java | 71df5d8422098d3ddb0f0a4ab7ab78a5e0851d50 | [
"Apache-2.0"
]
| permissive | kunal-exuberant/glimpse | https://github.com/kunal-exuberant/glimpse | 5d3209bd1da6378544f8b9765e9bf770d1b35018 | d9c7595942bce9306839d458115263fd19ece962 | refs/heads/master | 2022-12-03T19:43:25.081000 | 2019-07-18T16:18:25 | 2019-07-18T16:18:25 | 194,422,159 | 0 | 0 | Apache-2.0 | false | 2022-11-16T08:26:50 | 2019-06-29T15:45:19 | 2019-07-18T16:19:13 | 2022-11-16T08:26:48 | 824 | 0 | 0 | 5 | HTML | false | false | package glimpse.models;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Destination implements Serializable {
public static int DESTINATION_ID;
private int id;
private String name;
private Type type;
private int distance;
private String description;
private Address address;
private List<String> images;
public Destination(String name){
this.id = ++DESTINATION_ID;
this.name = name;
}
public Destination(int id, String name){
this.id = id;
this.name = name;
}
} | UTF-8 | Java | 694 | java | Destination.java | Java | []
| null | []
| package glimpse.models;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Destination implements Serializable {
public static int DESTINATION_ID;
private int id;
private String name;
private Type type;
private int distance;
private String description;
private Address address;
private List<String> images;
public Destination(String name){
this.id = ++DESTINATION_ID;
this.name = name;
}
public Destination(int id, String name){
this.id = id;
this.name = name;
}
} | 694 | 0.70317 | 0.70317 | 31 | 21.419355 | 13.490197 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.612903 | false | false | 15 |
8f5972f91283962c51db7afbef080060433f7b0a | 31,825,707,695,249 | 303c33ea49d9e9f4c5ef5aa261060a1a57dbf4d9 | /src/com/chenjin/query/PageResult.java | 226b86487a7cc4fe274040a395d997a10f75abd7 | [
"MIT"
]
| permissive | Tremble666/PermissionSystem | https://github.com/Tremble666/PermissionSystem | bda79c599d1e1c0b73882cc2701e16ce277f21df | 56a52ab20405d491b4ee8e1f5672b87d0ff3731a | refs/heads/master | 2020-03-07T21:02:34.521000 | 2018-05-23T13:45:54 | 2018-05-23T13:45:54 | 127,715,314 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.chenjin.query;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
//分页的结果集对象,封装了所有的分页对象
@Getter
public class PageResult {
private List listData;//当前页的结果集:通过sql查询得来
private Integer totalCount;//结果总数,通过sql查询
private Integer currentPage=1;//当前页,用户设置
private Integer pageSize=5;//每页显示多少条数据,用户设置
private Integer beginPage=1;//首页
private Integer prevPage;//上页,计算得到
private Integer nextPage;//下页,计算得到
private Integer totalPage;//末页/总页数,计算得到
public static PageResult empty(int pageSize){
return new PageResult(Collections.emptyList(),0,1,pageSize);
}
public PageResult(List listData, Integer totalCount, Integer currentPage,
Integer pageSize) {
this.listData = listData;
this.totalCount = totalCount;
this.currentPage = currentPage;
this.pageSize = pageSize;
this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize+1;
this.prevPage = this.currentPage - 1 >= 1 ? this.currentPage -1 : 1;
this.nextPage = this.currentPage + 1 <= this.totalPage ? this.currentPage + 1 : this.totalPage;
}
}
| UTF-8 | Java | 1,295 | java | PageResult.java | Java | []
| null | []
| package com.chenjin.query;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
//分页的结果集对象,封装了所有的分页对象
@Getter
public class PageResult {
private List listData;//当前页的结果集:通过sql查询得来
private Integer totalCount;//结果总数,通过sql查询
private Integer currentPage=1;//当前页,用户设置
private Integer pageSize=5;//每页显示多少条数据,用户设置
private Integer beginPage=1;//首页
private Integer prevPage;//上页,计算得到
private Integer nextPage;//下页,计算得到
private Integer totalPage;//末页/总页数,计算得到
public static PageResult empty(int pageSize){
return new PageResult(Collections.emptyList(),0,1,pageSize);
}
public PageResult(List listData, Integer totalCount, Integer currentPage,
Integer pageSize) {
this.listData = listData;
this.totalCount = totalCount;
this.currentPage = currentPage;
this.pageSize = pageSize;
this.totalPage = totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize+1;
this.prevPage = this.currentPage - 1 >= 1 ? this.currentPage -1 : 1;
this.nextPage = this.currentPage + 1 <= this.totalPage ? this.currentPage + 1 : this.totalPage;
}
}
| 1,295 | 0.75291 | 0.741271 | 37 | 29.18919 | 25.392952 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.648649 | false | false | 15 |
ac90018bc7f3592ca60b40afb8bb77ec7ac51f32 | 25,864,293,076,408 | f7853cd23045f29f93d28f40ab9bada7ba73e350 | /src/main/java/kz/lessons/lesson11/Pet.java | e916060ec08e61df57ab2c2d979cabf7ae47cbdd | []
| no_license | MyWayToJavaJunior/lesson11v3 | https://github.com/MyWayToJavaJunior/lesson11v3 | ea49097961085e10a5434325ebe808b005f453e4 | 6df3675cfc1aababc54f1f9380455284e77fd5d0 | refs/heads/master | 2016-09-06T01:08:56.394000 | 2015-07-13T06:46:27 | 2015-07-13T06:46:27 | 38,978,416 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package kz.lessons.lesson11;
/**
* абстрактный класс предок
* животных
*/
public abstract class Pet {
public String name;
public int age;
public Pet(final String name, final int age) {
this.name = name;
this.age = age;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Pet)) return false;
Pet entry = (Pet) obj;
return this.hashCode() == entry.hashCode() && name.equals(entry.name) && age == entry.age;
}
@Override
public int hashCode() {
int hash = 37;
hash = hash * 17 + name.hashCode();
hash = hash * 17 + age;
return hash;
}
@Override
public String toString() {
return "[ " + name + " : " + age +" ]";
}
}
| UTF-8 | Java | 800 | java | Pet.java | Java | []
| null | []
| package kz.lessons.lesson11;
/**
* абстрактный класс предок
* животных
*/
public abstract class Pet {
public String name;
public int age;
public Pet(final String name, final int age) {
this.name = name;
this.age = age;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof Pet)) return false;
Pet entry = (Pet) obj;
return this.hashCode() == entry.hashCode() && name.equals(entry.name) && age == entry.age;
}
@Override
public int hashCode() {
int hash = 37;
hash = hash * 17 + name.hashCode();
hash = hash * 17 + age;
return hash;
}
@Override
public String toString() {
return "[ " + name + " : " + age +" ]";
}
}
| 800 | 0.546753 | 0.536364 | 36 | 20.388889 | 20.019821 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.388889 | false | false | 15 |
ecfc20e434e02dfdd85e15336d75540b1484a848 | 2,662,879,792,322 | 12f15189895b82988c7afd16be3856bda3d2d02b | /src/main/java/com/example/demo/chapter1/TY.java | 91fa897e3f5830c8d5e52df41f11f3def3b6489b | []
| no_license | ESPataPon/test_static_file | https://github.com/ESPataPon/test_static_file | d42e3dec4b7b4ca7e34db67634268bb3fbe5d0b8 | dd4431143a31c2eed78866468dfe7dd3a8f5d4b4 | refs/heads/master | 2021-09-02T09:41:02.445000 | 2018-01-01T14:59:46 | 2018-01-01T14:59:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.chapter1;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created with IntelliJ IDEA.
* User: za-lvjian
* Date: 2017/9/29 17:44
* DESC:
*/
public class TY {
public static void main(String[] args) {
// 按指定模式在字符串查找
String line = "This order was placed for QT3000! OK?";
String pattern = "(.*)";
// 创建 Pattern 对象
Pattern r = Pattern.compile(pattern);
// 现在创建 matcher 对象
Matcher m = r.matcher(line);
if (m.find()) {
System.out.println("Found value: " + m.group(0));
System.out.println("Found value: " + m.group(1));
// System.out.println("Found value: " + m.group(2));
// System.out.println("Found value: " + m.group(3));
} else {
System.out.println("NO MATCH");
}
Pattern pattern2 = Pattern.compile("(.*)");
Matcher matcher = r.matcher("This order was placed for QT3000");
matcher.find();
System.out.println(matcher.group(0));
}
}
| UTF-8 | Java | 1,107 | java | TY.java | Java | [
{
"context": "tern;\n\n/**\n * Created with IntelliJ IDEA.\n * User: za-lvjian\n * Date: 2017/9/29 17:44\n * DESC:\n */\npublic clas",
"end": 154,
"score": 0.9996530413627625,
"start": 145,
"tag": "USERNAME",
"value": "za-lvjian"
}
]
| null | []
| package com.example.demo.chapter1;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Created with IntelliJ IDEA.
* User: za-lvjian
* Date: 2017/9/29 17:44
* DESC:
*/
public class TY {
public static void main(String[] args) {
// 按指定模式在字符串查找
String line = "This order was placed for QT3000! OK?";
String pattern = "(.*)";
// 创建 Pattern 对象
Pattern r = Pattern.compile(pattern);
// 现在创建 matcher 对象
Matcher m = r.matcher(line);
if (m.find()) {
System.out.println("Found value: " + m.group(0));
System.out.println("Found value: " + m.group(1));
// System.out.println("Found value: " + m.group(2));
// System.out.println("Found value: " + m.group(3));
} else {
System.out.println("NO MATCH");
}
Pattern pattern2 = Pattern.compile("(.*)");
Matcher matcher = r.matcher("This order was placed for QT3000");
matcher.find();
System.out.println(matcher.group(0));
}
}
| 1,107 | 0.561502 | 0.537089 | 39 | 26.307692 | 21.82583 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.410256 | false | false | 15 |
379cec6a78838d3d83bce8b6e5d308653c5963fd | 2,860,448,283,412 | ba16903416bb50e23c236a74cd2db2ca10df9364 | /WeatherReader/src/main/java/com/example/tianqitong/fragment/News_Fragment.java | 06e182e6d466b4c6badf7e74070aae3094e7df14 | []
| no_license | 1797732834/MyProject | https://github.com/1797732834/MyProject | 02062f06a882077401d617b5c7e117d3632bf68d | 6e99b81d06fb613748e561c0d09fac0080f7ddb8 | refs/heads/master | 2021-07-13T16:46:13.730000 | 2017-10-19T01:09:35 | 2017-10-19T01:09:35 | 107,480,886 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.tianqitong.fragment;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.example.tianqitong.R;
/**
* Created by Administrator on 2017/6/1 0001.
*/
public class News_Fragment extends Fragment {
View view;
WebView webView;
ProgressDialog dialog;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
init();
return view;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view = View.inflate(getActivity(), R.layout.activity_news,null);
}
void init(){
dialog = new ProgressDialog(getActivity());
dialog.setTitle("正在加载中......");
webView = (WebView) view.findViewById(R.id.news_webView);
webView.loadUrl("http://www.sohu.com/");
// 给webView设置常用属性
WebSettings webSettings = webView.getSettings();
// 设置兼容
webSettings.setJavaScriptEnabled(true);
// 支持缩放
webSettings.setSupportZoom(true);
//处理链接事件
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
// webView.loadUrl(request.getUrl().toString());
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
dialog.show();
}
@Override
public void onPageFinished(WebView view, String url) {
dialog.dismiss();
}
});
}
}
| UTF-8 | Java | 2,129 | java | News_Fragment.java | Java | [
{
"context": "port com.example.tianqitong.R;\n\n\n/**\n * Created by Administrator on 2017/6/1 0001.\n */\n\npublic class News_Fragment",
"end": 524,
"score": 0.845177948474884,
"start": 511,
"tag": "USERNAME",
"value": "Administrator"
}
]
| null | []
| package com.example.tianqitong.fragment;
import android.app.ProgressDialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.example.tianqitong.R;
/**
* Created by Administrator on 2017/6/1 0001.
*/
public class News_Fragment extends Fragment {
View view;
WebView webView;
ProgressDialog dialog;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
init();
return view;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
view = View.inflate(getActivity(), R.layout.activity_news,null);
}
void init(){
dialog = new ProgressDialog(getActivity());
dialog.setTitle("正在加载中......");
webView = (WebView) view.findViewById(R.id.news_webView);
webView.loadUrl("http://www.sohu.com/");
// 给webView设置常用属性
WebSettings webSettings = webView.getSettings();
// 设置兼容
webSettings.setJavaScriptEnabled(true);
// 支持缩放
webSettings.setSupportZoom(true);
//处理链接事件
webView.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
// webView.loadUrl(request.getUrl().toString());
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
dialog.show();
}
@Override
public void onPageFinished(WebView view, String url) {
dialog.dismiss();
}
});
}
}
| 2,129 | 0.658161 | 0.652865 | 70 | 28.671429 | 24.546003 | 123 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.585714 | false | false | 15 |
621a19ed1af496a91901ee3a3c12cfb02c12f27a | 9,560,597,248,545 | a761db79832a2d984f6d8156821ba5a6e6635ed0 | /build/generated-sources/ap-source-output/modelo/CategoriasProductos_.java | 72d29d5af6caec82650fb7f71cd08c620ed9fa62 | []
| no_license | RogerCHDK/BandgramJavaWeb | https://github.com/RogerCHDK/BandgramJavaWeb | 456b47a78ea25db78c5900bba373e59a6766b3b5 | 0350131c7375590a469d6f8f2238b5d44580b988 | refs/heads/main | 2023-06-06T07:46:19.145000 | 2021-06-27T00:01:52 | 2021-06-27T00:01:52 | 317,421,438 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package modelo;
import javax.annotation.Generated;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
import modelo.Productos;
@Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2021-01-25T13:21:28")
@StaticMetamodel(CategoriasProductos.class)
public class CategoriasProductos_ {
public static volatile CollectionAttribute<CategoriasProductos, Productos> productosCollection;
public static volatile SingularAttribute<CategoriasProductos, Long> id;
public static volatile SingularAttribute<CategoriasProductos, String> nombre;
public static volatile SingularAttribute<CategoriasProductos, Integer> status;
} | UTF-8 | Java | 745 | java | CategoriasProductos_.java | Java | []
| null | []
| package modelo;
import javax.annotation.Generated;
import javax.persistence.metamodel.CollectionAttribute;
import javax.persistence.metamodel.SingularAttribute;
import javax.persistence.metamodel.StaticMetamodel;
import modelo.Productos;
@Generated(value="EclipseLink-2.5.2.v20140319-rNA", date="2021-01-25T13:21:28")
@StaticMetamodel(CategoriasProductos.class)
public class CategoriasProductos_ {
public static volatile CollectionAttribute<CategoriasProductos, Productos> productosCollection;
public static volatile SingularAttribute<CategoriasProductos, Long> id;
public static volatile SingularAttribute<CategoriasProductos, String> nombre;
public static volatile SingularAttribute<CategoriasProductos, Integer> status;
} | 745 | 0.833557 | 0.8 | 18 | 40.444443 | 32.528999 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.833333 | false | false | 15 |
f11744dc9cd32aa7ba8c8b64fe7609cda5ee0261 | 25,280,177,541,649 | a8df5318f1a00ecdd9b3052e9a0c399e33bd6f25 | /app/src/main/java/com/example/reedme/model/SessionInfoModel.java | 9b26391331147bda42b782b788d651c8e3ceb0ec | []
| no_license | MPTechnolabs/Reedme | https://github.com/MPTechnolabs/Reedme | f240d160b821cb576daaad9f1fedf40a96d6caee | b5d86df9ba16f7695958644b1617981548a2fdfe | refs/heads/master | 2021-01-17T01:09:18.756000 | 2016-07-21T05:00:29 | 2016-07-21T05:00:29 | 62,387,002 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.reedme.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by SHRIYA17 on 04-Apr-16.
*/
public class SessionInfoModel {
@SerializedName("ResponseCode")
@Expose
private Integer ResponseCode;
@SerializedName("ResponseStatus")
@Expose
private String ResponseStatus;
@SerializedName("ResponseMessage")
@Expose
private String ResponseMessage;
/**
* @return The ResponseCode
*/
public Integer getResponseCode() {
return ResponseCode;
}
/**
* @param ResponseCode The ResponseCode
*/
public void setResponseCode(Integer ResponseCode) {
this.ResponseCode = ResponseCode;
}
/**
* @return The ResponseStatus
*/
public String getResponseStatus() {
return ResponseStatus;
}
/**
* @param ResponseStatus The ResponseStatus
*/
public void setResponseStatus(String ResponseStatus) {
this.ResponseStatus = ResponseStatus;
}
/**
* @return The ResponseMessage
*/
public String getResponseMessage() {
return ResponseMessage;
}
/**
* @param ResponseMessage The ResponseMessage
*/
public void setResponseMessage(String ResponseMessage) {
this.ResponseMessage = ResponseMessage;
}
}
| UTF-8 | Java | 1,433 | java | SessionInfoModel.java | Java | [
{
"context": ".annotations.SerializedName;\r\n\r\n/**\r\n * Created by SHRIYA17 on 04-Apr-16.\r\n */\r\npublic class SessionInfoModel",
"end": 162,
"score": 0.9996706247329712,
"start": 154,
"tag": "USERNAME",
"value": "SHRIYA17"
}
]
| null | []
| package com.example.reedme.model;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Created by SHRIYA17 on 04-Apr-16.
*/
public class SessionInfoModel {
@SerializedName("ResponseCode")
@Expose
private Integer ResponseCode;
@SerializedName("ResponseStatus")
@Expose
private String ResponseStatus;
@SerializedName("ResponseMessage")
@Expose
private String ResponseMessage;
/**
* @return The ResponseCode
*/
public Integer getResponseCode() {
return ResponseCode;
}
/**
* @param ResponseCode The ResponseCode
*/
public void setResponseCode(Integer ResponseCode) {
this.ResponseCode = ResponseCode;
}
/**
* @return The ResponseStatus
*/
public String getResponseStatus() {
return ResponseStatus;
}
/**
* @param ResponseStatus The ResponseStatus
*/
public void setResponseStatus(String ResponseStatus) {
this.ResponseStatus = ResponseStatus;
}
/**
* @return The ResponseMessage
*/
public String getResponseMessage() {
return ResponseMessage;
}
/**
* @param ResponseMessage The ResponseMessage
*/
public void setResponseMessage(String ResponseMessage) {
this.ResponseMessage = ResponseMessage;
}
}
| 1,433 | 0.62596 | 0.621773 | 63 | 20.746031 | 18.645369 | 60 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.190476 | false | false | 15 |
8455f4c8ae19cdf7eda30d9e356fd8180e97aacb | 31,559,419,739,265 | f4ae41a894607f248fa08c3f5613795e45d10614 | /core/src/utils/CameraStyles.java | 2412116061c183b2886552dbfd5cc7a1978cf12a | []
| no_license | JelX7ouss/libgdx-tiled-box2d | https://github.com/JelX7ouss/libgdx-tiled-box2d | 412fc30c515831b3f3033f9c46494b0a8c8ae088 | a1c1016082e5be8b57983d5360bb9941f8df9b03 | refs/heads/master | 2016-09-13T09:16:42.083000 | 2016-06-22T03:38:55 | 2016-06-22T03:38:55 | 61,678,371 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package utils;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
public class CameraStyles {
public static void lockOnTarget(Camera camera, Vector2 target){
Vector3 position = camera.position;
position.x = target.x;
position.y = target.y;
camera.position.set(position);
camera.update();
}
public static void followTarget(Camera camera, Vector2 target){
Vector3 position = camera.position;
position.x += (target.x - position.x) * .1f;
position.y += (target.y - position.y) * .1f;
camera.position.set(position);
camera.update();
}
}
| UTF-8 | Java | 631 | java | CameraStyles.java | Java | []
| null | []
| package utils;
import com.badlogic.gdx.graphics.Camera;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
public class CameraStyles {
public static void lockOnTarget(Camera camera, Vector2 target){
Vector3 position = camera.position;
position.x = target.x;
position.y = target.y;
camera.position.set(position);
camera.update();
}
public static void followTarget(Camera camera, Vector2 target){
Vector3 position = camera.position;
position.x += (target.x - position.x) * .1f;
position.y += (target.y - position.y) * .1f;
camera.position.set(position);
camera.update();
}
}
| 631 | 0.721078 | 0.708399 | 26 | 23.26923 | 19.813665 | 64 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.653846 | false | false | 15 |
a9d776edbf54327bc637add775d9534ff02f98f5 | 26,946,624,851,078 | 6f543367d1a3aa3889efee9ea143301de6c7286f | /app/src/main/java/com/example/gidm/db/DatabaseClient.java | 7fb5925d17869274e8d412bd24db1db64b6fd1af | []
| no_license | samahetfield/GIDM | https://github.com/samahetfield/GIDM | 61ce9fc29e33c24e762006760dc6ba516ca62e85 | 3eb80271c5056d9286be6df72517aa07c7728665 | refs/heads/master | 2020-05-07T13:12:30.874000 | 2019-05-25T15:44:33 | 2019-05-25T15:44:33 | 180,539,286 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.gidm.db;
import android.arch.persistence.room.Room;
import android.content.Context;
public class DatabaseClient {
private Context mCtx;
private static DatabaseClient mInstance;
//our app database object
private AppDatabase appDatabase;
private DatabaseClient(Context ctx){
this.mCtx = ctx;
appDatabase = Room.databaseBuilder(mCtx, AppDatabase.class, "GIDM").build();
}
public static synchronized DatabaseClient getInstance(Context ctx){
if(mInstance == null)
mInstance = new DatabaseClient(ctx);
return mInstance;
}
public AppDatabase getAppDatabase(){
return appDatabase;
}
}
| UTF-8 | Java | 696 | java | DatabaseClient.java | Java | []
| null | []
| package com.example.gidm.db;
import android.arch.persistence.room.Room;
import android.content.Context;
public class DatabaseClient {
private Context mCtx;
private static DatabaseClient mInstance;
//our app database object
private AppDatabase appDatabase;
private DatabaseClient(Context ctx){
this.mCtx = ctx;
appDatabase = Room.databaseBuilder(mCtx, AppDatabase.class, "GIDM").build();
}
public static synchronized DatabaseClient getInstance(Context ctx){
if(mInstance == null)
mInstance = new DatabaseClient(ctx);
return mInstance;
}
public AppDatabase getAppDatabase(){
return appDatabase;
}
}
| 696 | 0.691092 | 0.691092 | 28 | 23.857143 | 22.006029 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.464286 | false | false | 15 |
70546ddfeb287b3ced405dd03fee621d3a839278 | 30,416,958,449,003 | cf54b66ae0435496efb6d0f1684add1fdaf25e6c | /项目/observe/ObserverMain.java | b3ac46c338ea323890edeb9e3130733ad0083461 | []
| no_license | lgg476864889/Code | https://github.com/lgg476864889/Code | de312f1affcef26b3ecbbefb369af7c448bd292a | edaeacf5907b9572185a835a99daa8c0e2c28a57 | refs/heads/master | 2023-04-06T04:21:30.387000 | 2021-04-02T00:16:18 | 2021-04-02T00:16:18 | 343,332,801 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.test.observe;
/**
* @Author lggui1
* @Date 2021/4/1
* @Description 测试观察者模式类
*
*观察者模式主要是分两个角色,1.观察者,2.观察目标(被观察者)
* 观察者主要实现抽象观察者的更新方法update(自定义的抽象观察者名字可以不一样,这个例子是继承java类的)
* 观察目标主要实现抽象观察目标的通知,也包括新增观察者和删除观察者的方法;
* 观察目标的通知会调用观察者的update
**/
public class ObserverMain {
public static void main(String[] args) {
// 创建一个观察目标
JavaStackObservable javaStackObservable = new JavaStackObservable();
// 添加观察者
javaStackObservable.addObserver(new ReaderObserver("小明"));
javaStackObservable.addObserver(new ReaderObserver("小张"));
javaStackObservable.addObserver(new ReaderObserver("小爱"));
javaStackObservable.addObserver(new CopyObserver("超级读书"));
javaStackObservable.addObserver(new CopyObserver("酷爱读书"));
// 发表文章
javaStackObservable.publish("什么是观察者模式?");
// 发表文章
javaStackObservable.publish("JVM调优推荐!!");
System.out.println("我在发布之后做其他事情");
}
}
| UTF-8 | Java | 1,347 | java | ObserverMain.java | Java | [
{
"context": "package com.test.observe;\n\n/**\n * @Author lggui1\n * @Date 2021/4/1\n * @Description 测试观察者模式类\n *\n *观",
"end": 48,
"score": 0.9995272159576416,
"start": 42,
"tag": "USERNAME",
"value": "lggui1"
}
]
| null | []
| package com.test.observe;
/**
* @Author lggui1
* @Date 2021/4/1
* @Description 测试观察者模式类
*
*观察者模式主要是分两个角色,1.观察者,2.观察目标(被观察者)
* 观察者主要实现抽象观察者的更新方法update(自定义的抽象观察者名字可以不一样,这个例子是继承java类的)
* 观察目标主要实现抽象观察目标的通知,也包括新增观察者和删除观察者的方法;
* 观察目标的通知会调用观察者的update
**/
public class ObserverMain {
public static void main(String[] args) {
// 创建一个观察目标
JavaStackObservable javaStackObservable = new JavaStackObservable();
// 添加观察者
javaStackObservable.addObserver(new ReaderObserver("小明"));
javaStackObservable.addObserver(new ReaderObserver("小张"));
javaStackObservable.addObserver(new ReaderObserver("小爱"));
javaStackObservable.addObserver(new CopyObserver("超级读书"));
javaStackObservable.addObserver(new CopyObserver("酷爱读书"));
// 发表文章
javaStackObservable.publish("什么是观察者模式?");
// 发表文章
javaStackObservable.publish("JVM调优推荐!!");
System.out.println("我在发布之后做其他事情");
}
}
| 1,347 | 0.691192 | 0.681865 | 31 | 30.129032 | 24.175089 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.354839 | false | false | 15 |
c9c3b194bd5c09cece622781155ea51cc92c1042 | 8,452,495,694,261 | 863f5bd136b671f17a606394d7f17fecc8b797c3 | /group07/178007127/001DataStructure/src/main/java/com/easy/util/myqueue/Queue.java | 17238af545c7396bd76305416b395d112a51070f | []
| no_license | andy-sqy/coding2017-1 | https://github.com/andy-sqy/coding2017-1 | d0f2f0b175aef8b08ce2c570cbbbca95e94fe15e | d92bdf62cef48645739173a85bdf1c522f5f284e | refs/heads/master | 2020-03-03T14:22:01.859000 | 2017-02-26T07:05:34 | 2017-02-26T07:05:34 | 83,185,356 | 0 | 0 | null | true | 2017-02-26T05:29:08 | 2017-02-26T05:29:08 | 2017-02-23T05:10:26 | 2017-02-26T04:17:58 | 114 | 0 | 0 | 0 | null | null | null | package com.easy.util.myqueue;
import com.easy.util.mylinkedlist.LinkedList;
public class Queue {
LinkedList linkedList;
public Queue(){
linkedList=new LinkedList();
}
public void enQueue(Object o){
linkedList.add(o);
}
public Object deQueue(){
return linkedList.removeFirst();
}
public boolean isEmpty(){
return size()==0;
}
public int size(){
return linkedList.size();
}
}
| UTF-8 | Java | 409 | java | Queue.java | Java | []
| null | []
| package com.easy.util.myqueue;
import com.easy.util.mylinkedlist.LinkedList;
public class Queue {
LinkedList linkedList;
public Queue(){
linkedList=new LinkedList();
}
public void enQueue(Object o){
linkedList.add(o);
}
public Object deQueue(){
return linkedList.removeFirst();
}
public boolean isEmpty(){
return size()==0;
}
public int size(){
return linkedList.size();
}
}
| 409 | 0.689487 | 0.687042 | 27 | 14.148149 | 13.558389 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.296296 | false | false | 15 |
fcc7450532f5a61e23bf0c84eb2980244603eaf6 | 16,939,351,081,541 | 92f07527c6c643e51a6ec6359475fecc6b44d73e | /src/main/java/seedu/address/logic/commands/CommandResult.java | 4467949692feac3be732d941374b1ccf45c04a14 | [
"MIT"
]
| permissive | AY2122S1-CS2103T-W08-4/tp | https://github.com/AY2122S1-CS2103T-W08-4/tp | 633d43b1ec25d676730a5daa49ceff5b6cc6b479 | 4f4b4e635995f41a7438df8f81181214288aa5f5 | refs/heads/master | 2023-08-27T18:16:51.430000 | 2021-11-08T16:46:48 | 2021-11-08T16:46:48 | 406,352,004 | 0 | 6 | NOASSERTION | true | 2021-11-12T14:01:25 | 2021-09-14T12:10:44 | 2021-11-08T16:46:57 | 2021-11-08T16:46:49 | 23,702 | 0 | 5 | 3 | Java | false | false | package seedu.address.logic.commands;
import static java.util.Objects.requireNonNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.chart.PieChart;
/**
* Represents the result of a command execution.
*/
public class CommandResult {
private final String feedbackToUser;
private final Map<String, Map<String, Integer>> data;
/** Help information should be shown to the user. */
private final boolean showHelp;
/** The application should exit. */
private final boolean exit;
/**
* Constructs a {@code CommandResult} with the specified fields.
*/
public CommandResult(String feedbackToUser, boolean showHelp,
boolean exit, Map<String, Map<String, Integer>> data) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.data = data;
}
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
this(feedbackToUser, showHelp, exit, new HashMap<>());
}
/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser} and {@code data},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser, Map<String, Map<String, Integer>> data) {
this(feedbackToUser, false, false, data);
}
/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser) {
this(feedbackToUser, false, false, new HashMap<>());
}
public String getFeedbackToUser() {
return feedbackToUser;
}
public List<String> getPieChartTitles() {
return new ArrayList<>(data.keySet());
}
public List<ObservableList<PieChart.Data>> getPieChartDatas() {
if (data.isEmpty()) {
return null;
}
List<ObservableList<PieChart.Data>> pieChartDatas = new ArrayList<>();
for (Map.Entry<String, Map<String, Integer>> entry : data.entrySet()) {
Map<String, Integer> map = entry.getValue();
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
for (Map.Entry<String, Integer> item : map.entrySet()) {
String key = item.getKey();
Integer value = item.getValue();
pieChartData.add(new PieChart.Data(key, value));
}
pieChartDatas.add(pieChartData);
}
return pieChartDatas;
}
public boolean isShowFeedback() {
return data.isEmpty();
}
public boolean isShowPieChart() {
return !data.isEmpty();
}
public boolean isShowHelp() {
return showHelp;
}
public boolean isExit() {
return exit;
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
// instanceof handles nulls
if (!(other instanceof CommandResult)) {
return false;
}
CommandResult otherCommandResult = (CommandResult) other;
return feedbackToUser.equals(otherCommandResult.feedbackToUser)
&& showHelp == otherCommandResult.showHelp
&& exit == otherCommandResult.exit;
}
@Override
public int hashCode() {
return Objects.hash(feedbackToUser, showHelp, exit);
}
}
| UTF-8 | Java | 3,664 | java | CommandResult.java | Java | []
| null | []
| package seedu.address.logic.commands;
import static java.util.Objects.requireNonNull;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.chart.PieChart;
/**
* Represents the result of a command execution.
*/
public class CommandResult {
private final String feedbackToUser;
private final Map<String, Map<String, Integer>> data;
/** Help information should be shown to the user. */
private final boolean showHelp;
/** The application should exit. */
private final boolean exit;
/**
* Constructs a {@code CommandResult} with the specified fields.
*/
public CommandResult(String feedbackToUser, boolean showHelp,
boolean exit, Map<String, Map<String, Integer>> data) {
this.feedbackToUser = requireNonNull(feedbackToUser);
this.showHelp = showHelp;
this.exit = exit;
this.data = data;
}
public CommandResult(String feedbackToUser, boolean showHelp, boolean exit) {
this(feedbackToUser, showHelp, exit, new HashMap<>());
}
/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser} and {@code data},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser, Map<String, Map<String, Integer>> data) {
this(feedbackToUser, false, false, data);
}
/**
* Constructs a {@code CommandResult} with the specified {@code feedbackToUser},
* and other fields set to their default value.
*/
public CommandResult(String feedbackToUser) {
this(feedbackToUser, false, false, new HashMap<>());
}
public String getFeedbackToUser() {
return feedbackToUser;
}
public List<String> getPieChartTitles() {
return new ArrayList<>(data.keySet());
}
public List<ObservableList<PieChart.Data>> getPieChartDatas() {
if (data.isEmpty()) {
return null;
}
List<ObservableList<PieChart.Data>> pieChartDatas = new ArrayList<>();
for (Map.Entry<String, Map<String, Integer>> entry : data.entrySet()) {
Map<String, Integer> map = entry.getValue();
ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList();
for (Map.Entry<String, Integer> item : map.entrySet()) {
String key = item.getKey();
Integer value = item.getValue();
pieChartData.add(new PieChart.Data(key, value));
}
pieChartDatas.add(pieChartData);
}
return pieChartDatas;
}
public boolean isShowFeedback() {
return data.isEmpty();
}
public boolean isShowPieChart() {
return !data.isEmpty();
}
public boolean isShowHelp() {
return showHelp;
}
public boolean isExit() {
return exit;
}
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
// instanceof handles nulls
if (!(other instanceof CommandResult)) {
return false;
}
CommandResult otherCommandResult = (CommandResult) other;
return feedbackToUser.equals(otherCommandResult.feedbackToUser)
&& showHelp == otherCommandResult.showHelp
&& exit == otherCommandResult.exit;
}
@Override
public int hashCode() {
return Objects.hash(feedbackToUser, showHelp, exit);
}
}
| 3,664 | 0.631823 | 0.631823 | 131 | 26.969465 | 26.056 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.541985 | false | false | 15 |
276343ecde4ad89e1df7c493e491f19addaee587 | 18,640,158,126,726 | 03db87d5633470bf236e8f1d23857943606f32fb | /cendev-app/cendev-personallogin/src/main/java/com/censoft/personallogin/util/UnifiedCreditCodeUtil.java | de54f616662a66ad2a614e7fe498841fd7cd3179 | []
| no_license | He106165/register-cloud-app | https://github.com/He106165/register-cloud-app | 96d4a6d53f427bcc33d2b17f45bef994f796dfd7 | 4bf520f758c751a92c2698cf292dea7a6e2939ac | refs/heads/main | 2023-08-11T14:09:06.195000 | 2021-10-07T07:55:04 | 2021-10-07T07:55:04 | 414,509,087 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.censoft.personallogin.util;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import java.util.List;
/**
* @Description:统一信用代码的util
* @Author: lcj
* @Date: Created in 2020-06-30 10:42:26
*/
public class UnifiedCreditCodeUtil {
/**
* 最后一位编码
*/
private static final List<String> LAST_CODE = Arrays.asList(
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "J", "K",
"L", "M", "N", "P", "Q", "R", "T", "U", "W", "X", "Y"
);
/**
* 加权因子
*/
private static final Integer[] FACTOR = {1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28};
public static boolean checkUnifiedCreditCode(String unifiedCreditCode) {
unifiedCreditCode = trim(unifiedCreditCode);
// 校验身份证
if (StringUtils.isBlank(unifiedCreditCode) || unifiedCreditCode.length() != 18) {
return false;
}
final String upperCaseCode = unifiedCreditCode.toUpperCase();
// 统一社会信用代码由18位阿拉伯数字或英文大写字母表示(不包括I,O,Z,S,V以防止和阿拉伯字母混淆)-->V:???关我毛事?
if (upperCaseCode.contains("I") || upperCaseCode.contains("O") || upperCaseCode.contains("Z") || upperCaseCode.contains("S") || upperCaseCode.contains("V")) {
return false;
}
char[] chars = upperCaseCode.toCharArray();
int sumCode = 0;
for (int i = 0; i < 17; i++) {
String code = String.valueOf(chars[i]);
int lastCodeIndex = LAST_CODE.indexOf(code);
Integer factorNum = FACTOR[i];
sumCode += (lastCodeIndex * factorNum);
}
int modCode = 31 - sumCode % 31;
String lastCode = LAST_CODE.get(modCode % 31);
return lastCode.equals(String.valueOf(chars[17]));
}
/**
* 去空格
*
* @param str 处理字符串
* @return 结果字符串
*/
private static String trim(String str) {
return str.replaceAll("\n", "").replace(" ", "").trim();
}
} | UTF-8 | Java | 2,178 | java | UnifiedCreditCodeUtil.java | Java | [
{
"context": "List;\n\n/**\n * @Description:统一信用代码的util\n * @Author: lcj\n * @Date: Created in 2020-06-30 10:42:26\n */\npubl",
"end": 182,
"score": 0.9996252059936523,
"start": 179,
"tag": "USERNAME",
"value": "lcj"
}
]
| null | []
| package com.censoft.personallogin.util;
import org.apache.commons.lang.StringUtils;
import java.util.Arrays;
import java.util.List;
/**
* @Description:统一信用代码的util
* @Author: lcj
* @Date: Created in 2020-06-30 10:42:26
*/
public class UnifiedCreditCodeUtil {
/**
* 最后一位编码
*/
private static final List<String> LAST_CODE = Arrays.asList(
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"A", "B", "C", "D", "E", "F", "G", "H", "J", "K",
"L", "M", "N", "P", "Q", "R", "T", "U", "W", "X", "Y"
);
/**
* 加权因子
*/
private static final Integer[] FACTOR = {1, 3, 9, 27, 19, 26, 16, 17, 20, 29, 25, 13, 8, 24, 10, 30, 28};
public static boolean checkUnifiedCreditCode(String unifiedCreditCode) {
unifiedCreditCode = trim(unifiedCreditCode);
// 校验身份证
if (StringUtils.isBlank(unifiedCreditCode) || unifiedCreditCode.length() != 18) {
return false;
}
final String upperCaseCode = unifiedCreditCode.toUpperCase();
// 统一社会信用代码由18位阿拉伯数字或英文大写字母表示(不包括I,O,Z,S,V以防止和阿拉伯字母混淆)-->V:???关我毛事?
if (upperCaseCode.contains("I") || upperCaseCode.contains("O") || upperCaseCode.contains("Z") || upperCaseCode.contains("S") || upperCaseCode.contains("V")) {
return false;
}
char[] chars = upperCaseCode.toCharArray();
int sumCode = 0;
for (int i = 0; i < 17; i++) {
String code = String.valueOf(chars[i]);
int lastCodeIndex = LAST_CODE.indexOf(code);
Integer factorNum = FACTOR[i];
sumCode += (lastCodeIndex * factorNum);
}
int modCode = 31 - sumCode % 31;
String lastCode = LAST_CODE.get(modCode % 31);
return lastCode.equals(String.valueOf(chars[17]));
}
/**
* 去空格
*
* @param str 处理字符串
* @return 结果字符串
*/
private static String trim(String str) {
return str.replaceAll("\n", "").replace(" ", "").trim();
}
} | 2,178 | 0.553287 | 0.518426 | 62 | 31.403225 | 31.434242 | 166 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.354839 | false | false | 15 |
210482a86def91f29c63bac735cc52ccef0a1304 | 18,640,158,126,612 | 0ef51059396464f445273b3ae3e47ac8b2bcc3bb | /back-end/pfa-bll-v2/src/main/java/com/services/imp/AuthorityServiceImp.java | 66a8665d3109b784765d2c42b3e79dac6607822c | []
| no_license | ManHouda/Application_touristique | https://github.com/ManHouda/Application_touristique | 32c78e452be4b033319feb0a4dbc5c139ffabc45 | d637c057525d1482680d9df37c26b832c7299115 | refs/heads/master | 2023-01-05T20:43:04.568000 | 2020-01-13T10:38:20 | 2020-01-13T10:38:20 | 233,399,346 | 1 | 0 | null | false | 2023-01-01T15:17:35 | 2020-01-12T13:46:43 | 2020-01-13T10:38:23 | 2023-01-01T15:17:35 | 62,529 | 0 | 0 | 36 | Java | false | false | package com.services.imp;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dao.IAuthorityDao;
import com.entities.Authority;
import com.gnericdao.exceptions.EntityNotFoundException;
import com.java.utils.AuthorityType;
import com.services.IAuthorityService;
@Service
public class AuthorityServiceImp implements IAuthorityService {
@Autowired
IAuthorityDao authorityDao;
@Transactional
public Authority getAuthority(AuthorityType authority) throws EntityNotFoundException {
if(authority == AuthorityType.ROLE_TOURIST) {
return authorityDao.find(Long.valueOf(2));
}
if(authority == AuthorityType.ROLE_ADMIN) {
return authorityDao.find(Long.valueOf(1));
}
return null;
}
}
| UTF-8 | Java | 820 | java | AuthorityServiceImp.java | Java | []
| null | []
| package com.services.imp;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dao.IAuthorityDao;
import com.entities.Authority;
import com.gnericdao.exceptions.EntityNotFoundException;
import com.java.utils.AuthorityType;
import com.services.IAuthorityService;
@Service
public class AuthorityServiceImp implements IAuthorityService {
@Autowired
IAuthorityDao authorityDao;
@Transactional
public Authority getAuthority(AuthorityType authority) throws EntityNotFoundException {
if(authority == AuthorityType.ROLE_TOURIST) {
return authorityDao.find(Long.valueOf(2));
}
if(authority == AuthorityType.ROLE_ADMIN) {
return authorityDao.find(Long.valueOf(1));
}
return null;
}
}
| 820 | 0.797561 | 0.795122 | 33 | 23.848484 | 23.599077 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.272727 | false | false | 15 |
65cd896f35872040ee9af081bb4838c5dac3b7e0 | 21,337,397,589,869 | ec329bf40e6611279df3cedfa802bd5a6e0a3798 | /src/main/java/com/harmeetsingh13/java/producers/avroserializer/AvroSpecificProducerOne.java | 0e09c7f109f15821848d899290ddbca769695e39 | []
| no_license | harmeetsingh0013/learning-kafka | https://github.com/harmeetsingh0013/learning-kafka | 601846fcb95d3dc4d38645b1c5ca371a4078a640 | 6cc149fb464a9177ea491f41f8246f731d33c2bf | refs/heads/master | 2021-01-22T04:54:21.983000 | 2017-02-14T07:27:56 | 2017-02-14T07:27:56 | 81,599,237 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.harmeetsingh13.java.producers.avroserializer;
import com.harmeetsingh13.java.Customer;
import io.confluent.kafka.serializers.KafkaAvroSerializer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
import java.io.IOException;
import java.util.Properties;
/**
* Created by harmeet on 10/2/17.
*/
public class AvroSpecificProducerOne {
private static Properties kafkaProps = new Properties();
private static KafkaProducer<String, Customer> kafkaProducer;
static {
kafkaProps.put("bootstrap.servers", "localhost:9092");
kafkaProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
kafkaProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
kafkaProps.put("schema.registry.url", "http://localhost:8081");
kafkaProducer = new KafkaProducer<>(kafkaProps);
}
public static void fireAndForget(ProducerRecord<String, Customer> record) {
kafkaProducer.send(record);
}
public static void asyncSend(ProducerRecord<String, Customer> record) {
kafkaProducer.send(record, (recordMetaData, ex) -> {
System.out.println("Offset: " + recordMetaData.offset());
System.out.println("Topic: " + recordMetaData.topic());
System.out.println("Partition: " + recordMetaData.partition());
System.out.println("Timestamp: " + recordMetaData.timestamp());
});
}
public static void main(String[] args) throws InterruptedException, IOException {
Customer customer1 = new Customer(1001, "Jimmy");
Customer customer2 = new Customer(1002, "James");
ProducerRecord<String, Customer> record1 = new ProducerRecord<>("AvroSpecificProducerOneTopic",
"KeyOne", customer1
);
ProducerRecord<String, Customer> record2 = new ProducerRecord<>("AvroSpecificProducerOneTopic",
"KeyOne", customer2
);
asyncSend(record1);
asyncSend(record2);
Thread.sleep(1000);
}
}
| UTF-8 | Java | 2,229 | java | AvroSpecificProducerOne.java | Java | [
{
"context": "n;\nimport java.util.Properties;\n\n/**\n * Created by harmeet on 10/2/17.\n */\npublic class AvroSpecificProducer",
"end": 476,
"score": 0.9995546340942383,
"start": 469,
"tag": "USERNAME",
"value": "harmeet"
},
{
"context": "\n Customer customer1 = new Customer(1001, \"Jimmy\");\n Customer customer2 = new Customer(1002",
"end": 1770,
"score": 0.9995970726013184,
"start": 1765,
"tag": "NAME",
"value": "Jimmy"
},
{
"context": "\n Customer customer2 = new Customer(1002, \"James\");\n\n ProducerRecord<String, Customer> reco",
"end": 1828,
"score": 0.9998272061347961,
"start": 1823,
"tag": "NAME",
"value": "James"
}
]
| null | []
| package com.harmeetsingh13.java.producers.avroserializer;
import com.harmeetsingh13.java.Customer;
import io.confluent.kafka.serializers.KafkaAvroSerializer;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerConfig;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.common.serialization.StringSerializer;
import java.io.IOException;
import java.util.Properties;
/**
* Created by harmeet on 10/2/17.
*/
public class AvroSpecificProducerOne {
private static Properties kafkaProps = new Properties();
private static KafkaProducer<String, Customer> kafkaProducer;
static {
kafkaProps.put("bootstrap.servers", "localhost:9092");
kafkaProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
kafkaProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, KafkaAvroSerializer.class);
kafkaProps.put("schema.registry.url", "http://localhost:8081");
kafkaProducer = new KafkaProducer<>(kafkaProps);
}
public static void fireAndForget(ProducerRecord<String, Customer> record) {
kafkaProducer.send(record);
}
public static void asyncSend(ProducerRecord<String, Customer> record) {
kafkaProducer.send(record, (recordMetaData, ex) -> {
System.out.println("Offset: " + recordMetaData.offset());
System.out.println("Topic: " + recordMetaData.topic());
System.out.println("Partition: " + recordMetaData.partition());
System.out.println("Timestamp: " + recordMetaData.timestamp());
});
}
public static void main(String[] args) throws InterruptedException, IOException {
Customer customer1 = new Customer(1001, "Jimmy");
Customer customer2 = new Customer(1002, "James");
ProducerRecord<String, Customer> record1 = new ProducerRecord<>("AvroSpecificProducerOneTopic",
"KeyOne", customer1
);
ProducerRecord<String, Customer> record2 = new ProducerRecord<>("AvroSpecificProducerOneTopic",
"KeyOne", customer2
);
asyncSend(record1);
asyncSend(record2);
Thread.sleep(1000);
}
}
| 2,229 | 0.702109 | 0.685509 | 57 | 38.105263 | 31.714563 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.824561 | false | false | 15 |
59bb10c8834f1526e8b43232b39df1c66d259bfe | 25,125,558,749,614 | 7c01f9b8c697cc412a40480218a1e991c485d9a9 | /src/test/java/codingbat/array2/MatchUpTest.java | ad4c2e8fce19f43e6bf1a99e8383d19320ae1321 | []
| no_license | ThomassenMichiel/CodingChallenges | https://github.com/ThomassenMichiel/CodingChallenges | 5d8c4e8b4921a387edc7aa0fbf43be6c8097307e | 4c5f147fd144c4c61a6d1ef1e0ef0025a441616b | refs/heads/master | 2023-06-25T17:15:10.189000 | 2023-03-16T08:53:57 | 2023-03-16T08:53:57 | 220,125,452 | 0 | 0 | null | false | 2023-06-14T22:21:04 | 2019-11-07T01:33:04 | 2021-12-28T01:45:56 | 2023-06-14T22:21:01 | 515 | 0 | 0 | 3 | Java | false | false | package codingbat.array2;
import codingbat.ArrayHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
class MatchUpTest {
@Test
void first() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,10))).isEqualTo(2);
}
@Test
void second() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,5))).isEqualTo(3);
}
@Test
void third() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,3))).isEqualTo(2);
}
} | UTF-8 | Java | 656 | java | MatchUpTest.java | Java | []
| null | []
| package codingbat.array2;
import codingbat.ArrayHelper;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
class MatchUpTest {
@Test
void first() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,10))).isEqualTo(2);
}
@Test
void second() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,5))).isEqualTo(3);
}
@Test
void third() {
assertThat(new MatchUp().matchUp(ArrayHelper.array(1,2,3), ArrayHelper.array(2,3,3))).isEqualTo(2);
}
} | 656 | 0.681402 | 0.646341 | 24 | 26.375 | 34.051201 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.958333 | false | false | 15 |
b5684e7f3b571fff9e2c5b801a216aafff2687a4 | 5,162,550,692,915 | e398e2fb8de1049b046f9b1f593ca5fb7a44f86a | /src/main/java/org/mafagafogigante/dungeon/entity/creatures/DamageHandler.java | a28e785747681b747e98455ee49b6aa5d9a1bc88 | [
"BSD-3-Clause"
]
| permissive | Bil481ProjeGrup4/dungeon | https://github.com/Bil481ProjeGrup4/dungeon | d40d6a87998e17d8936b0452379b37783d2936ba | 38990843507f84f22252fb89bc341491302a39ce | refs/heads/master | 2021-08-19T09:44:54.960000 | 2017-11-25T17:13:49 | 2017-11-25T17:13:49 | 105,779,423 | 1 | 0 | null | true | 2017-10-04T14:38:05 | 2017-10-04T14:38:05 | 2017-10-01T18:36:03 | 2017-09-22T06:49:05 | 2,538 | 0 | 0 | 0 | null | null | null | package org.mafagafogigante.dungeon.entity.creatures;
/**
* The class responsible for inflicting damage from one creature onto another.
*/
class DamageHandler {
private DamageHandler() {
}
static void inflictDamage(Creature attacker, Creature defender, int damage) {
if ((defender instanceof Hero)) {
if (((Hero)defender).isImmortal()) {
defender.getHealth().decrementBy(0);
attacker.getBattleLog().incrementInflicted(0);
defender.getBattleLog().incrementTaken(0); }
else {
defender.getHealth().decrementBy(damage);
attacker.getBattleLog().incrementInflicted(damage);
defender.getBattleLog().incrementTaken(damage); }}
else {
defender.getHealth().decrementBy(damage);
attacker.getBattleLog().incrementInflicted(damage);
defender.getBattleLog().incrementTaken(damage); }
}
}
| UTF-8 | Java | 880 | java | DamageHandler.java | Java | []
| null | []
| package org.mafagafogigante.dungeon.entity.creatures;
/**
* The class responsible for inflicting damage from one creature onto another.
*/
class DamageHandler {
private DamageHandler() {
}
static void inflictDamage(Creature attacker, Creature defender, int damage) {
if ((defender instanceof Hero)) {
if (((Hero)defender).isImmortal()) {
defender.getHealth().decrementBy(0);
attacker.getBattleLog().incrementInflicted(0);
defender.getBattleLog().incrementTaken(0); }
else {
defender.getHealth().decrementBy(damage);
attacker.getBattleLog().incrementInflicted(damage);
defender.getBattleLog().incrementTaken(damage); }}
else {
defender.getHealth().decrementBy(damage);
attacker.getBattleLog().incrementInflicted(damage);
defender.getBattleLog().incrementTaken(damage); }
}
}
| 880 | 0.690909 | 0.6875 | 26 | 32.846153 | 26.08078 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 15 |
3d5e5c6380b973b37c4e74fcacf3f9204ae7b160 | 3,659,312,198,448 | 09b64d871520376813771f8e5fd5b04abb11d0de | /program2.java | 13e4faf6b75bfe276fe9be1b133ada8da16f23b5 | []
| no_license | ahmedbaig-hub/Last-Exam | https://github.com/ahmedbaig-hub/Last-Exam | 21c0c2ff54eff8ff81175508e09e9860e1b09e42 | 68183acf5352f697aad5aa5084acf7c117c5c15b | refs/heads/main | 2023-02-02T17:57:11.431000 | 2020-12-07T21:01:18 | 2020-12-07T21:01:18 | 319,442,904 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class program2 {
static Map<String, Integer> map = new HashMap<>();
public static void sortbykey()
{
TreeMap<String, Integer> sorted = new TreeMap<>(map);
// Display the TreeMap which is naturally sorted
for (Map.Entry<String, Integer> entry : sorted.entrySet())
System.out.println("Key = " + entry.getKey() +
", Value = " + entry.getValue());
}
public static void main(String args[])
{
// putting values in the Map
map.put("Jay", 10);
map.put("Raymon", 20);
map.put("Ahmed", 30);
map.put("Bally", 40);
map.put("Danish", 50);
sortbykey();
}
} | UTF-8 | Java | 852 | java | program2.java | Java | [
{
"context": " // putting values in the Map \r\n map.put(\"Jay\", 10); \r\n map.put(\"Raymon\", 20); \r\n ",
"end": 665,
"score": 0.9990532398223877,
"start": 662,
"tag": "NAME",
"value": "Jay"
},
{
"context": " \r\n map.put(\"Jay\", 10); \r\n map.put(\"Raymon\", 20); \r\n map.put(\"Ahmed\", 30); \r\n ",
"end": 698,
"score": 0.9993109107017517,
"start": 692,
"tag": "NAME",
"value": "Raymon"
},
{
"context": " map.put(\"Raymon\", 20); \r\n map.put(\"Ahmed\", 30); \r\n map.put(\"Bally\", 40); \r\n ",
"end": 730,
"score": 0.99953693151474,
"start": 725,
"tag": "NAME",
"value": "Ahmed"
},
{
"context": "\n map.put(\"Ahmed\", 30); \r\n map.put(\"Bally\", 40); \r\n map.put(\"Danish\", 50); \r\n \r\n ",
"end": 762,
"score": 0.9996683597564697,
"start": 757,
"tag": "NAME",
"value": "Bally"
},
{
"context": "\n map.put(\"Bally\", 40); \r\n map.put(\"Danish\", 50); \r\n \r\n \r\n sortbykey(); \r\n ",
"end": 795,
"score": 0.9995533227920532,
"start": 789,
"tag": "NAME",
"value": "Danish"
}
]
| null | []
| import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class program2 {
static Map<String, Integer> map = new HashMap<>();
public static void sortbykey()
{
TreeMap<String, Integer> sorted = new TreeMap<>(map);
// Display the TreeMap which is naturally sorted
for (Map.Entry<String, Integer> entry : sorted.entrySet())
System.out.println("Key = " + entry.getKey() +
", Value = " + entry.getValue());
}
public static void main(String args[])
{
// putting values in the Map
map.put("Jay", 10);
map.put("Raymon", 20);
map.put("Ahmed", 30);
map.put("Bally", 40);
map.put("Danish", 50);
sortbykey();
}
} | 852 | 0.507042 | 0.494131 | 31 | 25.516129 | 21.618198 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.709677 | false | false | 15 |
5119c73efbf2b15a2103caf5198d67b56f9b1855 | 32,323,923,932,418 | d4031159ef85b915805d03e08f73dd19e8ed59e1 | /src/main/java/com/Leetcode/Demo/test202107/LongestWord.java | f48b667a24e24f62c0301f66e1b492672b5e8b91 | []
| no_license | ysyq0507/LeetCode | https://github.com/ysyq0507/LeetCode | cb3317c62bee4a0f061e3225ea4522dce70088cc | ddc00a2eea243a77ffe10d2f2ddf250afeb17fbb | refs/heads/master | 2023-07-05T22:46:01.605000 | 2021-07-28T00:39:51 | 2021-07-28T00:39:51 | 389,988,817 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.Leetcode.Demo.test202107;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: 杨胜
* @date: 2021/7/22 20:14
* @Description: 词典最长单词
*/
public class LongestWord {
/**
* @param words
* @return 给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由words词典中其他单词逐步添加一个字母组成。若其中有多个可行的答案,则返回答案中字典序最小的单词。
* <p>
* 若无答案,则返回空字符串。
* <p>
*
* <p>
* 示例 1:
* <p>
* 输入:
* words = ["w","wo","wor","worl", "world"]
* 输出:"world"
* 解释:
* 单词"world"可由"w", "wo", "wor", 和 "worl"添加一个字母组成。
* 示例 2:
* <p>
* 输入:
* words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
* 输出:"apple"
* 解释:
* "apply"和"apple"都能由词典中的单词组成。但是"apple"的字典序小于"apply"。
*/
public static String genLongestWord(String[] words) {
String[] tempString = new String[50];
for (int i = 0; i < words.length; i++) {
if (tempString[words[i].length()] != null) {
tempString[words[i].length()] = tempString[words[i].length()] + " " + words[i];
} else {
tempString[words[i].length()] = words[i];
}
}
List<String> longestWordList = new ArrayList<>();
for (int j = tempString.length - 1; j >= 1; j--) {
if (tempString[j] == null) {
continue;
}
for (String t : tempString[j].split(" ")) {
if (isHaveTrueWord(tempString, t, j)) {
longestWordList.add(t);
}
}
if (longestWordList.size() > 0) {
break;
}
}
String[] strings = longestWordList.toArray(new String[longestWordList.size()]);
String longestWord ="";
if (strings.length > 0) {
longestWord = strings[0];
for (int i = 0; i < strings.length; i++) {
if (longestWord.compareTo(strings[i]) > 0 && strings[i].length() >= longestWord.length()) {
longestWord = strings[i];
}
}
}
return longestWord;
}
public static boolean isHaveTrueWord(String[] stepString, String longestWord, int longSize) {
if (longSize == 1) {
return true;
}
longestWord = longestWord.substring(0, longestWord.length() - 1);
if (stepString[longSize - 1] != null && stepString[longSize - 1].contains(longestWord) && isHaveTrueWord(stepString, longestWord, longSize - 1)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
String[] wordsA = {"w", "wo", "wor", "worl", "world"};
String[] wordsB = {"a", "banana", "app", "appl", "ap", "apply", "apple"};
String[] wordsC = {"l", "le", "lel", "lelelele"};
System.out.println(genLongestWord(wordsA));
System.out.println(genLongestWord(wordsB));
System.out.println(genLongestWord(wordsC));
}
}
| UTF-8 | Java | 3,342 | java | LongestWord.java | Java | [
{
"context": "rrayList;\nimport java.util.List;\n\n/**\n * @Author: 杨胜\n * @date: 2021/7/22 20:14\n * @Description: 词典最长单词",
"end": 109,
"score": 0.9981317520141602,
"start": 107,
"tag": "NAME",
"value": "杨胜"
}
]
| null | []
| package com.Leetcode.Demo.test202107;
import java.util.ArrayList;
import java.util.List;
/**
* @Author: 杨胜
* @date: 2021/7/22 20:14
* @Description: 词典最长单词
*/
public class LongestWord {
/**
* @param words
* @return 给出一个字符串数组words组成的一本英语词典。从中找出最长的一个单词,该单词是由words词典中其他单词逐步添加一个字母组成。若其中有多个可行的答案,则返回答案中字典序最小的单词。
* <p>
* 若无答案,则返回空字符串。
* <p>
*
* <p>
* 示例 1:
* <p>
* 输入:
* words = ["w","wo","wor","worl", "world"]
* 输出:"world"
* 解释:
* 单词"world"可由"w", "wo", "wor", 和 "worl"添加一个字母组成。
* 示例 2:
* <p>
* 输入:
* words = ["a", "banana", "app", "appl", "ap", "apply", "apple"]
* 输出:"apple"
* 解释:
* "apply"和"apple"都能由词典中的单词组成。但是"apple"的字典序小于"apply"。
*/
public static String genLongestWord(String[] words) {
String[] tempString = new String[50];
for (int i = 0; i < words.length; i++) {
if (tempString[words[i].length()] != null) {
tempString[words[i].length()] = tempString[words[i].length()] + " " + words[i];
} else {
tempString[words[i].length()] = words[i];
}
}
List<String> longestWordList = new ArrayList<>();
for (int j = tempString.length - 1; j >= 1; j--) {
if (tempString[j] == null) {
continue;
}
for (String t : tempString[j].split(" ")) {
if (isHaveTrueWord(tempString, t, j)) {
longestWordList.add(t);
}
}
if (longestWordList.size() > 0) {
break;
}
}
String[] strings = longestWordList.toArray(new String[longestWordList.size()]);
String longestWord ="";
if (strings.length > 0) {
longestWord = strings[0];
for (int i = 0; i < strings.length; i++) {
if (longestWord.compareTo(strings[i]) > 0 && strings[i].length() >= longestWord.length()) {
longestWord = strings[i];
}
}
}
return longestWord;
}
public static boolean isHaveTrueWord(String[] stepString, String longestWord, int longSize) {
if (longSize == 1) {
return true;
}
longestWord = longestWord.substring(0, longestWord.length() - 1);
if (stepString[longSize - 1] != null && stepString[longSize - 1].contains(longestWord) && isHaveTrueWord(stepString, longestWord, longSize - 1)) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
String[] wordsA = {"w", "wo", "wor", "worl", "world"};
String[] wordsB = {"a", "banana", "app", "appl", "ap", "apply", "apple"};
String[] wordsC = {"l", "le", "lel", "lelelele"};
System.out.println(genLongestWord(wordsA));
System.out.println(genLongestWord(wordsB));
System.out.println(genLongestWord(wordsC));
}
}
| 3,342 | 0.508784 | 0.497183 | 99 | 29.474747 | 28.93404 | 154 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.646465 | false | false | 15 |
b84727423e66b15b16772984cb0b963737d4ffb3 | 17,197,049,098,085 | 63cfb0da50df728375bfb71f2e8c8af5f57fb16d | /app/src/main/java/com/buylist/solomakha/buylistapp/mvp/views/ProductView.java | 995c5adbd43a718c73f77e83d9c70fb3086986dc | []
| no_license | AndreySol/BuyListApp | https://github.com/AndreySol/BuyListApp | 9d6c7ba3c570093ca4ba18bcf64495d780186213 | 60ea29417ec6af7aa4e446e6c66efb56402aeb53 | refs/heads/master | 2021-01-02T08:58:18.154000 | 2017-08-31T16:02:45 | 2017-08-31T16:02:45 | 99,105,817 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.buylist.solomakha.buylistapp.mvp.views;
import com.buylist.solomakha.buylistapp.storage.db.model.Category;
import com.buylist.solomakha.buylistapp.storage.db.model.Unit;
import com.buylist.solomakha.buylistapp.storage.db.model.embeded.ProductEmbedded;
import java.util.List;
/**
* Created by asolomakha on 8/9/2017.
*/
public interface ProductView
{
void showProductsByBasketId(List<ProductEmbedded> productList);
void showAddProductDialog(List<Unit> units, List<Category> categories);
}
| UTF-8 | Java | 515 | java | ProductView.java | Java | [
{
"context": "bedded;\n\nimport java.util.List;\n\n/**\n * Created by asolomakha on 8/9/2017.\n */\n\npublic interface ProductView\n{\n",
"end": 318,
"score": 0.9996193051338196,
"start": 308,
"tag": "USERNAME",
"value": "asolomakha"
}
]
| null | []
| package com.buylist.solomakha.buylistapp.mvp.views;
import com.buylist.solomakha.buylistapp.storage.db.model.Category;
import com.buylist.solomakha.buylistapp.storage.db.model.Unit;
import com.buylist.solomakha.buylistapp.storage.db.model.embeded.ProductEmbedded;
import java.util.List;
/**
* Created by asolomakha on 8/9/2017.
*/
public interface ProductView
{
void showProductsByBasketId(List<ProductEmbedded> productList);
void showAddProductDialog(List<Unit> units, List<Category> categories);
}
| 515 | 0.798058 | 0.786408 | 18 | 27.611111 | 30.194075 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.444444 | false | false | 15 |
4113beb846fc82a728a779fe29ee4cbdcd464605 | 17,197,049,095,886 | de9a8c3ad31e87a2a760dd734d88424b556a6b48 | /CraftTweaker2-API/src/main/java/crafttweaker/api/event/PlayerInteractEntityEvent.java | ce8bfa40bee6a26d121180cc7f637f78d4eb57a5 | [
"MIT"
]
| permissive | kindlich/CraftTweaker | https://github.com/kindlich/CraftTweaker | fd61116413b274dc6eac2d6f7468095eb04a9a06 | 7c769e5e47de1125b6c340cbc8b5dc1ec07faf96 | refs/heads/1.12 | 2023-08-17T16:30:47.448000 | 2020-12-15T17:33:38 | 2020-12-15T17:33:38 | 109,025,585 | 0 | 0 | MIT | true | 2023-04-04T09:46:26 | 2017-10-31T16:49:14 | 2022-04-03T20:39:45 | 2023-04-04T09:46:25 | 77,505 | 0 | 0 | 5 | Java | false | false | package crafttweaker.api.event;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.entity.IEntity;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
/**
* @author Stan
*/
@ZenClass("crafttweaker.event.PlayerInteractEntityEvent")
@ZenRegister
public interface PlayerInteractEntityEvent extends IEventCancelable, IPlayerEvent {
@ZenGetter("target")
IEntity getTarget();
}
| UTF-8 | Java | 452 | java | PlayerInteractEntityEvent.java | Java | [
{
"context": "n.zenscript.annotations.ZenGetter;\n\n/**\n * @author Stan\n */\n@ZenClass(\"crafttweaker.event.PlayerInteractE",
"end": 239,
"score": 0.9947649240493774,
"start": 235,
"tag": "NAME",
"value": "Stan"
}
]
| null | []
| package crafttweaker.api.event;
import crafttweaker.annotations.ZenRegister;
import crafttweaker.api.entity.IEntity;
import stanhebben.zenscript.annotations.ZenClass;
import stanhebben.zenscript.annotations.ZenGetter;
/**
* @author Stan
*/
@ZenClass("crafttweaker.event.PlayerInteractEntityEvent")
@ZenRegister
public interface PlayerInteractEntityEvent extends IEventCancelable, IPlayerEvent {
@ZenGetter("target")
IEntity getTarget();
}
| 452 | 0.811947 | 0.811947 | 17 | 25.588236 | 24.09066 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.411765 | false | false | 15 |
d0bf98e3bc984bcde4db5941f8800a4df154d9f2 | 12,292,196,429,078 | 57d0b2e9ac8f72ea648d0b0a3e21157a4e5b4f34 | /app/src/main/java/com/example/moneytracker/Adapters/MoneyRecordAdapter.java | 692a256b28962017e7ebe2ae9c85c64b1d55c9f9 | []
| no_license | azrail212/Money-Tracker | https://github.com/azrail212/Money-Tracker | 5515e8a0cd7e45d5dd26ee28ec881a6b9c14b6d0 | 3ad47561054088f50923ac1056a78acd44716ac0 | refs/heads/main | 2023-06-10T22:25:13.008000 | 2021-06-13T21:39:34 | 2021-06-13T21:39:34 | 350,000,477 | 0 | 0 | null | false | 2021-06-13T21:01:01 | 2021-03-21T13:03:18 | 2021-06-13T20:59:33 | 2021-06-13T21:01:01 | 356 | 0 | 0 | 0 | Java | false | false | package com.example.moneytracker.Adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.moneytracker.Activities.NewEntryActivity;
import com.example.moneytracker.Entities.MoneyRecord;
import com.example.moneytracker.R;
import java.util.Calendar;
import java.util.List;
public class MoneyRecordAdapter extends BaseAdapter {
private Context context;
private List<MoneyRecord> moneyRecords;
public MoneyRecordAdapter(Context context, List<MoneyRecord> moneyRecords) {
this.context = context;
this.moneyRecords = moneyRecords;
}
@Override
public int getCount() { return moneyRecords.size(); }
@Override
public Object getItem(int position) { return moneyRecords.get(position); }
@Override
public long getItemId(int position) { return moneyRecords.get(position).getId(); }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(R.layout.money_record_item, parent, false);
MoneyRecord moneyRecord = moneyRecords.get(position);
TextView date = convertView.findViewById(R.id.money_record_date);
TextView type = convertView.findViewById(R.id.money_record_type);
TextView amount = convertView.findViewById(R.id.money_record_amount);
TextView category = convertView.findViewById(R.id.money_record_category);
TextView description = convertView.findViewById(R.id.money_record_description);
Calendar c = moneyRecord.getDate();
date.setText(Integer.toString(c.get(Calendar.DAY_OF_MONTH))+"."+
Integer.toString(c.get(Calendar.MONTH))+"."+
Integer.toString(c.get(Calendar.YEAR)));
type.setText(moneyRecord.getType());
amount.setText(Double.toString(moneyRecord.getAmount()));
category.setText(moneyRecord.getCategory());
description.setText(moneyRecord.getDescription());
return convertView;
}
}
| UTF-8 | Java | 2,333 | java | MoneyRecordAdapter.java | Java | []
| null | []
| package com.example.moneytracker.Adapters;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.moneytracker.Activities.NewEntryActivity;
import com.example.moneytracker.Entities.MoneyRecord;
import com.example.moneytracker.R;
import java.util.Calendar;
import java.util.List;
public class MoneyRecordAdapter extends BaseAdapter {
private Context context;
private List<MoneyRecord> moneyRecords;
public MoneyRecordAdapter(Context context, List<MoneyRecord> moneyRecords) {
this.context = context;
this.moneyRecords = moneyRecords;
}
@Override
public int getCount() { return moneyRecords.size(); }
@Override
public Object getItem(int position) { return moneyRecords.get(position); }
@Override
public long getItemId(int position) { return moneyRecords.get(position).getId(); }
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = LayoutInflater.from(context);
convertView = inflater.inflate(R.layout.money_record_item, parent, false);
MoneyRecord moneyRecord = moneyRecords.get(position);
TextView date = convertView.findViewById(R.id.money_record_date);
TextView type = convertView.findViewById(R.id.money_record_type);
TextView amount = convertView.findViewById(R.id.money_record_amount);
TextView category = convertView.findViewById(R.id.money_record_category);
TextView description = convertView.findViewById(R.id.money_record_description);
Calendar c = moneyRecord.getDate();
date.setText(Integer.toString(c.get(Calendar.DAY_OF_MONTH))+"."+
Integer.toString(c.get(Calendar.MONTH))+"."+
Integer.toString(c.get(Calendar.YEAR)));
type.setText(moneyRecord.getType());
amount.setText(Double.toString(moneyRecord.getAmount()));
category.setText(moneyRecord.getCategory());
description.setText(moneyRecord.getDescription());
return convertView;
}
}
| 2,333 | 0.723532 | 0.723532 | 63 | 36.031746 | 28.604012 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.