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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Categoria. | null | Hash e equals para o id | Hash e equals para o id | @Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Categoria categoria = (Categoria) o;
return id.equals(categoria.id);
} | [
"@",
"Override",
"public",
"boolean",
"equals",
"(",
"Object",
"o",
")",
"{",
"if",
"(",
"this",
"==",
"o",
")",
"return",
"true",
";",
"if",
"(",
"o",
"==",
"null",
"||",
"getClass",
"(",
")",
"!=",
"o",
".",
"getClass",
"(",
")",
")",
"return",
"false",
";",
"Categoria",
"categoria",
"=",
"(",
"Categoria",
")",
"o",
";",
"return",
"id",
".",
"equals",
"(",
"categoria",
".",
"id",
")",
";",
"}"
] | [
37,
4
] | [
43,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Personagem. | null | método que é chamado quando o usuário solta a tecla | método que é chamado quando o usuário solta a tecla | public void keyReleased(KeyEvent e) {
key = e.getKeyCode();
//como há somente duas variáveis de velocidade, só precisa de duas instruções
switch(key){
case KeyEvent.VK_LEFT:
case KeyEvent.VK_RIGHT:
velx = 0;
break;
case KeyEvent.VK_UP:
case KeyEvent.VK_DOWN:
vely = 0;
break;
}
} | [
"public",
"void",
"keyReleased",
"(",
"KeyEvent",
"e",
")",
"{",
"key",
"=",
"e",
".",
"getKeyCode",
"(",
")",
";",
"//como há somente duas variáveis de velocidade, só precisa de duas instruções",
"switch",
"(",
"key",
")",
"{",
"case",
"KeyEvent",
".",
"VK_LEFT",
":",
"case",
"KeyEvent",
".",
"VK_RIGHT",
":",
"velx",
"=",
"0",
";",
"break",
";",
"case",
"KeyEvent",
".",
"VK_UP",
":",
"case",
"KeyEvent",
".",
"VK_DOWN",
":",
"vely",
"=",
"0",
";",
"break",
";",
"}",
"}"
] | [
88,
4
] | [
101,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DesafioMeuTimeApplication. | null | Retorna a cor da camisa do time adversário. Caso a cor principal do time da casa seja igual a cor principal do time de fora, retornar cor secundária do time de fora. Caso a cor principal do time da casa seja diferente da cor principal do time de fora, retornar cor principal do time de fora. | Retorna a cor da camisa do time adversário. Caso a cor principal do time da casa seja igual a cor principal do time de fora, retornar cor secundária do time de fora. Caso a cor principal do time da casa seja diferente da cor principal do time de fora, retornar cor principal do time de fora. | @Desafio("buscarCorCamisaTimeDeFora")
public String buscarCorCamisaTimeDeFora(Long timeDaCasa, Long timeDeFora) {
Time t_casa = this.buscaTimePeloId(timeDaCasa).orElseThrow(TimeNaoEncontradoException::new);
Time t_fora = this.buscaTimePeloId(timeDeFora).orElseThrow(TimeNaoEncontradoException::new);
return (t_casa.getCorUniformePrincipal().equals(t_fora.getCorUniformePrincipal()))?
(t_fora.getCorUniformeSecundario())
:
(t_fora.getCorUniformePrincipal());
} | [
"@",
"Desafio",
"(",
"\"buscarCorCamisaTimeDeFora\"",
")",
"public",
"String",
"buscarCorCamisaTimeDeFora",
"(",
"Long",
"timeDaCasa",
",",
"Long",
"timeDeFora",
")",
"{",
"Time",
"t_casa",
"=",
"this",
".",
"buscaTimePeloId",
"(",
"timeDaCasa",
")",
".",
"orElseThrow",
"(",
"TimeNaoEncontradoException",
"::",
"new",
")",
";",
"Time",
"t_fora",
"=",
"this",
".",
"buscaTimePeloId",
"(",
"timeDeFora",
")",
".",
"orElseThrow",
"(",
"TimeNaoEncontradoException",
"::",
"new",
")",
";",
"return",
"(",
"t_casa",
".",
"getCorUniformePrincipal",
"(",
")",
".",
"equals",
"(",
"t_fora",
".",
"getCorUniformePrincipal",
"(",
")",
")",
")",
"?",
"(",
"t_fora",
".",
"getCorUniformeSecundario",
"(",
")",
")",
":",
"(",
"t_fora",
".",
"getCorUniformePrincipal",
"(",
")",
")",
";",
"}"
] | [
195,
1
] | [
204,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
RegistroCRUD. | null | Getter para atributo URL | Getter para atributo URL | public String getURL()
{
return URLTemp;
} | [
"public",
"String",
"getURL",
"(",
")",
"{",
"return",
"URLTemp",
";",
"}"
] | [
84,
4
] | [
87,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
MainActivity. | null | para sair do aplicativo é preciso ser precionado 2 vezes seguidas o botão de voltar.* | para sair do aplicativo é preciso ser precionado 2 vezes seguidas o botão de voltar.* | @Override
public void onBackPressed() {
// para previnir saídas inesperadas.
long t = System.currentTimeMillis();
// 2 segundos para sair.
if (t - this.mViewHolder.backPressedTime > 2000) {
this.mViewHolder.backPressedTime = t;
Toast.makeText(this, "clique 2 vezes para sair",Toast.LENGTH_SHORT).show();
} else {// se pressionado novamente encerrar app.
// limpa.
super.onBackPressed();
}
} | [
"@",
"Override",
"public",
"void",
"onBackPressed",
"(",
")",
"{",
"// para previnir saídas inesperadas.",
"long",
"t",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"// 2 segundos para sair.",
"if",
"(",
"t",
"-",
"this",
".",
"mViewHolder",
".",
"backPressedTime",
">",
"2000",
")",
"{",
"this",
".",
"mViewHolder",
".",
"backPressedTime",
"=",
"t",
";",
"Toast",
".",
"makeText",
"(",
"this",
",",
"\"clique 2 vezes para sair\"",
",",
"Toast",
".",
"LENGTH_SHORT",
")",
".",
"show",
"(",
")",
";",
"}",
"else",
"{",
"// se pressionado novamente encerrar app.",
"// limpa.",
"super",
".",
"onBackPressed",
"(",
")",
";",
"}",
"}"
] | [
67,
4
] | [
79,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
PacientesResources. | null | trazendo todos | trazendo todos | @GetMapping("/pacientes")
@ApiOperation(value="Trazer todos os Pacientes")
public List<Pacientes> listarPacientes(){
return pacienteRepository.findAll();
} | [
"@",
"GetMapping",
"(",
"\"/pacientes\"",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Trazer todos os Pacientes\"",
")",
"public",
"List",
"<",
"Pacientes",
">",
"listarPacientes",
"(",
")",
"{",
"return",
"pacienteRepository",
".",
"findAll",
"(",
")",
";",
"}"
] | [
31,
1
] | [
36,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | False | true | method_declaration |
|
Lixo. | null | Apagar registros do arquivo lixo
@param endereçoRegistro Excluir um lixo do banco de dados, usar apos dar um read no lixo e escrever outro objeto nessa posição
| Apagar registros do arquivo lixo | public boolean delete(long enderecoRegistro) {
boolean achou = false;
try {
this.arquivo.seek(0);
long valorMetadado = this.arquivo.readLong(); // Recebendo o ultimo valor do metadado que foi deletado
Pagina pagina = new Pagina();
while(this.arquivo.getFilePointer() < this.arquivo.length() && !achou) {
pagina.lerProximaPagina();
// Deslocar sequencialmente no arquivo até achar o registro que está sendo procurado
if(pagina.enderecoRegistro == enderecoRegistro) {
// Voltando o ponteiro do arquivo para sobreescrever os dados antigos
this.arquivo.seek(this.arquivo.getFilePointer() - 12); // Voltando o tamanho de um int + um long
System.err.println(this.arquivo.getFilePointer());
// Marcando como excluido o elemento
this.arquivo.writeInt(-1);
// Receber a posição atual para ser inserida no inicio do arquivo
long metadadoAtualizado = this.arquivo.getFilePointer() - 4; // Ignorar o int que acabou de ser escrito
// Escrevendo o valor do metadado no long da posição do item deletado anteriormente
this.arquivo.writeLong(valorMetadado);
// Voltando ao inicio do arquivo para escrever o novo valor do metadado
this.arquivo.seek(0);
this.arquivo.writeLong(metadadoAtualizado);
// Marcando a flag como encontrado
achou = true;
}
}
} catch(Exception e) { e.printStackTrace(); }
return achou;
} | [
"public",
"boolean",
"delete",
"(",
"long",
"enderecoRegistro",
")",
"{",
"boolean",
"achou",
"=",
"false",
";",
"try",
"{",
"this",
".",
"arquivo",
".",
"seek",
"(",
"0",
")",
";",
"long",
"valorMetadado",
"=",
"this",
".",
"arquivo",
".",
"readLong",
"(",
")",
";",
"// Recebendo o ultimo valor do metadado que foi deletado",
"Pagina",
"pagina",
"=",
"new",
"Pagina",
"(",
")",
";",
"while",
"(",
"this",
".",
"arquivo",
".",
"getFilePointer",
"(",
")",
"<",
"this",
".",
"arquivo",
".",
"length",
"(",
")",
"&&",
"!",
"achou",
")",
"{",
"pagina",
".",
"lerProximaPagina",
"(",
")",
";",
"// Deslocar sequencialmente no arquivo até achar o registro que está sendo procurado",
"if",
"(",
"pagina",
".",
"enderecoRegistro",
"==",
"enderecoRegistro",
")",
"{",
"// Voltando o ponteiro do arquivo para sobreescrever os dados antigos",
"this",
".",
"arquivo",
".",
"seek",
"(",
"this",
".",
"arquivo",
".",
"getFilePointer",
"(",
")",
"-",
"12",
")",
";",
"// Voltando o tamanho de um int + um long",
"System",
".",
"err",
".",
"println",
"(",
"this",
".",
"arquivo",
".",
"getFilePointer",
"(",
")",
")",
";",
"// Marcando como excluido o elemento",
"this",
".",
"arquivo",
".",
"writeInt",
"(",
"-",
"1",
")",
";",
"// Receber a posição atual para ser inserida no inicio do arquivo",
"long",
"metadadoAtualizado",
"=",
"this",
".",
"arquivo",
".",
"getFilePointer",
"(",
")",
"-",
"4",
";",
"// Ignorar o int que acabou de ser escrito",
"// Escrevendo o valor do metadado no long da posição do item deletado anteriormente",
"this",
".",
"arquivo",
".",
"writeLong",
"(",
"valorMetadado",
")",
";",
"// Voltando ao inicio do arquivo para escrever o novo valor do metadado",
"this",
".",
"arquivo",
".",
"seek",
"(",
"0",
")",
";",
"this",
".",
"arquivo",
".",
"writeLong",
"(",
"metadadoAtualizado",
")",
";",
"// Marcando a flag como encontrado",
"achou",
"=",
"true",
";",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"achou",
";",
"}"
] | [
144,
4
] | [
180,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
QuickSort. | null | ===== Métodos de Ordenação por Risco de Fogo ===== // | ===== Métodos de Ordenação por Risco de Fogo ===== // | public void quickRiscoDeFogoCres() {
quickRiscoDeFogoCres(0, lista.size() - 1);
} | [
"public",
"void",
"quickRiscoDeFogoCres",
"(",
")",
"{",
"quickRiscoDeFogoCres",
"(",
"0",
",",
"lista",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}"
] | [
739,
4
] | [
741,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TurtleGeneratorStepDialog. | null | Cria widgets especificos da janela | Cria widgets especificos da janela | private Control buildContents(Control lastControl, ModifyListener defModListener) {
CTabFolder wTabFolder = swthlp.appendTabFolder(shell, lastControl, 90);
CTabItem item = new CTabItem(wTabFolder, SWT.NONE);
item.setText(BaseMessages.getString(PKG, "TurtleGeneratorStep.Properties"));
Composite cpt = swthlp.appendComposite(wTabFolder, lastControl);
ColumnInfo[] columns = new ColumnInfo[] {
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Properties.ColumnA"), ColumnInfo.COLUMN_TYPE_CCOMBO, this.getFields(), true),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Properties.ColumnB"), ColumnInfo.COLUMN_TYPE_TEXT),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Properties.ColumnC"), ColumnInfo.COLUMN_TYPE_TEXT) };
wMapTable = swthlp.appendTableView(cpt, null, columns, defModListener, 98);
item.setControl(cpt);
item = new CTabItem(wTabFolder, SWT.NONE);
item.setText(BaseMessages.getString(PKG, "TurtleGeneratorStep.Prefix"));
ColumnInfo[] columns3 = new ColumnInfo[] { new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Prefix.ColumnA"), ColumnInfo.COLUMN_TYPE_TEXT),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Prefix.ColumnB"), ColumnInfo.COLUMN_TYPE_TEXT) };
cpt = swthlp.appendComposite(wTabFolder, null);
wPrefixes = swthlp.appendTableView(cpt, null, columns3, defModListener, 90);
swthlp.appendButtonsRow(cpt, wPrefixes, new String[] { BaseMessages.getString(PKG, "TurtleGeneratorStep.Prefix.Clear"), BaseMessages.getString(PKG, "TurtleGeneratorStep.Prefix.Default") },
new SelectionListener[] { new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
wPrefixes.removeAll();
input.setChanged();
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
input.setChanged();
}
}, new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent arg0) {
for (String[] row : defaultPrefixes)
wPrefixes.add(row);
}
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
input.setChanged();
}
} });
item.setControl(cpt);
// Quarta tab (Descri��o da unidade)
item = new CTabItem(wTabFolder, SWT.NONE);
item.setText(BaseMessages.getString(PKG, "TurtleGeneratorStep.Unit"));
cpt = swthlp.appendComposite(wTabFolder, lastControl);
unity = swthlp.appendTextVarRow(cpt, unity, BaseMessages.getString(PKG, "TurtleGeneratorStep.Unit.Field"),
defModListener);
item.setControl(cpt);
// Quinta tab (Hierarquias)
item = new CTabItem(wTabFolder, SWT.NONE);
item.setText(BaseMessages.getString(PKG, "TurtleGeneratorStep.Hierarchy"));
cpt = swthlp.appendComposite(wTabFolder, lastControl);
ColumnInfo[] columns2 = new ColumnInfo[] {
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Hierarchy.ColumnA"), ColumnInfo.COLUMN_TYPE_CCOMBO,
this.getFields(), true),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Hierarchy.ColumnB"), ColumnInfo.COLUMN_TYPE_TEXT),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Hierarchy.ColumnC"), ColumnInfo.COLUMN_TYPE_TEXT),
new ColumnInfo(BaseMessages.getString(PKG, "TurtleGeneratorStep.Hierarchy.ColumnD"),
ColumnInfo.COLUMN_TYPE_TEXT) };
wMapTable2 = swthlp.appendTableView(cpt, null, columns2, defModListener, 98);
item.setControl(cpt);
wTabFolder.setSelection(0);
// Return the last created control here
return wTabFolder;
} | [
"private",
"Control",
"buildContents",
"(",
"Control",
"lastControl",
",",
"ModifyListener",
"defModListener",
")",
"{",
"CTabFolder",
"wTabFolder",
"=",
"swthlp",
".",
"appendTabFolder",
"(",
"shell",
",",
"lastControl",
",",
"90",
")",
";",
"CTabItem",
"item",
"=",
"new",
"CTabItem",
"(",
"wTabFolder",
",",
"SWT",
".",
"NONE",
")",
";",
"item",
".",
"setText",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Properties\"",
")",
")",
";",
"Composite",
"cpt",
"=",
"swthlp",
".",
"appendComposite",
"(",
"wTabFolder",
",",
"lastControl",
")",
";",
"ColumnInfo",
"[",
"]",
"columns",
"=",
"new",
"ColumnInfo",
"[",
"]",
"{",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Properties.ColumnA\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_CCOMBO",
",",
"this",
".",
"getFields",
"(",
")",
",",
"true",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Properties.ColumnB\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Properties.ColumnC\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
"}",
";",
"wMapTable",
"=",
"swthlp",
".",
"appendTableView",
"(",
"cpt",
",",
"null",
",",
"columns",
",",
"defModListener",
",",
"98",
")",
";",
"item",
".",
"setControl",
"(",
"cpt",
")",
";",
"item",
"=",
"new",
"CTabItem",
"(",
"wTabFolder",
",",
"SWT",
".",
"NONE",
")",
";",
"item",
".",
"setText",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Prefix\"",
")",
")",
";",
"ColumnInfo",
"[",
"]",
"columns3",
"=",
"new",
"ColumnInfo",
"[",
"]",
"{",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Prefix.ColumnA\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Prefix.ColumnB\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
"}",
";",
"cpt",
"=",
"swthlp",
".",
"appendComposite",
"(",
"wTabFolder",
",",
"null",
")",
";",
"wPrefixes",
"=",
"swthlp",
".",
"appendTableView",
"(",
"cpt",
",",
"null",
",",
"columns3",
",",
"defModListener",
",",
"90",
")",
";",
"swthlp",
".",
"appendButtonsRow",
"(",
"cpt",
",",
"wPrefixes",
",",
"new",
"String",
"[",
"]",
"{",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Prefix.Clear\"",
")",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Prefix.Default\"",
")",
"}",
",",
"new",
"SelectionListener",
"[",
"]",
"{",
"new",
"SelectionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"widgetSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"wPrefixes",
".",
"removeAll",
"(",
")",
";",
"input",
".",
"setChanged",
"(",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"widgetDefaultSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"input",
".",
"setChanged",
"(",
")",
";",
"}",
"}",
",",
"new",
"SelectionListener",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"widgetSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"for",
"(",
"String",
"[",
"]",
"row",
":",
"defaultPrefixes",
")",
"wPrefixes",
".",
"(",
"row",
")",
";",
"}",
"@",
"Override",
"public",
"void",
"widgetDefaultSelected",
"(",
"SelectionEvent",
"arg0",
")",
"{",
"input",
".",
"setChanged",
"(",
")",
";",
"}",
"}",
"}",
")",
";",
"item",
".",
"setControl",
"(",
"cpt",
")",
";",
"// Quarta tab (Descri��o da unidade)",
"item",
"=",
"new",
"CTabItem",
"(",
"wTabFolder",
",",
"SWT",
".",
"NONE",
")",
";",
"item",
".",
"setText",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Unit\"",
")",
")",
";",
"cpt",
"=",
"swthlp",
".",
"appendComposite",
"(",
"wTabFolder",
",",
"lastControl",
")",
";",
"unity",
"=",
"swthlp",
".",
"appendTextVarRow",
"(",
"cpt",
",",
"unity",
",",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Unit.Field\"",
")",
",",
"defModListener",
")",
";",
"item",
".",
"setControl",
"(",
"cpt",
")",
";",
"// Quinta tab (Hierarquias)",
"item",
"=",
"new",
"CTabItem",
"(",
"wTabFolder",
",",
"SWT",
".",
"NONE",
")",
";",
"item",
".",
"setText",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Hierarchy\"",
")",
")",
";",
"cpt",
"=",
"swthlp",
".",
"appendComposite",
"(",
"wTabFolder",
",",
"lastControl",
")",
";",
"ColumnInfo",
"[",
"]",
"columns2",
"=",
"new",
"ColumnInfo",
"[",
"]",
"{",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Hierarchy.ColumnA\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_CCOMBO",
",",
"this",
".",
"getFields",
"(",
")",
",",
"true",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Hierarchy.ColumnB\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Hierarchy.ColumnC\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
",",
"new",
"ColumnInfo",
"(",
"BaseMessages",
".",
"getString",
"(",
"PKG",
",",
"\"TurtleGeneratorStep.Hierarchy.ColumnD\"",
")",
",",
"ColumnInfo",
".",
"COLUMN_TYPE_TEXT",
")",
"}",
";",
"wMapTable2",
"=",
"swthlp",
".",
"appendTableView",
"(",
"cpt",
",",
"null",
",",
"columns2",
",",
"defModListener",
",",
"98",
")",
";",
"item",
".",
"setControl",
"(",
"cpt",
")",
";",
"wTabFolder",
".",
"setSelection",
"(",
"0",
")",
";",
"// Return the last created control here",
"return",
"wTabFolder",
";",
"}"
] | [
83,
1
] | [
156,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Lixo. | null | Inserindo um novo elemento no banco de dados
@param tamanhoRegistro Tamanho do registro que foi excluido.
@param enderecoRegistro long contendo o endereço do registro deletado.
@return boolean Se houve escrita no disco
| Inserindo um novo elemento no banco de dados
@param tamanhoRegistro Tamanho do registro que foi excluido.
@param enderecoRegistro long contendo o endereço do registro deletado. | public boolean create(int tamanhoRegistro, long enderecoRegistro) {
boolean inseriu = false;
try {
// Criando um objeto para fazer a leitura do lixo
LerLixo ler = new LerLixo();
// Se o registro já existir no banco ignorar inserção
if(!ler.registroExistente(enderecoRegistro)) {
// Ir no inicio do arquivo pegar a posicao de insercao do registro
this.arquivo.seek(0);
long melhorPos = this.arquivo.readLong();
if(melhorPos == -1) {
// Indo ate o final do arquivo escrevero registro
this.arquivo.seek(this.arquivo.length());
this.arquivo.writeInt(tamanhoRegistro);
this.arquivo.writeLong(enderecoRegistro);
} else {
// Indo na posicao de insercao do novo item
this.arquivo.seek(melhorPos + 4); // Pular o int -1, que representa que o item do lixo foi excluido
long itemAnteriorPilha = this.arquivo.readLong();
// Voltando a leitura para sobreescrever os dados
this.arquivo.seek(this.arquivo.getFilePointer() - 12); // Voltar a leitura do elemento int + long
// Escrever o registro novo
this.arquivo.writeInt(tamanhoRegistro);
this.arquivo.writeLong(enderecoRegistro);
// Ir no inicio do arquivo e atualizar a pilha de elementos excluidos
this.arquivo.seek(0);
this.arquivo.writeLong(itemAnteriorPilha);
}
inseriu = true;
}
ler = null;
} catch(Exception e) { e.printStackTrace(); }
return inseriu;
} | [
"public",
"boolean",
"create",
"(",
"int",
"tamanhoRegistro",
",",
"long",
"enderecoRegistro",
")",
"{",
"boolean",
"inseriu",
"=",
"false",
";",
"try",
"{",
"// Criando um objeto para fazer a leitura do lixo",
"LerLixo",
"ler",
"=",
"new",
"LerLixo",
"(",
")",
";",
"// Se o registro já existir no banco ignorar inserção",
"if",
"(",
"!",
"ler",
".",
"registroExistente",
"(",
"enderecoRegistro",
")",
")",
"{",
"// Ir no inicio do arquivo pegar a posicao de insercao do registro",
"this",
".",
"arquivo",
".",
"seek",
"(",
"0",
")",
";",
"long",
"melhorPos",
"=",
"this",
".",
"arquivo",
".",
"readLong",
"(",
")",
";",
"if",
"(",
"melhorPos",
"==",
"-",
"1",
")",
"{",
"// Indo ate o final do arquivo escrevero registro",
"this",
".",
"arquivo",
".",
"seek",
"(",
"this",
".",
"arquivo",
".",
"length",
"(",
")",
")",
";",
"this",
".",
"arquivo",
".",
"writeInt",
"(",
"tamanhoRegistro",
")",
";",
"this",
".",
"arquivo",
".",
"writeLong",
"(",
"enderecoRegistro",
")",
";",
"}",
"else",
"{",
"// Indo na posicao de insercao do novo item",
"this",
".",
"arquivo",
".",
"seek",
"(",
"melhorPos",
"+",
"4",
")",
";",
"// Pular o int -1, que representa que o item do lixo foi excluido",
"long",
"itemAnteriorPilha",
"=",
"this",
".",
"arquivo",
".",
"readLong",
"(",
")",
";",
"// Voltando a leitura para sobreescrever os dados",
"this",
".",
"arquivo",
".",
"seek",
"(",
"this",
".",
"arquivo",
".",
"getFilePointer",
"(",
")",
"-",
"12",
")",
";",
"// Voltar a leitura do elemento int + long",
"// Escrever o registro novo",
"this",
".",
"arquivo",
".",
"writeInt",
"(",
"tamanhoRegistro",
")",
";",
"this",
".",
"arquivo",
".",
"writeLong",
"(",
"enderecoRegistro",
")",
";",
"// Ir no inicio do arquivo e atualizar a pilha de elementos excluidos",
"this",
".",
"arquivo",
".",
"seek",
"(",
"0",
")",
";",
"this",
".",
"arquivo",
".",
"writeLong",
"(",
"itemAnteriorPilha",
")",
";",
"}",
"inseriu",
"=",
"true",
";",
"}",
"ler",
"=",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"inseriu",
";",
"}"
] | [
41,
4
] | [
86,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
QuickSort. | null | ===== Métodos de Ordenação por Data ===== // | ===== Métodos de Ordenação por Data ===== // | public void quickDataCres() {
quickDataCres(0, lista.size() - 1);
} | [
"public",
"void",
"quickDataCres",
"(",
")",
"{",
"quickDataCres",
"(",
"0",
",",
"lista",
".",
"size",
"(",
")",
"-",
"1",
")",
";",
"}"
] | [
35,
4
] | [
37,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Keypad. | null | retorna valor inserido pelo usuario | retorna valor inserido pelo usuario | public int getInput()
{
return input.nextInt();
} | [
"public",
"int",
"getInput",
"(",
")",
"{",
"return",
"input",
".",
"nextInt",
"(",
")",
";",
"}"
] | [
12,
1
] | [
15,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Usuario. | null | para usuário logado | para usuário logado | public String getSenha() {
return senha;
} | [
"public",
"String",
"getSenha",
"(",
")",
"{",
"return",
"senha",
";",
"}"
] | [
48,
4
] | [
50,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DesafioMeuTimeApplication. | null | Retorna uma lista com o identificador de todos os times cadastrado, ordenada pelo identificador. Retornar uma lista vazia caso não encontre times cadastrados. | Retorna uma lista com o identificador de todos os times cadastrado, ordenada pelo identificador. Retornar uma lista vazia caso não encontre times cadastrados. | @Desafio("buscarTimes")
public List<Long> buscarTimes() {
return this.times
.stream()
.sorted(Comparator.comparingLong(Time::getId))
.map(Time::getId)
.collect(Collectors.toList());
} | [
"@",
"Desafio",
"(",
"\"buscarTimes\"",
")",
"public",
"List",
"<",
"Long",
">",
"buscarTimes",
"(",
")",
"{",
"return",
"this",
".",
"times",
".",
"stream",
"(",
")",
".",
"sorted",
"(",
"Comparator",
".",
"comparingLong",
"(",
"Time",
"::",
"getId",
")",
")",
".",
"map",
"(",
"Time",
"::",
"getId",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | [
149,
1
] | [
156,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
AppPackageUtil. | null | Retorna a versão do aplicativo | Retorna a versão do aplicativo | public static String getVersionName(Activity activity) {
PackageManager pm = activity.getPackageManager();
String packageName = activity.getPackageName();
String versionName;
try {
PackageInfo info = pm.getPackageInfo(packageName, 0);
versionName = info.versionName;
} catch (PackageManager.NameNotFoundException e) {
versionName = "1.0";
// Caso ocarra uma excessão, será retornado a versão 1.0
}
return versionName;
} | [
"public",
"static",
"String",
"getVersionName",
"(",
"Activity",
"activity",
")",
"{",
"PackageManager",
"pm",
"=",
"activity",
".",
"getPackageManager",
"(",
")",
";",
"String",
"packageName",
"=",
"activity",
".",
"getPackageName",
"(",
")",
";",
"String",
"versionName",
";",
"try",
"{",
"PackageInfo",
"info",
"=",
"pm",
".",
"getPackageInfo",
"(",
"packageName",
",",
"0",
")",
";",
"versionName",
"=",
"info",
".",
"versionName",
";",
"}",
"catch",
"(",
"PackageManager",
".",
"NameNotFoundException",
"e",
")",
"{",
"versionName",
"=",
"\"1.0\"",
";",
"// Caso ocarra uma excessão, será retornado a versão 1.0",
"}",
"return",
"versionName",
";",
"}"
] | [
8,
4
] | [
20,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfiguration. | null | configuracoes de autorização | configuracoes de autorização | @Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers(HttpMethod.GET, "/topicos").permitAll() // permitindo a url topicos
.antMatchers(HttpMethod.GET, "/topicos/*").permitAll() // permitindo tudo em tópicos
.antMatchers(HttpMethod.POST, "/auth").permitAll() // permitindo a url auth
.antMatchers(HttpMethod.GET, "/actuator/*").permitAll() // permitindo a url do método actuator
.anyRequest().authenticated()
.and().csrf().disable() // csrf é um tipo de ataque hacker
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) // política de criação de sessao
.and().addFilterBefore(new AutenticacaoViaTokenFilter(tokenService, usuarioRepository), UsernamePasswordAuthenticationFilter.class);
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"HttpSecurity",
"http",
")",
"throws",
"Exception",
"{",
"http",
".",
"authorizeRequests",
"(",
")",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"GET",
",",
"\"/topicos\"",
")",
".",
"permitAll",
"(",
")",
"// permitindo a url topicos",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"GET",
",",
"\"/topicos/*\"",
")",
".",
"permitAll",
"(",
")",
"// permitindo tudo em tópicos",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"POST",
",",
"\"/auth\"",
")",
".",
"permitAll",
"(",
")",
"// permitindo a url auth",
".",
"antMatchers",
"(",
"HttpMethod",
".",
"GET",
",",
"\"/actuator/*\"",
")",
".",
"permitAll",
"(",
")",
"// permitindo a url do método actuator",
".",
"anyRequest",
"(",
")",
".",
"authenticated",
"(",
")",
".",
"and",
"(",
")",
".",
"csrf",
"(",
")",
".",
"disable",
"(",
")",
"// csrf é um tipo de ataque hacker",
".",
"sessionManagement",
"(",
")",
".",
"sessionCreationPolicy",
"(",
"SessionCreationPolicy",
".",
"STATELESS",
")",
"// política de criação de sessao",
".",
"and",
"(",
")",
".",
"addFilterBefore",
"(",
"new",
"AutenticacaoViaTokenFilter",
"(",
"tokenService",
",",
"usuarioRepository",
")",
",",
"UsernamePasswordAuthenticationFilter",
".",
"class",
")",
";",
"}"
] | [
45,
2
] | [
56,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TurmaController. | null | Metodo responsavel por carregar o servico e jogar o Turma no ObservableList | Metodo responsavel por carregar o servico e jogar o Turma no ObservableList | public void updateTableView() {
if (service == null) {
throw new IllegalStateException("Service was null");
}
List<Turma> list = service.findyAll();
obsList = FXCollections.observableArrayList(list);
tableViewTurma.setItems(obsList);
busca();
} | [
"public",
"void",
"updateTableView",
"(",
")",
"{",
"if",
"(",
"service",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Service was null\"",
")",
";",
"}",
"List",
"<",
"Turma",
">",
"list",
"=",
"service",
".",
"findyAll",
"(",
")",
";",
"obsList",
"=",
"FXCollections",
".",
"observableArrayList",
"(",
"list",
")",
";",
"tableViewTurma",
".",
"setItems",
"(",
"obsList",
")",
";",
"busca",
"(",
")",
";",
"}"
] | [
131,
4
] | [
140,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Conjunto. | null | Pertinencia de um elemento a um conjunto | Pertinencia de um elemento a um conjunto | public boolean pertinencia(int a) {
for (int i = 0; i < this.elementos.length ;i++ ) {
if (this.elementos[i] == a)
return true;
}
return false;
} | [
"public",
"boolean",
"pertinencia",
"(",
"int",
"a",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"this",
".",
"elementos",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"this",
".",
"elementos",
"[",
"i",
"]",
"==",
"a",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | [
45,
4
] | [
52,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UploaderFake. | null | links para imagens que passaram por upload. | links para imagens que passaram por upload. | @Override
public Set<String> envia(List<MultipartFile> imagens) {
return imagens.stream().map(imagem -> "http://bucket.io/" + imagem.getOriginalFilename()
+ "-" + UUID.randomUUID().toString()).collect(Collectors.toSet());
} | [
"@",
"Override",
"public",
"Set",
"<",
"String",
">",
"envia",
"(",
"List",
"<",
"MultipartFile",
">",
"imagens",
")",
"{",
"return",
"imagens",
".",
"stream",
"(",
")",
".",
"map",
"(",
"imagem",
"->",
"\"http://bucket.io/\"",
"+",
"imagem",
".",
"getOriginalFilename",
"(",
")",
"+",
"\"-\"",
"+",
"UUID",
".",
"randomUUID",
"(",
")",
".",
"toString",
"(",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toSet",
"(",
")",
")",
";",
"}"
] | [
16,
4
] | [
20,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Usuario. | null | Getter para atributo Rol | Getter para atributo Rol | public String getRol()
{
return Rol;
} | [
"public",
"String",
"getRol",
"(",
")",
"{",
"return",
"Rol",
";",
"}"
] | [
155,
4
] | [
158,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Tiro. | null | esse é o método chamado pelos players para calcular a posição do tiro | esse é o método chamado pelos players para calcular a posição do tiro | public void move(int id) {
//dependendo qual jogador a bala tem uma posição a seguir
switch(id){
case 1:
x += 5;
break;
case 2:
x -= 5;
break;
}
} | [
"public",
"void",
"move",
"(",
"int",
"id",
")",
"{",
"//dependendo qual jogador a bala tem uma posição a seguir",
"switch",
"(",
"id",
")",
"{",
"case",
"1",
":",
"x",
"+=",
"5",
";",
"break",
";",
"case",
"2",
":",
"x",
"-=",
"5",
";",
"break",
";",
"}",
"}"
] | [
13,
4
] | [
23,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Funcionario. | null | Método para pegar bonificação | Método para pegar bonificação | public double calcularComissao() {
return this.Salario * 0.10;
} | [
"public",
"double",
"calcularComissao",
"(",
")",
"{",
"return",
"this",
".",
"Salario",
"*",
"0.10",
";",
"}"
] | [
10,
1
] | [
12,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Bank. | null | Devolve a conta vinculada a um número dado | Devolve a conta vinculada a um número dado | public BankAccount find(int accountNumber) {
for (BankAccount conta : accounts)
if (conta.getAccountNumber() == accountNumber)
return conta; //Achei
return null;//Não achei
} | [
"public",
"BankAccount",
"find",
"(",
"int",
"accountNumber",
")",
"{",
"for",
"(",
"BankAccount",
"conta",
":",
"accounts",
")",
"if",
"(",
"conta",
".",
"getAccountNumber",
"(",
")",
"==",
"accountNumber",
")",
"return",
"conta",
";",
"//Achei",
"return",
"null",
";",
"//Não achei",
"}"
] | [
76,
4
] | [
81,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ShapeFactory. | null | Definido de forma dinâmica na aplicação de acordo com a configuração | Definido de forma dinâmica na aplicação de acordo com a configuração | public static Shape newShape() {
String shapeClass = Props.getString("shapeClass");
try {
Shape shape;
shape = (Shape) Class.forName(shapeClass).getDeclaredConstructor().newInstance();
String[] color = Props.getString("color").split(",");
shape.defineColor(Integer.parseInt(color[0]), Integer.parseInt(color[1]), Integer.parseInt(color[2]));
return shape;
} catch (InstantiationException
| IllegalAccessException
| ClassNotFoundException
| NoSuchMethodException
| InvocationTargetException e) {
throw new RuntimeException(e);
}
} | [
"public",
"static",
"Shape",
"newShape",
"(",
")",
"{",
"String",
"shapeClass",
"=",
"Props",
".",
"getString",
"(",
"\"shapeClass\"",
")",
";",
"try",
"{",
"Shape",
"shape",
";",
"shape",
"=",
"(",
"Shape",
")",
"Class",
".",
"forName",
"(",
"shapeClass",
")",
".",
"getDeclaredConstructor",
"(",
")",
".",
"newInstance",
"(",
")",
";",
"String",
"[",
"]",
"color",
"=",
"Props",
".",
"getString",
"(",
"\"color\"",
")",
".",
"split",
"(",
"\",\"",
")",
";",
"shape",
".",
"defineColor",
"(",
"Integer",
".",
"parseInt",
"(",
"color",
"[",
"0",
"]",
")",
",",
"Integer",
".",
"parseInt",
"(",
"color",
"[",
"1",
"]",
")",
",",
"Integer",
".",
"parseInt",
"(",
"color",
"[",
"2",
"]",
")",
")",
";",
"return",
"shape",
";",
"}",
"catch",
"(",
"InstantiationException",
"|",
"IllegalAccessException",
"|",
"ClassNotFoundException",
"|",
"NoSuchMethodException",
"|",
"InvocationTargetException",
"e",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"e",
")",
";",
"}",
"}"
] | [
18,
4
] | [
36,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
PropostaHealthCheck. | null | Como configurar melhor o Health??? | Como configurar melhor o Health??? | @Override
public Health health() {
Map<String, Object> details = new HashMap<>();
details.put("descrição", "tentando um health");
return Health.status(Status.UP).withDetails(details).build();
} | [
"@",
"Override",
"public",
"Health",
"health",
"(",
")",
"{",
"Map",
"<",
"String",
",",
"Object",
">",
"details",
"=",
"new",
"HashMap",
"<>",
"(",
")",
";",
"details",
".",
"put",
"(",
"\"descrição\", ",
"\"",
"entando um health\");",
"\r",
"",
"return",
"Health",
".",
"status",
"(",
"Status",
".",
"UP",
")",
".",
"withDetails",
"(",
"details",
")",
".",
"build",
"(",
")",
";",
"}"
] | [
15,
1
] | [
21,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Curso. | null | Métodos modificadores de acesso (sets e gets): | Métodos modificadores de acesso (sets e gets): | public int getIdCurso() {
return idCurso;
} | [
"public",
"int",
"getIdCurso",
"(",
")",
"{",
"return",
"idCurso",
";",
"}"
] | [
20,
4
] | [
22,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Iteracoes. | null | /*Imprimir todos os nomes do array | /*Imprimir todos os nomes do array | public static void imprimirTodosOsNomes(String... nomes) {
for (String nome : nomes) {
System.out.println("Impresso pelo FOR: " + nome);
}
// Utilizando Java API
Stream.of(nomes)
.forEach(nome -> System.out.println("Impresso pelo FOREACH: " + nome));
} | [
"public",
"static",
"void",
"imprimirTodosOsNomes",
"(",
"String",
"...",
"nomes",
")",
"{",
"for",
"(",
"String",
"nome",
":",
"nomes",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Impresso pelo FOR: \"",
"+",
"nome",
")",
";",
"}",
"// Utilizando Java API",
"Stream",
".",
"of",
"(",
"nomes",
")",
".",
"forEach",
"(",
"nome",
"->",
"System",
".",
"out",
".",
"println",
"(",
"\"Impresso pelo FOREACH: \"",
"+",
"nome",
")",
")",
";",
"}"
] | [
51,
4
] | [
59,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Testes. | null | Testes Ex1 da aula 07 | Testes Ex1 da aula 07 | public static void main(String[] args) {
// Criei uma ArrayList para guardar os trabalhadores (nao criei classe Empresa nem várias empresas)
// ArrayList permite manipulaçao dos dados mais facilmente e tem os metodos
// add() e remove()
ArrayList<Empregados> listaTrabalhadores = new ArrayList<Empregados>();
//Crio diferentes trabalhadores
Empregados empregado1 = new Empregados("Andre");
GerentesDeLoja gerenteDeLoja1 = new GerentesDeLoja("Ricardo");
GerentesDeLoja gerenteDeLoja2 = new GerentesDeLoja("Maria");
DirectoresRegionais directorRegional1 = new DirectoresRegionais("Abilio");
//Adiciono os trabalhadores à lista
listaTrabalhadores.add(empregado1);
listaTrabalhadores.add(gerenteDeLoja1);
listaTrabalhadores.add(gerenteDeLoja2);
listaTrabalhadores.add(directorRegional1);
// Defino atributos para cada trabalhador
gerenteDeLoja1.setObjectivosVendas(true);
gerenteDeLoja2.setObjectivosVendas(false);
directorRegional1.setLucroMensal(1300);
//Calculo salarios para todos os trabalhadores
empregado1.calcularSalario();
gerenteDeLoja1.calcularSalario();
gerenteDeLoja2.calcularSalario();
directorRegional1.calcularSalario();
// Imprimir lista de trabalhadores
// Uso um iterador (for-each) para percorrer a ArrayList e imprimir trabalhadores 1 a 1
// Podem consultar mais sobre for-each no link abaixo
// https://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work
System.out.println("Lista de Trabalhadores criados");
for (Empregados empregado : listaTrabalhadores ){
System.out.println(empregado.toString());
}
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// Criei uma ArrayList para guardar os trabalhadores (nao criei classe Empresa nem várias empresas)",
"// ArrayList permite manipulaçao dos dados mais facilmente e tem os metodos",
"// add() e remove()",
"ArrayList",
"<",
"Empregados",
">",
"listaTrabalhadores",
"=",
"new",
"ArrayList",
"<",
"Empregados",
">",
"(",
")",
";",
"//Crio diferentes trabalhadores",
"Empregados",
"empregado1",
"=",
"new",
"Empregados",
"(",
"\"Andre\"",
")",
";",
"GerentesDeLoja",
"gerenteDeLoja1",
"=",
"new",
"GerentesDeLoja",
"(",
"\"Ricardo\"",
")",
";",
"GerentesDeLoja",
"gerenteDeLoja2",
"=",
"new",
"GerentesDeLoja",
"(",
"\"Maria\"",
")",
";",
"DirectoresRegionais",
"directorRegional1",
"=",
"new",
"DirectoresRegionais",
"(",
"\"Abilio\"",
")",
";",
"//Adiciono os trabalhadores à lista",
"listaTrabalhadores",
".",
"add",
"(",
"empregado1",
")",
";",
"listaTrabalhadores",
".",
"add",
"(",
"gerenteDeLoja1",
")",
";",
"listaTrabalhadores",
".",
"add",
"(",
"gerenteDeLoja2",
")",
";",
"listaTrabalhadores",
".",
"add",
"(",
"directorRegional1",
")",
";",
"// Defino atributos para cada trabalhador",
"gerenteDeLoja1",
".",
"setObjectivosVendas",
"(",
"true",
")",
";",
"gerenteDeLoja2",
".",
"setObjectivosVendas",
"(",
"false",
")",
";",
"directorRegional1",
".",
"setLucroMensal",
"(",
"1300",
")",
";",
"//Calculo salarios para todos os trabalhadores",
"empregado1",
".",
"calcularSalario",
"(",
")",
";",
"gerenteDeLoja1",
".",
"calcularSalario",
"(",
")",
";",
"gerenteDeLoja2",
".",
"calcularSalario",
"(",
")",
";",
"directorRegional1",
".",
"calcularSalario",
"(",
")",
";",
"// Imprimir lista de trabalhadores",
"// Uso um iterador (for-each) para percorrer a ArrayList e imprimir trabalhadores 1 a 1",
"// Podem consultar mais sobre for-each no link abaixo",
"// https://stackoverflow.com/questions/85190/how-does-the-java-for-each-loop-work",
"System",
".",
"out",
".",
"println",
"(",
"\"Lista de Trabalhadores criados\"",
")",
";",
"for",
"(",
"Empregados",
"empregado",
":",
"listaTrabalhadores",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"empregado",
".",
"toString",
"(",
")",
")",
";",
"}",
"}"
] | [
7,
4
] | [
44,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ProdutoService. | null | Resolução do Problema no StackOverFlow: https://stackoverflow.com/questions/5587482/hibernate-a-collection-with-cascade-all-delete-orphan-was-no-longer-referenc | Resolução do Problema no StackOverFlow: https://stackoverflow.com/questions/5587482/hibernate-a-collection-with-cascade-all-delete-orphan-was-no-longer-referenc | @Transactional(propagation = Propagation.REQUIRES_NEW)
public Produto update(Produto produto) {
try {
produtoRepository.findById(produto.getId()).orElseThrow(() -> new ObjectNotFoundException("Produto não existe"));
for (ProdutosIngredientes item : produto.getIngredientes()) {
item.setProduto(produto);
}
Produto newProd = produtoRepository.findById(produto.getId()).get();
newProd.getIngredientes().clear();
newProd.getIngredientes().addAll(produto.getIngredientes());
newProd.setPrecoFinal(produto.getPrecoFinal());
return produtoRepository.save(newProd);
} catch (DataIntegrityViolationException e) {
throw new DataIntegrityException("Produto não pode ser alterado");
} catch (IllegalArgumentException e) {
throw new ObjectNotFoundException("Produto não existe");
}
} | [
"@",
"Transactional",
"(",
"propagation",
"=",
"Propagation",
".",
"REQUIRES_NEW",
")",
"public",
"Produto",
"update",
"(",
"Produto",
"produto",
")",
"{",
"try",
"{",
"produtoRepository",
".",
"findById",
"(",
"produto",
".",
"getId",
"(",
")",
")",
".",
"orElseThrow",
"(",
"(",
")",
"->",
"new",
"ObjectNotFoundException",
"(",
"\"Produto não existe\")",
")",
";",
"",
"for",
"(",
"ProdutosIngredientes",
"item",
":",
"produto",
".",
"getIngredientes",
"(",
")",
")",
"{",
"item",
".",
"setProduto",
"(",
"produto",
")",
";",
"}",
"Produto",
"newProd",
"=",
"produtoRepository",
".",
"findById",
"(",
"produto",
".",
"getId",
"(",
")",
")",
".",
"get",
"(",
")",
";",
"newProd",
".",
"getIngredientes",
"(",
")",
".",
"clear",
"(",
")",
";",
"newProd",
".",
"getIngredientes",
"(",
")",
".",
"addAll",
"(",
"produto",
".",
"getIngredientes",
"(",
")",
")",
";",
"newProd",
".",
"setPrecoFinal",
"(",
"produto",
".",
"getPrecoFinal",
"(",
")",
")",
";",
"return",
"produtoRepository",
".",
"save",
"(",
"newProd",
")",
";",
"}",
"catch",
"(",
"DataIntegrityViolationException",
"e",
")",
"{",
"throw",
"new",
"DataIntegrityException",
"(",
"\"Produto não pode ser alterado\")",
";",
"",
"}",
"catch",
"(",
"IllegalArgumentException",
"e",
")",
"{",
"throw",
"new",
"ObjectNotFoundException",
"(",
"\"Produto não existe\")",
";",
"",
"}",
"}"
] | [
52,
1
] | [
72,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
PropostaController. | null | 035 acompanhamento proposta | 035 acompanhamento proposta | @GetMapping("/{id}")
public ResponseEntity<PropostaResponseFilter> buscarPeloIdProposta(@PathVariable Long id) {
Optional<Proposta> possivelProposta = propostaRepository.findById(id);
return possivelProposta
.map(proposta -> ResponseEntity.ok()
.body(new PropostaResponseFilter(proposta)))
.orElse(ResponseEntity.notFound().build());
} | [
"@",
"GetMapping",
"(",
"\"/{id}\"",
")",
"public",
"ResponseEntity",
"<",
"PropostaResponseFilter",
">",
"buscarPeloIdProposta",
"(",
"@",
"PathVariable",
"Long",
"id",
")",
"{",
"Optional",
"<",
"Proposta",
">",
"possivelProposta",
"=",
"propostaRepository",
".",
"findById",
"(",
"id",
")",
";",
"return",
"possivelProposta",
".",
"map",
"(",
"proposta",
"->",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"new",
"PropostaResponseFilter",
"(",
"proposta",
")",
")",
")",
".",
"orElse",
"(",
"ResponseEntity",
".",
"notFound",
"(",
")",
".",
"build",
"(",
")",
")",
";",
"}"
] | [
67,
4
] | [
74,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Fila. | null | Método para tirar um nó e retorna um tipo generic | Método para tirar um nó e retorna um tipo generic | public T dequeue(){
if (!this.isEmpty()){
No primeiroNo = refNoEntradaFila;
No noAuxiliar = refNoEntradaFila;
while (true){
if (primeiroNo.getRefNo() != null) {
noAuxiliar = primeiroNo;
primeiroNo = primeiroNo.getRefNo();
}else {
noAuxiliar.setRefNo(null);
break;
}
}
return (T) primeiroNo.getObject();
}
return null;
} | [
"public",
"T",
"dequeue",
"(",
")",
"{",
"if",
"(",
"!",
"this",
".",
"isEmpty",
"(",
")",
")",
"{",
"No",
"primeiroNo",
"=",
"refNoEntradaFila",
";",
"No",
"noAuxiliar",
"=",
"refNoEntradaFila",
";",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"primeiroNo",
".",
"getRefNo",
"(",
")",
"!=",
"null",
")",
"{",
"noAuxiliar",
"=",
"primeiroNo",
";",
"primeiroNo",
"=",
"primeiroNo",
".",
"getRefNo",
"(",
")",
";",
"}",
"else",
"{",
"noAuxiliar",
".",
"setRefNo",
"(",
"null",
")",
";",
"break",
";",
"}",
"}",
"return",
"(",
"T",
")",
"primeiroNo",
".",
"getObject",
"(",
")",
";",
"}",
"return",
"null",
";",
"}"
] | [
36,
4
] | [
52,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DesafioMeuTimeApplication. | null | Realiza a inclusão de um novo jogador. | Realiza a inclusão de um novo jogador. | @Desafio("incluirJogador")
public void incluirJogador(Long id, Long idTime, String nome, LocalDate dataNascimento, Integer nivelHabilidade, BigDecimal salario) {
//Caso o identificador já exista, retornar br.com.codenation.desafio.exceptions.IdentificadorUtilizadoException
if(this.buscaJogadorPeloId(id).isPresent())
throw new IdentificadorUtilizadoException();
//Caso o time informado não exista, retornar br.com.codenation.desafio.exceptions.TimeNaoEncontradoException
Time t = this.buscaTimePeloId(idTime).orElseThrow(TimeNaoEncontradoException::new);
Jogador j = new Jogador(id, idTime, nome, dataNascimento, nivelHabilidade, salario);
this.jogadores.add(j);
t.addJogador(j);
} | [
"@",
"Desafio",
"(",
"\"incluirJogador\"",
")",
"public",
"void",
"incluirJogador",
"(",
"Long",
"id",
",",
"Long",
"idTime",
",",
"String",
"nome",
",",
"LocalDate",
"dataNascimento",
",",
"Integer",
"nivelHabilidade",
",",
"BigDecimal",
"salario",
")",
"{",
"//Caso o identificador já exista, retornar br.com.codenation.desafio.exceptions.IdentificadorUtilizadoException",
"if",
"(",
"this",
".",
"buscaJogadorPeloId",
"(",
"id",
")",
".",
"isPresent",
"(",
")",
")",
"throw",
"new",
"IdentificadorUtilizadoException",
"(",
")",
";",
"//Caso o time informado não exista, retornar br.com.codenation.desafio.exceptions.TimeNaoEncontradoException",
"Time",
"t",
"=",
"this",
".",
"buscaTimePeloId",
"(",
"idTime",
")",
".",
"orElseThrow",
"(",
"TimeNaoEncontradoException",
"::",
"new",
")",
";",
"Jogador",
"j",
"=",
"new",
"Jogador",
"(",
"id",
",",
"idTime",
",",
"nome",
",",
"dataNascimento",
",",
"nivelHabilidade",
",",
"salario",
")",
";",
"this",
".",
"jogadores",
".",
"add",
"(",
"j",
")",
";",
"t",
".",
"addJogador",
"(",
"j",
")",
";",
"}"
] | [
32,
1
] | [
43,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula03ex. | null | possibilidades de signos. | possibilidades de signos. | public static void obterSigno() {
Scanner s = new Scanner(System.in);
System.out.println("Introduza o seu dia de nascimento:");
int dia = s.nextInt();
System.out.println("Introduza o numero do seu mês de nascimento:");
int mes = s.nextInt();
if ((dia>=21 && mes == 3) || (dia <= 20 && mes == 4)){
System.out.println("O signo dado é Carneiro");
} else if ((dia>=21 && mes == 4) || (dia <= 20 && mes == 5)) {
System.out.println("O signo dado é Touro");
} else if ((dia>=21 && mes == 5) || (dia <= 20 && mes == 6)) {
System.out.println("O signo dado é Gémeos");
} else if ((dia>=21 && mes == 6) || (dia <= 21 && mes == 7)) {
System.out.println("O signo dado é Caranguejo");
} else if ((dia>=22 && mes == 7) || (dia <= 22 && mes == 8)) {
System.out.println("O signo dado é Leão");
} else if ((dia>=23 && mes == 8) || (dia <= 22 && mes == 9)) {
System.out.println("O signo dado é Virgem");
} else if ((dia>=23 && mes == 9) || (dia <= 22 && mes == 10)) {
System.out.println("O signo dado é Balança");
} else if ((dia>=23 && mes == 10) || (dia <= 21 && mes == 11)) {
System.out.println("O signo dado é Escorpião");
} else if ((dia>=22 && mes == 11) || (dia <= 21 && mes == 12)) {
System.out.println("O signo dado é Sagitário");
} else if ((dia>=22 && mes == 12) || (dia <= 20 && mes == 1)) {
System.out.println("O signo dado é Capricórnio");
} else if ((dia>=21 && mes == 1) || (dia <= 19 && mes == 2)) {
System.out.println("O signo dado é Aquário");
} else if ((dia>=20 && mes == 2) || (dia <= 20 && mes == 3)) {
System.out.println("O signo dado é Peixes");
} else {
System.out.println("A data introduzida nao é valida");;
}
} | [
"public",
"static",
"void",
"obterSigno",
"(",
")",
"{",
"Scanner",
"s",
"=",
"new",
"Scanner",
"(",
"System",
".",
"in",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduza o seu dia de nascimento:\"",
")",
";",
"int",
"dia",
"=",
"s",
".",
"nextInt",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduza o numero do seu mês de nascimento:\")",
";",
"",
"int",
"mes",
"=",
"s",
".",
"nextInt",
"(",
")",
";",
"if",
"(",
"(",
"dia",
">=",
"21",
"&&",
"mes",
"==",
"3",
")",
"||",
"(",
"dia",
"<=",
"20",
"&&",
"mes",
"==",
"4",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Carneiro\")",
";",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"21",
"&&",
"mes",
"==",
"4",
")",
"||",
"(",
"dia",
"<=",
"20",
"&&",
"mes",
"==",
"5",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Touro\")",
";",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"21",
"&&",
"mes",
"==",
"5",
")",
"||",
"(",
"dia",
"<=",
"20",
"&&",
"mes",
"==",
"6",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Gémeos\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"21",
"&&",
"mes",
"==",
"6",
")",
"||",
"(",
"dia",
"<=",
"21",
"&&",
"mes",
"==",
"7",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Caranguejo\")",
";",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"22",
"&&",
"mes",
"==",
"7",
")",
"||",
"(",
"dia",
"<=",
"22",
"&&",
"mes",
"==",
"8",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Leão\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"23",
"&&",
"mes",
"==",
"8",
")",
"||",
"(",
"dia",
"<=",
"22",
"&&",
"mes",
"==",
"9",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Virgem\")",
";",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"23",
"&&",
"mes",
"==",
"9",
")",
"||",
"(",
"dia",
"<=",
"22",
"&&",
"mes",
"==",
"10",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Balança\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"23",
"&&",
"mes",
"==",
"10",
")",
"||",
"(",
"dia",
"<=",
"21",
"&&",
"mes",
"==",
"11",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Escorpião\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"22",
"&&",
"mes",
"==",
"11",
")",
"||",
"(",
"dia",
"<=",
"21",
"&&",
"mes",
"==",
"12",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Sagitário\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"22",
"&&",
"mes",
"==",
"12",
")",
"||",
"(",
"dia",
"<=",
"20",
"&&",
"mes",
"==",
"1",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Capricórnio\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"21",
"&&",
"mes",
"==",
"1",
")",
"||",
"(",
"dia",
"<=",
"19",
"&&",
"mes",
"==",
"2",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Aquário\");",
"",
"",
"}",
"else",
"if",
"(",
"(",
"dia",
">=",
"20",
"&&",
"mes",
"==",
"2",
")",
"||",
"(",
"dia",
"<=",
"20",
"&&",
"mes",
"==",
"3",
")",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"O signo dado é Peixes\")",
";",
"",
"}",
"else",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"A data introduzida nao é valida\")",
";",
";",
"",
"}",
"}"
] | [
170,
4
] | [
203,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
App. | null | Função que pega as URLs da página 1 | Função que pega as URLs da página 1 | public static List<String> getListaURLs() {
List<String> URLs = new ArrayList<String>();
try {
Document document = Jsoup.connect("https://www.infomoney.com.br/mercados/").get();
App parserInfo = new App(document);
URLs = parserInfo.getURLInfo();
} catch (IOException e) {
e.printStackTrace();
}
return URLs;
} | [
"public",
"static",
"List",
"<",
"String",
">",
"getListaURLs",
"(",
")",
"{",
"List",
"<",
"String",
">",
"URLs",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"try",
"{",
"Document",
"document",
"=",
"Jsoup",
".",
"connect",
"(",
"\"https://www.infomoney.com.br/mercados/\"",
")",
".",
"get",
"(",
")",
";",
"App",
"parserInfo",
"=",
"new",
"App",
"(",
"document",
")",
";",
"URLs",
"=",
"parserInfo",
".",
"getURLInfo",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"URLs",
";",
"}"
] | [
208,
1
] | [
223,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DoubleRecursiveLinkedListImpl. | null | retorna a quantidade de elementos da lista | retorna a quantidade de elementos da lista | @Override
public int size() {
if (isEmpty()) {
return 0;
} else {
return size(this.head);
}
} | [
"@",
"Override",
"public",
"int",
"size",
"(",
")",
"{",
"if",
"(",
"isEmpty",
"(",
")",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"size",
"(",
"this",
".",
"head",
")",
";",
"}",
"}"
] | [
39,
1
] | [
46,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FramePrincipal. | null | método ativado ao se clicar o botão que cria a partida | método ativado ao se clicar o botão que cria a partida | private void BotaoServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BotaoServerActionPerformed
//comando necessário para criar uma nota tela sobreposta
BotaoServer.addActionListener((ActionListener) this);
//novo objeto servidor
server = new Servidor();
//instancia o servidor
server.start();
//inicia o jogo para o jogador 1
novaTela(1);
//desabilita os botões, para que não interfiram na nova tela
BotaoServer.setEnabled(false);
BotaoCliente.setEnabled(false);
} | [
"private",
"void",
"BotaoServerActionPerformed",
"(",
"java",
".",
"awt",
".",
"event",
".",
"ActionEvent",
"evt",
")",
"{",
"//GEN-FIRST:event_BotaoServerActionPerformed",
"//comando necessário para criar uma nota tela sobreposta",
"BotaoServer",
".",
"addActionListener",
"(",
"(",
"ActionListener",
")",
"this",
")",
";",
"//novo objeto servidor",
"server",
"=",
"new",
"Servidor",
"(",
")",
";",
"//instancia o servidor",
"server",
".",
"start",
"(",
")",
";",
"//inicia o jogo para o jogador 1",
"novaTela",
"(",
"1",
")",
";",
"//desabilita os botões, para que não interfiram na nova tela",
"BotaoServer",
".",
"setEnabled",
"(",
"false",
")",
";",
"BotaoCliente",
".",
"setEnabled",
"(",
"false",
")",
";",
"}"
] | [
67,
4
] | [
79,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfiguration. | null | Configuração de autenticação | Configuração de autenticação | @Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(autenticationService).passwordEncoder(passwordEncoder());
} | [
"@",
"Override",
"protected",
"void",
"configure",
"(",
"AuthenticationManagerBuilder",
"auth",
")",
"throws",
"Exception",
"{",
"auth",
".",
"userDetailsService",
"(",
"autenticationService",
")",
".",
"passwordEncoder",
"(",
"passwordEncoder",
"(",
")",
")",
";",
"}"
] | [
44,
1
] | [
47,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Connect. | null | cadastral no banco um usuario passado como parametro | cadastral no banco um usuario passado como parametro | public boolean insertUsuario(Usuario usuario) {
Statement st = null;
ResultSet rs = null;
try {
st = con.createStatement();
PreparedStatement preparedStatement = con.prepareStatement("insert into usuario (id, nome, senha, descricao, data_cadastro) values(?,?,?,?,?)");
preparedStatement.setInt(1, usuario.getId());
preparedStatement.setString(2, usuario.getNome());
preparedStatement.setString(3, usuario.getSenha());
preparedStatement.setString(4, "" + usuario.getDescricao());
preparedStatement.setDate(5, new java.sql.Date(new Date().getTime()));
preparedStatement.execute();
return true;
} catch (SQLException ex) {
Logger lgr = Logger.getLogger(Connect.class.getName());
lgr.log(Level.SEVERE, ex.getMessage(), ex);
return false;
}
} | [
"public",
"boolean",
"insertUsuario",
"(",
"Usuario",
"usuario",
")",
"{",
"Statement",
"st",
"=",
"null",
";",
"ResultSet",
"rs",
"=",
"null",
";",
"try",
"{",
"st",
"=",
"con",
".",
"createStatement",
"(",
")",
";",
"PreparedStatement",
"preparedStatement",
"=",
"con",
".",
"prepareStatement",
"(",
"\"insert into usuario (id, nome, senha, descricao, data_cadastro) values(?,?,?,?,?)\"",
")",
";",
"preparedStatement",
".",
"setInt",
"(",
"1",
",",
"usuario",
".",
"getId",
"(",
")",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"2",
",",
"usuario",
".",
"getNome",
"(",
")",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"3",
",",
"usuario",
".",
"getSenha",
"(",
")",
")",
";",
"preparedStatement",
".",
"setString",
"(",
"4",
",",
"\"\"",
"+",
"usuario",
".",
"getDescricao",
"(",
")",
")",
";",
"preparedStatement",
".",
"setDate",
"(",
"5",
",",
"new",
"java",
".",
"sql",
".",
"Date",
"(",
"new",
"Date",
"(",
")",
".",
"getTime",
"(",
")",
")",
")",
";",
"preparedStatement",
".",
"execute",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"SQLException",
"ex",
")",
"{",
"Logger",
"lgr",
"=",
"Logger",
".",
"getLogger",
"(",
"Connect",
".",
"class",
".",
"getName",
"(",
")",
")",
";",
"lgr",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"ex",
".",
"getMessage",
"(",
")",
",",
"ex",
")",
";",
"return",
"false",
";",
"}",
"}"
] | [
42,
5
] | [
65,
6
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
DiscoveryCloudletMulticast. | null | serve para parar esse serviço! | serve para parar esse serviço! | private void stopService() {
stop = true;
} | [
"private",
"void",
"stopService",
"(",
")",
"{",
"stop",
"=",
"true",
";",
"}"
] | [
148,
1
] | [
150,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Jogo. | null | método privado e interno para verificação de xeque-mate (verifica se o rei foi capturado): | método privado e interno para verificação de xeque-mate (verifica se o rei foi capturado): | private boolean xequeMate(String corDoRei) {
if (corDoRei == "preto") { //caso a cor do rei seja preta
if (!pecas[7].getStatus()) { //verifica-se o status do 7° elemento do vetor de peças
return true;
} else {
return false;
}
} else if (corDoRei == "branco") { //caso a cor do rei seja branca
if (!pecas[23].getStatus()) { //verifica-se o status do 23° elemento do vetor de peças
return true;
} else {
return false;
}
}
return false; //caso a cor passada não seja "preto" ou "branco", retorna nulo
} | [
"private",
"boolean",
"xequeMate",
"(",
"String",
"corDoRei",
")",
"{",
"if",
"(",
"corDoRei",
"==",
"\"preto\"",
")",
"{",
"//caso a cor do rei seja preta",
"if",
"(",
"!",
"pecas",
"[",
"7",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//verifica-se o status do 7° elemento do vetor de peças",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"if",
"(",
"corDoRei",
"==",
"\"branco\"",
")",
"{",
"//caso a cor do rei seja branca",
"if",
"(",
"!",
"pecas",
"[",
"23",
"]",
".",
"getStatus",
"(",
")",
")",
"{",
"//verifica-se o status do 23° elemento do vetor de peças",
"return",
"true",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"false",
";",
"//caso a cor passada não seja \"preto\" ou \"branco\", retorna nulo",
"}"
] | [
437,
4
] | [
452,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TesteUsuarioDAOImplementacao1. | null | /*insere um novo usuário no banco de dados
@Test
public void inserir() {
List<Usuario> lista = UsuarioDAO.todosUsuarios();
assertEquals(2, lista.size());
assertEquals("joao", lista.get(0).getLogin());
} | /*insere um novo usuário no banco de dados
| @Test
public void inserir() throws Exception {
Usuario u = new Usuario();
u.setLogin("duda");
u.setEmail("[email protected]");
u.setNome("Maria Eduarda");
u.setSenha("1010");
u.setPontos(50);
UsuarioDAOImplementacao1 x = new UsuarioDAOImplementacao1();
x.inserir(u);
IDataSet currentDataSet = jdt.getConnection().createDataSet();
ITable currentTable = currentDataSet.getTable("USUARIO");
FlatXmlDataFileLoader loader = new FlatXmlDataFileLoader();
IDataSet expectedDataSet = loader.load("/verifica.xml");
ITable expectedTable = expectedDataSet.getTable("USUARIO");
Assertion.assertEquals(expectedTable, currentTable);
} | [
"@",
"Test",
"public",
"void",
"inserir",
"(",
")",
"throws",
"Exception",
"{",
"Usuario",
"u",
"=",
"new",
"Usuario",
"(",
")",
";",
"u",
".",
"setLogin",
"(",
"\"duda\"",
")",
";",
"u",
".",
"setEmail",
"(",
"\"[email protected]\"",
")",
";",
"u",
".",
"setNome",
"(",
"\"Maria Eduarda\"",
")",
";",
"u",
".",
"setSenha",
"(",
"\"1010\"",
")",
";",
"u",
".",
"setPontos",
"(",
"50",
")",
";",
"UsuarioDAOImplementacao1",
"x",
"=",
"new",
"UsuarioDAOImplementacao1",
"(",
")",
";",
"x",
".",
"inserir",
"(",
"u",
")",
";",
"IDataSet",
"currentDataSet",
"=",
"jdt",
".",
"getConnection",
"(",
")",
".",
"createDataSet",
"(",
")",
";",
"ITable",
"currentTable",
"=",
"currentDataSet",
".",
"getTable",
"(",
"\"USUARIO\"",
")",
";",
"FlatXmlDataFileLoader",
"loader",
"=",
"new",
"FlatXmlDataFileLoader",
"(",
")",
";",
"IDataSet",
"expectedDataSet",
"=",
"loader",
".",
"load",
"(",
"\"/verifica.xml\"",
")",
";",
"ITable",
"expectedTable",
"=",
"expectedDataSet",
".",
"getTable",
"(",
"\"USUARIO\"",
")",
";",
"Assertion",
".",
"assertEquals",
"(",
"expectedTable",
",",
"currentTable",
")",
";",
"}"
] | [
30,
4
] | [
47,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Predicados. | null | Recebem um parâmetro e retornam boolean | Recebem um parâmetro e retornam boolean | public static void main (String[] args){
Predicate<String> estaVazio = valor -> valor.isEmpty();
System.out.println(estaVazio.test(""));
System.out.println(estaVazio.test("Jojo"));
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"Predicate",
"<",
"String",
">",
"estaVazio",
"=",
"valor",
"->",
"valor",
".",
"isEmpty",
"(",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"estaVazio",
".",
"test",
"(",
"\"\"",
")",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"estaVazio",
".",
"test",
"(",
"\"Jojo\"",
")",
")",
";",
"}"
] | [
6,
4
] | [
10,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula02. | null | 2. Area do circulo com raio r | 2. Area do circulo com raio r | static double circleArea(int r) {
return Math.PI * (r * r);
} | [
"static",
"double",
"circleArea",
"(",
"int",
"r",
")",
"{",
"return",
"Math",
".",
"PI",
"*",
"(",
"r",
"*",
"r",
")",
";",
"}"
] | [
23,
4
] | [
25,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ScenePrincipal. | null | TextField Representam áreas de texto | TextField Representam áreas de texto | public void criaScenePrincipal(Stage stage){
//Criando os labels para os pontos e os campos de texto para os dados
labelP1x = new Label("P1.x"); //rótulos
textP1x = new TextField(); //área de texto onde vc digitara alguma coisa
labelP1y = new Label("P1.y");
textP1y = new TextField();
labelP2x = new Label("P2.x");
textP2x = new TextField();
labelP2y = new Label("P2.y");
textP2y = new TextField();
//HBox é usado para agrupar elementos horizontalmente
HBox hP1x = new HBox(labelP1x, textP1x); //Passamos no construtor todos os elementos. Você poderá criar vários grupos horizontais
HBox hP1y = new HBox(labelP1y, textP1y);
HBox hP2x = new HBox(labelP2x, textP2x);
HBox hP2y = new HBox(labelP2y, textP2y);
VBox hboxEntrada = new VBox(hP1x,hP1y,hP2x,hP2y);
//Agora vamos criar a area que mostrará o que foi digitado
textAngular = new TextField();
textAngular.setEditable(false);//vamos deixar false para apenas mostrar texto
textAngular.setText("Coeficiente Angular: ");
textLinear = new TextField();
textLinear.setEditable(false);//vamos deixar false para apenas mostrar texto
textLinear.setText("Coeficiente Linear: ");
HBox hboxResposta = new HBox(textAngular,textLinear);
//Criamos o botão
btnAngular = new Button("Calcular coeficiente Angular");
//Criamos a ação que o botão responderá as ser pressionado
btnAngular.setOnAction(evento -> {
//Aqui dentro é a ação que será executado ao pressionar o botão
Reta reta = construirReta();
textAngular.setText("Coeficiente Angular: " + reta.coeficienteAngular());//Acessamos o componente textField1, pegamos o texto e colocaos em textField2
});
btnLinear = new Button("Calcular coeficiente Linear");
btnLinear.setOnAction(evento -> {
Reta reta = construirReta();
textLinear.setText("Coeficiente Linear: " + reta.coeficienteLinear());
});
HBox hboxBotao = new HBox(btnAngular,btnLinear);
//VBox é usada para agrupar elementos verticalmente
//No construtor passamos todos os elementos que serão agrupados, que podem ser outros grupos
VBox layoutFinal = new VBox(hboxEntrada, hboxResposta,hboxBotao);//Aqui vamos agrupar verticalmente o grupo (Label + Texto) o Botao e A area que aparecer o texto digitado
//Criamos a Scene
Scene scene = new Scene(layoutFinal, 300 , 200);
stage.setTitle("Software Para Calculos de Álgebra Linear");
stage.setScene(scene);
stage.show();
} | [
"public",
"void",
"criaScenePrincipal",
"(",
"Stage",
"stage",
")",
"{",
"//Criando os labels para os pontos e os campos de texto para os dados",
"labelP1x",
"=",
"new",
"Label",
"(",
"\"P1.x\"",
")",
";",
"//rótulos",
"textP1x",
"=",
"new",
"TextField",
"(",
")",
";",
"//área de texto onde vc digitara alguma coisa",
"labelP1y",
"=",
"new",
"Label",
"(",
"\"P1.y\"",
")",
";",
"textP1y",
"=",
"new",
"TextField",
"(",
")",
";",
"labelP2x",
"=",
"new",
"Label",
"(",
"\"P2.x\"",
")",
";",
"textP2x",
"=",
"new",
"TextField",
"(",
")",
";",
"labelP2y",
"=",
"new",
"Label",
"(",
"\"P2.y\"",
")",
";",
"textP2y",
"=",
"new",
"TextField",
"(",
")",
";",
"//HBox é usado para agrupar elementos horizontalmente",
"HBox",
"hP1x",
"=",
"new",
"HBox",
"(",
"labelP1x",
",",
"textP1x",
")",
";",
"//Passamos no construtor todos os elementos. Você poderá criar vários grupos horizontais",
"HBox",
"hP1y",
"=",
"new",
"HBox",
"(",
"labelP1y",
",",
"textP1y",
")",
";",
"HBox",
"hP2x",
"=",
"new",
"HBox",
"(",
"labelP2x",
",",
"textP2x",
")",
";",
"HBox",
"hP2y",
"=",
"new",
"HBox",
"(",
"labelP2y",
",",
"textP2y",
")",
";",
"VBox",
"hboxEntrada",
"=",
"new",
"VBox",
"(",
"hP1x",
",",
"hP1y",
",",
"hP2x",
",",
"hP2y",
")",
";",
"//Agora vamos criar a area que mostrará o que foi digitado",
"textAngular",
"=",
"new",
"TextField",
"(",
")",
";",
"textAngular",
".",
"setEditable",
"(",
"false",
")",
";",
"//vamos deixar false para apenas mostrar texto",
"textAngular",
".",
"setText",
"(",
"\"Coeficiente Angular: \"",
")",
";",
"textLinear",
"=",
"new",
"TextField",
"(",
")",
";",
"textLinear",
".",
"setEditable",
"(",
"false",
")",
";",
"//vamos deixar false para apenas mostrar texto",
"textLinear",
".",
"setText",
"(",
"\"Coeficiente Linear: \"",
")",
";",
"HBox",
"hboxResposta",
"=",
"new",
"HBox",
"(",
"textAngular",
",",
"textLinear",
")",
";",
"//Criamos o botão",
"btnAngular",
"=",
"new",
"Button",
"(",
"\"Calcular coeficiente Angular\"",
")",
";",
"//Criamos a ação que o botão responderá as ser pressionado",
"btnAngular",
".",
"setOnAction",
"(",
"evento",
"->",
"{",
"//Aqui dentro é a ação que será executado ao pressionar o botão",
"Reta",
"reta",
"=",
"construirReta",
"(",
")",
";",
"textAngular",
".",
"setText",
"(",
"\"Coeficiente Angular: \"",
"+",
"reta",
".",
"coeficienteAngular",
"(",
")",
")",
";",
"//Acessamos o componente textField1, pegamos o texto e colocaos em textField2",
"}",
")",
";",
"btnLinear",
"=",
"new",
"Button",
"(",
"\"Calcular coeficiente Linear\"",
")",
";",
"btnLinear",
".",
"setOnAction",
"(",
"evento",
"->",
"{",
"Reta",
"reta",
"=",
"construirReta",
"(",
")",
";",
"textLinear",
".",
"setText",
"(",
"\"Coeficiente Linear: \"",
"+",
"reta",
".",
"coeficienteLinear",
"(",
")",
")",
";",
"}",
")",
";",
"HBox",
"hboxBotao",
"=",
"new",
"HBox",
"(",
"btnAngular",
",",
"btnLinear",
")",
";",
"//VBox é usada para agrupar elementos verticalmente",
"//No construtor passamos todos os elementos que serão agrupados, que podem ser outros grupos",
"VBox",
"layoutFinal",
"=",
"new",
"VBox",
"(",
"hboxEntrada",
",",
"hboxResposta",
",",
"hboxBotao",
")",
";",
"//Aqui vamos agrupar verticalmente o grupo (Label + Texto) o Botao e A area que aparecer o texto digitado",
"//Criamos a Scene",
"Scene",
"scene",
"=",
"new",
"Scene",
"(",
"layoutFinal",
",",
"300",
",",
"200",
")",
";",
"stage",
".",
"setTitle",
"(",
"\"Software Para Calculos de Álgebra Linear\")",
";",
"",
"stage",
".",
"setScene",
"(",
"scene",
")",
";",
"stage",
".",
"show",
"(",
")",
";",
"}"
] | [
18,
4
] | [
79,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CadastroUsuarioController. | null | Este método é para salvar o usuário no BD. | Este método é para salvar o usuário no BD. | @PostMapping("/salvar")
@Transactional(readOnly = false)
public String salvar(@Valid Usuario usuario, BindingResult result, RedirectAttributes attr,
@RequestParam("file") MultipartFile arquivo) {
try {
if (arquivo != null && !arquivo.isEmpty()) {
String nomeArquivo = StringUtils.cleanPath(arquivo.getOriginalFilename());
Arquivo arquivoBD = new Arquivo(null, nomeArquivo, arquivo.getContentType(), arquivo.getBytes());
arquivoRepository.save(arquivoBD);
if (usuario.getFoto() != null && usuario.getFoto().getId() != null && usuario.getFoto().getId() > 0) {
arquivoRepository.delete(usuario.getFoto());
}
usuario.setFoto(arquivoBD);
} else {
usuario.setFoto(null);
}
if (result.hasErrors()) {
return "usuario/cadastro";
}
String senhaCriptografada = new BCryptPasswordEncoder().encode(usuario.getSenha());
usuario.setSenha(senhaCriptografada);
usuarioRepository.save(usuario);
attr.addFlashAttribute("msgSucesso", "Operação realizada com sucesso!");
} catch (IOException e) {
e.printStackTrace();
}
return "redirect:/usuarios/cadastro";
} | [
"@",
"PostMapping",
"(",
"\"/salvar\"",
")",
"@",
"Transactional",
"(",
"readOnly",
"=",
"false",
")",
"public",
"String",
"salvar",
"(",
"@",
"Valid",
"Usuario",
"usuario",
",",
"BindingResult",
"result",
",",
"RedirectAttributes",
"attr",
",",
"@",
"RequestParam",
"(",
"\"file\"",
")",
"MultipartFile",
"arquivo",
")",
"{",
"try",
"{",
"if",
"(",
"arquivo",
"!=",
"null",
"&&",
"!",
"arquivo",
".",
"isEmpty",
"(",
")",
")",
"{",
"String",
"nomeArquivo",
"=",
"StringUtils",
".",
"cleanPath",
"(",
"arquivo",
".",
"getOriginalFilename",
"(",
")",
")",
";",
"Arquivo",
"arquivoBD",
"=",
"new",
"Arquivo",
"(",
"null",
",",
"nomeArquivo",
",",
"arquivo",
".",
"getContentType",
"(",
")",
",",
"arquivo",
".",
"getBytes",
"(",
")",
")",
";",
"arquivoRepository",
".",
"save",
"(",
"arquivoBD",
")",
";",
"if",
"(",
"usuario",
".",
"getFoto",
"(",
")",
"!=",
"null",
"&&",
"usuario",
".",
"getFoto",
"(",
")",
".",
"getId",
"(",
")",
"!=",
"null",
"&&",
"usuario",
".",
"getFoto",
"(",
")",
".",
"getId",
"(",
")",
">",
"0",
")",
"{",
"arquivoRepository",
".",
"delete",
"(",
"usuario",
".",
"getFoto",
"(",
")",
")",
";",
"}",
"usuario",
".",
"setFoto",
"(",
"arquivoBD",
")",
";",
"}",
"else",
"{",
"usuario",
".",
"setFoto",
"(",
"null",
")",
";",
"}",
"if",
"(",
"result",
".",
"hasErrors",
"(",
")",
")",
"{",
"return",
"\"usuario/cadastro\"",
";",
"}",
"String",
"senhaCriptografada",
"=",
"new",
"BCryptPasswordEncoder",
"(",
")",
".",
"encode",
"(",
"usuario",
".",
"getSenha",
"(",
")",
")",
";",
"usuario",
".",
"setSenha",
"(",
"senhaCriptografada",
")",
";",
"usuarioRepository",
".",
"save",
"(",
"usuario",
")",
";",
"attr",
".",
"addFlashAttribute",
"(",
"\"msgSucesso\"",
",",
"\"Operação realizada com sucesso!\");",
"\r",
"",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"\"redirect:/usuarios/cadastro\"",
";",
"}"
] | [
52,
2
] | [
90,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SecurityConfig. | null | Define as configurações de cors, liberando o acesso do frontend ao backend | Define as configurações de cors, liberando o acesso do frontend ao backend | @Bean
CorsConfigurationSource corsConfigurationSource() {
CorsConfiguration configuration = new CorsConfiguration().applyPermitDefaultValues();
configuration.setAllowedMethods(Arrays.asList("POST", "GET", "PUT", "DELETE", "OPTIONS"));
final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", configuration);
return source;
} | [
"@",
"Bean",
"CorsConfigurationSource",
"corsConfigurationSource",
"(",
")",
"{",
"CorsConfiguration",
"configuration",
"=",
"new",
"CorsConfiguration",
"(",
")",
".",
"applyPermitDefaultValues",
"(",
")",
";",
"configuration",
".",
"setAllowedMethods",
"(",
"Arrays",
".",
"asList",
"(",
"\"POST\"",
",",
"\"GET\"",
",",
"\"PUT\"",
",",
"\"DELETE\"",
",",
"\"OPTIONS\"",
")",
")",
";",
"final",
"UrlBasedCorsConfigurationSource",
"source",
"=",
"new",
"UrlBasedCorsConfigurationSource",
"(",
")",
";",
"source",
".",
"registerCorsConfiguration",
"(",
"\"/**\"",
",",
"configuration",
")",
";",
"return",
"source",
";",
"}"
] | [
39,
4
] | [
46,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
SQLMaker. | null | UPDATE livros SET disponivel=1 WHERE titulo='O Diário de Anne Frank'; | UPDATE livros SET disponivel=1 WHERE titulo='O Diário de Anne Frank'; | public static String update(Map<String, String> options) {
final String SQL = "UPDATE {table} SET {fields} WHERE {conditions};";
return replaceParams(options, SQL);
} | [
"public",
"static",
"String",
"update",
"(",
"Map",
"<",
"String",
",",
"String",
">",
"options",
")",
"{",
"final",
"String",
"SQL",
"=",
"\"UPDATE {table} SET {fields} WHERE {conditions};\"",
";",
"return",
"replaceParams",
"(",
"options",
",",
"SQL",
")",
";",
"}"
] | [
41,
4
] | [
45,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FuncoesTopicos. | null | Imprime na tela os imoveis ou salvam em um arquivo de saida | Imprime na tela os imoveis ou salvam em um arquivo de saida | public static List<Imovel> q8EscreverArquivo(boolean opcao) {
if (!opcao) {
return imoveis;
} else {
try {
//Se a opção for do arquivo, faz os processos para salva-lo
gerenciarArquivo.abrirArquivo(1);
gerenciarArquivo.adicionarImoveis(imoveis);
gerenciarArquivo.fecharArquivo(1);
} catch (Exception e) {
System.out.println(e);
}
return null;
}
} | [
"public",
"static",
"List",
"<",
"Imovel",
">",
"q8EscreverArquivo",
"(",
"boolean",
"opcao",
")",
"{",
"if",
"(",
"!",
"opcao",
")",
"{",
"return",
"imoveis",
";",
"}",
"else",
"{",
"try",
"{",
"//Se a opção for do arquivo, faz os processos para salva-lo",
"gerenciarArquivo",
".",
"abrirArquivo",
"(",
"1",
")",
";",
"gerenciarArquivo",
".",
"adicionarImoveis",
"(",
"imoveis",
")",
";",
"gerenciarArquivo",
".",
"fecharArquivo",
"(",
"1",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"e",
")",
";",
"}",
"return",
"null",
";",
"}",
"}"
] | [
144,
4
] | [
158,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cartao. | null | métodos abaixo são usados para as regras de negócios | métodos abaixo são usados para as regras de negócios | public boolean verificarSeCartaoEstaBloqueado() {
return this.status.equals(CartaoStatus.BLOQUEADO);
} | [
"public",
"boolean",
"verificarSeCartaoEstaBloqueado",
"(",
")",
"{",
"return",
"this",
".",
"status",
".",
"equals",
"(",
"CartaoStatus",
".",
"BLOQUEADO",
")",
";",
"}"
] | [
95,
1
] | [
97,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Simultaneo. | null | Pulei para a classe contarTempo com Thread | Pulei para a classe contarTempo com Thread | public void mostrarMensagem() {
int anoNasc = Integer.parseInt(JOptionPane.showInputDialog("Em que ano você nasceu?"));
int anoAtual = Integer.parseInt(JOptionPane.showInputDialog("Em que ano estamos?"));
int resultado = anoAtual - anoNasc;
idade.setText("Você tem " + resultado + " anos");
} | [
"public",
"void",
"mostrarMensagem",
"(",
")",
"{",
"int",
"anoNasc",
"=",
"Integer",
".",
"parseInt",
"(",
"JOptionPane",
".",
"showInputDialog",
"(",
"\"Em que ano você nasceu?\")",
")",
";",
"",
"int",
"anoAtual",
"=",
"Integer",
".",
"parseInt",
"(",
"JOptionPane",
".",
"showInputDialog",
"(",
"\"Em que ano estamos?\"",
")",
")",
";",
"int",
"resultado",
"=",
"anoAtual",
"-",
"anoNasc",
";",
"idade",
".",
"setText",
"(",
"\"Você tem \" ",
" ",
"esultado ",
" ",
" anos\")",
";",
"",
"}"
] | [
53,
4
] | [
58,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CarController. | null | /*Melhor forma a se fazer projeções já que já é orientada a objeto | /*Melhor forma a se fazer projeções já que já é orientada a objeto | @GetMapping("complex-result-constructor")
public ResponseEntity<List<CarInfo>> complexResultConstructor() {
return ResponseEntity.status(HttpStatus.OK).body(carService.complexResultConstructor());
} | [
"@",
"GetMapping",
"(",
"\"complex-result-constructor\"",
")",
"public",
"ResponseEntity",
"<",
"List",
"<",
"CarInfo",
">",
">",
"complexResultConstructor",
"(",
")",
"{",
"return",
"ResponseEntity",
".",
"status",
"(",
"HttpStatus",
".",
"OK",
")",
".",
"body",
"(",
"carService",
".",
"complexResultConstructor",
"(",
")",
")",
";",
"}"
] | [
106,
4
] | [
109,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
PedidoController. | null | Salva um pedido | Salva um pedido | @RequestMapping(value="/pedido", method=RequestMethod.POST)
@ApiOperation(value="Salva um pedido")
@ResponseStatus(HttpStatus.CREATED)
public ResponseEntity<?> salvaPedido(@RequestBody Pedido pedido) {
Pedido obj = pedidoService.salvaPedido(pedido);
return ResponseEntity.ok().body(obj);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/pedido\"",
",",
"method",
"=",
"RequestMethod",
".",
"POST",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Salva um pedido\"",
")",
"@",
"ResponseStatus",
"(",
"HttpStatus",
".",
"CREATED",
")",
"public",
"ResponseEntity",
"<",
"?",
">",
"salvaPedido",
"(",
"@",
"RequestBody",
"Pedido",
"pedido",
")",
"{",
"Pedido",
"obj",
"=",
"pedidoService",
".",
"salvaPedido",
"(",
"pedido",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"obj",
")",
";",
"}"
] | [
34,
1
] | [
40,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ListaDinamica. | null | Conveter conteudo da classe para String | Conveter conteudo da classe para String | public String toString() {
String listaCompleta = "";
if(vazia()) {
listaCompleta = listaCompleta + null;
} else {
Celula listaCelula = inicio;
while(listaCelula != null) {
listaCompleta = listaCompleta + "\n" + listaCelula.item;
listaCelula = listaCelula.link;
}
listaCompleta = listaCompleta + "";
}
return (listaCompleta);
} | [
"public",
"String",
"toString",
"(",
")",
"{",
"String",
"listaCompleta",
"=",
"\"\"",
";",
"if",
"(",
"vazia",
"(",
")",
")",
"{",
"listaCompleta",
"=",
"listaCompleta",
"+",
"null",
";",
"}",
"else",
"{",
"Celula",
"listaCelula",
"=",
"inicio",
";",
"while",
"(",
"listaCelula",
"!=",
"null",
")",
"{",
"listaCompleta",
"=",
"listaCompleta",
"+",
"\"\\n\"",
"+",
"listaCelula",
".",
"item",
";",
"listaCelula",
"=",
"listaCelula",
".",
"link",
";",
"}",
"listaCompleta",
"=",
"listaCompleta",
"+",
"\"\"",
";",
"}",
"return",
"(",
"listaCompleta",
")",
";",
"}"
] | [
155,
1
] | [
168,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Jogador. | null | <MÉTODOS DE VALIDAÇÃO> | <MÉTODOS DE VALIDAÇÃO> | private boolean validaId(Long id){
return id!=null && !id.toString().isEmpty();
} | [
"private",
"boolean",
"validaId",
"(",
"Long",
"id",
")",
"{",
"return",
"id",
"!=",
"null",
"&&",
"!",
"id",
".",
"toString",
"(",
")",
".",
"isEmpty",
"(",
")",
";",
"}"
] | [
91,
4
] | [
93,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cliente. | null | /* Devolve o atributo de coleção contendo os perfis com as permissões de acesso do cliente | /* Devolve o atributo de coleção contendo os perfis com as permissões de acesso do cliente | @Override
public Collection<? extends GrantedAuthority> getAuthorities() {
return this.perfis;
} | [
"@",
"Override",
"public",
"Collection",
"<",
"?",
"extends",
"GrantedAuthority",
">",
"getAuthorities",
"(",
")",
"{",
"return",
"this",
".",
"perfis",
";",
"}"
] | [
83,
4
] | [
86,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cachorro. | null | Todas instâncias | Todas instâncias | public static String late() {
return "Au!Au!";
} | [
"public",
"static",
"String",
"late",
"(",
")",
"{",
"return",
"\"Au!Au!\"",
";",
"}"
] | [
7,
4
] | [
9,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | False | true | method_declaration |
|
TelaUsuario. | null | método para consultar usuários | método para consultar usuários | private void consultar() {
String sql = "select * from tbusuario where iduser=?";
try {
pst = conexao.prepareStatement(sql);
pst.setString(1, txtUsuId.getText());
rs = pst.executeQuery();
if (rs.next()) {
txtUsuNome.setText(rs.getString(2));
txtUsuFone.setText(rs.getString(3));
txtUsuLogin.setText(rs.getString(4));
txtUsuSenha.setText(rs.getString(5));
//a linha abaixo se refere ao combobox
cboUsuPerfil.setSelectedItem(rs.getString(6));
} else {
JOptionPane.showMessageDialog(null, "Usuário não cadastrado");
//as linhas abaixo "limpam" os campos
txtUsuNome.setText(null);
txtUsuFone.setText(null);
txtUsuLogin.setText(null);
txtUsuSenha.setText(null);
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
} | [
"private",
"void",
"consultar",
"(",
")",
"{",
"String",
"sql",
"=",
"\"select * from tbusuario where iduser=?\"",
";",
"try",
"{",
"pst",
"=",
"conexao",
".",
"prepareStatement",
"(",
"sql",
")",
";",
"pst",
".",
"setString",
"(",
"1",
",",
"txtUsuId",
".",
"getText",
"(",
")",
")",
";",
"rs",
"=",
"pst",
".",
"executeQuery",
"(",
")",
";",
"if",
"(",
"rs",
".",
"next",
"(",
")",
")",
"{",
"txtUsuNome",
".",
"setText",
"(",
"rs",
".",
"getString",
"(",
"2",
")",
")",
";",
"txtUsuFone",
".",
"setText",
"(",
"rs",
".",
"getString",
"(",
"3",
")",
")",
";",
"txtUsuLogin",
".",
"setText",
"(",
"rs",
".",
"getString",
"(",
"4",
")",
")",
";",
"txtUsuSenha",
".",
"setText",
"(",
"rs",
".",
"getString",
"(",
"5",
")",
")",
";",
"//a linha abaixo se refere ao combobox",
"cboUsuPerfil",
".",
"setSelectedItem",
"(",
"rs",
".",
"getString",
"(",
"6",
")",
")",
";",
"}",
"else",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"Usuário não cadastrado\");",
"",
"",
"//as linhas abaixo \"limpam\" os campos",
"txtUsuNome",
".",
"setText",
"(",
"null",
")",
";",
"txtUsuFone",
".",
"setText",
"(",
"null",
")",
";",
"txtUsuLogin",
".",
"setText",
"(",
"null",
")",
";",
"txtUsuSenha",
".",
"setText",
"(",
"null",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"e",
")",
";",
"}",
"}"
] | [
33,
4
] | [
58,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ResourceExceptionHandler. | null | /* Lista de erros dos atributos | /* Lista de erros dos atributos | private List<AtributoErroMensagem> getErros(MethodArgumentNotValidException ex) {
return ex.getBindingResult().getFieldErrors().stream()
.map(error -> new AtributoErroMensagem(error.getField(), error.getRejectedValue(), error.getDefaultMessage()))
.collect(Collectors.toList());
} | [
"private",
"List",
"<",
"AtributoErroMensagem",
">",
"getErros",
"(",
"MethodArgumentNotValidException",
"ex",
")",
"{",
"return",
"ex",
".",
"getBindingResult",
"(",
")",
".",
"getFieldErrors",
"(",
")",
".",
"stream",
"(",
")",
".",
"map",
"(",
"error",
"->",
"new",
"AtributoErroMensagem",
"(",
"error",
".",
"getField",
"(",
")",
",",
"error",
".",
"getRejectedValue",
"(",
")",
",",
"error",
".",
"getDefaultMessage",
"(",
")",
")",
")",
".",
"collect",
"(",
"Collectors",
".",
"toList",
"(",
")",
")",
";",
"}"
] | [
38,
1
] | [
42,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Auxiliar. | null | Salva as tarefas no arquivo JSON. | Salva as tarefas no arquivo JSON. | public static boolean tarefasToJSON(ArrayList<Tarefa> tarefas) throws Exception {
String config_file = getCfgPath();
createCfgIfNotExists(config_file);
// Codifica a lista de tarefas para JSON.
JSONObject json = new JSONObject();
JSONArray json_array = new JSONArray();
for(Tarefa t : tarefas) {
JSONObject tarefa_obj = new JSONObject();
tarefa_obj.put("subject", t.Materia);
tarefa_obj.put("description", t.Descricao);
tarefa_obj.put("deadline", t.prazoString());
json_array.put(tarefa_obj);
}
json.put("tarefas", json_array);
try {
// Esse try só vai jogar uma exceção se o salvamento
// fracassar.
File f = new File(config_file);
// Salva como UTF_8 porque Unicode é incrível
OutputStreamWriter fw = new OutputStreamWriter(
new FileOutputStream(f),
StandardCharsets.UTF_8
);
fw.write(json.toString());
fw.flush();
fw.close();
// Deu certo!
return true;
}
catch(Exception e) {
JOptionPane.showMessageDialog(
null,
"Houve um erro ao salvar as tarefas!\n" + e.toString(),
"Oops!", 0, UIManager.getIcon("OptionPane.errorIcon")
);
// Deu errado!
return false;
}
} | [
"public",
"static",
"boolean",
"tarefasToJSON",
"(",
"ArrayList",
"<",
"Tarefa",
">",
"tarefas",
")",
"throws",
"Exception",
"{",
"String",
"config_file",
"=",
"getCfgPath",
"(",
")",
";",
"createCfgIfNotExists",
"(",
"config_file",
")",
";",
"// Codifica a lista de tarefas para JSON.\r",
"JSONObject",
"json",
"=",
"new",
"JSONObject",
"(",
")",
";",
"JSONArray",
"json_array",
"=",
"new",
"JSONArray",
"(",
")",
";",
"for",
"(",
"Tarefa",
"t",
":",
"tarefas",
")",
"{",
"JSONObject",
"tarefa_obj",
"=",
"new",
"JSONObject",
"(",
")",
";",
"tarefa_obj",
".",
"put",
"(",
"\"subject\"",
",",
"t",
".",
"Materia",
")",
";",
"tarefa_obj",
".",
"put",
"(",
"\"description\"",
",",
"t",
".",
"Descricao",
")",
";",
"tarefa_obj",
".",
"put",
"(",
"\"deadline\"",
",",
"t",
".",
"prazoString",
"(",
")",
")",
";",
"json_array",
".",
"put",
"(",
"tarefa_obj",
")",
";",
"}",
"json",
".",
"put",
"(",
"\"tarefas\"",
",",
"json_array",
")",
";",
"try",
"{",
"// Esse try só vai jogar uma exceção se o salvamento\r",
"// fracassar.\r",
"File",
"f",
"=",
"new",
"File",
"(",
"config_file",
")",
";",
"// Salva como UTF_8 porque Unicode é incrível\r",
"OutputStreamWriter",
"fw",
"=",
"new",
"OutputStreamWriter",
"(",
"new",
"FileOutputStream",
"(",
"f",
")",
",",
"StandardCharsets",
".",
"UTF_8",
")",
";",
"fw",
".",
"write",
"(",
"json",
".",
"toString",
"(",
")",
")",
";",
"fw",
".",
"flush",
"(",
")",
";",
"fw",
".",
"close",
"(",
")",
";",
"// Deu certo!\r",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"Houve um erro ao salvar as tarefas!\\n\"",
"+",
"e",
".",
"toString",
"(",
")",
",",
"\"Oops!\"",
",",
"0",
",",
"UIManager",
".",
"getIcon",
"(",
"\"OptionPane.errorIcon\"",
")",
")",
";",
"// Deu errado!\r",
"return",
"false",
";",
"}",
"}"
] | [
77,
4
] | [
121,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
RabbitConfiguration. | null | Criação do conversor de mensagem | Criação do conversor de mensagem | @Bean
public Jackson2JsonMessageConverter jackJsonMessageConverter() {
final ObjectMapper mapper = Jackson2ObjectMapperBuilder
.json()
.modules(new JavaTimeModule())
.dateFormat(new StdDateFormat())
.build();
return new Jackson2JsonMessageConverter(mapper);
} | [
"@",
"Bean",
"public",
"Jackson2JsonMessageConverter",
"jackJsonMessageConverter",
"(",
")",
"{",
"final",
"ObjectMapper",
"mapper",
"=",
"Jackson2ObjectMapperBuilder",
".",
"json",
"(",
")",
".",
"modules",
"(",
"new",
"JavaTimeModule",
"(",
")",
")",
".",
"dateFormat",
"(",
"new",
"StdDateFormat",
"(",
")",
")",
".",
"build",
"(",
")",
";",
"return",
"new",
"Jackson2JsonMessageConverter",
"(",
"mapper",
")",
";",
"}"
] | [
45,
1
] | [
55,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
D_Video. | null | /*FUNÇÕES EM COMUM | /*FUNÇÕES EM COMUM | public void ligaDispositivo(){
this.ligado = true;
return;
} | [
"public",
"void",
"ligaDispositivo",
"(",
")",
"{",
"this",
".",
"ligado",
"=",
"true",
";",
"return",
";",
"}"
] | [
34,
4
] | [
37,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Jogo. | null | ======= Impressão ======= | ======= Impressão ======= | @Override
public String toString() {
return "[" + getData() + "]" + "-" + getLocal() + ": " + getMandante().getSigla() + " x "
+ getVisitante().getSigla();
} | [
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"return",
"\"[\"",
"+",
"getData",
"(",
")",
"+",
"\"]\"",
"+",
"\"-\"",
"+",
"getLocal",
"(",
")",
"+",
"\": \"",
"+",
"getMandante",
"(",
")",
".",
"getSigla",
"(",
")",
"+",
"\" x \"",
"+",
"getVisitante",
"(",
")",
".",
"getSigla",
"(",
")",
";",
"}"
] | [
72,
4
] | [
76,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Crud. | null | /* Método de leitura de uma entidade usando chave Secundaria
@return entidade caso a encontre
Caso a chave não seja encontrada uma exceção será gerada
| /* Método de leitura de uma entidade usando chave Secundaria
| public T read(String chaveSecundaria) throws Exception {
T entidade = null;
// Procurar uma entidade a partir de sua chave secundaria
int posPesquisa = this.arquivoIndiceIndireto.read(chaveSecundaria);
if(posPesquisa != -1) entidade = this.read(posPesquisa);
return entidade;
} | [
"public",
"T",
"read",
"(",
"String",
"chaveSecundaria",
")",
"throws",
"Exception",
"{",
"T",
"entidade",
"=",
"null",
";",
"// Procurar uma entidade a partir de sua chave secundaria",
"int",
"posPesquisa",
"=",
"this",
".",
"arquivoIndiceIndireto",
".",
"read",
"(",
"chaveSecundaria",
")",
";",
"if",
"(",
"posPesquisa",
"!=",
"-",
"1",
")",
"entidade",
"=",
"this",
".",
"read",
"(",
"posPesquisa",
")",
";",
"return",
"entidade",
";",
"}"
] | [
76,
4
] | [
84,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Crud. | null | Apagar um elemento do arquivo | Apagar um elemento do arquivo | public boolean delete(int id) {
// Criando uma entidade para receber o byteArray
boolean encontrar = false;
long pos = -1;
try {
// Pegar o ponteiro do arquivo no indice
pos = this.arquivoIndiceDireto.read(id);
} catch (Exception e) { e.printStackTrace(); }
// Removendo apenas itens que não existem na memória
if (pos != -1) {
try {
Entidade elemento = new Entidade(pos); // Criando uma cópia do objeto na memória
this.arquivo.seek(pos); // Deslocar para o elemento no arquivo
this.garbagecolector.create(elemento.length(),pos); // Remover o elemento do disco
// Removendo dos outros bancos de dados
this.arquivoIndiceDireto.delete(id);
this.arquivoIndiceIndireto.delete(elemento.objeto.chaveSecundaria());
// Objeto encontrado e removido!
encontrar = true;
} catch(Exception e) { e.printStackTrace(); }
}
return encontrar;
} | [
"public",
"boolean",
"delete",
"(",
"int",
"id",
")",
"{",
"// Criando uma entidade para receber o byteArray",
"boolean",
"encontrar",
"=",
"false",
";",
"long",
"pos",
"=",
"-",
"1",
";",
"try",
"{",
"// Pegar o ponteiro do arquivo no indice",
"pos",
"=",
"this",
".",
"arquivoIndiceDireto",
".",
"read",
"(",
"id",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"// Removendo apenas itens que não existem na memória",
"if",
"(",
"pos",
"!=",
"-",
"1",
")",
"{",
"try",
"{",
"Entidade",
"elemento",
"=",
"new",
"Entidade",
"(",
"pos",
")",
";",
"// Criando uma cópia do objeto na memória",
"this",
".",
"arquivo",
".",
"seek",
"(",
"pos",
")",
";",
"// Deslocar para o elemento no arquivo",
"this",
".",
"garbagecolector",
".",
"create",
"(",
"elemento",
".",
"length",
"(",
")",
",",
"pos",
")",
";",
"// Remover o elemento do disco",
"// Removendo dos outros bancos de dados",
"this",
".",
"arquivoIndiceDireto",
".",
"delete",
"(",
"id",
")",
";",
"this",
".",
"arquivoIndiceIndireto",
".",
"delete",
"(",
"elemento",
".",
"objeto",
".",
"chaveSecundaria",
"(",
")",
")",
";",
"// Objeto encontrado e removido!",
"encontrar",
"=",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}",
"return",
"encontrar",
";",
"}"
] | [
153,
4
] | [
183,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Ordenacao. | null | Gerar uma sequencia de dados aleatorios | Gerar uma sequencia de dados aleatorios | public int [] geradorAleatorio (int qtde, int intervalo){
Random gerador = new Random();
int [] numeros = gerador.ints(0, intervalo).limit(qtde).toArray();
return (numeros);
} | [
"public",
"int",
"[",
"]",
"geradorAleatorio",
"(",
"int",
"qtde",
",",
"int",
"intervalo",
")",
"{",
"Random",
"gerador",
"=",
"new",
"Random",
"(",
")",
";",
"int",
"[",
"]",
"numeros",
"=",
"gerador",
".",
"ints",
"(",
"0",
",",
"intervalo",
")",
".",
"limit",
"(",
"qtde",
")",
".",
"toArray",
"(",
")",
";",
"return",
"(",
"numeros",
")",
";",
"}"
] | [
7,
4
] | [
11,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ControlCategoria. | null | recuperar pelo codigo da categoria | recuperar pelo codigo da categoria | public ModelCategoria controlGetRecuperarCodigoCat(int catCodigo){
return this.daoCategoria.daoGetRecuperarCategoriaCodigo(catCodigo);
} | [
"public",
"ModelCategoria",
"controlGetRecuperarCodigoCat",
"(",
"int",
"catCodigo",
")",
"{",
"return",
"this",
".",
"daoCategoria",
".",
"daoGetRecuperarCategoriaCodigo",
"(",
"catCodigo",
")",
";",
"}"
] | [
37,
4
] | [
39,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Utils. | null | Função que retorna verdadeiro se String for double | Função que retorna verdadeiro se String for double | public static boolean eDouble(String numero){
try{
Double.parseDouble(numero);
return true;
}
catch(Exception e){
return false;
}
} | [
"public",
"static",
"boolean",
"eDouble",
"(",
"String",
"numero",
")",
"{",
"try",
"{",
"Double",
".",
"parseDouble",
"(",
"numero",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | [
32,
4
] | [
40,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Cachorro. | null | sobreposição do metodo da classe Lobo | sobreposição do metodo da classe Lobo | @Override
public void emitirSon() {
System.out.println("Au Au Au Au");
} | [
"@",
"Override",
"public",
"void",
"emitirSon",
"(",
")",
"{",
"System",
".",
"out",
".",
"println",
"(",
"\"Au Au Au Au\"",
")",
";",
"}"
] | [
13,
4
] | [
16,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FXMLProcessosManutencoesDialogController. | null | Função chamada quando o comboBox cliente é selecionado | Função chamada quando o comboBox cliente é selecionado | public void selecionarComboBoxCliente(Cliente cliente){
if (cliente != null){
// Obtem os clientes
veiculos = veiculoDao.listarPorDono(cliente);
// Recarrega o comboBox
carregarComboBoxVeiculos();
}
} | [
"public",
"void",
"selecionarComboBoxCliente",
"(",
"Cliente",
"cliente",
")",
"{",
"if",
"(",
"cliente",
"!=",
"null",
")",
"{",
"// Obtem os clientes",
"veiculos",
"=",
"veiculoDao",
".",
"listarPorDono",
"(",
"cliente",
")",
";",
"// Recarrega o comboBox",
"carregarComboBoxVeiculos",
"(",
")",
";",
"}",
"}"
] | [
99,
4
] | [
107,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TurmaService. | null | Lista todos os objetos Turma | Lista todos os objetos Turma | public List<Turma> findyAll(){
return dao.findAll();
} | [
"public",
"List",
"<",
"Turma",
">",
"findyAll",
"(",
")",
"{",
"return",
"dao",
".",
"findAll",
"(",
")",
";",
"}"
] | [
17,
4
] | [
19,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
FuncoesTopicos. | null | Retorna os imoveis que possuem a quantidade de quartos maior ou igual a passada | Retorna os imoveis que possuem a quantidade de quartos maior ou igual a passada | public static List<Imovel> q4FiltraPorQuartos(int numeroDeQuartos) {
List<Imovel> resultado = new ArrayList<>();
//Utiliza o iterador imovel para percorrer a lista
for (Imovel imovel : imoveis) {
//Verifica se o imovel atual possui a quantidade de quartos maior ou igual
if (imovel.getQuartos() >= numeroDeQuartos) {
resultado.add(imovel);
}
}
return resultado;
} | [
"public",
"static",
"List",
"<",
"Imovel",
">",
"q4FiltraPorQuartos",
"(",
"int",
"numeroDeQuartos",
")",
"{",
"List",
"<",
"Imovel",
">",
"resultado",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"//Utiliza o iterador imovel para percorrer a lista",
"for",
"(",
"Imovel",
"imovel",
":",
"imoveis",
")",
"{",
"//Verifica se o imovel atual possui a quantidade de quartos maior ou igual",
"if",
"(",
"imovel",
".",
"getQuartos",
"(",
")",
">=",
"numeroDeQuartos",
")",
"{",
"resultado",
".",
"add",
"(",
"imovel",
")",
";",
"}",
"}",
"return",
"resultado",
";",
"}"
] | [
75,
4
] | [
85,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
GerenteMySQL. | null | Cria uma categoria de acordo com o ResultSet passado | Cria uma categoria de acordo com o ResultSet passado | private Categoria getCategoria(ResultSet rs) throws SQLException {
Categoria retorno = new Categoria();
retorno.setCodigo(rs.getInt(1));
retorno.setNome(rs.getString(2));
return retorno;
} | [
"private",
"Categoria",
"getCategoria",
"(",
"ResultSet",
"rs",
")",
"throws",
"SQLException",
"{",
"Categoria",
"retorno",
"=",
"new",
"Categoria",
"(",
")",
";",
"retorno",
".",
"setCodigo",
"(",
"rs",
".",
"getInt",
"(",
"1",
")",
")",
";",
"retorno",
".",
"setNome",
"(",
"rs",
".",
"getString",
"(",
"2",
")",
")",
";",
"return",
"retorno",
";",
"}"
] | [
99,
4
] | [
104,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ApiExceptionHandler. | null | trata parâmetros de URI inválido | trata parâmetros de URI inválido | @Override
protected ResponseEntity<Object> handleBindException(BindException ex, HttpHeaders headers, HttpStatus status,
WebRequest request) {
return handleValidationInternal(ex, ex.getBindingResult(), headers, status, request);
} | [
"@",
"Override",
"protected",
"ResponseEntity",
"<",
"Object",
">",
"handleBindException",
"(",
"BindException",
"ex",
",",
"HttpHeaders",
"headers",
",",
"HttpStatus",
"status",
",",
"WebRequest",
"request",
")",
"{",
"return",
"handleValidationInternal",
"(",
"ex",
",",
"ex",
".",
"getBindingResult",
"(",
")",
",",
"headers",
",",
"status",
",",
"request",
")",
";",
"}"
] | [
342,
1
] | [
346,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Utils. | null | Função que retorna verdadeiro se String for inteiro | Função que retorna verdadeiro se String for inteiro | public static boolean eInteiro(String numero){
try{
Integer.parseInt(numero);
return true;
}
catch(Exception e){
return false;
}
} | [
"public",
"static",
"boolean",
"eInteiro",
"(",
"String",
"numero",
")",
"{",
"try",
"{",
"Integer",
".",
"parseInt",
"(",
"numero",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | [
21,
4
] | [
29,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
BlocoVermelhoPrisma. | null | Retorna verdadeiro quando a posição do bloco é alterada pelo heroi | Retorna verdadeiro quando a posição do bloco é alterada pelo heroi | public boolean contactHero(Animado hHeroi, ArrayList<Elemento> e) {
Posicao p = hHeroi.getPosicao();
if(p.getColunaAnterior() != p.getColuna()) {
boolean a = (p.getColunaAnterior() < p.getColuna()) ? super.moveRight() : super.moveLeft();
return a;
}
if(p.getLinhaAnterior() != p.getLinha()) {
boolean a = (p.getLinhaAnterior() < p.getLinha()) ? super.moveDown() : super.moveUp();
return a;
}
return false;
} | [
"public",
"boolean",
"contactHero",
"(",
"Animado",
"hHeroi",
",",
"ArrayList",
"<",
"Elemento",
">",
"e",
")",
"{",
"Posicao",
"p",
"=",
"hHeroi",
".",
"getPosicao",
"(",
")",
";",
"if",
"(",
"p",
".",
"getColunaAnterior",
"(",
")",
"!=",
"p",
".",
"getColuna",
"(",
")",
")",
"{",
"boolean",
"a",
"=",
"(",
"p",
".",
"getColunaAnterior",
"(",
")",
"<",
"p",
".",
"getColuna",
"(",
")",
")",
"?",
"super",
".",
"moveRight",
"(",
")",
":",
"super",
".",
"moveLeft",
"(",
")",
";",
"return",
"a",
";",
"}",
"if",
"(",
"p",
".",
"getLinhaAnterior",
"(",
")",
"!=",
"p",
".",
"getLinha",
"(",
")",
")",
"{",
"boolean",
"a",
"=",
"(",
"p",
".",
"getLinhaAnterior",
"(",
")",
"<",
"p",
".",
"getLinha",
"(",
")",
")",
"?",
"super",
".",
"moveDown",
"(",
")",
":",
"super",
".",
"moveUp",
"(",
")",
";",
"return",
"a",
";",
"}",
"return",
"false",
";",
"}"
] | [
19,
1
] | [
30,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Casa. | null | Obtem o mapa completo de electrodomesticos e divisoes | Obtem o mapa completo de electrodomesticos e divisoes | public Map<String, ArrayList<Eletrodomestico>> getMapaEletro() {
return mapaEletro;
} | [
"public",
"Map",
"<",
"String",
",",
"ArrayList",
"<",
"Eletrodomestico",
">",
">",
"getMapaEletro",
"(",
")",
"{",
"return",
"mapaEletro",
";",
"}"
] | [
31,
4
] | [
33,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
TurmaFormController. | null | SET para injetar dos services: O Turma SERVICE e o Professor Service | SET para injetar dos services: O Turma SERVICE e o Professor Service | public void setServices(TurmaService service, ProfessorService professorService) {
this.service = service;
this.professorService = professorService;
} | [
"public",
"void",
"setServices",
"(",
"TurmaService",
"service",
",",
"ProfessorService",
"professorService",
")",
"{",
"this",
".",
"service",
"=",
"service",
";",
"this",
".",
"professorService",
"=",
"professorService",
";",
"}"
] | [
83,
4
] | [
86,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Multiplicacao. | null | Método com 3 parâmetros | Método com 3 parâmetros | static double Multiplica(int a, int b, int c)
{
return a * b * c;
} | [
"static",
"double",
"Multiplica",
"(",
"int",
"a",
",",
"int",
"b",
",",
"int",
"c",
")",
"{",
"return",
"a",
"*",
"b",
"*",
"c",
";",
"}"
] | [
21,
1
] | [
24,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ResourceExceptionHandler. | null | /* Passando o erro da requisição | /* Passando o erro da requisição | private RequisicaoErroResposta getErroResposta(HttpStatus status, List<AtributoErroMensagem> errors) {
return new RequisicaoErroResposta("A requisição possui campos inválidos", status.value(),
status.getReasonPhrase(), errors);
} | [
"private",
"RequisicaoErroResposta",
"getErroResposta",
"(",
"HttpStatus",
"status",
",",
"List",
"<",
"AtributoErroMensagem",
">",
"errors",
")",
"{",
"return",
"new",
"RequisicaoErroResposta",
"(",
"\"A requisição possui campos inválidos\", s",
"t",
"tus.va",
"l",
"ue(),",
"",
"",
"",
"status",
".",
"getReasonPhrase",
"(",
")",
",",
"errors",
")",
";",
"}"
] | [
31,
4
] | [
34,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
NFInfoCancelamento. | null | campo destinado ao cancelamento por substituicao | campo destinado ao cancelamento por substituicao | public DFUnidadeFederativa getUfAutorizador() {
return ufAutorizador;
} | [
"public",
"DFUnidadeFederativa",
"getUfAutorizador",
"(",
")",
"{",
"return",
"ufAutorizador",
";",
"}"
] | [
28,
4
] | [
30,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula03. | null | Verifica o maior dos 3 numeros introduzidos pelo utilizador | Verifica o maior dos 3 numeros introduzidos pelo utilizador | static int maiorNum() {
// cria objecto Scanner
Scanner keyboard = new Scanner(System.in);
System.out.println("Introduz o 1º num:");
// aguarda 1º Numero no scanner
int num1 = keyboard.nextInt();
// guarda o 1º numero como maximo
int max = num1;
System.out.println("Introduz o 2º num:");
// aguarda 2º Numero no scanner
int num2 = keyboard.nextInt();
if (num2 > max) {
max = num2;
}
System.out.println("Introduz o 3º num:");
// aguarda 3º Numero no scanner
int num3 = keyboard.nextInt();
if (num3 > max) {
max = num3;
}
return max;
} | [
"static",
"int",
"maiorNum",
"(",
")",
"{",
"// cria objecto Scanner",
"Scanner",
"keyboard",
"=",
"new",
"Scanner",
"(",
"System",
".",
"in",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduz o 1º num:\")",
";",
"",
"// aguarda 1º Numero no scanner",
"int",
"num1",
"=",
"keyboard",
".",
"nextInt",
"(",
")",
";",
"// guarda o 1º numero como maximo",
"int",
"max",
"=",
"num1",
";",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduz o 2º num:\")",
";",
"",
"// aguarda 2º Numero no scanner",
"int",
"num2",
"=",
"keyboard",
".",
"nextInt",
"(",
")",
";",
"if",
"(",
"num2",
">",
"max",
")",
"{",
"max",
"=",
"num2",
";",
"}",
"System",
".",
"out",
".",
"println",
"(",
"\"Introduz o 3º num:\")",
";",
"",
"// aguarda 3º Numero no scanner",
"int",
"num3",
"=",
"keyboard",
".",
"nextInt",
"(",
")",
";",
"if",
"(",
"num3",
">",
"max",
")",
"{",
"max",
"=",
"num3",
";",
"}",
"return",
"max",
";",
"}"
] | [
74,
4
] | [
95,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Time. | null | ======== Metodo para impressão utilizando ToString ======== | ======== Metodo para impressão utilizando ToString ======== | @Override
public String toString() {
String print = "\n++++++ Clube: " + this.nome + " ++++++\n" + "\nSigla: " + this.sigla + "\nBrasão: "
+ this.descricaoEscudo + "\nFundado em: " + this.anoDeFundacao + "\nRenda Média: " + this.rendaMedia
+ "\n" + "\n ======= Técnico ======= " + "\n";
for (Tecnico tecnico : tecnicos) {
print += tecnico + "\n";
}
print += " ======= Jogadores ======= \n";
for (Jogador jogador : jogadores) {
print += jogador + "\n";
}
print += "\n ####### Jogos em Casa ####### \n";
for (Jogo mandante : mandantes) {
print += mandante + "\n";
}
print += "\n ####### Jogos Fora ####### " + "\n";
for (Jogo visitante : visitantes) {
print += visitante + "\n";
}
return print;
} | [
"@",
"Override",
"public",
"String",
"toString",
"(",
")",
"{",
"String",
"print",
"=",
"\"\\n++++++ Clube: \"",
"+",
"this",
".",
"nome",
"+",
"\" ++++++\\n\"",
"+",
"\"\\nSigla: \"",
"+",
"this",
".",
"sigla",
"+",
"\"\\nBrasão: \"",
"+",
"this",
".",
"descricaoEscudo",
"+",
"\"\\nFundado em: \"",
"+",
"this",
".",
"anoDeFundacao",
"+",
"\"\\nRenda Média: \" ",
" ",
"his.",
"r",
"endaMedia",
"+",
"\"\\n\"",
"+",
"\"\\n ======= Técnico ======= \" ",
" ",
"\\n\";",
"",
"for",
"(",
"Tecnico",
"tecnico",
":",
"tecnicos",
")",
"{",
"print",
"+=",
"tecnico",
"+",
"\"\\n\"",
";",
"}",
"print",
"+=",
"\" ======= Jogadores ======= \\n\"",
";",
"for",
"(",
"Jogador",
"jogador",
":",
"jogadores",
")",
"{",
"print",
"+=",
"jogador",
"+",
"\"\\n\"",
";",
"}",
"print",
"+=",
"\"\\n ####### Jogos em Casa ####### \\n\"",
";",
"for",
"(",
"Jogo",
"mandante",
":",
"mandantes",
")",
"{",
"print",
"+=",
"mandante",
"+",
"\"\\n\"",
";",
"}",
"print",
"+=",
"\"\\n ####### Jogos Fora ####### \"",
"+",
"\"\\n\"",
";",
"for",
"(",
"Jogo",
"visitante",
":",
"visitantes",
")",
"{",
"print",
"+=",
"visitante",
"+",
"\"\\n\"",
";",
"}",
"return",
"print",
";",
"}"
] | [
131,
4
] | [
156,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
NetworkToolkit. | null | Responsavel por realizar a operação de GET | Responsavel por realizar a operação de GET | public static String doGet(String url) {
String retorno = "";
try {
URL apiEnd = new URL(url);
int codigoResposta;
HttpURLConnection conexao;
InputStream is;
conexao = (HttpURLConnection) apiEnd.openConnection();
conexao.setRequestMethod("GET");
conexao.setReadTimeout(15000);
conexao.setConnectTimeout(15000);
conexao.connect();
codigoResposta = conexao.getResponseCode();
if(codigoResposta < HttpURLConnection.HTTP_BAD_REQUEST){
is = conexao.getInputStream();
}else{
is = conexao.getErrorStream();
}
retorno = converterInputStreamToString(is);
is.close();
conexao.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return retorno;
} | [
"public",
"static",
"String",
"doGet",
"(",
"String",
"url",
")",
"{",
"String",
"retorno",
"=",
"\"\"",
";",
"try",
"{",
"URL",
"apiEnd",
"=",
"new",
"URL",
"(",
"url",
")",
";",
"int",
"codigoResposta",
";",
"HttpURLConnection",
"conexao",
";",
"InputStream",
"is",
";",
"conexao",
"=",
"(",
"HttpURLConnection",
")",
"apiEnd",
".",
"openConnection",
"(",
")",
";",
"conexao",
".",
"setRequestMethod",
"(",
"\"GET\"",
")",
";",
"conexao",
".",
"setReadTimeout",
"(",
"15000",
")",
";",
"conexao",
".",
"setConnectTimeout",
"(",
"15000",
")",
";",
"conexao",
".",
"connect",
"(",
")",
";",
"codigoResposta",
"=",
"conexao",
".",
"getResponseCode",
"(",
")",
";",
"if",
"(",
"codigoResposta",
"<",
"HttpURLConnection",
".",
"HTTP_BAD_REQUEST",
")",
"{",
"is",
"=",
"conexao",
".",
"getInputStream",
"(",
")",
";",
"}",
"else",
"{",
"is",
"=",
"conexao",
".",
"getErrorStream",
"(",
")",
";",
"}",
"retorno",
"=",
"converterInputStreamToString",
"(",
"is",
")",
";",
"is",
".",
"close",
"(",
")",
";",
"conexao",
".",
"disconnect",
"(",
")",
";",
"}",
"catch",
"(",
"MalformedURLException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"e",
".",
"printStackTrace",
"(",
")",
";",
"}",
"return",
"retorno",
";",
"}"
] | [
16,
8
] | [
49,
9
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Login. | null | Botao Iniciar Sessão | Botao Iniciar Sessão | private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
String EnderecoEmailUser = jTextField1.getText();
try {
RegistoInterface regInt = (RegistoInterface) LocateRegistry.getRegistry(InetAddress.getByName("DESKTOP-BJABO8J").getHostAddress()).lookup(SERVICE_NAME);
if(jTextField1.getText().isEmpty()){
JOptionPane.showMessageDialog(jPanel1, "Preencha o espaço com o seu endereço de Email");
}
else {
if(regInt.VerifyEmail(EnderecoEmailUser)){
system.setOnGoingUser(regInt.getUser(EnderecoEmailUser));
PaginaInicial init = new PaginaInicial(system);
init.setVisible(true);
this.dispose();
}else{
JOptionPane.showMessageDialog(jPanel1, "Utilizador não reconhecido");
}
}
} catch (Exception Except) {
System.err.println("Error");
Except.printStackTrace();
}
} | [
"private",
"void",
"jButton1MouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"//GEN-FIRST:event_jButton1MouseClicked",
"String",
"EnderecoEmailUser",
"=",
"jTextField1",
".",
"getText",
"(",
")",
";",
"try",
"{",
"RegistoInterface",
"regInt",
"=",
"(",
"RegistoInterface",
")",
"LocateRegistry",
".",
"getRegistry",
"(",
"InetAddress",
".",
"getByName",
"(",
"\"DESKTOP-BJABO8J\"",
")",
".",
"getHostAddress",
"(",
")",
")",
".",
"lookup",
"(",
"SERVICE_NAME",
")",
";",
"if",
"(",
"jTextField1",
".",
"getText",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"jPanel1",
",",
"\"Preencha o espaço com o seu endereço de Email\");",
"",
"",
"}",
"else",
"{",
"if",
"(",
"regInt",
".",
"VerifyEmail",
"(",
"EnderecoEmailUser",
")",
")",
"{",
"system",
".",
"setOnGoingUser",
"(",
"regInt",
".",
"getUser",
"(",
"EnderecoEmailUser",
")",
")",
";",
"PaginaInicial",
"init",
"=",
"new",
"PaginaInicial",
"(",
"system",
")",
";",
"init",
".",
"setVisible",
"(",
"true",
")",
";",
"this",
".",
"dispose",
"(",
")",
";",
"}",
"else",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"jPanel1",
",",
"\"Utilizador não reconhecido\")",
";",
"",
"}",
"}",
"}",
"catch",
"(",
"Exception",
"Except",
")",
"{",
"System",
".",
"err",
".",
"println",
"(",
"\"Error\"",
")",
";",
"Except",
".",
"printStackTrace",
"(",
")",
";",
"}",
"}"
] | [
196,
4
] | [
219,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Parque. | null | Método que altera o temp o disp onívelde um lugar, para uma dada matricula; | Método que altera o temp o disp onívelde um lugar, para uma dada matricula; | public void alteraTempo(String m,int t)
{
if ( this.lugares.containsKey(m) )
this.lugares.get(m).setMinutos(t);
} | [
"public",
"void",
"alteraTempo",
"(",
"String",
"m",
",",
"int",
"t",
")",
"{",
"if",
"(",
"this",
".",
"lugares",
".",
"containsKey",
"(",
"m",
")",
")",
"this",
".",
"lugares",
".",
"get",
"(",
"m",
")",
".",
"setMinutos",
"(",
"t",
")",
";",
"}"
] | [
49,
2
] | [
53,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Splash. | null | desaparece novamente o navBar e statusBar.* | desaparece novamente o navBar e statusBar.* | @Override
public void onBackPressed() {
//tira a nevigation bar e status bar.
View decorView = getWindow().getDecorView();
int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN;
decorView.setSystemUiVisibility(uiOptions);
} | [
"@",
"Override",
"public",
"void",
"onBackPressed",
"(",
")",
"{",
"//tira a nevigation bar e status bar.",
"View",
"decorView",
"=",
"getWindow",
"(",
")",
".",
"getDecorView",
"(",
")",
";",
"int",
"uiOptions",
"=",
"View",
".",
"SYSTEM_UI_FLAG_HIDE_NAVIGATION",
"|",
"View",
".",
"SYSTEM_UI_FLAG_FULLSCREEN",
";",
"decorView",
".",
"setSystemUiVisibility",
"(",
"uiOptions",
")",
";",
"}"
] | [
46,
4
] | [
52,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
ConversaoCmParaPol. | null | metodo que faz a conversao de cm para pol | metodo que faz a conversao de cm para pol | public static double conversaoParaPol(double cm) {
double pol = 0;
pol = cm * 2.54;
return pol;
} | [
"public",
"static",
"double",
"conversaoParaPol",
"(",
"double",
"cm",
")",
"{",
"double",
"pol",
"=",
"0",
";",
"pol",
"=",
"cm",
"*",
"2.54",
";",
"return",
"pol",
";",
"}"
] | [
8,
4
] | [
12,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Seta. | null | Esse método é chamado quando heroi encosta na seta | Esse método é chamado quando heroi encosta na seta | @Override
public void contatoTransponivel(ArrayList<Elemento> ListElem){
ControleDeJogo cControle = new ControleDeJogo();
Hero hHeroi = (Hero) ListElem.get(0);
//Realiza uma seleção da orientação que deve mover o heroi
switch (super.orientacao) {
case CIMA:
hHeroi.moveUp();
if (!cControle.ehPosicaoValida(ListElem,hHeroi.getPosicao(),0))
hHeroi.voltaAUltimaPosicao();
break;
case BAIXO:
hHeroi.moveDown();
if (!cControle.ehPosicaoValida(ListElem,hHeroi.getPosicao(),0))
hHeroi.voltaAUltimaPosicao();
break;
case ESQUERDA:
hHeroi.moveLeft();
if (!cControle.ehPosicaoValida(ListElem,hHeroi.getPosicao(),0))
hHeroi.voltaAUltimaPosicao();
break;
case DIREITA:
hHeroi.moveRight();
if (!cControle.ehPosicaoValida(ListElem,hHeroi.getPosicao(),0))
hHeroi.voltaAUltimaPosicao();
break;
}
return;
} | [
"@",
"Override",
"public",
"void",
"contatoTransponivel",
"(",
"ArrayList",
"<",
"Elemento",
">",
"ListElem",
")",
"{",
"ControleDeJogo",
"cControle",
"=",
"new",
"ControleDeJogo",
"(",
")",
";",
"Hero",
"hHeroi",
"=",
"(",
"Hero",
")",
"ListElem",
".",
"get",
"(",
"0",
")",
";",
"//Realiza uma seleção da orientação que deve mover o heroi",
"switch",
"(",
"super",
".",
"orientacao",
")",
"{",
"case",
"CIMA",
":",
"hHeroi",
".",
"moveUp",
"(",
")",
";",
"if",
"(",
"!",
"cControle",
".",
"ehPosicaoValida",
"(",
"ListElem",
",",
"hHeroi",
".",
"getPosicao",
"(",
")",
",",
"0",
")",
")",
"hHeroi",
".",
"voltaAUltimaPosicao",
"(",
")",
";",
"break",
";",
"case",
"BAIXO",
":",
"hHeroi",
".",
"moveDown",
"(",
")",
";",
"if",
"(",
"!",
"cControle",
".",
"ehPosicaoValida",
"(",
"ListElem",
",",
"hHeroi",
".",
"getPosicao",
"(",
")",
",",
"0",
")",
")",
"hHeroi",
".",
"voltaAUltimaPosicao",
"(",
")",
";",
"break",
";",
"case",
"ESQUERDA",
":",
"hHeroi",
".",
"moveLeft",
"(",
")",
";",
"if",
"(",
"!",
"cControle",
".",
"ehPosicaoValida",
"(",
"ListElem",
",",
"hHeroi",
".",
"getPosicao",
"(",
")",
",",
"0",
")",
")",
"hHeroi",
".",
"voltaAUltimaPosicao",
"(",
")",
";",
"break",
";",
"case",
"DIREITA",
":",
"hHeroi",
".",
"moveRight",
"(",
")",
";",
"if",
"(",
"!",
"cControle",
".",
"ehPosicaoValida",
"(",
"ListElem",
",",
"hHeroi",
".",
"getPosicao",
"(",
")",
",",
"0",
")",
")",
"hHeroi",
".",
"voltaAUltimaPosicao",
"(",
")",
";",
"break",
";",
"}",
"return",
";",
"}"
] | [
17,
4
] | [
54,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula03ex. | null | 1.Criar uma função que dado o ano de nascimento devolve a idade. | 1.Criar uma função que dado o ano de nascimento devolve a idade. | public static int idade(int birthdate) {
// Função para calcular o ano actual em Java
int currentYear = LocalDate.now().getYear();
// Sem imports daria com currentYear = 2020;
return currentYear - birthdate;
} | [
"public",
"static",
"int",
"idade",
"(",
"int",
"birthdate",
")",
"{",
"// Função para calcular o ano actual em Java",
"int",
"currentYear",
"=",
"LocalDate",
".",
"now",
"(",
")",
".",
"getYear",
"(",
")",
";",
"// Sem imports daria com currentYear = 2020;",
"return",
"currentYear",
"-",
"birthdate",
";",
"}"
] | [
44,
4
] | [
49,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Imovel. | null | Define uma nova maneira de comparar se imóvel é maior que o outro por meio do valor | Define uma nova maneira de comparar se imóvel é maior que o outro por meio do valor | @Override
public int compareTo(Imovel o) {
if (this.getValor() < o.getValor()) {
return -1;
} else if (o.getValor() < this.getValor()) {
return 1;
} else {
return 0;
}
} | [
"@",
"Override",
"public",
"int",
"compareTo",
"(",
"Imovel",
"o",
")",
"{",
"if",
"(",
"this",
".",
"getValor",
"(",
")",
"<",
"o",
".",
"getValor",
"(",
")",
")",
"{",
"return",
"-",
"1",
";",
"}",
"else",
"if",
"(",
"o",
".",
"getValor",
"(",
")",
"<",
"this",
".",
"getValor",
"(",
")",
")",
"{",
"return",
"1",
";",
"}",
"else",
"{",
"return",
"0",
";",
"}",
"}"
] | [
132,
4
] | [
141,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
CadastroDominioController. | null | Este método é para salvar o domínio no BD. | Este método é para salvar o domínio no BD. | @PostMapping("/salvar")
public String salvar(@Valid Dominio dominio, BindingResult result, RedirectAttributes attr) {
if (result.hasErrors())
return "dominio/compraDominio";
dominioRepository.save(dominio);
attr.addFlashAttribute("msgSucesso", "Operação realizada com sucesso!");
return "redirect:/dominio/compraDominio";
} | [
"@",
"PostMapping",
"(",
"\"/salvar\"",
")",
"public",
"String",
"salvar",
"(",
"@",
"Valid",
"Dominio",
"dominio",
",",
"BindingResult",
"result",
",",
"RedirectAttributes",
"attr",
")",
"{",
"if",
"(",
"result",
".",
"hasErrors",
"(",
")",
")",
"return",
"\"dominio/compraDominio\"",
";",
"dominioRepository",
".",
"save",
"(",
"dominio",
")",
";",
"attr",
".",
"addFlashAttribute",
"(",
"\"msgSucesso\"",
",",
"\"Operação realizada com sucesso!\");",
"\r",
"",
"return",
"\"redirect:/dominio/compraDominio\"",
";",
"}"
] | [
34,
2
] | [
41,
3
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
aula02ex. | null | Exercicios de trabalho autonomo da aula02 | Exercicios de trabalho autonomo da aula02 | public static void main(String[] args) {
// 1.Obter a soma de dois números. - testes
System.out.println("Soma dos inteiros a e b");
System.out.println(soma(2, 3));
// 2.Obter o quadrado de um número. - testes
System.out.println("Quadrado de um numero a");
System.out.println(quadrado(2));
// 3.Obter a diferença entre dois números - testes
System.out.println("Diferença entre dois numeros inteiros");
System.out.println(diff(3, 4));
// 4.Obter a média entre dois números - testes
System.out.println("Media entre a e b");
System.out.println(average(6, 4));
// 5.Obter a área de um retângulo, dando os lados - testes
System.out.println("Área Rectangulo com lados de comprimento a e b");
System.out.println(areaRect(2, 4));
// 6.Dada uma temperatura em Celcius, obtera temperatura em Fahrenheit.
// Resolvido na aula02.java
// 7. Dada uma temperatura em Celsius, obter a temperatura em kelvin. - testes
System.out.println("Converte temperatura em Celsius (tempC) para Kelvin");
System.out.println(celsiusToKelvin(0));
// 8.Dado um comprimento em centímetros, obter o valor em polegadas. - testes
System.out.println("Converte a de cm para Inch");
System.out.println(cmToInch(2));
// 9.Dado um preço, obter o IVAa 23%correspondente ao mesmo. (Ex: 100€ -> 18.70€). - testes
// Assumo que o enunciado pede para obter os 23% do IVA de um preço
System.out.println("Calcula os 23% de IVA de a");
System.out.println(iva(100));
// 10.Dado um número com casas decimais (double), devolve o inteiro aproximado. (Ex: 4.3 -> 4, 5.7 -> 6). - testes
System.out.println("Arredonda um numero a");
System.out.println(arredondar(12.6));
// 11.Obter o perímetro de um círculo, dado o seu diâmetro. - testes
System.out.println("Perimetro de um circulo com raio r");
System.out.println(circleperimeter(3));
// 12.Obter a área de um prisma retangular, dando a sua largura, altura e comprimento - testes
System.out.println("Area do prisma com comprimento c, largura l e altura a");
System.out.println(areaPrisma(2, 3, 4));
} | [
"public",
"static",
"void",
"main",
"(",
"String",
"[",
"]",
"args",
")",
"{",
"// 1.Obter a soma de dois números. - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Soma dos inteiros a e b\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"soma",
"(",
"2",
",",
"3",
")",
")",
";",
"// 2.Obter o quadrado de um número. - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Quadrado de um numero a\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"quadrado",
"(",
"2",
")",
")",
";",
"// 3.Obter a diferença entre dois números - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Diferença entre dois numeros inteiros\")",
";",
"",
"System",
".",
"out",
".",
"println",
"(",
"diff",
"(",
"3",
",",
"4",
")",
")",
";",
"// 4.Obter a média entre dois números - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Media entre a e b\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"average",
"(",
"6",
",",
"4",
")",
")",
";",
"// 5.Obter a área de um retângulo, dando os lados - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Área Rectangulo com lados de comprimento a e b\")",
";",
"",
"System",
".",
"out",
".",
"println",
"(",
"areaRect",
"(",
"2",
",",
"4",
")",
")",
";",
"// 6.Dada uma temperatura em Celcius, obtera temperatura em Fahrenheit.",
"// Resolvido na aula02.java",
"// 7. Dada uma temperatura em Celsius, obter a temperatura em kelvin. - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Converte temperatura em Celsius (tempC) para Kelvin\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"celsiusToKelvin",
"(",
"0",
")",
")",
";",
"// 8.Dado um comprimento em centímetros, obter o valor em polegadas. - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Converte a de cm para Inch\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"cmToInch",
"(",
"2",
")",
")",
";",
"// 9.Dado um preço, obter o IVAa 23%correspondente ao mesmo. (Ex: 100€ -> 18.70€). - testes",
"// Assumo que o enunciado pede para obter os 23% do IVA de um preço",
"System",
".",
"out",
".",
"println",
"(",
"\"Calcula os 23% de IVA de a\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"iva",
"(",
"100",
")",
")",
";",
"// 10.Dado um número com casas decimais (double), devolve o inteiro aproximado. (Ex: 4.3 -> 4, 5.7 -> 6). - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Arredonda um numero a\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"arredondar",
"(",
"12.6",
")",
")",
";",
"// 11.Obter o perímetro de um círculo, dado o seu diâmetro. - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Perimetro de um circulo com raio r\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"circleperimeter",
"(",
"3",
")",
")",
";",
"// 12.Obter a área de um prisma retangular, dando a sua largura, altura e comprimento - testes",
"System",
".",
"out",
".",
"println",
"(",
"\"Area do prisma com comprimento c, largura l e altura a\"",
")",
";",
"System",
".",
"out",
".",
"println",
"(",
"areaPrisma",
"(",
"2",
",",
"3",
",",
"4",
")",
")",
";",
"}"
] | [
5,
4
] | [
42,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
InvestimentoController. | null | Evento disparado ao pressionar o botão simular | Evento disparado ao pressionar o botão simular | @FXML
private void simular() {
Alert alert = new Alert(Alert.AlertType.WARNING);
alert.setTitle("Atenção");
if (txtValorInicial.getText().isEmpty() || txtAporte.getText().isEmpty() || txtJuros.getText().isEmpty()
|| ((screen.equals("Simulador CDB") || screen.equals("Comparativo Poupança vs CDB"))
&& txt1.getText().isEmpty())
|| (screen.equals("Comparativo Poupança vs CDB") && txt2.getText().isEmpty())) {
alert.setHeaderText("Preencha todos os campos");
alert.showAndWait();
} else {
int periodo = (int) ChronoUnit.MONTHS.between(dataInicial.getValue(), dataFinal.getValue());
if (periodo <= 0) {
alert.setHeaderText("Escolha um intervalo maior que um mês");
alert.showAndWait();
} else {
// Limpa o grafico
lineChart.getData().clear();
// Verifica o nome da janela solicita e a abre
switch (screen) {
case "Simulador Poupança":
lineChart.setTitle("Poupança");
carregaGrafico(poupanca(), periodo);
break;
case "Simulador CDB":
lineChart.setTitle("Certificado de Depósito Bancário (CDB)");
carregaGrafico(cdb(), periodo);
break;
case "Comparativo Poupança vs CDB":
lineChart.setTitle("Comparativo Poupança vs CDB");
carregaGrafico(cdb(), poupanca(), periodo);
break;
}
}
}
} | [
"@",
"FXML",
"private",
"void",
"simular",
"(",
")",
"{",
"Alert",
"alert",
"=",
"new",
"Alert",
"(",
"Alert",
".",
"AlertType",
".",
"WARNING",
")",
";",
"alert",
".",
"setTitle",
"(",
"\"Atenção\");",
"",
"",
"if",
"(",
"txtValorInicial",
".",
"getText",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"txtAporte",
".",
"getText",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"txtJuros",
".",
"getText",
"(",
")",
".",
"isEmpty",
"(",
")",
"||",
"(",
"(",
"screen",
".",
"equals",
"(",
"\"Simulador CDB\"",
")",
"||",
"screen",
".",
"equals",
"(",
"\"Comparativo Poupança vs CDB\")",
")",
"",
"&&",
"txt1",
".",
"getText",
"(",
")",
".",
"isEmpty",
"(",
")",
")",
"||",
"(",
"screen",
".",
"equals",
"(",
"\"Comparativo Poupança vs CDB\")",
" ",
"& ",
"xt2.",
"g",
"etText(",
")",
".",
"i",
"sEmpty(",
")",
")",
")",
" ",
"",
"alert",
".",
"setHeaderText",
"(",
"\"Preencha todos os campos\"",
")",
";",
"alert",
".",
"showAndWait",
"(",
")",
";",
"}",
"else",
"{",
"int",
"periodo",
"=",
"(",
"int",
")",
"ChronoUnit",
".",
"MONTHS",
".",
"between",
"(",
"dataInicial",
".",
"getValue",
"(",
")",
",",
"dataFinal",
".",
"getValue",
"(",
")",
")",
";",
"if",
"(",
"periodo",
"<=",
"0",
")",
"{",
"alert",
".",
"setHeaderText",
"(",
"\"Escolha um intervalo maior que um mês\")",
";",
"",
"alert",
".",
"showAndWait",
"(",
")",
";",
"}",
"else",
"{",
"// Limpa o grafico",
"lineChart",
".",
"getData",
"(",
")",
".",
"clear",
"(",
")",
";",
"// Verifica o nome da janela solicita e a abre",
"switch",
"(",
"screen",
")",
"{",
"case",
"\"Simulador Poupança\":",
"",
"lineChart",
".",
"setTitle",
"(",
"\"Poupança\")",
";",
"",
"carregaGrafico",
"(",
"poupanca",
"(",
")",
",",
"periodo",
")",
";",
"break",
";",
"case",
"\"Simulador CDB\"",
":",
"lineChart",
".",
"setTitle",
"(",
"\"Certificado de Depósito Bancário (CDB)\");",
"",
"",
"carregaGrafico",
"(",
"cdb",
"(",
")",
",",
"periodo",
")",
";",
"break",
";",
"case",
"\"Comparativo Poupança vs CDB\":",
"",
"lineChart",
".",
"setTitle",
"(",
"\"Comparativo Poupança vs CDB\")",
";",
"",
"carregaGrafico",
"(",
"cdb",
"(",
")",
",",
"poupanca",
"(",
")",
",",
"periodo",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] | [
488,
1
] | [
537,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
JFrameHandler. | null | Le o nome da cidade quando se clica no botão | Le o nome da cidade quando se clica no botão | private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked
// TODO add your handling code here:
System.out.println("OnClickButton!");
OkHttpGet request = new OkHttpGet();
String cityName = jTextFieldCity.getText();
//ok, vamos tratar o basico por aqui pra pelo menos nao deixar passar cidade que nao existe e null
if (cityName.equals("")){
jTextPaneSaida.setText("Nome da cidade não pode ser nulo.");
JOptionPane.showMessageDialog(null,"Nome da cidade não pode ser nulo.");
}
else {
OWMRequests owm = new OWMRequests();
boolean validCity = owm.checkIfCityExists(cityName);
if (validCity){
jTextPaneSaida.setText("Carregando dados...");
String data = request.getDataFromCity(cityName);
jTextPaneSaida.setText(data);
}
else {
JOptionPane.showMessageDialog(null,"Cidade não encontrada");
}
}
} | [
"private",
"void",
"jButton1MouseClicked",
"(",
"java",
".",
"awt",
".",
"event",
".",
"MouseEvent",
"evt",
")",
"{",
"//GEN-FIRST:event_jButton1MouseClicked",
"// TODO add your handling code here:",
"System",
".",
"out",
".",
"println",
"(",
"\"OnClickButton!\"",
")",
";",
"OkHttpGet",
"request",
"=",
"new",
"OkHttpGet",
"(",
")",
";",
"String",
"cityName",
"=",
"jTextFieldCity",
".",
"getText",
"(",
")",
";",
"//ok, vamos tratar o basico por aqui pra pelo menos nao deixar passar cidade que nao existe e null",
"if",
"(",
"cityName",
".",
"equals",
"(",
"\"\"",
")",
")",
"{",
"jTextPaneSaida",
".",
"setText",
"(",
"\"Nome da cidade não pode ser nulo.\")",
";",
"",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"Nome da cidade não pode ser nulo.\")",
";",
"",
"}",
"else",
"{",
"OWMRequests",
"owm",
"=",
"new",
"OWMRequests",
"(",
")",
";",
"boolean",
"validCity",
"=",
"owm",
".",
"checkIfCityExists",
"(",
"cityName",
")",
";",
"if",
"(",
"validCity",
")",
"{",
"jTextPaneSaida",
".",
"setText",
"(",
"\"Carregando dados...\"",
")",
";",
"String",
"data",
"=",
"request",
".",
"getDataFromCity",
"(",
"cityName",
")",
";",
"jTextPaneSaida",
".",
"setText",
"(",
"data",
")",
";",
"}",
"else",
"{",
"JOptionPane",
".",
"showMessageDialog",
"(",
"null",
",",
"\"Cidade não encontrada\")",
";",
"",
"}",
"}",
"}"
] | [
125,
4
] | [
150,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Solution. | null | Completar a função birthdayCakeCandles que esta abaixo: | Completar a função birthdayCakeCandles que esta abaixo: | static int birthdayCakeCandles(int[] ar) {
// Esta é a resolução que esta explicada do Read.me
int maxCandleHeight = Integer.MIN_VALUE;
int maxCandleFreqCount = 0;
for (int i = 0; i < ar.length; i++) {
if (ar[i] == maxCandleHeight) {
maxCandleFreqCount++;
}
if (ar[i] > maxCandleHeight) {
maxCandleHeight = ar[i];
maxCandleFreqCount = 1;
}
}
return maxCandleFreqCount;
} | [
"static",
"int",
"birthdayCakeCandles",
"(",
"int",
"[",
"]",
"ar",
")",
"{",
"// Esta é a resolução que esta explicada do Read.me",
"int",
"maxCandleHeight",
"=",
"Integer",
".",
"MIN_VALUE",
";",
"int",
"maxCandleFreqCount",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"ar",
".",
"length",
";",
"i",
"++",
")",
"{",
"if",
"(",
"ar",
"[",
"i",
"]",
"==",
"maxCandleHeight",
")",
"{",
"maxCandleFreqCount",
"++",
";",
"}",
"if",
"(",
"ar",
"[",
"i",
"]",
">",
"maxCandleHeight",
")",
"{",
"maxCandleHeight",
"=",
"ar",
"[",
"i",
"]",
";",
"maxCandleFreqCount",
"=",
"1",
";",
"}",
"}",
"return",
"maxCandleFreqCount",
";",
"}"
] | [
11,
4
] | [
31,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Serial. | null | Seleção de configuração do equipamento | Seleção de configuração do equipamento | private void selecionarConfigEquipamento() {
switch (equipamento) {
case "WT1000N":
configWT1000N();
break;
case "3101C":
config3101C();
break;
case "WT27":
configWT1000N();
break;
}
} | [
"private",
"void",
"selecionarConfigEquipamento",
"(",
")",
"{",
"switch",
"(",
"equipamento",
")",
"{",
"case",
"\"WT1000N\"",
":",
"configWT1000N",
"(",
")",
";",
"break",
";",
"case",
"\"3101C\"",
":",
"config3101C",
"(",
")",
";",
"break",
";",
"case",
"\"WT27\"",
":",
"configWT1000N",
"(",
")",
";",
"break",
";",
"}",
"}"
] | [
163,
4
] | [
175,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
UsuarioController. | null | Retorna uma lista de usuários | Retorna uma lista de usuários | @RequestMapping(value="/", method=RequestMethod.GET)
@ApiOperation(value="Retorna uma lista de Usuários")
public ResponseEntity<?> listaUsuarios(){
List<Usuario> obj = usuarioService.listaUsuarios();
return ResponseEntity.ok().body(obj);
} | [
"@",
"RequestMapping",
"(",
"value",
"=",
"\"/\"",
",",
"method",
"=",
"RequestMethod",
".",
"GET",
")",
"@",
"ApiOperation",
"(",
"value",
"=",
"\"Retorna uma lista de Usuários\")",
"",
"public",
"ResponseEntity",
"<",
"?",
">",
"listaUsuarios",
"(",
")",
"{",
"List",
"<",
"Usuario",
">",
"obj",
"=",
"usuarioService",
".",
"listaUsuarios",
"(",
")",
";",
"return",
"ResponseEntity",
".",
"ok",
"(",
")",
".",
"body",
"(",
"obj",
")",
";",
"}"
] | [
29,
1
] | [
34,
2
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Calculadora. | null | retorno se quisermos usar as operaçoes umas dentro de outras | retorno se quisermos usar as operaçoes umas dentro de outras | public int sum(int a, int b) {
int resultado = a + b;
// Converto a operacao e resultado numa string para imprimir
String operacao = a + " + " + b + " = " + resultado;
System.out.println(operacao);
return resultado;
} | [
"public",
"int",
"sum",
"(",
"int",
"a",
",",
"int",
"b",
")",
"{",
"int",
"resultado",
"=",
"a",
"+",
"b",
";",
"// Converto a operacao e resultado numa string para imprimir",
"String",
"operacao",
"=",
"a",
"+",
"\" + \"",
"+",
"b",
"+",
"\" = \"",
"+",
"resultado",
";",
"System",
".",
"out",
".",
"println",
"(",
"operacao",
")",
";",
"return",
"resultado",
";",
"}"
] | [
16,
4
] | [
22,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Sprite. | null | método que carrega a imagem para a tela e pega suas dimensões | método que carrega a imagem para a tela e pega suas dimensões | public void carregaImg(String local) {
ImageIcon ii = new ImageIcon(local);
imagem = ii.getImage();
largura = imagem.getWidth(null);
altura = imagem.getHeight(null);
} | [
"public",
"void",
"carregaImg",
"(",
"String",
"local",
")",
"{",
"ImageIcon",
"ii",
"=",
"new",
"ImageIcon",
"(",
"local",
")",
";",
"imagem",
"=",
"ii",
".",
"getImage",
"(",
")",
";",
"largura",
"=",
"imagem",
".",
"getWidth",
"(",
"null",
")",
";",
"altura",
"=",
"imagem",
".",
"getHeight",
"(",
"null",
")",
";",
"}"
] | [
17,
4
] | [
22,
5
] | null | java | pt | ['pt', 'pt', 'pt'] | True | true | method_declaration |
|
Ship. | null | Verificar se já existe uma nave | Verificar se já existe uma nave | public static Ship getInstance() {
//Caso não exista uma nave
if (singleton == null) {
//Criação de uma nave
singleton = new Ship();
}
// Se ela já existe ele irá retorná-la
return singleton;
} | [
"public",
"static",
"Ship",
"getInstance",
"(",
")",
"{",
"//Caso não exista uma nave",
"if",
"(",
"singleton",
"==",
"null",
")",
"{",
"//Criação de uma nave",
"singleton",
"=",
"new",
"Ship",
"(",
")",
";",
"}",
"// Se ela já existe ele irá retorná-la",
"return",
"singleton",
";",
"}"
] | [
26,
4
] | [
34,
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.