identifier
stringlengths 0
89
| parameters
stringlengths 0
399
| return_statement
stringlengths 0
982
⌀ | docstring
stringlengths 10
3.04k
| docstring_summary
stringlengths 0
3.04k
| function
stringlengths 13
25.8k
| function_tokens
sequence | start_point
sequence | end_point
sequence | argument_list
null | language
stringclasses 3
values | docstring_language
stringclasses 4
values | docstring_language_predictions
stringclasses 4
values | is_langid_reliable
stringclasses 2
values | is_langid_extra_reliable
bool 1
class | type
stringclasses 9
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
AppConfig. | null | Classe responsável por manter alguma configuração, criar algum componente específico e assim por diante. | Classe responsável por manter alguma configuração, criar algum componente específico e assim por diante. | @Bean // É um componente do Spring. Desta forma é possível injetar o BCrypt em outras classes
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
} | [
"@",
"Bean",
"// É um componente do Spring. Desta forma é possível injetar o BCrypt em outras classes",
"public",
"BCryptPasswordEncoder",
"passwordEncoder",
"(",
")",
"{",
"return",
"new",
"BCryptPasswordEncoder",
"(",
")",
";",
"}"
] | [
9,
4
] | [
12,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
EmpresasService. | null | API para extrair os dados em formato xml e json das empresas | API para extrair os dados em formato xml e json das empresas | @Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List<Empresa> empresas = new Banco().getEmpresas();
String valor = request.getHeader("Accept");
System.out.println(valor);
if (valor.contains("xml")) {
XStream xstream = new XStream();
xstream.alias("empresa", Empresa.class);
String xml = xstream.toXML(empresas);
response.setContentType("application/xml");
response.getWriter().print(xml);
} else if (valor.endsWith("json")) {
Gson gson = new Gson();
String json = gson.toJson(empresas);
response.setContentType("application/json");
response.getWriter().print(json);
} else {
response.setContentType("application/json");
response.getWriter().print("{'message' : 'no content'}");
}
} | [
"@",
"Override",
"protected",
"void",
"service",
"(",
"HttpServletRequest",
"request",
",",
"HttpServletResponse",
"response",
")",
"throws",
"ServletException",
",",
"IOException",
"{",
"List",
"<",
"Empresa",
">",
"empresas",
"=",
"new",
"Banco",
"(",
")",
".",
"getEmpresas",
"(",
")",
";",
"String",
"valor",
"=",
"request",
".",
"getHeader",
"(",
"\"Accept\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"valor",
")",
";",
"if",
"(",
"valor",
".",
"contains",
"(",
"\"xml\"",
")",
")",
"{",
"XStream",
"xstream",
"=",
"new",
"XStream",
"(",
")",
";",
"xstream",
".",
"alias",
"(",
"\"empresa\"",
",",
"Empresa",
".",
"class",
")",
";",
"String",
"xml",
"=",
"xstream",
".",
"toXML",
"(",
"empresas",
")",
";",
"response",
".",
"setContentType",
"(",
"\"application/xml\"",
")",
";",
"response",
".",
"getWriter",
"(",
")",
".",
"print",
"(",
"xml",
")",
";",
"}",
"else",
"if",
"(",
"valor",
".",
"endsWith",
"(",
"\"json\"",
")",
")",
"{",
"Gson",
"gson",
"=",
"new",
"Gson",
"(",
")",
";",
"String",
"json",
"=",
"gson",
".",
"toJson",
"(",
"empresas",
")",
";",
"response",
".",
"setContentType",
"(",
"\"application/json\"",
")",
";",
"response",
".",
"getWriter",
"(",
")",
".",
"print",
"(",
"json",
")",
";",
"}",
"else",
"{",
"response",
".",
"setContentType",
"(",
"\"application/json\"",
")",
";",
"response",
".",
"getWriter",
"(",
")",
".",
"print",
"(",
"\"{'message' : 'no content'}\"",
")",
";",
"}",
"}"
] | [
17,
4
] | [
49,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Alerts. | null | Mostra um alert, serve pra mostrar se o usuario clicou em SIM ou NAO | Mostra um alert, serve pra mostrar se o usuario clicou em SIM ou NAO | public static Optional<ButtonType> showConfirmation(String title, String content) {
Alert alert = new Alert(AlertType.CONFIRMATION);
alert.setTitle(title);
alert.setHeaderText(null);
alert.setContentText(content);
return alert.showAndWait();
} | [
"public",
"static",
"Optional",
"<",
"ButtonType",
">",
"showConfirmation",
"(",
"String",
"title",
",",
"String",
"content",
")",
"{",
"Alert",
"alert",
"=",
"new",
"Alert",
"(",
"AlertType",
".",
"CONFIRMATION",
")",
";",
"alert",
".",
"setTitle",
"(",
"title",
")",
";",
"alert",
".",
"setHeaderText",
"(",
"null",
")",
";",
"alert",
".",
"setContentText",
"(",
"content",
")",
";",
"return",
"alert",
".",
"showAndWait",
"(",
")",
";",
"}"
] | [
19,
4
] | [
25,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Solution. | null | Na resoluaao da sopa a determinado o endPos da palavra, por isso da jeito ter este setter para nao ter de estar a calcular de novo dentro da classe | Na resoluaao da sopa a determinado o endPos da palavra, por isso da jeito ter este setter para nao ter de estar a calcular de novo dentro da classe | public void setEndPos(Point endPos) {
this.endPos = endPos;
} | [
"public",
"void",
"setEndPos",
"(",
"Point",
"endPos",
")",
"{",
"this",
".",
"endPos",
"=",
"endPos",
";",
"}"
] | [
93,
1
] | [
95,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Tabuleiro. | null | método invocado pela classe Jogo para, a partir do tabuleiro carregado do arquivo, identificar as peças de cada jogador e retorná-las ao Jogo: | método invocado pela classe Jogo para, a partir do tabuleiro carregado do arquivo, identificar as peças de cada jogador e retorná-las ao Jogo: | public Peca[] pecasJogadoresPartidaRetomada(String corDoJogador) {
Peca[] pecasIndividuais = new Peca[16]; //vetor auxiliar de Pecas, com 16 posições
//contadores auxiliares serão criados, para que seja possível identificar quantas peças duplicadas há na partida carregada:
int contadorTorres = 1; //contador auxiliar exclusivo para Torre
int contadorCavalos = 1; //contador auxiliar exclusivo para Cavalo
int contadorBispos = 1; //contador auxiliar exclusivo para Bispo
int indicePeoes = 8; //contador auxiliar exclusivo para os peões
//percorrendo o tabuleiro:
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
//para cada posição ocupada por uma peça de mesma cor que o jogador:
if (!tabuleiro[i][j].getStatus() && tabuleiro[i][j].getPeca() != null && tabuleiro[i][j].getPeca().getCor() == corDoJogador) {
//analisando o tipo de peça e atribuindo em sua respectiva posição no vetor:
switch(tabuleiro[i][j].getPeca().desenho().charAt(0)) { //apenas análise do primeiro caractere do desenho é o suficiente, visto que todos são, com certeza, de cor preta
case 'R':
if (contadorTorres == 1) { //primeira torre encontrada
pecasIndividuais[4] = tabuleiro[i][j].getPeca();
} else { //segunda torre encontrada
pecasIndividuais[5] = tabuleiro[i][j].getPeca();
}
contadorTorres++;
break;
case 'N':
if (contadorCavalos == 1) { //primeiro cavalo encontrado
pecasIndividuais[2] = tabuleiro[i][j].getPeca();
} else { //segundo cavalo encontrado
pecasIndividuais[3] = tabuleiro[i][j].getPeca();
}
contadorCavalos++;
break;
case 'B':
if (contadorBispos == 1) { //primeiro bispo encontrado
pecasIndividuais[0] = tabuleiro[i][j].getPeca();
} else { //segundo bispo encontrado
pecasIndividuais[1] = tabuleiro[i][j].getPeca();
}
contadorBispos++;
break;
case 'Q':
pecasIndividuais[6] = tabuleiro[i][j].getPeca();
break;
case 'K':
pecasIndividuais[7] = tabuleiro[i][j].getPeca();
break;
case 'P':
pecasIndividuais[indicePeoes] = tabuleiro[i][j].getPeca(); //embora há vários peões, todos ficam lado a lado no vetor
indicePeoes++; //logo, é apenas preciso incrementar o índice previamente definido
break;
}
}
}
}
return pecasIndividuais; //o vetor de peças do jogador é retornado
} | [
"public",
"Peca",
"[",
"]",
"pecasJogadoresPartidaRetomada",
"(",
"String",
"corDoJogador",
")",
"{",
"Peca",
"[",
"]",
"pecasIndividuais",
"=",
"new",
"Peca",
"[",
"16",
"]",
";",
"//vetor auxiliar de Pecas, com 16 posições",
"//contadores auxiliares serão criados, para que seja possível identificar quantas peças duplicadas há na partida carregada:",
"int",
"contadorTorres",
"=",
"1",
";",
"//contador auxiliar exclusivo para Torre",
"int",
"contadorCavalos",
"=",
"1",
";",
"//contador auxiliar exclusivo para Cavalo",
"int",
"contadorBispos",
"=",
"1",
";",
"//contador auxiliar exclusivo para Bispo",
"int",
"indicePeoes",
"=",
"8",
";",
"//contador auxiliar exclusivo para os peões",
"//percorrendo o tabuleiro:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"8",
";",
"j",
"++",
")",
"{",
"//para cada posição ocupada por uma peça de mesma cor que o jogador:",
"if",
"(",
"!",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getStatus",
"(",
")",
"&&",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
"!=",
"null",
"&&",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
".",
"getCor",
"(",
")",
"==",
"corDoJogador",
")",
"{",
"//analisando o tipo de peça e atribuindo em sua respectiva posição no vetor:",
"switch",
"(",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
".",
"desenho",
"(",
")",
".",
"charAt",
"(",
"0",
")",
")",
"{",
"//apenas análise do primeiro caractere do desenho é o suficiente, visto que todos são, com certeza, de cor preta",
"case",
"'",
"'",
":",
"if",
"(",
"contadorTorres",
"==",
"1",
")",
"{",
"//primeira torre encontrada",
"pecasIndividuais",
"[",
"4",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"else",
"{",
"//segunda torre encontrada",
"pecasIndividuais",
"[",
"5",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"contadorTorres",
"++",
";",
"break",
";",
"case",
"'",
"'",
":",
"if",
"(",
"contadorCavalos",
"==",
"1",
")",
"{",
"//primeiro cavalo encontrado",
"pecasIndividuais",
"[",
"2",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"else",
"{",
"//segundo cavalo encontrado",
"pecasIndividuais",
"[",
"3",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"contadorCavalos",
"++",
";",
"break",
";",
"case",
"'",
"'",
":",
"if",
"(",
"contadorBispos",
"==",
"1",
")",
"{",
"//primeiro bispo encontrado",
"pecasIndividuais",
"[",
"0",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"else",
"{",
"//segundo bispo encontrado",
"pecasIndividuais",
"[",
"1",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"}",
"contadorBispos",
"++",
";",
"break",
";",
"case",
"'",
"'",
":",
"pecasIndividuais",
"[",
"6",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"pecasIndividuais",
"[",
"7",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"break",
";",
"case",
"'",
"'",
":",
"pecasIndividuais",
"[",
"indicePeoes",
"]",
"=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
";",
"//embora há vários peões, todos ficam lado a lado no vetor",
"indicePeoes",
"++",
";",
"//logo, é apenas preciso incrementar o índice previamente definido",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"pecasIndividuais",
";",
"//o vetor de peças do jogador é retornado",
"}"
] | [
517,
4
] | [
576,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Tabuleiro. | null | método invocado pela classe Jogo, para percorrer o tabuleiro e armazenar em uma String as principais informaçõesde todas as suas posições: | método invocado pela classe Jogo, para percorrer o tabuleiro e armazenar em uma String as principais informaçõesde todas as suas posições: | public String textoArquivo() {
String text = ""; //string, inicializada vazia
//perccorendo cada posição do tabuleiro:
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
text += tabuleiro[i][j].getLinha() + " " + tabuleiro[i][j].getColuna(); //adicionando à string a linha e coluna da posição
if (!tabuleiro[i][j].getStatus()) { //caso a posição esteja ocupada
text += " " + tabuleiro[i][j].getPeca().desenho() + "\n"; //o desenho da peça também é adicionado à string (o \n servirá para escrita em linhas no arquivo, posteriormente)
} else {
text += "\n"; //caso a posição esteja livre, apenas o '\n' é adicionado à string
}
}
}
return text; //a string, após percorrer todo o tabuleiro, é retornada
} | [
"public",
"String",
"textoArquivo",
"(",
")",
"{",
"String",
"text",
"=",
"\"\"",
";",
"//string, inicializada vazia",
"//perccorendo cada posição do tabuleiro:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"8",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"8",
";",
"j",
"++",
")",
"{",
"text",
"+=",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getLinha",
"(",
")",
"+",
"\" \"",
"+",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getColuna",
"(",
")",
";",
"//adicionando à string a linha e coluna da posição",
"if",
"(",
"!",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//caso a posição esteja ocupada",
"text",
"+=",
"\" \"",
"+",
"tabuleiro",
"[",
"i",
"]",
"[",
"j",
"]",
".",
"getPeca",
"(",
")",
".",
"desenho",
"(",
")",
"+",
"\"\\n\"",
";",
"//o desenho da peça também é adicionado à string (o \\n servirá para escrita em linhas no arquivo, posteriormente)",
"}",
"else",
"{",
"text",
"+=",
"\"\\n\"",
";",
"//caso a posição esteja livre, apenas o '\\n' é adicionado à string",
"}",
"}",
"}",
"return",
"text",
";",
"//a string, após percorrer todo o tabuleiro, é retornada",
"}"
] | [
499,
4
] | [
514,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Torre. | null | método que retorna o código representação da peça: | método que retorna o código representação da peça: | @Override
public String desenho() {
if (this.getCor().equals("preto")) { //caso sua cor seja preta
return "Rb";
} else { //caso sua cor seja branco
return "Rw";
}
} | [
"@",
"Override",
"public",
"String",
"desenho",
"(",
")",
"{",
"if",
"(",
"this",
".",
"getCor",
"(",
")",
".",
"equals",
"(",
"\"preto\"",
")",
")",
"{",
"//caso sua cor seja preta",
"return",
"\"Rb\"",
";",
"}",
"else",
"{",
"//caso sua cor seja branco",
"return",
"\"Rw\"",
";",
"}",
"}"
] | [
12,
4
] | [
19,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ContaBancaria. | null | Altera a senha para uma nova se a senha introduzida por a correcta | Altera a senha para uma nova se a senha introduzida por a correcta | public void alterarSenha(int senha) {
// Crio Scanner para receber a senha anterior e verificar se está correcta
Scanner keyboard = new Scanner(System.in);
System.out.println("Para alterar a senha precisa de confirmar a sua senha");
System.out.println("Introduza a senha desta conta:");
int senhaInserida = keyboard.nextInt();
// Só troca a senha se a inserida for a que estiver activa actualmente no objecto
if (senhaInserida == this.senha) {
System.out.println("A sua senha foi alterada com sucesso!");
this.senha = senha;
} else {
System.out.println("Introduziu a senha errada.");
System.out.println("Nao foi possivel alterar a senha desta conta");
}
} | [
"public",
"void",
"alterarSenha",
"(",
"int",
"senha",
")",
"{",
"// Crio Scanner para receber a senha anterior e verificar se está correcta",
"Scanner",
"keyboard",
"=",
"new",
"Scanner",
"(",
"System",
".",
"in",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Para alterar a senha precisa de confirmar a sua senha\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduza a senha desta conta:\"",
")",
";",
"int",
"senhaInserida",
"=",
"keyboard",
".",
"nextInt",
"(",
")",
";",
"// Só troca a senha se a inserida for a que estiver activa actualmente no objecto",
"if",
"(",
"senhaInserida",
"==",
"this",
".",
"senha",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"A sua senha foi alterada com sucesso!\"",
")",
";",
"this",
".",
"senha",
"=",
"senha",
";",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduziu a senha errada.\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Nao foi possivel alterar a senha desta conta\"",
")",
";",
"}",
"}"
] | [
56,
4
] | [
70,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
App. | null | Função de formatação de dados de parametros recebidos | Função de formatação de dados de parametros recebidos | public static String formataDados(String dados){
dados = dados.replaceAll("\\"" , "");
dados = dados.replace("\\","");
dados = dados.replace('"',' ');
return dados;
} | [
"public",
"static",
"String",
"formataDados",
"(",
"String",
"dados",
")",
"{",
"dados",
"=",
"dados",
".",
"replaceAll",
"(",
"\"\\\\"\"",
",",
"\"\"",
")",
";",
"dados",
"=",
"dados",
".",
"replace",
"(",
"\"\\\\\"",
",",
"\"\"",
")",
";",
"dados",
"=",
"dados",
".",
"replace",
"(",
"'",
"'",
",",
"'",
"'",
")",
";",
"return",
"dados",
";",
"}"
] | [
171,
1
] | [
177,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cachorro. | null | (Polimorfismo) sobrepondo com a mesma assinatura do método emitirSom da classe Mamifero | (Polimorfismo) sobrepondo com a mesma assinatura do método emitirSom da classe Mamifero | @Override
public void emitirSom(){
System.out.println("Latindo");
} | [
"@",
"Override",
"public",
"void",
"emitirSom",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Latindo\"",
")",
";",
"}"
] | [
10,
4
] | [
13,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SQLMaker. | null | INSERT INTO livros (titulo) VALUES ('orgulho e preconceito'); | INSERT INTO livros (titulo) VALUES ('orgulho e preconceito'); | public static String insert(Map<String, String> options) {
final String SQL = "INSERT INTO {table} ({fields}) VALUES ({values});";
return replaceParams(options, SQL);
} | [
"public",
"static",
"String",
"insert",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"final",
"String",
"SQL",
"=",
"\"INSERT INTO {table} ({fields}) VALUES ({values});\"",
";",
"return",
"replaceParams",
"(",
"options",
",",
"SQL",
")",
";",
"}"
] | [
30,
4
] | [
33,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
LBSTree. | null | Percorrer os nodos na arvore em pos-ordem | Percorrer os nodos na arvore em pos-ordem | protected void postOrder(LBSTreeNode treeRef) {
if (treeRef != null) {
treeString = treeString + "(";
postOrder(treeRef.linkLeft);
postOrder(treeRef.linkRight);
treeString = treeString + " " + treeRef.item + " ";
treeString = treeString + ")";
}
} | [
"protected",
"void",
"postOrder",
"(",
"LBSTreeNode",
"treeRef",
")",
"{",
"if",
"(",
"treeRef",
"!=",
"null",
")",
"{",
"treeString",
"=",
"treeString",
"+",
"\"(\"",
";",
"postOrder",
"(",
"treeRef",
".",
"linkLeft",
")",
";",
"postOrder",
"(",
"treeRef",
".",
"linkRight",
")",
";",
"treeString",
"=",
"treeString",
"+",
"\" \"",
"+",
"treeRef",
".",
"item",
"+",
"\" \"",
";",
"treeString",
"=",
"treeString",
"+",
"\")\"",
";",
"}",
"}"
] | [
163,
1
] | [
171,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UsuarioController. | null | Deleta um usuário | Deleta um usuário | @RequestMapping(value="/usuario", method=RequestMethod.DELETE)
@ApiOperation(value="Deleta um usuário")
public void deletaUsuario(@RequestBody Usuario usuario) {
usuarioService.deletaUsuario(usuario);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/usuario\"",
",",
"method",
"=",
"RequestMethod",
".",
"DELETE",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Deleta um usuário\")",
"",
"public",
"void",
"deletaUsuario",
"(",
"@",
"RequestBody",
"Usuario",
"usuario",
")",
"{",
"usuarioService",
".",
"deletaUsuario",
"(",
"usuario",
")",
";",
"}"
] | [
62,
1
] | [
66,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ControleDeJogo. | null | Função usada por ehPosicaoValida | Função usada por ehPosicaoValida | private boolean ehPosicaoValidaHeroi(ArrayList<Elemento> e, Elemento eTemp, int i) {
//Caso o eTemp seja um bloco móvel:
if (eTemp.isMovel() == true) {
if (eTemp.contactHero((Animado) e.get(0), e)) {
if (!ehPosicaoValida(e, eTemp.getPosicao(), i)) {
eTemp.voltaAUltimaPosicao();
return false;
} else return true;
} else return false;
}
//Caso eTemp seja um robô:
if (eTemp.getClass().getSimpleName().equals("Robo")) {
eTemp.contactHero((Animado) e.get(0), e);
return true;
}
return false;
} | [
"private",
"boolean",
"ehPosicaoValidaHeroi",
"(",
"ArrayList",
"<",
"Elemento",
">",
"e",
",",
"Elemento",
"eTemp",
",",
"int",
"i",
")",
"{",
"//Caso o eTemp seja um bloco móvel:\r",
"if",
"(",
"eTemp",
".",
"isMovel",
"(",
")",
"==",
"true",
")",
"{",
"if",
"(",
"eTemp",
".",
"contactHero",
"(",
"(",
"Animado",
")",
"e",
".",
"get",
"(",
"0",
")",
",",
"e",
")",
")",
"{",
"if",
"(",
"!",
"ehPosicaoValida",
"(",
"e",
",",
"eTemp",
".",
"getPosicao",
"(",
")",
",",
"i",
")",
")",
"{",
"eTemp",
".",
"voltaAUltimaPosicao",
"(",
")",
";",
"return",
"false",
";",
"}",
"else",
"return",
"true",
";",
"}",
"else",
"return",
"false",
";",
"}",
"//Caso eTemp seja um robô:\r",
"if",
"(",
"eTemp",
".",
"getClass",
"(",
")",
".",
"getSimpleName",
"(",
")",
".",
"equals",
"(",
"\"Robo\"",
")",
")",
"{",
"eTemp",
".",
"contactHero",
"(",
"(",
"Animado",
")",
"e",
".",
"get",
"(",
"0",
")",
",",
"e",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | [
51,
1
] | [
70,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ServicoDAO. | null | Retorna os servicos realizados por dado veiculo | Retorna os servicos realizados por dado veiculo | public List<Servicos> listarPorVeiculo(Veiculo veiculo) {
String sql = "SELECT s.cod_servico AS codigo, s.nome,\n" +
" s.descricao, s.preco\n" +
" FROM servico s\n" +
" INNER JOIN manutencao_servico ms ON ms.cod_servico = s.cod_servico\n" +
" INNER JOIN manutencao m ON m.cod_manutencao = ms.cod_manutencao\n" +
" INNER JOIN veiculo v ON v.placa = m.cod_veiculo\n" +
" WHERE v.placa = ?;";
List<Servicos> retorno = new ArrayList<>();
try {
PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, veiculo.getPlaca());
ResultSet resultado = stmt.executeQuery();
while (resultado.next()) {
Servicos servico = new Servicos();
servico.setCodigo(resultado.getInt("codigo"));
servico.setNome(resultado.getString("nome"));
servico.setDescricao(resultado.getString("descricao"));
servico.setPreco(resultado.getDouble("preco"));
retorno.add(servico);
}
} catch (SQLException ex) {
Logger.getLogger(ServicoDAO.class.getName()).log(Level.SEVERE, null, ex);
}
return retorno;
} | [
"public",
"List",
"<",
"Servicos",
">",
"listarPorVeiculo",
"(",
"Veiculo",
"veiculo",
")",
"{",
"String",
"sql",
"=",
"\"SELECT s.cod_servico AS codigo, s.nome,\\n\"",
"+",
"\"\t\ts.descricao, s.preco\\n\"",
"+",
"\"\tFROM servico s\\n\"",
"+",
"\"\tINNER JOIN manutencao_servico ms ON ms.cod_servico = s.cod_servico\\n\"",
"+",
"\"\tINNER JOIN manutencao m ON m.cod_manutencao = ms.cod_manutencao\\n\"",
"+",
"\"\tINNER JOIN veiculo v ON v.placa = m.cod_veiculo\\n\"",
"+",
"\"\tWHERE v.placa = ?;\"",
";",
"List",
"<",
"Servicos",
">",
"retorno",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"try",
"{",
"PreparedStatement",
"stmt",
"=",
"connection",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"stmt",
".",
"setString",
"(",
"1",
",",
"veiculo",
".",
"getPlaca",
"(",
")",
")",
";",
"ResultSet",
"resultado",
"=",
"stmt",
".",
"executeQuery",
"(",
")",
";",
"while",
"(",
"resultado",
".",
"next",
"(",
")",
")",
"{",
"Servicos",
"servico",
"=",
"new",
"Servicos",
"(",
")",
";",
"servico",
".",
"setCodigo",
"(",
"resultado",
".",
"getInt",
"(",
"\"codigo\"",
")",
")",
";",
"servico",
".",
"setNome",
"(",
"resultado",
".",
"getString",
"(",
"\"nome\"",
")",
")",
";",
"servico",
".",
"setDescricao",
"(",
"resultado",
".",
"getString",
"(",
"\"descricao\"",
")",
")",
";",
"servico",
".",
"setPreco",
"(",
"resultado",
".",
"getDouble",
"(",
"\"preco\"",
")",
")",
";",
"retorno",
".",
"add",
"(",
"servico",
")",
";",
"}",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"Logger",
".",
"getLogger",
"(",
"ServicoDAO",
".",
"class",
".",
"getName",
"(",
")",
")",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"null",
",",
"ex",
")",
";",
"}",
"return",
"retorno",
";",
"}"
] | [
126,
4
] | [
154,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfig. | null | Metodo para controlar acesso nos recursos | Metodo para controlar acesso nos recursos | @Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(OpenURLS.VALUES).permitAll()
.anyRequest().authenticated(); //Aqui permite que todos os endpoints definidos em OpenURLS sejam abertos a quem estiver autenticado
http.csrf().disable();
http.headers().frameOptions().disable();
http.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS); //Define o tipo de sessão como Stateless
http.addFilterBefore(new JwtAuthenticationFilter(tokenManager, userService), UsernamePasswordAuthenticationFilter.class);
http.exceptionHandling().authenticationEntryPoint(new JwtAuthenticationEntryPoint());
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"HttpSecurity",
"http",
")",
"throws",
"Exception",
"{",
"http",
".",
"authorizeRequests",
"(",
")",
".",
"antMatchers",
"(",
"OpenURLS",
".",
"VALUES",
")",
".",
"permitAll",
"(",
")",
".",
"anyRequest",
"(",
")",
".",
"authenticated",
"(",
")",
";",
"//Aqui permite que todos os endpoints definidos em OpenURLS sejam abertos a quem estiver autenticado",
"http",
".",
"csrf",
"(",
")",
".",
"disable",
"(",
")",
";",
"http",
".",
"headers",
"(",
")",
".",
"frameOptions",
"(",
")",
".",
"disable",
"(",
")",
";",
"http",
".",
"sessionManagement",
"(",
")",
".",
"sessionCreationPolicy",
"(",
"SessionCreationPolicy",
".",
"STATELESS",
")",
";",
"//Define o tipo de sessão como Stateless",
"http",
".",
"addFilterBefore",
"(",
"new",
"JwtAuthenticationFilter",
"(",
"tokenManager",
",",
"userService",
")",
",",
"UsernamePasswordAuthenticationFilter",
".",
"class",
")",
";",
"http",
".",
"exceptionHandling",
"(",
")",
".",
"authenticationEntryPoint",
"(",
"new",
"JwtAuthenticationEntryPoint",
"(",
")",
")",
";",
"}"
] | [
48,
4
] | [
63,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cliente. | null | /* Os dois métodos abaixo devolvem os dados de acesso do usuário | /* Os dois métodos abaixo devolvem os dados de acesso do usuário | @Override
public String getPassword() {
return this.senha;
} | [
"@",
"Override",
"public",
"String",
"getPassword",
"(",
")",
"{",
"return",
"this",
".",
"senha",
";",
"}"
] | [
89,
4
] | [
92,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CrudFuncionarioService. | null | simulando o view do front | simulando o view do front | public void inicial(Scanner scanner) {
while(system) {
System.out.println("Qual acao de cargo deseja executar");
System.out.println("0 - Sair");
System.out.println("1 - Salvar");
System.out.println("2 - Atualizar");
System.out.println("3 - Visualizar");
System.out.println("4 - Deletar");
int action = scanner.nextInt();
switch (action) {
case 1:
salvar(scanner);
break;
case 2:
atualizar(scanner);
break;
case 3:
visualizar(scanner);
break;
case 4:
deletar(scanner);
break;
default:
system = false;
break;
}
}
} | [
"public",
"void",
"inicial",
"(",
"Scanner",
"scanner",
")",
"{",
"while",
"(",
"system",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Qual acao de cargo deseja executar\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"0 - Sair\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"1 - Salvar\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"2 - Atualizar\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"3 - Visualizar\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"4 - Deletar\"",
")",
";",
"int",
"action",
"=",
"scanner",
".",
"nextInt",
"(",
")",
";",
"switch",
"(",
"action",
")",
"{",
"case",
"1",
":",
"salvar",
"(",
"scanner",
")",
";",
"break",
";",
"case",
"2",
":",
"atualizar",
"(",
"scanner",
")",
";",
"break",
";",
"case",
"3",
":",
"visualizar",
"(",
"scanner",
")",
";",
"break",
";",
"case",
"4",
":",
"deletar",
"(",
"scanner",
")",
";",
"break",
";",
"default",
":",
"system",
"=",
"false",
";",
"break",
";",
"}",
"}",
"}"
] | [
42,
1
] | [
73,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Daily. | null | converte o formato de data de UTC pra um humanamente legivel | converte o formato de data de UTC pra um humanamente legivel | public String dateFormater(long date){
DateTimeFormatter formatter =
DateTimeFormatter.ofPattern("dd/MM/yyyy"); //pattern da data
long unixTime = date;
final String formattedDtm = Instant.ofEpochSecond(unixTime)
.atZone(ZoneId.of("GMT-3")) //nesse parametro que muda o fusohorário, por padrão é o horário de sp
.format(formatter);
return(formattedDtm);
} | [
"public",
"String",
"dateFormater",
"(",
"long",
"date",
")",
"{",
"DateTimeFormatter",
"formatter",
"=",
"DateTimeFormatter",
".",
"ofPattern",
"(",
"\"dd/MM/yyyy\"",
")",
";",
"//pattern da data",
"long",
"unixTime",
"=",
"date",
";",
"final",
"String",
"formattedDtm",
"=",
"Instant",
".",
"ofEpochSecond",
"(",
"unixTime",
")",
".",
"atZone",
"(",
"ZoneId",
".",
"of",
"(",
"\"GMT-3\"",
")",
")",
"//nesse parametro que muda o fusohorário, por padrão é o horário de sp",
".",
"format",
"(",
"formatter",
")",
";",
"return",
"(",
"formattedDtm",
")",
";",
"}"
] | [
82,
4
] | [
92,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Data. | null | Usuário insere a data | Usuário insere a data | public boolean isBissexto(){
boolean resposta=false;
if (this.getAno()%4==0){
if(this.getAno()%100==0){
if(this.getAno()%400==0){
resposta = true;
}
}
}
return resposta;
} | [
"public",
"boolean",
"isBissexto",
"(",
")",
"{",
"boolean",
"resposta",
"=",
"false",
";",
"if",
"(",
"this",
".",
"getAno",
"(",
")",
"%",
"4",
"==",
"0",
")",
"{",
"if",
"(",
"this",
".",
"getAno",
"(",
")",
"%",
"100",
"==",
"0",
")",
"{",
"if",
"(",
"this",
".",
"getAno",
"(",
")",
"%",
"400",
"==",
"0",
")",
"{",
"resposta",
"=",
"true",
";",
"}",
"}",
"}",
"return",
"resposta",
";",
"}"
] | [
91,
4
] | [
101,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
InsertionSort. | null | ------------ Organizar por precipitação ------------ \\ | ------------ Organizar por precipitação ------------ \\ | public long organizaPrecipitacaoCres(){
int ini = 1,
chg;
double men;
tempo1 = System.currentTimeMillis();
while (ini < lista.size()){
men = lista.get(ini).getPrecipitacao();
Informacoes Info = lista.get(ini);
chg = ini - 1;
while (chg>-1 && men < lista.get(chg).getPrecipitacao()){
lista.set(chg + 1, lista.get(chg));
chg --;
}
lista.set(chg+1,Info);
ini++;
}
tempo2 = System.currentTimeMillis();
return tempo2 - tempo1;
} | [
"public",
"long",
"organizaPrecipitacaoCres",
"(",
")",
"{",
"int",
"ini",
"=",
"1",
",",
"chg",
";",
"double",
"men",
";",
"tempo1",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"ini",
"<",
"lista",
".",
"size",
"(",
")",
")",
"{",
"men",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
".",
"getPrecipitacao",
"(",
")",
";",
"Informacoes",
"Info",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
";",
"chg",
"=",
"ini",
"-",
"1",
";",
"while",
"(",
"chg",
">",
"-",
"1",
"&&",
"men",
"<",
"lista",
".",
"get",
"(",
"chg",
")",
".",
"getPrecipitacao",
"(",
")",
")",
"{",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"lista",
".",
"get",
"(",
"chg",
")",
")",
";",
"chg",
"--",
";",
"}",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"Info",
")",
";",
"ini",
"++",
";",
"}",
"tempo2",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"return",
"tempo2",
"-",
"tempo1",
";",
"}"
] | [
320,
4
] | [
338,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Bank. | null | Remove usando isntância da conta | Remove usando isntância da conta | public void removeAccount(BankAccount account) {
for (BankAccount conta : this.accounts) {
if (conta.equals(account)) {
this.accounts.remove(conta);
break;
}
}
} | [
"public",
"void",
"removeAccount",
"(",
"BankAccount",
"account",
")",
"{",
"for",
"(",
"BankAccount",
"conta",
":",
"this",
".",
"accounts",
")",
"{",
"if",
"(",
"conta",
".",
"equals",
"(",
"account",
")",
")",
"{",
"this",
".",
"accounts",
".",
"remove",
"(",
"conta",
")",
";",
"break",
";",
"}",
"}",
"}"
] | [
122,
4
] | [
129,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
GraphSemanticLevelMarkerStepMeta. | null | Carregar campos a partir do XML de um .ktr | Carregar campos a partir do XML de um .ktr | @Override
public void loadXML(Node stepDomNode, List<DatabaseMeta> databases, Map<String, Counter> sequenceCounters)
throws KettleXMLException {
inputGraph = XMLHandler.getTagValue(stepDomNode, Field.INPUT_GRAPH.name());
outputSubject = XMLHandler.getTagValue(stepDomNode, Field.OUTPUT_SUBJECT.name());
outputPredicate = XMLHandler.getTagValue(stepDomNode, Field.OUTPUT_PREDICATE.name());
outputObject = XMLHandler.getTagValue(stepDomNode, Field.OUTPUT_OBJECT.name());
browseFilename = XMLHandler.getTagValue(stepDomNode, Field.INPUT_BROWSE_FILE_NAME.name());
rulesFilename = XMLHandler.getTagValue(stepDomNode, Field.INPUT_RULES_FILE_NAME.name());
} | [
"@",
"Override",
"public",
"void",
"loadXML",
"(",
"Node",
"stepDomNode",
",",
"List",
"<",
"DatabaseMeta",
">",
"databases",
",",
"Map",
"<",
"String",
",",
"Counter",
">",
"sequenceCounters",
")",
"throws",
"KettleXMLException",
"{",
"inputGraph",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"INPUT_GRAPH",
".",
"name",
"(",
")",
")",
";",
"outputSubject",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"OUTPUT_SUBJECT",
".",
"name",
"(",
")",
")",
";",
"outputPredicate",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"OUTPUT_PREDICATE",
".",
"name",
"(",
")",
")",
";",
"outputObject",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"OUTPUT_OBJECT",
".",
"name",
"(",
")",
")",
";",
"browseFilename",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"INPUT_BROWSE_FILE_NAME",
".",
"name",
"(",
")",
")",
";",
"rulesFilename",
"=",
"XMLHandler",
".",
"getTagValue",
"(",
"stepDomNode",
",",
"Field",
".",
"INPUT_RULES_FILE_NAME",
".",
"name",
"(",
")",
")",
";",
"}"
] | [
90,
1
] | [
99,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Order. | null | Soma dos produtos escolhidos | Soma dos produtos escolhidos | public Double getTotal() {
double soma = 0.0;
for (Product p : products) {
soma += p.getPrice();
}
return soma;
} | [
"public",
"Double",
"getTotal",
"(",
")",
"{",
"double",
"soma",
"=",
"0.0",
";",
"for",
"(",
"Product",
"p",
":",
"products",
")",
"{",
"soma",
"+=",
"p",
".",
"getPrice",
"(",
")",
";",
"}",
"return",
"soma",
";",
"}"
] | [
116,
2
] | [
122,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ListMealsFragment. | null | Chama serviço para recuperar as refeições | Chama serviço para recuperar as refeições | private boolean doNewRequisition() {
String auth = PreferencesUtils.getAccessKeyOnSharedPreferences(getContext());
String matricula = AlunoDAO.getInstance(getActivity().getBaseContext()).find().getMatricula();
Call<List<DiaRefeicao>> call = ConnectionServer.getInstance().getService().listaRefeicoes(auth, matricula);
Response<List<DiaRefeicao>> response = null;
try {
response = call.execute();
if (response.isSuccess()) {
addListDiaRefeicao(response.body());
montaTabela(response.body());
} else {
Erro erro = ErrorUtils.parseError(response, getContext());
activity.showMessage(erro.getMensagem());
return false;
}
} catch (IOException e) {
activity.showMessage(getString(R.string.erroconexao));
return false;
}
return true;
} | [
"private",
"boolean",
"doNewRequisition",
"(",
")",
"{",
"String",
"auth",
"=",
"PreferencesUtils",
".",
"getAccessKeyOnSharedPreferences",
"(",
"getContext",
"(",
")",
")",
";",
"String",
"matricula",
"=",
"AlunoDAO",
".",
"getInstance",
"(",
"getActivity",
"(",
")",
".",
"getBaseContext",
"(",
")",
")",
".",
"find",
"(",
")",
".",
"getMatricula",
"(",
")",
";",
"Call",
"<",
"List",
"<",
"DiaRefeicao",
">",
">",
"call",
"=",
"ConnectionServer",
".",
"getInstance",
"(",
")",
".",
"getService",
"(",
")",
".",
"listaRefeicoes",
"(",
"auth",
",",
"matricula",
")",
";",
"Response",
"<",
"List",
"<",
"DiaRefeicao",
">",
">",
"response",
"=",
"null",
";",
"try",
"{",
"response",
"=",
"call",
".",
"execute",
"(",
")",
";",
"if",
"(",
"response",
".",
"isSuccess",
"(",
")",
")",
"{",
"addListDiaRefeicao",
"(",
"response",
".",
"body",
"(",
")",
")",
";",
"montaTabela",
"(",
"response",
".",
"body",
"(",
")",
")",
";",
"}",
"else",
"{",
"Erro",
"erro",
"=",
"ErrorUtils",
".",
"parseError",
"(",
"response",
",",
"getContext",
"(",
")",
")",
";",
"activity",
".",
"showMessage",
"(",
"erro",
".",
"getMensagem",
"(",
")",
")",
";",
"return",
"false",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"activity",
".",
"showMessage",
"(",
"getString",
"(",
"R",
".",
"string",
".",
"erroconexao",
")",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | [
90,
4
] | [
113,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
OkHttpGet. | null | Método chamado pela interface gráfica pra fazer as chamadas de request pra api e pro site | Método chamado pela interface gráfica pra fazer as chamadas de request pra api e pro site | public String getDataFromCity(String cityName){
City city = OkHttpGet.owm.getCityByCityName(cityName); // Solicita os dados da cidade pra API
Coord coord = city.getCoordData(); //Filtra somente os dados necessários pra fazer o request HTTP
//Separa coordenadas pra mandar via metodo GET
String lat = coord.getLatitude().toString();
String lon = coord.getLongitude().toString();
String data = requestForecastJson(lat,lon,cityName); //chama metodo que acessa
return data;
} | [
"public",
"String",
"getDataFromCity",
"(",
"String",
"cityName",
")",
"{",
"City",
"city",
"=",
"OkHttpGet",
".",
"owm",
".",
"getCityByCityName",
"(",
"cityName",
")",
";",
"// Solicita os dados da cidade pra API",
"Coord",
"coord",
"=",
"city",
".",
"getCoordData",
"(",
")",
";",
"//Filtra somente os dados necessários pra fazer o request HTTP",
"//Separa coordenadas pra mandar via metodo GET",
"String",
"lat",
"=",
"coord",
".",
"getLatitude",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"lon",
"=",
"coord",
".",
"getLongitude",
"(",
")",
".",
"toString",
"(",
")",
";",
"String",
"data",
"=",
"requestForecastJson",
"(",
"lat",
",",
"lon",
",",
"cityName",
")",
";",
"//chama metodo que acessa ",
"return",
"data",
";",
"}"
] | [
76,
4
] | [
88,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ChatManager. | null | Método para checar a mensagem recebida e retornar a mensagem desejada | Método para checar a mensagem recebida e retornar a mensagem desejada | public String ChecarMSG(Message message) throws IOException, MalformedURLException, InterruptedException{
String msg = "";
switch (message.getBody().trim()){
case ":1S:":
case ":)":
case ":-)":
case ":2S:":
case ";)":
case ";-)":
case ":3S:":
case ":4S:":
case ":5S:":
case ":P":
case ":p":
case ":-p":
case ":-P":
case ":6S:":
case ";P":
case ";p":
case ";-p":
case ";-P":
case ":7S:":
case ":-D":
case ":D":
case ":8S:":
case ":9S:":
case ":10S:":
case ":11S:":
case ":12S:":
case ":13S:":
case ":14S:":
case ":15S:":
msg = "Emoji feliz";
break;
case ":28S:":
case ":29S:":
case ":(":
case ":-(":
case ":30S:":
case ":31S:":
case ":32S:":
case "?:|":
case ":33S:":
case ":34S:":
case ":36S:":
case ":37S:":
case ":38S:":
case ":39S:":
case ":40S:":
case ":41S:":
msg = "Emoji triste";
break;
case ":16S:":
case ":45O:":
case "(heart)":
case "(redheart)":
case ":46O:":
case "(greenheart)":
case ":47O:":
case "(blueheart)":
case ":48O:":
case "(yellowheart)":
case ":49O:":
case "(purpleheart)":
case ":50O:":
case "(blackheart)":
case "":
msg = "Emoji coracao";
break;
default:
msg = "Mensagem sem comando";
}
// Checa se a mensagem tem algum comando para enviar ao módulo
if(!msg.equals("Mensagem sem comando")){
EnviarMsgESP(msg);
}
return msg;
} | [
"public",
"String",
"ChecarMSG",
"(",
"Message",
"message",
")",
"throws",
"IOException",
",",
"MalformedURLException",
",",
"InterruptedException",
"{",
"String",
"msg",
"=",
"\"\"",
";",
"switch",
"(",
"message",
".",
"getBody",
"(",
")",
".",
"trim",
"(",
")",
")",
"{",
"case",
"\":1S:\"",
":",
"case",
"\":)\"",
":",
"case",
"\":-)\"",
":",
"case",
"\":2S:\"",
":",
"case",
"\";)\"",
":",
"case",
"\";-)\"",
":",
"case",
"\":3S:\"",
":",
"case",
"\":4S:\"",
":",
"case",
"\":5S:\"",
":",
"case",
"\":P\"",
":",
"case",
"\":p\"",
":",
"case",
"\":-p\"",
":",
"case",
"\":-P\"",
":",
"case",
"\":6S:\"",
":",
"case",
"\";P\"",
":",
"case",
"\";p\"",
":",
"case",
"\";-p\"",
":",
"case",
"\";-P\"",
":",
"case",
"\":7S:\"",
":",
"case",
"\":-D\"",
":",
"case",
"\":D\"",
":",
"case",
"\":8S:\"",
":",
"case",
"\":9S:\"",
":",
"case",
"\":10S:\"",
":",
"case",
"\":11S:\"",
":",
"case",
"\":12S:\"",
":",
"case",
"\":13S:\"",
":",
"case",
"\":14S:\"",
":",
"case",
"\":15S:\"",
":",
"msg",
"=",
"\"Emoji feliz\"",
";",
"break",
";",
"case",
"\":28S:\"",
":",
"case",
"\":29S:\"",
":",
"case",
"\":(\"",
":",
"case",
"\":-(\"",
":",
"case",
"\":30S:\"",
":",
"case",
"\":31S:\"",
":",
"case",
"\":32S:\"",
":",
"case",
"\"?:|\"",
":",
"case",
"\":33S:\"",
":",
"case",
"\":34S:\"",
":",
"case",
"\":36S:\"",
":",
"case",
"\":37S:\"",
":",
"case",
"\":38S:\"",
":",
"case",
"\":39S:\"",
":",
"case",
"\":40S:\"",
":",
"case",
"\":41S:\"",
":",
"msg",
"=",
"\"Emoji triste\"",
";",
"break",
";",
"case",
"\":16S:\"",
":",
"case",
"\":45O:\"",
":",
"case",
"\"(heart)\"",
":",
"case",
"\"(redheart)\"",
":",
"case",
"\":46O:\"",
":",
"case",
"\"(greenheart)\"",
":",
"case",
"\":47O:\"",
":",
"case",
"\"(blueheart)\"",
":",
"case",
"\":48O:\"",
":",
"case",
"\"(yellowheart)\"",
":",
"case",
"\":49O:\"",
":",
"case",
"\"(purpleheart)\"",
":",
"case",
"\":50O:\"",
":",
"case",
"\"(blackheart)\"",
":",
"case",
"\"\"",
":",
"msg",
"=",
"\"Emoji coracao\"",
";",
"break",
";",
"default",
":",
"msg",
"=",
"\"Mensagem sem comando\"",
";",
"}",
"// Checa se a mensagem tem algum comando para enviar ao módulo",
"if",
"(",
"!",
"msg",
".",
"equals",
"(",
"\"Mensagem sem comando\"",
")",
")",
"{",
"EnviarMsgESP",
"(",
"msg",
")",
";",
"}",
"return",
"msg",
";",
"}"
] | [
963,
4
] | [
1044,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
InvestimentoController. | null | Evento responsavel pela aplicação da mascara de porcentagem | Evento responsavel pela aplicação da mascara de porcentagem | @FXML
private void porcentageField(KeyEvent e) {
Mask.porcentageField((TextField) (e.getSource()));
} | [
"@",
"FXML",
"private",
"void",
"porcentageField",
"(",
"KeyEvent",
"e",
")",
"{",
"Mask",
".",
"porcentageField",
"(",
"(",
"TextField",
")",
"(",
"e",
".",
"getSource",
"(",
")",
")",
")",
";",
"}"
] | [
482,
1
] | [
485,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cliente. | null | agora criar métodos para o cliente usando o atalho botãodireito -> insert code -> getter and setter -> all -> gerar | agora criar métodos para o cliente usando o atalho botãodireito -> insert code -> getter and setter -> all -> gerar | public int getId() {
return id;
} | [
"public",
"int",
"getId",
"(",
")",
"{",
"return",
"id",
";",
"}"
] | [
12,
4
] | [
14,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ProtocoloController. | null | Retorna uma lista de Protocolos | Retorna uma lista de Protocolos | @RequestMapping(value="/", method=RequestMethod.GET)
@ApiOperation(value="Retorna uma lista de Protocolos")
public ResponseEntity<?> listaProtocolos(){
List<Protocolo> obj = protocoloService.listaProtocolos();
return ResponseEntity.ok().body(obj);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Retorna uma lista de Protocolos\"",
")",
"public",
"ResponseEntity",
"<",
"?",
">",
"listaProtocolos",
"(",
")",
"{",
"List",
"<",
"Protocolo",
">",
"obj",
"=",
"protocoloService",
".",
"listaProtocolos",
"(",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"obj",
")",
";",
"}"
] | [
28,
1
] | [
33,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfiguration. | null | Configurações de Autenticação ( | Configurações de Autenticação ( | @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(this.usersService)
.passwordEncoder(new BCryptPasswordEncoder());
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"AuthenticationManagerBuilder",
"auth",
")",
"throws",
"Exception",
"{",
"auth",
".",
"userDetailsService",
"(",
"this",
".",
"usersService",
")",
".",
"passwordEncoder",
"(",
"new",
"BCryptPasswordEncoder",
"(",
")",
")",
";",
"}"
] | [
63,
4
] | [
67,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CreditCard. | null | montante gasto, verifica tambem se o gasto é permitido | montante gasto, verifica tambem se o gasto é permitido | public void gastar(int quantia, String descr){
// Se o gasto exceder o maximo de credito, entao a transação dá erro
if (saldo()-quantia< 0) {
System.out.println("Crédito Insuficiente para esta transação, só tem mais " + saldo() + "€ disponíveis.");
} else {
// Soma a quantia aos gastos do cartão
gastos += quantia;
//Usa o contador numMovimentos para introduzir a transaçao na lista e incrementa o numMovimentos
movimentos[numMovimentos] = "Valor: " + quantia + "€ " + "Descricao: " + descr;
numMovimentos++;
}
} | [
"public",
"void",
"gastar",
"(",
"int",
"quantia",
",",
"String",
"descr",
")",
"{",
"// Se o gasto exceder o maximo de credito, entao a transação dá erro",
"if",
"(",
"saldo",
"(",
")",
"-",
"quantia",
"<",
"0",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Crédito Insuficiente para esta transação, só tem mais \" + s",
"l",
"o() +",
" ",
" ",
"€",
"isponíveis.\");",
"",
"",
"}",
"else",
"{",
"// Soma a quantia aos gastos do cartão",
"gastos",
"+=",
"quantia",
";",
"//Usa o contador numMovimentos para introduzir a transaçao na lista e incrementa o numMovimentos",
"movimentos",
"[",
"numMovimentos",
"]",
"=",
"\"Valor: \"",
"+",
"quantia",
"+",
"\"€ \" +",
"\"",
"escricao: \" +",
"d",
"scr;",
"",
"numMovimentos",
"++",
";",
"}",
"}"
] | [
65,
4
] | [
76,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Pessoa. | null | metodo especiais | metodo especiais | public String getNome() {
return nome;
} | [
"public",
"String",
"getNome",
"(",
")",
"{",
"return",
"nome",
";",
"}"
] | [
31,
4
] | [
33,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | False | true | method_declaration |
|
FuncoesTopicos. | null | Recebe uma string de proprietário e retorna se possui ou não imoveis | Recebe uma string de proprietário e retorna se possui ou não imoveis | public static boolean q2ProcuraProprietario(String proprietario) {
//System.out.println("Proprietário: " + proprietario);
//Utiliza o iterador imovel para percorrer a lista
for (Imovel imovel : imoveis) {
//Compara se o proprietario do imovel atual é o mesmo que o desejado
if (imovel.getProprietario().equals(proprietario)) {
return true;
}
}
return false;
} | [
"public",
"static",
"boolean",
"q2ProcuraProprietario",
"(",
"String",
"proprietario",
")",
"{",
"//System.out.println(\"Proprietário: \" + proprietario);",
"//Utiliza o iterador imovel para percorrer a lista",
"for",
"(",
"Imovel",
"imovel",
":",
"imoveis",
")",
"{",
"//Compara se o proprietario do imovel atual é o mesmo que o desejado",
"if",
"(",
"imovel",
".",
"getProprietario",
"(",
")",
".",
"equals",
"(",
"proprietario",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | [
49,
4
] | [
59,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
VotingMachinesDeluxe. | null | Aplica a aleatoriedade e contabiliza os votos novamente | Aplica a aleatoriedade e contabiliza os votos novamente | public static boolean verifica_votacao(int n, double a, double f, int votos_a){
int novos_votos_a = 0;
int novos_votos_b = 0;
for(int i = 0; i <= n - 1; i++){
double random = Math.random();
// Computando votos de A
if(i < votos_a-1){
if (random < f) novos_votos_b++;
else novos_votos_a++;
} else {
// Computando votos de B
if (random < f) novos_votos_a++;
else novos_votos_b++;
}
}
return (novos_votos_b > novos_votos_a);
} | [
"public",
"static",
"boolean",
"verifica_votacao",
"(",
"int",
"n",
",",
"double",
"a",
",",
"double",
"f",
",",
"int",
"votos_a",
")",
"{",
"int",
"novos_votos_a",
"=",
"0",
";",
"int",
"novos_votos_b",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"n",
"-",
"1",
";",
"i",
"++",
")",
"{",
"double",
"random",
"=",
"Math",
".",
"random",
"(",
")",
";",
"// Computando votos de A",
"if",
"(",
"i",
"<",
"votos_a",
"-",
"1",
")",
"{",
"if",
"(",
"random",
"<",
"f",
")",
"novos_votos_b",
"++",
";",
"else",
"novos_votos_a",
"++",
";",
"}",
"else",
"{",
"// Computando votos de B",
"if",
"(",
"random",
"<",
"f",
")",
"novos_votos_a",
"++",
";",
"else",
"novos_votos_b",
"++",
";",
"}",
"}",
"return",
"(",
"novos_votos_b",
">",
"novos_votos_a",
")",
";",
"}"
] | [
79,
1
] | [
98,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
QuickSort. | null | ===== Métodos de Ordenação por Pais ===== // | ===== Métodos de Ordenação por Pais ===== // | public void quickPaisCres() {
quickPaisCres(0, lista.size() - 1);
} | [
"public",
"void",
"quickPaisCres",
"(",
")",
"{",
"quickPaisCres",
"(",
"0",
",",
"lista",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}"
] | [
211,
4
] | [
213,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Tamanho. | null | No caso de Strings, é um Método. No caso de Arrays, é um Atributo. | No caso de Strings, é um Método. No caso de Arrays, é um Atributo. | public static void main(String[] args) {
String nome = "Mateus";
int tamanho = nome.length(); // Método
System.out.println(tamanho);
String[] nomes = {"Mateus", "Milene", "Gabriela"};
int tamanhos = nomes.length; // Atributo
System.out.println(tamanhos);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"String",
"nome",
"=",
"\"Mateus\"",
";",
"int",
"tamanho",
"=",
"nome",
".",
"length",
"(",
")",
";",
"// Método",
"System",
".",
"out",
".",
"println",
"(",
"tamanho",
")",
";",
"String",
"[",
"]",
"nomes",
"=",
"{",
"\"Mateus\"",
",",
"\"Milene\"",
",",
"\"Gabriela\"",
"}",
";",
"int",
"tamanhos",
"=",
"nomes",
".",
"length",
";",
"// Atributo",
"System",
".",
"out",
".",
"println",
"(",
"tamanhos",
")",
";",
"}"
] | [
6,
4
] | [
14,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Endereco. | null | Método para recuperar as informações do endereço passado por ele | Método para recuperar as informações do endereço passado por ele | public String getEndereco(Endereco e){
return "O endereço correspondente ao CEP é:\nCEP: " + e.cep + "\nLogradouro: " + e.logradouro +
"\nComplemento: " + e.complemento + "\nBairro: " + e.bairro + "\nLocalidade: " + e.localidade +
"\nUF: " + e.uf + "\nDDD: " + e.ddd + "\nIBGE: " + e.ibge;
} | [
"public",
"String",
"getEndereco",
"(",
"Endereco",
"e",
")",
"{",
"return",
"\"O endereço correspondente ao CEP é:\\nCEP: \" +",
"e",
"c",
"e",
"p +",
"\"",
"nLogradouro: \" +",
"e",
"l",
"o",
"gradouro +",
"\r",
"\"\\nComplemento: \"",
"+",
"e",
".",
"complemento",
"+",
"\"\\nBairro: \"",
"+",
"e",
".",
"bairro",
"+",
"\"\\nLocalidade: \"",
"+",
"e",
".",
"localidade",
"+",
"\"\\nUF: \"",
"+",
"e",
".",
"uf",
"+",
"\"\\nDDD: \"",
"+",
"e",
".",
"ddd",
"+",
"\"\\nIBGE: \"",
"+",
"e",
".",
"ibge",
";",
"}"
] | [
32,
4
] | [
36,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DesafioMeuTimeApplication. | null | Retorna o nome do time. | Retorna o nome do time. | @Desafio("buscarNomeTime")
public String buscarNomeTime(Long idTime) {
//Caso o time informado não exista, retornar br.com.codenation.desafio.exceptions.TimeNaoEncontradoException
return this.buscaTimePeloId(idTime).orElseThrow(TimeNaoEncontradoException::new).getNome();
} | [
"@",
"Desafio",
"(",
"\"buscarNomeTime\"",
")",
"public",
"String",
"buscarNomeTime",
"(",
"Long",
"idTime",
")",
"{",
"//Caso o time informado não exista, retornar br.com.codenation.desafio.exceptions.TimeNaoEncontradoException",
"return",
"this",
".",
"buscaTimePeloId",
"(",
"idTime",
")",
".",
"orElseThrow",
"(",
"TimeNaoEncontradoException",
"::",
"new",
")",
".",
"getNome",
"(",
")",
";",
"}"
] | [
75,
1
] | [
79,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
BuscaUsuarioController. | null | Esta método é para buscar um usuário. | Esta método é para buscar um usuário. | @GetMapping("/busca")
public String entrarBusca() {
return "usuario/busca";
} | [
"@",
"GetMapping",
"(",
"\"/busca\"",
")",
"public",
"String",
"entrarBusca",
"(",
")",
"{",
"return",
"\"usuario/busca\"",
";",
"}"
] | [
30,
2
] | [
33,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
EmpresaActivity. | null | Criando as opções do menu | Criando as opções do menu | @Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_empresa, menu);
return super.onCreateOptionsMenu(menu);
} | [
"@",
"Override",
"public",
"boolean",
"onCreateOptionsMenu",
"(",
"Menu",
"menu",
")",
"{",
"MenuInflater",
"inflater",
"=",
"getMenuInflater",
"(",
")",
";",
"inflater",
".",
"inflate",
"(",
"R",
".",
"menu",
".",
"menu_empresa",
",",
"menu",
")",
";",
"return",
"super",
".",
"onCreateOptionsMenu",
"(",
"menu",
")",
";",
"}"
] | [
90,
4
] | [
96,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
WS3D_Controller. | null | Visualização das coisas no mapa | Visualização das coisas no mapa | private Thing things_Vison(){
Thing a = null;
Creature.updateState();
List<Thing> LThings = Creature.getThingsInVision();
for (int i = 0; i < LThings.size(); i++){
a = LThings.get(i);
// O print ira verificar todas as coisas no campo de visão da criatura
//System.out.println("Things: "+ a);
if (Creature.calculateDistanceTo(a) < 30){
}
}
return a;
} | [
"private",
"Thing",
"things_Vison",
"(",
")",
"{",
"Thing",
"a",
"=",
"null",
";",
"Creature",
".",
"updateState",
"(",
")",
";",
"List",
"<",
"Thing",
">",
"LThings",
"=",
"Creature",
".",
"getThingsInVision",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"LThings",
".",
"size",
"(",
")",
";",
"i",
"++",
")",
"{",
"a",
"=",
"LThings",
".",
"get",
"(",
"i",
")",
";",
"// O print ira verificar todas as coisas no campo de visão da criatura\r",
"//System.out.println(\"Things: \"+ a);\r",
"if",
"(",
"Creature",
".",
"calculateDistanceTo",
"(",
"a",
")",
"<",
"30",
")",
"{",
"}",
"}",
"return",
"a",
";",
"}"
] | [
367,
4
] | [
381,
4
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Produto. | null | ======== Método equals para comparação de propriedades ======== | ======== Método equals para comparação de propriedades ======== | @Override
public boolean equals(Object object) {
if (object == this)
return true;
if (!(object instanceof Produto))
return false;
Produto produto = (Produto) object;
return this.getId() == produto.getId();
} | [
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"object",
")",
"{",
"if",
"(",
"object",
"==",
"this",
")",
"return",
"true",
";",
"if",
"(",
"!",
"(",
"object",
"instanceof",
"Produto",
")",
")",
"return",
"false",
";",
"Produto",
"produto",
"=",
"(",
"Produto",
")",
"object",
";",
"return",
"this",
".",
"getId",
"(",
")",
"==",
"produto",
".",
"getId",
"(",
")",
";",
"}"
] | [
62,
4
] | [
72,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FuncoesTopicos. | null | Verifica se a cidade já se encontra na lista | Verifica se a cidade já se encontra na lista | private static boolean estaNaLista(String cidade){
for (String cid : cidades){
if(cid.equals(cidade))
return true;
}
return false;
} | [
"private",
"static",
"boolean",
"estaNaLista",
"(",
"String",
"cidade",
")",
"{",
"for",
"(",
"String",
"cid",
":",
"cidades",
")",
"{",
"if",
"(",
"cid",
".",
"equals",
"(",
"cidade",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | [
40,
4
] | [
46,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ListaDinamica. | null | Reitrar objeto no fim da lista | Reitrar objeto no fim da lista | public Object retirarFim() {
return(retirar(contador));
} | [
"public",
"Object",
"retirarFim",
"(",
")",
"{",
"return",
"(",
"retirar",
"(",
"contador",
")",
")",
";",
"}"
] | [
151,
1
] | [
153,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
JediService. | null | Converte de Jedi para JediDTO e por fim return em lista | Converte de Jedi para JediDTO e por fim return em lista | public List<JediDTO> findAll() {
List<Jedi> result = repository.findAll();
return result.stream()
.map(JediDTO::new)
.collect(Collectors.toList());
} | [
"public",
"List",
"<",
"JediDTO",
">",
"findAll",
"(",
")",
"{",
"List",
"<",
"Jedi",
">",
"result",
"=",
"repository",
".",
"findAll",
"(",
")",
";",
"return",
"result",
".",
"stream",
"(",
")",
".",
"map",
"(",
"JediDTO",
"::",
"new",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | [
20,
4
] | [
25,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ProfessorService. | null | Metodo que vai Inserir ou atualizar os dados do Professor | Metodo que vai Inserir ou atualizar os dados do Professor | public void saveOrUpdate(Professor obj){
if(obj.getIdnome()== null){
dao.insert(obj);
}
else{
dao.update(obj);
}
} | [
"public",
"void",
"saveOrUpdate",
"(",
"Professor",
"obj",
")",
"{",
"if",
"(",
"obj",
".",
"getIdnome",
"(",
")",
"==",
"null",
")",
"{",
"dao",
".",
"insert",
"(",
"obj",
")",
";",
"}",
"else",
"{",
"dao",
".",
"update",
"(",
"obj",
")",
";",
"}",
"}"
] | [
22,
4
] | [
29,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ConfiguracaoSeguranca. | null | configurações de autorização de acesso | configurações de autorização de acesso | @Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.GET, "/categorias/{id:[0-9]+}").permitAll()
.antMatchers(HttpMethod.POST, "/usuarios").permitAll()
.antMatchers(HttpMethod.POST, "/categorias").permitAll()
.antMatchers(HttpMethod.POST, "/respostas").permitAll()
.antMatchers(HttpMethod.POST, "/produtos").permitAll()
.antMatchers(HttpMethod.POST, "/imagens").permitAll()
.antMatchers("/h2-console/**").permitAll()
.antMatchers("/auth/**").permitAll()
.anyRequest().authenticated()
.and().csrf().disable()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().addFilterBefore(new AutenticacaoViaTokenFilter(tokenService, usuarioRepository), UsernamePasswordAuthenticationFilter.class);
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"HttpSecurity",
"http",
")",
"throws",
"Exception",
"{",
"http",
".",
"authorizeRequests",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"GET",
",",
"\"/categorias/{id:[0-9]+}\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/usuarios\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/categorias\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/respostas\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/produtos\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/imagens\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"\"/h2-console/**\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"\"/auth/**\"",
")",
".",
"permitAll",
"(",
")",
".",
"anyRequest",
"(",
")",
".",
"authenticated",
"(",
")",
".",
"and",
"(",
")",
".",
"csrf",
"(",
")",
".",
"disable",
"(",
")",
".",
"sessionManagement",
"(",
")",
".",
"sessionCreationPolicy",
"(",
"SessionCreationPolicy",
".",
"STATELESS",
")",
".",
"and",
"(",
")",
".",
"addFilterBefore",
"(",
"new",
"AutenticacaoViaTokenFilter",
"(",
"tokenService",
",",
"usuarioRepository",
")",
",",
"UsernamePasswordAuthenticationFilter",
".",
"class",
")",
";",
"}"
] | [
44,
1
] | [
59,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Coracao. | null | O coração da tela. | O coração da tela. | @Override
public void contatoTransponivel(ArrayList<Elemento> listaElementos) {
int vidasHeroi = Desenhador.getTelaDoJogo().getVidasHeroi();
Desenhador.getTelaDoJogo().setVidasHeroi(vidasHeroi + 1);
listaElementos.remove(this);
return;
} | [
"@",
"Override",
"public",
"void",
"contatoTransponivel",
"(",
"ArrayList",
"<",
"Elemento",
">",
"listaElementos",
")",
"{",
"int",
"vidasHeroi",
"=",
"Desenhador",
".",
"getTelaDoJogo",
"(",
")",
".",
"getVidasHeroi",
"(",
")",
";",
"Desenhador",
".",
"getTelaDoJogo",
"(",
")",
".",
"setVidasHeroi",
"(",
"vidasHeroi",
"+",
"1",
")",
";",
"listaElementos",
".",
"remove",
"(",
"this",
")",
";",
"return",
";",
"}"
] | [
62,
4
] | [
69,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FuncoesTopicos. | null | Os iteradores são especificos para o proprietario desejado | Os iteradores são especificos para o proprietario desejado | public static ListIterator<Imovel> q7RetornarIteradores(String nome){
List<Imovel> lista = new LinkedList<>();
//Utiliza o iterador imovel para percorrer a lista
for(Imovel imovel : imoveis){
//Compara se o proprietario do imovel atual é o mesmo que o desejado
if(imovel.getProprietario().equals(nome)){
lista.add(imovel);
}
}
//Pega uma lista de iteradores do imovel
ListIterator<Imovel> iteradores = lista.listIterator();
return iteradores;
} | [
"public",
"static",
"ListIterator",
"<",
"Imovel",
">",
"q7RetornarIteradores",
"(",
"String",
"nome",
")",
"{",
"List",
"<",
"Imovel",
">",
"lista",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"//Utiliza o iterador imovel para percorrer a lista",
"for",
"(",
"Imovel",
"imovel",
":",
"imoveis",
")",
"{",
"//Compara se o proprietario do imovel atual é o mesmo que o desejado",
"if",
"(",
"imovel",
".",
"getProprietario",
"(",
")",
".",
"equals",
"(",
"nome",
")",
")",
"{",
"lista",
".",
"add",
"(",
"imovel",
")",
";",
"}",
"}",
"//Pega uma lista de iteradores do imovel",
"ListIterator",
"<",
"Imovel",
">",
"iteradores",
"=",
"lista",
".",
"listIterator",
"(",
")",
";",
"return",
"iteradores",
";",
"}"
] | [
126,
5
] | [
141,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
MainActivity. | null | navega no ArrayList preenchido no popular tela | navega no ArrayList preenchido no popular tela | public void showProximo(View view){
EditText id = findViewById(R.id.id_cliente);
EditText nome = findViewById(R.id.nome);
EditText cpf = findViewById(R.id.cpf);
EditText data_nasc = findViewById(R.id.data_nasc);
Cliente c = clientes.get(idAtual);
id.setText(c.getId_cliente().toString());
nome.setText(c.getNome());
cpf.setText(c.getCpf());
data_nasc.setText(c.getData_nasc());
idAtual++;
if(idAtual == totalClientes) idAtual = 0;
} | [
"public",
"void",
"showProximo",
"(",
"View",
"view",
")",
"{",
"EditText",
"id",
"=",
"findViewById",
"(",
"R",
".",
"id",
".",
"id_cliente",
")",
";",
"EditText",
"nome",
"=",
"findViewById",
"(",
"R",
".",
"id",
".",
"nome",
")",
";",
"EditText",
"cpf",
"=",
"findViewById",
"(",
"R",
".",
"id",
".",
"cpf",
")",
";",
"EditText",
"data_nasc",
"=",
"findViewById",
"(",
"R",
".",
"id",
".",
"data_nasc",
")",
";",
"Cliente",
"c",
"=",
"clientes",
".",
"get",
"(",
"idAtual",
")",
";",
"id",
".",
"setText",
"(",
"c",
".",
"getId_cliente",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"nome",
".",
"setText",
"(",
"c",
".",
"getNome",
"(",
")",
")",
";",
"cpf",
".",
"setText",
"(",
"c",
".",
"getCpf",
"(",
")",
")",
";",
"data_nasc",
".",
"setText",
"(",
"c",
".",
"getData_nasc",
"(",
")",
")",
";",
"idAtual",
"++",
";",
"if",
"(",
"idAtual",
"==",
"totalClientes",
")",
"idAtual",
"=",
"0",
";",
"}"
] | [
66,
4
] | [
82,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Secretaria. | null | Inscreve os cursos ofertados para o semestre | Inscreve os cursos ofertados para o semestre | public boolean inserirCurso(Curso novoCurso){
for (Curso curso : semestre) {
if (curso.getId() == novoCurso.getId())
return false;
else
return(semestre.add(novoCurso));
}
return false;
} | [
"public",
"boolean",
"inserirCurso",
"(",
"Curso",
"novoCurso",
")",
"{",
"for",
"(",
"Curso",
"curso",
":",
"semestre",
")",
"{",
"if",
"(",
"curso",
".",
"getId",
"(",
")",
"==",
"novoCurso",
".",
"getId",
"(",
")",
")",
"return",
"false",
";",
"else",
"return",
"(",
"semestre",
".",
"add",
"(",
"novoCurso",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | [
22,
4
] | [
31,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Habitacion. | null | Setter para atributo Estado | Setter para atributo Estado | public void setEstado(String EstadoAAsignar)
{
Estado = EstadoAAsignar;
} | [
"public",
"void",
"setEstado",
"(",
"String",
"EstadoAAsignar",
")",
"{",
"Estado",
"=",
"EstadoAAsignar",
";",
"}"
] | [
68,
4
] | [
71,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Arrays. | null | Começam com os valores 0 | Começam com os valores 0 | public static void main(String[] args){
//Formas de declarar:
String[] nomeDoVetor = new String[2];
int[] vetorNumerico = new int[3];
double[] vetorJaDeclarado = {1,2,3,4,5};
//Alterando valor:
System.out.println("antes: "+vetorJaDeclarado[1]);
vetorJaDeclarado[1] = 9;
System.out.println("depois: "+vetorJaDeclarado[1]);
//Tamanho:
System.out.println("Tamanho: "+vetorJaDeclarado.length);
//Percorrendo:
for (int i=0; i<5; i++){
System.out.println(vetorJaDeclarado[i]);
}
//Matriz:_______________________________________________________
int[][] matriz = {{1,2,3},{4,5,6},{7,8,9}};
for (int i=0; i<3; i++){
for (int j=0; j<3; j++){
System.out.print(matriz[i][j]+" ");
}
System.out.println();
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"//Formas de declarar:",
"String",
"[",
"]",
"nomeDoVetor",
"=",
"new",
"String",
"[",
"2",
"]",
";",
"int",
"[",
"]",
"vetorNumerico",
"=",
"new",
"int",
"[",
"3",
"]",
";",
"double",
"[",
"]",
"vetorJaDeclarado",
"=",
"{",
"1",
",",
"2",
",",
"3",
",",
"4",
",",
"5",
"}",
";",
"//Alterando valor:",
"System",
".",
"out",
".",
"println",
"(",
"\"antes: \"",
"+",
"vetorJaDeclarado",
"[",
"1",
"]",
")",
";",
"vetorJaDeclarado",
"[",
"1",
"]",
"=",
"9",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"depois: \"",
"+",
"vetorJaDeclarado",
"[",
"1",
"]",
")",
";",
"//Tamanho:",
"System",
".",
"out",
".",
"println",
"(",
"\"Tamanho: \"",
"+",
"vetorJaDeclarado",
".",
"length",
")",
";",
"//Percorrendo:",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"5",
";",
"i",
"++",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"vetorJaDeclarado",
"[",
"i",
"]",
")",
";",
"}",
"//Matriz:_______________________________________________________",
"int",
"[",
"]",
"[",
"]",
"matriz",
"=",
"{",
"{",
"1",
",",
"2",
",",
"3",
"}",
",",
"{",
"4",
",",
"5",
",",
"6",
"}",
",",
"{",
"7",
",",
"8",
",",
"9",
"}",
"}",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
")",
"{",
"for",
"(",
"int",
"j",
"=",
"0",
";",
"j",
"<",
"3",
";",
"j",
"++",
")",
"{",
"System",
".",
"out",
".",
"print",
"(",
"matriz",
"[",
"i",
"]",
"[",
"j",
"]",
"+",
"\" \"",
")",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
")",
";",
"}",
"}"
] | [
5,
4
] | [
32,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Pagina. | null | Reconstrói uma página a partir de um vetor de bytes lido no arquivo | Reconstrói uma página a partir de um vetor de bytes lido no arquivo | public void setBytes(byte[] buffer) throws IOException {
// Usa um fluxo de bytes para leitura dos atributos
ByteArrayInputStream ba = new ByteArrayInputStream(buffer);
DataInputStream in = new DataInputStream(ba);
byte[] bs = new byte[TAMANHO_CHAVE];
// Lê a quantidade de elementos da página
n = in.readInt();
// Lê todos os elementos (reais ou vazios)
int i=0;
while(i<maxElementos) {
filhos[i] = in.readLong();
in.read(bs);
chaves[i] = (new String(bs)).trim();
dados[i] = in.readInt();
i++;
}
filhos[i] = in.readLong();
proxima = in.readLong();
} | [
"public",
"void",
"setBytes",
"(",
"byte",
"[",
"]",
"buffer",
")",
"throws",
"IOException",
"{",
"// Usa um fluxo de bytes para leitura dos atributos",
"ByteArrayInputStream",
"ba",
"=",
"new",
"ByteArrayInputStream",
"(",
"buffer",
")",
";",
"DataInputStream",
"in",
"=",
"new",
"DataInputStream",
"(",
"ba",
")",
";",
"byte",
"[",
"]",
"bs",
"=",
"new",
"byte",
"[",
"TAMANHO_CHAVE",
"]",
";",
"// Lê a quantidade de elementos da página",
"n",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"// Lê todos os elementos (reais ou vazios)",
"int",
"i",
"=",
"0",
";",
"while",
"(",
"i",
"<",
"maxElementos",
")",
"{",
"filhos",
"[",
"i",
"]",
"=",
"in",
".",
"readLong",
"(",
")",
";",
"in",
".",
"read",
"(",
"bs",
")",
";",
"chaves",
"[",
"i",
"]",
"=",
"(",
"new",
"String",
"(",
"bs",
")",
")",
".",
"trim",
"(",
")",
";",
"dados",
"[",
"i",
"]",
"=",
"in",
".",
"readInt",
"(",
")",
";",
"i",
"++",
";",
"}",
"filhos",
"[",
"i",
"]",
"=",
"in",
".",
"readLong",
"(",
")",
";",
"proxima",
"=",
"in",
".",
"readLong",
"(",
")",
";",
"}"
] | [
146,
8
] | [
167,
9
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
clienteController. | null | Serviço para realizar um depósito em uma determinada conta corrente | Serviço para realizar um depósito em uma determinada conta corrente | @PutMapping("/v1/deposito/{numeroConta}")
public ResponseEntity<Object> depositoConta(@PathVariable ("numeroConta") double numeroConta, @RequestBody double valor){
try {
Cliente cliente = clienteRepository.getOne(numeroConta);
cliente.deposito(valor);
Cliente clienteDeposito = clienteRepository.save(cliente);
return ResponseEntity.ok(clienteDeposito);
} catch (Exception e) {
e.printStackTrace();
return ResponseEntity.status(500).body(null);
}
} | [
"@",
"PutMapping",
"(",
"\"/v1/deposito/{numeroConta}\"",
")",
"public",
"ResponseEntity",
"<",
"Object",
">",
"depositoConta",
"(",
"@",
"PathVariable",
"(",
"\"numeroConta\"",
")",
"double",
"numeroConta",
",",
"@",
"RequestBody",
"double",
"valor",
")",
"{",
"try",
"{",
"Cliente",
"cliente",
"=",
"clienteRepository",
".",
"getOne",
"(",
"numeroConta",
")",
";",
"cliente",
".",
"deposito",
"(",
"valor",
")",
";",
"Cliente",
"clienteDeposito",
"=",
"clienteRepository",
".",
"save",
"(",
"cliente",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
"clienteDeposito",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"return",
"ResponseEntity",
".",
"status",
"(",
"500",
")",
".",
"body",
"(",
"null",
")",
";",
"}",
"}"
] | [
39,
4
] | [
50,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Ordenacao. | null | Exibe o vetor passado como parametro | Exibe o vetor passado como parametro | public String exibirVetor (int[] vet) {
String strVet = "";
for (int i = 0; i < vet.length; i++){
strVet += vet[i] + " ";
}
return (strVet);
} | [
"public",
"String",
"exibirVetor",
"(",
"int",
"[",
"]",
"vet",
")",
"{",
"String",
"strVet",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"vet",
".",
"length",
";",
"i",
"++",
")",
"{",
"strVet",
"+=",
"vet",
"[",
"i",
"]",
"+",
"\" \"",
";",
"}",
"return",
"(",
"strVet",
")",
";",
"}"
] | [
14,
4
] | [
20,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ConnectionFactory. | null | metodo para conexao retonrnado o emf | metodo para conexao retonrnado o emf | public EntityManager getConnection() {
return emf.createEntityManager();
} | [
"public",
"EntityManager",
"getConnection",
"(",
")",
"{",
"return",
"emf",
".",
"createEntityManager",
"(",
")",
";",
"}"
] | [
12,
1
] | [
16,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
GerenteMySQL. | null | Retorna a lista de artistas cadastrados no banco | Retorna a lista de artistas cadastrados no banco | @Override
public List<Artista> getListaArtistas() {
Connection conn = null;
PreparedStatement ps = null;
HashMap<Integer, Artista> lista = new HashMap<Integer, Artista>();
try {
conn = C3P0Pool.getConnection();
String sql = "select " + "a.numeroinscricao, a.nome, a.sexo, a.email, a.obs, a.telefone, " + "e.logradouro, e.cep, e.estado, e.bairro, e.cidade, e.pais " + "from artista a join endereco e on (a.numeroinscricao = e.fk_artista) " + "order by numeroinscricao;";
ps = conn.prepareStatement(sql);
ResultSet rs = ps.executeQuery();
while (rs.next()) {
try {
Artista artista = this.getArtista(rs);
lista.put(artista.getNumeroInscricao(), artista);
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
close(conn, ps);
}
return new ArrayList<Artista>(lista.values());
} | [
"@",
"Override",
"public",
"List",
"<",
"Artista",
">",
"getListaArtistas",
"(",
")",
"{",
"Connection",
"conn",
"=",
"null",
";",
"PreparedStatement",
"ps",
"=",
"null",
";",
"HashMap",
"<",
"Integer",
",",
"Artista",
">",
"lista",
"=",
"new",
"HashMap",
"<",
"Integer",
",",
"Artista",
">",
"(",
")",
";",
"try",
"{",
"conn",
"=",
"C3P0Pool",
".",
"getConnection",
"(",
")",
";",
"String",
"sql",
"=",
"\"select \"",
"+",
"\"a.numeroinscricao, a.nome, a.sexo, a.email, a.obs, a.telefone, \"",
"+",
"\"e.logradouro, e.cep, e.estado, e.bairro, e.cidade, e.pais \"",
"+",
"\"from artista a join endereco e on (a.numeroinscricao = e.fk_artista) \"",
"+",
"\"order by numeroinscricao;\"",
";",
"ps",
"=",
"conn",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"ResultSet",
"rs",
"=",
"ps",
".",
"executeQuery",
"(",
")",
";",
"while",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"try",
"{",
"Artista",
"artista",
"=",
"this",
".",
"getArtista",
"(",
"rs",
")",
";",
"lista",
".",
"put",
"(",
"artista",
".",
"getNumeroInscricao",
"(",
")",
",",
"artista",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"finally",
"{",
"close",
"(",
"conn",
",",
"ps",
")",
";",
"}",
"return",
"new",
"ArrayList",
"<",
"Artista",
">",
"(",
"lista",
".",
"values",
"(",
")",
")",
";",
"}"
] | [
351,
4
] | [
375,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Jogo. | null | método privado e interno para verificação de Insuficiência Material: | método privado e interno para verificação de Insuficiência Material: | private boolean verificaInsuficiencia() {
int contador = 0; //contador para as peças presentes no jogo
//caso 1: Rei vs Rei
for (int i = 0; i < 32; i++) {
if (pecas[i].getStatus()) { //contando quantas peças estão ativas no jogo
contador++;
}
if (contador > 2) { //se haver mais peças que as descritas no caso
break;
}
}
if (contador == 2 && pecas[7].getStatus() && pecas[23].getStatus()) { //apenas duas peças ativas e ambas são os Reis
return true;
}
//caso 2 e 3: Rei vs Rei e Bispo OU Rei vs Rei e Cavalo
contador = 0;
for (int i = 0; i < 32; i++) {
if (pecas[i].getStatus()) { //contando quantas peças estão ativas no jogo
contador++;
}
if (contador > 3) { //se haver mais peças que as descritas no caso
return false;
}
}
//caso as peças ativas sejam aquelas na primeira opção do caso:
if (contador == 3 && ((pecas[7].getStatus() && pecas[23].getStatus() && (pecas[16].getStatus() && !pecas[17].getStatus() || !pecas[16].getStatus() && pecas[17].getStatus())) || (pecas[23].getStatus() && pecas[7].getStatus() && (pecas[0].getStatus() && !pecas[1].getStatus() || !pecas[0].getStatus() && pecas[1].getStatus())))) {
return true;
}
//caso as peças ativas sejam aquelas na segunda opção do caso:
if (contador == 3 && ((pecas[7].getStatus() && pecas[23].getStatus() && (!pecas[18].getStatus() && pecas[19].getStatus() || pecas[18].getStatus() && !pecas[19].getStatus())) || (pecas[23].getStatus() && pecas[7].getStatus() && (!pecas[2].getStatus() && pecas[3].getStatus() || pecas[2].getStatus() && !pecas[3].getStatus())))) {
return true;
}
return false;
} | [
"private",
"boolean",
"verificaInsuficiencia",
"(",
")",
"{",
"int",
"contador",
"=",
"0",
";",
"//contador para as peças presentes no jogo",
"//caso 1: Rei vs Rei ",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"32",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pecas",
"[",
"i",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//contando quantas peças estão ativas no jogo",
"contador",
"++",
";",
"}",
"if",
"(",
"contador",
">",
"2",
")",
"{",
"//se haver mais peças que as descritas no caso",
"break",
";",
"}",
"}",
"if",
"(",
"contador",
"==",
"2",
"&&",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//apenas duas peças ativas e ambas são os Reis",
"return",
"true",
";",
"}",
"//caso 2 e 3: Rei vs Rei e Bispo OU Rei vs Rei e Cavalo",
"contador",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"32",
";",
"i",
"++",
")",
"{",
"if",
"(",
"pecas",
"[",
"i",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//contando quantas peças estão ativas no jogo",
"contador",
"++",
";",
"}",
"if",
"(",
"contador",
">",
"3",
")",
"{",
"//se haver mais peças que as descritas no caso",
"return",
"false",
";",
"}",
"}",
"//caso as peças ativas sejam aquelas na primeira opção do caso:",
"if",
"(",
"contador",
"==",
"3",
"&&",
"(",
"(",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
"&&",
"(",
"pecas",
"[",
"16",
"]",
".",
"getStatus",
"(",
")",
"&&",
"!",
"pecas",
"[",
"17",
"]",
".",
"getStatus",
"(",
")",
"||",
"!",
"pecas",
"[",
"16",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"17",
"]",
".",
"getStatus",
"(",
")",
")",
")",
"||",
"(",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
"&&",
"(",
"pecas",
"[",
"0",
"]",
".",
"getStatus",
"(",
")",
"&&",
"!",
"pecas",
"[",
"1",
"]",
".",
"getStatus",
"(",
")",
"||",
"!",
"pecas",
"[",
"0",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"1",
"]",
".",
"getStatus",
"(",
")",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"//caso as peças ativas sejam aquelas na segunda opção do caso:",
"if",
"(",
"contador",
"==",
"3",
"&&",
"(",
"(",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
"&&",
"(",
"!",
"pecas",
"[",
"18",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"19",
"]",
".",
"getStatus",
"(",
")",
"||",
"pecas",
"[",
"18",
"]",
".",
"getStatus",
"(",
")",
"&&",
"!",
"pecas",
"[",
"19",
"]",
".",
"getStatus",
"(",
")",
")",
")",
"||",
"(",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
"&&",
"(",
"!",
"pecas",
"[",
"2",
"]",
".",
"getStatus",
"(",
")",
"&&",
"pecas",
"[",
"3",
"]",
".",
"getStatus",
"(",
")",
"||",
"pecas",
"[",
"2",
"]",
".",
"getStatus",
"(",
")",
"&&",
"!",
"pecas",
"[",
"3",
"]",
".",
"getStatus",
"(",
")",
")",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | [
290,
4
] | [
329,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ExerciciosStreams. | null | /*Operações intermediárias: retornam um stream e poe ser encadeada
Operações terminais: não podem ser uma atrás da outra, retornam objeto ou valor
| /*Operações intermediárias: retornam um stream e poe ser encadeada
Operações terminais: não podem ser uma atrás da outra, retornam objeto ou valor
| public static void main(String[] args) {
List<String> numerosAleatorios =
Arrays.asList("1","0","4","1","2","3","9","9","6","5");
imprimirElementosViaForEach(numerosAleatorios);
coletarQuantiaDeElementos(numerosAleatorios);
tronsformarEmOutroTipo(numerosAleatorios);
verificarETransformar(numerosAleatorios);
transformarEPegarMedia(numerosAleatorios);
removerValoresImpares(numerosAleatorios);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"List",
"<",
"String",
">",
"numerosAleatorios",
"=",
"Arrays",
".",
"asList",
"(",
"\"1\"",
",",
"\"0\"",
",",
"\"4\"",
",",
"\"1\"",
",",
"\"2\"",
",",
"\"3\"",
",",
"\"9\"",
",",
"\"9\"",
",",
"\"6\"",
",",
"\"5\"",
")",
";",
"imprimirElementosViaForEach",
"(",
"numerosAleatorios",
")",
";",
"coletarQuantiaDeElementos",
"(",
"numerosAleatorios",
")",
";",
"tronsformarEmOutroTipo",
"(",
"numerosAleatorios",
")",
";",
"verificarETransformar",
"(",
"numerosAleatorios",
")",
";",
"transformarEPegarMedia",
"(",
"numerosAleatorios",
")",
";",
"removerValoresImpares",
"(",
"numerosAleatorios",
")",
";",
"}"
] | [
13,
4
] | [
22,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Caneta1. | null | Public qualquer um pode mexer | Public qualquer um pode mexer | public void status(){
System.out.println("Modelo "+ this.modelo);
System.out.println("Uma Caneta "+ this.cor);
System.out.println("Ponta "+ this.ponta);
System.out.println("Carga "+ this.carga);
System.out.println("A caneta da tampada " + this.tampar);
} | [
"public",
"void",
"status",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Modelo \"",
"+",
"this",
".",
"modelo",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Uma Caneta \"",
"+",
"this",
".",
"cor",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Ponta \"",
"+",
"this",
".",
"ponta",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Carga \"",
"+",
"this",
".",
"carga",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"A caneta da tampada \"",
"+",
"this",
".",
"tampar",
")",
";",
"}"
] | [
21,
3
] | [
27,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
InsertionSort. | null | ------------ Organizar por Pais ------------ \\ | ------------ Organizar por Pais ------------ \\ | public long organizaPaisCres(){
int ini = 1, chg;
String men;
tempo1 = System.currentTimeMillis();
while (ini < lista.size()){
men = lista.get(ini).getPais();
Informacoes Info = lista.get(ini);
chg = ini - 1;
while (chg>-1 && lista.get(chg).getPais().compareTo(men)>0){
lista.set(chg + 1, lista.get(chg));
chg --;
}
lista.set(chg+1,Info);
ini++;
}
tempo2 = System.currentTimeMillis();
return tempo2 - tempo1;
} | [
"public",
"long",
"organizaPaisCres",
"(",
")",
"{",
"int",
"ini",
"=",
"1",
",",
"chg",
";",
"String",
"men",
";",
"tempo1",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"ini",
"<",
"lista",
".",
"size",
"(",
")",
")",
"{",
"men",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
".",
"getPais",
"(",
")",
";",
"Informacoes",
"Info",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
";",
"chg",
"=",
"ini",
"-",
"1",
";",
"while",
"(",
"chg",
">",
"-",
"1",
"&&",
"lista",
".",
"get",
"(",
"chg",
")",
".",
"getPais",
"(",
")",
".",
"compareTo",
"(",
"men",
")",
">",
"0",
")",
"{",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"lista",
".",
"get",
"(",
"chg",
")",
")",
";",
"chg",
"--",
";",
"}",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"Info",
")",
";",
"ini",
"++",
";",
"}",
"tempo2",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"return",
"tempo2",
"-",
"tempo1",
";",
"}"
] | [
112,
4
] | [
129,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
QuickSort. | null | ===== Métodos de Ordenação por Estado ===== // | ===== Métodos de Ordenação por Estado ===== // | public void quickEstadoCres() {
quickEstadoCres(0, lista.size() - 1);
} | [
"public",
"void",
"quickEstadoCres",
"(",
")",
"{",
"quickEstadoCres",
"(",
"0",
",",
"lista",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}"
] | [
299,
4
] | [
301,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
teste2. | null | Função principal que irá criar a janela | Função principal que irá criar a janela | public static void main(String arg[])
{
public static final boolean seila = false;
teste2 ex = new teste2();
ex.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ex.getContentPane().setBackground(Color.DARK_GRAY);
//ícone na mesma pasta do código fonte
ex.setIconImage(new ImageIcon("Cobra_Kai.jpg").getImage());
ex.setTitle("Estudantes...");
//tira o maximizar e alteração do tamanho
ex.setResizable(false);
ex.setSize(350,480);
ex.setVisible(true);
ex.setLocationRelativeTo(null);
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"arg",
"[",
"]",
")",
"{",
"public",
"static",
"final",
"boolean",
"seila",
"=",
"false",
";",
"teste2",
"ex",
"=",
"new",
"teste2",
"(",
")",
";",
"ex",
".",
"setDefaultCloseOperation",
"(",
"JFrame",
".",
"EXIT_ON_CLOSE",
")",
";",
"ex",
".",
"getContentPane",
"(",
")",
".",
"setBackground",
"(",
"Color",
".",
"DARK_GRAY",
")",
";",
"//ícone na mesma pasta do código fonte",
"ex",
".",
"setIconImage",
"(",
"new",
"ImageIcon",
"(",
"\"Cobra_Kai.jpg\"",
")",
".",
"getImage",
"(",
")",
")",
";",
"ex",
".",
"setTitle",
"(",
"\"Estudantes...\"",
")",
";",
"//tira o maximizar e alteração do tamanho",
"ex",
".",
"setResizable",
"(",
"false",
")",
";",
"ex",
".",
"setSize",
"(",
"350",
",",
"480",
")",
";",
"ex",
".",
"setVisible",
"(",
"true",
")",
";",
"ex",
".",
"setLocationRelativeTo",
"(",
"null",
")",
";",
"}"
] | [
195,
2
] | [
209,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ListaDinamica. | null | Inserir objeto na lista em uma certa posi��o | Inserir objeto na lista em uma certa posi��o | public void inserir(Object novoItem, int posicao) {
Celula novaCelula, tempCelula;
int i;
if(posicao == contador+1) { // Inserir no fim da lista
novaCelula = new Celula(novoItem);
if(inicio == null) {
inicio = novaCelula;
} else {
fim.link = novaCelula;
}
fim = novaCelula;
contador++;
} else {
if (posicao == 1) { // Inserir no inicio da lista
novaCelula = new Celula(novoItem, inicio);
if(fim == null) {
fim = novaCelula;
}
inicio = novaCelula;
contador++;
} else { // Inserir no meio da lista
if(!chaveValida(posicao)) {
System.out.println("ERRO: Indice invalido!");
} else {
tempCelula = inicio;
for (i = 0; i < posicao; i++) {
tempCelula = tempCelula.link;
}
novaCelula = new Celula(tempCelula.item, tempCelula.link);
tempCelula.link = novaCelula;
if(tempCelula == fim) {
fim = novaCelula;
}
tempCelula.item = novoItem;
contador++;
}
}
}
} | [
"public",
"void",
"inserir",
"(",
"Object",
"novoItem",
",",
"int",
"posicao",
")",
"{",
"Celula",
"novaCelula",
",",
"tempCelula",
";",
"int",
"i",
";",
"if",
"(",
"posicao",
"==",
"contador",
"+",
"1",
")",
"{",
"// Inserir no fim da lista",
"novaCelula",
"=",
"new",
"Celula",
"(",
"novoItem",
")",
";",
"if",
"(",
"inicio",
"==",
"null",
")",
"{",
"inicio",
"=",
"novaCelula",
";",
"}",
"else",
"{",
"fim",
".",
"link",
"=",
"novaCelula",
";",
"}",
"fim",
"=",
"novaCelula",
";",
"contador",
"++",
";",
"}",
"else",
"{",
"if",
"(",
"posicao",
"==",
"1",
")",
"{",
"// Inserir no inicio da lista",
"novaCelula",
"=",
"new",
"Celula",
"(",
"novoItem",
",",
"inicio",
")",
";",
"if",
"(",
"fim",
"==",
"null",
")",
"{",
"fim",
"=",
"novaCelula",
";",
"}",
"inicio",
"=",
"novaCelula",
";",
"contador",
"++",
";",
"}",
"else",
"{",
"// Inserir no meio da lista",
"if",
"(",
"!",
"chaveValida",
"(",
"posicao",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"ERRO: Indice invalido!\"",
")",
";",
"}",
"else",
"{",
"tempCelula",
"=",
"inicio",
";",
"for",
"(",
"i",
"=",
"0",
";",
"i",
"<",
"posicao",
";",
"i",
"++",
")",
"{",
"tempCelula",
"=",
"tempCelula",
".",
"link",
";",
"}",
"novaCelula",
"=",
"new",
"Celula",
"(",
"tempCelula",
".",
"item",
",",
"tempCelula",
".",
"link",
")",
";",
"tempCelula",
".",
"link",
"=",
"novaCelula",
";",
"if",
"(",
"tempCelula",
"==",
"fim",
")",
"{",
"fim",
"=",
"novaCelula",
";",
"}",
"tempCelula",
".",
"item",
"=",
"novoItem",
";",
"contador",
"++",
";",
"}",
"}",
"}",
"}"
] | [
48,
1
] | [
86,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UsuarioController. | null | Retorna um usuário único | Retorna um usuário único | @RequestMapping(value="/{id}", method=RequestMethod.GET)
@ApiOperation(value="Retorna um usuário único")
public ResponseEntity<?> listaUsuarioUnico(@PathVariable(value="id") Long id){
Usuario obj = usuarioService.listaUsuarioUnico(id);
return ResponseEntity.ok().body(obj);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/{id}\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Retorna um usuário único\")",
"",
"public",
"ResponseEntity",
"<",
"?",
">",
"listaUsuarioUnico",
"(",
"@",
"PathVariable",
"(",
"value",
"=",
"\"id\"",
")",
"Long",
"id",
")",
"{",
"Usuario",
"obj",
"=",
"usuarioService",
".",
"listaUsuarioUnico",
"(",
"id",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"obj",
")",
";",
"}"
] | [
37,
1
] | [
42,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TelaPrincipalController. | null | ---> iniciar todo o acesso aos botoes de menu | ---> iniciar todo o acesso aos botoes de menu | @FXML
private void acessarTelaCadastrarMedico(ActionEvent event) throws IOException {
try {
abrirFormulario("telaCadastrarMedico");
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erro ao conectar ao banco de dados verifique se o seu servidor está ativo", "ERRO", 0);
}
} | [
"@",
"FXML",
"private",
"void",
"acessarTelaCadastrarMedico",
"(",
"ActionEvent",
"event",
")",
"throws",
"IOException",
"{",
"try",
"{",
"abrirFormulario",
"(",
"\"telaCadastrarMedico\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"Erro ao conectar ao banco de dados verifique se o seu servidor está ativo\",",
" ",
"ERRO\",",
" ",
")",
";",
"",
"}",
"}"
] | [
170,
4
] | [
177,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfig. | null | cofiguração de recursos estaticos | cofiguração de recursos estaticos | @Override
public void configure(WebSecurity web) throws Exception {
// TODO Auto-generated method stub
super.configure(web);
} | [
"@",
"Override",
"public",
"void",
"configure",
"(",
"WebSecurity",
"web",
")",
"throws",
"Exception",
"{",
"// TODO Auto-generated method stub",
"super",
".",
"configure",
"(",
"web",
")",
";",
"}"
] | [
94,
4
] | [
98,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CartaoDebito. | null | falta verificar o número do cartão | falta verificar o número do cartão | public boolean verifica_num_cartao_deb() {
Cartao cartao_aux = new Cartao();
return (cartao_aux.ValidaNUM_Cartao(Long.toString(n_cartao_debito)));
} | [
"public",
"boolean",
"verifica_num_cartao_deb",
"(",
")",
"{",
"Cartao",
"cartao_aux",
"=",
"new",
"Cartao",
"(",
")",
";",
"return",
"(",
"cartao_aux",
".",
"ValidaNUM_Cartao",
"(",
"Long",
".",
"toString",
"(",
"n_cartao_debito",
")",
")",
")",
";",
"}"
] | [
89,
4
] | [
95,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
MissionService. | null | readOnly para não fazer lock no banco, pois será operação apenas de leitura | readOnly para não fazer lock no banco, pois será operação apenas de leitura | @Transactional(readOnly = true)
public Page<MissionDTO> findAll(Pageable pageable) {
//traz pra memoria e JPA armazena em cache os Jedis
jediRepository.findAll();
Page<Mission> result = repository.findAll(pageable);
return result.map(MissionDTO::new);
} | [
"@",
"Transactional",
"(",
"readOnly",
"=",
"true",
")",
"public",
"Page",
"<",
"MissionDTO",
">",
"findAll",
"(",
"Pageable",
"pageable",
")",
"{",
"//traz pra memoria e JPA armazena em cache os Jedis",
"jediRepository",
".",
"findAll",
"(",
")",
";",
"Page",
"<",
"Mission",
">",
"result",
"=",
"repository",
".",
"findAll",
"(",
"pageable",
")",
";",
"return",
"result",
".",
"map",
"(",
"MissionDTO",
"::",
"new",
")",
";",
"}"
] | [
30,
4
] | [
36,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
EnemyGuardian. | null | * Retorna o movimento feito pelo inimigo em char, retorna 'S' caso ele nao se mova ** | * Retorna o movimento feito pelo inimigo em char, retorna 'S' caso ele nao se mova ** | public char getMoveDirection() {
int distBravia = this.minDistanceToBravia(this.iPos, this.jPos);
if(distBravia > 4 || distBravia == -1) {
discovered = false;
lightRange = 0;
lit = false;
}
if(lit) {
discovered = true;
lightRange = 1;
}
if(discovered) return this.getBestDirection();
return 'S';
} | [
"public",
"char",
"getMoveDirection",
"(",
")",
"{",
"int",
"distBravia",
"=",
"this",
".",
"minDistanceToBravia",
"(",
"this",
".",
"iPos",
",",
"this",
".",
"jPos",
")",
";",
"if",
"(",
"distBravia",
">",
"4",
"||",
"distBravia",
"==",
"-",
"1",
")",
"{",
"discovered",
"=",
"false",
";",
"lightRange",
"=",
"0",
";",
"lit",
"=",
"false",
";",
"}",
"if",
"(",
"lit",
")",
"{",
"discovered",
"=",
"true",
";",
"lightRange",
"=",
"1",
";",
"}",
"if",
"(",
"discovered",
")",
"return",
"this",
".",
"getBestDirection",
"(",
")",
";",
"return",
"'",
"'",
";",
"}"
] | [
18,
1
] | [
31,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UsuarioRepository. | null | metodo usado para retornar dados do usuario no findAll... | metodo usado para retornar dados do usuario no findAll... | private Usuario getUsuario(ResultSet rs) throws SQLException {
Usuario usuario = new Usuario();
usuario.setIdUsuario(rs.getInt("idusuario"));
usuario.setNome(rs.getString("nome"));
usuario.setEmail(rs.getString("email"));
usuario.setSenha(rs.getString("senha"));
usuario.setPerfil(rs.getString("perfil"));
return usuario;
} | [
"private",
"Usuario",
"getUsuario",
"(",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"Usuario",
"usuario",
"=",
"new",
"Usuario",
"(",
")",
";",
"usuario",
".",
"setIdUsuario",
"(",
"rs",
".",
"getInt",
"(",
"\"idusuario\"",
")",
")",
";",
"usuario",
".",
"setNome",
"(",
"rs",
".",
"getString",
"(",
"\"nome\"",
")",
")",
";",
"usuario",
".",
"setEmail",
"(",
"rs",
".",
"getString",
"(",
"\"email\"",
")",
")",
";",
"usuario",
".",
"setSenha",
"(",
"rs",
".",
"getString",
"(",
"\"senha\"",
")",
")",
";",
"usuario",
".",
"setPerfil",
"(",
"rs",
".",
"getString",
"(",
"\"perfil\"",
")",
")",
";",
"return",
"usuario",
";",
"}"
] | [
140,
1
] | [
152,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FXMLEntregaController. | null | Carrega os campos da tela Entrega com os dados da tabela da esquerda | Carrega os campos da tela Entrega com os dados da tabela da esquerda | public void selecionarItemTableViewEntrega(Entrega entrega) {
if (entrega != null) {
textFieldCodigo.setText(entrega.getId().toString());
textFieldHoraSaida.setText(entrega.getHoraSaida().toString());
carregarTableViewDados(entrega);
comboBoxStatus.setValue(entrega.getStatus());
} else {
textFieldCodigo.setText("");
}
} | [
"public",
"void",
"selecionarItemTableViewEntrega",
"(",
"Entrega",
"entrega",
")",
"{",
"if",
"(",
"entrega",
"!=",
"null",
")",
"{",
"textFieldCodigo",
".",
"setText",
"(",
"entrega",
".",
"getId",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"textFieldHoraSaida",
".",
"setText",
"(",
"entrega",
".",
"getHoraSaida",
"(",
")",
".",
"toString",
"(",
")",
")",
";",
"carregarTableViewDados",
"(",
"entrega",
")",
";",
"comboBoxStatus",
".",
"setValue",
"(",
"entrega",
".",
"getStatus",
"(",
")",
")",
";",
"}",
"else",
"{",
"textFieldCodigo",
".",
"setText",
"(",
"\"\"",
")",
";",
"}",
"}"
] | [
156,
1
] | [
167,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UsuarioService. | null | Sobrescrevendo o loadUserByUsername para receber um username e devolver usuario logado | Sobrescrevendo o loadUserByUsername para receber um username e devolver usuario logado | @Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
TypedQuery<Usuario> query = entityManager
.createQuery("select u from Usuario u where u.login = :username", Usuario.class)
.setParameter("username", username);
List<?> usuarios = query.getResultList();
if (usuarios.isEmpty()) {
throw new UsernameNotFoundException("Não foi possível encontrar usuário com email: " + username);
}
return user.map(usuarios.get(0));
} | [
"@",
"Override",
"public",
"UserDetails",
"loadUserByUsername",
"(",
"String",
"username",
")",
"throws",
"UsernameNotFoundException",
"{",
"TypedQuery",
"<",
"Usuario",
">",
"query",
"=",
"entityManager",
".",
"createQuery",
"(",
"\"select u from Usuario u where u.login = :username\"",
",",
"Usuario",
".",
"class",
")",
".",
"setParameter",
"(",
"\"username\"",
",",
"username",
")",
";",
"List",
"<",
"?",
">",
"usuarios",
"=",
"query",
".",
"getResultList",
"(",
")",
";",
"if",
"(",
"usuarios",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"UsernameNotFoundException",
"(",
"\"Não foi possível encontrar usuário com email: \" + ",
"s",
"rname);",
"",
"",
"}",
"return",
"user",
".",
"map",
"(",
"usuarios",
".",
"get",
"(",
"0",
")",
")",
";",
"}"
] | [
25,
4
] | [
39,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TelaCliente. | null | método para setar os campos do formulário com o conteúdo da tabela | método para setar os campos do formulário com o conteúdo da tabela | public void setar_campos() {
int setar = tblClientes.getSelectedRow();
txtCliId.setText(tblClientes.getModel().getValueAt(setar, 0).toString());
txtCliNome.setText(tblClientes.getModel().getValueAt(setar, 1).toString());
txtCliEndereco.setText(tblClientes.getModel().getValueAt(setar, 2).toString());
txtCliFone.setText(tblClientes.getModel().getValueAt(setar, 3).toString());
txtCliEmail.setText(tblClientes.getModel().getValueAt(setar, 4).toString());
//a linha abaixo desabilita o botão adicionar
btnAdicionar.setEnabled(false);
} | [
"public",
"void",
"setar_campos",
"(",
")",
"{",
"int",
"setar",
"=",
"tblClientes",
".",
"getSelectedRow",
"(",
")",
";",
"txtCliId",
".",
"setText",
"(",
"tblClientes",
".",
"getModel",
"(",
")",
".",
"getValueAt",
"(",
"setar",
",",
"0",
")",
".",
"toString",
"(",
")",
")",
";",
"txtCliNome",
".",
"setText",
"(",
"tblClientes",
".",
"getModel",
"(",
")",
".",
"getValueAt",
"(",
"setar",
",",
"1",
")",
".",
"toString",
"(",
")",
")",
";",
"txtCliEndereco",
".",
"setText",
"(",
"tblClientes",
".",
"getModel",
"(",
")",
".",
"getValueAt",
"(",
"setar",
",",
"2",
")",
".",
"toString",
"(",
")",
")",
";",
"txtCliFone",
".",
"setText",
"(",
"tblClientes",
".",
"getModel",
"(",
")",
".",
"getValueAt",
"(",
"setar",
",",
"3",
")",
".",
"toString",
"(",
")",
")",
";",
"txtCliEmail",
".",
"setText",
"(",
"tblClientes",
".",
"getModel",
"(",
")",
".",
"getValueAt",
"(",
"setar",
",",
"4",
")",
".",
"toString",
"(",
")",
")",
";",
"//a linha abaixo desabilita o botão adicionar",
"btnAdicionar",
".",
"setEnabled",
"(",
"false",
")",
";",
"}"
] | [
81,
4
] | [
90,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DFStringValidador. | null | (pq está ruim?, ele faz a validacao da nota tecnica 2019.001 Versao 1.00 descrita no comentario do metodo) | (pq está ruim?, ele faz a validacao da nota tecnica 2019.001 Versao 1.00 descrita no comentario do metodo) | public static void validaPreenchimentoDeMargemValorAgregado(NFNotaInfoItemImpostoICMS impostoICMS) throws InvocationTargetException, IllegalAccessException {
if (impostoICMS != null) {
//seleciona todos os metodos da classe de ICMS
for (Method method : impostoICMS.getClass().getMethods()) {
final Class<?> returnType = method.getReturnType();
Method[] typeMethods = returnType.getMethods();
//verifica se a classe de ICMS tem o item NFNotaInfoItemModalidadeBCICMSST.
final boolean present = Arrays.stream(typeMethods).anyMatch(method1 -> method1.getReturnType().equals(NFNotaInfoItemModalidadeBCICMSST.class));
if (present) {
//invoca o metodo para verificar qual classe de ICMS esta preenchida(objectValue!=null)
Object objectValue = method.invoke(impostoICMS);
if (objectValue != null) {
// retorna o metodo necessario para extrair o valor de ModalidadeMVA.
Method modalidadeMethod = Arrays.stream(typeMethods).filter(method1 -> method1.getReturnType().equals(NFNotaInfoItemModalidadeBCICMSST.class)).findAny().get();
NFNotaInfoItemModalidadeBCICMSST modalidadeBCICMSST = (NFNotaInfoItemModalidadeBCICMSST) modalidadeMethod.invoke(objectValue, new Object[]{});
// retorna o metodo necessario para extrair o valor da percentualMargemValorAdicionadoICMSST(pMVAST).
Method percentualMethod = Arrays.stream(typeMethods).filter(method1 -> method1.getName().contains("getPercentualMargemValorAdicionadoICMSST")).findAny().orElse(null);
String percentualValue = null;
if (percentualMethod != null) {
percentualValue = (String) percentualMethod.invoke(objectValue, new Object[]{});
}
//verificacoes conforme a regra de validacao
if (modalidadeBCICMSST != null && modalidadeBCICMSST.equals(NFNotaInfoItemModalidadeBCICMSST.MARGEM_VALOR_AGREGADO) && StringUtils.isBlank(percentualValue)) {
throw new IllegalStateException("Informada modalidade de determinacao da BC da ST como MVA(modBCST=4)" + " e nao informado o campo pMVAST!");
} else if (StringUtils.isNotBlank(percentualValue) && (modalidadeBCICMSST == null || !modalidadeBCICMSST.equals(NFNotaInfoItemModalidadeBCICMSST.MARGEM_VALOR_AGREGADO))) {
throw new IllegalStateException(String.format("Informada modalidade de determinacao da BC da ST diferente de MVA(informado[%s]) e informado o campo pMVAST", (modalidadeBCICMSST != null ? modalidadeBCICMSST.toString() : "modBCST<>4")));
}
}
}
}
}
} | [
"public",
"static",
"void",
"validaPreenchimentoDeMargemValorAgregado",
"(",
"NFNotaInfoItemImpostoICMS",
"impostoICMS",
")",
"throws",
"InvocationTargetException",
",",
"IllegalAccessException",
"{",
"if",
"(",
"impostoICMS",
"!=",
"null",
")",
"{",
"//seleciona todos os metodos da classe de ICMS",
"for",
"(",
"Method",
"method",
":",
"impostoICMS",
".",
"getClass",
"(",
")",
".",
"getMethods",
"(",
")",
")",
"{",
"final",
"Class",
"<",
"?",
">",
"returnType",
"=",
"method",
".",
"getReturnType",
"(",
")",
";",
"Method",
"[",
"]",
"typeMethods",
"=",
"returnType",
".",
"getMethods",
"(",
")",
";",
"//verifica se a classe de ICMS tem o item NFNotaInfoItemModalidadeBCICMSST.",
"final",
"boolean",
"present",
"=",
"Arrays",
".",
"stream",
"(",
"typeMethods",
")",
".",
"anyMatch",
"(",
"method1",
"->",
"method1",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"NFNotaInfoItemModalidadeBCICMSST",
".",
"class",
")",
")",
";",
"if",
"(",
"present",
")",
"{",
"//invoca o metodo para verificar qual classe de ICMS esta preenchida(objectValue!=null)",
"Object",
"objectValue",
"=",
"method",
".",
"invoke",
"(",
"impostoICMS",
")",
";",
"if",
"(",
"objectValue",
"!=",
"null",
")",
"{",
"// retorna o metodo necessario para extrair o valor de ModalidadeMVA.",
"Method",
"modalidadeMethod",
"=",
"Arrays",
".",
"stream",
"(",
"typeMethods",
")",
".",
"filter",
"(",
"method1",
"->",
"method1",
".",
"getReturnType",
"(",
")",
".",
"equals",
"(",
"NFNotaInfoItemModalidadeBCICMSST",
".",
"class",
")",
")",
".",
"findAny",
"(",
")",
".",
"get",
"(",
")",
";",
"NFNotaInfoItemModalidadeBCICMSST",
"modalidadeBCICMSST",
"=",
"(",
"NFNotaInfoItemModalidadeBCICMSST",
")",
"modalidadeMethod",
".",
"invoke",
"(",
"objectValue",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"// retorna o metodo necessario para extrair o valor da percentualMargemValorAdicionadoICMSST(pMVAST).",
"Method",
"percentualMethod",
"=",
"Arrays",
".",
"stream",
"(",
"typeMethods",
")",
".",
"filter",
"(",
"method1",
"->",
"method1",
".",
"getName",
"(",
")",
".",
"contains",
"(",
"\"getPercentualMargemValorAdicionadoICMSST\"",
")",
")",
".",
"findAny",
"(",
")",
".",
"orElse",
"(",
"null",
")",
";",
"String",
"percentualValue",
"=",
"null",
";",
"if",
"(",
"percentualMethod",
"!=",
"null",
")",
"{",
"percentualValue",
"=",
"(",
"String",
")",
"percentualMethod",
".",
"invoke",
"(",
"objectValue",
",",
"new",
"Object",
"[",
"]",
"{",
"}",
")",
";",
"}",
"//verificacoes conforme a regra de validacao",
"if",
"(",
"modalidadeBCICMSST",
"!=",
"null",
"&&",
"modalidadeBCICMSST",
".",
"equals",
"(",
"NFNotaInfoItemModalidadeBCICMSST",
".",
"MARGEM_VALOR_AGREGADO",
")",
"&&",
"StringUtils",
".",
"isBlank",
"(",
"percentualValue",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Informada modalidade de determinacao da BC da ST como MVA(modBCST=4)\"",
"+",
"\" e nao informado o campo pMVAST!\"",
")",
";",
"}",
"else",
"if",
"(",
"StringUtils",
".",
"isNotBlank",
"(",
"percentualValue",
")",
"&&",
"(",
"modalidadeBCICMSST",
"==",
"null",
"||",
"!",
"modalidadeBCICMSST",
".",
"equals",
"(",
"NFNotaInfoItemModalidadeBCICMSST",
".",
"MARGEM_VALOR_AGREGADO",
")",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"String",
".",
"format",
"(",
"\"Informada modalidade de determinacao da BC da ST diferente de MVA(informado[%s]) e informado o campo pMVAST\"",
",",
"(",
"modalidadeBCICMSST",
"!=",
"null",
"?",
"modalidadeBCICMSST",
".",
"toString",
"(",
")",
":",
"\"modBCST<>4\"",
")",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}"
] | [
803,
4
] | [
834,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Testes. | null | Cria lampadas pela informaçao do utilizador | Cria lampadas pela informaçao do utilizador | public void criarLampadas(){
// Pede informaçao ao utilizador
Scanner s = new Scanner(System.in);
System.out.println("Quantas lampadas quer criar?");
int numLampadas = 0;
// Recebe o num de lampadas a criar
try {
numLampadas = s.nextInt();
} catch (Exception e) {
e.printStackTrace();
System.out.println("Erro! Por favor insira o valor inteiro do numero de lampadas");
}
// Cria um certo num de lampadas e adiciona à lista
for (int i = 1; i<=numLampadas; i++){
System.out.println("Introduza a potencia em Watts da lampada num " + i + ": ");
try {
int wattsLampada = s.nextInt();
Lampada l = new Lampada(wattsLampada);
addLampada(l);
} catch (Exception e) {
e.printStackTrace();
System.out.println("Erro! Por favor insira o valor inteiro em Watts");
}
}
} | [
"public",
"void",
"criarLampadas",
"(",
")",
"{",
"// Pede informaçao ao utilizador\r",
"Scanner",
"s",
"=",
"new",
"Scanner",
"(",
"System",
".",
"in",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Quantas lampadas quer criar?\"",
")",
";",
"int",
"numLampadas",
"=",
"0",
";",
"// Recebe o num de lampadas a criar\r",
"try",
"{",
"numLampadas",
"=",
"s",
".",
"nextInt",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Erro! Por favor insira o valor inteiro do numero de lampadas\"",
")",
";",
"}",
"// Cria um certo num de lampadas e adiciona à lista\r",
"for",
"(",
"int",
"i",
"=",
"1",
";",
"i",
"<=",
"numLampadas",
";",
"i",
"++",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduza a potencia em Watts da lampada num \"",
"+",
"i",
"+",
"\": \"",
")",
";",
"try",
"{",
"int",
"wattsLampada",
"=",
"s",
".",
"nextInt",
"(",
")",
";",
"Lampada",
"l",
"=",
"new",
"Lampada",
"(",
"wattsLampada",
")",
";",
"addLampada",
"(",
"l",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Erro! Por favor insira o valor inteiro em Watts\"",
")",
";",
"}",
"}",
"}"
] | [
16,
4
] | [
41,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfigurations. | null | que nao esta logado cadastrar uma categoria. | que nao esta logado cadastrar uma categoria. | @Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.POST, "/usuario").permitAll()
.antMatchers(HttpMethod.POST, "/auth").permitAll()
.anyRequest().authenticated()
.and().cors()
.and().csrf().disable()
.sessionManagement()
.sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and().addFilterBefore(new AutenticacaoViaTokenFilter(tokenService, usuarioRepository), UsernamePasswordAuthenticationFilter.class);
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"HttpSecurity",
"http",
")",
"throws",
"Exception",
"{",
"http",
".",
"authorizeRequests",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/usuario\"",
")",
".",
"permitAll",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/auth\"",
")",
".",
"permitAll",
"(",
")",
".",
"anyRequest",
"(",
")",
".",
"authenticated",
"(",
")",
".",
"and",
"(",
")",
".",
"cors",
"(",
")",
".",
"and",
"(",
")",
".",
"csrf",
"(",
")",
".",
"disable",
"(",
")",
".",
"sessionManagement",
"(",
")",
".",
"sessionCreationPolicy",
"(",
"SessionCreationPolicy",
".",
"STATELESS",
")",
".",
"and",
"(",
")",
".",
"addFilterBefore",
"(",
"new",
"AutenticacaoViaTokenFilter",
"(",
"tokenService",
",",
"usuarioRepository",
")",
",",
"UsernamePasswordAuthenticationFilter",
".",
"class",
")",
";",
"}"
] | [
44,
4
] | [
55,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula03ex. | null | triciclo, camião, monociclo. (Ex: getWheels(“Bicicleta”) -> 2) | triciclo, camião, monociclo. (Ex: getWheels(“Bicicleta”) -> 2) | public static int getWheels(String veiculo) {
// É mais pratico usar switch em vez de if/else nesta situaçao
// devido ao grande numero de casos especificos a testar
switch (veiculo) {
case "automovel":
// Neste caso nao precisa de break porque cada caso já faz return
// por isso sai do ciclo automaticamente
return 4;
case "moto":
return 2;
case "bicicleta":
return 2;
case "triciclo":
return 3;
case "camião":
return 12;
case "monociclo":
return 1;
default:
return 0;
}
} | [
"public",
"static",
"int",
"getWheels",
"(",
"String",
"veiculo",
")",
"{",
"// É mais pratico usar switch em vez de if/else nesta situaçao",
"// devido ao grande numero de casos especificos a testar",
"switch",
"(",
"veiculo",
")",
"{",
"case",
"\"automovel\"",
":",
"// Neste caso nao precisa de break porque cada caso já faz return",
"// por isso sai do ciclo automaticamente",
"return",
"4",
";",
"case",
"\"moto\"",
":",
"return",
"2",
";",
"case",
"\"bicicleta\"",
":",
"return",
"2",
";",
"case",
"\"triciclo\"",
":",
"return",
"3",
";",
"case",
"\"camião\":",
"",
"return",
"12",
";",
"case",
"\"monociclo\"",
":",
"return",
"1",
";",
"default",
":",
"return",
"0",
";",
"}",
"}"
] | [
85,
4
] | [
106,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
LBSTreeNode. | null | Converte conteudo da classe para String | Converte conteudo da classe para String | public String toString() {
return(item.toString());
} | [
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"(",
"item",
".",
"toString",
"(",
")",
")",
";",
"}"
] | [
24,
1
] | [
26,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DownloadArquivosController. | null | Este método busca uma lista de usuários e o retorna como um download. | Este método busca uma lista de usuários e o retorna como um download. | @GetMapping("/download")
public ResponseEntity < ? > downloadFile(@PathParam("salvar") String salvar) {
List < Usuario > lista = usuarioRepository.findAll();
String conteudo = "";
for (int i = 0; i <= (lista.size() - 1); i++) {
conteudo = conteudo + "\n" +
"ID: " + lista.get(i).getId() +
"\n" +
"EMAIL:" + lista.get(i).getEmail() +
"\n" +
"PERFIL:" + lista.get(i).getPerfil();
}
Arquivo relatorioUsuarios = new Arquivo(null, "relatorioUsuarios.txt", "text/plain", conteudo.getBytes());
String texto = (salvar == null || salvar.equals("true")) ? "attachment; filename=\"" + relatorioUsuarios.getNomeArquivo() + "\"" :
"inline; filename=\"" + relatorioUsuarios.getNomeArquivo()+ "\"";
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(relatorioUsuarios.getTipoArquivo()))
.header(HttpHeaders.CONTENT_DISPOSITION, texto)
.body(new ByteArrayResource(relatorioUsuarios.getDados()));
} | [
"@",
"GetMapping",
"(",
"\"/download\"",
")",
"public",
"ResponseEntity",
"<",
"?",
">",
"downloadFile",
"(",
"@",
"PathParam",
"(",
"\"salvar\"",
")",
"String",
"salvar",
")",
"{",
"List",
"<",
"Usuario",
">",
"lista",
"=",
"usuarioRepository",
".",
"findAll",
"(",
")",
";",
"String",
"conteudo",
"=",
"\"\"",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"(",
"lista",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"i",
"++",
")",
"{",
"conteudo",
"=",
"conteudo",
"+",
"\"\\n\"",
"+",
"\"ID: \"",
"+",
"lista",
".",
"get",
"(",
"i",
")",
".",
"getId",
"(",
")",
"+",
"\"\\n\"",
"+",
"\"EMAIL:\"",
"+",
"lista",
".",
"get",
"(",
"i",
")",
".",
"getEmail",
"(",
")",
"+",
"\"\\n\"",
"+",
"\"PERFIL:\"",
"+",
"lista",
".",
"get",
"(",
"i",
")",
".",
"getPerfil",
"(",
")",
";",
"}",
"Arquivo",
"relatorioUsuarios",
"=",
"new",
"Arquivo",
"(",
"null",
",",
"\"relatorioUsuarios.txt\"",
",",
"\"text/plain\"",
",",
"conteudo",
".",
"getBytes",
"(",
")",
")",
";",
"String",
"texto",
"=",
"(",
"salvar",
"==",
"null",
"||",
"salvar",
".",
"equals",
"(",
"\"true\"",
")",
")",
"?",
"\"attachment; filename=\\\"\"",
"+",
"relatorioUsuarios",
".",
"getNomeArquivo",
"(",
")",
"+",
"\"\\\"\"",
":",
"\"inline; filename=\\\"\"",
"+",
"relatorioUsuarios",
".",
"getNomeArquivo",
"(",
")",
"+",
"\"\\\"\"",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"contentType",
"(",
"MediaType",
".",
"parseMediaType",
"(",
"relatorioUsuarios",
".",
"getTipoArquivo",
"(",
")",
")",
")",
".",
"header",
"(",
"HttpHeaders",
".",
"CONTENT_DISPOSITION",
",",
"texto",
")",
".",
"body",
"(",
"new",
"ByteArrayResource",
"(",
"relatorioUsuarios",
".",
"getDados",
"(",
")",
")",
")",
";",
"}"
] | [
35,
2
] | [
58,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Operacoes. | null | Eh passado como parametro uma variavel do tipo 'Time' chamada 'time01' | Eh passado como parametro uma variavel do tipo 'Time' chamada 'time01' | public void cadastrar(Time time01){
//Realiza a conexao com o banco de dados
Conexao conn = new Conexao();
Connection cntn = conn.getConnection();
//Comando SQL para insercao de dados na tabela
String sql = "insert into times_de_futebol(id_time, nome, apelido, mascote, "
+ "ano_de_fundacao,localizacao) values(?,?,?,?,?,?)";
//Tenta realizar os seguintes comandos. Caso nao consiga, o catch eh acionado
try {
//Realiza a captura dos valores para inserir, posteriormente, no banco de dados
/*PreparedStatement faz uma pre-otimizacao. Se pretendemos utiizar um comando sql
repetidas vezes, mudando apenas os parametros, o uso do PreparedStatement sera mais
rapido e com menos carga sobre o banco de dados*/
PreparedStatement ps = cntn.prepareStatement(sql);
ps.setInt(1, time01.id_time);
ps.setString(2, time01.nome);
ps.setString(3, time01.apelido);
ps.setString(4, time01.mascote);
ps.setInt(5, time01.ano_de_fundacao);
ps.setString(6, time01.localizacao);
//Executa a operacao
ps.executeUpdate();
//Exibe uma mensagem na tela para informar que o cadastro foi realizado
JOptionPane.showMessageDialog(null, "cadastrado com sucesso");
//Encerra o Preparedstatement
ps.close();
//Encerra a conexao com o banco de dados
cntn.close();
//Captura a excecao
}catch (SQLException ex){
//Exibe uma mensagem na tela para informar que ocorreu um erro ao cadastrar
JOptionPane.showMessageDialog(null, "problemas ao cadastrar " + ex);
}
} | [
"public",
"void",
"cadastrar",
"(",
"Time",
"time01",
")",
"{",
"//Realiza a conexao com o banco de dados",
"Conexao",
"conn",
"=",
"new",
"Conexao",
"(",
")",
";",
"Connection",
"cntn",
"=",
"conn",
".",
"getConnection",
"(",
")",
";",
"//Comando SQL para insercao de dados na tabela",
"String",
"sql",
"=",
"\"insert into times_de_futebol(id_time, nome, apelido, mascote, \"",
"+",
"\"ano_de_fundacao,localizacao) values(?,?,?,?,?,?)\"",
";",
"//Tenta realizar os seguintes comandos. Caso nao consiga, o catch eh acionado",
"try",
"{",
"//Realiza a captura dos valores para inserir, posteriormente, no banco de dados",
"/*PreparedStatement faz uma pre-otimizacao. Se pretendemos utiizar um comando sql \n repetidas vezes, mudando apenas os parametros, o uso do PreparedStatement sera mais\n rapido e com menos carga sobre o banco de dados*/",
"PreparedStatement",
"ps",
"=",
"cntn",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"ps",
".",
"setInt",
"(",
"1",
",",
"time01",
".",
"id_time",
")",
";",
"ps",
".",
"setString",
"(",
"2",
",",
"time01",
".",
"nome",
")",
";",
"ps",
".",
"setString",
"(",
"3",
",",
"time01",
".",
"apelido",
")",
";",
"ps",
".",
"setString",
"(",
"4",
",",
"time01",
".",
"mascote",
")",
";",
"ps",
".",
"setInt",
"(",
"5",
",",
"time01",
".",
"ano_de_fundacao",
")",
";",
"ps",
".",
"setString",
"(",
"6",
",",
"time01",
".",
"localizacao",
")",
";",
"//Executa a operacao",
"ps",
".",
"executeUpdate",
"(",
")",
";",
"//Exibe uma mensagem na tela para informar que o cadastro foi realizado",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"cadastrado com sucesso\"",
")",
";",
"//Encerra o Preparedstatement",
"ps",
".",
"close",
"(",
")",
";",
"//Encerra a conexao com o banco de dados",
"cntn",
".",
"close",
"(",
")",
";",
"//Captura a excecao",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"//Exibe uma mensagem na tela para informar que ocorreu um erro ao cadastrar",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"problemas ao cadastrar \"",
"+",
"ex",
")",
";",
"}",
"}"
] | [
14,
4
] | [
47,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
PecaXadrez. | null | Retorna a posiçao da peça | Retorna a posiçao da peça | public int[] getPosicao() {
return posicao;
} | [
"public",
"int",
"[",
"]",
"getPosicao",
"(",
")",
"{",
"return",
"posicao",
";",
"}"
] | [
30,
4
] | [
32,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Tabuleiro. | null | sobrecarga do método acima, utilizada para instanciar posições livres (sem peça) no tabuleiro, a partir de arquivo: | sobrecarga do método acima, utilizada para instanciar posições livres (sem peça) no tabuleiro, a partir de arquivo: | public void distribuicaoAtual(int linha, char coluna) {
tabuleiro[linha][coluna-97] = new Posicao(linha, coluna, false); //instanciando a posição (parâmetro novaPartida = false)
tabuleiro[linha][coluna-97].setStatus(true); //definindo o status da posição como true (livre)
tabuleiro[linha][coluna-97].setPeca(null); //definindo o campo peca da posição como nulo
} | [
"public",
"void",
"distribuicaoAtual",
"(",
"int",
"linha",
",",
"char",
"coluna",
")",
"{",
"tabuleiro",
"[",
"linha",
"]",
"[",
"coluna",
"-",
"97",
"]",
"=",
"new",
"Posicao",
"(",
"linha",
",",
"coluna",
",",
"false",
")",
";",
"//instanciando a posição (parâmetro novaPartida = false)",
"tabuleiro",
"[",
"linha",
"]",
"[",
"coluna",
"-",
"97",
"]",
".",
"setStatus",
"(",
"true",
")",
";",
"//definindo o status da posição como true (livre)",
"tabuleiro",
"[",
"linha",
"]",
"[",
"coluna",
"-",
"97",
"]",
".",
"setPeca",
"(",
"null",
")",
";",
"//definindo o campo peca da posição como nulo",
"}"
] | [
248,
4
] | [
252,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Conexao. | null | ---->pega uma conexao ou criar uma conexao | ---->pega uma conexao ou criar uma conexao | public static SessionFactory getSessionFactory() {
if (conexao == null) {
conexao = buildSessionFactory();
}
return conexao;
} | [
"public",
"static",
"SessionFactory",
"getSessionFactory",
"(",
")",
"{",
"if",
"(",
"conexao",
"==",
"null",
")",
"{",
"conexao",
"=",
"buildSessionFactory",
"(",
")",
";",
"}",
"return",
"conexao",
";",
"}"
] | [
41,
4
] | [
46,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
EspecieController. | null | Retorna uma lista de especies | Retorna uma lista de especies | @RequestMapping(value="/", method=RequestMethod.GET)
@ApiOperation(value="Retorna uma lista de especies")
public ResponseEntity<?> listaEspecies(){
List<Especie> obj = especieService.listaEspecies();
return ResponseEntity.ok().body(obj);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Retorna uma lista de especies\"",
")",
"public",
"ResponseEntity",
"<",
"?",
">",
"listaEspecies",
"(",
")",
"{",
"List",
"<",
"Especie",
">",
"obj",
"=",
"especieService",
".",
"listaEspecies",
"(",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"obj",
")",
";",
"}"
] | [
29,
1
] | [
34,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ItemSet. | null | se o itemset do parametro é um um subitemset deste objeto | se o itemset do parametro é um um subitemset deste objeto | public boolean isSubItem(ItemSet itemSet){
boolean flag = true;
for(Item item : itemSet.items){
boolean exist = false;
for(Item myItem : this.items){
if(item.getItemNumber() == myItem.getItemNumber()){
exist = true;
break;
}
}
if(!exist){
flag = false;
break;
}
}
return flag;
} | [
"public",
"boolean",
"isSubItem",
"(",
"ItemSet",
"itemSet",
")",
"{",
"boolean",
"flag",
"=",
"true",
";",
"for",
"(",
"Item",
"item",
":",
"itemSet",
".",
"items",
")",
"{",
"boolean",
"exist",
"=",
"false",
";",
"for",
"(",
"Item",
"myItem",
":",
"this",
".",
"items",
")",
"{",
"if",
"(",
"item",
".",
"getItemNumber",
"(",
")",
"==",
"myItem",
".",
"getItemNumber",
"(",
")",
")",
"{",
"exist",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"exist",
")",
"{",
"flag",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"flag",
";",
"}"
] | [
32,
4
] | [
50,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ContaCliente. | null | Função idêntica à unsyncAcaoThread, com synchronized | Função idêntica à unsyncAcaoThread, com synchronized | synchronized public void syncAcaoThread(){
double valor;
double temp;
for (int i=0; i < 5000; i++){
valor = 100;
temp = this.getSaldo() + valor;
this.deposita(valor);
valor = 50;
temp = this.getSaldo() - valor;
this.saca(valor);
}
} | [
"synchronized",
"public",
"void",
"syncAcaoThread",
"(",
")",
"{",
"double",
"valor",
";",
"double",
"temp",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"5000",
";",
"i",
"++",
")",
"{",
"valor",
"=",
"100",
";",
"temp",
"=",
"this",
".",
"getSaldo",
"(",
")",
"+",
"valor",
";",
"this",
".",
"deposita",
"(",
"valor",
")",
";",
"valor",
"=",
"50",
";",
"temp",
"=",
"this",
".",
"getSaldo",
"(",
")",
"-",
"valor",
";",
"this",
".",
"saca",
"(",
"valor",
")",
";",
"}",
"}"
] | [
47,
4
] | [
60,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ContextGetterDecl. | null | assume no args | assume no args | @Override
public int hashCode() {
int hash = MurmurHash.initialize();
hash = MurmurHash.update(hash, name);
hash = MurmurHash.update(hash, getArgType());
hash = MurmurHash.finish(hash, 2);
return hash;
} | [
"@",
"Override",
"public",
"int",
"hashCode",
"(",
")",
"{",
"int",
"hash",
"=",
"MurmurHash",
".",
"initialize",
"(",
")",
";",
"hash",
"=",
"MurmurHash",
".",
"update",
"(",
"hash",
",",
"name",
")",
";",
"hash",
"=",
"MurmurHash",
".",
"update",
"(",
"hash",
",",
"getArgType",
"(",
")",
")",
";",
"hash",
"=",
"MurmurHash",
".",
"finish",
"(",
"hash",
",",
"2",
")",
";",
"return",
"hash",
";",
"}"
] | [
21,
1
] | [
28,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DatabaseManager. | null | delete com expressão semelhante a atualização | delete com expressão semelhante a atualização | public void removeCliente(String cpf){
SQLiteDatabase db = this.getWritableDatabase();
db.delete("CLIENTE","CPF=?",new String[]{cpf});
} | [
"public",
"void",
"removeCliente",
"(",
"String",
"cpf",
")",
"{",
"SQLiteDatabase",
"db",
"=",
"this",
".",
"getWritableDatabase",
"(",
")",
";",
"db",
".",
"delete",
"(",
"\"CLIENTE\"",
",",
"\"CPF=?\"",
",",
"new",
"String",
"[",
"]",
"{",
"cpf",
"}",
")",
";",
"}"
] | [
78,
4
] | [
81,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Withdrawal. | null | exibe um menu de opcos de saque e a opcao cancelar | exibe um menu de opcos de saque e a opcao cancelar | private int displayMenuOfAmounts()
{
int userChoice = 0;
Screen screen = getScreen();
int[] amounts = {0, 20, 40, 60, 100, 200}; //array para as opcoes do menu
while(userChoice == 0)
{
screen.displayMessageLine("\n1: $20");
screen.displayMessageLine("2: $40");
screen.displayMessageLine("3: $60");
screen.displayMessageLine("4: $100");
screen.displayMessageLine("5: $200");
screen.displayMessageLine("6: cancel transation");
screen.displayMessageLine("\n Choice a withdrawal amount:");
int input = keypad.getInput(); //obtem a entreda do usuario
switch (input)
{
case 1: //usuario escolheu
case 2: //escolheu uma opcao de 1 a 5
case 3: //quantia correspondete do array de quantias
case 4:
case 5:
userChoice = amounts[input]; //salva a escolha do usuario
break;
case CANCELED:
userChoice = CANCELED;
break;
default: //usuario nao inseriu valores corretos
screen.displayMessageLine("\n Invalid selection. Try again.");
}
}
return userChoice;
} | [
"private",
"int",
"displayMenuOfAmounts",
"(",
")",
"{",
"int",
"userChoice",
"=",
"0",
";",
"Screen",
"screen",
"=",
"getScreen",
"(",
")",
";",
"int",
"[",
"]",
"amounts",
"=",
"{",
"0",
",",
"20",
",",
"40",
",",
"60",
",",
"100",
",",
"200",
"}",
";",
"//array para as opcoes do menu",
"while",
"(",
"userChoice",
"==",
"0",
")",
"{",
"screen",
".",
"displayMessageLine",
"(",
"\"\\n1: $20\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"2: $40\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"3: $60\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"4: $100\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"5: $200\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"6: cancel transation\"",
")",
";",
"screen",
".",
"displayMessageLine",
"(",
"\"\\n Choice a withdrawal amount:\"",
")",
";",
"int",
"input",
"=",
"keypad",
".",
"getInput",
"(",
")",
";",
"//obtem a entreda do usuario",
"switch",
"(",
"input",
")",
"{",
"case",
"1",
":",
"//usuario escolheu ",
"case",
"2",
":",
"//escolheu uma opcao de 1 a 5",
"case",
"3",
":",
"//quantia correspondete do array de quantias",
"case",
"4",
":",
"case",
"5",
":",
"userChoice",
"=",
"amounts",
"[",
"input",
"]",
";",
"//salva a escolha do usuario",
"break",
";",
"case",
"CANCELED",
":",
"userChoice",
"=",
"CANCELED",
";",
"break",
";",
"default",
":",
"//usuario nao inseriu valores corretos",
"screen",
".",
"displayMessageLine",
"(",
"\"\\n Invalid selection. Try again.\"",
")",
";",
"}",
"}",
"return",
"userChoice",
";",
"}"
] | [
62,
1
] | [
100,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
NTripleGeneratorStepDialog. | null | Criar widgets especificos da janela | Criar widgets especificos da janela | private Control buildContents(Control lastControl, ModifyListener defModListener) {
wInputGroup = swthlp.appendGroup(shell, lastControl, BaseMessages.getString(PKG, "NTripleGeneratorStep.Group.Input.Label"));
wInputSubject = appendComboVar(wInputGroup, defModListener, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.SubjectField.Label"));
wInputPredicate = appendComboVar(wInputSubject, defModListener, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.PredicateField.Label"));
wInputObject = appendComboVar(wInputPredicate, defModListener, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.ObjectField.Label"));
wInnerIsLiteral = swthlp.appendCheckboxRow(wInputGroup, wInputObject, BaseMessages.getString(PKG, "NTripleGeneratorStep.LiteralCheckField.Label"),
new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent e) {
enableDataTypeAndLangTag(wInnerIsLiteral.getSelection());
input.setChanged(true);
}
});
wInputDataType = appendComboVar(wInnerIsLiteral, defModListener, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.LiteralTypeField.Label"));
wInputLangTag = appendComboVar(wInputDataType, defModListener, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.LangtagField.Label"));
wOutputGroup = swthlp.appendGroup(shell, wInputGroup, BaseMessages.getString(PKG, "NTripleGeneratorStep.Group.Output.Label"));
wInnerKeepInput = swthlp.appendCheckboxRow(wOutputGroup, wOutputGroup,
BaseMessages.getString(PKG,"NTripleGeneratorStep.PassCheckField.Label"),
new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent arg0) {
widgetSelected(arg0);
}
public void widgetSelected(SelectionEvent e) {
input.setChanged(true);
}
});
wOutputNTriple = swthlp.appendTextVarRow(wOutputGroup,
wInnerKeepInput, BaseMessages.getString(PKG, "NTripleGeneratorStep.NTripleField.Label"), defModListener);
return wOutputGroup;
} | [
"private",
"Control",
"buildContents",
"(",
"Control",
"lastControl",
",",
"ModifyListener",
"defModListener",
")",
"{",
"wInputGroup",
"=",
"swthlp",
".",
"appendGroup",
"(",
"shell",
",",
"lastControl",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.Group.Input.Label\"",
")",
")",
";",
"wInputSubject",
"=",
"appendComboVar",
"(",
"wInputGroup",
",",
"defModListener",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.SubjectField.Label\"",
")",
")",
";",
"wInputPredicate",
"=",
"appendComboVar",
"(",
"wInputSubject",
",",
"defModListener",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.PredicateField.Label\"",
")",
")",
";",
"wInputObject",
"=",
"appendComboVar",
"(",
"wInputPredicate",
",",
"defModListener",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.ObjectField.Label\"",
")",
")",
";",
"wInnerIsLiteral",
"=",
"swthlp",
".",
"appendCheckboxRow",
"(",
"wInputGroup",
",",
"wInputObject",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.LiteralCheckField.Label\"",
")",
",",
"new",
"SelectionListener",
"(",
")",
"{",
"public",
"void",
"widgetDefaultSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"widgetSelected",
"(",
"arg0",
")",
";",
"}",
"public",
"void",
"widgetSelected",
"(",
"SelectionEvent",
"e",
")",
"{",
"enableDataTypeAndLangTag",
"(",
"wInnerIsLiteral",
".",
"getSelection",
"(",
")",
")",
";",
"input",
".",
"setChanged",
"(",
"true",
")",
";",
"}",
"}",
")",
";",
"wInputDataType",
"=",
"appendComboVar",
"(",
"wInnerIsLiteral",
",",
"defModListener",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.LiteralTypeField.Label\"",
")",
")",
";",
"wInputLangTag",
"=",
"appendComboVar",
"(",
"wInputDataType",
",",
"defModListener",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.LangtagField.Label\"",
")",
")",
";",
"wOutputGroup",
"=",
"swthlp",
".",
"appendGroup",
"(",
"shell",
",",
"wInputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.Group.Output.Label\"",
")",
")",
";",
"wInnerKeepInput",
"=",
"swthlp",
".",
"appendCheckboxRow",
"(",
"wOutputGroup",
",",
"wOutputGroup",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.PassCheckField.Label\"",
")",
",",
"new",
"SelectionListener",
"(",
")",
"{",
"public",
"void",
"widgetDefaultSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"widgetSelected",
"(",
"arg0",
")",
";",
"}",
"public",
"void",
"widgetSelected",
"(",
"SelectionEvent",
"e",
")",
"{",
"input",
".",
"setChanged",
"(",
"true",
")",
";",
"}",
"}",
")",
";",
"wOutputNTriple",
"=",
"swthlp",
".",
"appendTextVarRow",
"(",
"wOutputGroup",
",",
"wInnerKeepInput",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"NTripleGeneratorStep.NTripleField.Label\"",
")",
",",
"defModListener",
")",
";",
"return",
"wOutputGroup",
";",
"}"
] | [
77,
1
] | [
114,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
RabbitConfiguration. | null | Criação do template | Criação do template | @Bean
public RabbitTemplate rabbitTemplate() {
RabbitTemplate rabbitTemplate = new RabbitTemplate(connectionFactory);
rabbitTemplate.setMessageConverter(jackJsonMessageConverter());
return rabbitTemplate;
} | [
"@",
"Bean",
"public",
"RabbitTemplate",
"rabbitTemplate",
"(",
")",
"{",
"RabbitTemplate",
"rabbitTemplate",
"=",
"new",
"RabbitTemplate",
"(",
"connectionFactory",
")",
";",
"rabbitTemplate",
".",
"setMessageConverter",
"(",
"jackJsonMessageConverter",
"(",
")",
")",
";",
"return",
"rabbitTemplate",
";",
"}"
] | [
33,
1
] | [
41,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
InsertionSort. | null | ------------ Organizar por Dias sem chuva ------------ \\ | ------------ Organizar por Dias sem chuva ------------ \\ | public long organizaDiasCres(){
int ini = 1,
chg;
int men;
tempo1 = System.currentTimeMillis();
while (ini < lista.size()){
men = lista.get(ini).getDiasSemChuva();
Informacoes Info = lista.get(ini);
chg = ini - 1;
while (chg>-1 && men < lista.get(chg).getDiasSemChuva()){
lista.set(chg + 1, lista.get(chg));
chg --;
}
lista.set(chg+1,Info);
ini++;
}
tempo2 = System.currentTimeMillis();
return tempo2 - tempo1;
} | [
"public",
"long",
"organizaDiasCres",
"(",
")",
"{",
"int",
"ini",
"=",
"1",
",",
"chg",
";",
"int",
"men",
";",
"tempo1",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"while",
"(",
"ini",
"<",
"lista",
".",
"size",
"(",
")",
")",
"{",
"men",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
".",
"getDiasSemChuva",
"(",
")",
";",
"Informacoes",
"Info",
"=",
"lista",
".",
"get",
"(",
"ini",
")",
";",
"chg",
"=",
"ini",
"-",
"1",
";",
"while",
"(",
"chg",
">",
"-",
"1",
"&&",
"men",
"<",
"lista",
".",
"get",
"(",
"chg",
")",
".",
"getDiasSemChuva",
"(",
")",
")",
"{",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"lista",
".",
"get",
"(",
"chg",
")",
")",
";",
"chg",
"--",
";",
"}",
"lista",
".",
"set",
"(",
"chg",
"+",
"1",
",",
"Info",
")",
";",
"ini",
"++",
";",
"}",
"tempo2",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"return",
"tempo2",
"-",
"tempo1",
";",
"}"
] | [
278,
4
] | [
296,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
RecipeController. | null | Retorna receitas que contenham id de ingrediente | Retorna receitas que contenham id de ingrediente | @GetMapping("/recipes/ingredients/{id}")
public List<Recipe> getRecipeByIngredientsId(@PathVariable(value = "id") long id){
return recipeRepository.findByIngredientsId(id);
} | [
"@",
"GetMapping",
"(",
"\"/recipes/ingredients/{id}\"",
")",
"public",
"List",
"<",
"Recipe",
">",
"getRecipeByIngredientsId",
"(",
"@",
"PathVariable",
"(",
"value",
"=",
"\"id\"",
")",
"long",
"id",
")",
"{",
"return",
"recipeRepository",
".",
"findByIngredientsId",
"(",
"id",
")",
";",
"}"
] | [
59,
2
] | [
62,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ListFactoring. | null | método que obtem a lista a partir do arquivo. | método que obtem a lista a partir do arquivo. | public List<String> makeList(){
try(BufferedReader br = new BufferedReader(new FileReader(path))){
String line = br.readLine();
while(line != null){
line = br.readLine();
list.add(line);
}
}catch (IOException e){
System.out.println("Error: " + e.getMessage());
}
return list;
} | [
"public",
"List",
"<",
"String",
">",
"makeList",
"(",
")",
"{",
"try",
"(",
"BufferedReader",
"br",
"=",
"new",
"BufferedReader",
"(",
"new",
"FileReader",
"(",
"path",
")",
")",
")",
"{",
"String",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"while",
"(",
"line",
"!=",
"null",
")",
"{",
"line",
"=",
"br",
".",
"readLine",
"(",
")",
";",
"list",
".",
"add",
"(",
"line",
")",
";",
"}",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Error: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"list",
";",
"}"
] | [
25,
4
] | [
38,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DatabaseManager. | null | Faz a busca de dados na base e armazena a tabela resulado em um cursor. | Faz a busca de dados na base e armazena a tabela resulado em um cursor. | Cursor listaTodosClientes(){
SQLiteDatabase db = this.getReadableDatabase();
Cursor cur = db.rawQuery("SELECT ID_CLIENTE,CPF,NOME,DATA_NASC FROM CLIENTE ORDER BY ID_CLIENTE",null);
return cur;
} | [
"Cursor",
"listaTodosClientes",
"(",
")",
"{",
"SQLiteDatabase",
"db",
"=",
"this",
".",
"getReadableDatabase",
"(",
")",
";",
"Cursor",
"cur",
"=",
"db",
".",
"rawQuery",
"(",
"\"SELECT ID_CLIENTE,CPF,NOME,DATA_NASC FROM CLIENTE ORDER BY ID_CLIENTE\"",
",",
"null",
")",
";",
"return",
"cur",
";",
"}"
] | [
55,
4
] | [
60,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
OperationService. | null | Arredonda o resultado da conversão para duas casas decimais e persiste a operação no banco | Arredonda o resultado da conversão para duas casas decimais e persiste a operação no banco | public Operation saveOperation(OperationPostRequestBody operationPostRequestBody) {
Double finalValue = finalValue(operationPostRequestBody);
// Colocando o resultado da conversão em duas casas decimais
DecimalFormat df = new DecimalFormat("####0.00");
String finalValueWithCents = df.format(finalValue);
Operation operation = new Operation();
operation.setConvertedPrice(finalValueWithCents);
operation.setCurrencyIn(operationPostRequestBody.getCurrencyIn());
operation.setCurrencyOut(operationPostRequestBody.getCurrencyOut());
operation.setOriginalPrice(operationPostRequestBody.getOriginalPrice());
operation.setCustomer(operationPostRequestBody.getCustomer());
operation.setOperationDate(new Date());
operation.setServiceBill(operationPostRequestBody.getServiceBill());
operation.setConvertedPrice(finalValueWithCents);
operationRepository.save(operation);
return operation;
} | [
"public",
"Operation",
"saveOperation",
"(",
"OperationPostRequestBody",
"operationPostRequestBody",
")",
"{",
"Double",
"finalValue",
"=",
"finalValue",
"(",
"operationPostRequestBody",
")",
";",
"// Colocando o resultado da conversão em duas casas decimais",
"DecimalFormat",
"df",
"=",
"new",
"DecimalFormat",
"(",
"\"####0.00\"",
")",
";",
"String",
"finalValueWithCents",
"=",
"df",
".",
"format",
"(",
"finalValue",
")",
";",
"Operation",
"operation",
"=",
"new",
"Operation",
"(",
")",
";",
"operation",
".",
"setConvertedPrice",
"(",
"finalValueWithCents",
")",
";",
"operation",
".",
"setCurrencyIn",
"(",
"operationPostRequestBody",
".",
"getCurrencyIn",
"(",
")",
")",
";",
"operation",
".",
"setCurrencyOut",
"(",
"operationPostRequestBody",
".",
"getCurrencyOut",
"(",
")",
")",
";",
"operation",
".",
"setOriginalPrice",
"(",
"operationPostRequestBody",
".",
"getOriginalPrice",
"(",
")",
")",
";",
"operation",
".",
"setCustomer",
"(",
"operationPostRequestBody",
".",
"getCustomer",
"(",
")",
")",
";",
"operation",
".",
"setOperationDate",
"(",
"new",
"Date",
"(",
")",
")",
";",
"operation",
".",
"setServiceBill",
"(",
"operationPostRequestBody",
".",
"getServiceBill",
"(",
")",
")",
";",
"operation",
".",
"setConvertedPrice",
"(",
"finalValueWithCents",
")",
";",
"operationRepository",
".",
"save",
"(",
"operation",
")",
";",
"return",
"operation",
";",
"}"
] | [
64,
1
] | [
85,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Crud. | null | Criar um novo CRUD | Criar um novo CRUD | private int create(T entidade, int id) {
byte[] dadosEntidade;
try {
// Setando a id do objeto
entidade.setId(id);
// Montando um novo objeto
dadosEntidade = entidade.toByteArray();
// Indo para o final do arquivo para escrever o novo objeto
long pos = this.garbagecolector.read(dadosEntidade.length); // Pegar a posicao atual do arquivo para inserir no indice direto e no indireto
if(pos == -1) pos = this.arquivo.length();
arquivo.seek(pos); // Ir para o final do arquivo
arquivo.writeLong(dadosEntidade.length); // Escrevendo o tamanho do objeto
arquivo.write(dadosEntidade); // Escrevendo o objeto na memoria
// Sobreescrendo metadado com o novo id
arquivo.seek(0);
arquivo.writeInt(id + 1);
// Inserindo nos outros arquivos de banco de dados
this.arquivoIndiceDireto.create(id, pos); // Inserindo a id e o pos no hash extensivel
this.arquivoIndiceIndireto.create(entidade.chaveSecundaria(), id); // Inserindo a chave de pesquisa na arvore B+
} catch (Exception e) {
//System.err.println(e);
id = -1;
}
return id;
} | [
"private",
"int",
"create",
"(",
"T",
"entidade",
",",
"int",
"id",
")",
"{",
"byte",
"[",
"]",
"dadosEntidade",
";",
"try",
"{",
"// Setando a id do objeto",
"entidade",
".",
"setId",
"(",
"id",
")",
";",
"// Montando um novo objeto",
"dadosEntidade",
"=",
"entidade",
".",
"toByteArray",
"(",
")",
";",
"// Indo para o final do arquivo para escrever o novo objeto",
"long",
"pos",
"=",
"this",
".",
"garbagecolector",
".",
"read",
"(",
"dadosEntidade",
".",
"length",
")",
";",
"// Pegar a posicao atual do arquivo para inserir no indice direto e no indireto",
"if",
"(",
"pos",
"==",
"-",
"1",
")",
"pos",
"=",
"this",
".",
"arquivo",
".",
"length",
"(",
")",
";",
"arquivo",
".",
"seek",
"(",
"pos",
")",
";",
"// Ir para o final do arquivo",
"arquivo",
".",
"writeLong",
"(",
"dadosEntidade",
".",
"length",
")",
";",
"// Escrevendo o tamanho do objeto",
"arquivo",
".",
"write",
"(",
"dadosEntidade",
")",
";",
"// Escrevendo o objeto na memoria",
"// Sobreescrendo metadado com o novo id",
"arquivo",
".",
"seek",
"(",
"0",
")",
";",
"arquivo",
".",
"writeInt",
"(",
"id",
"+",
"1",
")",
";",
"// Inserindo nos outros arquivos de banco de dados",
"this",
".",
"arquivoIndiceDireto",
".",
"create",
"(",
"id",
",",
"pos",
")",
";",
"// Inserindo a id e o pos no hash extensivel",
"this",
".",
"arquivoIndiceIndireto",
".",
"create",
"(",
"entidade",
".",
"chaveSecundaria",
"(",
")",
",",
"id",
")",
";",
"// Inserindo a chave de pesquisa na arvore B+",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"//System.err.println(e); ",
"id",
"=",
"-",
"1",
";",
"}",
"return",
"id",
";",
"}"
] | [
186,
4
] | [
217,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.