blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
sequence | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
sequence | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
18d68f9e41093ce169261de1ad10928352e39510 | 7,825,430,475,670 | 6cd6b856e5ac6821459fa95dfe14dc3625af1ee7 | /src/main/java/com/reports/imports/servicehandle/ImportReader.java | 1b63f1f0568618ab32457021e249353bc023150d | [] | no_license | xiaoyunz/ExcelReportHandle | https://github.com/xiaoyunz/ExcelReportHandle | 822e27ddc4f24acb944296b90c63ebc8ad189e1e | b785b0727ed165bc088e0f3c8e2bb25e668e5e3f | refs/heads/master | 2021-07-22T23:46:58.520000 | 2018-12-19T01:33:54 | 2018-12-19T01:33:54 | 145,274,307 | 7 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.reports.imports.servicehandle;
import java.io.InputStream;
import java.util.Map;
import com.reports.imports.xmlhandle.Import;
/**
* 报表导入读取接口类
*/
public interface ImportReader {
/**
* 读取导入报表数据
* @param importx import-config.xml中定义的报表节点
* @param is 报表输入流
* @return
*/
public Map<String,Object> readImportData(Import importx, InputStream is);
}
| UTF-8 | Java | 434 | java | ImportReader.java | Java | [] | null | [] | package com.reports.imports.servicehandle;
import java.io.InputStream;
import java.util.Map;
import com.reports.imports.xmlhandle.Import;
/**
* 报表导入读取接口类
*/
public interface ImportReader {
/**
* 读取导入报表数据
* @param importx import-config.xml中定义的报表节点
* @param is 报表输入流
* @return
*/
public Map<String,Object> readImportData(Import importx, InputStream is);
}
| 434 | 0.729947 | 0.729947 | 20 | 17.700001 | 19.859758 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.75 | false | false | 4 |
d41e40fcc652da3d3fac6e8cf87a54d60539f312 | 9,904,194,611,187 | b972e29512962be64dd8c45de69ff89fa19c0f4d | /src/main/java/com/cobelliluetichperezvazquez/trabajointegrador/model/Cliente.java | cdec8797d73e1f4a07cdbc2c75ef0a34b8e09cf9 | [] | no_license | cobellisantiago/ISW_2020_TP1 | https://github.com/cobellisantiago/ISW_2020_TP1 | 4fcaa234876c3f8cfee106babdfa1cf4d2f6b7e9 | 1e78b9bdcfdc6118a9861d7c91b22931917aaaf9 | refs/heads/master | 2022-12-25T11:04:16.689000 | 2020-09-30T00:01:31 | 2020-09-30T00:01:31 | 298,689,693 | 0 | 0 | null | false | 2020-09-30T00:04:59 | 2020-09-25T22:14:00 | 2020-09-30T00:01:34 | 2020-09-30T00:04:58 | 680 | 0 | 0 | 0 | JavaScript | false | false | package com.cobelliluetichperezvazquez.trabajointegrador.model;
import java.util.Calendar;
import com.cobelliluetichperezvazquez.trabajointegrador.model.enums.*;
import javax.persistence.*;
@Entity
public class Cliente {
@Id
String idCliente;
TipoDeDocumento tipoDeDocumento;
String numeroDeDocumento;
String apellido;
String nombre;
NumeroDeSiniestros numeroSiniestrosUltimoAño;
CondicionIVA condicionIVA;
String profesion;
Integer añoDeRegistro;
Sexo sexo;
Calendar fechaDeNacimiento;
String CUIL;
String correoElectronico;
EstadoCivil estadoCivil;
EstadoCliente estado;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_domicilio")
Domicilio domicilio;
public Cliente() {
}
public Cliente(String idCliente, TipoDeDocumento tipoDeDocumento, String numeroDeDocumento, String apellido,
String nombre, NumeroDeSiniestros numeroSiniestrosUltimoAño, CondicionIVA condicionIVA, String profesion,
Integer añoDeRegistro, Sexo sexo, Calendar fechaDeNacimiento, String CUIL, String correoElectronico,
EstadoCivil estadoCivil, EstadoCliente estado, Domicilio domicilio) {
this.idCliente = idCliente;
this.tipoDeDocumento = tipoDeDocumento;
this.numeroDeDocumento = numeroDeDocumento;
this.apellido = apellido;
this.nombre = nombre;
this.numeroSiniestrosUltimoAño = numeroSiniestrosUltimoAño;
this.condicionIVA = condicionIVA;
this.profesion = profesion;
this.añoDeRegistro = añoDeRegistro;
this.sexo = sexo;
this.fechaDeNacimiento = fechaDeNacimiento;
this.CUIL = CUIL;
this.correoElectronico = correoElectronico;
this.estadoCivil = estadoCivil;
this.estado = estado;
this.domicilio = domicilio;
}
public String getIdCliente() {
return idCliente;
}
public void setIdCliente(String idCliente) {
this.idCliente = idCliente;
}
public TipoDeDocumento getTipoDeDocumento() {
return tipoDeDocumento;
}
public void setTipoDeDocumento(TipoDeDocumento tipoDeDocumento) {
this.tipoDeDocumento = tipoDeDocumento;
}
public String getNumeroDeDocumento() {
return numeroDeDocumento;
}
public void setNumeroDeDocumento(String numeroDeDocumento) {
this.numeroDeDocumento = numeroDeDocumento;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public NumeroDeSiniestros getNumeroSiniestrosUltimoAño() {
return numeroSiniestrosUltimoAño;
}
public void setNumeroSiniestrosUltimoAño(NumeroDeSiniestros numeroSiniestrosUltimoAño) {
this.numeroSiniestrosUltimoAño = numeroSiniestrosUltimoAño;
}
public CondicionIVA getCondicionIVA() {
return condicionIVA;
}
public void setCondicionIVA(CondicionIVA condicionIVA) {
this.condicionIVA = condicionIVA;
}
public String getProfesion() {
return profesion;
}
public void setProfesion(String profesion) {
this.profesion = profesion;
}
public Integer getAñoDeRegistro() {
return añoDeRegistro;
}
public void setAñoDeRegistro(Integer añoDeRegistro) {
this.añoDeRegistro = añoDeRegistro;
}
public Sexo getSexo() {
return sexo;
}
public void setSexo(Sexo sexo) {
this.sexo = sexo;
}
public Calendar getFechaDeNacimiento() {
return fechaDeNacimiento;
}
public void setFechaDeNacimiento(Calendar fechaDeNacimiento) {
this.fechaDeNacimiento = fechaDeNacimiento;
}
public String getCUIL() {
return CUIL;
}
public void setCUIL(String cUIL) {
CUIL = cUIL;
}
public String getCorreoElectronico() {
return correoElectronico;
}
public void setCorreoElectronico(String correoElectronico) {
this.correoElectronico = correoElectronico;
}
public EstadoCivil getEstadoCivil() {
return estadoCivil;
}
public void setEstadoCivil(EstadoCivil estadoCivil) {
this.estadoCivil = estadoCivil;
}
public EstadoCliente getEstado() {
return estado;
}
public void setEstado(EstadoCliente estado) {
this.estado = estado;
}
public Domicilio getDomicilio() {
return domicilio;
}
public void setDomicilio(Domicilio domicilio) {
this.domicilio = domicilio;
}
} | UTF-8 | Java | 4,773 | java | Cliente.java | Java | [] | null | [] | package com.cobelliluetichperezvazquez.trabajointegrador.model;
import java.util.Calendar;
import com.cobelliluetichperezvazquez.trabajointegrador.model.enums.*;
import javax.persistence.*;
@Entity
public class Cliente {
@Id
String idCliente;
TipoDeDocumento tipoDeDocumento;
String numeroDeDocumento;
String apellido;
String nombre;
NumeroDeSiniestros numeroSiniestrosUltimoAño;
CondicionIVA condicionIVA;
String profesion;
Integer añoDeRegistro;
Sexo sexo;
Calendar fechaDeNacimiento;
String CUIL;
String correoElectronico;
EstadoCivil estadoCivil;
EstadoCliente estado;
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "id_domicilio")
Domicilio domicilio;
public Cliente() {
}
public Cliente(String idCliente, TipoDeDocumento tipoDeDocumento, String numeroDeDocumento, String apellido,
String nombre, NumeroDeSiniestros numeroSiniestrosUltimoAño, CondicionIVA condicionIVA, String profesion,
Integer añoDeRegistro, Sexo sexo, Calendar fechaDeNacimiento, String CUIL, String correoElectronico,
EstadoCivil estadoCivil, EstadoCliente estado, Domicilio domicilio) {
this.idCliente = idCliente;
this.tipoDeDocumento = tipoDeDocumento;
this.numeroDeDocumento = numeroDeDocumento;
this.apellido = apellido;
this.nombre = nombre;
this.numeroSiniestrosUltimoAño = numeroSiniestrosUltimoAño;
this.condicionIVA = condicionIVA;
this.profesion = profesion;
this.añoDeRegistro = añoDeRegistro;
this.sexo = sexo;
this.fechaDeNacimiento = fechaDeNacimiento;
this.CUIL = CUIL;
this.correoElectronico = correoElectronico;
this.estadoCivil = estadoCivil;
this.estado = estado;
this.domicilio = domicilio;
}
public String getIdCliente() {
return idCliente;
}
public void setIdCliente(String idCliente) {
this.idCliente = idCliente;
}
public TipoDeDocumento getTipoDeDocumento() {
return tipoDeDocumento;
}
public void setTipoDeDocumento(TipoDeDocumento tipoDeDocumento) {
this.tipoDeDocumento = tipoDeDocumento;
}
public String getNumeroDeDocumento() {
return numeroDeDocumento;
}
public void setNumeroDeDocumento(String numeroDeDocumento) {
this.numeroDeDocumento = numeroDeDocumento;
}
public String getApellido() {
return apellido;
}
public void setApellido(String apellido) {
this.apellido = apellido;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public NumeroDeSiniestros getNumeroSiniestrosUltimoAño() {
return numeroSiniestrosUltimoAño;
}
public void setNumeroSiniestrosUltimoAño(NumeroDeSiniestros numeroSiniestrosUltimoAño) {
this.numeroSiniestrosUltimoAño = numeroSiniestrosUltimoAño;
}
public CondicionIVA getCondicionIVA() {
return condicionIVA;
}
public void setCondicionIVA(CondicionIVA condicionIVA) {
this.condicionIVA = condicionIVA;
}
public String getProfesion() {
return profesion;
}
public void setProfesion(String profesion) {
this.profesion = profesion;
}
public Integer getAñoDeRegistro() {
return añoDeRegistro;
}
public void setAñoDeRegistro(Integer añoDeRegistro) {
this.añoDeRegistro = añoDeRegistro;
}
public Sexo getSexo() {
return sexo;
}
public void setSexo(Sexo sexo) {
this.sexo = sexo;
}
public Calendar getFechaDeNacimiento() {
return fechaDeNacimiento;
}
public void setFechaDeNacimiento(Calendar fechaDeNacimiento) {
this.fechaDeNacimiento = fechaDeNacimiento;
}
public String getCUIL() {
return CUIL;
}
public void setCUIL(String cUIL) {
CUIL = cUIL;
}
public String getCorreoElectronico() {
return correoElectronico;
}
public void setCorreoElectronico(String correoElectronico) {
this.correoElectronico = correoElectronico;
}
public EstadoCivil getEstadoCivil() {
return estadoCivil;
}
public void setEstadoCivil(EstadoCivil estadoCivil) {
this.estadoCivil = estadoCivil;
}
public EstadoCliente getEstado() {
return estado;
}
public void setEstado(EstadoCliente estado) {
this.estado = estado;
}
public Domicilio getDomicilio() {
return domicilio;
}
public void setDomicilio(Domicilio domicilio) {
this.domicilio = domicilio;
}
} | 4,773 | 0.676625 | 0.676625 | 186 | 24.559139 | 24.211863 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.446237 | false | false | 4 |
49cdbeada4dd785e4080490eddaae7f6ab1aab47 | 29,540,785,091,575 | af4b2e14b4c77946f28f204a3707b0a8fb4d5991 | /src/com/nate/unit2/observer/hw/stock/StockMarket.java | ffcda4c1cda4cad6b0f33010947365f0674ec2db | [] | no_license | nate-dem/asd-labs | https://github.com/nate-dem/asd-labs | beb89ffce692dfc134065a9cf05034ab6a6c1558 | 563712e2d2cbab7c9e57193a407a51f431f9b73a | refs/heads/master | 2018-10-13T16:23:56.419000 | 2018-07-16T13:55:21 | 2018-07-16T13:55:21 | 140,611,653 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.nate.unit2.observer.hw.stock;
import java.util.ArrayList;
import java.util.List;
public class StockMarket extends AbstractMarket implements Subject {
private List<StockObserver> observers;
public StockMarket() {
observers = new ArrayList<>();
}
public void addStock(String stockSymbol, Double price){
stocklist.put(stockSymbol, price);
}
public void update(String stockSymbol, Double price){
stocklist.put(stockSymbol, price);
this.notifyObserver();
}
@Override
public void registerObserver(StockObserver newObserver) {
observers.add(newObserver);
}
@Override
public void unregisterObserver(StockObserver observer) {
observers.remove(observers.indexOf(observer));
}
@Override
public void notifyObserver() {
for(StockObserver observer : observers){
// observer.update(stocklist);
}
observers.forEach(o -> o.update(this));
}
}
| UTF-8 | Java | 888 | java | StockMarket.java | Java | [] | null | [] | package com.nate.unit2.observer.hw.stock;
import java.util.ArrayList;
import java.util.List;
public class StockMarket extends AbstractMarket implements Subject {
private List<StockObserver> observers;
public StockMarket() {
observers = new ArrayList<>();
}
public void addStock(String stockSymbol, Double price){
stocklist.put(stockSymbol, price);
}
public void update(String stockSymbol, Double price){
stocklist.put(stockSymbol, price);
this.notifyObserver();
}
@Override
public void registerObserver(StockObserver newObserver) {
observers.add(newObserver);
}
@Override
public void unregisterObserver(StockObserver observer) {
observers.remove(observers.indexOf(observer));
}
@Override
public void notifyObserver() {
for(StockObserver observer : observers){
// observer.update(stocklist);
}
observers.forEach(o -> o.update(this));
}
}
| 888 | 0.746622 | 0.745495 | 40 | 21.200001 | 20.879656 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.3 | false | false | 4 |
8471a29324fa32098e880e48ed3868109c8f2d94 | 33,861,522,185,097 | c894f0a882af97f968efe1bc6772acb48586e6f2 | /src/main/java/com/ekkod/webservis/service/TestService.java | 8c1b892f14fe4dd53986b361996266b77cf4bbe4 | [] | no_license | erencetinkayaceng/RestfulJerseyWebservis | https://github.com/erencetinkayaceng/RestfulJerseyWebservis | f87d7e47d58f5fef7c5ae28f9b402f52fcd88eb8 | 70620e6d2b1768cc175e5ab7f8fc4bc14553c297 | refs/heads/master | 2021-01-11T16:36:33.583000 | 2017-01-26T14:45:34 | 2017-01-26T14:45:34 | 80,121,596 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ekkod.webservis.service;
import java.util.List;
import com.ekkod.web.dao.TestDao;
import com.ekkod.web.model.Test;
public class TestService {
TestDao dao = new TestDao();
public List<Test> getirTestler(int id) {
return dao.getirIDsonrasiTestler(id);
}
}
| UTF-8 | Java | 276 | java | TestService.java | Java | [] | null | [] | package com.ekkod.webservis.service;
import java.util.List;
import com.ekkod.web.dao.TestDao;
import com.ekkod.web.model.Test;
public class TestService {
TestDao dao = new TestDao();
public List<Test> getirTestler(int id) {
return dao.getirIDsonrasiTestler(id);
}
}
| 276 | 0.75 | 0.75 | 15 | 17.4 | 16.483526 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.733333 | false | false | 4 |
2d402c314503e5b187463cc4853c36dbde537007 | 14,491,219,723,372 | 76b7b1a837fc9da296c10870eaa6366c79d616f7 | /src/Java Native/esdk_ivs_native_professional_java/src/main/java/com/huawei/esdk/ivs/professional/local/impl/autogen/IVSProfessionalCommon.java | 8d0b219fd534bfc7ece4fca60c778315af0aaf35 | [
"Apache-2.0"
] | permissive | zanaozhe/eSDK_IVS_Java | https://github.com/zanaozhe/eSDK_IVS_Java | e0b8ea90ea0487e7f7e81ea4bac1bdd3bc626b87 | bcefd63efab6d08efd33775c8e8f4e95e4f65909 | refs/heads/master | 2020-03-25T20:02:43.910000 | 2016-08-30T12:31:12 | 2016-08-30T12:31:12 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Copyright 2015 Huawei Technologies Co., Ltd. All rights reserved.
* eSDK is licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.huawei.esdk.ivs.professional.local.impl.autogen;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by Apache CXF 2.6.10
* 2014-01-06T23:40:35.994+08:00
* Generated source version: 2.6.10
*
*/
@WebService(targetNamespace = "esdk_ivs_professional_server", name = "IVSProfessional.Common")
@XmlSeeAlso({ObjectFactory.class})
public interface IVSProfessionalCommon {
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "registerNotification", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.RegisterNotification")
@WebMethod(action = "esdk_ivs_professional_server.registerNotification")
@ResponseWrapper(localName = "registerNotificationResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.RegisterNotificationResponse")
public java.lang.Integer registerNotification(
@WebParam(name = "wsUri", targetNamespace = "")
java.lang.String wsUri
);
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "keepAlive", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.KeepAlive")
@WebMethod(action = "esdk_ivs_professional_server.keepAlive")
@ResponseWrapper(localName = "keepAliveResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.KeepAliveResponse")
public java.lang.Integer keepAlive();
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "login", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.Login")
@WebMethod(action = "esdk_ivs_professional_server.login")
@ResponseWrapper(localName = "loginResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.LoginResponse")
public java.lang.Integer login(
@WebParam(name = "userName", targetNamespace = "")
java.lang.String userName,
@WebParam(name = "password", targetNamespace = "")
java.lang.String password
);
@RequestWrapper(localName = "getVersion", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.GetVersion")
@WebMethod(action = "esdk_ivs_professional_server.getVersion")
@ResponseWrapper(localName = "getVersionResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.GetVersionResponse")
public void getVersion(
@WebParam(mode = WebParam.Mode.OUT, name = "resultCode", targetNamespace = "")
javax.xml.ws.Holder<java.lang.Integer> resultCode,
@WebParam(mode = WebParam.Mode.OUT, name = "version", targetNamespace = "")
javax.xml.ws.Holder<java.lang.String> version
);
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "logout", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.Logout")
@WebMethod(action = "esdk_ivs_professional_server.logout")
@ResponseWrapper(localName = "logoutResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.LogoutResponse")
public java.lang.Integer logout();
}
| UTF-8 | Java | 4,411 | java | IVSProfessionalCommon.java | Java | [
{
"context": "ava.lang.Integer login(\n @WebParam(name = \"userName\", targetNamespace = \"\")\n java.lang.String ",
"end": 2987,
"score": 0.8917138576507568,
"start": 2979,
"tag": "USERNAME",
"value": "userName"
}
] | null | [] | /**
* Copyright 2015 Huawei Technologies Co., Ltd. All rights reserved.
* eSDK is licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.huawei.esdk.ivs.professional.local.impl.autogen;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.ws.RequestWrapper;
import javax.xml.ws.ResponseWrapper;
/**
* This class was generated by Apache CXF 2.6.10
* 2014-01-06T23:40:35.994+08:00
* Generated source version: 2.6.10
*
*/
@WebService(targetNamespace = "esdk_ivs_professional_server", name = "IVSProfessional.Common")
@XmlSeeAlso({ObjectFactory.class})
public interface IVSProfessionalCommon {
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "registerNotification", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.RegisterNotification")
@WebMethod(action = "esdk_ivs_professional_server.registerNotification")
@ResponseWrapper(localName = "registerNotificationResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.RegisterNotificationResponse")
public java.lang.Integer registerNotification(
@WebParam(name = "wsUri", targetNamespace = "")
java.lang.String wsUri
);
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "keepAlive", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.KeepAlive")
@WebMethod(action = "esdk_ivs_professional_server.keepAlive")
@ResponseWrapper(localName = "keepAliveResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.KeepAliveResponse")
public java.lang.Integer keepAlive();
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "login", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.Login")
@WebMethod(action = "esdk_ivs_professional_server.login")
@ResponseWrapper(localName = "loginResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.LoginResponse")
public java.lang.Integer login(
@WebParam(name = "userName", targetNamespace = "")
java.lang.String userName,
@WebParam(name = "password", targetNamespace = "")
java.lang.String password
);
@RequestWrapper(localName = "getVersion", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.GetVersion")
@WebMethod(action = "esdk_ivs_professional_server.getVersion")
@ResponseWrapper(localName = "getVersionResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.GetVersionResponse")
public void getVersion(
@WebParam(mode = WebParam.Mode.OUT, name = "resultCode", targetNamespace = "")
javax.xml.ws.Holder<java.lang.Integer> resultCode,
@WebParam(mode = WebParam.Mode.OUT, name = "version", targetNamespace = "")
javax.xml.ws.Holder<java.lang.String> version
);
@WebResult(name = "resultCode", targetNamespace = "")
@RequestWrapper(localName = "logout", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.Logout")
@WebMethod(action = "esdk_ivs_professional_server.logout")
@ResponseWrapper(localName = "logoutResponse", targetNamespace = "esdk_ivs_professional_server", className = "com.huawei.esdk.ivs.professional.local.impl.autogen.LogoutResponse")
public java.lang.Integer logout();
}
| 4,411 | 0.744276 | 0.735888 | 77 | 56.285713 | 54.657341 | 210 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.688312 | false | false | 4 |
9d72cd090f4ce47d9b9d56206c93e8baaff4a1d4 | 10,230,612,134,790 | 4737211958ad98823bfada0515bb7943992aca13 | /src/main/java/collab/UserEntityDemo.java | c9642c62271aec79edff7dd8f34a9dcc5291b7cc | [] | no_license | Gal-Greenberg/Shopping-backend | https://github.com/Gal-Greenberg/Shopping-backend | 652a1d36d0da538a56fa3de6fe3e3e3846f3aa90 | 251bd05880c23cbe477c6e8b4b452c7db3be6524 | refs/heads/master | 2023-05-28T06:58:40.431000 | 2020-05-24T08:52:43 | 2020-05-24T08:52:43 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package collab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import collab.dal.UserDao;
import collab.data.UserEntity;
import collab.data.UserRole;
import collab.data.utils.EntityFactory;
import collab.rest.NotFoundException;
//@Profile("production")
//@Component
public class UserEntityDemo implements CommandLineRunner {
private EntityFactory factory;
private UserDao userDao;
@Autowired
public UserEntityDemo(EntityFactory factory, UserDao userDao) {
super();
this.factory = factory;
this.userDao = userDao;
}
@Override
public void run(String... args) throws Exception {
// System.err.println("\n\n ---------------- User Entity Start: -------------------- \n");
// String username = "Player1";
// UserRole ur = UserRole.PLAYER;
// String userEmail = "yuvalbne@gmail.com";
// String userDomain = "2020a.alik";
// String avatar = ":)";
// String username1 = "Manager";
// UserRole ur1 = UserRole.MANAGER;
// String userEmail1 = "Nofaralfasi@gmail.com";
// String avatar1 = ":')";
//
// UserEntity player1 = factory.createNewUser( userEmail+"@@"+userDomain, username, avatar, ur);
// System.err.println("new user:" + player1 + "\n");
// player1 = this.userDao.save(player1);
// System.err.println("stored user:" + player1 + "\n");
// UserEntity managerDemo = factory.createNewUser( userEmail1+"@@"+userDomain, username1, avatar1, ur1);
// System.err.println("new user:" + managerDemo + "\n");
// managerDemo = this.userDao.save(managerDemo);
// System.err.println("stored user:" + managerDemo + "\n");
/*this.userDao.deleteAll();
if (!this.userDao.findAll().iterator().hasNext()) {
System.err.println("\nSuccessfully deleted all users");
} else {
throw new RuntimeException("Error! there is a user in the memory after deletion");
}
System.out.println("\n ---------------- User Entity End -------------------- \n\n");
*/
UserEntity userFromDB = userDao.findById("Nofaralfasi@gmail.com@@2020a.alik")
.orElseThrow(()->new NotFoundException("no user could be found "));
System.err.println(userFromDB.getAvatar());
}
} | UTF-8 | Java | 2,261 | java | UserEntityDemo.java | Java | [
{
"context": "-------------------- \\n\");\n//\t\tString username = \"Player1\";\n//\t\tUserRole ur = UserRole.PLAYER;\n//\t\tString u",
"end": 889,
"score": 0.9996504783630371,
"start": 882,
"tag": "USERNAME",
"value": "Player1"
},
{
"context": "ole ur = UserRole.PLAYER;\n//\t\tString userEmail = \"yuvalbne@gmail.com\";\n//\t\tString userDomain = \"2020a.alik\";\n//\t\tStrin",
"end": 969,
"score": 0.9999241232872009,
"start": 951,
"tag": "EMAIL",
"value": "yuvalbne@gmail.com"
},
{
"context": "//\t\tString avatar = \":)\";\n//\t\tString username1 = \"Manager\";\n//\t\tUserRole ur1 = UserRole.MANAGER;\n//\t\tString",
"end": 1067,
"score": 0.9995478987693787,
"start": 1060,
"tag": "USERNAME",
"value": "Manager"
},
{
"context": " ur1 = UserRole.MANAGER;\n//\t\tString userEmail1 = \"Nofaralfasi@gmail.com\";\n//\t\tString avatar1 = \":')\";\n//\t\t\n//\t\tUserEntity",
"end": 1153,
"score": 0.9999264478683472,
"start": 1132,
"tag": "EMAIL",
"value": "Nofaralfasi@gmail.com"
},
{
"context": "\n\t\t*/\n\t\tUserEntity userFromDB = userDao.findById(\"Nofaralfasi@gmail.com@@2020a.alik\")\n\t\t\t\t.orElseThrow(()->new NotFoundEx",
"end": 2123,
"score": 0.9997825622558594,
"start": 2102,
"tag": "EMAIL",
"value": "Nofaralfasi@gmail.com"
}
] | null | [] | package collab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;
import collab.dal.UserDao;
import collab.data.UserEntity;
import collab.data.UserRole;
import collab.data.utils.EntityFactory;
import collab.rest.NotFoundException;
//@Profile("production")
//@Component
public class UserEntityDemo implements CommandLineRunner {
private EntityFactory factory;
private UserDao userDao;
@Autowired
public UserEntityDemo(EntityFactory factory, UserDao userDao) {
super();
this.factory = factory;
this.userDao = userDao;
}
@Override
public void run(String... args) throws Exception {
// System.err.println("\n\n ---------------- User Entity Start: -------------------- \n");
// String username = "Player1";
// UserRole ur = UserRole.PLAYER;
// String userEmail = "<EMAIL>";
// String userDomain = "2020a.alik";
// String avatar = ":)";
// String username1 = "Manager";
// UserRole ur1 = UserRole.MANAGER;
// String userEmail1 = "<EMAIL>";
// String avatar1 = ":')";
//
// UserEntity player1 = factory.createNewUser( userEmail+"@@"+userDomain, username, avatar, ur);
// System.err.println("new user:" + player1 + "\n");
// player1 = this.userDao.save(player1);
// System.err.println("stored user:" + player1 + "\n");
// UserEntity managerDemo = factory.createNewUser( userEmail1+"@@"+userDomain, username1, avatar1, ur1);
// System.err.println("new user:" + managerDemo + "\n");
// managerDemo = this.userDao.save(managerDemo);
// System.err.println("stored user:" + managerDemo + "\n");
/*this.userDao.deleteAll();
if (!this.userDao.findAll().iterator().hasNext()) {
System.err.println("\nSuccessfully deleted all users");
} else {
throw new RuntimeException("Error! there is a user in the memory after deletion");
}
System.out.println("\n ---------------- User Entity End -------------------- \n\n");
*/
UserEntity userFromDB = userDao.findById("<EMAIL>@@2020a.alik")
.orElseThrow(()->new NotFoundException("no user could be found "));
System.err.println(userFromDB.getAvatar());
}
} | 2,222 | 0.692172 | 0.682441 | 64 | 34.34375 | 27.404505 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 4 |
6bbc0df14bff2bf849a7897d14441dc0f191535b | 9,320,079,087,222 | cd6fc0e35e3591d0fef7a4a8700c1a4529f0eb88 | /src/main/src/main/java/com/harmreduction/model/Subqueries.java | 0bd451e4c852119da785b64f407485b84b1b3f62 | [] | no_license | Shivina17/Dissertation | https://github.com/Shivina17/Dissertation | ee5364fadc4826d0cfbf7ecd836f4c3e47396561 | fe2c9c5d15864d6213c8427036ed2402ac871287 | refs/heads/master | 2020-04-05T16:29:20.586000 | 2019-04-02T13:59:04 | 2019-04-02T13:59:04 | 157,014,968 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.harmreduction.model;
public class Subqueries {
private String queryName;
private String query;
private String date;
private String author;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getQueryName() {
return queryName;
}
public void setQueryName(String queryName) {
this.queryName = queryName;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
}
| UTF-8 | Java | 741 | java | Subqueries.java | Java | [] | null | [] | package com.harmreduction.model;
public class Subqueries {
private String queryName;
private String query;
private String date;
private String author;
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getQueryName() {
return queryName;
}
public void setQueryName(String queryName) {
this.queryName = queryName;
}
public String getAuthor() {
return author;
}
public void setAuthor(String author) {
this.author = author;
}
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
}
| 741 | 0.60054 | 0.60054 | 42 | 16.619047 | 14.886799 | 48 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.309524 | false | false | 4 |
6434c422dfc4307d839cb863e76b2c559dbfa8a1 | 35,459,250,009,711 | 704bd1ad7e3a4ee9c42e81fd455dddd5a77dad0d | /DesignPatterns/src/main/java/za/ac/cput/AshDesign/behavioural/state/Person.java | c5ff36407c026069bc7ffe41317f509d20e3d8d8 | [] | no_license | AshDyani/DesignPatterns | https://github.com/AshDyani/DesignPatterns | 8749f31d4195606dd0612b8e2fcc012914e9d098 | 0d79881f4adcf930cc0e7d6ac003704a1d3b62f1 | refs/heads/master | 2016-09-07T20:14:50.096000 | 2015-03-13T16:20:55 | 2015-03-13T16:20:55 | 32,156,039 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package za.ac.cput.AshDesign.behavioural.state;
/**
* Created by student on 2015/03/11.
*/
public class Person implements MoodState {
MoodState moodState;
public Person(MoodState moodState) {
this.moodState = moodState;
}
public void setMoodState(MoodState moodState) {
this.moodState = moodState;
}
@Override
public String sayGreetings() {
return moodState.sayGreetings();
}
@Override
public String sayGreetingsBad() {
return moodState.sayGreetingsBad();
}
}
| UTF-8 | Java | 544 | java | Person.java | Java | [
{
"context": "ut.AshDesign.behavioural.state;\n\n/**\n * Created by student on 2015/03/11.\n */\npublic class Person implements",
"end": 74,
"score": 0.9659519195556641,
"start": 67,
"tag": "USERNAME",
"value": "student"
}
] | null | [] | package za.ac.cput.AshDesign.behavioural.state;
/**
* Created by student on 2015/03/11.
*/
public class Person implements MoodState {
MoodState moodState;
public Person(MoodState moodState) {
this.moodState = moodState;
}
public void setMoodState(MoodState moodState) {
this.moodState = moodState;
}
@Override
public String sayGreetings() {
return moodState.sayGreetings();
}
@Override
public String sayGreetingsBad() {
return moodState.sayGreetingsBad();
}
}
| 544 | 0.658088 | 0.643382 | 28 | 18.428572 | 18.256952 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.214286 | false | false | 4 |
741a661660f602de779d919b9289a40d63e63161 | 34,978,213,673,167 | c08f1f0a1135b3afe84360ec2aefa23a93627b7e | /src/com/tgy/entity/Page.java | 43d8dc2635ec74d8c0c20b2ff9a26eba50e642f4 | [] | no_license | shaolizhi2010/tgy | https://github.com/shaolizhi2010/tgy | fcda260483cf7b0d0733e70f456065065bbe3051 | 80139c5dab9306147c7ae4073725025e57e38114 | refs/heads/master | 2021-01-21T21:54:23.404000 | 2014-10-23T01:35:30 | 2014-10-23T01:35:30 | 25,613,332 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tgy.entity;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
@Entity
public class Page {
@Id
public ObjectId id;
public String name;
public String userID;
public String bookmarkID;
public String pid;
public String link;
}
| UTF-8 | Java | 321 | java | Page.java | Java | [] | null | [] | package com.tgy.entity;
import org.bson.types.ObjectId;
import org.mongodb.morphia.annotations.Entity;
import org.mongodb.morphia.annotations.Id;
@Entity
public class Page {
@Id
public ObjectId id;
public String name;
public String userID;
public String bookmarkID;
public String pid;
public String link;
}
| 321 | 0.76947 | 0.76947 | 18 | 16.833334 | 13.881442 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 4 |
4920c62edb2a5e71242eeb0cacddd6bc04924788 | 18,992,345,439,671 | 6652c5c464617298417da2c0f2e83a83d926f45a | /Spinner/app/src/main/java/com/example/zz/spinner/MainActivity.java | ba1734ace6fcc8ad22d95e3dbface39c0086433a | [] | no_license | 2502089568/androidViewProject | https://github.com/2502089568/androidViewProject | 6cdb59af83663dc9ec85e92f8a5757577ea6546e | b22f7aa2acbc086bc683a1bff7305b5182f78b8d | refs/heads/master | 2020-03-19T02:59:35.987000 | 2018-03-17T06:57:55 | 2018-03-17T06:57:55 | 135,683,542 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.zz.spinner;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private TextView textView;
private Spinner spinner;
//private List<String>list;
private List<Map<String, Object>> dataList;
private SimpleAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView)findViewById(R.id.texView);
spinner = (Spinner)findViewById(R.id.spinner);
textView.setText("您选择的城市是北京");
//1.设置数据源
/* list = new ArrayList<String>();
list.add("北京");
list.add("上海");
list.add("广州");
list.add("深圳");*/
dataList = new ArrayList<Map<String, Object>>();
getData();
//2.新建 ArrayAdapter(数组适配器)(上下文,布局样式,数据源)
// adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list);
adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"image","text"}, new int[]{R.id.image,R.id.text});
//3.adapter设置一个下拉列表样式
//adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(R.layout.item);
//4.spinner加载适配器
spinner.setAdapter(adapter);
//5.spinner设置监听器
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?>parent, View view, int position, long id){
//String cityName = adapter.getItem(position);
textView.setText("您选择的城市是"+adapter.getItem(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
textView.setText("NONE");
}
});
}
private void getData() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("image", R.mipmap.ic_launcher);
map.put("text", "北京");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("image", R.mipmap.ic_launcher);
map2.put("text", "上海");
Map<String, Object> map3 = new HashMap<String, Object>();
map3.put("image", R.mipmap.ic_launcher);
map3.put("text", "广州");
Map<String, Object> map4 = new HashMap<String, Object>();
map4.put("image", R.mipmap.ic_launcher);
map4.put("text","深圳");
dataList.add(map);
dataList.add(map2);
dataList.add(map3);
dataList.add(map4);
}
}
| UTF-8 | Java | 3,059 | java | MainActivity.java | Java | [] | null | [] | package com.example.zz.spinner;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.SimpleAdapter;
import android.widget.Spinner;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MainActivity extends AppCompatActivity {
private TextView textView;
private Spinner spinner;
//private List<String>list;
private List<Map<String, Object>> dataList;
private SimpleAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView)findViewById(R.id.texView);
spinner = (Spinner)findViewById(R.id.spinner);
textView.setText("您选择的城市是北京");
//1.设置数据源
/* list = new ArrayList<String>();
list.add("北京");
list.add("上海");
list.add("广州");
list.add("深圳");*/
dataList = new ArrayList<Map<String, Object>>();
getData();
//2.新建 ArrayAdapter(数组适配器)(上下文,布局样式,数据源)
// adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,list);
adapter=new SimpleAdapter(this, dataList, R.layout.item, new String[]{"image","text"}, new int[]{R.id.image,R.id.text});
//3.adapter设置一个下拉列表样式
//adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
adapter.setDropDownViewResource(R.layout.item);
//4.spinner加载适配器
spinner.setAdapter(adapter);
//5.spinner设置监听器
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener(){
public void onItemSelected(AdapterView<?>parent, View view, int position, long id){
//String cityName = adapter.getItem(position);
textView.setText("您选择的城市是"+adapter.getItem(position));
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
textView.setText("NONE");
}
});
}
private void getData() {
Map<String, Object> map = new HashMap<String, Object>();
map.put("image", R.mipmap.ic_launcher);
map.put("text", "北京");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("image", R.mipmap.ic_launcher);
map2.put("text", "上海");
Map<String, Object> map3 = new HashMap<String, Object>();
map3.put("image", R.mipmap.ic_launcher);
map3.put("text", "广州");
Map<String, Object> map4 = new HashMap<String, Object>();
map4.put("image", R.mipmap.ic_launcher);
map4.put("text","深圳");
dataList.add(map);
dataList.add(map2);
dataList.add(map3);
dataList.add(map4);
}
}
| 3,059 | 0.636051 | 0.629859 | 77 | 36.753246 | 24.146284 | 128 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.077922 | false | false | 4 |
0e3bff49ace7101d8b3bbf6bc7f8c060fea98e04 | 24,893,630,460,347 | 2d0e2f382105cc67fadd7b7d6d02ba9f05c014ae | /tarea5.1/src/tarea5/pkg1/Tarea51.java | 21aff91266818f969c50f25b5377bbab76d8c775 | [] | no_license | abel05/TareaCliente | https://github.com/abel05/TareaCliente | 9b477225f1125bb47ff6dfedaea822beb3d7d4ca | 1b35a46a1f5a17225c726adda0cdf06e93d940ea | refs/heads/master | 2021-07-09T21:50:49.644000 | 2017-10-04T21:53:24 | 2017-10-04T21:53:24 | 105,822,137 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tarea5.pkg1;
import java.util.Scanner;
/**
*
* @author ABEL
*/
public class Tarea51 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int pos;
char carter;
String original, invertida = new String();
System.out.println("Introduzca la cadena: ");
original = scan.nextLine();
pos = original.length() - 1;
while (pos >= 0){
carter = original.charAt(pos);
invertida = invertida + carter;
pos--;
}
System.out.println("Cadena invertida: " + invertida);
}
}
| UTF-8 | Java | 834 | java | Tarea51.java | Java | [
{
"context": "\r\nimport java.util.Scanner;\r\n\r\n/**\r\n *\r\n * @author ABEL\r\n */\r\npublic class Tarea51 {\r\n\r\n /**\r\n * @pa",
"end": 267,
"score": 0.7850092053413391,
"start": 263,
"tag": "NAME",
"value": "ABEL"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tarea5.pkg1;
import java.util.Scanner;
/**
*
* @author ABEL
*/
public class Tarea51 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int pos;
char carter;
String original, invertida = new String();
System.out.println("Introduzca la cadena: ");
original = scan.nextLine();
pos = original.length() - 1;
while (pos >= 0){
carter = original.charAt(pos);
invertida = invertida + carter;
pos--;
}
System.out.println("Cadena invertida: " + invertida);
}
}
| 834 | 0.615108 | 0.607914 | 35 | 21.828571 | 20.717812 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.257143 | false | false | 4 |
9e0099d6acf60ad62ec260c24c357764590c12d3 | 9,131,100,513,991 | a02a1ea21002520c826c1115944a314d2422ccae | /examples/B6.JideTabbedPane/JideTabbedPaneDemo.java | 1871eb34cdbc8b5c250d4714284c4f40279597b3 | [] | no_license | opticyclic/jide-examples | https://github.com/opticyclic/jide-examples | 0d9bc158a58ff41b67395b795e2e5acd6f09aa72 | 5a1520384c164272e531aff35389f249fbac0b2c | refs/heads/master | 2023-08-14T23:17:12.862000 | 2021-10-09T08:40:56 | 2021-10-09T08:40:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* @(#)JideTabbedPaneDemo.java
*
* Copyright 2002 JIDE Software Inc. All rights reserved.
*/
import com.jidesoft.dialog.JideOptionPane;
import com.jidesoft.icons.IconsFactory;
import com.jidesoft.icons.JideIconsFactory;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.UIDefaultsLookup;
import com.jidesoft.swing.JideBoxLayout;
import com.jidesoft.swing.JideTabbedPane;
import com.jidesoft.swing.TabEditingValidator;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/**
* Demoed Component: JideTabbedPane <br> Required jar files: jide-common.jar <br> Required L&F: Jide L&F extension
* required
*/
public class JideTabbedPaneDemo extends AbstractDemo {
private static final long serialVersionUID = 9174217322756338307L;
private static JideTabbedPane _tabbedPane;
private static boolean _allowDuplicateTabNames = false;
static JideTabbedPaneDemo demo = new JideTabbedPaneDemo();
private static JPanel _panel;
private final String WIN2K_COLOR_THEME = "Win2K";
private final String OFFICE2003_COLOR_THEME = "Office2003";
private final String VSNET_COLOR_THEME = "Vsnet";
private final String WINXP_COLOR_THEME = "WinXP";
public JideTabbedPaneDemo() {
}
public String getName() {
return "JideTabbedPane Demo";
}
public String getProduct() {
return PRODUCT_NAME_COMMON;
}
@Override
public String getDescription() {
return "JideTabbedPane is an extended version JTabbedPane. The additional features are \n" +
"1. Has an option to hide the tab area if there is only one component in a tabbed pane\n" +
"2. Has an option to shrink the tab width so that all tabs can always fit in one row\n" +
"3. Has an option to show scroll left and scroll right buttons and a close button in the right corner of the tab area\n" +
"4. Has an option to show a close button on tab\n" +
"5. Supports in-placing tab editing. Mouse double clicks on tab to start editing\n" +
"6. Supports various LookAndFeels\n" +
"\n" +
"Demoed classes:\n" +
"com.jidesoft.swing.JideTabbedPane\n";
}
public Component getDemoPanel() {
_panel = new JPanel(new BorderLayout());
_panel.setOpaque(true);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
_panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
_tabbedPane = createTabbedPane();
_panel.add(_tabbedPane, BorderLayout.CENTER);
return _panel;
}
@Override
public String getDemoFolder() {
return "B6.JideTabbedPane";
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
showAsFrame(new JideTabbedPaneDemo());
}
});
}
@Override
public Component getOptionsPanel() {
JPanel panel = new JPanel();
panel.setLayout(new JideBoxLayout(panel, BoxLayout.Y_AXIS, 2));
final JCheckBox show = new JCheckBox("Always show tab buttons");
show.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowTabButtons(show.isSelected());
}
});
final JCheckBox hide = new JCheckBox("Hidden tab Area if only one tab");
hide.setSelected(_tabbedPane.isHideOneTab());
hide.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setHideOneTab(hide.isSelected());
}
});
final JCheckBox showTab = new JCheckBox("Show tab area");
showTab.setSelected(_tabbedPane.isShowTabArea());
showTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowTabArea(showTab.isSelected());
}
});
final JCheckBox showTabContent = new JCheckBox("Show tab content");
showTabContent.setSelected(_tabbedPane.isShowTabContent());
showTabContent.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
boolean content = showTabContent.isSelected();
_tabbedPane.setShowTabContent(content);
if (content) {
_panel.add(_tabbedPane, BorderLayout.CENTER);
}
else {
_panel.add(_tabbedPane, BorderLayout.BEFORE_FIRST_LINE);
}
}
});
final JCheckBox useDefaultIcon = new JCheckBox("Show icons according to UIDefaults");
useDefaultIcon.setToolTipText("Show icons according to the value defined in UIDefaults \"JideTabbedPane.showIconOnTab\"");
final JCheckBox icon = new JCheckBox("Show Icons");
icon.setSelected(_tabbedPane.isShowIconsOnTab());
icon.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowIconsOnTab(icon.isSelected());
}
});
useDefaultIcon.setSelected(_tabbedPane.isUseDefaultShowIconsOnTab());
icon.setEnabled(!useDefaultIcon.isSelected());
useDefaultIcon.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setUseDefaultShowIconsOnTab(useDefaultIcon.isSelected());
icon.setEnabled(!useDefaultIcon.isSelected());
}
});
final JCheckBox showCloseButton = new JCheckBox("Show close buttons");
showCloseButton.setSelected(_tabbedPane.isShowCloseButton());
showCloseButton.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButton(showCloseButton.isSelected());
}
});
final JCheckBox useDefaultClose = new JCheckBox("Show close button according to UIDefaults");
useDefaultClose.setToolTipText("Show close button on tab according to the value defined in UIDefaults \"JideTabbedPane.showCloseButtonOnTab\"");
final JCheckBox close = new JCheckBox("Show a close button on tab");
close.setSelected(_tabbedPane.isShowCloseButtonOnTab());
useDefaultClose.setSelected(_tabbedPane.isUseDefaultShowCloseButtonOnTab());
close.setEnabled(!useDefaultClose.isSelected());
useDefaultClose.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setUseDefaultShowCloseButtonOnTab(useDefaultClose.isSelected());
close.setEnabled(!useDefaultClose.isSelected());
}
});
final JCheckBox closeOnSelectedTab = new JCheckBox("Show a close button on the selected tab only");
closeOnSelectedTab.setSelected(_tabbedPane.isShowCloseButtonOnSelectedTab());
closeOnSelectedTab.setEnabled(close.isSelected());
closeOnSelectedTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnSelectedTab(closeOnSelectedTab.isSelected());
SwingUtilities.updateComponentTreeUI(_tabbedPane);
}
});
final JCheckBox closeOnMouseOver = new JCheckBox("Show a close button on mouse over only");
closeOnMouseOver.setSelected(_tabbedPane.isShowCloseButtonOnMouseOver());
closeOnMouseOver.setEnabled(close.isSelected());
closeOnMouseOver.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnMouseOver(closeOnMouseOver.isSelected());
SwingUtilities.updateComponentTreeUI(_tabbedPane);
}
});
close.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnTab(close.isSelected());
closeOnSelectedTab.setEnabled(close.isSelected());
closeOnMouseOver.setEnabled(close.isSelected());
}
});
final JCheckBox toggleFirstTabClosable = new JCheckBox("The first tab is closable");
toggleFirstTabClosable.setSelected(_tabbedPane.isTabClosableAt(0));
toggleFirstTabClosable.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setTabClosableAt(0, toggleFirstTabClosable.isSelected());
}
});
final JCheckBox toggleMiddleMouseButtonCloseTab = new JCheckBox("Middle mouse button to close the tab");
toggleMiddleMouseButtonCloseTab.setSelected(_tabbedPane.isCloseTabOnMouseMiddleButton());
toggleMiddleMouseButtonCloseTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setCloseTabOnMouseMiddleButton(toggleMiddleMouseButtonCloseTab.isSelected());
}
});
final JCheckBox editing = new JCheckBox("Allow tab title editing");
editing.setSelected(_tabbedPane.isTabEditingAllowed());
editing.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setTabEditingAllowed(editing.isSelected());
}
});
final JCheckBox allowDuplicateTabNames = new JCheckBox("Allow duplicate tab titles");
allowDuplicateTabNames.setSelected(_tabbedPane.isTabEditingAllowed());
allowDuplicateTabNames.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_allowDuplicateTabNames = allowDuplicateTabNames.isSelected();
}
});
final JCheckBox bold = new JCheckBox("Bold the selected tab");
bold.setSelected(_tabbedPane.isBoldActiveTab());
bold.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setBoldActiveTab(bold.isSelected());
}
});
final JCheckBox scroll = new JCheckBox("Change the selected tab on mouse wheel");
scroll.setSelected(_tabbedPane.isScrollSelectedTabOnWheel());
scroll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setScrollSelectedTabOnWheel(scroll.isSelected());
}
});
final JCheckBox leading = new JCheckBox("Set a tab leading component");
leading.setSelected(false);
leading.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (leading.isSelected()) {
Component leadingComponent = new LabelUIResource(JideIconsFactory.getImageIcon(JideIconsFactory.JIDELOGO_SMALL2));
_tabbedPane.setTabLeadingComponent(leadingComponent);
}
else {
_tabbedPane.setTabLeadingComponent(null);
}
}
});
final JCheckBox trailing = new JCheckBox("Set a tab trailing component");
trailing.setSelected(false);
trailing.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (trailing.isSelected()) {
Component trailingComponent = new LabelUIResource(JideIconsFactory.getImageIcon(JideIconsFactory.JIDELOGO_SMALL));
_tabbedPane.setTabTrailingComponent(trailingComponent);
}
else {
_tabbedPane.setTabTrailingComponent(null);
}
}
});
JLabel shape = new JLabel("Tab Shape:");
shape.setDisplayedMnemonic('S');
// the comboBox of the shapes
String[] tabShapes = {
"Office2003",
"Windows",
"Vsnet",
"Vsnet (Rounded Corner)",
"Eclipse",
"Eclipse3x",
"Excel",
"Box",
"Flat",
"Flat (Rounded Corner)",
"Windows (Selected Only)"
};
final JComboBox shapeComboBox = new JComboBox(tabShapes);
shapeComboBox.setSelectedIndex(0);
shape.setLabelFor(shapeComboBox);
JLabel color = new JLabel("Color Theme:");
color.setDisplayedMnemonic('C');
//the comboBox of the color choose
String[] colorPhases = {WIN2K_COLOR_THEME, OFFICE2003_COLOR_THEME, WINXP_COLOR_THEME};
final JComboBox colorComboBox = new JComboBox(colorPhases);
colorComboBox.setSelectedIndex(1);
color.setLabelFor(colorComboBox);
shapeComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
Runnable runnable = new Runnable() {
public void run() {
int defaultStyle = LookAndFeelFactory.OFFICE2003_STYLE;
if (shapeComboBox.getSelectedIndex() == 0) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_OFFICE2003);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(1);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 1) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_WINDOWS);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(3);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 2) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_VSNET);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 3) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ROUNDED_VSNET);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 4) {
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE_STYLE);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ECLIPSE);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.setSelectedIndex(0);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 5) {
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE3X_STYLE);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ECLIPSE3X);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.setSelectedIndex(0);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 6) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_EXCEL);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 7) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_BOX);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 8) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_FLAT);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 9) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ROUNDED_FLAT);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 10) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_WINDOWS_SELECTED);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
SwingUtilities.updateComponentTreeUI(_tabbedPane.getTopLevelAncestor());
}
};
SwingUtilities.invokeLater(runnable);
}
});
final JCheckBox oneNoteColorCheckBox = new JCheckBox("OneNote Color");
oneNoteColorCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
_tabbedPane.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
}
else {
_tabbedPane.setTabColorProvider(null);
}
}
});
colorComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (WIN2K_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is default
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
}
else if (OFFICE2003_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is office2003
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_OFFICE2003);
}
else if (VSNET_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is visual studio
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
}
else if (WINXP_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is windows xp
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WINXP);
}
// oneNoteColorCheckBox.setEnabled(OFFICE2003_COLOR_THEME.equals(colorComboBox.getSelectedItem()));
}
});
JLabel lay = new JLabel("Layout:");
lay.setDisplayedMnemonic('L');
//the comboBox of the layout
String[] layPhases = {
"None",
"Fit",
"Fixed",
"Compressed"};
final JComboBox layoutComboBox = new JComboBox(layPhases);
layoutComboBox.setSelectedIndex(0);
lay.setLabelFor(layoutComboBox);
layoutComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (layoutComboBox.getSelectedIndex() == 0) {//LayOut Style is Auto Size
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_NONE);
}
else if (layoutComboBox.getSelectedIndex() == 1) {//LayOut Style is Size to Fix
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_FIT);
}
else if (layoutComboBox.getSelectedIndex() == 2) {//LayOut Style is Fix
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_FIXED);
}
else if (layoutComboBox.getSelectedIndex() == 3) {//LayOut Style is Compressed
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_COMPRESSED);
}
}
});
JLabel position = new JLabel("Tab Placement:");
position.setDisplayedMnemonic('P');
//the tabPlacement of the tabbedPane
String[] positionPhases = {
"Top",
"Bottom",
"Left",
"Right"};
final JComboBox positionComboBox = new JComboBox(positionPhases);
positionComboBox.setSelectedIndex(0);
position.setLabelFor(positionComboBox);
positionComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (positionComboBox.getSelectedIndex() == 0) {
_tabbedPane.setTabPlacement(JideTabbedPane.TOP);
}
else if (positionComboBox.getSelectedIndex() == 1) {
_tabbedPane.setTabPlacement(JideTabbedPane.BOTTOM);
}
else if (positionComboBox.getSelectedIndex() == 2) {
_tabbedPane.setTabPlacement(JideTabbedPane.LEFT);
}
else if (positionComboBox.getSelectedIndex() == 3) {
_tabbedPane.setTabPlacement(JideTabbedPane.RIGHT);
}
}
});
panel.add(shape);
panel.add(shapeComboBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(color);
panel.add(colorComboBox);
panel.add(oneNoteColorCheckBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(lay);
panel.add(layoutComboBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(position);
panel.add(positionComboBox);
panel.add(Box.createVerticalStrut(8), JideBoxLayout.FIX);
panel.add(new JLabel("More Options:"));
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(show);
panel.add(hide);
panel.add(showTab);
panel.add(showTabContent);
panel.add(useDefaultIcon);
panel.add(icon);
panel.add(bold);
panel.add(scroll);
panel.add(showCloseButton);
panel.add(useDefaultClose);
panel.add(close);
panel.add(closeOnSelectedTab);
panel.add(closeOnMouseOver);
panel.add(toggleFirstTabClosable);
panel.add(toggleMiddleMouseButtonCloseTab);
panel.add(editing);
panel.add(allowDuplicateTabNames);
panel.add(leading);
panel.add(trailing);
return panel;
}
private static JideTabbedPane createTabbedPane() {
final JideTabbedPane tabbedPane = new JideTabbedPane(JideTabbedPane.TOP);
tabbedPane.setOpaque(true);
final String[] titles = new String[]{
"Mail",
"Calendar",
"Contacts",
"Tasks",
"Notes",
"Folder List",
"Shortcuts",
"Journal"
};
final int[] mnemonics = new int[]{
KeyEvent.VK_M,
KeyEvent.VK_C,
KeyEvent.VK_O,
KeyEvent.VK_T,
KeyEvent.VK_N,
KeyEvent.VK_F,
KeyEvent.VK_S,
KeyEvent.VK_J
};
final ImageIcon[] icons = new ImageIcon[]{
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/email.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/calendar.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/contacts.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/tasks.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/notes.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/folder.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/shortcut.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/journal.gif")
};
for (int i = 0; i < titles.length; i++) {
JScrollPane scrollPane = new JScrollPane(new JTextArea());
scrollPane.setPreferredSize(new Dimension(530, 530));
tabbedPane.addTab(titles[i], icons[i], scrollPane);
tabbedPane.setMnemonicAt(i, mnemonics[i]);
}
tabbedPane.setEnabledAt(2, false);
tabbedPane.setTabEditingValidator(new TabEditingValidator() {
public boolean alertIfInvalid(int tabIndex, String tabText) {
if (tabText.trim().length() == 0) {
JideOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(tabbedPane), "'" + tabText + "' is an invalid name for a tab title.", "Invalid Tab Title", JideOptionPane.ERROR_MESSAGE, null);
return false;
}
if (_allowDuplicateTabNames)
return true;
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabText.trim().equalsIgnoreCase(tabbedPane.getDisplayTitleAt(i)) && i != tabbedPane.getSelectedIndex()) {
JideOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(tabbedPane), "There is already a tab with the title of '" + tabText + "'.", "Invalid Tab Title", JideOptionPane.ERROR_MESSAGE, null);
return false;
}
}
return true;
}
public boolean isValid(int tabIndex, String tabText) {
if (tabText.trim().length() == 0)
return false;
if (_allowDuplicateTabNames)
return true;
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabText.trim().equalsIgnoreCase(tabbedPane.getDisplayTitleAt(i)) && i != tabbedPane.getSelectedIndex()) {
return false;
}
}
return true;
}
public boolean shouldStartEdit(int tabIndex, MouseEvent event) {
return true;
}
});
return tabbedPane;
}
class LabelUIResource extends JLabel implements UIResource {
public LabelUIResource(String text) {
super(text);
}
public LabelUIResource(Icon image) {
super(image);
}
}
}
| UTF-8 | Java | 31,654 | java | JideTabbedPaneDemo.java | Java | [] | null | [] | /*
* @(#)JideTabbedPaneDemo.java
*
* Copyright 2002 JIDE Software Inc. All rights reserved.
*/
import com.jidesoft.dialog.JideOptionPane;
import com.jidesoft.icons.IconsFactory;
import com.jidesoft.icons.JideIconsFactory;
import com.jidesoft.plaf.LookAndFeelFactory;
import com.jidesoft.plaf.UIDefaultsLookup;
import com.jidesoft.swing.JideBoxLayout;
import com.jidesoft.swing.JideTabbedPane;
import com.jidesoft.swing.TabEditingValidator;
import javax.swing.*;
import javax.swing.plaf.UIResource;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
/**
* Demoed Component: JideTabbedPane <br> Required jar files: jide-common.jar <br> Required L&F: Jide L&F extension
* required
*/
public class JideTabbedPaneDemo extends AbstractDemo {
private static final long serialVersionUID = 9174217322756338307L;
private static JideTabbedPane _tabbedPane;
private static boolean _allowDuplicateTabNames = false;
static JideTabbedPaneDemo demo = new JideTabbedPaneDemo();
private static JPanel _panel;
private final String WIN2K_COLOR_THEME = "Win2K";
private final String OFFICE2003_COLOR_THEME = "Office2003";
private final String VSNET_COLOR_THEME = "Vsnet";
private final String WINXP_COLOR_THEME = "WinXP";
public JideTabbedPaneDemo() {
}
public String getName() {
return "JideTabbedPane Demo";
}
public String getProduct() {
return PRODUCT_NAME_COMMON;
}
@Override
public String getDescription() {
return "JideTabbedPane is an extended version JTabbedPane. The additional features are \n" +
"1. Has an option to hide the tab area if there is only one component in a tabbed pane\n" +
"2. Has an option to shrink the tab width so that all tabs can always fit in one row\n" +
"3. Has an option to show scroll left and scroll right buttons and a close button in the right corner of the tab area\n" +
"4. Has an option to show a close button on tab\n" +
"5. Supports in-placing tab editing. Mouse double clicks on tab to start editing\n" +
"6. Supports various LookAndFeels\n" +
"\n" +
"Demoed classes:\n" +
"com.jidesoft.swing.JideTabbedPane\n";
}
public Component getDemoPanel() {
_panel = new JPanel(new BorderLayout());
_panel.setOpaque(true);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
_panel.setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6));
_tabbedPane = createTabbedPane();
_panel.add(_tabbedPane, BorderLayout.CENTER);
return _panel;
}
@Override
public String getDemoFolder() {
return "B6.JideTabbedPane";
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
LookAndFeelFactory.installDefaultLookAndFeelAndExtension();
showAsFrame(new JideTabbedPaneDemo());
}
});
}
@Override
public Component getOptionsPanel() {
JPanel panel = new JPanel();
panel.setLayout(new JideBoxLayout(panel, BoxLayout.Y_AXIS, 2));
final JCheckBox show = new JCheckBox("Always show tab buttons");
show.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowTabButtons(show.isSelected());
}
});
final JCheckBox hide = new JCheckBox("Hidden tab Area if only one tab");
hide.setSelected(_tabbedPane.isHideOneTab());
hide.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setHideOneTab(hide.isSelected());
}
});
final JCheckBox showTab = new JCheckBox("Show tab area");
showTab.setSelected(_tabbedPane.isShowTabArea());
showTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowTabArea(showTab.isSelected());
}
});
final JCheckBox showTabContent = new JCheckBox("Show tab content");
showTabContent.setSelected(_tabbedPane.isShowTabContent());
showTabContent.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
boolean content = showTabContent.isSelected();
_tabbedPane.setShowTabContent(content);
if (content) {
_panel.add(_tabbedPane, BorderLayout.CENTER);
}
else {
_panel.add(_tabbedPane, BorderLayout.BEFORE_FIRST_LINE);
}
}
});
final JCheckBox useDefaultIcon = new JCheckBox("Show icons according to UIDefaults");
useDefaultIcon.setToolTipText("Show icons according to the value defined in UIDefaults \"JideTabbedPane.showIconOnTab\"");
final JCheckBox icon = new JCheckBox("Show Icons");
icon.setSelected(_tabbedPane.isShowIconsOnTab());
icon.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowIconsOnTab(icon.isSelected());
}
});
useDefaultIcon.setSelected(_tabbedPane.isUseDefaultShowIconsOnTab());
icon.setEnabled(!useDefaultIcon.isSelected());
useDefaultIcon.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setUseDefaultShowIconsOnTab(useDefaultIcon.isSelected());
icon.setEnabled(!useDefaultIcon.isSelected());
}
});
final JCheckBox showCloseButton = new JCheckBox("Show close buttons");
showCloseButton.setSelected(_tabbedPane.isShowCloseButton());
showCloseButton.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButton(showCloseButton.isSelected());
}
});
final JCheckBox useDefaultClose = new JCheckBox("Show close button according to UIDefaults");
useDefaultClose.setToolTipText("Show close button on tab according to the value defined in UIDefaults \"JideTabbedPane.showCloseButtonOnTab\"");
final JCheckBox close = new JCheckBox("Show a close button on tab");
close.setSelected(_tabbedPane.isShowCloseButtonOnTab());
useDefaultClose.setSelected(_tabbedPane.isUseDefaultShowCloseButtonOnTab());
close.setEnabled(!useDefaultClose.isSelected());
useDefaultClose.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setUseDefaultShowCloseButtonOnTab(useDefaultClose.isSelected());
close.setEnabled(!useDefaultClose.isSelected());
}
});
final JCheckBox closeOnSelectedTab = new JCheckBox("Show a close button on the selected tab only");
closeOnSelectedTab.setSelected(_tabbedPane.isShowCloseButtonOnSelectedTab());
closeOnSelectedTab.setEnabled(close.isSelected());
closeOnSelectedTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnSelectedTab(closeOnSelectedTab.isSelected());
SwingUtilities.updateComponentTreeUI(_tabbedPane);
}
});
final JCheckBox closeOnMouseOver = new JCheckBox("Show a close button on mouse over only");
closeOnMouseOver.setSelected(_tabbedPane.isShowCloseButtonOnMouseOver());
closeOnMouseOver.setEnabled(close.isSelected());
closeOnMouseOver.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnMouseOver(closeOnMouseOver.isSelected());
SwingUtilities.updateComponentTreeUI(_tabbedPane);
}
});
close.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setShowCloseButtonOnTab(close.isSelected());
closeOnSelectedTab.setEnabled(close.isSelected());
closeOnMouseOver.setEnabled(close.isSelected());
}
});
final JCheckBox toggleFirstTabClosable = new JCheckBox("The first tab is closable");
toggleFirstTabClosable.setSelected(_tabbedPane.isTabClosableAt(0));
toggleFirstTabClosable.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setTabClosableAt(0, toggleFirstTabClosable.isSelected());
}
});
final JCheckBox toggleMiddleMouseButtonCloseTab = new JCheckBox("Middle mouse button to close the tab");
toggleMiddleMouseButtonCloseTab.setSelected(_tabbedPane.isCloseTabOnMouseMiddleButton());
toggleMiddleMouseButtonCloseTab.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setCloseTabOnMouseMiddleButton(toggleMiddleMouseButtonCloseTab.isSelected());
}
});
final JCheckBox editing = new JCheckBox("Allow tab title editing");
editing.setSelected(_tabbedPane.isTabEditingAllowed());
editing.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setTabEditingAllowed(editing.isSelected());
}
});
final JCheckBox allowDuplicateTabNames = new JCheckBox("Allow duplicate tab titles");
allowDuplicateTabNames.setSelected(_tabbedPane.isTabEditingAllowed());
allowDuplicateTabNames.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_allowDuplicateTabNames = allowDuplicateTabNames.isSelected();
}
});
final JCheckBox bold = new JCheckBox("Bold the selected tab");
bold.setSelected(_tabbedPane.isBoldActiveTab());
bold.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setBoldActiveTab(bold.isSelected());
}
});
final JCheckBox scroll = new JCheckBox("Change the selected tab on mouse wheel");
scroll.setSelected(_tabbedPane.isScrollSelectedTabOnWheel());
scroll.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
_tabbedPane.setScrollSelectedTabOnWheel(scroll.isSelected());
}
});
final JCheckBox leading = new JCheckBox("Set a tab leading component");
leading.setSelected(false);
leading.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (leading.isSelected()) {
Component leadingComponent = new LabelUIResource(JideIconsFactory.getImageIcon(JideIconsFactory.JIDELOGO_SMALL2));
_tabbedPane.setTabLeadingComponent(leadingComponent);
}
else {
_tabbedPane.setTabLeadingComponent(null);
}
}
});
final JCheckBox trailing = new JCheckBox("Set a tab trailing component");
trailing.setSelected(false);
trailing.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (trailing.isSelected()) {
Component trailingComponent = new LabelUIResource(JideIconsFactory.getImageIcon(JideIconsFactory.JIDELOGO_SMALL));
_tabbedPane.setTabTrailingComponent(trailingComponent);
}
else {
_tabbedPane.setTabTrailingComponent(null);
}
}
});
JLabel shape = new JLabel("Tab Shape:");
shape.setDisplayedMnemonic('S');
// the comboBox of the shapes
String[] tabShapes = {
"Office2003",
"Windows",
"Vsnet",
"Vsnet (Rounded Corner)",
"Eclipse",
"Eclipse3x",
"Excel",
"Box",
"Flat",
"Flat (Rounded Corner)",
"Windows (Selected Only)"
};
final JComboBox shapeComboBox = new JComboBox(tabShapes);
shapeComboBox.setSelectedIndex(0);
shape.setLabelFor(shapeComboBox);
JLabel color = new JLabel("Color Theme:");
color.setDisplayedMnemonic('C');
//the comboBox of the color choose
String[] colorPhases = {WIN2K_COLOR_THEME, OFFICE2003_COLOR_THEME, WINXP_COLOR_THEME};
final JComboBox colorComboBox = new JComboBox(colorPhases);
colorComboBox.setSelectedIndex(1);
color.setLabelFor(colorComboBox);
shapeComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
Runnable runnable = new Runnable() {
public void run() {
int defaultStyle = LookAndFeelFactory.OFFICE2003_STYLE;
if (shapeComboBox.getSelectedIndex() == 0) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_OFFICE2003);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_OFFICE2003);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(1);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 1) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_WINDOWS);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(3);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 2) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_VSNET);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 3) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ROUNDED_VSNET);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 4) {
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE_STYLE);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ECLIPSE);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.setSelectedIndex(0);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 5) {
LookAndFeelFactory.installJideExtension(LookAndFeelFactory.ECLIPSE3X_STYLE);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ECLIPSE3X);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.setSelectedIndex(0);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 6) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_EXCEL);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 7) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_BOX);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 8) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_FLAT);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 9) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_ROUNDED_FLAT);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(VSNET_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
else if (shapeComboBox.getSelectedIndex() == 10) {
LookAndFeelFactory.installJideExtension(defaultStyle);
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
_tabbedPane.setTabShape(JideTabbedPane.SHAPE_WINDOWS_SELECTED);
colorComboBox.removeAllItems();
colorComboBox.addItem(WIN2K_COLOR_THEME);
colorComboBox.addItem(OFFICE2003_COLOR_THEME);
colorComboBox.addItem(WINXP_COLOR_THEME);
colorComboBox.setSelectedIndex(2);
_panel.setBackground(UIDefaultsLookup.getColor("control"));
}
SwingUtilities.updateComponentTreeUI(_tabbedPane.getTopLevelAncestor());
}
};
SwingUtilities.invokeLater(runnable);
}
});
final JCheckBox oneNoteColorCheckBox = new JCheckBox("OneNote Color");
oneNoteColorCheckBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
_tabbedPane.setTabColorProvider(JideTabbedPane.ONENOTE_COLOR_PROVIDER);
}
else {
_tabbedPane.setTabColorProvider(null);
}
}
});
colorComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (WIN2K_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is default
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WIN2K);
}
else if (OFFICE2003_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is office2003
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_OFFICE2003);
}
else if (VSNET_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is visual studio
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_VSNET);
}
else if (WINXP_COLOR_THEME.equals(colorComboBox.getSelectedItem())) {//color set is windows xp
_tabbedPane.setColorTheme(JideTabbedPane.COLOR_THEME_WINXP);
}
// oneNoteColorCheckBox.setEnabled(OFFICE2003_COLOR_THEME.equals(colorComboBox.getSelectedItem()));
}
});
JLabel lay = new JLabel("Layout:");
lay.setDisplayedMnemonic('L');
//the comboBox of the layout
String[] layPhases = {
"None",
"Fit",
"Fixed",
"Compressed"};
final JComboBox layoutComboBox = new JComboBox(layPhases);
layoutComboBox.setSelectedIndex(0);
lay.setLabelFor(layoutComboBox);
layoutComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (layoutComboBox.getSelectedIndex() == 0) {//LayOut Style is Auto Size
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_NONE);
}
else if (layoutComboBox.getSelectedIndex() == 1) {//LayOut Style is Size to Fix
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_FIT);
}
else if (layoutComboBox.getSelectedIndex() == 2) {//LayOut Style is Fix
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_FIXED);
}
else if (layoutComboBox.getSelectedIndex() == 3) {//LayOut Style is Compressed
_tabbedPane.setTabResizeMode(JideTabbedPane.RESIZE_MODE_COMPRESSED);
}
}
});
JLabel position = new JLabel("Tab Placement:");
position.setDisplayedMnemonic('P');
//the tabPlacement of the tabbedPane
String[] positionPhases = {
"Top",
"Bottom",
"Left",
"Right"};
final JComboBox positionComboBox = new JComboBox(positionPhases);
positionComboBox.setSelectedIndex(0);
position.setLabelFor(positionComboBox);
positionComboBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (positionComboBox.getSelectedIndex() == 0) {
_tabbedPane.setTabPlacement(JideTabbedPane.TOP);
}
else if (positionComboBox.getSelectedIndex() == 1) {
_tabbedPane.setTabPlacement(JideTabbedPane.BOTTOM);
}
else if (positionComboBox.getSelectedIndex() == 2) {
_tabbedPane.setTabPlacement(JideTabbedPane.LEFT);
}
else if (positionComboBox.getSelectedIndex() == 3) {
_tabbedPane.setTabPlacement(JideTabbedPane.RIGHT);
}
}
});
panel.add(shape);
panel.add(shapeComboBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(color);
panel.add(colorComboBox);
panel.add(oneNoteColorCheckBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(lay);
panel.add(layoutComboBox);
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(position);
panel.add(positionComboBox);
panel.add(Box.createVerticalStrut(8), JideBoxLayout.FIX);
panel.add(new JLabel("More Options:"));
panel.add(Box.createVerticalStrut(4), JideBoxLayout.FIX);
panel.add(show);
panel.add(hide);
panel.add(showTab);
panel.add(showTabContent);
panel.add(useDefaultIcon);
panel.add(icon);
panel.add(bold);
panel.add(scroll);
panel.add(showCloseButton);
panel.add(useDefaultClose);
panel.add(close);
panel.add(closeOnSelectedTab);
panel.add(closeOnMouseOver);
panel.add(toggleFirstTabClosable);
panel.add(toggleMiddleMouseButtonCloseTab);
panel.add(editing);
panel.add(allowDuplicateTabNames);
panel.add(leading);
panel.add(trailing);
return panel;
}
private static JideTabbedPane createTabbedPane() {
final JideTabbedPane tabbedPane = new JideTabbedPane(JideTabbedPane.TOP);
tabbedPane.setOpaque(true);
final String[] titles = new String[]{
"Mail",
"Calendar",
"Contacts",
"Tasks",
"Notes",
"Folder List",
"Shortcuts",
"Journal"
};
final int[] mnemonics = new int[]{
KeyEvent.VK_M,
KeyEvent.VK_C,
KeyEvent.VK_O,
KeyEvent.VK_T,
KeyEvent.VK_N,
KeyEvent.VK_F,
KeyEvent.VK_S,
KeyEvent.VK_J
};
final ImageIcon[] icons = new ImageIcon[]{
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/email.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/calendar.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/contacts.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/tasks.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/notes.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/folder.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/shortcut.gif"),
IconsFactory.getImageIcon(JideTabbedPaneDemo.class, "icons/journal.gif")
};
for (int i = 0; i < titles.length; i++) {
JScrollPane scrollPane = new JScrollPane(new JTextArea());
scrollPane.setPreferredSize(new Dimension(530, 530));
tabbedPane.addTab(titles[i], icons[i], scrollPane);
tabbedPane.setMnemonicAt(i, mnemonics[i]);
}
tabbedPane.setEnabledAt(2, false);
tabbedPane.setTabEditingValidator(new TabEditingValidator() {
public boolean alertIfInvalid(int tabIndex, String tabText) {
if (tabText.trim().length() == 0) {
JideOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(tabbedPane), "'" + tabText + "' is an invalid name for a tab title.", "Invalid Tab Title", JideOptionPane.ERROR_MESSAGE, null);
return false;
}
if (_allowDuplicateTabNames)
return true;
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabText.trim().equalsIgnoreCase(tabbedPane.getDisplayTitleAt(i)) && i != tabbedPane.getSelectedIndex()) {
JideOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(tabbedPane), "There is already a tab with the title of '" + tabText + "'.", "Invalid Tab Title", JideOptionPane.ERROR_MESSAGE, null);
return false;
}
}
return true;
}
public boolean isValid(int tabIndex, String tabText) {
if (tabText.trim().length() == 0)
return false;
if (_allowDuplicateTabNames)
return true;
for (int i = 0; i < tabbedPane.getTabCount(); i++) {
if (tabText.trim().equalsIgnoreCase(tabbedPane.getDisplayTitleAt(i)) && i != tabbedPane.getSelectedIndex()) {
return false;
}
}
return true;
}
public boolean shouldStartEdit(int tabIndex, MouseEvent event) {
return true;
}
});
return tabbedPane;
}
class LabelUIResource extends JLabel implements UIResource {
public LabelUIResource(String text) {
super(text);
}
public LabelUIResource(Icon image) {
super(image);
}
}
}
| 31,654 | 0.582454 | 0.576357 | 686 | 45.142857 | 32.806393 | 223 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.618076 | false | false | 4 |
6240cfc0c7b4eec2e2b1a1897bde164eedd8695e | 36,249,523,998,280 | 14746c4b8511abe301fd470a152de627327fe720 | /soroush-android-1.10.0_source_from_JADX/mobi/mmdt/ott/lib_webservicescomponent/retrofit/webservices/capi/Conversation/update/C5808a.java | 70e09a18b64293bf26ac60087be13a324d62082d | [] | no_license | maasalan/soroush-messenger-apis | https://github.com/maasalan/soroush-messenger-apis | 3005c4a43123c6543dbcca3dd9084f95e934a6f4 | 29867bf53a113a30b1aa36719b1c7899b991d0a8 | refs/heads/master | 2020-03-21T21:23:20.693000 | 2018-06-28T19:57:01 | 2018-06-28T19:57:01 | 139,060,676 | 3 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.capi.Conversation.update;
import android.content.Context;
import java.util.List;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.retrofit_implementation.C2566a;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.retrofit_implementation.C2567b;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.base.data_models.BaseResponse;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.capi.base.ConversaionList;
public final class C5808a extends C2566a {
private ConversationListUpdateRequest f15971a;
public C5808a(String str, Long l, List<ConversaionList> list) {
this.f15971a = new ConversationListUpdateRequest(str, l, list);
}
public final ConversationListUpdateResponse m13013a(Context context) {
return (ConversationListUpdateResponse) registeredSend(context, C2567b.m7018a().m7022a(context).getconversationListUpdate(this.f15971a), this.f15971a);
}
public final /* synthetic */ BaseResponse sendRequest(Context context) {
return m13013a(context);
}
}
| UTF-8 | Java | 1,119 | java | C5808a.java | Java | [] | null | [] | package mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.capi.Conversation.update;
import android.content.Context;
import java.util.List;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.retrofit_implementation.C2566a;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.retrofit_implementation.C2567b;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.base.data_models.BaseResponse;
import mobi.mmdt.ott.lib_webservicescomponent.retrofit.webservices.capi.base.ConversaionList;
public final class C5808a extends C2566a {
private ConversationListUpdateRequest f15971a;
public C5808a(String str, Long l, List<ConversaionList> list) {
this.f15971a = new ConversationListUpdateRequest(str, l, list);
}
public final ConversationListUpdateResponse m13013a(Context context) {
return (ConversationListUpdateResponse) registeredSend(context, C2567b.m7018a().m7022a(context).getconversationListUpdate(this.f15971a), this.f15971a);
}
public final /* synthetic */ BaseResponse sendRequest(Context context) {
return m13013a(context);
}
}
| 1,119 | 0.79714 | 0.741734 | 24 | 45.625 | 43.017258 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.708333 | false | false | 4 |
924eb1885a3db8e045a8080be77be4c0651d7155 | 35,115,652,640,129 | 8301d4a0f223ea7585a2600eda64ceef6bba0f97 | /igor-monitor-jenkins/src/main/java/com/netflix/spinnaker/igor/jenkins/client/model/Branch.java | 8ad3725d4ce6226ae8bee026328351093907ce57 | [
"Apache-2.0"
] | permissive | gal-yardeni/igor | https://github.com/gal-yardeni/igor | c384b1b6b30428ea1cb33c5643a9f77e24eedacc | 3368f234ace6c46431349a18e64e94472db48029 | refs/heads/master | 2021-01-07T14:59:29.141000 | 2020-02-18T20:47:14 | 2020-02-18T20:47:14 | 241,734,743 | 0 | 0 | Apache-2.0 | true | 2020-02-19T21:55:06 | 2020-02-19T21:55:05 | 2020-02-18T20:47:18 | 2020-02-19T19:47:21 | 1,885 | 0 | 0 | 0 | null | false | false | /*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.jenkins.client.model;
import javax.xml.bind.annotation.XmlElement;
public class Branch {
@XmlElement(required = false)
private String name;
@XmlElement(required = false, name = "SHA1")
private String sha1;
/**
* Given a full branch reference (e.g. {@code origin/master}), this method will return the branch
* name without the repository (e.g. {@code master}).
*/
public String getSimpleBranchName() {
if (name == null) {
return null;
}
String[] segments = name.split("/");
return segments[segments.length - 1];
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSha1() {
return sha1;
}
public void setSha1(String sha1) {
this.sha1 = sha1;
}
}
| UTF-8 | Java | 1,423 | java | Branch.java | Java | [
{
"context": "/*\n * Copyright 2020 Netflix, Inc.\n *\n * Licensed under the Apache License",
"end": 24,
"score": 0.796931266784668,
"start": 21,
"tag": "NAME",
"value": "Net"
}
] | null | [] | /*
* Copyright 2020 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.netflix.spinnaker.igor.jenkins.client.model;
import javax.xml.bind.annotation.XmlElement;
public class Branch {
@XmlElement(required = false)
private String name;
@XmlElement(required = false, name = "SHA1")
private String sha1;
/**
* Given a full branch reference (e.g. {@code origin/master}), this method will return the branch
* name without the repository (e.g. {@code master}).
*/
public String getSimpleBranchName() {
if (name == null) {
return null;
}
String[] segments = name.split("/");
return segments[segments.length - 1];
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSha1() {
return sha1;
}
public void setSha1(String sha1) {
this.sha1 = sha1;
}
}
| 1,423 | 0.686578 | 0.674631 | 55 | 24.872726 | 25.052711 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.345455 | false | false | 4 |
3f027b6c8da59b46e10ec3e17b680ef42d358e1a | 34,943,853,942,733 | 32b72e1dc8b6ee1be2e80bb70a03a021c83db550 | /ast_results/AnySoftKeyboard_AnySoftKeyboard/app/src/test/java/com/anysoftkeyboard/ui/settings/MainSettingsActivityTest.java | a925673207037f6ff369392aab89a836e27ebf44 | [] | no_license | cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | https://github.com/cmFodWx5YWRhdjEyMTA5/smell-and-machine-learning | d90c41a17e88fcd99d543124eeb6e93f9133cb4a | 0564143d92f8024ff5fa6b659c2baebf827582b1 | refs/heads/master | 2020-07-13T13:53:40.297000 | 2019-01-11T11:51:18 | 2019-01-11T11:51:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | // isComment
package com.anysoftkeyboard.ui.settings;
import static android.Manifest.permission.READ_CONTACTS;
import static android.content.Intent.ACTION_VIEW;
import static com.anysoftkeyboard.PermissionsRequestCodes.CONTACTS;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import android.Manifest;
import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import com.anysoftkeyboard.AnySoftKeyboardRobolectricTestRunner;
import com.anysoftkeyboard.PermissionsRequestCodes;
import com.anysoftkeyboard.quicktextkeys.ui.QuickTextKeysBrowseFragment;
import com.menny.android.anysoftkeyboard.R;
import net.evendanan.chauffeur.lib.permissions.PermissionsFragmentChauffeurActivity;
import net.evendanan.chauffeur.lib.permissions.PermissionsRequest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.Shadows;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import androidx.test.core.app.ApplicationProvider;
@RunWith(AnySoftKeyboardRobolectricTestRunner.class)
public class isClassOrIsInterface {
private static Intent isMethod(String isParameter) {
Intent isVariable = new Intent(isNameExpr, null, isMethod(), MainSettingsActivity.class);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, isNameExpr);
return isNameExpr;
}
@Test(expected = IllegalArgumentException.class)
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class);
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, new Intent(isMethod(), MainSettingsActivity.class));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class);
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof MainFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof LanguageSettingsFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof UserInterfaceSettingsFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof QuickTextKeysBrowseFragment);
/*isComment*/
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof KeyboardAddOnBrowserFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof KeyboardThemeSelectorFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof GesturesSettingsFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof QuickTextKeysBrowseFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isMethod(), isNameExpr.isFieldAccessExpr.isMethod());
isNameExpr.isMethod(new String[] { isNameExpr.isFieldAccessExpr.isFieldAccessExpr }, isNameExpr.isFieldAccessExpr.isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
PermissionsRequest isVariable = isNameExpr.isFieldAccessExpr;
isNameExpr.isMethod(isNameExpr);
isNameExpr.isFieldAccessExpr = null;
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
PermissionsRequest isVariable = isNameExpr.isFieldAccessExpr;
isNameExpr.isMethod(isNameExpr);
isNameExpr.isFieldAccessExpr = null;
isNameExpr.isMethod(new String[isIntegerConstant], new String[] { isNameExpr.isFieldAccessExpr.isFieldAccessExpr }, new String[isIntegerConstant]);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
}
public static class isClassOrIsInterface extends MainSettingsActivity {
public static PermissionsRequest isVariable;
@NonNull
@Override
protected PermissionsRequest isMethod(int isParameter, @NonNull String[] isParameter, @NonNull Intent isParameter) {
return isNameExpr = super.isMethod(isNameExpr, isNameExpr, isNameExpr);
}
}
}
| UTF-8 | Java | 11,565 | java | MainSettingsActivityTest.java | Java | [] | null | [] | // isComment
package com.anysoftkeyboard.ui.settings;
import static android.Manifest.permission.READ_CONTACTS;
import static android.content.Intent.ACTION_VIEW;
import static com.anysoftkeyboard.PermissionsRequestCodes.CONTACTS;
import static androidx.test.core.app.ApplicationProvider.getApplicationContext;
import android.Manifest;
import android.app.Application;
import android.content.Intent;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.design.widget.BottomNavigationView;
import android.support.v4.app.Fragment;
import com.anysoftkeyboard.AnySoftKeyboardRobolectricTestRunner;
import com.anysoftkeyboard.PermissionsRequestCodes;
import com.anysoftkeyboard.quicktextkeys.ui.QuickTextKeysBrowseFragment;
import com.menny.android.anysoftkeyboard.R;
import net.evendanan.chauffeur.lib.permissions.PermissionsFragmentChauffeurActivity;
import net.evendanan.chauffeur.lib.permissions.PermissionsRequest;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.Robolectric;
import org.robolectric.Shadows;
import org.robolectric.android.controller.ActivityController;
import org.robolectric.annotation.Config;
import androidx.test.core.app.ApplicationProvider;
@RunWith(AnySoftKeyboardRobolectricTestRunner.class)
public class isClassOrIsInterface {
private static Intent isMethod(String isParameter) {
Intent isVariable = new Intent(isNameExpr, null, isMethod(), MainSettingsActivity.class);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr, isNameExpr);
return isNameExpr;
}
@Test(expected = IllegalArgumentException.class)
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class);
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, new Intent(isMethod(), MainSettingsActivity.class));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class);
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof MainFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof LanguageSettingsFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof UserInterfaceSettingsFragment);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof QuickTextKeysBrowseFragment);
/*isComment*/
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr) instanceof MainFragment);
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof KeyboardAddOnBrowserFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof KeyboardThemeSelectorFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof GesturesSettingsFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
public void isMethod() {
ActivityController<MainSettingsActivity> isVariable = isNameExpr.isMethod(MainSettingsActivity.class, isMethod("isStringConstant"));
isNameExpr.isMethod();
MainSettingsActivity isVariable = isNameExpr.isMethod();
Fragment isVariable = isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr);
isNameExpr.isMethod(isNameExpr instanceof QuickTextKeysBrowseFragment);
BottomNavigationView isVariable = (BottomNavigationView) isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr, isNameExpr.isMethod());
isNameExpr.isMethod(isNameExpr.isMethod().isMethod(isNameExpr.isFieldAccessExpr));
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr.isMethod(), isNameExpr.isFieldAccessExpr.isMethod());
isNameExpr.isMethod(new String[] { isNameExpr.isFieldAccessExpr.isFieldAccessExpr }, isNameExpr.isFieldAccessExpr.isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
PermissionsRequest isVariable = isNameExpr.isFieldAccessExpr;
isNameExpr.isMethod(isNameExpr);
isNameExpr.isFieldAccessExpr = null;
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
PermissionsRequest isVariable = isNameExpr.isFieldAccessExpr;
isNameExpr.isMethod(isNameExpr);
isNameExpr.isFieldAccessExpr = null;
isNameExpr.isMethod(new String[isIntegerConstant], new String[] { isNameExpr.isFieldAccessExpr.isFieldAccessExpr }, new String[isIntegerConstant]);
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
isNameExpr.isMethod(isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod());
}
@Test
@Config(sdk = isNameExpr.isFieldAccessExpr.isFieldAccessExpr)
public void isMethod() {
isNameExpr.isMethod((Application) isNameExpr.isMethod()).isMethod(isNameExpr.isFieldAccessExpr.isFieldAccessExpr);
Intent isVariable = isNameExpr.isMethod(isMethod(), MyMainSettingsActivity.class, isNameExpr.isMethod(), isNameExpr);
isNameExpr.isFieldAccessExpr = null;
ActivityController<MyMainSettingsActivity> isVariable = isNameExpr.isMethod(MyMainSettingsActivity.class, isNameExpr);
isNameExpr.isMethod();
isNameExpr.isMethod(isNameExpr.isFieldAccessExpr);
}
public static class isClassOrIsInterface extends MainSettingsActivity {
public static PermissionsRequest isVariable;
@NonNull
@Override
protected PermissionsRequest isMethod(int isParameter, @NonNull String[] isParameter, @NonNull Intent isParameter) {
return isNameExpr = super.isMethod(isNameExpr, isNameExpr, isNameExpr);
}
}
}
| 11,565 | 0.773973 | 0.773887 | 202 | 56.252476 | 44.566566 | 162 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.846535 | false | false | 4 |
eab8201592fccd606eaf239a0b3ed83125b7ec5a | 36,318,243,479,173 | 6509b1539884c3ce7767463094b26748748a160e | /src/test/java/com/automation/pagelib/Recharge.java | 5fe27db202e74845f12a86dfc6a5eb3593cf7be5 | [] | no_license | agajendra1992/Undotres_Assignment_New | https://github.com/agajendra1992/Undotres_Assignment_New | fb42dc14cdd01dd688fb7c634b8b6a0572492f77 | d1064f2ad8a9c136a92afa078e675f93a2251515 | refs/heads/main | 2023-07-12T16:34:57.502000 | 2021-08-16T17:51:01 | 2021-08-16T17:51:01 | 396,904,477 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.automation.pagelib;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.openqa.selenium.WebElement;
import com.automation.testbase.TestBase;
public class Recharge extends TestBase {
private static Logger logger = LogManager.getLogger(Recharge.class);
public void operatorClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Operaton option");
getWebElement("app.operator").click();
}
public void operatorselect(String Operator) throws Exception {
logger.info("Select the Operator");
for (int i = 0; i < getWebElements("app.operatorselect").size(); i++) {
if (getWebElements("app.operatorselect").get(i).getText().equalsIgnoreCase(Operator)) {
getWebElements("app.operatorselect").get(i).click();
}
}
}
public void setMobileNumber(String Name) throws Exception {
logger.info("Enter the Mobile Number");
getWebElement("app.mobilenumber").clear();
getWebElement("app.mobilenumber").sendKeys(Name);
}
public void amountClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Operaton option");
getWebElement("app.amount").click();
}
public void amountselect(String Amount) throws Exception {
logger.info("Select the Amount");
for (int i = 0; i < getWebElements("app.amountselect").size(); i++) {
if (getWebElements("app.amountselect").get(i).getText().equalsIgnoreCase(Amount)) {
getWebElements("app.amountselect").get(i).click();
}
}
}
public void nextbtnClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Next Button");
getWebElement("app.nextbtn").click();
}
public void paymentTypeClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Payment type");
getWebElement("app.paymenttype").click();
}
public void paymentmethodClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Payment Method");
getWebElement("app.paymentmethod").click();
}
public WebElement RechagrCellularPage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.recharge");
}
public WebElement PaymentPage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.paymentscreen");
}
public WebElement Cellular() throws Exception {
new TestBase().defaultframe();
// waitelement(getWebElement("app.spinner"));
return getWebElement("app.spinner");
}
public void cardNumber(String cardNumber) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Card Number");
getWebElement("app.cardnumber").sendKeys(cardNumber);
}
public void cardexpMonth(String cardexp) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Exp Month");
getWebElement("app.month").sendKeys(cardexp);
}
public void cardexpyear(String expyear) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Exp Year");
getWebElement("app.year").sendKeys(expyear);
}
public void cardCVV(String cvv) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the CVV Num");
getWebElement("app.cvvno").sendKeys(cvv);
}
public void email(String email) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the email");
getWebElement("app.email").sendKeys(email);
}
public void submitDetails() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Submit details");
getWebElement("app.submit").click();
}
public void userId(String userId) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the UserName");
getWebElement("app.userid").sendKeys(userId);
}
public void password(String password) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Password");
getWebElement("app.password").sendKeys(password);
}
public void captcha() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Captcha checkobox ");
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.delay(1000);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
}
public void accessBtn() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Access button ");
getWebElement("app.access").click();
}
public WebElement verifyPaymentmesage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.message");
}
}
| UTF-8 | Java | 4,566 | java | Recharge.java | Java | [] | null | [] | package com.automation.pagelib;
import java.awt.Robot;
import java.awt.event.KeyEvent;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.openqa.selenium.WebElement;
import com.automation.testbase.TestBase;
public class Recharge extends TestBase {
private static Logger logger = LogManager.getLogger(Recharge.class);
public void operatorClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Operaton option");
getWebElement("app.operator").click();
}
public void operatorselect(String Operator) throws Exception {
logger.info("Select the Operator");
for (int i = 0; i < getWebElements("app.operatorselect").size(); i++) {
if (getWebElements("app.operatorselect").get(i).getText().equalsIgnoreCase(Operator)) {
getWebElements("app.operatorselect").get(i).click();
}
}
}
public void setMobileNumber(String Name) throws Exception {
logger.info("Enter the Mobile Number");
getWebElement("app.mobilenumber").clear();
getWebElement("app.mobilenumber").sendKeys(Name);
}
public void amountClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Operaton option");
getWebElement("app.amount").click();
}
public void amountselect(String Amount) throws Exception {
logger.info("Select the Amount");
for (int i = 0; i < getWebElements("app.amountselect").size(); i++) {
if (getWebElements("app.amountselect").get(i).getText().equalsIgnoreCase(Amount)) {
getWebElements("app.amountselect").get(i).click();
}
}
}
public void nextbtnClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Next Button");
getWebElement("app.nextbtn").click();
}
public void paymentTypeClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Payment type");
getWebElement("app.paymenttype").click();
}
public void paymentmethodClick() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Payment Method");
getWebElement("app.paymentmethod").click();
}
public WebElement RechagrCellularPage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.recharge");
}
public WebElement PaymentPage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.paymentscreen");
}
public WebElement Cellular() throws Exception {
new TestBase().defaultframe();
// waitelement(getWebElement("app.spinner"));
return getWebElement("app.spinner");
}
public void cardNumber(String cardNumber) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Card Number");
getWebElement("app.cardnumber").sendKeys(cardNumber);
}
public void cardexpMonth(String cardexp) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Exp Month");
getWebElement("app.month").sendKeys(cardexp);
}
public void cardexpyear(String expyear) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Exp Year");
getWebElement("app.year").sendKeys(expyear);
}
public void cardCVV(String cvv) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the CVV Num");
getWebElement("app.cvvno").sendKeys(cvv);
}
public void email(String email) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the email");
getWebElement("app.email").sendKeys(email);
}
public void submitDetails() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Submit details");
getWebElement("app.submit").click();
}
public void userId(String userId) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the UserName");
getWebElement("app.userid").sendKeys(userId);
}
public void password(String password) throws Exception {
new TestBase().defaultframe();
logger.info("Enter the Password");
getWebElement("app.password").sendKeys(password);
}
public void captcha() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Captcha checkobox ");
Robot robot = new Robot();
robot.keyPress(KeyEvent.VK_TAB);
robot.keyRelease(KeyEvent.VK_TAB);
robot.delay(1000);
robot.keyPress(KeyEvent.VK_SPACE);
robot.keyRelease(KeyEvent.VK_SPACE);
}
public void accessBtn() throws Exception {
new TestBase().defaultframe();
logger.info("Click on Access button ");
getWebElement("app.access").click();
}
public WebElement verifyPaymentmesage() throws Exception {
new TestBase().defaultframe();
return getWebElement("app.message");
}
}
| 4,566 | 0.724704 | 0.722952 | 164 | 26.841463 | 22.587214 | 90 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.70122 | false | false | 4 |
98bdc982eb94ae96a79d66932c60d9c9852592be | 35,115,652,644,935 | 6b83984ff783452c3e9aa2b7a1d16192b351a60a | /question0931_minimum_falling_path_sum/Solution1.java | 102cc01a7c93ff710abb7ea9bd1b0080645c9b60 | [] | no_license | 617076674/LeetCode | https://github.com/617076674/LeetCode | aeedf17d7cd87b9e59e0a107cd6af5ce9bac64f8 | 0718538ddb79e71fec9a330ea27524a60eb60259 | refs/heads/master | 2022-05-13T18:29:44.982000 | 2022-04-13T01:03:28 | 2022-04-13T01:03:28 | 146,989,451 | 207 | 58 | null | null | null | null | null | null | null | null | null | null | null | null | null | package question0931_minimum_falling_path_sum;
/**
* 记忆化搜索。
*
* 时间复杂度和空间复杂度均是 O(m * n),其中 m 是矩阵 A 的行数,n 是矩阵 A 的列数。
*
* 执行用时:2ms,击败99.23%。消耗内存:41.1MB,击败100.00%。
*/
public class Solution1 {
private int m, n;
private Integer[][] memo;
public int minFallingPathSum(int[][] A) {
if (null == A || (m = A.length) == 0) {
return 0;
}
if (null == A[0] || (n = A[0].length) == 0) {
return 0;
}
memo = new Integer[m][n];
int result = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
result = Math.min(result, minFallingPathSum(A, 0, i));
}
return result;
}
private int minFallingPathSum(int[][] A, int row, int col) {
if (row == A.length) {
return 0;
}
if (memo[row][col] != null) {
return memo[row][col];
}
int result = Integer.MAX_VALUE;
if (col == 0) {
for (int i = 0; i <= Math.min(n - 1, 1) ; i++) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
} else if (col == n - 1) {
for (int i = n - 1; i >= Math.max(0, n - 2) ; i--) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
} else {
for (int i = col - 1; i <= col + 1; i++) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
}
memo[row][col] = result;
return result;
}
} | UTF-8 | Java | 1,678 | java | Solution1.java | Java | [] | null | [] | package question0931_minimum_falling_path_sum;
/**
* 记忆化搜索。
*
* 时间复杂度和空间复杂度均是 O(m * n),其中 m 是矩阵 A 的行数,n 是矩阵 A 的列数。
*
* 执行用时:2ms,击败99.23%。消耗内存:41.1MB,击败100.00%。
*/
public class Solution1 {
private int m, n;
private Integer[][] memo;
public int minFallingPathSum(int[][] A) {
if (null == A || (m = A.length) == 0) {
return 0;
}
if (null == A[0] || (n = A[0].length) == 0) {
return 0;
}
memo = new Integer[m][n];
int result = Integer.MAX_VALUE;
for (int i = 0; i < n; i++) {
result = Math.min(result, minFallingPathSum(A, 0, i));
}
return result;
}
private int minFallingPathSum(int[][] A, int row, int col) {
if (row == A.length) {
return 0;
}
if (memo[row][col] != null) {
return memo[row][col];
}
int result = Integer.MAX_VALUE;
if (col == 0) {
for (int i = 0; i <= Math.min(n - 1, 1) ; i++) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
} else if (col == n - 1) {
for (int i = n - 1; i >= Math.max(0, n - 2) ; i--) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
} else {
for (int i = col - 1; i <= col + 1; i++) {
result = Math.min(result, A[row][i] + minFallingPathSum(A, row + 1, i));
}
}
memo[row][col] = result;
return result;
}
} | 1,678 | 0.448408 | 0.42293 | 54 | 28.092592 | 23.838398 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.851852 | false | false | 4 |
a16e126bf95eba28b142ef7287068de629554e3e | 6,734,508,782,846 | f060f7a7976678cc8b9a1264e6f78e601ecad852 | /day009-ObjectArray-ArrayList/src/org/xueyao/homework/HomeWork_01.java | 9b8e4ab6a6e5587431f475902b7caf4e91aeb25c | [] | no_license | flowstone/Base-Java | https://github.com/flowstone/Base-Java | 1a734ea23ae22b4ffd7b05d37c0e020592164535 | 80e8700e696dede08456f4eb7e3c8203dd5dae69 | refs/heads/master | 2020-12-03T04:02:53.070000 | 2017-12-22T12:02:50 | 2017-12-22T12:02:50 | 95,805,211 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.xueyao.homework;
/**
* 第一题:分析以下需求,并用代码实现
1.按照以下描述完成类的定义。
学生类
属性:
姓名name
年龄age
成绩score
行为:
吃饭eat()
stuty(String content)(content:表示学习的内容)
2.定义学生工具StudentsTool,有四个方法,描述如下
public void listStudents(Student[] arr):遍历打印学生信息
public int getMaxScore(Student[] arr):获取学生成绩的最高分
public Student getMaxStudent(Student[] arr):获取成绩最高的学员
public int getAverageScore(Student[] arr):获取学生成绩的平均值
public int getCount(Student[] arr):获取不及格的学员数量
3.定义测试类TestStudentTool,在main方法中首先创建长度为5的Student数组并初始化数据,再创建StudentsTool类的对象,并调用以上方法
* @author Yao Xue
* @date Jul 6, 2017 2:55:16 PM
*/
public class HomeWork_01 {
}
| GB18030 | Java | 1,093 | java | HomeWork_01.java | Java | [
{
"context": "t数组并初始化数据,再创建StudentsTool类的对象,并调用以上方法 \n\n * @author Yao Xue\n * @date Jul 6, 2017 2:55:16 PM\n */\npublic class ",
"end": 714,
"score": 0.9998361468315125,
"start": 707,
"tag": "NAME",
"value": "Yao Xue"
}
] | null | [] | package org.xueyao.homework;
/**
* 第一题:分析以下需求,并用代码实现
1.按照以下描述完成类的定义。
学生类
属性:
姓名name
年龄age
成绩score
行为:
吃饭eat()
stuty(String content)(content:表示学习的内容)
2.定义学生工具StudentsTool,有四个方法,描述如下
public void listStudents(Student[] arr):遍历打印学生信息
public int getMaxScore(Student[] arr):获取学生成绩的最高分
public Student getMaxStudent(Student[] arr):获取成绩最高的学员
public int getAverageScore(Student[] arr):获取学生成绩的平均值
public int getCount(Student[] arr):获取不及格的学员数量
3.定义测试类TestStudentTool,在main方法中首先创建长度为5的Student数组并初始化数据,再创建StudentsTool类的对象,并调用以上方法
* @author <NAME>
* @date Jul 6, 2017 2:55:16 PM
*/
public class HomeWork_01 {
}
| 1,092 | 0.613316 | 0.59283 | 27 | 27.925926 | 22.075502 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 4 |
4f30a191a1ddabd8f6d68520f3fe3e401ba5bba7 | 6,734,508,781,379 | 4bb13f27a9f98f67f6dd8dbc3379c24808659b91 | /Node.java | d671da0a6ab187d6a5dddefc17ac0b4a407efd5c | [] | no_license | desparza90/FinalPart2 | https://github.com/desparza90/FinalPart2 | 99d8561b5097c08b94efddc90d1cdf416de5c4af | 4c363067e6772286e2984ccdc7382cacae52035f | refs/heads/master | 2021-08-23T22:07:41.509000 | 2017-12-06T19:45:15 | 2017-12-06T19:45:15 | 113,278,219 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package inventory;
public class Node<T>
{
T data;
Node next;
public Node() {
data = null;
next = null;
}
public Node(T newItem, Node nextN)
{
this.data = newItem;
this.next = nextN;
}
} | UTF-8 | Java | 204 | java | Node.java | Java | [] | null | [] | package inventory;
public class Node<T>
{
T data;
Node next;
public Node() {
data = null;
next = null;
}
public Node(T newItem, Node nextN)
{
this.data = newItem;
this.next = nextN;
}
} | 204 | 0.617647 | 0.617647 | 18 | 10.388889 | 9.827054 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.333333 | false | false | 4 |
c77569bb3c13ab9faf37960edb3317a124ae85e8 | 36,266,703,876,542 | 70f075a8682a5760e44013ef8659764e08426f55 | /src/test/java/com/itexico/testing/tests/JavascriptAlertBoxTest.java | 6b43c3de49f9ad6cb449851ffb117f92c13c9868 | [] | no_license | zchumager/selenium-easy-demo | https://github.com/zchumager/selenium-easy-demo | 7f349d8484b59bf6f253031b5ee1bd804a00d1ee | 4409b9a9f551ca8d06232e8238596d81b1a8154b | refs/heads/master | 2023-05-11T16:24:00.755000 | 2019-06-20T17:46:54 | 2019-06-20T17:46:54 | 192,963,987 | 0 | 0 | null | false | 2023-05-09T18:09:08 | 2019-06-20T17:48:23 | 2019-06-20T17:49:11 | 2023-05-09T18:09:03 | 6,944 | 0 | 0 | 1 | Java | false | false | package com.itexico.testing.tests;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.Alert;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.itexico.testing.bases.BaseTest;
import com.itexico.testing.steps.JavascriptAlertBoxSteps;
public class JavascriptAlertBoxTest extends BaseTest<JavascriptAlertBoxSteps>{
private WebDriverWait wait;
private Alert alert;
public JavascriptAlertBoxTest() {
this.driver = new ChromeDriver();
}
public void exec(Alert a, String method) {
Method m;
try {
m = Alert.class.getMethod(method);
m.invoke(a); //Invoca el metodo en el contexto de la instancia de Alert
} catch (NoSuchMethodException | SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
@BeforeTest
private void setup() {
this.driver.manage().window().maximize();
this.driver.get("https://www.seleniumeasy.com/test/javascript-alert-box-demo.html");
this.steps = new JavascriptAlertBoxSteps(this.driver);
}
@Test
public void testJavascriptAlertBox() {
this.steps.clickButtonByIndex(0);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = this.wait.until(ExpectedConditions.alertIsPresent());
this.exec(alert, "accept");
}
@Test
public void testConfirmP() {
Map<String, String> actionMessage = new HashMap<String, String>();
actionMessage.put("accept", "You pressed OK!");
actionMessage.put("dismiss", "You pressed Cancel!");
for(Map.Entry<String, String> e: actionMessage.entrySet()) {
this.steps.clickButtonByIndex(1);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = wait.until(ExpectedConditions.alertIsPresent());
this.exec(alert, e.getKey());
Assert.assertEquals(this.steps.getconfirmP_Text(), e.getValue());
}
}
@Test
public void testPromptP() {
String name = "Pedro";
String greetingMsg = "You have entered '" +name +"' !";
this.steps.clickButtonByIndex(2);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = wait.until(ExpectedConditions.alertIsPresent());
this.alert.sendKeys(name);
this.alert.accept();
Assert.assertEquals(this.steps.getPromptP_Text(), greetingMsg);
}
}
| UTF-8 | Java | 2,668 | java | JavascriptAlertBoxTest.java | Java | [
{
"context": "est\n\tpublic void testPromptP() {\n\t\tString name = \"Pedro\";\n\t\tString greetingMsg = \"You have entered '\" +na",
"end": 2322,
"score": 0.99977046251297,
"start": 2317,
"tag": "NAME",
"value": "Pedro"
}
] | null | [] | package com.itexico.testing.tests;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import org.openqa.selenium.Alert;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.Assert;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
import com.itexico.testing.bases.BaseTest;
import com.itexico.testing.steps.JavascriptAlertBoxSteps;
public class JavascriptAlertBoxTest extends BaseTest<JavascriptAlertBoxSteps>{
private WebDriverWait wait;
private Alert alert;
public JavascriptAlertBoxTest() {
this.driver = new ChromeDriver();
}
public void exec(Alert a, String method) {
Method m;
try {
m = Alert.class.getMethod(method);
m.invoke(a); //Invoca el metodo en el contexto de la instancia de Alert
} catch (NoSuchMethodException | SecurityException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
@BeforeTest
private void setup() {
this.driver.manage().window().maximize();
this.driver.get("https://www.seleniumeasy.com/test/javascript-alert-box-demo.html");
this.steps = new JavascriptAlertBoxSteps(this.driver);
}
@Test
public void testJavascriptAlertBox() {
this.steps.clickButtonByIndex(0);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = this.wait.until(ExpectedConditions.alertIsPresent());
this.exec(alert, "accept");
}
@Test
public void testConfirmP() {
Map<String, String> actionMessage = new HashMap<String, String>();
actionMessage.put("accept", "You pressed OK!");
actionMessage.put("dismiss", "You pressed Cancel!");
for(Map.Entry<String, String> e: actionMessage.entrySet()) {
this.steps.clickButtonByIndex(1);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = wait.until(ExpectedConditions.alertIsPresent());
this.exec(alert, e.getKey());
Assert.assertEquals(this.steps.getconfirmP_Text(), e.getValue());
}
}
@Test
public void testPromptP() {
String name = "Pedro";
String greetingMsg = "You have entered '" +name +"' !";
this.steps.clickButtonByIndex(2);
this.wait = new WebDriverWait(this.driver, 10);
this.alert = wait.until(ExpectedConditions.alertIsPresent());
this.alert.sendKeys(name);
this.alert.accept();
Assert.assertEquals(this.steps.getPromptP_Text(), greetingMsg);
}
}
| 2,668 | 0.733883 | 0.73051 | 93 | 27.688171 | 23.373535 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.086021 | false | false | 4 |
b5228d658addffa747b4cc0b6b9b3701868b7caf | 21,157,008,960,483 | 7934146111d1a952bf1aee876d1be533bd055aec | /loan-endpoint/src/main/java/com/loanscompany/lam/endpoint/appconfig/ApplicationProperties.java | 13a9fdf481b1fd3a4d744c218d0e1c4ad97fc5ab | [] | no_license | percym/loanapplicationmanager | https://github.com/percym/loanapplicationmanager | 6072b790a5c4780006290e0b32efe1fc5eac3efb | 9492ae12d272cc9656049aedac109ac17e8d7a3d | refs/heads/master | 2022-11-23T11:03:35.518000 | 2019-05-06T09:19:24 | 2019-05-06T09:19:24 | 188,811,925 | 0 | 0 | null | false | 2022-11-16T11:33:05 | 2019-05-27T09:20:08 | 2019-08-26T08:13:47 | 2022-11-16T11:33:02 | 377 | 0 | 0 | 8 | Java | false | false | package com.loanscompany.lam.endpoint.appconfig;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
/**
* Properties specific to Dova.
* <p>
* Properties configured in the test.properties file.
*
* @author percym
*/
@Data
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = true)
//@Import({springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration.class})
public class ApplicationProperties {
private String secret;
private long tokenValidityInSeconds;
} | UTF-8 | Java | 756 | java | ApplicationProperties.java | Java | [
{
"context": "gured in the test.properties file.\r\n *\r\n * @author percym\r\n */\r\n@Data\r\n@Getter\r\n@Setter\r\n@Component\r\n@Confi",
"end": 425,
"score": 0.9995396733283997,
"start": 419,
"tag": "USERNAME",
"value": "percym"
}
] | null | [] | package com.loanscompany.lam.endpoint.appconfig;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Import;
import org.springframework.stereotype.Component;
/**
* Properties specific to Dova.
* <p>
* Properties configured in the test.properties file.
*
* @author percym
*/
@Data
@Getter
@Setter
@Component
@ConfigurationProperties(prefix = "application", ignoreUnknownFields = true)
//@Import({springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration.class})
public class ApplicationProperties {
private String secret;
private long tokenValidityInSeconds;
} | 756 | 0.772487 | 0.772487 | 29 | 24.137932 | 25.958487 | 92 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.344828 | false | false | 4 |
35f574296a65dc13b86a6f2b6dcc7e326e0bde06 | 21,062,519,663,592 | d175d69678885df6cc61b376ede4dd2a946af05b | /api/src/main/java/com/authorization/exception/AuthorizationHeaderMissingException.java | e5b8bbe60535c430eaeb969f109e0e0eb0832c3f | [] | no_license | razvancornita/AuthorizationsAPI | https://github.com/razvancornita/AuthorizationsAPI | ce789f7dccf45467bbfcf4becc4e9fcb2e177e6b | 3fd2a4fea56dcd3ae32fbabe20bcb59d6a1a679f | refs/heads/main | 2023-06-15T07:46:08.602000 | 2021-07-19T09:21:15 | 2021-07-19T09:21:15 | 386,916,967 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.authorization.exception;
import org.springframework.security.core.AuthenticationException;
public class AuthorizationHeaderMissingException extends AuthenticationException {
public AuthorizationHeaderMissingException() {
super("Authorization header is missing.");
}
} | UTF-8 | Java | 297 | java | AuthorizationHeaderMissingException.java | Java | [] | null | [] | package com.authorization.exception;
import org.springframework.security.core.AuthenticationException;
public class AuthorizationHeaderMissingException extends AuthenticationException {
public AuthorizationHeaderMissingException() {
super("Authorization header is missing.");
}
} | 297 | 0.811448 | 0.811448 | 9 | 32.111111 | 29.797256 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 4 |
04f243e5ae2f81fb58344a5d0419d9d4b5dafc15 | 37,014,028,169,676 | 4619ef64436f410273215c4db1773d6e7c2c3b64 | /SimiCart/app/src/main/java/com/simicart/core/slidemenu/controller/PhoneSlideMenuController.java | 24e05b1003df5a880d3d11212c4a4f66edf3ce18 | [] | no_license | Simicart/Android-studio-core | https://github.com/Simicart/Android-studio-core | ba72add5d98b6fff1895d0fc1b02441276d2963d | 44389099b7a2e2ca5c1eb1c14f6f8129713d880c | refs/heads/master | 2021-06-08T16:21:49.831000 | 2016-09-21T13:35:06 | 2016-09-21T13:35:06 | 48,149,460 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.simicart.core.slidemenu.controller;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import com.simicart.core.base.fragment.SimiFragment;
import com.simicart.core.base.manager.SimiManager;
import com.simicart.core.base.model.entity.SimiData;
import com.simicart.core.base.translate.SimiTranslator;
import com.simicart.core.cms.entity.Cms;
import com.simicart.core.common.DataPreferences;
import com.simicart.core.common.KeyData;
import com.simicart.core.common.KeyEvent;
import com.simicart.core.config.DataLocal;
import com.simicart.core.config.Rconfig;
import com.simicart.core.customer.fragment.MyAccountFragment;
import com.simicart.core.customer.fragment.OrderHistoryFragment;
import com.simicart.core.customer.fragment.SignInFragment;
import com.simicart.core.setting.fragment.SettingAppFragment;
import com.simicart.core.slidemenu.delegate.CloseSlideMenuDelegate;
import com.simicart.core.slidemenu.delegate.SlideMenuDelegate;
import com.simicart.core.slidemenu.entity.ItemNavigation;
import com.simicart.core.slidemenu.entity.ItemNavigation.TypeItem;
import com.simicart.core.splashscreen.entity.DeepLinkEntity;
import java.util.ArrayList;
import java.util.HashMap;
public class PhoneSlideMenuController {
private final String HOME = "Home";
private final String CATEGORY = "Category";
private final String ORDER_HISTORY = "Order History";
private final String MORE = "More";
private final String SETTING = "Setting";
protected HashMap<String, String> mPluginFragment;
protected OnItemClickListener mListener;
protected OnClickListener onClickPersonal;
protected ArrayList<ItemNavigation> mItems = new ArrayList<ItemNavigation>();
protected Context mContext;
protected SlideMenuDelegate mDelegate;
protected int DEFAULT_POSITION = 0;
protected CloseSlideMenuDelegate mCloseDelegate;
protected ArrayList<ItemNavigation> mItemsAccount;
private boolean check_keyboard_first;
public PhoneSlideMenuController(SlideMenuDelegate delegate, Context context) {
mDelegate = delegate;
mContext = context;
mItems = new ArrayList<ItemNavigation>();
mPluginFragment = new HashMap<String, String>();
}
public void setCloseDelegate(CloseSlideMenuDelegate delegate) {
mCloseDelegate = delegate;
}
public OnItemClickListener getListener() {
return mListener;
}
public void setListener(OnItemClickListener mListener) {
this.mListener = mListener;
}
public OnClickListener getOnClickPersonal() {
return onClickPersonal;
}
public void closeSlideMenuTablet() {
if (mCloseDelegate != null)
mCloseDelegate.closeSlideMenu();
}
public void create() {
mListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
onNaviagte(position);
}
};
onClickPersonal = new OnClickListener() {
@Override
public void onClick(View v) {
SimiFragment fragment = null;
mCloseDelegate.closeSlideMenu();
if (DataPreferences.isSignInComplete()) {
// profile
fragment = MyAccountFragment.newInstance();
} else {
// sign in
HashMap<String, Object> hmData = new HashMap<>();
hmData.put("is_checkout", false);
SimiData data = new SimiData(hmData);
fragment = SignInFragment.newInstance(data);
}
SimiManager.getIntance().replacePopupFragment(fragment);
}
};
initial();
}
private void initial() {
initDataAdapter();
if (null != mDelegate) {
mDelegate.setAdapter(mItems);
}
// open home page
if (DeepLinkEntity.getInstance().getName().equals("")) {
onNaviagte(DEFAULT_POSITION);
} else {
openDeepLink();
}
}
private void openDeepLink() {
SimiFragment fragment = null;
if (!DeepLinkEntity.getInstance().getID().equals("")
&& DeepLinkEntity.getInstance().getType() != 0) {
if (DeepLinkEntity.getInstance().getType() == 1) {
Log.e("Open deep link", "1");
ArrayList<String> listID = new ArrayList<String>();
listID.add(DeepLinkEntity.getInstance().getID());
// fragment = ProductDetailParentFragment.newInstance(
// DeepLinkEntity.newInstance().getID(), listID);
// SimiManager.getIntance().replaceFragment(fragment);
} else if (DeepLinkEntity.getInstance().getType() == 2) {
Log.e("Open deep link", "2");
if (DeepLinkEntity.getInstance().isHasChild() == true) {
if (DataLocal.isTablet) {
// fragment = CategoryFragment.newInstance(
// DeepLinkEntity.newInstance().getID(),
// DeepLinkEntity.newInstance().getName());
// CateSlideMenuFragment.getIntance()
// .replaceFragmentCategoryMenu(fragment);
// CateSlideMenuFragment.getIntance().openMenu();
} else {
// fragment = CategoryFragment.newInstance(
// DeepLinkEntity.newInstance().getID(),
// DeepLinkEntity.newInstance().getName());
// SimiManager.getIntance().replaceFragment(fragment);
}
} else {
// fragment = ProductListFragment.newInstance(
// DeepLinkEntity.newInstance().getID(), DeepLinkEntity.newInstance().getName(), null, null, null);
// SimiManager.getIntance().replaceFragment(fragment);
}
}
}
DeepLinkEntity.getInstance().setID("");
DeepLinkEntity.getInstance().setName("");
DeepLinkEntity.getInstance().setHasChild(false);
DeepLinkEntity.getInstance().setType(0);
}
public void initDataAdapter() {
addPersonal();
addHome();
addCategory();
if (DataPreferences.isSignInComplete()) {
addItemRelatedPersonal();
}
addMoreItems();
addSetting();
}
public void addPersonal() {
String name = "";
if (DataPreferences.isSignInComplete()) {
name = DataPreferences.getUsername();
} else {
name = SimiTranslator.getInstance().translate("Sign in");
removeItemRelatedPersonal();
}
mDelegate.setUpdateSignIn(name);
mDelegate.setAdapter(mItems);
}
public void addItemRelatedPersonal() {
// order history
int index = checkElement(ORDER_HISTORY);
mItemsAccount = new ArrayList<>();
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(ORDER_HISTORY);
int id_icon = Rconfig.getInstance().drawable(
"ic_menu_order_history");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItemsAccount.add(item);
dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.ADD_ITEM_RELATED_PERSONAL, mItemsAccount);
int index_category = checkElement(CATEGORY);
if (DataLocal.isTablet) {
index_category = checkElement(HOME);
}
insertItemAfter(index_category, mItemsAccount);
}
}
public void removeItemRelatedPersonal() {
if (mItemsAccount != null) {
for (ItemNavigation item : mItemsAccount) {
int index = checkElement(item.getName());
if (index != -1) {
mItems.remove(index);
}
}
}
// order history
// int index = checkElement(ORDER_HISTORY);
// if (index != -1) {
// mItems.remove(index);
// }
//dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.REMOVE_ITEM);
}
public void addHome() {
int index = checkElement(HOME);
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(HOME);
int id_icon = Rconfig.getInstance().drawable("ic_menu_home");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItems.add(item);
}
}
public void addCategory() {
if (!DataLocal.isTablet) {
int index = checkElement(CATEGORY);
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(CATEGORY);
int id_icon = Rconfig.getInstance()
.drawable("ic_menu_category");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItems.add(item);
}
}
}
public void addMoreItems() {
// more
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setSparator(true);
item.setName(MORE);
mItems.add(item);
// event for add barcode to slidemenu
dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.ADD_ITEM_MORE, mItems);
// SlideMenuData slideMenuData = new SlideMenuData();
// slideMenuData.setItemNavigations(mItems);
// slideMenuData.setPluginFragment(mPluginFragment);
// EventSlideMenu eventSlideMenu = new EventSlideMenu();
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more",
// slideMenuData);
//
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.qrbarcode",
// slideMenuData);
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.locator",
// slideMenuData);
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.contactus",
// slideMenuData);
// CMS
addCMS();
}
public void addCMS() {
if ((null != DataLocal.listCms) && (DataLocal.listCms.size() > 0)) {
for (Cms cms : DataLocal.listCms) {
ItemNavigation item = new ItemNavigation();
String name = cms.getTitle();
if (null != name && !name.equals("null")) {
item.setName(name);
}
String url = cms.getIcon();
if (null != url && !url.equals("null")) {
item.setUrl(url);
}
item.setType(TypeItem.CMS);
mItems.add(item);
}
}
}
public void addSetting() {
ItemNavigation item = new ItemNavigation();
item.setExtended(true);
item.setType(TypeItem.NORMAL);
item.setName(SETTING);
int id_icon = Rconfig.getInstance().drawable("ic_menu_setting");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setShowPopup(true);
item.setIcon(icon);
mItems.add(item);
}
public void onNaviagte(int position) {
SimiManager.getIntance().showCartLayout(true);
ItemNavigation item = mItems.get(position);
if (null != item) {
if (!item.isSparator()) {
// event click barcode leftmenu
dispatchOnClickEvent(KeyEvent.SLIDE_MENU_EVENT.CLICK_ITEM, item.getName());
TypeItem type = item.getType();
SimiFragment fragment = null;
if (type == TypeItem.NORMAL) {
fragment = navigateNormal(item);
} else if (type == TypeItem.PLUGIN) {
fragment = navigatePlugin(item);
// fragment.setShowPopup(item.isShowPopup());
} else if (type == TypeItem.CMS) {
fragment = navigateCMS(item);
}
if (null != fragment) {
if (!DataLocal.isTablet) {
// replace fragment for phone
SimiManager.getIntance().replaceFragment(fragment);
if (check_keyboard_first) {
SimiManager.getIntance().hideKeyboard();
}
check_keyboard_first = true;
} else {
// replace for tablet
if (item.isShowPopup()) {
SimiManager.getIntance().replacePopupFragment(fragment);
} else {
SimiManager.getIntance().replaceFragment(fragment);
}
}
}
mDelegate.onSelectedItem(position);
if (mCloseDelegate != null) {
mCloseDelegate.closeSlideMenu();
}
}
}
}
public SimiFragment navigateNormal(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
HashMap<String, Object> hm = null;
switch (name) {
case "Home":
//fragment = HomeFragment.newInstance();
SimiManager.getIntance().openHomePage();
break;
case "Category":
hm = new HashMap<>();
hm.put(KeyData.CATEGORY.CATEGORY_NAME, "all categories");
SimiManager.getIntance().openCategory(hm);
break;
case "Order History":
fragment = OrderHistoryFragment.newInstance();
break;
case "Setting":
fragment = SettingAppFragment.newInstance();
// fragment.setShowPopup(true);
break;
default:
break;
}
return fragment;
}
public SimiFragment navigatePlugin(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
if (null != name) {
for (String key : mPluginFragment.keySet()) {
if (name.contains(key)) {
String fullname = mPluginFragment.get(key);
fragment = (SimiFragment) Fragment.instantiate(mContext,
fullname);
}
}
}
return fragment;
}
public SimiFragment navigateCMS(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
for (Cms cms : DataLocal.listCms) {
if (name.equals(cms.getTitle())) {
String content = cms.getContent();
HashMap<String, Object> hm = new HashMap<>();
hm.put(KeyData.CMS_PAGE.CONTENT, content);
SimiManager.getIntance().openCMSPage(hm);
}
}
// initial CMSFragment by using content field.
return fragment;
}
protected int checkElement(String name) {
if (null != mItems || mItems.size() > 0) {
for (int i = 0; i < mItems.size(); i++) {
ItemNavigation item = mItems.get(i);
if (item.getName().equals(name)) {
return i;
}
}
return -1;
}
return -1;
}
protected ItemNavigation getElement(String name) {
if (null != mItems || mItems.size() > 0) {
for (int i = 0; i < mItems.size(); i++) {
ItemNavigation item = mItems.get(i);
if (item.getName().equals(name)) {
return item;
}
}
return null;
}
return null;
}
public boolean removeItemElement(String name) {
int position = checkElement(name);
if (position > -1) {
mItems.remove(position);
return true;
}
return false;
}
public boolean replaceItemElement(String nameOldElement,
ItemNavigation newItem) {
int position = checkElement(nameOldElement);
if (position > -1) {
mItems.set(position, newItem);
return true;
}
return false;
}
public boolean insertItemAfter(int index,
ArrayList<ItemNavigation> mItemsAccount) {
if (index != -1 && mItemsAccount.size() > 0) {
ArrayList<ItemNavigation> list1 = new ArrayList<ItemNavigation>();
ArrayList<ItemNavigation> list2 = new ArrayList<ItemNavigation>();
for (int i = 0; i <= index; i++) {
list1.add(mItems.get(i));
}
for (int i = index + 1; i < mItems.size(); i++) {
list2.add(mItems.get(i));
}
// if (list1.size() == 0 || list2.size() == 0) {
// return false;
// }
mItems.clear();
for (int i = 0; i < list1.size(); i++) {
mItems.add(list1.get(i));
}
for (ItemNavigation itemNavigation : mItemsAccount) {
mItems.add(itemNavigation);
}
for (int i = 0; i < list2.size(); i++) {
mItems.add(list2.get(i));
}
return true;
}
return false;
}
public void updateSignIn() {
String name = SimiTranslator.getInstance().translate("My Account");
if (DataPreferences.isSignInComplete()) {
name = DataPreferences.getUsername();
addItemRelatedPersonal();
} else {
name = SimiTranslator.getInstance().translate("Sign in");
removeItemRelatedPersonal();
}
mDelegate.setUpdateSignIn(name);
mDelegate.setAdapter(mItems);
}
protected void dispatchItemEvent(String event_name, ArrayList<ItemNavigation> mItemsAccount) {
Intent intent = new Intent(event_name);
Bundle bundle = new Bundle();
// SimiEventLeftMenuEntity leftEntity = new SimiEventLeftMenuEntity();
// leftEntity.setMenu(mMenu);
HashMap<String, Object> hmData = new HashMap<>();
hmData.put(KeyData.SLIDE_MENU.LIST_ITEMS, mItemsAccount);
hmData.put(KeyData.SLIDE_MENU.LIST_FRAGMENTS, mPluginFragment);
SimiData data = new SimiData(hmData);
bundle.putParcelable("entity", data);
intent.putExtra("data", bundle);
LocalBroadcastManager.getInstance(mContext).sendBroadcastSync(intent);
}
protected void dispatchOnClickEvent(String event_name, String item_name) {
Intent intent = new Intent(event_name);
Bundle bundle = new Bundle();
HashMap<String, Object> hmData = new HashMap<>();
hmData.put(KeyData.SLIDE_MENU.ITEM_NAME, item_name);
SimiData data = new SimiData(hmData);
bundle.putParcelable("entity", data);
intent.putExtra("data", bundle);
LocalBroadcastManager.getInstance(mContext).sendBroadcastSync(intent);
}
}
| UTF-8 | Java | 20,527 | java | PhoneSlideMenuController.java | Java | [] | null | [] | package com.simicart.core.slidemenu.controller;
import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import com.simicart.core.base.fragment.SimiFragment;
import com.simicart.core.base.manager.SimiManager;
import com.simicart.core.base.model.entity.SimiData;
import com.simicart.core.base.translate.SimiTranslator;
import com.simicart.core.cms.entity.Cms;
import com.simicart.core.common.DataPreferences;
import com.simicart.core.common.KeyData;
import com.simicart.core.common.KeyEvent;
import com.simicart.core.config.DataLocal;
import com.simicart.core.config.Rconfig;
import com.simicart.core.customer.fragment.MyAccountFragment;
import com.simicart.core.customer.fragment.OrderHistoryFragment;
import com.simicart.core.customer.fragment.SignInFragment;
import com.simicart.core.setting.fragment.SettingAppFragment;
import com.simicart.core.slidemenu.delegate.CloseSlideMenuDelegate;
import com.simicart.core.slidemenu.delegate.SlideMenuDelegate;
import com.simicart.core.slidemenu.entity.ItemNavigation;
import com.simicart.core.slidemenu.entity.ItemNavigation.TypeItem;
import com.simicart.core.splashscreen.entity.DeepLinkEntity;
import java.util.ArrayList;
import java.util.HashMap;
public class PhoneSlideMenuController {
private final String HOME = "Home";
private final String CATEGORY = "Category";
private final String ORDER_HISTORY = "Order History";
private final String MORE = "More";
private final String SETTING = "Setting";
protected HashMap<String, String> mPluginFragment;
protected OnItemClickListener mListener;
protected OnClickListener onClickPersonal;
protected ArrayList<ItemNavigation> mItems = new ArrayList<ItemNavigation>();
protected Context mContext;
protected SlideMenuDelegate mDelegate;
protected int DEFAULT_POSITION = 0;
protected CloseSlideMenuDelegate mCloseDelegate;
protected ArrayList<ItemNavigation> mItemsAccount;
private boolean check_keyboard_first;
public PhoneSlideMenuController(SlideMenuDelegate delegate, Context context) {
mDelegate = delegate;
mContext = context;
mItems = new ArrayList<ItemNavigation>();
mPluginFragment = new HashMap<String, String>();
}
public void setCloseDelegate(CloseSlideMenuDelegate delegate) {
mCloseDelegate = delegate;
}
public OnItemClickListener getListener() {
return mListener;
}
public void setListener(OnItemClickListener mListener) {
this.mListener = mListener;
}
public OnClickListener getOnClickPersonal() {
return onClickPersonal;
}
public void closeSlideMenuTablet() {
if (mCloseDelegate != null)
mCloseDelegate.closeSlideMenu();
}
public void create() {
mListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
onNaviagte(position);
}
};
onClickPersonal = new OnClickListener() {
@Override
public void onClick(View v) {
SimiFragment fragment = null;
mCloseDelegate.closeSlideMenu();
if (DataPreferences.isSignInComplete()) {
// profile
fragment = MyAccountFragment.newInstance();
} else {
// sign in
HashMap<String, Object> hmData = new HashMap<>();
hmData.put("is_checkout", false);
SimiData data = new SimiData(hmData);
fragment = SignInFragment.newInstance(data);
}
SimiManager.getIntance().replacePopupFragment(fragment);
}
};
initial();
}
private void initial() {
initDataAdapter();
if (null != mDelegate) {
mDelegate.setAdapter(mItems);
}
// open home page
if (DeepLinkEntity.getInstance().getName().equals("")) {
onNaviagte(DEFAULT_POSITION);
} else {
openDeepLink();
}
}
private void openDeepLink() {
SimiFragment fragment = null;
if (!DeepLinkEntity.getInstance().getID().equals("")
&& DeepLinkEntity.getInstance().getType() != 0) {
if (DeepLinkEntity.getInstance().getType() == 1) {
Log.e("Open deep link", "1");
ArrayList<String> listID = new ArrayList<String>();
listID.add(DeepLinkEntity.getInstance().getID());
// fragment = ProductDetailParentFragment.newInstance(
// DeepLinkEntity.newInstance().getID(), listID);
// SimiManager.getIntance().replaceFragment(fragment);
} else if (DeepLinkEntity.getInstance().getType() == 2) {
Log.e("Open deep link", "2");
if (DeepLinkEntity.getInstance().isHasChild() == true) {
if (DataLocal.isTablet) {
// fragment = CategoryFragment.newInstance(
// DeepLinkEntity.newInstance().getID(),
// DeepLinkEntity.newInstance().getName());
// CateSlideMenuFragment.getIntance()
// .replaceFragmentCategoryMenu(fragment);
// CateSlideMenuFragment.getIntance().openMenu();
} else {
// fragment = CategoryFragment.newInstance(
// DeepLinkEntity.newInstance().getID(),
// DeepLinkEntity.newInstance().getName());
// SimiManager.getIntance().replaceFragment(fragment);
}
} else {
// fragment = ProductListFragment.newInstance(
// DeepLinkEntity.newInstance().getID(), DeepLinkEntity.newInstance().getName(), null, null, null);
// SimiManager.getIntance().replaceFragment(fragment);
}
}
}
DeepLinkEntity.getInstance().setID("");
DeepLinkEntity.getInstance().setName("");
DeepLinkEntity.getInstance().setHasChild(false);
DeepLinkEntity.getInstance().setType(0);
}
public void initDataAdapter() {
addPersonal();
addHome();
addCategory();
if (DataPreferences.isSignInComplete()) {
addItemRelatedPersonal();
}
addMoreItems();
addSetting();
}
public void addPersonal() {
String name = "";
if (DataPreferences.isSignInComplete()) {
name = DataPreferences.getUsername();
} else {
name = SimiTranslator.getInstance().translate("Sign in");
removeItemRelatedPersonal();
}
mDelegate.setUpdateSignIn(name);
mDelegate.setAdapter(mItems);
}
public void addItemRelatedPersonal() {
// order history
int index = checkElement(ORDER_HISTORY);
mItemsAccount = new ArrayList<>();
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(ORDER_HISTORY);
int id_icon = Rconfig.getInstance().drawable(
"ic_menu_order_history");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItemsAccount.add(item);
dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.ADD_ITEM_RELATED_PERSONAL, mItemsAccount);
int index_category = checkElement(CATEGORY);
if (DataLocal.isTablet) {
index_category = checkElement(HOME);
}
insertItemAfter(index_category, mItemsAccount);
}
}
public void removeItemRelatedPersonal() {
if (mItemsAccount != null) {
for (ItemNavigation item : mItemsAccount) {
int index = checkElement(item.getName());
if (index != -1) {
mItems.remove(index);
}
}
}
// order history
// int index = checkElement(ORDER_HISTORY);
// if (index != -1) {
// mItems.remove(index);
// }
//dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.REMOVE_ITEM);
}
public void addHome() {
int index = checkElement(HOME);
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(HOME);
int id_icon = Rconfig.getInstance().drawable("ic_menu_home");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItems.add(item);
}
}
public void addCategory() {
if (!DataLocal.isTablet) {
int index = checkElement(CATEGORY);
if (index == -1) {
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setName(CATEGORY);
int id_icon = Rconfig.getInstance()
.drawable("ic_menu_category");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setIcon(icon);
mItems.add(item);
}
}
}
public void addMoreItems() {
// more
ItemNavigation item = new ItemNavigation();
item.setType(TypeItem.NORMAL);
item.setSparator(true);
item.setName(MORE);
mItems.add(item);
// event for add barcode to slidemenu
dispatchItemEvent(KeyEvent.SLIDE_MENU_EVENT.ADD_ITEM_MORE, mItems);
// SlideMenuData slideMenuData = new SlideMenuData();
// slideMenuData.setItemNavigations(mItems);
// slideMenuData.setPluginFragment(mPluginFragment);
// EventSlideMenu eventSlideMenu = new EventSlideMenu();
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more",
// slideMenuData);
//
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.qrbarcode",
// slideMenuData);
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.locator",
// slideMenuData);
// eventSlideMenu.dispatchEvent("com.simicart.add.navigation.more.contactus",
// slideMenuData);
// CMS
addCMS();
}
public void addCMS() {
if ((null != DataLocal.listCms) && (DataLocal.listCms.size() > 0)) {
for (Cms cms : DataLocal.listCms) {
ItemNavigation item = new ItemNavigation();
String name = cms.getTitle();
if (null != name && !name.equals("null")) {
item.setName(name);
}
String url = cms.getIcon();
if (null != url && !url.equals("null")) {
item.setUrl(url);
}
item.setType(TypeItem.CMS);
mItems.add(item);
}
}
}
public void addSetting() {
ItemNavigation item = new ItemNavigation();
item.setExtended(true);
item.setType(TypeItem.NORMAL);
item.setName(SETTING);
int id_icon = Rconfig.getInstance().drawable("ic_menu_setting");
Drawable icon = mContext.getResources().getDrawable(id_icon);
icon.setColorFilter(Color.parseColor("#ffffff"),
PorterDuff.Mode.SRC_ATOP);
item.setShowPopup(true);
item.setIcon(icon);
mItems.add(item);
}
public void onNaviagte(int position) {
SimiManager.getIntance().showCartLayout(true);
ItemNavigation item = mItems.get(position);
if (null != item) {
if (!item.isSparator()) {
// event click barcode leftmenu
dispatchOnClickEvent(KeyEvent.SLIDE_MENU_EVENT.CLICK_ITEM, item.getName());
TypeItem type = item.getType();
SimiFragment fragment = null;
if (type == TypeItem.NORMAL) {
fragment = navigateNormal(item);
} else if (type == TypeItem.PLUGIN) {
fragment = navigatePlugin(item);
// fragment.setShowPopup(item.isShowPopup());
} else if (type == TypeItem.CMS) {
fragment = navigateCMS(item);
}
if (null != fragment) {
if (!DataLocal.isTablet) {
// replace fragment for phone
SimiManager.getIntance().replaceFragment(fragment);
if (check_keyboard_first) {
SimiManager.getIntance().hideKeyboard();
}
check_keyboard_first = true;
} else {
// replace for tablet
if (item.isShowPopup()) {
SimiManager.getIntance().replacePopupFragment(fragment);
} else {
SimiManager.getIntance().replaceFragment(fragment);
}
}
}
mDelegate.onSelectedItem(position);
if (mCloseDelegate != null) {
mCloseDelegate.closeSlideMenu();
}
}
}
}
public SimiFragment navigateNormal(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
HashMap<String, Object> hm = null;
switch (name) {
case "Home":
//fragment = HomeFragment.newInstance();
SimiManager.getIntance().openHomePage();
break;
case "Category":
hm = new HashMap<>();
hm.put(KeyData.CATEGORY.CATEGORY_NAME, "all categories");
SimiManager.getIntance().openCategory(hm);
break;
case "Order History":
fragment = OrderHistoryFragment.newInstance();
break;
case "Setting":
fragment = SettingAppFragment.newInstance();
// fragment.setShowPopup(true);
break;
default:
break;
}
return fragment;
}
public SimiFragment navigatePlugin(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
if (null != name) {
for (String key : mPluginFragment.keySet()) {
if (name.contains(key)) {
String fullname = mPluginFragment.get(key);
fragment = (SimiFragment) Fragment.instantiate(mContext,
fullname);
}
}
}
return fragment;
}
public SimiFragment navigateCMS(ItemNavigation item) {
SimiFragment fragment = null;
String name = item.getName();
for (Cms cms : DataLocal.listCms) {
if (name.equals(cms.getTitle())) {
String content = cms.getContent();
HashMap<String, Object> hm = new HashMap<>();
hm.put(KeyData.CMS_PAGE.CONTENT, content);
SimiManager.getIntance().openCMSPage(hm);
}
}
// initial CMSFragment by using content field.
return fragment;
}
protected int checkElement(String name) {
if (null != mItems || mItems.size() > 0) {
for (int i = 0; i < mItems.size(); i++) {
ItemNavigation item = mItems.get(i);
if (item.getName().equals(name)) {
return i;
}
}
return -1;
}
return -1;
}
protected ItemNavigation getElement(String name) {
if (null != mItems || mItems.size() > 0) {
for (int i = 0; i < mItems.size(); i++) {
ItemNavigation item = mItems.get(i);
if (item.getName().equals(name)) {
return item;
}
}
return null;
}
return null;
}
public boolean removeItemElement(String name) {
int position = checkElement(name);
if (position > -1) {
mItems.remove(position);
return true;
}
return false;
}
public boolean replaceItemElement(String nameOldElement,
ItemNavigation newItem) {
int position = checkElement(nameOldElement);
if (position > -1) {
mItems.set(position, newItem);
return true;
}
return false;
}
public boolean insertItemAfter(int index,
ArrayList<ItemNavigation> mItemsAccount) {
if (index != -1 && mItemsAccount.size() > 0) {
ArrayList<ItemNavigation> list1 = new ArrayList<ItemNavigation>();
ArrayList<ItemNavigation> list2 = new ArrayList<ItemNavigation>();
for (int i = 0; i <= index; i++) {
list1.add(mItems.get(i));
}
for (int i = index + 1; i < mItems.size(); i++) {
list2.add(mItems.get(i));
}
// if (list1.size() == 0 || list2.size() == 0) {
// return false;
// }
mItems.clear();
for (int i = 0; i < list1.size(); i++) {
mItems.add(list1.get(i));
}
for (ItemNavigation itemNavigation : mItemsAccount) {
mItems.add(itemNavigation);
}
for (int i = 0; i < list2.size(); i++) {
mItems.add(list2.get(i));
}
return true;
}
return false;
}
public void updateSignIn() {
String name = SimiTranslator.getInstance().translate("My Account");
if (DataPreferences.isSignInComplete()) {
name = DataPreferences.getUsername();
addItemRelatedPersonal();
} else {
name = SimiTranslator.getInstance().translate("Sign in");
removeItemRelatedPersonal();
}
mDelegate.setUpdateSignIn(name);
mDelegate.setAdapter(mItems);
}
protected void dispatchItemEvent(String event_name, ArrayList<ItemNavigation> mItemsAccount) {
Intent intent = new Intent(event_name);
Bundle bundle = new Bundle();
// SimiEventLeftMenuEntity leftEntity = new SimiEventLeftMenuEntity();
// leftEntity.setMenu(mMenu);
HashMap<String, Object> hmData = new HashMap<>();
hmData.put(KeyData.SLIDE_MENU.LIST_ITEMS, mItemsAccount);
hmData.put(KeyData.SLIDE_MENU.LIST_FRAGMENTS, mPluginFragment);
SimiData data = new SimiData(hmData);
bundle.putParcelable("entity", data);
intent.putExtra("data", bundle);
LocalBroadcastManager.getInstance(mContext).sendBroadcastSync(intent);
}
protected void dispatchOnClickEvent(String event_name, String item_name) {
Intent intent = new Intent(event_name);
Bundle bundle = new Bundle();
HashMap<String, Object> hmData = new HashMap<>();
hmData.put(KeyData.SLIDE_MENU.ITEM_NAME, item_name);
SimiData data = new SimiData(hmData);
bundle.putParcelable("entity", data);
intent.putExtra("data", bundle);
LocalBroadcastManager.getInstance(mContext).sendBroadcastSync(intent);
}
}
| 20,527 | 0.560384 | 0.558387 | 575 | 34.699131 | 23.784208 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.587826 | false | false | 4 |
cb51e269ca57b8847a161c474c94d2574a9c95b8 | 36,713,380,471,260 | 57728206bbcfc486e7a5606b894fa9009a8b9a88 | /agent/src/com/cloud/agent/resource/computing/LibvirtStorageVolumeDef.java | 2449edbd508eb73aa435755cd2f7983f5003df7f | [] | no_license | chiragjog/CloudStack | https://github.com/chiragjog/CloudStack | ae790a261045ebbf68a33d8dd1a86e6b479a5770 | 6279ca28d6e274fba980527f39b89e9af2bf588a | refs/heads/master | 2021-01-18T03:36:30.256000 | 2012-02-24T01:18:50 | 2012-02-24T01:18:50 | 2,956,218 | 2 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.agent.resource.computing;
public class LibvirtStorageVolumeDef {
public enum volFormat {
RAW("raw"), QCOW2("qcow2"), DIR("dir");
private String _format;
volFormat(String format) {
_format = format;
}
@Override
public String toString() {
return _format;
}
public static volFormat getFormat(String format) {
if (format == null) {
return null;
}
if (format.equalsIgnoreCase("raw")) {
return RAW;
} else if (format.equalsIgnoreCase("qcow2")) {
return QCOW2;
}
return null;
}
}
private String _volName;
private Long _volSize;
private volFormat _volFormat;
private String _backingPath;
private volFormat _backingFormat;
public LibvirtStorageVolumeDef(String volName, Long size, volFormat format,
String tmplPath, volFormat tmplFormat) {
_volName = volName;
_volSize = size;
_volFormat = format;
_backingPath = tmplPath;
_backingFormat = tmplFormat;
}
public volFormat getFormat() {
return this._volFormat;
}
@Override
public String toString() {
StringBuilder storageVolBuilder = new StringBuilder();
storageVolBuilder.append("<volume>\n");
storageVolBuilder.append("<name>" + _volName + "</name>\n");
if (_volSize != null) {
storageVolBuilder
.append("<capacity >" + _volSize + "</capacity>\n");
}
storageVolBuilder.append("<target>\n");
storageVolBuilder.append("<format type='" + _volFormat + "'/>\n");
storageVolBuilder.append("<permissions>");
storageVolBuilder.append("<mode>0744</mode>");
storageVolBuilder.append("</permissions>");
storageVolBuilder.append("</target>\n");
if (_backingPath != null) {
storageVolBuilder.append("<backingStore>\n");
storageVolBuilder.append("<path>" + _backingPath + "</path>\n");
storageVolBuilder.append("<format type='" + _backingFormat
+ "'/>\n");
storageVolBuilder.append("</backingStore>\n");
}
storageVolBuilder.append("</volume>\n");
return storageVolBuilder.toString();
}
}
| UTF-8 | Java | 2,751 | java | LibvirtStorageVolumeDef.java | Java | [] | null | [] | /**
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
*
* This software is licensed under the GNU General Public License v3 or later.
*
* It is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.cloud.agent.resource.computing;
public class LibvirtStorageVolumeDef {
public enum volFormat {
RAW("raw"), QCOW2("qcow2"), DIR("dir");
private String _format;
volFormat(String format) {
_format = format;
}
@Override
public String toString() {
return _format;
}
public static volFormat getFormat(String format) {
if (format == null) {
return null;
}
if (format.equalsIgnoreCase("raw")) {
return RAW;
} else if (format.equalsIgnoreCase("qcow2")) {
return QCOW2;
}
return null;
}
}
private String _volName;
private Long _volSize;
private volFormat _volFormat;
private String _backingPath;
private volFormat _backingFormat;
public LibvirtStorageVolumeDef(String volName, Long size, volFormat format,
String tmplPath, volFormat tmplFormat) {
_volName = volName;
_volSize = size;
_volFormat = format;
_backingPath = tmplPath;
_backingFormat = tmplFormat;
}
public volFormat getFormat() {
return this._volFormat;
}
@Override
public String toString() {
StringBuilder storageVolBuilder = new StringBuilder();
storageVolBuilder.append("<volume>\n");
storageVolBuilder.append("<name>" + _volName + "</name>\n");
if (_volSize != null) {
storageVolBuilder
.append("<capacity >" + _volSize + "</capacity>\n");
}
storageVolBuilder.append("<target>\n");
storageVolBuilder.append("<format type='" + _volFormat + "'/>\n");
storageVolBuilder.append("<permissions>");
storageVolBuilder.append("<mode>0744</mode>");
storageVolBuilder.append("</permissions>");
storageVolBuilder.append("</target>\n");
if (_backingPath != null) {
storageVolBuilder.append("<backingStore>\n");
storageVolBuilder.append("<path>" + _backingPath + "</path>\n");
storageVolBuilder.append("<format type='" + _backingFormat
+ "'/>\n");
storageVolBuilder.append("</backingStore>\n");
}
storageVolBuilder.append("</volume>\n");
return storageVolBuilder.toString();
}
}
| 2,751 | 0.69611 | 0.691021 | 93 | 28.580645 | 23.903625 | 87 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2 | false | false | 4 |
c11f07f5cf676c316b89b5eac60f2d9d08c3c9d8 | 4,355,096,879,184 | affb2cb9369d1432d8ccc50a3733506ec3e6da54 | /app/test/db/Test_FooLocalDAO.java | ed17e207be40673762bd38aaf94e0fd2b4e0590f | [
"Apache-2.0"
] | permissive | TsungHan-Wen/playMyBatisMariaDB | https://github.com/TsungHan-Wen/playMyBatisMariaDB | f9d630cadda1a29b518286699ebabc8038997f49 | a33c44795a5428e6b6f0dae4002e74345defd687 | refs/heads/master | 2023-05-09T14:01:01.725000 | 2021-05-24T11:51:41 | 2021-05-24T11:51:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package test.db;
import org.apache.ibatis.session.SqlSessionManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import error.HelperException;
import pojo.web.signup.request.SignupRequest;
import services.WebService;
public class Test_FooLocalDAO extends AbstractFooDAO{
static Test_FooLocalDAO dao;
@BeforeClass
public static void before(){
play.Logger.info("Test_FooLocalDAO , test case start");
Injector injector = Guice.createInjector(new modules.MyBatisModule());
dao = new Test_FooLocalDAO();
dao.sqlSessionManager = injector.getInstance(SqlSessionManager.class);
dao.webService = injector.getInstance(WebService.class);
dao.fooServiceImpl = injector.getInstance(FooServiceImpl.class);
}
@Test
public void case1(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 1 Test SessionManager rollback - start");
SignupRequest request = new SignupRequest();
request.setEmail("111@star.com.tw");
request.setUsername("111");
request.setPassword("111");
dao.testErrorWithSessionManager(request);
play.Logger.info("Test SessionManager rollback - end");
play.Logger.info("----------------------------------------------");
}
@Test
public void case2(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 2 Test Annation Transactional rollback - start");
SignupRequest request = new SignupRequest();
try{
request.setEmail("222@star.com.tw");
request.setUsername("222");
request.setPassword("222");
dao.testErrorWithAnnotationTransation(request);
} catch (Exception e) {
e.printStackTrace();
}
play.Logger.info("Test Annation Transactional rollback - end");
play.Logger.info("----------------------------------------------");
}
@Test
public void case3(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 3 Test Annation Transactional rollback with HelperException - start");
SignupRequest request = new SignupRequest();
try{
request.setEmail("333@star.com.tw");
request.setUsername("333");
request.setPassword("333");
dao.testErrorWithAnnotationTransation(request);
} catch (Exception e) {
HelperException.un.genException(e , request );
}
play.Logger.info("Test Annation Transactional rollback - end");
play.Logger.info("----------------------------------------------");
}
@AfterClass
public static void after(){
play.Logger.info("Test_FooLocalDAO , test case finish");
}
} | UTF-8 | Java | 2,744 | java | Test_FooLocalDAO.java | Java | [
{
"context": "uest = new SignupRequest();\n request.setEmail(\"111@star.com.tw\");\n request.setUsername(\"111\");\n request.se",
"end": 1098,
"score": 0.9998965859413147,
"start": 1083,
"tag": "EMAIL",
"value": "111@star.com.tw"
},
{
"context": "mail(\"111@star.com.tw\");\n request.setUsername(\"111\");\n request.setPassword(\"111\");\n dao.testEr",
"end": 1130,
"score": 0.9994195103645325,
"start": 1127,
"tag": "USERNAME",
"value": "111"
},
{
"context": "uest.setUsername(\"111\");\n request.setPassword(\"111\");\n dao.testErrorWithSessionManager(request);\n",
"end": 1162,
"score": 0.9993739128112793,
"start": 1159,
"tag": "PASSWORD",
"value": "111"
},
{
"context": "SignupRequest();\n try{\n request.setEmail(\"222@star.com.tw\");\n request.setUsername(\"222\");\n reques",
"end": 1631,
"score": 0.9998999834060669,
"start": 1616,
"tag": "EMAIL",
"value": "222@star.com.tw"
},
{
"context": "il(\"222@star.com.tw\");\n request.setUsername(\"222\");\n request.setPassword(\"222\");\n dao.te",
"end": 1665,
"score": 0.9994301795959473,
"start": 1662,
"tag": "USERNAME",
"value": "222"
},
{
"context": "st.setUsername(\"222\");\n request.setPassword(\"222\");\n dao.testErrorWithAnnotationTransation(re",
"end": 1699,
"score": 0.9994334578514099,
"start": 1696,
"tag": "PASSWORD",
"value": "222"
},
{
"context": "SignupRequest();\n try{\n request.setEmail(\"333@star.com.tw\");\n request.setUsername(\"333\");\n reques",
"end": 2266,
"score": 0.9999277591705322,
"start": 2251,
"tag": "EMAIL",
"value": "333@star.com.tw"
},
{
"context": "il(\"333@star.com.tw\");\n request.setUsername(\"333\");\n request.setPassword(\"333\");\n dao.te",
"end": 2300,
"score": 0.9993751645088196,
"start": 2297,
"tag": "USERNAME",
"value": "333"
},
{
"context": "st.setUsername(\"333\");\n request.setPassword(\"333\");\n dao.testErrorWithAnnotationTransation(re",
"end": 2334,
"score": 0.9991960525512695,
"start": 2331,
"tag": "PASSWORD",
"value": "333"
}
] | null | [] | package test.db;
import org.apache.ibatis.session.SqlSessionManager;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import error.HelperException;
import pojo.web.signup.request.SignupRequest;
import services.WebService;
public class Test_FooLocalDAO extends AbstractFooDAO{
static Test_FooLocalDAO dao;
@BeforeClass
public static void before(){
play.Logger.info("Test_FooLocalDAO , test case start");
Injector injector = Guice.createInjector(new modules.MyBatisModule());
dao = new Test_FooLocalDAO();
dao.sqlSessionManager = injector.getInstance(SqlSessionManager.class);
dao.webService = injector.getInstance(WebService.class);
dao.fooServiceImpl = injector.getInstance(FooServiceImpl.class);
}
@Test
public void case1(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 1 Test SessionManager rollback - start");
SignupRequest request = new SignupRequest();
request.setEmail("<EMAIL>");
request.setUsername("111");
request.setPassword("111");
dao.testErrorWithSessionManager(request);
play.Logger.info("Test SessionManager rollback - end");
play.Logger.info("----------------------------------------------");
}
@Test
public void case2(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 2 Test Annation Transactional rollback - start");
SignupRequest request = new SignupRequest();
try{
request.setEmail("<EMAIL>");
request.setUsername("222");
request.setPassword("222");
dao.testErrorWithAnnotationTransation(request);
} catch (Exception e) {
e.printStackTrace();
}
play.Logger.info("Test Annation Transactional rollback - end");
play.Logger.info("----------------------------------------------");
}
@Test
public void case3(){
play.Logger.info("----------------------------------------------");
play.Logger.info("Case 3 Test Annation Transactional rollback with HelperException - start");
SignupRequest request = new SignupRequest();
try{
request.setEmail("<EMAIL>");
request.setUsername("333");
request.setPassword("333");
dao.testErrorWithAnnotationTransation(request);
} catch (Exception e) {
HelperException.un.genException(e , request );
}
play.Logger.info("Test Annation Transactional rollback - end");
play.Logger.info("----------------------------------------------");
}
@AfterClass
public static void after(){
play.Logger.info("Test_FooLocalDAO , test case finish");
}
} | 2,720 | 0.628644 | 0.616618 | 84 | 31.678572 | 25.52364 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.595238 | false | false | 4 |
3e06b27b8530a526d815237db9c37fa62624024d | 36,790,689,877,683 | 6ca021455d3cfd5f6f1998175c7ff8a7fd7a670a | /src/main/java/com/automation/test/OrderBooking.java | 2db289fc7a5c2940644abb07169d6e3704249765 | [] | no_license | analyst-anju/AutomationExercise | https://github.com/analyst-anju/AutomationExercise | 53ed7866e28f8d64fd1e87d8a6458967971d9dda | b92fb703f38d3b009baf737b8cd1f4e98e712014 | refs/heads/master | 2020-04-14T01:56:00.288000 | 2018-12-30T10:38:38 | 2018-12-30T10:38:38 | 163,573,052 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.automation.test;
import java.io.File;
import java.io.FileReader;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OrderBooking
{
public WebDriver driver = null;
public Properties properties = new Properties();
private static Logger logger = LoggerFactory.getLogger(OrderBooking.class);
public WebDriver setUp() throws Exception
{
logger.info("properties file is at src/test/resources/test.properties");
properties.load(new FileReader(new File("src/test/resources/test.properties")));
// Dont Change below line. Set this value in test.properties file incase you need to change it..
System.setProperty("webdriver.chrome.driver", properties.getProperty("webdriver.chrome.driver"));
driver = new ChromeDriver();
return driver;
}
public OrderBooking()
{
try
{
driver = setUp();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public WebDriver openWebsite(String urlName)
{
driver.get(urlName);
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Sign in")));
driver.manage().window().maximize();
driver.findElement(By.linkText("Sign in")).click();
return driver;
}
public void assertPageLogin(String userName)
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(userName)));
}
public void clickOnTab(String tabName)
{
WebElement we = driver.findElement(By.xpath("//div[@id='block_top_menu']/ul/li[3]/a"));
if (we.getAttribute("title").equals(tabName))
{
we.click();
}
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[text()='Catalog']")));
}
public void hoverItem(String itemName)
{
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath(String.format("//img[@title=\'%s\']", itemName)));
js.executeScript("arguments[0].scrollIntoView();", we);
Actions ac = new Actions(driver);
ac.moveToElement(we).moveToElement(driver.findElement(By.xpath(String.format("//a[@title=\'%s\']", "Add to cart")))).click().build().perform();
}
public void onPopUp() throws InterruptedException
{
WebElement we = driver.findElement(By.xpath("//div[@id='layer_cart']"));
Thread.sleep(10000); // static wait put coz elements on same page, will improve on it
we.findElement(By.xpath("//a[@title='Proceed to checkout']")).click();
}
public void onCartSummary()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Your shopping cart']")));
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//div[@id='center_column']//a[@title='Proceed to checkout']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onAddress()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Addresses']")));
// button processAddress name
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='processAddress']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onShipping()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Shipping']")));
// input id cgv
driver.findElement(By.xpath("//input[@id='cgv']")).click();
// button name processCarrier
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='processCarrier']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onPayment()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Your payment method']")));
}
public void clickLoggedUser(String userName)
{
/*
* WebDriverWait wait=new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(userName)));
*/
driver.findElement(By.linkText(userName)).click();
}
public void assertOrderDetails()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Order history']")));
}
public void clickButtonOnProfile()
{
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='submitIdentity']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
}
| UTF-8 | Java | 5,723 | java | OrderBooking.java | Java | [
{
"context": "Conditions.visibilityOfElementLocated(By.linkText(userName)));\r\n */\r\n\r\n driver.findElement(By.lin",
"end": 5131,
"score": 0.6862004399299622,
"start": 5123,
"tag": "USERNAME",
"value": "userName"
}
] | null | [] | package com.automation.test;
import java.io.File;
import java.io.FileReader;
import java.util.Properties;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class OrderBooking
{
public WebDriver driver = null;
public Properties properties = new Properties();
private static Logger logger = LoggerFactory.getLogger(OrderBooking.class);
public WebDriver setUp() throws Exception
{
logger.info("properties file is at src/test/resources/test.properties");
properties.load(new FileReader(new File("src/test/resources/test.properties")));
// Dont Change below line. Set this value in test.properties file incase you need to change it..
System.setProperty("webdriver.chrome.driver", properties.getProperty("webdriver.chrome.driver"));
driver = new ChromeDriver();
return driver;
}
public OrderBooking()
{
try
{
driver = setUp();
}
catch (Exception e)
{
e.printStackTrace();
}
}
public WebDriver openWebsite(String urlName)
{
driver.get(urlName);
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("Sign in")));
driver.manage().window().maximize();
driver.findElement(By.linkText("Sign in")).click();
return driver;
}
public void assertPageLogin(String userName)
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(userName)));
}
public void clickOnTab(String tabName)
{
WebElement we = driver.findElement(By.xpath("//div[@id='block_top_menu']/ul/li[3]/a"));
if (we.getAttribute("title").equals(tabName))
{
we.click();
}
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//p[text()='Catalog']")));
}
public void hoverItem(String itemName)
{
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath(String.format("//img[@title=\'%s\']", itemName)));
js.executeScript("arguments[0].scrollIntoView();", we);
Actions ac = new Actions(driver);
ac.moveToElement(we).moveToElement(driver.findElement(By.xpath(String.format("//a[@title=\'%s\']", "Add to cart")))).click().build().perform();
}
public void onPopUp() throws InterruptedException
{
WebElement we = driver.findElement(By.xpath("//div[@id='layer_cart']"));
Thread.sleep(10000); // static wait put coz elements on same page, will improve on it
we.findElement(By.xpath("//a[@title='Proceed to checkout']")).click();
}
public void onCartSummary()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Your shopping cart']")));
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//div[@id='center_column']//a[@title='Proceed to checkout']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onAddress()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Addresses']")));
// button processAddress name
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='processAddress']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onShipping()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Shipping']")));
// input id cgv
driver.findElement(By.xpath("//input[@id='cgv']")).click();
// button name processCarrier
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='processCarrier']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
public void onPayment()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Your payment method']")));
}
public void clickLoggedUser(String userName)
{
/*
* WebDriverWait wait=new WebDriverWait(driver, 20); wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText(userName)));
*/
driver.findElement(By.linkText(userName)).click();
}
public void assertOrderDetails()
{
WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[text()='Order history']")));
}
public void clickButtonOnProfile()
{
JavascriptExecutor js = (JavascriptExecutor) driver;
WebElement we = driver.findElement(By.xpath("//button[@name='submitIdentity']"));
js.executeScript("arguments[0].scrollIntoView();", we);
we.click();
}
}
| 5,723 | 0.66556 | 0.660143 | 155 | 34.922581 | 34.598625 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625806 | false | false | 4 |
0b7c67c04120b248d1b8cfb37e37d11a7965e41d | 7,129,645,777,137 | f32315bb87b0e0d6d4842295be520623c2d50d52 | /regerege_rekka/src/main/java/debug/DisplayAutomaton.java | c89b4dc393dc880a20eeffabf70bca5a3db1c0ad | [
"MIT"
] | permissive | Hiipivahalko/regerege_rekka | https://github.com/Hiipivahalko/regerege_rekka | 7513e430cfa6aa5a119a2fbdf563649533a8f3ee | 6faf792389fe26fef4a3ac39d91b290f1734dc41 | refs/heads/master | 2020-07-21T12:38:40.777000 | 2019-10-30T14:30:10 | 2019-10-30T14:30:10 | 206,867,148 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package debug;
import automaton.node.Node;
import java.util.LinkedList;
public class DisplayAutomaton {
public DisplayAutomaton() {
}
public void displayNFA(LinkedList<Node> mNfa) {
System.out.println("-----NFA-----");
for (Node n : mNfa) {
if (n.isGoalNode()) System.out.println("goal " + n.getId());
for (char i : n.getTransfers().keySet()) {
for (Node n2 : n.getTransfers().get(i)) {
System.out.println(n.getId() + " --> " + n2.getId() + " : " + i);
}
}
}
}
public void displayDFA(LinkedList<Node> mDfa) {
System.out.println("------DFA-------");
for (Node n : mDfa) {
if (n.isGoalNode()) System.out.println("goal " + n.getNodeSet());
for (char c : n.getTransfers().keySet()) {
for (Node n2 : n.getTransfers().get(c)) {
System.out.println(n.getNodeSet() + " -> " + n2.getNodeSet() + " : " + c);
}
}
}
}
}
| UTF-8 | Java | 1,065 | java | DisplayAutomaton.java | Java | [] | null | [] | package debug;
import automaton.node.Node;
import java.util.LinkedList;
public class DisplayAutomaton {
public DisplayAutomaton() {
}
public void displayNFA(LinkedList<Node> mNfa) {
System.out.println("-----NFA-----");
for (Node n : mNfa) {
if (n.isGoalNode()) System.out.println("goal " + n.getId());
for (char i : n.getTransfers().keySet()) {
for (Node n2 : n.getTransfers().get(i)) {
System.out.println(n.getId() + " --> " + n2.getId() + " : " + i);
}
}
}
}
public void displayDFA(LinkedList<Node> mDfa) {
System.out.println("------DFA-------");
for (Node n : mDfa) {
if (n.isGoalNode()) System.out.println("goal " + n.getNodeSet());
for (char c : n.getTransfers().keySet()) {
for (Node n2 : n.getTransfers().get(c)) {
System.out.println(n.getNodeSet() + " -> " + n2.getNodeSet() + " : " + c);
}
}
}
}
}
| 1,065 | 0.474178 | 0.470423 | 37 | 27.783783 | 27.081594 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.243243 | false | false | 4 |
9dd535cfa692fb29eaf9cecfc353971e3cb45ea1 | 4,509,715,715,503 | e7a8f80d82a599df6d0c6e777402ba5b39ba8038 | /java/NorthBreeze/src/main/java/northwind/service/AppContextListener.java | 9034716dfd40db07abdeef8889e0aa1975cc360d | [
"MIT"
] | permissive | wegiangb/breeze.js.samples | https://github.com/wegiangb/breeze.js.samples | f87392f0c3a930bbc60c6447efc6099816ab7c28 | de6a267fdca4b0b8c17f8040138d275a64d6dc37 | refs/heads/master | 2020-05-07T19:30:31.964000 | 2017-04-17T16:31:54 | 2017-04-17T16:31:54 | 180,815,959 | 1 | 0 | null | true | 2019-04-11T14:59:52 | 2019-04-11T14:59:51 | 2019-03-23T17:24:02 | 2017-04-17T16:31:54 | 10,224 | 0 | 0 | 0 | null | false | false | package northwind.service;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.breezejs.Metadata;
import com.breezejs.hib.MetadataBuilder;
@WebListener
public class AppContextListener implements ServletContextListener {
public static final String SESSIONFACTORY = "sessionFactory";
public static final String METADATA = "metadata";
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("AppContextListener.contextInitialized begin");
// configures settings from hibernate.cfg.xml
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();
System.out.println("AppContextListener.contextInitialized: sessionFactory=" + sessionFactory);
// builds metadata from the Hibernate mappings
MetadataBuilder metaGen = new MetadataBuilder(sessionFactory, configuration);
Metadata metadata = metaGen.buildMetadata();
System.out.println("AppContextListener.contextInitialized: metadata=" + metadata);
// Set the values in the context so they can be used in the NorthBreeze service class
ServletContext ctx = sce.getServletContext();
ctx.setAttribute(SESSIONFACTORY, sessionFactory);
ctx.setAttribute(METADATA, metadata);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// Clean up when the app is shut down
ServletContext ctx = sce.getServletContext();
SessionFactory sessionFactory = (SessionFactory) ctx.getAttribute(SESSIONFACTORY);
if (sessionFactory != null) {
sessionFactory.close();
}
}
}
| UTF-8 | Java | 1,776 | java | AppContextListener.java | Java | [] | null | [] | package northwind.service;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.breezejs.Metadata;
import com.breezejs.hib.MetadataBuilder;
@WebListener
public class AppContextListener implements ServletContextListener {
public static final String SESSIONFACTORY = "sessionFactory";
public static final String METADATA = "metadata";
@Override
public void contextInitialized(ServletContextEvent sce) {
System.out.println("AppContextListener.contextInitialized begin");
// configures settings from hibernate.cfg.xml
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();
System.out.println("AppContextListener.contextInitialized: sessionFactory=" + sessionFactory);
// builds metadata from the Hibernate mappings
MetadataBuilder metaGen = new MetadataBuilder(sessionFactory, configuration);
Metadata metadata = metaGen.buildMetadata();
System.out.println("AppContextListener.contextInitialized: metadata=" + metadata);
// Set the values in the context so they can be used in the NorthBreeze service class
ServletContext ctx = sce.getServletContext();
ctx.setAttribute(SESSIONFACTORY, sessionFactory);
ctx.setAttribute(METADATA, metadata);
}
@Override
public void contextDestroyed(ServletContextEvent sce) {
// Clean up when the app is shut down
ServletContext ctx = sce.getServletContext();
SessionFactory sessionFactory = (SessionFactory) ctx.getAttribute(SESSIONFACTORY);
if (sessionFactory != null) {
sessionFactory.close();
}
}
}
| 1,776 | 0.798986 | 0.798986 | 51 | 33.823528 | 28.611465 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.509804 | false | false | 4 |
3f67a05341425e2d9a4eda99b1be296812c56843 | 38,998,303,076,431 | d3419ceaa95c3f112b4e17447bdd3d2b5ddef6a9 | /src/main/java/org/phantomapi/hud/package-info.java | 137ba21a0645d838bf183784404240eb777c00b5 | [
"WTFPL"
] | permissive | DiyarSavda/Phantom | https://github.com/DiyarSavda/Phantom | 97f1185da2409b68a959512fdfb6126ddd276044 | f2f293692d1d7790d0dfb018f689f46f6bb7ff52 | refs/heads/master | 2021-01-01T17:15:04.167000 | 2017-07-22T13:37:57 | 2017-07-22T13:37:57 | 98,033,512 | 0 | 0 | null | true | 2017-07-22T13:37:00 | 2017-07-22T13:37:00 | 2017-04-01T03:58:52 | 2017-07-18T00:50:33 | 152,777 | 0 | 0 | 0 | null | null | null | /**
* Ingame huds with holograms
*
* @author cyberpwn
*/
package org.phantomapi.hud; | UTF-8 | Java | 89 | java | package-info.java | Java | [
{
"context": "/**\n * Ingame huds with holograms\n * \n * @author cyberpwn\n */\npackage org.phantomapi.hud;",
"end": 57,
"score": 0.9995564222335815,
"start": 49,
"tag": "USERNAME",
"value": "cyberpwn"
}
] | null | [] | /**
* Ingame huds with holograms
*
* @author cyberpwn
*/
package org.phantomapi.hud; | 89 | 0.674157 | 0.674157 | 6 | 14 | 11.416363 | 29 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.166667 | false | false | 4 |
34951ea252a34b4c20543029487fe826ee8c0e49 | 3,410,204,086,389 | 7018a20b16f6262127c24c1aff47e3432f245a26 | /Automata_Minimo_Equivalente/src/model/AutomataImp.java | fee942b1c11c71a55e1fcab53ee040987cc8b9a7 | [] | no_license | Jhusseth/Informatica_Teorica | https://github.com/Jhusseth/Informatica_Teorica | 621f4639e834aac83b891e20fca93ed2d0fe9908 | f18eacb2c36c3a0125ec3178c98b517f4bc21022 | refs/heads/master | 2023-01-23T14:02:13.986000 | 2020-11-21T14:33:59 | 2020-11-21T14:33:59 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
public class AutomataImp implements Automata {
/**
* The states in a machine
*/
private HashMap<String,String> states;
/**
* Input alphabet of the machine
*/
private HashSet<Character> inputAlphabet;
/**
* The output alphabet of the machine
*/
private HashSet<String> outputAlphabet;
/**
* Initial state in the machine
*/
private String stateInitial;
/**
* Rows in the machine
*/
private Integer rows;
/**
* Type of machine, True for Mealy and False for Moore.
*/
private boolean type;
/**
* The matrix of automata
*/
private HashMap<String,String[]> data;
/**
* Contructor
* @param type - machine state True for Mealy and False for Moore
*/
public AutomataImp (boolean type) {
data = new HashMap<String,String[]>();
states = new HashMap<String,String>();
inputAlphabet = new HashSet<Character>();
outputAlphabet = new HashSet<String>();
this.type=type;
}
@Override
public String[][] getInitialTable() {
String[][] rst = new String[data.keySet().size()+1][rows+1];
int i = 0;
for (Character c : inputAlphabet) {
rst[0][i+1] = c+"";
i++;
}
i = 0;
for (String out : data.keySet()) {
rst[i+1][0] = out;
i++;
}
i = 1;
for (String key : data.keySet()) {
if (data.get(key)==null)
data.put(key, new String[rows]);
for (int j = 0; j < data.get(key).length; j++) {
rst[i][j+1] = data.get(key)[j];
}
i++;
}
return rst;
}
@Override
public String[][] calculate() {
HashSet<String> a = stepOne();
ArrayList<ArrayList<String>> b = stepTwo(a);
String[][] c = stepThree(b);
return c;
}
@Override
public boolean setInitialData(String[] initialData) {
if (initialData[0].length()<1 || initialData[1].length()<1 || initialData[2].length()<1 || initialData[3].length()<1)
return false;
String[] Q = initialData[0].split(" ");
String[] S = initialData[1].split(" ");
rows = type ? S.length:S.length+1;
String[] R = initialData[2].split(" ");
String q1 = initialData[3].toString();
boolean entroQ1 = false;
for (String aux: S) {
if (aux.length()>1)
return false;
inputAlphabet.add(aux.charAt(0));
}
for (String aux : R) {
if (aux.length()>1)
return false;
outputAlphabet.add(aux);
}
for (String aux: Q) {
if (!data.containsKey(aux)) {
if (q1.equals(aux)) {
this.stateInitial = aux;
entroQ1 = true;
}
data.put(aux,null);
}
}
return entroQ1;
}
@Override
public boolean addRow(String[] add) {
if (add.length<1)
return false;
if (type) {
for (String s : add) {
if (s.length()<1)
return false;
states.put(s.substring(0,s.length()-1),s.substring(s.length()-1));
}
}
for (String aux: add) {
String tmp[] = aux.split(" ");
if (tmp.length!=(rows+1) || !data.containsKey(tmp[0]))
return false;
String rowAdd[] = new String[rows];
for (int i = 1; i < tmp.length; i++)
rowAdd[i-1] = tmp[i];
data.put(tmp[0],rowAdd);
}
return true;
}
/**
* A recursive method that get out the accessible states from a given
* @param visited that help to store the states visited
* @param add with the state to add
* @return a hashSet collection that has all the states accessible from add
*/
private HashSet<String> aux(HashSet<String> visited,String add) {
if (visited.contains(add))
return visited;
visited.add(add);
for (String v : data.get(add)) {
v = v.split("\r")[0];
if (!type && outputAlphabet.contains(v))
break;
aux(visited, type ? v.substring(0, v.length()-1):v);
}
return visited;
}
@Override
public HashSet<String> stepOne() {
HashSet<String> t = aux(new HashSet<String>(),stateInitial);
return t;
}
@Override
public ArrayList<ArrayList<String>> stepTwo(HashSet<String> q) {
ArrayList<ArrayList<String>> rst = stepTwoA(q);
rst = stepTwoB(rst);
return rst;
}
/**
* Method for step To One, gets the start partition
* @param cEq with all states it has to work
* @return a list of list that has the blocks of first partition
*/
private ArrayList<ArrayList<String>> stepTwoA(HashSet<String> cEq) {
ArrayList<ArrayList<String>> rst = new ArrayList<ArrayList<String>>();
HashMap<String,HashSet<String>> aux = new HashMap<String,HashSet<String>>();
for (String actual : cEq) {
String[] b = data.get(actual);
String key = !type ? data.get(actual)[data.get(actual).length-1]:"";
key = key.split("\r")[0];
if (type) {
for (String a : b) {
a = a.split("\r")[0];
key += a.charAt(a.length()-1);
}
}
HashSet<String> tmp = aux.getOrDefault(key, new HashSet<String>());
if (!tmp.contains(actual))
tmp.add(actual);
aux.put(key, tmp);
}
for (String s : aux.keySet()) {
ArrayList<String> tmp = new ArrayList<String>();
tmp.addAll(aux.get(s));
rst.add(tmp);
}
return rst;
}
/**
* Method to find the states achievable from a state
* @param tmp the state to know their accessible states
* @return a list with their accessible nodes
*/
private ArrayList<String> findStatesAchievable(String tmp) {
ArrayList<String> rst = new ArrayList<String>();
for (String a : data.get(tmp)) {
a = a.split("\r")[0];
if (!type && outputAlphabet.contains(a))
break;
rst.add(type ? a.substring(0, a.length()-1):a);
}
return rst;
}
/**
* Method to find the first achievable states from a given state
* @param arr with the partition to search
* @param tmp the state to find
* @return a block where the state tmp is
*/
private ArrayList<String> findStatesFirstAchievable(ArrayList<ArrayList<String>> arr, String tmp) {
for (ArrayList<String> a : arr) {
for (String s : a) {
if (tmp.equals(s))
return a;
}
}
return null;
}
/**
* Method to know if to states belongs to same block of a partition
* @param arr with the partition to search
* @param tmp with the name of state one
* @param tmp2 with the name of state two
* @return
*/
private Boolean isPartOfSameBlock(ArrayList<ArrayList<String>> arr, String tmp, String tmp2) {
ArrayList<String> auxTmp = findStatesAchievable(tmp);
ArrayList<String> auxTmp2 = findStatesAchievable(tmp2);
if (auxTmp.size()!=auxTmp2.size())
return false;
for (int i = 0; i < auxTmp.size(); i++) {
String a = auxTmp.get(i);
String b = auxTmp2.get(i);
if (findStatesFirstAchievable(arr,a)!=findStatesFirstAchievable(arr,b))
return false;
}
return true;
}
/**
* Method for step Two B that help to get next partition of a given
* @param parts that represents the partition that has to be partitioned again
* @return the final partition equivalent
*/
private ArrayList<ArrayList<String>> stepTwoB(ArrayList<ArrayList<String>> parts) {
ArrayList<ArrayList<String>> rst = new ArrayList<ArrayList<String>>();
for (ArrayList<String> arr : parts) {
String tmp = arr.get(0);
ArrayList<String> aux = new ArrayList<>();
ArrayList<String> aux2 = new ArrayList<>();
rst.add(aux);
aux.add(tmp);
for (int i = 1; i < arr.size(); i++) {
String tmp2 = arr.get(i);
if (isPartOfSameBlock(parts,tmp,tmp2))
aux.add(tmp2);
else
aux2.add(tmp2);
}
if (aux2.size()>0 && !rst.contains(aux2))
rst.add(aux2);
}
while (!stepTwoC(parts,rst)) {
parts = rst;
rst = stepTwoB(rst);
}
return rst;
}
/**
* Method to check if to partitions are equal
* @param pm with one partition
* @param pm1 with another partition
* @return true if there equal, false otherwise
*/
private Boolean stepTwoC(ArrayList<ArrayList<String>> pm,ArrayList<ArrayList<String>> pm1) {
if (pm.size()!=pm1.size())
return false;
for (int i = 0; i < pm.size(); i++) {
if (pm.get(i).size()!=pm1.get(i).size())
return false;
for (int j = 0; j < pm.get(i).size(); j++) {
if (!pm.get(i).get(j).equals(pm.get(i).get(j)))
return false;
}
}
return true;
}
/**
* Method to find the index of a state in a partition
* @param stepTwo it's the partition where to search
* @param find it's the state to find
* @return the index where was found the state in the partition
*/
private int findQn(ArrayList<ArrayList<String>> stepTwo, String find) {
int i = -1;
for (ArrayList<String> arr : stepTwo) {
for (String arr2 : arr) {
if (arr2.equals(find))
return i+1;
}
i++;
}
return i+1;
}
@Override
public String[][] stepThree(ArrayList<ArrayList<String>> stepTwo) {
HashMap<String,HashSet<String>> veryHelpful = new HashMap<String,HashSet<String>>();
String[][] rst = new String[stepTwo.size()+1][rows+1];
rst[0][0] = " ";
int a = 1;
for (Character c : inputAlphabet) {
rst[0][a] = c+"";
a++;
}
if (!type)
rst[0][rows] = "";
a = 1;
for (int i = 0; i < stepTwo.size(); i++) { //Each qn
rst[i+1][0] = "S"+a;
HashSet<String> helpful = new HashSet<String>();
veryHelpful.put(rst[i+1][0],helpful);
String test = stepTwo.get(i).get(0);
for (int j = 0; j < inputAlphabet.size(); j++) {
String cell = data.get(test)[j];
cell = cell.split("\r")[0];
String qn = "S"+(findQn(stepTwo, type ? cell.substring(0,cell.length()-1):cell)+1);
qn = type ? qn+"/"+cell.substring(cell.length()-1):qn;
rst[i+1][j+1] = qn;
helpful.add(data.get(test)[rows-1].split("\r")[0]);
}
a++;
}
if (!type) {
for (int i = 0; i < veryHelpful.keySet().size(); i++) {
String key = (String) veryHelpful.keySet().toArray()[i];
rst[i+1][rows] = veryHelpful.get(key).toArray()[0].toString();
}
}
return rst;
}
@Override
public void restart () {
this.data = new HashMap<String,String[]>();
this.states = new HashMap<String,String>();
this.inputAlphabet = new HashSet<Character>();
this.outputAlphabet = new HashSet<String>();
}
}
| UTF-8 | Java | 9,937 | java | AutomataImp.java | Java | [
{
"context": "ta.get(actual).length-1]:\"\";\n\t\t\tkey = key.split(\"\\r\")[0];\n\t\t\tif (type) {\n\t\t\t\tfor (String a : b) {\n\t\t\t\t\ta",
"end": 4577,
"score": 0.7747454047203064,
"start": 4573,
"tag": "KEY",
"value": "r\")["
}
] | null | [] | package model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
public class AutomataImp implements Automata {
/**
* The states in a machine
*/
private HashMap<String,String> states;
/**
* Input alphabet of the machine
*/
private HashSet<Character> inputAlphabet;
/**
* The output alphabet of the machine
*/
private HashSet<String> outputAlphabet;
/**
* Initial state in the machine
*/
private String stateInitial;
/**
* Rows in the machine
*/
private Integer rows;
/**
* Type of machine, True for Mealy and False for Moore.
*/
private boolean type;
/**
* The matrix of automata
*/
private HashMap<String,String[]> data;
/**
* Contructor
* @param type - machine state True for Mealy and False for Moore
*/
public AutomataImp (boolean type) {
data = new HashMap<String,String[]>();
states = new HashMap<String,String>();
inputAlphabet = new HashSet<Character>();
outputAlphabet = new HashSet<String>();
this.type=type;
}
@Override
public String[][] getInitialTable() {
String[][] rst = new String[data.keySet().size()+1][rows+1];
int i = 0;
for (Character c : inputAlphabet) {
rst[0][i+1] = c+"";
i++;
}
i = 0;
for (String out : data.keySet()) {
rst[i+1][0] = out;
i++;
}
i = 1;
for (String key : data.keySet()) {
if (data.get(key)==null)
data.put(key, new String[rows]);
for (int j = 0; j < data.get(key).length; j++) {
rst[i][j+1] = data.get(key)[j];
}
i++;
}
return rst;
}
@Override
public String[][] calculate() {
HashSet<String> a = stepOne();
ArrayList<ArrayList<String>> b = stepTwo(a);
String[][] c = stepThree(b);
return c;
}
@Override
public boolean setInitialData(String[] initialData) {
if (initialData[0].length()<1 || initialData[1].length()<1 || initialData[2].length()<1 || initialData[3].length()<1)
return false;
String[] Q = initialData[0].split(" ");
String[] S = initialData[1].split(" ");
rows = type ? S.length:S.length+1;
String[] R = initialData[2].split(" ");
String q1 = initialData[3].toString();
boolean entroQ1 = false;
for (String aux: S) {
if (aux.length()>1)
return false;
inputAlphabet.add(aux.charAt(0));
}
for (String aux : R) {
if (aux.length()>1)
return false;
outputAlphabet.add(aux);
}
for (String aux: Q) {
if (!data.containsKey(aux)) {
if (q1.equals(aux)) {
this.stateInitial = aux;
entroQ1 = true;
}
data.put(aux,null);
}
}
return entroQ1;
}
@Override
public boolean addRow(String[] add) {
if (add.length<1)
return false;
if (type) {
for (String s : add) {
if (s.length()<1)
return false;
states.put(s.substring(0,s.length()-1),s.substring(s.length()-1));
}
}
for (String aux: add) {
String tmp[] = aux.split(" ");
if (tmp.length!=(rows+1) || !data.containsKey(tmp[0]))
return false;
String rowAdd[] = new String[rows];
for (int i = 1; i < tmp.length; i++)
rowAdd[i-1] = tmp[i];
data.put(tmp[0],rowAdd);
}
return true;
}
/**
* A recursive method that get out the accessible states from a given
* @param visited that help to store the states visited
* @param add with the state to add
* @return a hashSet collection that has all the states accessible from add
*/
private HashSet<String> aux(HashSet<String> visited,String add) {
if (visited.contains(add))
return visited;
visited.add(add);
for (String v : data.get(add)) {
v = v.split("\r")[0];
if (!type && outputAlphabet.contains(v))
break;
aux(visited, type ? v.substring(0, v.length()-1):v);
}
return visited;
}
@Override
public HashSet<String> stepOne() {
HashSet<String> t = aux(new HashSet<String>(),stateInitial);
return t;
}
@Override
public ArrayList<ArrayList<String>> stepTwo(HashSet<String> q) {
ArrayList<ArrayList<String>> rst = stepTwoA(q);
rst = stepTwoB(rst);
return rst;
}
/**
* Method for step To One, gets the start partition
* @param cEq with all states it has to work
* @return a list of list that has the blocks of first partition
*/
private ArrayList<ArrayList<String>> stepTwoA(HashSet<String> cEq) {
ArrayList<ArrayList<String>> rst = new ArrayList<ArrayList<String>>();
HashMap<String,HashSet<String>> aux = new HashMap<String,HashSet<String>>();
for (String actual : cEq) {
String[] b = data.get(actual);
String key = !type ? data.get(actual)[data.get(actual).length-1]:"";
key = key.split("\r")[0];
if (type) {
for (String a : b) {
a = a.split("\r")[0];
key += a.charAt(a.length()-1);
}
}
HashSet<String> tmp = aux.getOrDefault(key, new HashSet<String>());
if (!tmp.contains(actual))
tmp.add(actual);
aux.put(key, tmp);
}
for (String s : aux.keySet()) {
ArrayList<String> tmp = new ArrayList<String>();
tmp.addAll(aux.get(s));
rst.add(tmp);
}
return rst;
}
/**
* Method to find the states achievable from a state
* @param tmp the state to know their accessible states
* @return a list with their accessible nodes
*/
private ArrayList<String> findStatesAchievable(String tmp) {
ArrayList<String> rst = new ArrayList<String>();
for (String a : data.get(tmp)) {
a = a.split("\r")[0];
if (!type && outputAlphabet.contains(a))
break;
rst.add(type ? a.substring(0, a.length()-1):a);
}
return rst;
}
/**
* Method to find the first achievable states from a given state
* @param arr with the partition to search
* @param tmp the state to find
* @return a block where the state tmp is
*/
private ArrayList<String> findStatesFirstAchievable(ArrayList<ArrayList<String>> arr, String tmp) {
for (ArrayList<String> a : arr) {
for (String s : a) {
if (tmp.equals(s))
return a;
}
}
return null;
}
/**
* Method to know if to states belongs to same block of a partition
* @param arr with the partition to search
* @param tmp with the name of state one
* @param tmp2 with the name of state two
* @return
*/
private Boolean isPartOfSameBlock(ArrayList<ArrayList<String>> arr, String tmp, String tmp2) {
ArrayList<String> auxTmp = findStatesAchievable(tmp);
ArrayList<String> auxTmp2 = findStatesAchievable(tmp2);
if (auxTmp.size()!=auxTmp2.size())
return false;
for (int i = 0; i < auxTmp.size(); i++) {
String a = auxTmp.get(i);
String b = auxTmp2.get(i);
if (findStatesFirstAchievable(arr,a)!=findStatesFirstAchievable(arr,b))
return false;
}
return true;
}
/**
* Method for step Two B that help to get next partition of a given
* @param parts that represents the partition that has to be partitioned again
* @return the final partition equivalent
*/
private ArrayList<ArrayList<String>> stepTwoB(ArrayList<ArrayList<String>> parts) {
ArrayList<ArrayList<String>> rst = new ArrayList<ArrayList<String>>();
for (ArrayList<String> arr : parts) {
String tmp = arr.get(0);
ArrayList<String> aux = new ArrayList<>();
ArrayList<String> aux2 = new ArrayList<>();
rst.add(aux);
aux.add(tmp);
for (int i = 1; i < arr.size(); i++) {
String tmp2 = arr.get(i);
if (isPartOfSameBlock(parts,tmp,tmp2))
aux.add(tmp2);
else
aux2.add(tmp2);
}
if (aux2.size()>0 && !rst.contains(aux2))
rst.add(aux2);
}
while (!stepTwoC(parts,rst)) {
parts = rst;
rst = stepTwoB(rst);
}
return rst;
}
/**
* Method to check if to partitions are equal
* @param pm with one partition
* @param pm1 with another partition
* @return true if there equal, false otherwise
*/
private Boolean stepTwoC(ArrayList<ArrayList<String>> pm,ArrayList<ArrayList<String>> pm1) {
if (pm.size()!=pm1.size())
return false;
for (int i = 0; i < pm.size(); i++) {
if (pm.get(i).size()!=pm1.get(i).size())
return false;
for (int j = 0; j < pm.get(i).size(); j++) {
if (!pm.get(i).get(j).equals(pm.get(i).get(j)))
return false;
}
}
return true;
}
/**
* Method to find the index of a state in a partition
* @param stepTwo it's the partition where to search
* @param find it's the state to find
* @return the index where was found the state in the partition
*/
private int findQn(ArrayList<ArrayList<String>> stepTwo, String find) {
int i = -1;
for (ArrayList<String> arr : stepTwo) {
for (String arr2 : arr) {
if (arr2.equals(find))
return i+1;
}
i++;
}
return i+1;
}
@Override
public String[][] stepThree(ArrayList<ArrayList<String>> stepTwo) {
HashMap<String,HashSet<String>> veryHelpful = new HashMap<String,HashSet<String>>();
String[][] rst = new String[stepTwo.size()+1][rows+1];
rst[0][0] = " ";
int a = 1;
for (Character c : inputAlphabet) {
rst[0][a] = c+"";
a++;
}
if (!type)
rst[0][rows] = "";
a = 1;
for (int i = 0; i < stepTwo.size(); i++) { //Each qn
rst[i+1][0] = "S"+a;
HashSet<String> helpful = new HashSet<String>();
veryHelpful.put(rst[i+1][0],helpful);
String test = stepTwo.get(i).get(0);
for (int j = 0; j < inputAlphabet.size(); j++) {
String cell = data.get(test)[j];
cell = cell.split("\r")[0];
String qn = "S"+(findQn(stepTwo, type ? cell.substring(0,cell.length()-1):cell)+1);
qn = type ? qn+"/"+cell.substring(cell.length()-1):qn;
rst[i+1][j+1] = qn;
helpful.add(data.get(test)[rows-1].split("\r")[0]);
}
a++;
}
if (!type) {
for (int i = 0; i < veryHelpful.keySet().size(); i++) {
String key = (String) veryHelpful.keySet().toArray()[i];
rst[i+1][rows] = veryHelpful.get(key).toArray()[0].toString();
}
}
return rst;
}
@Override
public void restart () {
this.data = new HashMap<String,String[]>();
this.states = new HashMap<String,String>();
this.inputAlphabet = new HashSet<Character>();
this.outputAlphabet = new HashSet<String>();
}
}
| 9,937 | 0.622421 | 0.611452 | 395 | 24.156961 | 22.533142 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.524051 | false | false | 4 |
699f203febef27e32ac33b9fdca56254bec21828 | 3,410,204,087,342 | 2501d4bcb9b9aba3ce8cc79710a9984e43ecd5b0 | /src/test/java/com/tuin/web/controller/MenuControllerTest.java | df00176e25261af11074e7ce7537246ad53b9d8d | [
"MIT"
] | permissive | appecapps/tuinstrflt | https://github.com/appecapps/tuinstrflt | e7cd904baade0eabf5614c132670d7011e5f7451 | c525c491c84cc496e02c01967e40463dd0be5672 | refs/heads/master | 2021-01-20T21:19:44.775000 | 2017-08-29T13:57:11 | 2017-08-29T13:57:11 | 101,764,569 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.tuin.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
//--- Entities
import com.tuin.bean.Menu;
import com.tuin.test.MenuFactoryForTest;
//--- Services
import com.tuin.business.service.MenuService;
import com.tuin.web.common.Message;
import com.tuin.web.common.MessageHelper;
import com.tuin.web.common.MessageType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.context.MessageSource;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@RunWith(MockitoJUnitRunner.class)
public class MenuControllerTest {
@InjectMocks
private MenuController menuController;
@Mock
private MenuService menuService;
@Mock
private MessageHelper messageHelper;
@Mock
private MessageSource messageSource;
private MenuFactoryForTest menuFactoryForTest = new MenuFactoryForTest();
private void givenPopulateModel() {
}
@Test
public void list() {
// Given
Model model = new ExtendedModelMap();
List<Menu> list = new ArrayList<Menu>();
when(menuService.findAll()).thenReturn(list);
// When
String viewName = menuController.list(model);
// Then
assertEquals("menu/list", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(list, modelMap.get("list"));
}
@Test
public void formForCreate() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
// When
String viewName = menuController.formForCreate(model);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertNull(((Menu)modelMap.get("menu")).getId());
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
}
@Test
public void formForUpdate() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
when(menuService.findById(id)).thenReturn(menu);
// When
String viewName = menuController.formForUpdate(model, id);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
}
@Test
public void createOk() {
// Given
Model model = new ExtendedModelMap();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
Menu menuCreated = new Menu();
when(menuService.create(menu)).thenReturn(menuCreated);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("redirect:/menu/form/"+menu.getId(), viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menuCreated, (Menu) modelMap.get("menu"));
assertEquals(null, modelMap.get("mode"));
assertEquals(null, modelMap.get("saveAction"));
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"save.ok"));
}
@Test
public void createBindingResultErrors() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(true);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
}
@Test
public void createException() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(false);
Menu menu = menuFactoryForTest.newMenu();
Exception exception = new RuntimeException("test exception");
when(menuService.create(menu)).thenThrow(exception);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
Mockito.verify(messageHelper).addException(model, "menu.error.create", exception);
}
@Test
public void updateOk() {
// Given
Model model = new ExtendedModelMap();
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
BindingResult bindingResult = mock(BindingResult.class);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
Menu menuSaved = new Menu();
menuSaved.setId(id);
when(menuService.update(menu)).thenReturn(menuSaved);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("redirect:/menu/form/"+menu.getId(), viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menuSaved, (Menu) modelMap.get("menu"));
assertEquals(null, modelMap.get("mode"));
assertEquals(null, modelMap.get("saveAction"));
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"save.ok"));
}
@Test
public void updateBindingResultErrors() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(true);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
}
@Test
public void updateException() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(false);
Menu menu = menuFactoryForTest.newMenu();
Exception exception = new RuntimeException("test exception");
when(menuService.update(menu)).thenThrow(exception);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
Mockito.verify(messageHelper).addException(model, "menu.error.update", exception);
}
@Test
public void deleteOK() {
// Given
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
// When
String viewName = menuController.delete(redirectAttributes, id);
// Then
verify(menuService).delete(id);
assertEquals("redirect:/menu", viewName);
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"delete.ok"));
}
@Test
public void deleteException() {
// Given
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
Exception exception = new RuntimeException("test exception");
doThrow(exception).when(menuService).delete(id);
// When
String viewName = menuController.delete(redirectAttributes, id);
// Then
verify(menuService).delete(id);
assertEquals("redirect:/menu", viewName);
Mockito.verify(messageHelper).addException(redirectAttributes, "menu.error.delete", exception);
}
}
| UTF-8 | Java | 9,611 | java | MenuControllerTest.java | Java | [] | null | [] | package com.tuin.web.controller;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
//--- Entities
import com.tuin.bean.Menu;
import com.tuin.test.MenuFactoryForTest;
//--- Services
import com.tuin.business.service.MenuService;
import com.tuin.web.common.Message;
import com.tuin.web.common.MessageHelper;
import com.tuin.web.common.MessageType;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.springframework.context.MessageSource;
import org.springframework.ui.ExtendedModelMap;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@RunWith(MockitoJUnitRunner.class)
public class MenuControllerTest {
@InjectMocks
private MenuController menuController;
@Mock
private MenuService menuService;
@Mock
private MessageHelper messageHelper;
@Mock
private MessageSource messageSource;
private MenuFactoryForTest menuFactoryForTest = new MenuFactoryForTest();
private void givenPopulateModel() {
}
@Test
public void list() {
// Given
Model model = new ExtendedModelMap();
List<Menu> list = new ArrayList<Menu>();
when(menuService.findAll()).thenReturn(list);
// When
String viewName = menuController.list(model);
// Then
assertEquals("menu/list", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(list, modelMap.get("list"));
}
@Test
public void formForCreate() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
// When
String viewName = menuController.formForCreate(model);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertNull(((Menu)modelMap.get("menu")).getId());
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
}
@Test
public void formForUpdate() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
when(menuService.findById(id)).thenReturn(menu);
// When
String viewName = menuController.formForUpdate(model, id);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
}
@Test
public void createOk() {
// Given
Model model = new ExtendedModelMap();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
Menu menuCreated = new Menu();
when(menuService.create(menu)).thenReturn(menuCreated);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("redirect:/menu/form/"+menu.getId(), viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menuCreated, (Menu) modelMap.get("menu"));
assertEquals(null, modelMap.get("mode"));
assertEquals(null, modelMap.get("saveAction"));
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"save.ok"));
}
@Test
public void createBindingResultErrors() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(true);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
}
@Test
public void createException() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(false);
Menu menu = menuFactoryForTest.newMenu();
Exception exception = new RuntimeException("test exception");
when(menuService.create(menu)).thenThrow(exception);
// When
String viewName = menuController.create(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("create", modelMap.get("mode"));
assertEquals("/menu/create", modelMap.get("saveAction"));
Mockito.verify(messageHelper).addException(model, "menu.error.create", exception);
}
@Test
public void updateOk() {
// Given
Model model = new ExtendedModelMap();
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
BindingResult bindingResult = mock(BindingResult.class);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
Menu menuSaved = new Menu();
menuSaved.setId(id);
when(menuService.update(menu)).thenReturn(menuSaved);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("redirect:/menu/form/"+menu.getId(), viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menuSaved, (Menu) modelMap.get("menu"));
assertEquals(null, modelMap.get("mode"));
assertEquals(null, modelMap.get("saveAction"));
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"save.ok"));
}
@Test
public void updateBindingResultErrors() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
Menu menu = menuFactoryForTest.newMenu();
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(true);
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
}
@Test
public void updateException() {
// Given
Model model = new ExtendedModelMap();
givenPopulateModel();
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
HttpServletRequest httpServletRequest = mock(HttpServletRequest.class);
BindingResult bindingResult = mock(BindingResult.class);
when(bindingResult.hasErrors()).thenReturn(false);
Menu menu = menuFactoryForTest.newMenu();
Exception exception = new RuntimeException("test exception");
when(menuService.update(menu)).thenThrow(exception);
// When
String viewName = menuController.update(menu, bindingResult, model, redirectAttributes, httpServletRequest);
// Then
assertEquals("menu/form", viewName);
Map<String,?> modelMap = model.asMap();
assertEquals(menu, (Menu) modelMap.get("menu"));
assertEquals("update", modelMap.get("mode"));
assertEquals("/menu/update", modelMap.get("saveAction"));
Mockito.verify(messageHelper).addException(model, "menu.error.update", exception);
}
@Test
public void deleteOK() {
// Given
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
// When
String viewName = menuController.delete(redirectAttributes, id);
// Then
verify(menuService).delete(id);
assertEquals("redirect:/menu", viewName);
Mockito.verify(messageHelper).addMessage(redirectAttributes, new Message(MessageType.SUCCESS,"delete.ok"));
}
@Test
public void deleteException() {
// Given
RedirectAttributes redirectAttributes = mock(RedirectAttributes.class);
Menu menu = menuFactoryForTest.newMenu();
Long id = menu.getId();
Exception exception = new RuntimeException("test exception");
doThrow(exception).when(menuService).delete(id);
// When
String viewName = menuController.delete(redirectAttributes, id);
// Then
verify(menuService).delete(id);
assertEquals("redirect:/menu", viewName);
Mockito.verify(messageHelper).addException(redirectAttributes, "menu.error.delete", exception);
}
}
| 9,611 | 0.737592 | 0.737592 | 338 | 27.434912 | 27.099699 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.215976 | false | false | 4 |
873cf37b61a2a253d0e63e794666bbab84a905e5 | 3,410,204,087,899 | 26ae71f1ede52a39d779ec25729c47a2e7808018 | /artxe-http/artxe-http-server/src/main/java/me/kazoku/artxe/http/simple/server/entities/Queries.java | 139c4d1eb998dbfe88b15af9e0b9b05d1395db4e | [] | no_license | takahatashun/artxe-core | https://github.com/takahatashun/artxe-core | 31196e1a3a2515433fd23de0c8d467bf6b1a759f | e31558586116efc5812352d2038a4b61a2ce0ef4 | refs/heads/master | 2023-03-22T21:53:34.222000 | 2021-03-14T06:18:35 | 2021-03-14T06:18:35 | 322,548,102 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package me.kazoku.artxe.http.simple.server.entities;
import me.kazoku.artxe.http.simple.server.util.NameValuePair;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
public class Queries {
private final Map<String, String> queryMap;
private final String queryString;
private Queries(String queryString, Map<String, String> queryMap) {
this.queryMap = queryMap;
this.queryString = queryString;
}
public static Queries fromMap(Map<String, String> queryMap) {
String queryString = queryMap.entrySet().stream()
.map(Query::newInstance)
.map(Query::toString)
.collect(Collectors.joining("&"));
return new Queries(queryString, queryMap);
}
public static Queries fromString(String rawQueries) {
if (rawQueries.isEmpty()) {
return new Queries("", Collections.emptyMap());
}
List<Query> queries = new LinkedList<>();
if (rawQueries.contains("&")) {
Scanner queryScanner = new Scanner(rawQueries);
queryScanner.useDelimiter("&");
while (queryScanner.hasNext()) queries.add(Query.parse(queryScanner.next()));
} else queries.add(Query.parse(rawQueries));
Map<String, String> queryMap = queries.stream()
.collect(Collectors.toMap(Query::getName, Query::getValue));
queryMap = Collections.unmodifiableMap(queryMap);
return new Queries(rawQueries, queryMap);
}
private static String urlEncode(String text) {
try {
return URLEncoder.encode(text, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
return text;
}
}
public boolean containField(String name) {
return queryMap.containsKey(name);
}
public String getField(String name) {
return queryMap.getOrDefault(name, null);
}
public String toString() {
return queryString;
}
public Map<String, String> toMap() {
return Collections.unmodifiableMap(queryMap);
}
private static class Query extends NameValuePair {
private Query(String name, String value) {
super(name, value);
}
private static Query newInstance(Map.Entry<String, String> entry) {
return newInstance(entry.getKey(), entry.getValue());
}
private static Query newInstance(String name, String value) {
return new Query(urlEncode(name), urlEncode(value));
}
private static Query parse(String raw) {
int index;
String name, content;
if ((index = raw.indexOf('=')) != -1) {
name = raw.substring(0, index);
content = raw.substring(index + 1).trim();
} else {
name = raw;
content = "";
}
return new Query(name, content);
}
@Override
public String toString() {
return join("=");
}
}
}
| UTF-8 | Java | 2,856 | java | Queries.java | Java | [] | null | [] | package me.kazoku.artxe.http.simple.server.entities;
import me.kazoku.artxe.http.simple.server.util.NameValuePair;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.stream.Collectors;
public class Queries {
private final Map<String, String> queryMap;
private final String queryString;
private Queries(String queryString, Map<String, String> queryMap) {
this.queryMap = queryMap;
this.queryString = queryString;
}
public static Queries fromMap(Map<String, String> queryMap) {
String queryString = queryMap.entrySet().stream()
.map(Query::newInstance)
.map(Query::toString)
.collect(Collectors.joining("&"));
return new Queries(queryString, queryMap);
}
public static Queries fromString(String rawQueries) {
if (rawQueries.isEmpty()) {
return new Queries("", Collections.emptyMap());
}
List<Query> queries = new LinkedList<>();
if (rawQueries.contains("&")) {
Scanner queryScanner = new Scanner(rawQueries);
queryScanner.useDelimiter("&");
while (queryScanner.hasNext()) queries.add(Query.parse(queryScanner.next()));
} else queries.add(Query.parse(rawQueries));
Map<String, String> queryMap = queries.stream()
.collect(Collectors.toMap(Query::getName, Query::getValue));
queryMap = Collections.unmodifiableMap(queryMap);
return new Queries(rawQueries, queryMap);
}
private static String urlEncode(String text) {
try {
return URLEncoder.encode(text, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
return text;
}
}
public boolean containField(String name) {
return queryMap.containsKey(name);
}
public String getField(String name) {
return queryMap.getOrDefault(name, null);
}
public String toString() {
return queryString;
}
public Map<String, String> toMap() {
return Collections.unmodifiableMap(queryMap);
}
private static class Query extends NameValuePair {
private Query(String name, String value) {
super(name, value);
}
private static Query newInstance(Map.Entry<String, String> entry) {
return newInstance(entry.getKey(), entry.getValue());
}
private static Query newInstance(String name, String value) {
return new Query(urlEncode(name), urlEncode(value));
}
private static Query parse(String raw) {
int index;
String name, content;
if ((index = raw.indexOf('=')) != -1) {
name = raw.substring(0, index);
content = raw.substring(index + 1).trim();
} else {
name = raw;
content = "";
}
return new Query(name, content);
}
@Override
public String toString() {
return join("=");
}
}
}
| 2,856 | 0.670868 | 0.669468 | 102 | 27 | 22.786304 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.588235 | false | false | 4 |
e89accaeb2f8472ea483a1d5a023ecc25bd7d445 | 33,870,112,151,035 | c594eb7db02a3f4c3e19ff7fb1894ee4c86583bb | /src/main/java/com/kulesh/firstapp/firstapp/student/StudentConfig.java | cec6fac60f97eb45a90a9a9892707e5392876fbe | [] | no_license | Kulesh143/firstapp | https://github.com/Kulesh143/firstapp | fea2ddce0ba8ec22f6f80b3ea55018af5b636f42 | 9a6c504167e9f2a1351c55ecda3a964519931e1c | refs/heads/master | 2023-06-30T02:32:59.938000 | 2021-07-23T10:56:40 | 2021-07-23T10:56:40 | 388,770,875 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.kulesh.firstapp.firstapp.student;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.LocalDate;
import java.time.Month;
import java.util.List;
@Configuration
public class StudentConfig {
@Bean
CommandLineRunner commandLineRunner(StudentRepository repository){
return args -> {
student Kulesh=new student(
"Kulesh",
"kulesh@yahoo.com",
LocalDate.of(1994, Month.JUNE,11)
);
student KalEl=new student(
"KalEl",
"kalel1994@yahoo.com",
LocalDate.of(2004, Month.JUNE,11)
);
repository.saveAll(List.of(Kulesh,KalEl));
};
}
}
| UTF-8 | Java | 872 | java | StudentConfig.java | Java | [
{
"context": " student Kulesh=new student(\n \"Kulesh\",\n \"kulesh@yahoo.com\",\n ",
"end": 504,
"score": 0.9998047947883606,
"start": 498,
"tag": "NAME",
"value": "Kulesh"
},
{
"context": " \"Kulesh\",\n \"kulesh@yahoo.com\",\n LocalDate.of(1994, Month.JU",
"end": 544,
"score": 0.9999275803565979,
"start": 528,
"tag": "EMAIL",
"value": "kulesh@yahoo.com"
},
{
"context": "Month.JUNE,11)\n\n );\n student KalEl=new student(\n \"KalEl\",\n ",
"end": 640,
"score": 0.7702175974845886,
"start": 637,
"tag": "NAME",
"value": "Kal"
},
{
"context": " student KalEl=new student(\n \"KalEl\",\n \"kalel1994@yahoo.com\",\n ",
"end": 682,
"score": 0.9998227953910828,
"start": 677,
"tag": "NAME",
"value": "KalEl"
},
{
"context": " \"KalEl\",\n \"kalel1994@yahoo.com\",\n LocalDate.of(2004, Month.JU",
"end": 725,
"score": 0.9999285340309143,
"start": 706,
"tag": "EMAIL",
"value": "kalel1994@yahoo.com"
}
] | null | [] | package com.kulesh.firstapp.firstapp.student;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.LocalDate;
import java.time.Month;
import java.util.List;
@Configuration
public class StudentConfig {
@Bean
CommandLineRunner commandLineRunner(StudentRepository repository){
return args -> {
student Kulesh=new student(
"Kulesh",
"<EMAIL>",
LocalDate.of(1994, Month.JUNE,11)
);
student KalEl=new student(
"KalEl",
"<EMAIL>",
LocalDate.of(2004, Month.JUNE,11)
);
repository.saveAll(List.of(Kulesh,KalEl));
};
}
}
| 851 | 0.605505 | 0.587156 | 31 | 27.129032 | 20.50923 | 70 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.645161 | false | false | 4 |
cef827ef5772bec660db905cecbb73dd5a663331 | 36,919,538,903,245 | 60ae7629086df34a23ca9905f5eeb3a638efc502 | /src/main/java/com/github/bingoohuang/building_maintainable_software/boardfactory/BoardFactoryV3.java | 5615f1bdc5a2f5d95f7688c20e2c1da0b0275cbb | [
"Apache-2.0"
] | permissive | bingoohuang/refactor-cases | https://github.com/bingoohuang/refactor-cases | 947b8bed91c4ba7f89c6335ffeda80586fa75aad | 6f8b09bffa6ebc01ba3fd8d4dbac696f368c75d4 | refs/heads/master | 2021-01-11T22:05:20.540000 | 2017-01-17T07:54:14 | 2017-01-17T07:54:14 | 78,919,327 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.bingoohuang.building_maintainable_software.boardfactory;
/**
* @author bingoohuang [bingoohuang@gmail.com] Created on 2017/1/15.
*/
public class BoardFactoryV3 {
public Board createBoard(Square[][] grid) {
return new BoardCreator(grid).create();
}
}
| UTF-8 | Java | 288 | java | BoardFactoryV3.java | Java | [
{
"context": "package com.github.bingoohuang.building_maintainable_software.boardfactory;\n\n/**",
"end": 30,
"score": 0.8296228051185608,
"start": 19,
"tag": "USERNAME",
"value": "bingoohuang"
},
{
"context": "aintainable_software.boardfactory;\n\n/**\n * @author bingoohuang [bingoohuang@gmail.com] Created on 2017/1/15.\n",
"end": 100,
"score": 0.733156681060791,
"start": 92,
"tag": "USERNAME",
"value": "bingoohu"
},
{
"context": "le_software.boardfactory;\n\n/**\n * @author bingoohuang [bingoohuang@gmail.com] Created on 2017/1/15.\n */",
"end": 103,
"score": 0.7361568212509155,
"start": 100,
"tag": "NAME",
"value": "ang"
},
{
"context": "ftware.boardfactory;\n\n/**\n * @author bingoohuang [bingoohuang@gmail.com] Created on 2017/1/15.\n */\npublic class BoardFact",
"end": 126,
"score": 0.999930739402771,
"start": 105,
"tag": "EMAIL",
"value": "bingoohuang@gmail.com"
}
] | null | [] | package com.github.bingoohuang.building_maintainable_software.boardfactory;
/**
* @author bingoohuang [<EMAIL>] Created on 2017/1/15.
*/
public class BoardFactoryV3 {
public Board createBoard(Square[][] grid) {
return new BoardCreator(grid).create();
}
}
| 274 | 0.71875 | 0.690972 | 10 | 27.799999 | 27.970699 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 4 |
bdace6b4cae84eea41ea754dd5e8c4f1d9bff5fb | 36,919,538,902,939 | 708cbfeb5cabab2a47dc578aab0233fd4865a705 | /src/main/java/com/mateus/sistema/domain/produto/Subgrupo.java | 7fb4afffe1317f58ea6a234d94fdf77dab966710 | [] | no_license | mateusrdg/sistema | https://github.com/mateusrdg/sistema | 6f06bc07e64148457f2adb87003c934c3ea3f4d2 | 39ffa90d276098cedc4e89a0b559e205a2ac626a | refs/heads/master | 2020-07-03T21:06:48.714000 | 2020-01-27T02:53:54 | 2020-01-27T02:53:54 | 202,048,279 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.mateus.sistema.domain.produto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity(name = "Subgrupo")
public class Subgrupo implements Serializable {
@Version
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String descricao;
@ManyToOne
@JoinColumn(name = "grupo_id")
private Grupo grupo;
@JsonIgnore
@OneToMany(mappedBy = "subgrupo")
private List<ProdutoSubgrupo> produtoSubgrupos = new ArrayList<ProdutoSubgrupo>();
public Subgrupo() {
}
public Subgrupo(Long id) {
this.id = id;
}
public Subgrupo(Long id, String descricao, Grupo grupo) {
this.id = id;
this.descricao = descricao;
this.grupo = grupo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Grupo getGrupo() {
return grupo;
}
public void setGrupo(Grupo grupo) {
this.grupo = grupo;
}
public List<ProdutoSubgrupo> getProdutoSubgrupos() {
return produtoSubgrupos;
}
public void setProdutoSubgrupos(List<ProdutoSubgrupo> produtoSubgrupos) {
this.produtoSubgrupos = produtoSubgrupos;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Subgrupo other = (Subgrupo) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
| UTF-8 | Java | 2,164 | java | Subgrupo.java | Java | [] | null | [] | package com.mateus.sistema.domain.produto;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Version;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity(name = "Subgrupo")
public class Subgrupo implements Serializable {
@Version
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String descricao;
@ManyToOne
@JoinColumn(name = "grupo_id")
private Grupo grupo;
@JsonIgnore
@OneToMany(mappedBy = "subgrupo")
private List<ProdutoSubgrupo> produtoSubgrupos = new ArrayList<ProdutoSubgrupo>();
public Subgrupo() {
}
public Subgrupo(Long id) {
this.id = id;
}
public Subgrupo(Long id, String descricao, Grupo grupo) {
this.id = id;
this.descricao = descricao;
this.grupo = grupo;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public Grupo getGrupo() {
return grupo;
}
public void setGrupo(Grupo grupo) {
this.grupo = grupo;
}
public List<ProdutoSubgrupo> getProdutoSubgrupos() {
return produtoSubgrupos;
}
public void setProdutoSubgrupos(List<ProdutoSubgrupo> produtoSubgrupos) {
this.produtoSubgrupos = produtoSubgrupos;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((id == null) ? 0 : id.hashCode());
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Subgrupo other = (Subgrupo) obj;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
return true;
}
}
| 2,164 | 0.716728 | 0.714418 | 106 | 19.415094 | 17.998882 | 83 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.433962 | false | false | 4 |
fb0a39488c8462a17ccf7d83684ed081eb0ba178 | 36,919,538,904,032 | 73504aa122b557eea4442644137714c97f8349f8 | /app/src/main/java/com/routehelperr/model/InfoModalModel.java | f6a607a2913b10ed73eb6471804057c2bc5a6510 | [] | no_license | mg120/RouteHelper | https://github.com/mg120/RouteHelper | 707c5bbd34a9ea60962e3182159dcc4cd338291e | ebcd99fb425a360848131aa7935d8b0c9f8d44b2 | refs/heads/master | 2020-06-13T05:21:10.504000 | 2019-06-30T18:50:50 | 2019-06-30T18:50:50 | 194,550,136 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.routehelperr.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class InfoModalModel {
@SerializedName("success")
private Boolean success;
@SerializedName("data")
private String data;
@SerializedName("message")
private ModalData message;
// Getters
public Boolean getSuccess() {
return success;
}
public String getData() {
return data;
}
public ModalData getMessage() {
return message;
}
// Message Class ...
public static class ModalData {
@SerializedName("modals")
private List<ModalYear> modals;
//Getters
public List<ModalYear> getInfo() {
return modals;
}
}
// INFO Class ...
public static class ModalYear {
@SerializedName("modalyear")
@Expose
private String modalyear;
// Getters
public String getModalyear() {
return modalyear;
}
}
}
| UTF-8 | Java | 1,117 | java | InfoModalModel.java | Java | [] | null | [] | package com.routehelperr.model;
import android.os.Parcel;
import android.os.Parcelable;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class InfoModalModel {
@SerializedName("success")
private Boolean success;
@SerializedName("data")
private String data;
@SerializedName("message")
private ModalData message;
// Getters
public Boolean getSuccess() {
return success;
}
public String getData() {
return data;
}
public ModalData getMessage() {
return message;
}
// Message Class ...
public static class ModalData {
@SerializedName("modals")
private List<ModalYear> modals;
//Getters
public List<ModalYear> getInfo() {
return modals;
}
}
// INFO Class ...
public static class ModalYear {
@SerializedName("modalyear")
@Expose
private String modalyear;
// Getters
public String getModalyear() {
return modalyear;
}
}
}
| 1,117 | 0.615936 | 0.615936 | 58 | 18.258621 | 14.733916 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.275862 | false | false | 4 |
715838d3cc4ea6689034a0389104feabb0f92cd7 | 39,135,742,021,430 | d60aa63a88af5e0a7745f272d71c4873b40899e2 | /advert-java/advert/src/main/java/com/miguan/advert/domain/mapper/AdRenderMapper.java | c3d1bfa52362f58eb89d29935cbc7c55be28e6a6 | [] | no_license | cckmit/project-6 | https://github.com/cckmit/project-6 | c3b20e9f25c28aafd8a0bcddebd37e71dccf912f | 79fe6cbe3d4c4799518c91b92b51e458892276c8 | refs/heads/master | 2023-04-03T02:28:06.358000 | 2021-03-26T09:04:32 | 2021-03-26T09:04:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.miguan.advert.domain.mapper;
public interface AdRenderMapper {
String findRNameByRKey(String platKey);
}
| UTF-8 | Java | 125 | java | AdRenderMapper.java | Java | [] | null | [] | package com.miguan.advert.domain.mapper;
public interface AdRenderMapper {
String findRNameByRKey(String platKey);
}
| 125 | 0.776 | 0.776 | 8 | 14.625 | 18.80118 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 4 |
316165b48a9ca6d6ee8c97d379dc0b40c596073c | 33,844,342,341,609 | 93e9defa76fc8d1668e885db543c5189c84734e9 | /main/java/ui/MainMenu.java | 81579accee85c5ca0b5b7caa68f40855cc0c7ffe | [] | no_license | cph-sn286/Maarioo | https://github.com/cph-sn286/Maarioo | e3cc65074eb3b39383a18ae885f0975a4cb5a80a | 7a1af987bdd5a834bb54c355743412e3b21634e9 | refs/heads/main | 2023-02-15T05:50:31.979000 | 2021-01-04T10:14:47 | 2021-01-04T10:14:47 | 320,255,524 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ui;
import com.google.protobuf.Message;
import com.sun.org.apache.xalan.internal.xsltc.trax.SmartTransformerFactoryImpl;
import com.sun.org.glassfish.external.statistics.Statistic;
import domain.MarioException;
import domain.Order;
import domain.Pizza;
import domain.Statistics;
import persistence.Database;
import persistence.DbMenuCardMapper;
import persistence.DbOrderMapper;
import javax.swing.plaf.basic.BasicBorders;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainMenu {
private final String USER = "testdb_user";
private final String PASSWORD = "1234";
private final String URL = "jdbc:mysql://localhost:3306/mario?serverTimezone=CET&useSSL=false";
private Database database;
private DbMenuCardMapper dbMenuCardMapper;
private DbOrderMapper dbOrderMapper;
boolean running = true;
public MainMenu() throws MarioException, IOException {
try {
this.database = new Database(USER, PASSWORD, URL);
} catch (MarioException e) {
System.out.println(e.getMessage());
MarioException.addLogMessage(e);
this.running = false;
// TODO: Skal logges til fil
}
this.dbMenuCardMapper = new DbMenuCardMapper(database);
this.dbOrderMapper = new DbOrderMapper(database);
}
public void mainMenuLoop() throws MarioException {
while (running) {
showMenu();
switch (Input.getInt("Vælg 1-12: ")) {
case 1:
showMenuCard();
break;
case 2:
showSinglePizza();
break;
case 3:
deletePizza();
break;
case 4:
insertPizza();
break;
case 5:
updatePizza();
break;
case 6:
showOrderList();
break;
case 7:
insertOrder();
break;
case 8:
updateOrder();
break;
case 9:
deleteOrder();
break;
case 10:
running = false;
break;
case 11:
statisticsTotal();
break;
case 12:
showOrderlistSortByPickupTime();
break;
}
}
System.out.println("Tak for denne gang!");
}
private void showMenu() {
System.out.println("**** Marios pizzabar - hovedmenu ******");
System.out.println("[1] Vis menukort [2] Vis enkelt pizza [3] Fjern pizza [4] Opret ny pizza [5] Opdater pizza [6] Vis ordrerliste [7] Indsæt ordrer [8] opdater ordrer [9] fjern ordrer [10] Afslut");
}
private void showMenuCard() {
System.out.println("**** Menukort hos Marios ******");
List<Pizza> menuCard = null;
try {
menuCard = dbMenuCardMapper.getAllPizzas();
} catch (MarioException e) {
System.out.println(e.getMessage());
}
if (menuCard != null) {
for (Pizza pizza : menuCard) {
System.out.println(pizza.toString());
}
} else {
this.running = false;
}
}
private void updatePizza() {
System.out.println("***** Opdater pizza *******");
int pizzaNo = Input.getInt("Indtast pizza nummer på den du vil rette: ");
System.out.println("Indtast ny værdi, hvis den skal rettes - eller blot <retur>: ");
Pizza pizza = null;
try {
pizza = dbMenuCardMapper.getPizzaById(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
String newPizzaNoInput = Input.getString("Pizzanummer: (" + pizza.getPizzaNo() + "): ");
if (newPizzaNoInput.length() > 0) {
pizza.setPizzaNo(Integer.parseInt(newPizzaNoInput));
}
String newPizzaNameInput = Input.getString("Pizza navn: (" + pizza.getName() + "): ");
if (newPizzaNameInput.length() > 0) {
pizza.setName(newPizzaNameInput);
}
String newPizzaIngredientsInput = Input.getString("Pizza ingredienser: (" + pizza.getIngredients() + "): ");
if (newPizzaIngredientsInput.length() > 0) {
pizza.setIngredients(newPizzaIngredientsInput);
}
String newPizzaPriceInput = Input.getString("Pizza pris: (" + pizza.getPrice() + "): ");
if (newPizzaPriceInput.length() > 0) {
pizza.setPrice(Integer.parseInt(newPizzaPriceInput));
}
boolean result = false;
try {
result = dbMenuCardMapper.updatePizza(pizza);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu opdateret");
} else {
System.out.println("Vi kunne desværre ikke opdatere den nye pizza.");
}
}
private void insertPizza() {
System.out.println("**** Opret ny pizza *******");
int pizzaNo = Input.getInt("Indtast pizza nummer: ");
String name = Input.getString("Indtast navn på pizza: ");
String ingredients = Input.getString("Indtast indhold: ");
int price = Input.getInt("Indtast pris: ");
Pizza newPizza = new Pizza(pizzaNo, name, ingredients, price);
Pizza insertedPizza = null;
try {
insertedPizza = dbMenuCardMapper.insertPizza(newPizza);
} catch (MarioException e) {
e.printStackTrace();
}
if (insertedPizza != null) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu tilføjet");
System.out.println("Pizzaen har fået DB id = " + insertedPizza.getPizzaId());
} else {
System.out.println("Vi kunne desværre ikke oprette den nye pizza. PizzaNo findes allerede.");
}
}
private void deletePizza() {
int pizzaNo = Input.getInt("Indtast nummer på pizza som skal fjernes: ");
boolean result = false;
try {
result = dbMenuCardMapper.deletePizza(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu fjernet");
} else {
System.out.println("Pizzaen med nr = " + pizzaNo + " findes ikke, og kan derfor ikke fjernes");
}
}
private void showSinglePizza() {
int pizzaNo = Input.getInt("Indtast pizzanummer: ");
Pizza pizza = null;
try {
pizza = dbMenuCardMapper.getPizzaById(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
if (pizza != null) {
System.out.println("Du har fundet pizza nummer: " + pizzaNo);
System.out.println(pizza.toString());
} else {
System.out.println("Pizza med nr = " + pizzaNo + " findes desværre ikke");
}
}
private void showOrderList() {
System.out.println("**** Orderliste ******");
List<Order> orderList = null;
try {
orderList = dbOrderMapper.getAllOrders();
} catch (MarioException e) {
try {
MarioException.addLogMessage(e);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
for (Order order : orderList) {
System.out.println(order.toString());
}
}
private void showOrderlistSortByPickupTime() {
System.out.println("**** Orderliste by pickup_time ****");
List<Order> orderList = null;
try {
orderList = dbOrderMapper.getAllOrdersSortByPickupTime();
} catch (MarioException e) {
e.printStackTrace();
}
for (Order order : orderList) {
System.out.println(order.toString());
}
}
private void insertOrder() {
System.out.println("*** Opret ny order *** ");
int pizzaNo = Input.getInt("Indtast pizza nummer: ");
int amount = Input.getInt("Indtast antal pizzaer: ");
String customer_name = Input.getString("Indtast dit navn: ");
String customer_phone = Input.getString("Indtast tlf nr: ");
int pickup_time = Input.getTimeInMinutes("indtast afhentningstid: ");
Order newOrder = new Order(pizzaNo, amount, customer_name, customer_phone, pickup_time);
Order insertedOrder = null;
try {
insertedOrder = dbOrderMapper.insertOrder(newOrder);
} catch (MarioException e) {
e.printStackTrace();
}
if (insertedOrder != null) {
System.out.println("Orderen med id nr: " + insertedOrder.getOrder_id() + " er nu oprettet");
System.out.println("Afhentningstidspunkt er: " + Input.getMinutesToTimeFormat(pickup_time));
} else {
System.out.println("Orderen kunne ikke oprettes");
}
}
private void updateOrder() {
System.out.println("***** Opdater Order *******");
int order_id = Input.getInt("Indtast order_id på den du vil rette: ");
System.out.println("Indtast ny værdi, hvis den skal rettes - eller blot <retur>: ");
Order order = null;
try {
order = dbOrderMapper.getOrderById(order_id);
} catch (MarioException e) {
e.printStackTrace();
}
order.setOrder_id(order_id);
String newOrderPizza_noInput = Input.getString("Pizza nummer: (" + order.getPizza_no() + "): ");
if (newOrderPizza_noInput.length() > 0) {
order.setPizza_no(Integer.parseInt(newOrderPizza_noInput));
}
String newOrderAmountInput = Input.getString("order amount: (" + order.getAmount() + "): ");
if (newOrderAmountInput.length() > 0) {
order.setAmount(Integer.parseInt(newOrderAmountInput));
}
String newCustomer_nameInput = Input.getString("Customer name: (" + order.getCustomer_name() + "): ");
if (newCustomer_nameInput.length() > 0) {
order.setCustomer_name((newCustomer_nameInput));
}
String newCustomer_phoneInput = Input.getString("Customer phone: (" + order.getCustomer_phone() + "): ");
if (newCustomer_phoneInput.length() > 0) {
order.setCustomer_phone((newCustomer_phoneInput));
}
String newPickup_timeInput = Input.getString("Pickup_time: (" + order.getPickup_time() + "): ");
if (newPickup_timeInput.length() > 0) {
order.setPickup_time((Integer.parseInt(newPickup_timeInput)));
}
boolean result = false;
try {
result = dbOrderMapper.updateOrder(order);
} catch (MarioException e) {
e.printStackTrace();
}
System.out.println(order.toString());
if (result) {
System.out.println("Orderen med id = " + order_id + " er nu opdateret");
} else {
System.out.println("Vi kunne desværre ikke opdatere ordreren.");
}
}
private void deleteOrder() {
int order_id = Input.getInt("Indtast order_id på orderen som skal fjernes: ");
boolean result = false;
try {
result = dbOrderMapper.deleteOrder(order_id);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Orderen med id nr = " + order_id + " er nu fjernet");
} else {
System.out.println("Orderen med id nr = " + order_id + " findes ikke, og kan derfor ikke fjernes");
}
}
private void statisticsTotal() throws MarioException {
Statistics statistics = new Statistics();
List<Pizza> pizzaList = dbMenuCardMapper.getAllPizzas();
List<Order> orderList = dbOrderMapper.getAllOrders();
List<Statistics> statisticsList = new ArrayList<>();
for (Pizza pizza : pizzaList) {
int totalAmount = 0;
int totalEarned = 0;
statisticsList.add(new Statistics(pizza.getPizzaNo(),pizza.getName(), totalAmount, totalEarned));
statistics.setPizzaNo(pizza.getPizzaNo());
statistics.setPizzaName(pizza.getName());
statistics.setAmountSold(totalAmount);
statistics.setTotalEarned(totalEarned);
for (Order order : orderList) {
if (pizza.getPizzaNo() == order.getPizza_no()) {
totalAmount = totalAmount + order.getAmount();
totalEarned = totalAmount * dbMenuCardMapper.getPizzaById(pizza.getPizzaNo()).getPrice();
statistics.setAmountSold(totalAmount);
statistics.setTotalEarned(totalEarned);
}
}
System.out.println(statistics);
}
}
}
| UTF-8 | Java | 13,239 | java | MainMenu.java | Java | [
{
"context": "lass MainMenu {\n\n private final String USER = \"testdb_user\";\n private final String PASSWORD = \"1234\";\n ",
"end": 605,
"score": 0.9949580430984497,
"start": 594,
"tag": "USERNAME",
"value": "testdb_user"
},
{
"context": "estdb_user\";\n private final String PASSWORD = \"1234\";\n private final String URL = \"jdbc:mysql://lo",
"end": 649,
"score": 0.9992558360099792,
"start": 645,
"tag": "PASSWORD",
"value": "1234"
},
{
"context": "void showMenu() {\n System.out.println(\"**** Marios pizzabar - hovedmenu ******\");\n System.out",
"end": 2759,
"score": 0.8719004392623901,
"start": 2753,
"tag": "NAME",
"value": "Marios"
},
{
"context": "() {\n System.out.println(\"**** Menukort hos Marios ******\");\n List<Pizza> menuCard = nul",
"end": 3087,
"score": 0.6909427046775818,
"start": 3086,
"tag": "NAME",
"value": "M"
}
] | null | [] | package ui;
import com.google.protobuf.Message;
import com.sun.org.apache.xalan.internal.xsltc.trax.SmartTransformerFactoryImpl;
import com.sun.org.glassfish.external.statistics.Statistic;
import domain.MarioException;
import domain.Order;
import domain.Pizza;
import domain.Statistics;
import persistence.Database;
import persistence.DbMenuCardMapper;
import persistence.DbOrderMapper;
import javax.swing.plaf.basic.BasicBorders;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainMenu {
private final String USER = "testdb_user";
private final String PASSWORD = "<PASSWORD>";
private final String URL = "jdbc:mysql://localhost:3306/mario?serverTimezone=CET&useSSL=false";
private Database database;
private DbMenuCardMapper dbMenuCardMapper;
private DbOrderMapper dbOrderMapper;
boolean running = true;
public MainMenu() throws MarioException, IOException {
try {
this.database = new Database(USER, PASSWORD, URL);
} catch (MarioException e) {
System.out.println(e.getMessage());
MarioException.addLogMessage(e);
this.running = false;
// TODO: Skal logges til fil
}
this.dbMenuCardMapper = new DbMenuCardMapper(database);
this.dbOrderMapper = new DbOrderMapper(database);
}
public void mainMenuLoop() throws MarioException {
while (running) {
showMenu();
switch (Input.getInt("Vælg 1-12: ")) {
case 1:
showMenuCard();
break;
case 2:
showSinglePizza();
break;
case 3:
deletePizza();
break;
case 4:
insertPizza();
break;
case 5:
updatePizza();
break;
case 6:
showOrderList();
break;
case 7:
insertOrder();
break;
case 8:
updateOrder();
break;
case 9:
deleteOrder();
break;
case 10:
running = false;
break;
case 11:
statisticsTotal();
break;
case 12:
showOrderlistSortByPickupTime();
break;
}
}
System.out.println("Tak for denne gang!");
}
private void showMenu() {
System.out.println("**** Marios pizzabar - hovedmenu ******");
System.out.println("[1] Vis menukort [2] Vis enkelt pizza [3] Fjern pizza [4] Opret ny pizza [5] Opdater pizza [6] Vis ordrerliste [7] Indsæt ordrer [8] opdater ordrer [9] fjern ordrer [10] Afslut");
}
private void showMenuCard() {
System.out.println("**** Menukort hos Marios ******");
List<Pizza> menuCard = null;
try {
menuCard = dbMenuCardMapper.getAllPizzas();
} catch (MarioException e) {
System.out.println(e.getMessage());
}
if (menuCard != null) {
for (Pizza pizza : menuCard) {
System.out.println(pizza.toString());
}
} else {
this.running = false;
}
}
private void updatePizza() {
System.out.println("***** Opdater pizza *******");
int pizzaNo = Input.getInt("Indtast pizza nummer på den du vil rette: ");
System.out.println("Indtast ny værdi, hvis den skal rettes - eller blot <retur>: ");
Pizza pizza = null;
try {
pizza = dbMenuCardMapper.getPizzaById(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
String newPizzaNoInput = Input.getString("Pizzanummer: (" + pizza.getPizzaNo() + "): ");
if (newPizzaNoInput.length() > 0) {
pizza.setPizzaNo(Integer.parseInt(newPizzaNoInput));
}
String newPizzaNameInput = Input.getString("Pizza navn: (" + pizza.getName() + "): ");
if (newPizzaNameInput.length() > 0) {
pizza.setName(newPizzaNameInput);
}
String newPizzaIngredientsInput = Input.getString("Pizza ingredienser: (" + pizza.getIngredients() + "): ");
if (newPizzaIngredientsInput.length() > 0) {
pizza.setIngredients(newPizzaIngredientsInput);
}
String newPizzaPriceInput = Input.getString("Pizza pris: (" + pizza.getPrice() + "): ");
if (newPizzaPriceInput.length() > 0) {
pizza.setPrice(Integer.parseInt(newPizzaPriceInput));
}
boolean result = false;
try {
result = dbMenuCardMapper.updatePizza(pizza);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu opdateret");
} else {
System.out.println("Vi kunne desværre ikke opdatere den nye pizza.");
}
}
private void insertPizza() {
System.out.println("**** Opret ny pizza *******");
int pizzaNo = Input.getInt("Indtast pizza nummer: ");
String name = Input.getString("Indtast navn på pizza: ");
String ingredients = Input.getString("Indtast indhold: ");
int price = Input.getInt("Indtast pris: ");
Pizza newPizza = new Pizza(pizzaNo, name, ingredients, price);
Pizza insertedPizza = null;
try {
insertedPizza = dbMenuCardMapper.insertPizza(newPizza);
} catch (MarioException e) {
e.printStackTrace();
}
if (insertedPizza != null) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu tilføjet");
System.out.println("Pizzaen har fået DB id = " + insertedPizza.getPizzaId());
} else {
System.out.println("Vi kunne desværre ikke oprette den nye pizza. PizzaNo findes allerede.");
}
}
private void deletePizza() {
int pizzaNo = Input.getInt("Indtast nummer på pizza som skal fjernes: ");
boolean result = false;
try {
result = dbMenuCardMapper.deletePizza(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Pizzaen med nr = " + pizzaNo + " er nu fjernet");
} else {
System.out.println("Pizzaen med nr = " + pizzaNo + " findes ikke, og kan derfor ikke fjernes");
}
}
private void showSinglePizza() {
int pizzaNo = Input.getInt("Indtast pizzanummer: ");
Pizza pizza = null;
try {
pizza = dbMenuCardMapper.getPizzaById(pizzaNo);
} catch (MarioException e) {
e.printStackTrace();
}
if (pizza != null) {
System.out.println("Du har fundet pizza nummer: " + pizzaNo);
System.out.println(pizza.toString());
} else {
System.out.println("Pizza med nr = " + pizzaNo + " findes desværre ikke");
}
}
private void showOrderList() {
System.out.println("**** Orderliste ******");
List<Order> orderList = null;
try {
orderList = dbOrderMapper.getAllOrders();
} catch (MarioException e) {
try {
MarioException.addLogMessage(e);
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
for (Order order : orderList) {
System.out.println(order.toString());
}
}
private void showOrderlistSortByPickupTime() {
System.out.println("**** Orderliste by pickup_time ****");
List<Order> orderList = null;
try {
orderList = dbOrderMapper.getAllOrdersSortByPickupTime();
} catch (MarioException e) {
e.printStackTrace();
}
for (Order order : orderList) {
System.out.println(order.toString());
}
}
private void insertOrder() {
System.out.println("*** Opret ny order *** ");
int pizzaNo = Input.getInt("Indtast pizza nummer: ");
int amount = Input.getInt("Indtast antal pizzaer: ");
String customer_name = Input.getString("Indtast dit navn: ");
String customer_phone = Input.getString("Indtast tlf nr: ");
int pickup_time = Input.getTimeInMinutes("indtast afhentningstid: ");
Order newOrder = new Order(pizzaNo, amount, customer_name, customer_phone, pickup_time);
Order insertedOrder = null;
try {
insertedOrder = dbOrderMapper.insertOrder(newOrder);
} catch (MarioException e) {
e.printStackTrace();
}
if (insertedOrder != null) {
System.out.println("Orderen med id nr: " + insertedOrder.getOrder_id() + " er nu oprettet");
System.out.println("Afhentningstidspunkt er: " + Input.getMinutesToTimeFormat(pickup_time));
} else {
System.out.println("Orderen kunne ikke oprettes");
}
}
private void updateOrder() {
System.out.println("***** Opdater Order *******");
int order_id = Input.getInt("Indtast order_id på den du vil rette: ");
System.out.println("Indtast ny værdi, hvis den skal rettes - eller blot <retur>: ");
Order order = null;
try {
order = dbOrderMapper.getOrderById(order_id);
} catch (MarioException e) {
e.printStackTrace();
}
order.setOrder_id(order_id);
String newOrderPizza_noInput = Input.getString("Pizza nummer: (" + order.getPizza_no() + "): ");
if (newOrderPizza_noInput.length() > 0) {
order.setPizza_no(Integer.parseInt(newOrderPizza_noInput));
}
String newOrderAmountInput = Input.getString("order amount: (" + order.getAmount() + "): ");
if (newOrderAmountInput.length() > 0) {
order.setAmount(Integer.parseInt(newOrderAmountInput));
}
String newCustomer_nameInput = Input.getString("Customer name: (" + order.getCustomer_name() + "): ");
if (newCustomer_nameInput.length() > 0) {
order.setCustomer_name((newCustomer_nameInput));
}
String newCustomer_phoneInput = Input.getString("Customer phone: (" + order.getCustomer_phone() + "): ");
if (newCustomer_phoneInput.length() > 0) {
order.setCustomer_phone((newCustomer_phoneInput));
}
String newPickup_timeInput = Input.getString("Pickup_time: (" + order.getPickup_time() + "): ");
if (newPickup_timeInput.length() > 0) {
order.setPickup_time((Integer.parseInt(newPickup_timeInput)));
}
boolean result = false;
try {
result = dbOrderMapper.updateOrder(order);
} catch (MarioException e) {
e.printStackTrace();
}
System.out.println(order.toString());
if (result) {
System.out.println("Orderen med id = " + order_id + " er nu opdateret");
} else {
System.out.println("Vi kunne desværre ikke opdatere ordreren.");
}
}
private void deleteOrder() {
int order_id = Input.getInt("Indtast order_id på orderen som skal fjernes: ");
boolean result = false;
try {
result = dbOrderMapper.deleteOrder(order_id);
} catch (MarioException e) {
e.printStackTrace();
}
if (result) {
System.out.println("Orderen med id nr = " + order_id + " er nu fjernet");
} else {
System.out.println("Orderen med id nr = " + order_id + " findes ikke, og kan derfor ikke fjernes");
}
}
private void statisticsTotal() throws MarioException {
Statistics statistics = new Statistics();
List<Pizza> pizzaList = dbMenuCardMapper.getAllPizzas();
List<Order> orderList = dbOrderMapper.getAllOrders();
List<Statistics> statisticsList = new ArrayList<>();
for (Pizza pizza : pizzaList) {
int totalAmount = 0;
int totalEarned = 0;
statisticsList.add(new Statistics(pizza.getPizzaNo(),pizza.getName(), totalAmount, totalEarned));
statistics.setPizzaNo(pizza.getPizzaNo());
statistics.setPizzaName(pizza.getName());
statistics.setAmountSold(totalAmount);
statistics.setTotalEarned(totalEarned);
for (Order order : orderList) {
if (pizza.getPizzaNo() == order.getPizza_no()) {
totalAmount = totalAmount + order.getAmount();
totalEarned = totalAmount * dbMenuCardMapper.getPizzaById(pizza.getPizzaNo()).getPrice();
statistics.setAmountSold(totalAmount);
statistics.setTotalEarned(totalEarned);
}
}
System.out.println(statistics);
}
}
}
| 13,245 | 0.561782 | 0.558152 | 361 | 35.626038 | 29.20965 | 207 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.534626 | false | false | 4 |
c47ae49eb83d90fb6d764be410b8792783099719 | 36,953,898,646,122 | 2ef4153447761f7a8668a1bfdc6e6d764c1b06d9 | /AndroidBomber/core/src/com/geekbrains/game/BombEmitter.java | b0124c338821b67f0e98eac944829c83cb0e6194 | [] | no_license | Shamil09/Bomberman | https://github.com/Shamil09/Bomberman | 6dc31e255dfaf45a0198d4a951f612456e1c50b2 | 784825518e5c2dc3cc87e7ae90b16f10cb1d7178 | refs/heads/master | 2020-03-19T18:37:03.672000 | 2018-06-10T16:00:53 | 2018-06-10T16:00:53 | 136,817,159 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.geekbrains.game;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import java.io.Serializable;
public class BombEmitter extends ObjectPool<Bomb> implements Serializable {
private transient GameScreen gs;
private transient TextureRegion textureRegion;
public void reloadResources(GameScreen gs) {
this.gs = gs;
this.textureRegion = Assets.getInstance().getAtlas().findRegion("bomb");
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).reloadResources(gs, textureRegion);
}
for (int i = 0; i < freeList.size(); i++) {
freeList.get(i).reloadResources(gs, textureRegion);
}
}
@Override
protected Bomb newObject() {
return new Bomb(gs, textureRegion);
}
public BombEmitter(GameScreen gs) {
this.gs = gs;
this.textureRegion = Assets.getInstance().getAtlas().findRegion("bomb");
this.addObjectsToFreeList(10);
}
public void update(float dt) {
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).update(dt);
}
checkPool();
}
public void render(SpriteBatch batch) {
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).render(batch);
}
}
public boolean isBombInCell(int cellX, int cellY) {
for (int i = 0; i < activeList.size(); i++) {
Bomb b = activeList.get(i);
if (b.getCellX() == cellX && b.getCellY() == cellY) {
return true;
}
}
return false;
}
public void tryToDetonateBomb(int cellX, int cellY) {
for (int i = 0; i < activeList.size(); i++) {
Bomb b = activeList.get(i);
if (b.getCellX() == cellX && b.getCellY() == cellY) {
b.detonate();
return;
}
}
}
}
| UTF-8 | Java | 1,961 | java | BombEmitter.java | Java | [] | null | [] | package com.geekbrains.game;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import java.io.Serializable;
public class BombEmitter extends ObjectPool<Bomb> implements Serializable {
private transient GameScreen gs;
private transient TextureRegion textureRegion;
public void reloadResources(GameScreen gs) {
this.gs = gs;
this.textureRegion = Assets.getInstance().getAtlas().findRegion("bomb");
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).reloadResources(gs, textureRegion);
}
for (int i = 0; i < freeList.size(); i++) {
freeList.get(i).reloadResources(gs, textureRegion);
}
}
@Override
protected Bomb newObject() {
return new Bomb(gs, textureRegion);
}
public BombEmitter(GameScreen gs) {
this.gs = gs;
this.textureRegion = Assets.getInstance().getAtlas().findRegion("bomb");
this.addObjectsToFreeList(10);
}
public void update(float dt) {
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).update(dt);
}
checkPool();
}
public void render(SpriteBatch batch) {
for (int i = 0; i < activeList.size(); i++) {
activeList.get(i).render(batch);
}
}
public boolean isBombInCell(int cellX, int cellY) {
for (int i = 0; i < activeList.size(); i++) {
Bomb b = activeList.get(i);
if (b.getCellX() == cellX && b.getCellY() == cellY) {
return true;
}
}
return false;
}
public void tryToDetonateBomb(int cellX, int cellY) {
for (int i = 0; i < activeList.size(); i++) {
Bomb b = activeList.get(i);
if (b.getCellX() == cellX && b.getCellY() == cellY) {
b.detonate();
return;
}
}
}
}
| 1,961 | 0.562978 | 0.557879 | 66 | 28.712122 | 23.612249 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.606061 | false | false | 4 |
cebb0b9944ab93158d80a2addca2f5b343e33fa9 | 34,076,270,584,087 | 8a36d00fef078eab74cb06f87dd340d6db2fd20e | /Wynk-master-test/src/main/java/wynk/com/kshitij/presenter/UrlsListListener.java | 9bb1d6c54b9a6d8f499f18808b6b7aaf5bf6df3e | [] | no_license | KshitijGulati/Wynk-Test-Kshitij | https://github.com/KshitijGulati/Wynk-Test-Kshitij | 656418c34a950db8e99bd302ac3200f11b16fc0e | 702a49375b45953e53a085fbd535af2aeb562ea5 | refs/heads/master | 2021-01-05T08:22:31.664000 | 2020-02-16T19:23:13 | 2020-02-16T19:23:13 | 240,950,990 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package wynk.com.kshitij.presenter;
import java.util.List;
import wynk.com.kshitij.model.Photo;
public interface UrlsListListener {
void updateImages(List<Photo> photoList);
}
| UTF-8 | Java | 185 | java | UrlsListListener.java | Java | [] | null | [] | package wynk.com.kshitij.presenter;
import java.util.List;
import wynk.com.kshitij.model.Photo;
public interface UrlsListListener {
void updateImages(List<Photo> photoList);
}
| 185 | 0.772973 | 0.772973 | 11 | 15.818182 | 17.846916 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 4 |
4fc3e38bdb632426e27c175fc7cb8e1c38776444 | 34,522,947,180,192 | 742cc18e9a2e845b89cac7ad1e1ee3e1e5496ba4 | /springmvc-helloworld/src/com/baidu/zhaocc/web/controller/InfoFillWizardFormController.java | a5051d97d57d2c1f2cb1a4c4d4b854a8efb20181 | [] | no_license | zhaocc1106/LearningSpringMVC | https://github.com/zhaocc1106/LearningSpringMVC | cb473b99b662d0d9e23fba7dc4c9aa042b208df8 | 650b3b31c23c05e280d9d0e417c36e820fc05505 | refs/heads/master | 2021-04-15T13:36:37.837000 | 2018-06-10T03:22:11 | 2018-06-10T03:22:11 | 126,686,828 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.baidu.zhaocc.web.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractWizardFormController;
import com.baidu.zhaocc.module.BaseInfoModel;
public class InfoFillWizardFormController extends AbstractWizardFormController {
public InfoFillWizardFormController() {
setCommandClass(BaseInfoModel.class);
setCommandName("user");
}
@Override
protected Map referenceData(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
Map map = new HashMap();
switch(page)
{
case 1:
map.put("schoolTypeList", Arrays.asList("高中", "本科", "研究生"));
break;
case 2:
map.put("cityList", Arrays.asList("北京", "上海", "天津"));
break;
}
return map;
}
@Override
protected void validatePage(Object command, Errors errors, int page,
boolean finish) {
super.validatePage(command, errors, page, finish);
}
//每一页完成后的处理
@Override
protected void postProcessPage(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
super.postProcessPage(request, command, errors, page);
}
@Override
protected ModelAndView processFinish(HttpServletRequest arg0,
HttpServletResponse arg1, Object command, BindException arg3)
throws Exception {
System.out.println("command:" + command);
return new ModelAndView("redirect:/success");
}
@Override
protected ModelAndView processCancel(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
System.out.println("command:" + command);
return new ModelAndView("redirect:/cancel");
}
}
| UTF-8 | Java | 1,977 | java | InfoFillWizardFormController.java | Java | [] | null | [] | package com.baidu.zhaocc.web.controller;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.validation.BindException;
import org.springframework.validation.Errors;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.AbstractWizardFormController;
import com.baidu.zhaocc.module.BaseInfoModel;
public class InfoFillWizardFormController extends AbstractWizardFormController {
public InfoFillWizardFormController() {
setCommandClass(BaseInfoModel.class);
setCommandName("user");
}
@Override
protected Map referenceData(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
Map map = new HashMap();
switch(page)
{
case 1:
map.put("schoolTypeList", Arrays.asList("高中", "本科", "研究生"));
break;
case 2:
map.put("cityList", Arrays.asList("北京", "上海", "天津"));
break;
}
return map;
}
@Override
protected void validatePage(Object command, Errors errors, int page,
boolean finish) {
super.validatePage(command, errors, page, finish);
}
//每一页完成后的处理
@Override
protected void postProcessPage(HttpServletRequest request, Object command,
Errors errors, int page) throws Exception {
super.postProcessPage(request, command, errors, page);
}
@Override
protected ModelAndView processFinish(HttpServletRequest arg0,
HttpServletResponse arg1, Object command, BindException arg3)
throws Exception {
System.out.println("command:" + command);
return new ModelAndView("redirect:/success");
}
@Override
protected ModelAndView processCancel(HttpServletRequest request,
HttpServletResponse response, Object command, BindException errors)
throws Exception {
System.out.println("command:" + command);
return new ModelAndView("redirect:/cancel");
}
}
| 1,977 | 0.767201 | 0.764615 | 67 | 27.850746 | 24.944269 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.104478 | false | false | 4 |
ea8bcd3220419171ed4f7452abaa24e6d68d0bca | 39,479,339,418,942 | 72d19597f5c870a8d238ee4c48a0ead69ae7b0b8 | /myc/src/main/java/gob/osinergmin/myc/domain/ui/DetalleObligacionFilter.java | 220f7b87903f2f6c18b1db2e52ed939a43ee0ab8 | [] | no_license | danteciro/AP0230-MYC | https://github.com/danteciro/AP0230-MYC | a2bfe56cd14999785e87cb3081e16bd891599998 | 2b196bd8ef1cf7119ef2c6975f325b1e77ca3429 | refs/heads/master | 2021-01-21T15:30:32.078000 | 2017-07-13T19:45:25 | 2017-07-13T19:45:25 | 91,848,046 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gob.osinergmin.myc.domain.ui;
import gob.osinergmin.myc.domain.ui.base.BasePaginatorFilter;
/**
*
* @author lbarboza
*/
public class DetalleObligacionFilter extends BasePaginatorFilter{
private Long idDetalleObligacion;
private String descripcion;
public Long getIdDetalleObligacion() {
return idDetalleObligacion;
}
public void setIdDetalleObligacion(Long idDetalleObligacion) {
this.idDetalleObligacion = idDetalleObligacion;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
} | UTF-8 | Java | 789 | java | DetalleObligacionFilter.java | Java | [
{
"context": "i.base.BasePaginatorFilter;\r\n\r\n/**\r\n *\r\n * @author lbarboza\r\n */\r\npublic class DetalleObligacionFilter extend",
"end": 238,
"score": 0.9989110231399536,
"start": 230,
"tag": "USERNAME",
"value": "lbarboza"
}
] | null | [] | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package gob.osinergmin.myc.domain.ui;
import gob.osinergmin.myc.domain.ui.base.BasePaginatorFilter;
/**
*
* @author lbarboza
*/
public class DetalleObligacionFilter extends BasePaginatorFilter{
private Long idDetalleObligacion;
private String descripcion;
public Long getIdDetalleObligacion() {
return idDetalleObligacion;
}
public void setIdDetalleObligacion(Long idDetalleObligacion) {
this.idDetalleObligacion = idDetalleObligacion;
}
public String getDescripcion() {
return descripcion;
}
public void setDescripcion(String descripcion) {
this.descripcion = descripcion;
}
} | 789 | 0.690748 | 0.690748 | 32 | 22.71875 | 22.687048 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.3125 | false | false | 4 |
447fdedf5309eb9e20e3b145a79c6611e385979b | 38,774,964,795,335 | 440212c5a06434bc31df687fa979fbbdfd47ccb3 | /src/main/java/com/bc/ui/table/cell/TableCellUIFactoryImpl.java | 15092035dc2788b832169959afd1abbca351d209 | [] | no_license | poshjosh/bctablecelluimanager | https://github.com/poshjosh/bctablecelluimanager | 06dd2c21cb8b66f74457e44c1327e17162ea6d57 | 7b427d1b95608d1e75469627e480d3c5f45227bf | refs/heads/master | 2021-01-19T11:37:55.747000 | 2018-07-21T15:12:36 | 2018-07-21T15:12:36 | 87,981,441 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Copyright 2017 NUROX Ltd.
*
* Licensed under the NUROX Ltd Software License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.looseboxes.com/legal/licenses/software.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bc.ui.table.cell;
import java.awt.Color;
import java.awt.Component;
import java.text.DateFormat;
import java.util.Objects;
import javax.swing.JLabel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
/**
* @author Chinomso Bassey Ikwuagwu on Mar 18, 2017 1:35:45 PM
*/
public class TableCellUIFactoryImpl implements TableCellUIFactory{
private final TableCellUIState tableCellUIState;
private final TableCellSize tableCellSize;
private final TableCellDisplayFormat tableCellDisplayFormat;
private final TableCellSizeManager tableCellSizeManager;
public TableCellUIFactoryImpl(int minCellHeight, int maxCellHeight, DateFormat dateFormat) {
this(new TableCellUIStateImpl(),
new TableCellSizeImpl(new TableCellDisplayFormatImpl(dateFormat), minCellHeight, maxCellHeight),
new TableCellDisplayFormatImpl(dateFormat),
new TableCellSizeManagerImpl(new ColumnWidthsImpl())
);
}
public TableCellUIFactoryImpl(
TableCellUIState tableCellUIState,
TableCellSize tableCellSize,
TableCellDisplayFormat tableCellDisplayFormat,
TableCellSizeManager tableCellSizeManager
) {
this.tableCellUIState = Objects.requireNonNull(tableCellUIState);
this.tableCellSize = Objects.requireNonNull(tableCellSize);
this.tableCellDisplayFormat = Objects.requireNonNull(tableCellDisplayFormat);
this.tableCellSizeManager = Objects.requireNonNull(tableCellSizeManager);
}
@Override
public TableCellComponentFormat getTableCellComponentFormat() {
return new TableCellComponentFormatImpl(
new TableCellComponentModelImpl(this.tableCellDisplayFormat),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public Component getRendererComponent(int columnIndex) {
return this.getComponent(columnIndex);
}
@Override
public Component getHeaderRendererComponent(int columnIndex) {
final JLabel textField = new JLabel();
textField.setBackground(Color.WHITE);
return textField;
}
@Override
public Component getEditorComponent(int columnIndex) {
return this.getComponent(columnIndex);
}
public Component getComponent(int columnIndex) {
return new TableCellTextArea();
}
@Override
public TableCellComponentModel getRendererComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
@Override
public TableCellComponentModel getHeaderRendererComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
@Override
public TableCellComponentModel getEditorComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
public TableCellComponentModel getComponentModel(int columnIndex) {
return new TableCellComponentModelImpl(this.tableCellDisplayFormat);
}
@Override
public TableCellRenderer getRenderer(int columnIndex) {
return new TableCellRendererForComponent(
this.getRendererComponent(columnIndex),
this.getRendererComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellRenderer getHeaderRenderer(int columnIndex) {
return new TableCellRendererForComponent(
this.getHeaderRendererComponent(columnIndex),
this.getHeaderRendererComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellEditor getEditor(int columnIndex) {
return new TableCellEditorForComponent(
this.getEditorComponent(columnIndex),
this.getEditorComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellSizeManager getTableCellSizeManager() {
return tableCellSizeManager;
}
public TableCellUIState getTableCellUIState() {
return tableCellUIState;
}
public TableCellSize getTableCellSize() {
return tableCellSize;
}
public TableCellDisplayFormat getTableCellDisplayFormat() {
return tableCellDisplayFormat;
}
}
| UTF-8 | Java | 5,125 | java | TableCellUIFactoryImpl.java | Java | [
{
"context": "vax.swing.table.TableCellRenderer;\n\n/**\n * @author Chinomso Bassey Ikwuagwu on Mar 18, 2017 1:35:45 PM\n */\npublic class Table",
"end": 896,
"score": 0.9998734593391418,
"start": 872,
"tag": "NAME",
"value": "Chinomso Bassey Ikwuagwu"
}
] | null | [] | /*
* Copyright 2017 NUROX Ltd.
*
* Licensed under the NUROX Ltd Software License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.looseboxes.com/legal/licenses/software.html
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.bc.ui.table.cell;
import java.awt.Color;
import java.awt.Component;
import java.text.DateFormat;
import java.util.Objects;
import javax.swing.JLabel;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
/**
* @author <NAME> on Mar 18, 2017 1:35:45 PM
*/
public class TableCellUIFactoryImpl implements TableCellUIFactory{
private final TableCellUIState tableCellUIState;
private final TableCellSize tableCellSize;
private final TableCellDisplayFormat tableCellDisplayFormat;
private final TableCellSizeManager tableCellSizeManager;
public TableCellUIFactoryImpl(int minCellHeight, int maxCellHeight, DateFormat dateFormat) {
this(new TableCellUIStateImpl(),
new TableCellSizeImpl(new TableCellDisplayFormatImpl(dateFormat), minCellHeight, maxCellHeight),
new TableCellDisplayFormatImpl(dateFormat),
new TableCellSizeManagerImpl(new ColumnWidthsImpl())
);
}
public TableCellUIFactoryImpl(
TableCellUIState tableCellUIState,
TableCellSize tableCellSize,
TableCellDisplayFormat tableCellDisplayFormat,
TableCellSizeManager tableCellSizeManager
) {
this.tableCellUIState = Objects.requireNonNull(tableCellUIState);
this.tableCellSize = Objects.requireNonNull(tableCellSize);
this.tableCellDisplayFormat = Objects.requireNonNull(tableCellDisplayFormat);
this.tableCellSizeManager = Objects.requireNonNull(tableCellSizeManager);
}
@Override
public TableCellComponentFormat getTableCellComponentFormat() {
return new TableCellComponentFormatImpl(
new TableCellComponentModelImpl(this.tableCellDisplayFormat),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public Component getRendererComponent(int columnIndex) {
return this.getComponent(columnIndex);
}
@Override
public Component getHeaderRendererComponent(int columnIndex) {
final JLabel textField = new JLabel();
textField.setBackground(Color.WHITE);
return textField;
}
@Override
public Component getEditorComponent(int columnIndex) {
return this.getComponent(columnIndex);
}
public Component getComponent(int columnIndex) {
return new TableCellTextArea();
}
@Override
public TableCellComponentModel getRendererComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
@Override
public TableCellComponentModel getHeaderRendererComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
@Override
public TableCellComponentModel getEditorComponentModel(int columnIndex) {
return this.getComponentModel(columnIndex);
}
public TableCellComponentModel getComponentModel(int columnIndex) {
return new TableCellComponentModelImpl(this.tableCellDisplayFormat);
}
@Override
public TableCellRenderer getRenderer(int columnIndex) {
return new TableCellRendererForComponent(
this.getRendererComponent(columnIndex),
this.getRendererComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellRenderer getHeaderRenderer(int columnIndex) {
return new TableCellRendererForComponent(
this.getHeaderRendererComponent(columnIndex),
this.getHeaderRendererComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellEditor getEditor(int columnIndex) {
return new TableCellEditorForComponent(
this.getEditorComponent(columnIndex),
this.getEditorComponentModel(columnIndex),
this.tableCellUIState,
this.tableCellSize
);
}
@Override
public TableCellSizeManager getTableCellSizeManager() {
return tableCellSizeManager;
}
public TableCellUIState getTableCellUIState() {
return tableCellUIState;
}
public TableCellSize getTableCellSize() {
return tableCellSize;
}
public TableCellDisplayFormat getTableCellDisplayFormat() {
return tableCellDisplayFormat;
}
}
| 5,107 | 0.701268 | 0.698341 | 155 | 32.064518 | 27.332523 | 112 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.393548 | false | false | 4 |
f2a8009b3ad960dd45544345a8bef4d6a40e0787 | 13,769,665,216,792 | 2f8f055f4ede35ccd7ea985985e3afb17d1cd7c7 | /src/HomeWork/ArithCalcInArr.java | 354189d3d9aa7a8e30dae1a98c5d796d29b85277 | [] | no_license | YuriyFilimonov/multithreading | https://github.com/YuriyFilimonov/multithreading | 8296138a0366226e3881f6e0065eaeabcc347e05 | 24430b255f8aa7b4ef9f98b84357afb208a4a0d2 | refs/heads/master | 2022-04-19T17:43:58.472000 | 2020-04-22T07:53:08 | 2020-04-22T07:53:08 | 256,969,612 | 0 | 0 | null | false | 2020-04-22T07:53:10 | 2020-04-19T10:18:13 | 2020-04-19T10:18:35 | 2020-04-22T07:53:09 | 3 | 0 | 0 | 0 | Java | false | false | package HomeWork;
public class ArithCalcInArr {
static final int size = 10_000_000;
static final int h = size / 2;
static float[] arr = new float[size];
static float[] fillArr() {
for (int i = 0; i < size; i++) {
arr[i] = 1.0f;
}
return arr;
}
synchronized static float[] arithCalc(float[] arr, int offset) {
int os = offset;
for (int i = 0; i < arr.length; i++) {
arr[i] = (float) (arr[i] * Math.sin(0.2f + (i+os) / 5) * Math.cos(0.2f + (i+os) / 5)
* Math.cos(0.4f + (i+os) / 2));
}
return arr;
}
static float[] firstThread(float[] allArr) {
float[] a1 = new float[allArr.length/2];
System.arraycopy(allArr, 0, a1, 0, allArr.length / 2);
return a1;
}
static float[] secondThread(float[] allArr) {
float[] a2 = new float[allArr.length/2];
System.arraycopy(allArr, allArr.length / 2, a2, 0, allArr.length / 2);
return a2;
}
static float[] mergArr(float[] a1, float[] a2) {
float[] arr = new float[a1.length + a2.length];
System.arraycopy(a1, 0, arr, 0, a1.length);
System.arraycopy(a2, 0, arr, a2.length, a2.length);
for (int i = 0; i <arr.length; i+=1_000_000) {
System.out.print(arr[i] + "\t");
}
System.out.println();
return arr;
}
}
| UTF-8 | Java | 1,411 | java | ArithCalcInArr.java | Java | [] | null | [] | package HomeWork;
public class ArithCalcInArr {
static final int size = 10_000_000;
static final int h = size / 2;
static float[] arr = new float[size];
static float[] fillArr() {
for (int i = 0; i < size; i++) {
arr[i] = 1.0f;
}
return arr;
}
synchronized static float[] arithCalc(float[] arr, int offset) {
int os = offset;
for (int i = 0; i < arr.length; i++) {
arr[i] = (float) (arr[i] * Math.sin(0.2f + (i+os) / 5) * Math.cos(0.2f + (i+os) / 5)
* Math.cos(0.4f + (i+os) / 2));
}
return arr;
}
static float[] firstThread(float[] allArr) {
float[] a1 = new float[allArr.length/2];
System.arraycopy(allArr, 0, a1, 0, allArr.length / 2);
return a1;
}
static float[] secondThread(float[] allArr) {
float[] a2 = new float[allArr.length/2];
System.arraycopy(allArr, allArr.length / 2, a2, 0, allArr.length / 2);
return a2;
}
static float[] mergArr(float[] a1, float[] a2) {
float[] arr = new float[a1.length + a2.length];
System.arraycopy(a1, 0, arr, 0, a1.length);
System.arraycopy(a2, 0, arr, a2.length, a2.length);
for (int i = 0; i <arr.length; i+=1_000_000) {
System.out.print(arr[i] + "\t");
}
System.out.println();
return arr;
}
}
| 1,411 | 0.518072 | 0.478384 | 47 | 29.021276 | 23.993341 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.957447 | false | false | 4 |
3b40c70103cde9b95915802dff98286947069961 | 34,119,220,256,729 | d6ab38714f7a5f0dc6d7446ec20626f8f539406a | /backend/collecting/dsfj/Java/edited/nio.DirectReadWriteByteBuffer.java | 01245efbc690fc2ab5d1b7b473f18fb52f6ec6d3 | [] | no_license | haditabatabaei/webproject | https://github.com/haditabatabaei/webproject | 8db7178affaca835b5d66daa7d47c28443b53c3d | 86b3f253e894f4368a517711bbfbe257be0259fd | refs/heads/master | 2020-04-10T09:26:25.819000 | 2018-12-08T12:21:52 | 2018-12-08T12:21:52 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
package java.nio;
import com.google.gwt.corp.compatibility.Numbers;
import com.google.gwt.typedarrays.shared.ArrayBuffer;
public final class DirectReadWriteByteBuffer extends DirectByteBuffer {
static DirectReadWriteByteBuffer copy (DirectByteBuffer other, int markOfOther) {
DirectReadWriteByteBuffer buf = new DirectReadWriteByteBuffer(other.byteArray.buffer(), other.capacity(),
other.byteArray.byteOffset());
buf.limit = other.limit();
buf.position = other.position();
buf.mark = markOfOther;
buf.order(other.order());
return buf;
}
DirectReadWriteByteBuffer (ArrayBuffer backingArray) {
super(backingArray);
}
public DirectReadWriteByteBuffer (int capacity) {
super(capacity);
}
DirectReadWriteByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) {
super(backingArray, capacity, arrayOffset);
}
public FloatBuffer asFloatBuffer () {
return DirectReadWriteFloatBufferAdapter.wrap(this);
}
public IntBuffer asIntBuffer () {
return order() == ByteOrder.nativeOrder() ? DirectReadWriteIntBufferAdapter.wrap(this) : super.asIntBuffer();
}
public ShortBuffer asShortBuffer () {
return order() == ByteOrder.nativeOrder() ? DirectReadWriteShortBufferAdapter.wrap(this) : super.asShortBuffer();
}
public ByteBuffer asReadOnlyBuffer () {
return DirectReadOnlyByteBuffer.copy(this, mark);
}
public ByteBuffer compact () {
int rem = remaining();
for (int i = 0; i < rem; i++) {
byteArray.set(i, byteArray.get(position + i));
}
position = limit - position;
limit = capacity;
mark = UNSET_MARK;
return this;
}
public ByteBuffer duplicate () {
return copy(this, mark);
}
public boolean isReadOnly () {
return false;
}
protected byte[] protectedArray () {
throw new UnsupportedOperationException();
}
protected int protectedArrayOffset () {
throw new UnsupportedOperationException();
}
protected boolean protectedHasArray () {
return true;
}
public ByteBuffer put (byte b) {
byteArray.set(position++, b);
return this;
}
public ByteBuffer put (int index, byte b) {
byteArray.set(index, b);
return this;
}
public ByteBuffer put (byte[] src, int off, int len) {
if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
if (isReadOnly()) {
throw new ReadOnlyBufferException();
}
for (int i = 0; i < len; i++) {
byteArray.set(i + position, src[off + i]);
}
position += len;
return this;
}
public ByteBuffer putDouble (double value) {
return putLong(Numbers.doubleToRawLongBits(value));
}
public ByteBuffer putDouble (int index, double value) {
return putLong(index, Numbers.doubleToRawLongBits(value));
}
public ByteBuffer putFloat (float value) {
return putInt(Numbers.floatToIntBits(value));
}
public ByteBuffer putFloat (int index, float value) {
return putInt(index, Numbers.floatToIntBits(value));
}
public ByteBuffer putInt (int value) {
int newPosition = position + 4;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer putInt (int index, int value) {
store(index, value);
return this;
}
public ByteBuffer putLong (int index, long value) {
store(index, value);
return this;
}
public ByteBuffer putLong (long value) {
int newPosition = position + 8;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer putShort (int index, short value) {
store(index, value);
return this;
}
public ByteBuffer putShort (short value) {
int newPosition = position + 2;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer slice () {
DirectReadWriteByteBuffer slice = new DirectReadWriteByteBuffer(byteArray.buffer(), remaining(),
byteArray.byteOffset() + position);
slice.order = order;
return slice;
}
}
| UTF-8 | Java | 3,932 | java | nio.DirectReadWriteByteBuffer.java | Java | [] | null | [] |
package java.nio;
import com.google.gwt.corp.compatibility.Numbers;
import com.google.gwt.typedarrays.shared.ArrayBuffer;
public final class DirectReadWriteByteBuffer extends DirectByteBuffer {
static DirectReadWriteByteBuffer copy (DirectByteBuffer other, int markOfOther) {
DirectReadWriteByteBuffer buf = new DirectReadWriteByteBuffer(other.byteArray.buffer(), other.capacity(),
other.byteArray.byteOffset());
buf.limit = other.limit();
buf.position = other.position();
buf.mark = markOfOther;
buf.order(other.order());
return buf;
}
DirectReadWriteByteBuffer (ArrayBuffer backingArray) {
super(backingArray);
}
public DirectReadWriteByteBuffer (int capacity) {
super(capacity);
}
DirectReadWriteByteBuffer (ArrayBuffer backingArray, int capacity, int arrayOffset) {
super(backingArray, capacity, arrayOffset);
}
public FloatBuffer asFloatBuffer () {
return DirectReadWriteFloatBufferAdapter.wrap(this);
}
public IntBuffer asIntBuffer () {
return order() == ByteOrder.nativeOrder() ? DirectReadWriteIntBufferAdapter.wrap(this) : super.asIntBuffer();
}
public ShortBuffer asShortBuffer () {
return order() == ByteOrder.nativeOrder() ? DirectReadWriteShortBufferAdapter.wrap(this) : super.asShortBuffer();
}
public ByteBuffer asReadOnlyBuffer () {
return DirectReadOnlyByteBuffer.copy(this, mark);
}
public ByteBuffer compact () {
int rem = remaining();
for (int i = 0; i < rem; i++) {
byteArray.set(i, byteArray.get(position + i));
}
position = limit - position;
limit = capacity;
mark = UNSET_MARK;
return this;
}
public ByteBuffer duplicate () {
return copy(this, mark);
}
public boolean isReadOnly () {
return false;
}
protected byte[] protectedArray () {
throw new UnsupportedOperationException();
}
protected int protectedArrayOffset () {
throw new UnsupportedOperationException();
}
protected boolean protectedHasArray () {
return true;
}
public ByteBuffer put (byte b) {
byteArray.set(position++, b);
return this;
}
public ByteBuffer put (int index, byte b) {
byteArray.set(index, b);
return this;
}
public ByteBuffer put (byte[] src, int off, int len) {
if (off < 0 || len < 0 || (long)off + (long)len > src.length) {
throw new IndexOutOfBoundsException();
}
if (len > remaining()) {
throw new BufferOverflowException();
}
if (isReadOnly()) {
throw new ReadOnlyBufferException();
}
for (int i = 0; i < len; i++) {
byteArray.set(i + position, src[off + i]);
}
position += len;
return this;
}
public ByteBuffer putDouble (double value) {
return putLong(Numbers.doubleToRawLongBits(value));
}
public ByteBuffer putDouble (int index, double value) {
return putLong(index, Numbers.doubleToRawLongBits(value));
}
public ByteBuffer putFloat (float value) {
return putInt(Numbers.floatToIntBits(value));
}
public ByteBuffer putFloat (int index, float value) {
return putInt(index, Numbers.floatToIntBits(value));
}
public ByteBuffer putInt (int value) {
int newPosition = position + 4;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer putInt (int index, int value) {
store(index, value);
return this;
}
public ByteBuffer putLong (int index, long value) {
store(index, value);
return this;
}
public ByteBuffer putLong (long value) {
int newPosition = position + 8;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer putShort (int index, short value) {
store(index, value);
return this;
}
public ByteBuffer putShort (short value) {
int newPosition = position + 2;
store(position, value);
position = newPosition;
return this;
}
public ByteBuffer slice () {
DirectReadWriteByteBuffer slice = new DirectReadWriteByteBuffer(byteArray.buffer(), remaining(),
byteArray.byteOffset() + position);
slice.order = order;
return slice;
}
}
| 3,932 | 0.711851 | 0.710071 | 166 | 22.674698 | 24.265404 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.849398 | false | false | 4 |
323f9fff2a883b62ada8b4b82505d571eced2dd2 | 34,119,220,256,583 | bbfa56cfc81b7145553de55829ca92f3a97fce87 | /plugins/org.ifc4emf.metamodel.ifc/src/IFC2X3/jaxb/IfcPropertyReferenceValueRef.java | 660b7dafb3ca0b135ab4fdc6faa0fe26fe207531 | [] | no_license | patins1/raas4emf | https://github.com/patins1/raas4emf | 9e24517d786a1225344a97344777f717a568fdbe | 33395d018bc7ad17a0576033779dbdf70fa8f090 | refs/heads/master | 2021-08-16T00:27:12.859000 | 2021-07-30T13:01:48 | 2021-07-30T13:01:48 | 87,889,951 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package IFC2X3.jaxb;
import javax.xml.bind.annotation.*;
import org.eclipse.emf.ecore.jaxb.*;
import IFC2X3.IFC2X3Factory;
import IFC2X3.IfcPropertyReferenceValue;
@XmlRootElement(name = "IfcPropertyReferenceValueRefElement")
public class IfcPropertyReferenceValueRef extends IFC2X3.jaxb.IfcSimplePropertyRef {
@Override
public IfcPropertyReferenceValue createInstance() {
return IFC2X3Factory.eINSTANCE.createIfcPropertyReferenceValue();
}
public static IfcPropertyReferenceValueRef valueOf(String id) {
IfcPropertyReferenceValueRef result = new IfcPropertyReferenceValueRef();
result.setID(id);
return result;
}
@Override
public String toString() {
return getID();
}
} | UTF-8 | Java | 735 | java | IfcPropertyReferenceValueRef.java | Java | [] | null | [] | package IFC2X3.jaxb;
import javax.xml.bind.annotation.*;
import org.eclipse.emf.ecore.jaxb.*;
import IFC2X3.IFC2X3Factory;
import IFC2X3.IfcPropertyReferenceValue;
@XmlRootElement(name = "IfcPropertyReferenceValueRefElement")
public class IfcPropertyReferenceValueRef extends IFC2X3.jaxb.IfcSimplePropertyRef {
@Override
public IfcPropertyReferenceValue createInstance() {
return IFC2X3Factory.eINSTANCE.createIfcPropertyReferenceValue();
}
public static IfcPropertyReferenceValueRef valueOf(String id) {
IfcPropertyReferenceValueRef result = new IfcPropertyReferenceValueRef();
result.setID(id);
return result;
}
@Override
public String toString() {
return getID();
}
} | 735 | 0.761905 | 0.745578 | 32 | 21.03125 | 25.533659 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 4 |
51a5b2ed4e948cf21fe9009f1e507f362d3ab796 | 34,565,896,856,879 | c5b4477e1d746a6b533bd0b3d376b220e1a2acfa | /WebServiceRestFull/src/java/dao/ProdutoDAO.java | 2df9b260d8277ed9c0bb8b5dfeb88942d9a2e1d8 | [] | no_license | pauloboth/Trabalho1LP3 | https://github.com/pauloboth/Trabalho1LP3 | 9aa3a77019ada4271098765f766d3cc8fe78a536 | c36994dbdc04d82aeaaac272483d88fc886a1c09 | refs/heads/master | 2016-09-10T18:25:55.838000 | 2015-11-14T00:39:50 | 2015-11-14T00:39:50 | 42,478,554 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dao;
import model.Produto;
import java.util.List;
import org.hibernate.Session;
import util.HibernateUtil;
public class ProdutoDAO {
private Session session;
public ProdutoDAO() {
session = HibernateUtil.getSessionFactory().openSession();
}
public Session getSession() {
if (session == null || !session.isOpen() || !session.isConnected()) {
session = HibernateUtil.getSessionFactory().openSession();
}
return session;
}
public void save(Produto i) {
session = HibernateUtil.getSessionFactory().openSession();
session.getTransaction().begin();
if (i.getPro_id() > 0) {
session.update(i);
} else {
session.save(i);
}
session.getTransaction().commit();
session.close();
}
public void delete(Produto i) {
session = HibernateUtil.getSessionFactory().openSession();
session.getTransaction().begin();
session.delete(i);
session.getTransaction().commit();
session.close();
}
public Produto findById(int id) {
session = HibernateUtil.getSessionFactory().openSession();
Produto m = (Produto) session.get(Produto.class, id);
session.close();
return m;
}
public List<Produto> findAll() {
session = HibernateUtil.getSessionFactory().openSession();
List<Produto> ls = session.createQuery("from Produto").list();
session.close();
return ls;
}
public Produto findEdit(int pro_id) {
session = HibernateUtil.getSessionFactory().openSession();
// Query para retornar o Produto e as especificações (fetch)
Produto p = (Produto) session.createQuery("select p from Produto p "
+ "left outer join fetch p.lsProdutoEspecificacao pe "
+ "where p.pro_id = :pro_id")
.setParameter("pro_id", pro_id)
.uniqueResult();
session.close();
return p;
}
}
| UTF-8 | Java | 2,102 | java | ProdutoDAO.java | Java | [] | null | [] | package dao;
import model.Produto;
import java.util.List;
import org.hibernate.Session;
import util.HibernateUtil;
public class ProdutoDAO {
private Session session;
public ProdutoDAO() {
session = HibernateUtil.getSessionFactory().openSession();
}
public Session getSession() {
if (session == null || !session.isOpen() || !session.isConnected()) {
session = HibernateUtil.getSessionFactory().openSession();
}
return session;
}
public void save(Produto i) {
session = HibernateUtil.getSessionFactory().openSession();
session.getTransaction().begin();
if (i.getPro_id() > 0) {
session.update(i);
} else {
session.save(i);
}
session.getTransaction().commit();
session.close();
}
public void delete(Produto i) {
session = HibernateUtil.getSessionFactory().openSession();
session.getTransaction().begin();
session.delete(i);
session.getTransaction().commit();
session.close();
}
public Produto findById(int id) {
session = HibernateUtil.getSessionFactory().openSession();
Produto m = (Produto) session.get(Produto.class, id);
session.close();
return m;
}
public List<Produto> findAll() {
session = HibernateUtil.getSessionFactory().openSession();
List<Produto> ls = session.createQuery("from Produto").list();
session.close();
return ls;
}
public Produto findEdit(int pro_id) {
session = HibernateUtil.getSessionFactory().openSession();
// Query para retornar o Produto e as especificações (fetch)
Produto p = (Produto) session.createQuery("select p from Produto p "
+ "left outer join fetch p.lsProdutoEspecificacao pe "
+ "where p.pro_id = :pro_id")
.setParameter("pro_id", pro_id)
.uniqueResult();
session.close();
return p;
}
}
| 2,102 | 0.578095 | 0.577619 | 69 | 28.434782 | 23.437538 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.550725 | false | false | 4 |
a0f486d1a9db63382e417781132b6ba598bafcf9 | 36,550,171,734,533 | a327aaa9884a48ee83ab845d9217b297dc452f7c | /src/main/java/org/hyperlinux/Linq/LinqApplication.java | 28c59b89bc9ccee12e431af7dccf5421d802a8f2 | [] | no_license | Joalien/Linq | https://github.com/Joalien/Linq | d023df74de28f30bead974ec3f8b1048c11e551f | 7e729809dcb09f0903d1047ad68365abf395b0fb | refs/heads/master | 2021-04-15T04:45:49.069000 | 2018-03-29T11:56:17 | 2018-03-29T11:56:17 | 126,823,807 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.hyperlinux.Linq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication()
public class LinqApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(LinqApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(LinqApplication.class);
}
}
| UTF-8 | Java | 649 | java | LinqApplication.java | Java | [] | null | [] | package org.hyperlinux.Linq;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication()
public class LinqApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(LinqApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(LinqApplication.class);
}
}
| 649 | 0.844376 | 0.844376 | 18 | 34.944443 | 30.09886 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.944444 | false | false | 4 |
721ad48443e71076e5498edcc197ff197e926fbc | 38,019,050,537,205 | 9b603c0a29899e91b28fb11d4256a0d954a1a5e7 | /src/org/riflemansd/businessprofit/MainTest.java | c0548a0727c3cd1abcd94c99dc868bc04dd69950 | [] | no_license | RiflemanSD/BusinessProfit | https://github.com/RiflemanSD/BusinessProfit | 7fbc682df9c63088cc4a2e031ea06676d1c49689 | 06b02791d23877f213f2563903ead841d15bb93e | refs/heads/master | 2016-08-12T14:09:52.477000 | 2016-02-04T20:30:25 | 2016-02-04T20:30:25 | 50,368,637 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* ~~ The MainTest is part of BusinessProfit. ~~
*
* The BusinessProfit's classes and any part of the code
* cannot be copied/distributed without
* the permission of Sotiris Doudis
*
* Github - RiflemanSD - https://github.com/RiflemanSD
*
* Copyright © 2016 Sotiris Doudis | All rights reserved
*
* License for BusinessProfit project - in GREEK language
*
* Οποιοσδήποτε μπορεί να χρησιμοποιήσει το πρόγραμμα για προσωπική του χρήση.
* Αλλά απαγoρεύεται η πώληση ή διακίνηση του προγράμματος σε τρίτους.
*
* Aπαγορεύεται η αντιγραφή ή διακίνηση οποιοδήποτε μέρος του κώδικα χωρίς
* την άδεια του δημιουργού.
* Σε περίπτωση που θέλετε να χρεισημοποιήσετε κάποια κλάση ή μέρος του κώδικα.
* Πρέπει να συμπεριλάβεται στο header της κλάσης τον δημιουργό και link στην
* αυθεντική κλάση (στο github).
*
* ~~ Information about BusinessProfit project - in GREEK language ~~
*
* Το BusinessProfit είναι ένα project για την αποθήκευση και επεξεργασία
* των εσόδων/εξόδων μίας επιχείρησης με σκοπό να μπορεί ο επιχειρηματίας να καθορήσει
* το καθαρό κέρδος της επιχείρησης. Καθώς και να κρατάει κάποια σημαντικά
* στατιστικά στοιχεία για τον όγκο της εργασίας κτλ..
*
* Το project δημιουργήθηκε από τον Σωτήρη Δούδη. Φοιτητή πληροφορικής του Α.Π.Θ
* για προσωπική χρήση. Αλλά και για όποιον άλλον πιθανόν το χρειαστεί.
*
* Το project προγραμματίστηκε σε Java (https://www.java.com/en/download/).
* Με χρήση του NetBeans IDE (https://netbeans.org/)
* Για να το τρέξετε πρέπει να έχετε εγκαταστήσει την java.
*
* Ο καθένας μπορεί δωρεάν να χρησιμοποιήσει το project αυτό. Αλλά δεν επιτρέπεται
* η αντιγραφή/διακήνηση του κώδικα, χωρίς την άδεια του Δημιουργού (Δείτε την License).
*
* Github - https://github.com/RiflemanSD/BusinessProfit
*
*
* Copyright © 2016 Sotiris Doudis | All rights reserved
*/
package org.riflemansd.businessprofit;
import org.riflemansd.businessprofit2.Category;
import org.riflemansd.businessprofit2.PackagesIncome;
/** <h1>MainTest</h1>
*
* <p></p>
*
* <p>Last Update: 01/02/2016</p>
* <p>Author: <a href=https://github.com/RiflemanSD>RiflemanSD</a></p>
*
* <p>Copyright © 2016 Sotiris Doudis | All rights reserved</p>
*
* @version 1.0.7
* @author RiflemanSD
*/
public class MainTest extends javax.swing.JFrame {
/**
* Creates new form MainTest
*/
public MainTest() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
par = new javax.swing.JTextField();
pal = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
value = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
par.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
pal.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton1.setText("ok");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
value.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
value.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(par, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(pal, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(value, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(pal, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
.addComponent(par))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(value, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
PackagesIncome pack = new PackagesIncome(0, new Category(0, "packages"), "test", Integer.parseInt(this.par.getText()), Integer.parseInt(this.pal.getText()));
System.out.println(pack.getValue());
this.value.setText("" + pack.getValue());
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainTest().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JTextField pal;
private javax.swing.JTextField par;
private javax.swing.JLabel value;
// End of variables declaration//GEN-END:variables
}
| UTF-8 | Java | 9,185 | java | MainTest.java | Java | [
{
"context": "the permission of Sotiris Doudis\r\n * \r\n * Github - RiflemanSD - https://github.com/RiflemanSD\r\n * \r\n * Copyrigh",
"end": 221,
"score": 0.9989180564880371,
"start": 211,
"tag": "USERNAME",
"value": "RiflemanSD"
},
{
"context": "\n * \r\n * Github - RiflemanSD - https://github.com/RiflemanSD\r\n * \r\n * Copyright © 2016 Sotiris Doudis | All ri",
"end": 253,
"score": 0.9993265867233276,
"start": 243,
"tag": "USERNAME",
"value": "RiflemanSD"
},
{
"context": "://github.com/RiflemanSD\r\n * \r\n * Copyright © 2016 Sotiris Doudis | All rights reserved\r\n * \r\n * License for Busine",
"end": 294,
"score": 0.9998886585235596,
"start": 280,
"tag": "NAME",
"value": "Sotiris Doudis"
},
{
"context": "ην License).\r\n * \r\n * Github - https://github.com/RiflemanSD/BusinessProfit\r\n * \r\n * \r\n * Copyright © 2016 Sot",
"end": 1810,
"score": 0.9955036044120789,
"start": 1800,
"tag": "USERNAME",
"value": "RiflemanSD"
},
{
"context": "anSD/BusinessProfit\r\n * \r\n * \r\n * Copyright © 2016 Sotiris Doudis | All rights reserved\r\n */\r\npackage org.riflemans",
"end": 1871,
"score": 0.999788761138916,
"start": 1857,
"tag": "NAME",
"value": "Sotiris Doudis"
},
{
"context": "016</p>\r\n * <p>Author: <a href=https://github.com/RiflemanSD>RiflemanSD</a></p>\r\n * \r\n * <p>Copyright © 2016 S",
"end": 2182,
"score": 0.9994171857833862,
"start": 2172,
"tag": "USERNAME",
"value": "RiflemanSD"
},
{
"context": " <p>Author: <a href=https://github.com/RiflemanSD>RiflemanSD</a></p>\r\n * \r\n * <p>Copyright © 2016 Sotiris Doud",
"end": 2193,
"score": 0.995273232460022,
"start": 2183,
"tag": "USERNAME",
"value": "RiflemanSD"
},
{
"context": "SD>RiflemanSD</a></p>\r\n * \r\n * <p>Copyright © 2016 Sotiris Doudis | All rights reserved</p>\r\n * \r\n * @version 1.0.7",
"end": 2245,
"score": 0.9996788501739502,
"start": 2231,
"tag": "NAME",
"value": "Sotiris Doudis"
},
{
"context": "s reserved</p>\r\n * \r\n * @version 1.0.7\r\n * @author RiflemanSD\r\n */\r\npublic class MainTest extends javax.swing.J",
"end": 2318,
"score": 0.998560905456543,
"start": 2308,
"tag": "USERNAME",
"value": "RiflemanSD"
}
] | null | [] | /* ~~ The MainTest is part of BusinessProfit. ~~
*
* The BusinessProfit's classes and any part of the code
* cannot be copied/distributed without
* the permission of Sotiris Doudis
*
* Github - RiflemanSD - https://github.com/RiflemanSD
*
* Copyright © 2016 <NAME> | All rights reserved
*
* License for BusinessProfit project - in GREEK language
*
* Οποιοσδήποτε μπορεί να χρησιμοποιήσει το πρόγραμμα για προσωπική του χρήση.
* Αλλά απαγoρεύεται η πώληση ή διακίνηση του προγράμματος σε τρίτους.
*
* Aπαγορεύεται η αντιγραφή ή διακίνηση οποιοδήποτε μέρος του κώδικα χωρίς
* την άδεια του δημιουργού.
* Σε περίπτωση που θέλετε να χρεισημοποιήσετε κάποια κλάση ή μέρος του κώδικα.
* Πρέπει να συμπεριλάβεται στο header της κλάσης τον δημιουργό και link στην
* αυθεντική κλάση (στο github).
*
* ~~ Information about BusinessProfit project - in GREEK language ~~
*
* Το BusinessProfit είναι ένα project για την αποθήκευση και επεξεργασία
* των εσόδων/εξόδων μίας επιχείρησης με σκοπό να μπορεί ο επιχειρηματίας να καθορήσει
* το καθαρό κέρδος της επιχείρησης. Καθώς και να κρατάει κάποια σημαντικά
* στατιστικά στοιχεία για τον όγκο της εργασίας κτλ..
*
* Το project δημιουργήθηκε από τον Σωτήρη Δούδη. Φοιτητή πληροφορικής του Α.Π.Θ
* για προσωπική χρήση. Αλλά και για όποιον άλλον πιθανόν το χρειαστεί.
*
* Το project προγραμματίστηκε σε Java (https://www.java.com/en/download/).
* Με χρήση του NetBeans IDE (https://netbeans.org/)
* Για να το τρέξετε πρέπει να έχετε εγκαταστήσει την java.
*
* Ο καθένας μπορεί δωρεάν να χρησιμοποιήσει το project αυτό. Αλλά δεν επιτρέπεται
* η αντιγραφή/διακήνηση του κώδικα, χωρίς την άδεια του Δημιουργού (Δείτε την License).
*
* Github - https://github.com/RiflemanSD/BusinessProfit
*
*
* Copyright © 2016 <NAME> | All rights reserved
*/
package org.riflemansd.businessprofit;
import org.riflemansd.businessprofit2.Category;
import org.riflemansd.businessprofit2.PackagesIncome;
/** <h1>MainTest</h1>
*
* <p></p>
*
* <p>Last Update: 01/02/2016</p>
* <p>Author: <a href=https://github.com/RiflemanSD>RiflemanSD</a></p>
*
* <p>Copyright © 2016 <NAME> | All rights reserved</p>
*
* @version 1.0.7
* @author RiflemanSD
*/
public class MainTest extends javax.swing.JFrame {
/**
* Creates new form MainTest
*/
public MainTest() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
par = new javax.swing.JTextField();
pal = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
value = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
par.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
pal.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
jButton1.setText("ok");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
value.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
value.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(par, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(pal, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 170, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(value, javax.swing.GroupLayout.PREFERRED_SIZE, 172, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(pal, javax.swing.GroupLayout.DEFAULT_SIZE, 32, Short.MAX_VALUE)
.addComponent(par))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(value, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
PackagesIncome pack = new PackagesIncome(0, new Category(0, "packages"), "test", Integer.parseInt(this.par.getText()), Integer.parseInt(this.pal.getText()));
System.out.println(pack.getValue());
this.value.setText("" + pack.getValue());
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(MainTest.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MainTest().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
private javax.swing.JTextField pal;
private javax.swing.JTextField par;
private javax.swing.JLabel value;
// End of variables declaration//GEN-END:variables
}
| 9,161 | 0.655127 | 0.645751 | 181 | 43.961327 | 36.568615 | 165 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.469613 | false | false | 4 |
e72055d93d4e6ce5153d4dc4628e0e3c2ff6a714 | 3,659,312,163,813 | d29f31bf70fbe9d6252ca2d8e42072b1164d6f40 | /app/src/main/java/com/interfaces/daniel/asoguau/modelo/Donacion.java | 3f60c9399694c82bdde16c8ae8c48cd31ad856f6 | [] | no_license | andreslacruz/Asoguau | https://github.com/andreslacruz/Asoguau | ba8fa2784d25f7bfeee62107b9f908e3fc25ae7b | 3095de98a5a4d494612a05ac9a38db77d4014394 | refs/heads/master | 2021-01-18T12:45:59.020000 | 2015-10-16T20:35:29 | 2015-10-16T20:35:32 | 44,844,246 | 1 | 0 | null | true | 2015-10-23T23:44:14 | 2015-10-23T23:44:14 | 2015-10-09T16:03:58 | 2015-10-20T14:11:17 | 32,895 | 0 | 0 | 0 | null | null | null | package com.interfaces.daniel.asoguau.modelo;
/**
* Created by hanyou on 04/10/15.
*/
public class Donacion {
private String monto;
private String nreferencia;
private String nombre;
private String fecha;
public Donacion(String monto, String nreferencia, String nombre, String fecha) {
this.monto = monto;
this.nreferencia = nreferencia;
this.nombre = nombre;
this.fecha = fecha;
}
public String getMonto() {
return monto;
}
public void setMonto(String monto) {
this.monto = monto;
}
public String getNreferencia() {
return nreferencia;
}
public void setNreferencia(String nreferencia) {
this.nreferencia = nreferencia;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
}
| UTF-8 | Java | 1,030 | java | Donacion.java | Java | [
{
"context": "terfaces.daniel.asoguau.modelo;\n\n/**\n * Created by hanyou on 04/10/15.\n */\npublic class Donacion {\n priv",
"end": 71,
"score": 0.9990558624267578,
"start": 65,
"tag": "USERNAME",
"value": "hanyou"
}
] | null | [] | package com.interfaces.daniel.asoguau.modelo;
/**
* Created by hanyou on 04/10/15.
*/
public class Donacion {
private String monto;
private String nreferencia;
private String nombre;
private String fecha;
public Donacion(String monto, String nreferencia, String nombre, String fecha) {
this.monto = monto;
this.nreferencia = nreferencia;
this.nombre = nombre;
this.fecha = fecha;
}
public String getMonto() {
return monto;
}
public void setMonto(String monto) {
this.monto = monto;
}
public String getNreferencia() {
return nreferencia;
}
public void setNreferencia(String nreferencia) {
this.nreferencia = nreferencia;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public String getFecha() {
return fecha;
}
public void setFecha(String fecha) {
this.fecha = fecha;
}
}
| 1,030 | 0.614563 | 0.608738 | 50 | 19.6 | 17.934324 | 84 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
cd190c4fe90fe6fc57eab9850ec4f3ac2d5aeb9c | 32,358,283,630,797 | 3abb019e88de07febd01a33a5ccbc0c3f4b8b9ee | /src/com/stormnet/dentapp/dao/TicketDao.java | 1ef095da2f5ce39588a1302c195b9ecc4d6a8e1a | [] | no_license | mmalashchonak/hospital-appointment-javafx | https://github.com/mmalashchonak/hospital-appointment-javafx | 1b7e08568ce5f462444f61cf4d0af357f7285526 | 7c989d7fb01c00978860cf5f5c5d119bdf5a68f0 | refs/heads/master | 2023-02-25T17:29:25.082000 | 2021-01-30T00:24:08 | 2021-01-30T00:24:08 | 276,268,838 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.stormnet.dentapp.dao;
import com.stormnet.dentapp.bo.Ticket;
public interface TicketDao extends BaseDao<Ticket>{
}
| UTF-8 | Java | 130 | java | TicketDao.java | Java | [] | null | [] | package com.stormnet.dentapp.dao;
import com.stormnet.dentapp.bo.Ticket;
public interface TicketDao extends BaseDao<Ticket>{
}
| 130 | 0.8 | 0.8 | 7 | 17.571428 | 20.611073 | 51 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 4 |
f00d6b37c6a6880bd9c630feac0a8d22989f5158 | 15,771,119,943,568 | 893fc6a5103ac91cc0e133ba1a4ac9331811b20d | /src/com/example/skytrainvancouver/StationActivity.java | 69e9ece7e65af588834ef66fcc9c586da5b5b824 | [
"MIT"
] | permissive | pablokintopp/skytrainVancouverApp | https://github.com/pablokintopp/skytrainVancouverApp | 00e8ae1f60ad47f86b6f1ca766ac5c5c25a4f98b | b6c17584acf05c6cfacc7efefb9b639f321402ed | refs/heads/master | 2020-04-06T03:39:31.656000 | 2015-04-07T07:30:09 | 2015-04-07T07:30:09 | 31,280,833 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.skytrainvancouver;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
public class StationActivity extends Activity {
int idStation;
Station station;
@SuppressWarnings("deprecation")
Gallery gallery;
ImageView image;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_station);
//loading parameters
Bundle b = getIntent().getExtras();
idStation = b.getInt("id");
station = Constants.stations.get(idStation);
final TextView title = (TextView) findViewById(R.id.textViewName);
final TextView info = (TextView) findViewById(R.id.textViewInfo);
final TextView titlePoint = (TextView) findViewById(R.id.textViewNamePoint);
gallery = (Gallery) findViewById(R.id.galleryPoints);
image = (ImageView) findViewById(R.id.imageViewZoom);
image.setMinimumWidth(500);
image.setMinimumHeight(500);
title.setText(station.getName());
info.setText(station.showInfo());
gallery.setAdapter(new ImageAdapter(this,station));
gallery.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
image.setImageResource(station.getPoints().get(position).getIdImg());
titlePoint.setText(station.getPoints().get(position).getName());
}
});
}
}
class ImageAdapter extends BaseAdapter{
private Context context;
Station station;
public ImageAdapter(Context c,Station station) {
this.context =c;
this.station =station;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return station.getPoints().size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView pic = new ImageView(context);
pic.setImageResource(station.getPoints().get(position).getIdImg());
pic.setScaleType(ImageView.ScaleType.FIT_XY);
pic.setLayoutParams(new Gallery.LayoutParams(200,175));
return pic;
}
}
| UTF-8 | Java | 2,716 | java | StationActivity.java | Java | [] | null | [] | package com.example.skytrainvancouver;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;
import android.widget.TextView;
public class StationActivity extends Activity {
int idStation;
Station station;
@SuppressWarnings("deprecation")
Gallery gallery;
ImageView image;
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_station);
//loading parameters
Bundle b = getIntent().getExtras();
idStation = b.getInt("id");
station = Constants.stations.get(idStation);
final TextView title = (TextView) findViewById(R.id.textViewName);
final TextView info = (TextView) findViewById(R.id.textViewInfo);
final TextView titlePoint = (TextView) findViewById(R.id.textViewNamePoint);
gallery = (Gallery) findViewById(R.id.galleryPoints);
image = (ImageView) findViewById(R.id.imageViewZoom);
image.setMinimumWidth(500);
image.setMinimumHeight(500);
title.setText(station.getName());
info.setText(station.showInfo());
gallery.setAdapter(new ImageAdapter(this,station));
gallery.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
image.setImageResource(station.getPoints().get(position).getIdImg());
titlePoint.setText(station.getPoints().get(position).getName());
}
});
}
}
class ImageAdapter extends BaseAdapter{
private Context context;
Station station;
public ImageAdapter(Context c,Station station) {
this.context =c;
this.station =station;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return station.getPoints().size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@SuppressWarnings("deprecation")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView pic = new ImageView(context);
pic.setImageResource(station.getPoints().get(position).getIdImg());
pic.setScaleType(ImageView.ScaleType.FIT_XY);
pic.setLayoutParams(new Gallery.LayoutParams(200,175));
return pic;
}
}
| 2,716 | 0.724227 | 0.71944 | 101 | 24.891088 | 21.644243 | 78 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.841584 | false | false | 4 |
b67574edb4714eebadb5d9799df115acc82d8726 | 2,869,038,180,868 | d3cedd2182c45f1795ae2c1595d1e209688bb23e | /SwitchCase.java | 19913ec3fde89b2c845ee08a99c0bc3f857ef884 | [] | no_license | resharj/MyCaptainCodes | https://github.com/resharj/MyCaptainCodes | b224a00122f3772abf07785b0ee44875bf572191 | b112b28d8ac8cbf13012d6d68be31664bd2ced88 | refs/heads/master | 2022-12-07T23:06:24.923000 | 2020-08-27T17:04:13 | 2020-08-27T17:04:13 | 290,797,972 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package switchCase;
import java.util.Scanner;
public class SwitchCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
int choice;
System.out.println("Input choice:1, 2 or 3");
Scanner s=new Scanner(System.in);
choice=s.nextInt();
switch(choice) {
case 1 : System.out.println("You said Hi.");
break;
case 2 : System.out.println("You said Hey.");
break;
case 3 : System.out.println("You said Hello.");
break;
default : System.out.println("Invalid choice");
}
}
}
| UTF-8 | Java | 549 | java | SwitchCase.java | Java | [] | null | [] | package switchCase;
import java.util.Scanner;
public class SwitchCase {
public static void main(String[] args) {
// TODO Auto-generated method stub
int choice;
System.out.println("Input choice:1, 2 or 3");
Scanner s=new Scanner(System.in);
choice=s.nextInt();
switch(choice) {
case 1 : System.out.println("You said Hi.");
break;
case 2 : System.out.println("You said Hey.");
break;
case 3 : System.out.println("You said Hello.");
break;
default : System.out.println("Invalid choice");
}
}
}
| 549 | 0.644809 | 0.63388 | 24 | 20.875 | 18.063112 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.833333 | false | false | 4 |
98fc6858d2e1de6b059d1b86435a6c7ee95519ce | 12,472,585,054,038 | fb1d0f2f03a596dd31ab603aa63144107f98aee1 | /AlgorithmStudy/src/ch07/divide/example/Karatsuba.java | 92e72238ce421187444e6e84ab255c71524285b7 | [] | no_license | crowdark/algorithmStudy | https://github.com/crowdark/algorithmStudy | de6cf0579d85a912dbfb6994a8c6baaa337e8a84 | 6d58fac607ba9c77a635afe50642ab608ee9e177 | refs/heads/master | 2016-08-11T15:04:09.281000 | 2016-05-02T15:02:06 | 2016-05-02T15:02:06 | 54,892,450 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ch07.divide.example;
import java.util.Arrays;
public class Karatsuba {
public static void main(String[] args) {
int[] a = { 1, 0, 1, 9, 9 };
int[] b = { 2, 0, 9 };
// int[] c = multiply(a, b);
int[] c = add(a, b);
System.out.println(Arrays.toString(c));
}
public static int[] multiply(final int[] a, final int[] b) {
int[] c = new int[a.length + b.length + 1];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < b.length; j++) {
c[i + j] += a[i] * b[j];
}
}
normalize(c);
return c;
}
public static int[] karatsuba(final int[] a, final int[] b) {
int an = a.length;
int bn = b.length;
if (an < bn) {
return karatsuba(b, a);
}
if (an == 0 || bn == 0) {
return new int[0];
}
if (an <= 50) {
return multiply(a, b);
}
int half = an / 2;
int[] a0 = new int[half];
int[] a1 = new int[an - half];
System.arraycopy(a, 0, a0, 0, half);
System.arraycopy(a, half + 1, a1, 0, an);
int bhalf = Math.min(half, bn);
int[] b0 = new int[bhalf];
int[] b1 = new int[bn - bhalf];
System.arraycopy(b, 0, b0, 0, bhalf);
System.arraycopy(b, bhalf + 1, b1, 0, bn);
int[] z2 = karatsuba(a1, b1);
int[] z0 = karatsuba(a0, b0);
a0 = add(a0, a1);
return null;
}
private static int[] add(int[] a0, int[] a1) {
int size = 0;
int a[], b[];
if (a0.length > a1.length) {
size = a0.length + 1;
a = a0;
b = new int[a0.length];
System.arraycopy(a1, 0, b, 0, a1.length);
} else {
size = a1.length + 1;
a = a1;
b = new int[a1.length];
System.arraycopy(a0, 0, b, 0, a0.length);
}
int[] c = new int[size];
for (int i = 0; i < a.length; i++) {
c[i] = a[i] + b[i];
}
normalize(c);
return c;
}
private static void normalize(int[] num) {
// TODO Auto-generated method stub
for (int i = 0; i < num.length - 1; i++) {
if (num[i] < 0) {
int borrow = (Math.abs(num[i]) + 9) / 10;
num[i + 1] -= borrow;
num[i] += borrow * 10;
} else {
num[i + 1] += num[i] / 10;
num[i] %= 10;
}
}
}
}
| UTF-8 | Java | 2,135 | java | Karatsuba.java | Java | [] | null | [] | package ch07.divide.example;
import java.util.Arrays;
public class Karatsuba {
public static void main(String[] args) {
int[] a = { 1, 0, 1, 9, 9 };
int[] b = { 2, 0, 9 };
// int[] c = multiply(a, b);
int[] c = add(a, b);
System.out.println(Arrays.toString(c));
}
public static int[] multiply(final int[] a, final int[] b) {
int[] c = new int[a.length + b.length + 1];
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < b.length; j++) {
c[i + j] += a[i] * b[j];
}
}
normalize(c);
return c;
}
public static int[] karatsuba(final int[] a, final int[] b) {
int an = a.length;
int bn = b.length;
if (an < bn) {
return karatsuba(b, a);
}
if (an == 0 || bn == 0) {
return new int[0];
}
if (an <= 50) {
return multiply(a, b);
}
int half = an / 2;
int[] a0 = new int[half];
int[] a1 = new int[an - half];
System.arraycopy(a, 0, a0, 0, half);
System.arraycopy(a, half + 1, a1, 0, an);
int bhalf = Math.min(half, bn);
int[] b0 = new int[bhalf];
int[] b1 = new int[bn - bhalf];
System.arraycopy(b, 0, b0, 0, bhalf);
System.arraycopy(b, bhalf + 1, b1, 0, bn);
int[] z2 = karatsuba(a1, b1);
int[] z0 = karatsuba(a0, b0);
a0 = add(a0, a1);
return null;
}
private static int[] add(int[] a0, int[] a1) {
int size = 0;
int a[], b[];
if (a0.length > a1.length) {
size = a0.length + 1;
a = a0;
b = new int[a0.length];
System.arraycopy(a1, 0, b, 0, a1.length);
} else {
size = a1.length + 1;
a = a1;
b = new int[a1.length];
System.arraycopy(a0, 0, b, 0, a0.length);
}
int[] c = new int[size];
for (int i = 0; i < a.length; i++) {
c[i] = a[i] + b[i];
}
normalize(c);
return c;
}
private static void normalize(int[] num) {
// TODO Auto-generated method stub
for (int i = 0; i < num.length - 1; i++) {
if (num[i] < 0) {
int borrow = (Math.abs(num[i]) + 9) / 10;
num[i + 1] -= borrow;
num[i] += borrow * 10;
} else {
num[i + 1] += num[i] / 10;
num[i] %= 10;
}
}
}
}
| 2,135 | 0.497892 | 0.460422 | 97 | 20.010309 | 15.918928 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.845361 | false | false | 4 |
44d194d3b124b6524275670630a9e5b4293916ca | 31,233,002,210,907 | c3848ac71c93e9c206e21874b8aca20deea38c4f | /app/src/test/java/io/github/hidroh/materialistic/data/SessionManagerTest.java | ff080d6f665fe8fe0eee50da35cb0158c52f3f41 | [
"Apache-2.0"
] | permissive | minmin777/cs395Project2 | https://github.com/minmin777/cs395Project2 | 375bfa94c24ae7802cc412efbd78448f8b1c03d0 | 756aed0ff0a7c3a366984d2d58df651e780365d3 | refs/heads/master | 2020-04-08T10:25:13.803000 | 2018-11-28T05:04:27 | 2018-11-28T05:04:27 | 159,268,125 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package io.github.hidroh.materialistic.data;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import io.github.hidroh.materialistic.DataModule;
import io.github.hidroh.materialistic.test.InMemoryCache;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@RunWith(JUnit4.class)
public class SessionManagerTest {
@Inject LocalCache cache;
private SessionManager manager;
@Before
public void setUp() {
ObjectGraph objectGraph = ObjectGraph.create(new TestModule());
objectGraph.inject(this);
cache.setViewed("1");
cache.setViewed("2");
manager = new SessionManager();
objectGraph.inject(manager);
}
@Test
public void testIsViewedNull() {
assertFalse(manager.isViewed(null)
.toBlocking().single());
}
@Test
public void testIsViewedTrue() {
assertTrue(manager.isViewed("1")
.toBlocking().single());
}
@Test
public void testIsViewedFalse() {
assertFalse(manager.isViewed("-1")
.toBlocking().single());
}
@Module(
injects = {
SessionManagerTest.class,
SessionManager.class
},
overrides = true
)
static class TestModule {
@Provides @Singleton @Named(DataModule.IO_THREAD)
public Scheduler provideIoThreadScheduler() {
return Schedulers.immediate();
}
@Provides @Singleton
public LocalCache provideLocalCache() {
return new InMemoryCache();
}
}
}
| UTF-8 | Java | 1,914 | java | SessionManagerTest.java | Java | [
{
"context": "package io.github.hidroh.materialistic.data;\n\nimport org.junit.Before;\nimp",
"end": 24,
"score": 0.9196149706840515,
"start": 18,
"tag": "USERNAME",
"value": "hidroh"
},
{
"context": "ctGraph;\nimport dagger.Provides;\nimport io.github.hidroh.materialistic.DataModule;\nimport io.github.hidroh",
"end": 344,
"score": 0.8529145121574402,
"start": 338,
"tag": "USERNAME",
"value": "hidroh"
},
{
"context": "hidroh.materialistic.DataModule;\nimport io.github.hidroh.materialistic.test.InMemoryCache;\nimport rx.Sched",
"end": 394,
"score": 0.8978495597839355,
"start": 388,
"tag": "USERNAME",
"value": "hidroh"
}
] | null | [] | package io.github.hidroh.materialistic.data;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;
import dagger.Module;
import dagger.ObjectGraph;
import dagger.Provides;
import io.github.hidroh.materialistic.DataModule;
import io.github.hidroh.materialistic.test.InMemoryCache;
import rx.Scheduler;
import rx.schedulers.Schedulers;
import static junit.framework.Assert.assertFalse;
import static junit.framework.Assert.assertTrue;
@RunWith(JUnit4.class)
public class SessionManagerTest {
@Inject LocalCache cache;
private SessionManager manager;
@Before
public void setUp() {
ObjectGraph objectGraph = ObjectGraph.create(new TestModule());
objectGraph.inject(this);
cache.setViewed("1");
cache.setViewed("2");
manager = new SessionManager();
objectGraph.inject(manager);
}
@Test
public void testIsViewedNull() {
assertFalse(manager.isViewed(null)
.toBlocking().single());
}
@Test
public void testIsViewedTrue() {
assertTrue(manager.isViewed("1")
.toBlocking().single());
}
@Test
public void testIsViewedFalse() {
assertFalse(manager.isViewed("-1")
.toBlocking().single());
}
@Module(
injects = {
SessionManagerTest.class,
SessionManager.class
},
overrides = true
)
static class TestModule {
@Provides @Singleton @Named(DataModule.IO_THREAD)
public Scheduler provideIoThreadScheduler() {
return Schedulers.immediate();
}
@Provides @Singleton
public LocalCache provideLocalCache() {
return new InMemoryCache();
}
}
}
| 1,914 | 0.647858 | 0.644723 | 74 | 24.864864 | 17.60553 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.432432 | false | false | 4 |
7efa641789dd6ff2d0302721a7fe7a81ca8e1ea3 | 17,394,617,579,617 | fb94e19690451dd2d1dd6e894fafb884d22046f7 | /Project1/src/prWeek3/ex1/Screen.java | 1163380159eae6ac625441718d14d66fdc9c9630 | [] | no_license | seriferabia/Modul1Projets | https://github.com/seriferabia/Modul1Projets | 2c2d7733f7781d6af87e5379232c3513d982fa2d | 7c35c4650b02d98c98721f71ebb6fff80611248f | refs/heads/master | 2020-04-25T10:32:44.162000 | 2019-02-26T13:14:20 | 2019-02-26T13:14:20 | 172,712,854 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package prWeek3.ex1;
public class Screen {
public String displayName(Customer customer){
if(customer.getCategory().equalsIgnoreCase("business")){
System.out.println(customer.getName().toUpperCase());
return customer.getName().toUpperCase();
}
if(customer.getCategory().equalsIgnoreCase("economic")){
System.out.println(customer.getName().toLowerCase());
return customer.getName().toLowerCase();
}
return "";
}
}
| UTF-8 | Java | 510 | java | Screen.java | Java | [] | null | [] | package prWeek3.ex1;
public class Screen {
public String displayName(Customer customer){
if(customer.getCategory().equalsIgnoreCase("business")){
System.out.println(customer.getName().toUpperCase());
return customer.getName().toUpperCase();
}
if(customer.getCategory().equalsIgnoreCase("economic")){
System.out.println(customer.getName().toLowerCase());
return customer.getName().toLowerCase();
}
return "";
}
}
| 510 | 0.621569 | 0.617647 | 16 | 30.875 | 25.680428 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.375 | false | false | 4 |
efde66275118e31994e348af23d0f2b0c3a149e0 | 1,975,684,993,487 | 3bad2fb336103246f445789ab7a403c486deaf8d | /src/main/java/com/xinda/util/ImageCaptchca.java | f094b88d1b154aabe40352b6cd8c20918ac8ea0d | [] | no_license | xushunlei/xindaPower-Sys | https://github.com/xushunlei/xindaPower-Sys | a5293f22f347fce301e579cb16406eb287f84e5d | 859a2c9596f6620a7f41bfa7cd58382b07746a95 | refs/heads/master | 2021-01-24T08:12:40.243000 | 2018-03-26T00:46:09 | 2018-03-26T00:46:09 | 93,374,311 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xinda.util;
public interface ImageCaptchca extends Captchca {
void setImageType(String type);
}
| UTF-8 | Java | 115 | java | ImageCaptchca.java | Java | [] | null | [] | package com.xinda.util;
public interface ImageCaptchca extends Captchca {
void setImageType(String type);
}
| 115 | 0.765217 | 0.765217 | 5 | 21 | 18.708286 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.6 | false | false | 4 |
aec7de7aa2b619ac5788f9715aef8dccf1fc198f | 1,975,684,992,241 | 117ed72380b61530d102dc5755d9698a41d0b4e6 | /app/src/main/java/com/gb/Ball.java | 18cd0c5fc32ca642403abca801d1ef79ff96f134 | [] | no_license | nayyarsyed/ball_animation | https://github.com/nayyarsyed/ball_animation | 4be6e2bc3c19bda9baa9f57608cf417ed7fa9ebf | c8b8fe514a7a5d92cb506f654326d12f05d4a431 | refs/heads/master | 2023-03-04T18:50:53.582000 | 2019-10-02T09:03:02 | 2019-10-02T09:03:02 | 212,291,223 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gb;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
public class Ball{
public int[] direction = new int[]{1,1}; //direction modifier (-1,1)
public int x,y,size;
public int speed ;
public Paint paint;
public RectF oval;
public Ball(int x, int y, int s,int size, int color){
this.x = x;
this.y = y;
this.size = size;
this.paint = new Paint();
this.paint.setColor(color);
this.speed =s;
}
public void move(Canvas canvas) {
x += speed * direction[0];
y += speed * direction[1];
oval = new RectF(x-size/2,y-size/2,x+size/2,y+size/2);
//Do we need to bounce next time?
Rect bounds = new Rect();
this.oval.roundOut(bounds); ///store our int bounds
//This is what you're looking for ▼
if(!canvas.getClipBounds().contains(bounds)){
if(this.x-size<0 || this.x+size > canvas.getWidth()){
direction[0] = direction[0]*-1;
}
if(this.y-size<0 || this.y+size > canvas.getHeight()){
direction[1] = direction[1]*-1;
}
}
}
} | UTF-8 | Java | 1,239 | java | Ball.java | Java | [] | null | [] | package com.gb;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
public class Ball{
public int[] direction = new int[]{1,1}; //direction modifier (-1,1)
public int x,y,size;
public int speed ;
public Paint paint;
public RectF oval;
public Ball(int x, int y, int s,int size, int color){
this.x = x;
this.y = y;
this.size = size;
this.paint = new Paint();
this.paint.setColor(color);
this.speed =s;
}
public void move(Canvas canvas) {
x += speed * direction[0];
y += speed * direction[1];
oval = new RectF(x-size/2,y-size/2,x+size/2,y+size/2);
//Do we need to bounce next time?
Rect bounds = new Rect();
this.oval.roundOut(bounds); ///store our int bounds
//This is what you're looking for ▼
if(!canvas.getClipBounds().contains(bounds)){
if(this.x-size<0 || this.x+size > canvas.getWidth()){
direction[0] = direction[0]*-1;
}
if(this.y-size<0 || this.y+size > canvas.getHeight()){
direction[1] = direction[1]*-1;
}
}
}
} | 1,239 | 0.560226 | 0.545675 | 45 | 26.51111 | 20.589773 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.844444 | false | false | 4 |
7b66eadf67a4fd109a8aab8af6e64935e217d807 | 10,204,842,325,886 | afa067afc7a25cdb8445ddc68579d39e3ea83c34 | /src/main/java/thelm/packagedauto/inventory/PackagerExtensionItemHandler.java | 1e2436f0ad4a53fc73b9ba774332142593a65e42 | [
"MIT"
] | permissive | TheLMiffy1111/PackagedAuto | https://github.com/TheLMiffy1111/PackagedAuto | 4dfcad72e66917f7844add7032d86d9f76d318bd | 4aa7982334b32f56b07d1ae6e08ee3112bed8ce9 | refs/heads/1.18.2 | 2023-08-08T20:25:15.112000 | 2023-08-05T17:02:50 | 2023-08-05T17:02:50 | 160,515,872 | 11 | 18 | MIT | false | 2022-12-01T15:21:56 | 2018-12-05T12:36:30 | 2022-04-14T19:09:44 | 2022-12-01T15:21:55 | 15,759 | 10 | 13 | 7 | Java | false | false | package thelm.packagedauto.inventory;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.items.IItemHandlerModifiable;
import thelm.packagedauto.block.entity.PackagerBlockEntity;
import thelm.packagedauto.block.entity.PackagerExtensionBlockEntity;
public class PackagerExtensionItemHandler extends BaseItemHandler<PackagerExtensionBlockEntity> {
public PackagerExtensionItemHandler(PackagerExtensionBlockEntity blockEntity) {
super(blockEntity, 11);
}
@Override
protected void onContentsChanged(int slot) {
if(slot < 9 && !blockEntity.getLevel().isClientSide) {
if(blockEntity.isWorking && !getStackInSlot(slot).isEmpty() && !blockEntity.isInputValid()) {
blockEntity.endProcess();
}
}
super.onContentsChanged(slot);
}
@Override
public boolean isItemValid(int index, ItemStack stack) {
return switch(index) {
case 9 -> false;
case 10 -> stack.getCapability(CapabilityEnergy.ENERGY).isPresent();
default -> blockEntity.isWorking ? !getStackInSlot(index).isEmpty() : true;
};
}
@Override
public IItemHandlerModifiable getWrapperForDirection(Direction side) {
return wrapperMap.computeIfAbsent(side, s->new PackagerExtensionItemHandlerWrapper(this, s));
}
@Override
public int get(int id) {
return switch(id) {
case 0 -> blockEntity.remainingProgress;
case 1 -> blockEntity.isWorking ? 1 : 0;
case 2 -> blockEntity.mode.ordinal();
case 3 -> blockEntity.getEnergyStorage().getEnergyStored();
default -> 0;
};
}
@Override
public void set(int id, int value) {
switch(id) {
case 0 -> blockEntity.remainingProgress = value;
case 1 -> blockEntity.isWorking = value != 0;
case 2 -> blockEntity.mode = PackagerBlockEntity.Mode.values()[value];
case 3 -> blockEntity.getEnergyStorage().setEnergyStored(value);
}
}
@Override
public int getCount() {
return 4;
}
}
| UTF-8 | Java | 1,943 | java | PackagerExtensionItemHandler.java | Java | [] | null | [] | package thelm.packagedauto.inventory;
import net.minecraft.core.Direction;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.items.IItemHandlerModifiable;
import thelm.packagedauto.block.entity.PackagerBlockEntity;
import thelm.packagedauto.block.entity.PackagerExtensionBlockEntity;
public class PackagerExtensionItemHandler extends BaseItemHandler<PackagerExtensionBlockEntity> {
public PackagerExtensionItemHandler(PackagerExtensionBlockEntity blockEntity) {
super(blockEntity, 11);
}
@Override
protected void onContentsChanged(int slot) {
if(slot < 9 && !blockEntity.getLevel().isClientSide) {
if(blockEntity.isWorking && !getStackInSlot(slot).isEmpty() && !blockEntity.isInputValid()) {
blockEntity.endProcess();
}
}
super.onContentsChanged(slot);
}
@Override
public boolean isItemValid(int index, ItemStack stack) {
return switch(index) {
case 9 -> false;
case 10 -> stack.getCapability(CapabilityEnergy.ENERGY).isPresent();
default -> blockEntity.isWorking ? !getStackInSlot(index).isEmpty() : true;
};
}
@Override
public IItemHandlerModifiable getWrapperForDirection(Direction side) {
return wrapperMap.computeIfAbsent(side, s->new PackagerExtensionItemHandlerWrapper(this, s));
}
@Override
public int get(int id) {
return switch(id) {
case 0 -> blockEntity.remainingProgress;
case 1 -> blockEntity.isWorking ? 1 : 0;
case 2 -> blockEntity.mode.ordinal();
case 3 -> blockEntity.getEnergyStorage().getEnergyStored();
default -> 0;
};
}
@Override
public void set(int id, int value) {
switch(id) {
case 0 -> blockEntity.remainingProgress = value;
case 1 -> blockEntity.isWorking = value != 0;
case 2 -> blockEntity.mode = PackagerBlockEntity.Mode.values()[value];
case 3 -> blockEntity.getEnergyStorage().setEnergyStored(value);
}
}
@Override
public int getCount() {
return 4;
}
}
| 1,943 | 0.752959 | 0.743181 | 65 | 28.892307 | 28.497299 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.676923 | false | false | 4 |
15ca815ae3aad03387cc7a6a2a5614bd076abb55 | 37,546,604,109,760 | 519bba5b90fca6b8b7514902f302ecd0e6a04e1a | /game/core/src/com/mygdx/game/Score.java | 044dc3bb99e2d8a7d4f26eb36be8ac431ce389cc | [] | no_license | TrashAdc/PDS | https://github.com/TrashAdc/PDS | 0d894a8aaf6a5620c66edd808ba7dc5d449e30c1 | ae5d698cb2ebdd7928cab82e4201caa88e3cd2d4 | refs/heads/master | 2021-01-13T04:09:21.249000 | 2017-05-23T15:38:11 | 2017-05-23T15:38:11 | 78,038,877 | 2 | 0 | null | false | 2017-01-27T17:05:56 | 2017-01-04T17:48:49 | 2017-01-18T05:15:04 | 2017-01-27T17:05:56 | 932 | 1 | 0 | 0 | Java | null | null | package com.mygdx.game;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
/**
* Created by Devin Popock on 1/17/2017.
**/
public class Score {
private int P1Kill = 0, P2Kill = 0; //kills of each player
private int stockP1 = 3, stockP2 = 3; //stocks of each player
private float chargeP1, chargeP2;
private int damageP1, damageP2;
private boolean stockmodeplaceholder;
private Sprite p1Stock, p2Stock; //stock images
public Score(int stocks){
chargeP1 = 0f;
chargeP2 = 0f;
damageP1 = 0;
damageP2 = 0;
stockP1 = stocks;
stockP2 = stocks;
p1Stock = new Sprite(new Texture("core/assets/image/p1stock.png"));
p1Stock.setSize(50f, 50f);
p2Stock = new Sprite(new Texture("core/assets/image/p2stock.png"));
p2Stock.setSize(50f, 50f);
}
// Returns value of percent as a String
public String scoreConverter(int inputScore) {
String converted = Integer.toString(inputScore);
return converted;
}
/*public float chargecalc(){
basicAstat/10=percentmodifier;
percentmodifier2=10/100;;
DamageD*percentmodifier=chargepart1;
DamageR*percentmodifier2=chargepart2;
return charge=chargepart2+chargepart1;
}*/
private void attackCharge(int baseAtk, GameData.Player player){ //gives player ultimate charge based on damage dealt
float c = baseAtk / 2;
if (player == GameData.Player.PLAYER1)
chargeP1 += c;
else
chargeP2 += c;
}
private void hitCharge(int baseAtk, GameData.Player player){ //gives player ultimate charge based on damage taken
float c = baseAtk / 10;
if (player == GameData.Player.PLAYER1)
chargeP1 += c;
else
chargeP2 += c;
}
public int getDamage(GameData.Player player){
return (player == GameData.Player.PLAYER1) ? damageP1 : damageP2;
}
public void addDamage(GameData.Player player, int damage){
if (player == GameData.Player.PLAYER1) {
damageP1 += damage; //deal damage
hitCharge(damage, player); //give charge to the player being hit
hitCharge(damage, GameData.Player.PLAYER2); //give charge to the attacking player
}
else {
damageP2 += damage;
hitCharge(damage, player);
hitCharge(damage, GameData.Player.PLAYER1);
}
}
public int getStock(GameData.Player player){ //gets amount of stocks a player has
return (player == GameData.Player.PLAYER1) ? stockP1 : stockP2;
}
private void takeStock(GameData.Player player, int stocks){ //takes a stock from a player
if (player == GameData.Player.PLAYER1)
stockP1 -= stocks;
else
stockP2 -= stocks;
}
public String playerKilled(GameData.Player playerThatDied){ //is run when a player dies
if (playerThatDied == GameData.Player.PLAYER1){
takeStock(playerThatDied, 1);
damageP1 = 0;
P2Kill++;
return scoreConverter(P2Kill);
}
if(playerThatDied == GameData.Player.PLAYER2) {
takeStock(GameData.Player.PLAYER2, 1);
damageP2 = 0;
P1Kill++;
return scoreConverter(P1Kill);
}
return "";
}
public void drawStock(SpriteBatch batch){ //draws amount of stocks
int stock1 = getStock(GameData.Player.PLAYER1);
int stock2 = getStock(GameData.Player.PLAYER2);
float posX1 = (Window.SIZE.width / 3.75f);
float posX2 = (Window.SIZE.width / 1.5f);
float posY = Window.SIZE.height / 100;
//draw p1 stock
if (stock1 >= 3) {
p1Stock.setPosition(posX1 + 25, posY);
p1Stock.draw(batch);
}
if (stock1 >= 2){
p1Stock.setPosition(posX1, posY);
p1Stock.draw(batch);
}
if (stock1 >= 1){
p1Stock.setPosition(posX1 - 25, posY);
p1Stock.draw(batch);
}
//draw p2 stock
if (stock2 >= 3) {
p2Stock.setPosition(posX2 - 25, posY);
p2Stock.draw(batch);
}
if (stock2 >= 2){
p2Stock.setPosition(posX2, posY);
p2Stock.draw(batch);
}
if (stock2 >= 1){
p2Stock.setPosition(posX2 + 25, posY);
p2Stock.draw(batch);
}
}
public void restart(){
stockP1 = 3;
stockP2 = 3;
damageP1 = 0;
damageP2 = 0;
}
/*public boolean gameState() {
while (gameon) {
if (stockmodeplaceholder == true) {
if (stockCount1 == 0 || stockCount2 == 0) {
gameover = true;
gameon = false;
}
} else {
if (timephold == 0) {
gameover = true;
gameon = false;
}
}
}
return gameover;
}
public boolean gameResults() {
if (gameover) {
if (stockmodeplaceholder) {
if (stockCount1 == 0) {
//winner2=true
//return winner2
}
else if(stockCount2==0){
//winner1=true
//return winner1
}
}
else{
if(P1Kill>P2Kill){
//winner1=true
//return winner1
}
else if(P2Kill>P1Kill){
//winner2=true
//return winner2 q
}
}
}
return false;
}*/
} | UTF-8 | Java | 6,039 | java | Score.java | Java | [
{
"context": "dx.graphics.g2d.SpriteBatch;\r\n\r\n/**\r\n * Created by Devin Popock on 1/17/2017.\r\n **/\r\npublic class Score {\r\n pr",
"end": 200,
"score": 0.9998593330383301,
"start": 188,
"tag": "NAME",
"value": "Devin Popock"
}
] | null | [] | package com.mygdx.game;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
/**
* Created by <NAME> on 1/17/2017.
**/
public class Score {
private int P1Kill = 0, P2Kill = 0; //kills of each player
private int stockP1 = 3, stockP2 = 3; //stocks of each player
private float chargeP1, chargeP2;
private int damageP1, damageP2;
private boolean stockmodeplaceholder;
private Sprite p1Stock, p2Stock; //stock images
public Score(int stocks){
chargeP1 = 0f;
chargeP2 = 0f;
damageP1 = 0;
damageP2 = 0;
stockP1 = stocks;
stockP2 = stocks;
p1Stock = new Sprite(new Texture("core/assets/image/p1stock.png"));
p1Stock.setSize(50f, 50f);
p2Stock = new Sprite(new Texture("core/assets/image/p2stock.png"));
p2Stock.setSize(50f, 50f);
}
// Returns value of percent as a String
public String scoreConverter(int inputScore) {
String converted = Integer.toString(inputScore);
return converted;
}
/*public float chargecalc(){
basicAstat/10=percentmodifier;
percentmodifier2=10/100;;
DamageD*percentmodifier=chargepart1;
DamageR*percentmodifier2=chargepart2;
return charge=chargepart2+chargepart1;
}*/
private void attackCharge(int baseAtk, GameData.Player player){ //gives player ultimate charge based on damage dealt
float c = baseAtk / 2;
if (player == GameData.Player.PLAYER1)
chargeP1 += c;
else
chargeP2 += c;
}
private void hitCharge(int baseAtk, GameData.Player player){ //gives player ultimate charge based on damage taken
float c = baseAtk / 10;
if (player == GameData.Player.PLAYER1)
chargeP1 += c;
else
chargeP2 += c;
}
public int getDamage(GameData.Player player){
return (player == GameData.Player.PLAYER1) ? damageP1 : damageP2;
}
public void addDamage(GameData.Player player, int damage){
if (player == GameData.Player.PLAYER1) {
damageP1 += damage; //deal damage
hitCharge(damage, player); //give charge to the player being hit
hitCharge(damage, GameData.Player.PLAYER2); //give charge to the attacking player
}
else {
damageP2 += damage;
hitCharge(damage, player);
hitCharge(damage, GameData.Player.PLAYER1);
}
}
public int getStock(GameData.Player player){ //gets amount of stocks a player has
return (player == GameData.Player.PLAYER1) ? stockP1 : stockP2;
}
private void takeStock(GameData.Player player, int stocks){ //takes a stock from a player
if (player == GameData.Player.PLAYER1)
stockP1 -= stocks;
else
stockP2 -= stocks;
}
public String playerKilled(GameData.Player playerThatDied){ //is run when a player dies
if (playerThatDied == GameData.Player.PLAYER1){
takeStock(playerThatDied, 1);
damageP1 = 0;
P2Kill++;
return scoreConverter(P2Kill);
}
if(playerThatDied == GameData.Player.PLAYER2) {
takeStock(GameData.Player.PLAYER2, 1);
damageP2 = 0;
P1Kill++;
return scoreConverter(P1Kill);
}
return "";
}
public void drawStock(SpriteBatch batch){ //draws amount of stocks
int stock1 = getStock(GameData.Player.PLAYER1);
int stock2 = getStock(GameData.Player.PLAYER2);
float posX1 = (Window.SIZE.width / 3.75f);
float posX2 = (Window.SIZE.width / 1.5f);
float posY = Window.SIZE.height / 100;
//draw p1 stock
if (stock1 >= 3) {
p1Stock.setPosition(posX1 + 25, posY);
p1Stock.draw(batch);
}
if (stock1 >= 2){
p1Stock.setPosition(posX1, posY);
p1Stock.draw(batch);
}
if (stock1 >= 1){
p1Stock.setPosition(posX1 - 25, posY);
p1Stock.draw(batch);
}
//draw p2 stock
if (stock2 >= 3) {
p2Stock.setPosition(posX2 - 25, posY);
p2Stock.draw(batch);
}
if (stock2 >= 2){
p2Stock.setPosition(posX2, posY);
p2Stock.draw(batch);
}
if (stock2 >= 1){
p2Stock.setPosition(posX2 + 25, posY);
p2Stock.draw(batch);
}
}
public void restart(){
stockP1 = 3;
stockP2 = 3;
damageP1 = 0;
damageP2 = 0;
}
/*public boolean gameState() {
while (gameon) {
if (stockmodeplaceholder == true) {
if (stockCount1 == 0 || stockCount2 == 0) {
gameover = true;
gameon = false;
}
} else {
if (timephold == 0) {
gameover = true;
gameon = false;
}
}
}
return gameover;
}
public boolean gameResults() {
if (gameover) {
if (stockmodeplaceholder) {
if (stockCount1 == 0) {
//winner2=true
//return winner2
}
else if(stockCount2==0){
//winner1=true
//return winner1
}
}
else{
if(P1Kill>P2Kill){
//winner1=true
//return winner1
}
else if(P2Kill>P1Kill){
//winner2=true
//return winner2 q
}
}
}
return false;
}*/
} | 6,033 | 0.519954 | 0.490313 | 192 | 29.463541 | 22.618639 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.546875 | false | false | 4 |
bc8d6b04067581500955297aefabd5482d5b0ea8 | 35,897,336,690,812 | d530ddb0a782d268672929bb8701ad24f516e294 | /Enum/src/Size.java | 6ac97d17011fb0feca3d4959665f8117aa6a716f | [] | no_license | Xwadrom/KnowledgeCenter | https://github.com/Xwadrom/KnowledgeCenter | 29548bec4080d1212b4a6fd7c901c8f7c2938d8e | a20ccf26feaa4607a1d314fbcbe46cdf03861543 | refs/heads/master | 2020-07-18T13:51:57.938000 | 2019-10-12T15:34:10 | 2019-10-12T15:34:10 | 206,257,893 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public enum Size {
XSMALL ("Bardzo mały"), SMALL("Mały"), MEDIUM("Sredni"), LARGE("Duży"), XLARGE("Bardzo duzy");
//Konstruktor wywołujemy definiując odpowiednie wartości, np. SMALL("Mały"). SMALL będzie w tym przypadku wartością typu Size i będzie przechowywać napis "Mały" przypisany do pola polish.
private final String polish;
Size(String polish) {
this.polish=polish;
}
//Wygenerowałem także konstruktor, który pozwala ustawić wartość pola polish. Zwróć uwagę, że konstruktor jest prywatny, czyli możemy go wywoływać tylko wewnątrz typu Size. Jeśli nie zapiszesz przy konstruktorze słowa private, to efektywnie i tak będzie on prywatny. Wywołanie konstruktora dla typu enum wygląda trochę inaczej niż w przypadku klas, ponieważ w tym przypadku nigdy nie pojawi się operator new.
public String getPolish() {
return polish;
}
//W praktyce powinniśmy więc od użytkownika wczytać napis lub liczbę i przekształcić je na wartość typu Size. Do zamiany nazwy typu String na wartość typu enum można wykorzystać metodę valueOf(), jednak zmuszanie użytkownika do podawania nazwy rozmiaru np. w postaci SMALL, czy MEDIUM jest mało naturalne. Lepiej byłoby wpisanie polskiej nazwy, np. "Mały". Jeśli chcemy coś takiego osiągnąć, to możemy zdefiniować dodatkową metodę, która dokona konwersji:
public static Size fromDescription(String description){
Size[] values = values ();
for (Size size: values){
if (size.getPolish().equals(description))
return size;
} return null;
}
//Metoda fromDescription() przyjmuje jako argument dowolny String. Następnie porównujemy, czy opis którejś z wartości XSMALL, SMALL itp. zgadza się z tą nazwą. Jeśli tak, to zwracamy tę wartość, jeśli przekazany napis nie odpowiada opisowi żadnej wartości, zwracamy null.
}
| UTF-8 | Java | 1,932 | java | Size.java | Java | [
{
"context": "ujemy definiując odpowiednie wartości, np. SMALL(\"Mały\"). SMALL będzie w tym przypadku wartością typu Si",
"end": 196,
"score": 0.6522955894470215,
"start": 192,
"tag": "NAME",
"value": "Mały"
},
{
"context": "alne. Lepiej byłoby wpisanie polskiej nazwy, np. \"Mały\". Jeśli chcemy coś takiego osiągnąć, to możemy zd",
"end": 1235,
"score": 0.8612290620803833,
"start": 1231,
"tag": "NAME",
"value": "Mały"
}
] | null | [] | public enum Size {
XSMALL ("Bardzo mały"), SMALL("Mały"), MEDIUM("Sredni"), LARGE("Duży"), XLARGE("Bardzo duzy");
//Konstruktor wywołujemy definiując odpowiednie wartości, np. SMALL("Mały"). SMALL będzie w tym przypadku wartością typu Size i będzie przechowywać napis "Mały" przypisany do pola polish.
private final String polish;
Size(String polish) {
this.polish=polish;
}
//Wygenerowałem także konstruktor, który pozwala ustawić wartość pola polish. Zwróć uwagę, że konstruktor jest prywatny, czyli możemy go wywoływać tylko wewnątrz typu Size. Jeśli nie zapiszesz przy konstruktorze słowa private, to efektywnie i tak będzie on prywatny. Wywołanie konstruktora dla typu enum wygląda trochę inaczej niż w przypadku klas, ponieważ w tym przypadku nigdy nie pojawi się operator new.
public String getPolish() {
return polish;
}
//W praktyce powinniśmy więc od użytkownika wczytać napis lub liczbę i przekształcić je na wartość typu Size. Do zamiany nazwy typu String na wartość typu enum można wykorzystać metodę valueOf(), jednak zmuszanie użytkownika do podawania nazwy rozmiaru np. w postaci SMALL, czy MEDIUM jest mało naturalne. Lepiej byłoby wpisanie polskiej nazwy, np. "Mały". Jeśli chcemy coś takiego osiągnąć, to możemy zdefiniować dodatkową metodę, która dokona konwersji:
public static Size fromDescription(String description){
Size[] values = values ();
for (Size size: values){
if (size.getPolish().equals(description))
return size;
} return null;
}
//Metoda fromDescription() przyjmuje jako argument dowolny String. Następnie porównujemy, czy opis którejś z wartości XSMALL, SMALL itp. zgadza się z tą nazwą. Jeśli tak, to zwracamy tę wartość, jeśli przekazany napis nie odpowiada opisowi żadnej wartości, zwracamy null.
}
| 1,932 | 0.746357 | 0.746357 | 27 | 67.629631 | 119.990784 | 455 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1 | false | false | 4 |
0d441d9c571e3e845d80612f7ea4840dd21751fe | 33,930,241,678,296 | cb58c58d7a6b671863ef8d5bd891af57c3e7142b | /app/src/main/java/com/example/iopd/api/BookmarkQueue.java | f8df9a12904d1531b09c1c7a15b4fbc7d5796c73 | [] | no_license | putthichai/iOPD | https://github.com/putthichai/iOPD | 1ec79fb8a4b4f91d5c786873ac18cf540a5ea816 | 09f3f6f814d0582c938009dee0f6795b2cb6568d | refs/heads/master | 2020-04-17T17:16:37.844000 | 2019-06-09T05:59:05 | 2019-06-09T05:59:05 | 165,038,825 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.iopd.api;
import android.content.Context;
import android.os.AsyncTask;
import com.example.iopd.activity.iOPD;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class BookmarkQueue extends AsyncTask<String, Void, JSONObject> {
private static int patientId, roomId, appointmentId,workflowId;
private iOPD mCallback;
public BookmarkQueue(int pId, int rId, int aId,int wId, Context context){
patientId = pId;
roomId = rId;
appointmentId = aId;
workflowId = wId;
mCallback = (iOPD) context;
}
@Override
protected JSONObject doInBackground(String... strings) {
try {
if(roomId == 0 || appointmentId == 0) return null;
String data = URLEncoder.encode("patient_id", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(patientId), "UTF-8");
data += "&" + URLEncoder.encode("room_id", "UTF-8") + "="
+ URLEncoder.encode(String.valueOf(roomId), "UTF-8");
data += "&" + URLEncoder.encode("appointment_id", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(appointmentId), "UTF-8");
data += "&" + URLEncoder.encode("queue_type_id", "UTF-8")
+ "=" + URLEncoder.encode("1", "UTF-8");
data += "&" + URLEncoder.encode("queue_status_id", "UTF-8")
+ "=" + URLEncoder.encode("1", "UTF-8");
data += "&" + URLEncoder.encode("workflowId", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(workflowId), "UTF-8");
URL url = new URL(strings[0]);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setReadTimeout(10000);
conn.setReadTimeout(15000);
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write( data );
wr.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while((line = reader.readLine()) != null)
{
// Append server response in string
sb.append(line + "\n");
}
conn.disconnect();
reader.close();
wr.close();
JSONObject jobj = new JSONObject(sb.toString());
return jobj;
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(JSONObject object) {
try {
mCallback.bookmarkFinish(object.getJSONObject("results").getInt("id"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 3,238 | java | BookmarkQueue.java | Java | [] | null | [] | package com.example.iopd.api;
import android.content.Context;
import android.os.AsyncTask;
import com.example.iopd.activity.iOPD;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
public class BookmarkQueue extends AsyncTask<String, Void, JSONObject> {
private static int patientId, roomId, appointmentId,workflowId;
private iOPD mCallback;
public BookmarkQueue(int pId, int rId, int aId,int wId, Context context){
patientId = pId;
roomId = rId;
appointmentId = aId;
workflowId = wId;
mCallback = (iOPD) context;
}
@Override
protected JSONObject doInBackground(String... strings) {
try {
if(roomId == 0 || appointmentId == 0) return null;
String data = URLEncoder.encode("patient_id", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(patientId), "UTF-8");
data += "&" + URLEncoder.encode("room_id", "UTF-8") + "="
+ URLEncoder.encode(String.valueOf(roomId), "UTF-8");
data += "&" + URLEncoder.encode("appointment_id", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(appointmentId), "UTF-8");
data += "&" + URLEncoder.encode("queue_type_id", "UTF-8")
+ "=" + URLEncoder.encode("1", "UTF-8");
data += "&" + URLEncoder.encode("queue_status_id", "UTF-8")
+ "=" + URLEncoder.encode("1", "UTF-8");
data += "&" + URLEncoder.encode("workflowId", "UTF-8")
+ "=" + URLEncoder.encode(String.valueOf(workflowId), "UTF-8");
URL url = new URL(strings[0]);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setReadTimeout(10000);
conn.setReadTimeout(15000);
conn.setUseCaches(false);
conn.setDoOutput(true);
conn.setDoInput(true);
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
wr.write( data );
wr.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
StringBuilder sb = new StringBuilder();
String line = null;
// Read Server Response
while((line = reader.readLine()) != null)
{
// Append server response in string
sb.append(line + "\n");
}
conn.disconnect();
reader.close();
wr.close();
JSONObject jobj = new JSONObject(sb.toString());
return jobj;
}
catch(Exception ex)
{
ex.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(JSONObject object) {
try {
mCallback.bookmarkFinish(object.getJSONObject("results").getInt("id"));
} catch (JSONException e) {
e.printStackTrace();
}
}
}
| 3,238 | 0.567943 | 0.559605 | 102 | 30.725491 | 26.672361 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.715686 | false | false | 4 |
1ae9cd7db55736492d1a0e84dc67e093e930544f | 36,945,308,701,092 | 1b5987a7e72a58e12ac36a36a60aa6add2661095 | /code/org/processmining/framework/models/pdm/PDMModel.java | 84c7fd45d0c8e075fbd97f2c80544c669b51397d | [] | no_license | qianc62/BePT | https://github.com/qianc62/BePT | f4b1da467ee52e714c9a9cc2fb33cd2c75bdb5db | 38fb5cc5521223ba07402c7bb5909b17967cfad8 | refs/heads/master | 2021-07-11T16:25:25.879000 | 2020-09-22T10:50:51 | 2020-09-22T10:50:51 | 201,562,390 | 36 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /***********************************************************
* This software is part of the ProM package *
* http://www.processmining.org/ *
* *
* Copyright (c) 2003-2006 TU/e Eindhoven *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by Eindhoven University of Technology *
* Department of Information Systems *
* http://is.tm.tue.nl *
* *
**********************************************************/
package org.processmining.framework.models.pdm;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import org.processmining.framework.models.*;
import org.w3c.dom.*;
import org.processmining.framework.models.pdm.*;
import org.processmining.framework.log.AuditTrailEntry;
import org.processmining.framework.ui.Message;
/**
* <p>
* Title: PDMModel
* </p>
* <p>
* Description: Represents a Product Data Model (PDM)
* </p>
* <p>
* Copyright: Copyright (c) 2006
* </p>
* <p>
* Company:
* </p>
*
* @author Irene Vanderfeesten
* @version 1.0
*/
public class PDMModel extends ModelGraph {
private String name; // the name of the model
private PDMDataElement root; // the root element of the model
HashMap dataElements = new HashMap(); // the list of dataElements in the
// model
HashMap operations = new HashMap(); // the list of operations in the model
HashMap resources = new HashMap(); // the list of resources from the model
HashSet removedOps = new HashSet();
int i = 0; // global counter for unique state identifiers
/**
* Create a new PDM model with the given name
*
* @param name
* The name of the PDM model
*/
public PDMModel(String name) {
super("PDM model");
this.name = name;
}
/**
* Adds a Data Element to the set of Data Elements of the Product Data Model
*
* @param element
* PDMDataElement
*/
public void addDataElement(PDMDataElement element) {
dataElements.put(element.getID(), element);
addVertex(element);
}
/**
* Sets the root element of the model. This is one of the data elements
* added to the hashMap before.
*
* @param dataElement
* PDMDataElement
*/
public void setRootElement(PDMDataElement dataElement) {
root = dataElement;
}
/**
* Adds a Resource to the set of Resources ot the Product Data Model NB:
* Later on this should be moved to the section of the Organizational Model
*
* @param resource
* PDMResource
*/
public void addResource(PDMResource resource) {
resources.put(resource.getID(), resource);
}
/**
* Adds an Operation to the set of Operations of the Product Data Model
*
* @param operation
* PDMOperation
*/
public void addOperation(PDMOperation operation) {
operations.put(operation.getID(), operation);
}
/**
* Removes an Operation to the set of Operations of the Product Data Model
* added by Johfra
*
* @param operation
* PDMOperation
*/
public void remOperation(PDMOperation operation) {
operations.remove(operation.getID());
}
/**
* Returns the Data Element with identifier "id"
*
* @param id
* String
* @return PDMDataElement
*/
public PDMDataElement getDataElement(String id) {
return (PDMDataElement) dataElements.get(id);
}
/**
* Returns a HashMap with all data elements in this PDM model.
*
* @return HashMap
*/
public HashMap getDataElements() {
return dataElements;
}
/**
* Returns the Resource with identifier "id"
*
* @param id
* String
* @return PDMResource
*/
public PDMResource getResource(String id) {
return (PDMResource) resources.get(id);
}
/**
* Returns the Resource with identifier "id"
*
* @param id
* String
* @return PDMResource
*/
public PDMOperation getOperation(String id) {
return (PDMOperation) operations.get(id);
}
/**
* Returns all operations in the PDM model.
*
* @return HashMap
*/
public HashMap getOperations() {
return operations;
}
/**
* Returns the root element op the Product Data Model
*
* @return PDMDataElement
*/
public PDMDataElement getRootElement() {
return root;
}
/**
* Returns the leaf elements of the Product Data Model
*
* @return HashSet
*/
/*
* public HashMap getLeafElements() { HashMap map = new HashMap(); Object[]
* elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++)
* { PDMDataElement data = (PDMDataElement) elts[j];
* map.put(data.getID(),data); } Object[] ops =
* operations.values().toArray(); for (int i=0; i<ops.length; i++){
* PDMOperation op = (PDMOperation) ops[i]; if
* (!(op.getInputElements().isEmpty())){ HashMap outs =
* op.getOutputElements(); Object[] outArray = outs.values().toArray(); for
* (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement)
* outArray[j]; map.remove(d.getID()); } } } return map; }
*/
public HashMap getLeafElements() {
HashMap result = new HashMap();
HashSet leafOps = getLeafOperations();
if (!(leafOps.isEmpty())) {
Iterator it = leafOps.iterator();
while (it.hasNext()) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement data = op.getOutputElement();
result.put(data.getID(), data);
}
} else {
Object[] elts = dataElements.values().toArray();
for (int j = 0; j < elts.length; j++) {
PDMDataElement data = (PDMDataElement) elts[j];
result.put(data.getID(), data);
}
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap outs = op.getOutputElements();
Object[] outArray = outs.values().toArray();
for (int j = 0; j < outArray.length; j++) {
PDMDataElement d = (PDMDataElement) outArray[j];
result.remove(d.getID());
}
}
}
return result;
}
public HashSet getLeafOperations() {
HashSet result = new HashSet();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
if ((op.getInputElements().isEmpty())) {
result.add(op);
}
}
return result;
}
/**
* Returns a HashMap with the preceeding data elements of data element
* 'data'
*
* @param data
* PDMDataElement
* @return HashMap
*/
public HashMap getPrecedingElements(PDMDataElement data) {
HashMap precs = new HashMap();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
if (op.getOutputElements().containsValue(data)) {
HashMap ins = op.getInputElements();
Object[] inputs = ins.values().toArray();
for (int j = 0; j < inputs.length; j++) {
PDMDataElement el = (PDMDataElement) inputs[j];
precs.put(el.getID(), el);
}
}
}
return precs;
}
/**
* Returns a HashSet with the operations that have data element 'data' as
* output element.
*
* @param data
* PDMDataElement
* @return HashSet
*/
public HashSet getOperationsWithOutputElement(PDMDataElement data) {
HashSet opso = new HashSet();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap outputs = op.getOutputElements();
if (outputs.containsValue(data)) {
opso.add(op);
}
}
return opso;
}
public HashSet calculateExecutableOperations(HashSet dataElts,
HashSet executed, HashSet failed, boolean root) {
HashSet result = new HashSet();
HashSet enabledOperations = new HashSet();
if (root) {
// Calculate the enabled operations (i.e. those operation of which
// all input elements are in the set of available elements)
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap inputs = op.getInputElements();
Object[] ins = inputs.values().toArray();
boolean enabled = true;
int k = 0;
while (enabled && k < ins.length) {
PDMDataElement d = (PDMDataElement) ins[k];
if (!(dataElts.contains(d))) {
enabled = false;
}
k++;
}
if (enabled) {
enabledOperations.add(op);
// System.out.println("Enabled operation: "+ op.getID());
}
}
} else if (!(dataElts.contains(this.getRootElement()))) {
// Calculate the enabled operations (i.e. those operation of which
// all input elements are in the set of available elements)
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap inputs = op.getInputElements();
Object[] ins = inputs.values().toArray();
boolean enabled = true;
int k = 0;
while (enabled && k < ins.length) {
PDMDataElement d = (PDMDataElement) ins[k];
if (!(dataElts.contains(d))) {
enabled = false;
}
k++;
}
if (enabled) {
enabledOperations.add(op);
}
}
}
// remove already executed operations
Iterator exIt = executed.iterator();
while (exIt.hasNext()) {
PDMOperation op = (PDMOperation) exIt.next();
enabledOperations.remove(op);
}
// remove already failed operations
Iterator fIt = failed.iterator();
while (fIt.hasNext()) {
PDMOperation op = (PDMOperation) fIt.next();
enabledOperations.remove(op);
}
result = enabledOperations;
return result;
}
/**
* Calculates which data elements are the input elements of the PDM. In
* order to do so it checks for each operation if the input elements are
* also output elements to another operation. If so, the input element of
* the operation is not een input element of the PDM model. If not, then the
* input element of the operation is an input element to the PDM model.
*
* @return HashSet
*/
/*
* public HashSet getPDMInputElements() { HashSet result = new HashSet();
* HashMap ops = getOperations(); Object[] opsAr = ops.values().toArray();
* // walk through all operations of the PDM for (int i=0; i<opsAr.length;
* i++){ PDMOperation op = (PDMOperation) opsAr[i]; HashMap ins =
* op.getInputElements(); Object[] insAr = ins.values().toArray(); // check
* all input data elements of operation 'op' for (int j=0; j<insAr.length;
* j++){ PDMDataElement data = (PDMDataElement) insAr[j]; Boolean isInputElt
* = true; // check for on of the input data elements of 'op' whether there
* // is an operation that produces this data element for (int k=0;
* k<opsAr.length; k++){ PDMOperation op2 = (PDMOperation) opsAr[k]; if
* (op2.hasOutputDataElement(data)){ isInputElt = false; } } if
* (isInputElt){ result.add(data); //
* System.out.println("PDM input element: "+ data.getID()); } } } return
* result; }
*/
public PDMStateSpace calculateSimpleStateSpace(boolean root,
boolean failure, boolean input, boolean colored, int numStates,
int breadth) {
PDMStateSpace result = new PDMStateSpace(this, colored);
HashSet states = new HashSet();
int j = (operations.size() + 1);
if (!input) {
HashSet empty = new HashSet();
PDMState st = new PDMState(result, "state" + i, empty, empty, empty);
result.addState(st);
states.add(st);
i++;
} else {
// Start with the complete set of input data elements available
HashSet empty = new HashSet();
String name = new String("state" + i);
HashSet ins = new HashSet(); // this hashSet contains the input
// elements to the process (input
// elements of PDM)
HashSet execOps = new HashSet();
// Fill the hashSet with the leaf elements
HashMap leafs = getLeafElements();
Object[] leafElts = leafs.values().toArray();
for (int i = 0; i < leafElts.length; i++) {
PDMDataElement d = (PDMDataElement) leafElts[i];
ins.add(d);
}
HashSet leafOps = getLeafOperations();
Iterator it = leafOps.iterator();
while (it.hasNext()) {
PDMOperation op = (PDMOperation) it.next();
execOps.add(op);
}
PDMState start = new PDMState(result, name, ins, execOps, empty); // start
// state
// of
// the
// statespace
result.addState(start);
i++;
states.add(start);
}
while (!states.isEmpty()) {
HashSet states2 = (HashSet) states.clone();
Iterator it = states2.iterator();
while (it.hasNext()) {
PDMState state = (PDMState) it.next();
HashSet nextStates = calculateNextStates(state, result, root,
failure, numStates, breadth);
Iterator it2 = nextStates.iterator();
// Add the new states to iterator
while (it2.hasNext()) {
PDMState st = (PDMState) it2.next();
states.add(st);
}
states.remove(state);
}
}
i = 0;
j = 0;
Message.add("<PDMMDPStateSpace>", Message.TEST);
Message.add("<NumberOfStates = " + result.getNumberOfStates() + " >",
Message.TEST);
Message.add("</PDMMDPStateSpace>", Message.TEST);
return result;
}
public HashSet calculateNextStates(PDMState state,
PDMStateSpace statespace, boolean root, boolean failure,
int numStates, int breadth) {
HashSet result = new HashSet();
HashSet data = state.dataElements;
HashSet exec1 = state.executedOperations;
HashSet failed = state.failedOperations;
HashSet execOps = calculateExecutableOperations(data, exec1, failed,
root);
Iterator it = execOps.iterator();
int b = 0;
int bLimit = 0;
if (!failure) {
bLimit = breadth;
} else {
bLimit = breadth / 2;
}
// for each executable operation a new state is created
while (it.hasNext() && i < numStates && b < bLimit) {
if (!failure) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement d = op.getOutputElement();
// First, add the state with the operation 'op' succesfully
// executed
HashSet ins2 = (HashSet) data.clone(); // NB: is it necessary to
// clear this clone
// again?
ins2.add(d);
HashSet exec2 = (HashSet) exec1.clone();
exec2.add(op);
PDMState s = checkIfStateExists(statespace, ins2, exec2, failed);
// Check whether the new state already exists
// If so, then another link to this state is made
if (!(s == null)) {
PDMState st = s;
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
1.0);
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
// int num = checkStatusOfState(statespace, )
PDMState st = new PDMState(statespace, name, ins2, exec2,
failed);
statespace.addState(st);
result.add(st);
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
1.0);
statespace.addEdge(edge);
i++;
b++;
}
}
// Then, if failure of operations is considered, add the state with
// the failed operations 'op'.
if (failure) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement d = op.getOutputElement();
// First, add the state with the operation 'op' succesfully
// executed
HashSet ins2 = (HashSet) data.clone(); // NB: is it necessary to
// clear this clone
// again?
ins2.add(d);
HashSet exec2 = (HashSet) exec1.clone();
exec2.add(op);
PDMState s = checkIfStateExists(statespace, ins2, exec2, failed);
// Check whether the new state already exists
// If so, then another link to this state is made
if (!(s == null)) {
PDMState st = s;
double prob = 1.0 - (op.getFailureProbability());
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
prob);
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
// int num = checkStatusOfState(statespace, )
PDMState st = new PDMState(statespace, name, ins2, exec2,
failed);
statespace.addState(st);
result.add(st);
double prob = 1.0 - (op.getFailureProbability());
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
prob);
statespace.addEdge(edge);
i++;
b++;
}
HashSet failed2 = (HashSet) failed.clone();
failed2.add(op);
PDMState s2 = checkIfStateExists(statespace, data, exec1,
failed2);
if (!(s2 == null)) {
PDMState st = s2;
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
op.getFailureProbability());
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
PDMState st = new PDMState(statespace, name, data, exec1,
failed2);
statespace.addState(st);
result.add(st);
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
op.getFailureProbability());
statespace.addEdge(edge);
i++;
b++;
}
// failed2.clear();
}
}
return result;
}
public PDMState checkIfStateExists(PDMStateSpace statespace, HashSet data,
HashSet exec, HashSet failed) {
PDMState result = null;
boolean bool = false;
HashSet states = statespace.getStates();
Iterator it = states.iterator();
while (it.hasNext() && !bool) {
PDMState state2 = (PDMState) it.next();
boolean one = false;
boolean two = false;
boolean three = false;
HashSet data2 = state2.dataElements;
HashSet exec2 = state2.executedOperations;
HashSet failed2 = state2.failedOperations;
one = hashSetContainsSameDataElements(data, data2);
two = hashSetContainsSameOperations(exec, exec2);
three = hashSetContainsSameOperations(failed, failed2);
if (one && two && three) {
bool = true;
result = state2;
}
}
return result;
}
public boolean hashSetContainsSameDataElements(HashSet set1, HashSet set2) {
boolean result = false;
HashSet s1 = (HashSet) set1.clone();
HashSet s2 = (HashSet) set2.clone();
// first part, are all elements of s1 also in s2?
boolean one = false;
Iterator it = set1.iterator();
while (it.hasNext()) {
PDMDataElement d = (PDMDataElement) it.next();
if (s2.contains(d)) {
s1.remove(d);
}
}
if (s1.isEmpty()) {
one = true;
}
// second part, are all elements of s2 also in s1?
boolean two = false;
HashSet s3 = (HashSet) set1.clone();
HashSet s4 = (HashSet) set2.clone();
Iterator it2 = set2.iterator();
while (it2.hasNext()) {
PDMDataElement d = (PDMDataElement) it2.next();
if (s3.contains(d)) {
s4.remove(d);
}
}
if (s4.isEmpty()) {
two = true;
}
// administrative stuff
s1.clear();
s2.clear();
s3.clear();
s4.clear();
result = one && two;
return result;
}
public boolean hashSetContainsSameOperations(HashSet set1, HashSet set2) {
boolean result = false;
HashSet s1 = (HashSet) set1.clone();
HashSet s2 = (HashSet) set2.clone();
// first part, are all elements of s1 also in s2?
boolean one = false;
Iterator it = set1.iterator();
while (it.hasNext()) {
PDMOperation d = (PDMOperation) it.next();
if (s2.contains(d)) {
s1.remove(d);
}
}
if (s1.isEmpty()) {
one = true;
}
// second part, are all elements of s21 also in s1?
boolean two = false;
HashSet s3 = (HashSet) set1.clone();
HashSet s4 = (HashSet) set2.clone();
Iterator it2 = set2.iterator();
while (it2.hasNext()) {
PDMOperation d = (PDMOperation) it2.next();
if (s3.contains(d)) {
s4.remove(d);
}
}
if (s4.isEmpty()) {
two = true;
}
// administrative stuff
s1.clear();
s2.clear();
s3.clear();
s4.clear();
result = one && two;
return result;
}
/**
* Export to PDM file.
*
* @param bw
* Writer
* @throws IOException
* If writing fails
*/
public void writeToPDM(Writer bw) throws IOException {
bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
bw.write("<PDM\n");
bw.write("\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
bw
.write("\txsi:noNamespaceSchemaLocation=\"C:/Documents and Settings/ivdfeest/My Documents/Implementatie/PDM.xsd\"\n");
bw.write(">\n");
Iterator it = dataElements.values().iterator();
while (it.hasNext()) {
PDMDataElement dataElement = (PDMDataElement) it.next();
dataElement.writeToPDM(bw);
}
Iterator it2 = resources.values().iterator();
while (it2.hasNext()) {
PDMResource resource = (PDMResource) it.next();
resource.writeToPDM(bw);
}
Iterator it3 = operations.values().iterator();
while (it3.hasNext()) {
PDMOperation operation = (PDMOperation) it.next();
operation.writeToPDM(bw);
}
bw.write("</PDM>\n");
}
/**
* Export PDM model to Declare process model.
*
* @param bw
* Writer
* @throws IOException
* If writing fails
*/
public void writePDMToDeclare(Writer bw) throws IOException {
// write the preamble of the XML file
bw
.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
bw.write("<model>\n");
bw.write("<assignment language=\"ConDec\" name=\"" + name + "\">\n");
// write the activity definitions, i.e. each operation in the PDM is an
// activity definition in Declare
bw.write("<activitydefinitions>\n");
// start with an initial activity that puts the values for the leaf
// elements of the PDM
bw.write("<activity id=\"Initial\" name=\"Initial\">\n");
bw.write("<authorization/>\n");
bw.write("<datamodel>\n");
// all leaf elements
HashMap leafs = getLeafElements();
Object[] leafElts = leafs.values().toArray();
for (int i = 0; i < leafElts.length; i++) {
PDMDataElement data = (PDMDataElement) leafElts[i];
data.writePDMToDeclare(bw, "output");
}
bw.write("</datamodel>\n");
bw.write("<attributes/>\n");
bw.write("</activity>\n");
// first remove input operations from the set of operations and then
// write all real operations
HashMap realOps = (HashMap) operations.clone();
HashSet inputOps = getLeafOperations();
Iterator it7 = inputOps.iterator();
while (it7.hasNext()) {
PDMOperation op = (PDMOperation) it7.next();
realOps.remove(op.getID());
}
Iterator it4 = realOps.values().iterator();
while (it4.hasNext()) {
PDMOperation operation = (PDMOperation) it4.next();
operation.writePDMToDeclare(bw);
}
bw.write("\n");
// write all input operations (i.e. producing input data elements)
Iterator it8 = inputOps.iterator();
while (it8.hasNext()) {
PDMOperation op = (PDMOperation) it8.next();
op.writePDMToDeclare(bw);
}
bw.write("</activitydefinitions>\n");
// write the constraint definition, for now we do not have any
// constraints in the PDM that are translated to Declare
bw.write("<constraintdefinitions>\n");
bw.write("</constraintdefinitions>\n");
// write all dataelements
bw.write("<data>\n");
Iterator it5 = dataElements.values().iterator();
while (it5.hasNext()) {
PDMDataElement dataElement = (PDMDataElement) it5.next();
dataElement.writePDMToDeclare(bw);
}
bw.write("</data>\n");
// write the organizational information
bw.write("<team/>\n");
// TODO: improve graphical positioning of activities. Now they are
// presented in one long line.
// write the graphical positioning information of the Declare model,
// first the initial operation, then the real operations and then the
// input operations.
bw.write("<graphical>\n");
bw.write("<cells>\n");
Iterator it6 = realOps.values().iterator();
Double pos = 10.0;
while (it6.hasNext()) {
PDMOperation operation = (PDMOperation) it6.next();
bw.write("<cell activitydefinition=\"" + operation.getOperationNR()
+ "\" height=\"40.0\" width=\"80.0\" x=\"" + pos
+ "\" y=\"90.0\" />\n");
pos = pos + 85.0;
}
Iterator it9 = inputOps.iterator();
pos = 10.0;
while (it9.hasNext()) {
PDMOperation operation = (PDMOperation) it9.next();
bw.write("<cell activitydefinition=\"" + operation.getOperationNR()
+ "\" height=\"40.0\" width=\"80.0\" x=\"" + pos
+ "\" y=\"180.0\" />\n");
pos = pos + 85.0;
}
bw.write("</cells>\n");
// write the connectors
bw.write("<connectors/>\n");
// close the XML file in the right way
bw.write("</graphical>\n");
bw.write("</assignment>\n");
bw.write("</model>\n");
}
/**
* Writes the model to DOT.
*
* @param bw
* The writer
* @throws IOException
* If writing fails
*/
public void writeToDot(Writer bw) throws IOException {
// super.writeToDot(bw);
// Preamble of dot file
bw
.write("digraph G {ranksep=\".3\"; fontsize=\"8\"; remincross=true; margin=\"0.0,0.0\"; rankdir=TB; ");
bw.write("fontname=\"Arial\"; \n");
bw.write("edge [arrowsize=\"0.5\"];\n");
bw.write("node [fontname=\"Arial\",fontsize=\"8\"];\n");
// Add the Data Element nodes
Iterator it = getVerticeList().iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof PDMDataElement) {
((PDMDataElement) object).writeToDot(bw, this);
}
}
// Add all edges
it = operations.values().iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof PDMOperation) {
((PDMOperation) object).writeToDot(bw, this);
}
}
bw.write("\n}\n");
}
}
| UTF-8 | Java | 25,439 | java | PDMModel.java | Java | [
{
"context": "\n * </p>\n * <p>\n * Company:\n * </p>\n * \n * @author Irene Vanderfeesten\n * @version 1.0\n */\npublic class PDMModel extends",
"end": 1284,
"score": 0.9998931884765625,
"start": 1265,
"tag": "NAME",
"value": "Irene Vanderfeesten"
}
] | null | [] | /***********************************************************
* This software is part of the ProM package *
* http://www.processmining.org/ *
* *
* Copyright (c) 2003-2006 TU/e Eindhoven *
* and is licensed under the *
* Common Public License, Version 1.0 *
* by Eindhoven University of Technology *
* Department of Information Systems *
* http://is.tm.tue.nl *
* *
**********************************************************/
package org.processmining.framework.models.pdm;
import java.io.*;
import java.util.*;
import javax.xml.parsers.*;
import org.processmining.framework.models.*;
import org.w3c.dom.*;
import org.processmining.framework.models.pdm.*;
import org.processmining.framework.log.AuditTrailEntry;
import org.processmining.framework.ui.Message;
/**
* <p>
* Title: PDMModel
* </p>
* <p>
* Description: Represents a Product Data Model (PDM)
* </p>
* <p>
* Copyright: Copyright (c) 2006
* </p>
* <p>
* Company:
* </p>
*
* @author <NAME>
* @version 1.0
*/
public class PDMModel extends ModelGraph {
private String name; // the name of the model
private PDMDataElement root; // the root element of the model
HashMap dataElements = new HashMap(); // the list of dataElements in the
// model
HashMap operations = new HashMap(); // the list of operations in the model
HashMap resources = new HashMap(); // the list of resources from the model
HashSet removedOps = new HashSet();
int i = 0; // global counter for unique state identifiers
/**
* Create a new PDM model with the given name
*
* @param name
* The name of the PDM model
*/
public PDMModel(String name) {
super("PDM model");
this.name = name;
}
/**
* Adds a Data Element to the set of Data Elements of the Product Data Model
*
* @param element
* PDMDataElement
*/
public void addDataElement(PDMDataElement element) {
dataElements.put(element.getID(), element);
addVertex(element);
}
/**
* Sets the root element of the model. This is one of the data elements
* added to the hashMap before.
*
* @param dataElement
* PDMDataElement
*/
public void setRootElement(PDMDataElement dataElement) {
root = dataElement;
}
/**
* Adds a Resource to the set of Resources ot the Product Data Model NB:
* Later on this should be moved to the section of the Organizational Model
*
* @param resource
* PDMResource
*/
public void addResource(PDMResource resource) {
resources.put(resource.getID(), resource);
}
/**
* Adds an Operation to the set of Operations of the Product Data Model
*
* @param operation
* PDMOperation
*/
public void addOperation(PDMOperation operation) {
operations.put(operation.getID(), operation);
}
/**
* Removes an Operation to the set of Operations of the Product Data Model
* added by Johfra
*
* @param operation
* PDMOperation
*/
public void remOperation(PDMOperation operation) {
operations.remove(operation.getID());
}
/**
* Returns the Data Element with identifier "id"
*
* @param id
* String
* @return PDMDataElement
*/
public PDMDataElement getDataElement(String id) {
return (PDMDataElement) dataElements.get(id);
}
/**
* Returns a HashMap with all data elements in this PDM model.
*
* @return HashMap
*/
public HashMap getDataElements() {
return dataElements;
}
/**
* Returns the Resource with identifier "id"
*
* @param id
* String
* @return PDMResource
*/
public PDMResource getResource(String id) {
return (PDMResource) resources.get(id);
}
/**
* Returns the Resource with identifier "id"
*
* @param id
* String
* @return PDMResource
*/
public PDMOperation getOperation(String id) {
return (PDMOperation) operations.get(id);
}
/**
* Returns all operations in the PDM model.
*
* @return HashMap
*/
public HashMap getOperations() {
return operations;
}
/**
* Returns the root element op the Product Data Model
*
* @return PDMDataElement
*/
public PDMDataElement getRootElement() {
return root;
}
/**
* Returns the leaf elements of the Product Data Model
*
* @return HashSet
*/
/*
* public HashMap getLeafElements() { HashMap map = new HashMap(); Object[]
* elts = dataElements.values().toArray(); for (int j=0; j<elts.length; j++)
* { PDMDataElement data = (PDMDataElement) elts[j];
* map.put(data.getID(),data); } Object[] ops =
* operations.values().toArray(); for (int i=0; i<ops.length; i++){
* PDMOperation op = (PDMOperation) ops[i]; if
* (!(op.getInputElements().isEmpty())){ HashMap outs =
* op.getOutputElements(); Object[] outArray = outs.values().toArray(); for
* (int j=0; j<outArray.length; j++) { PDMDataElement d = (PDMDataElement)
* outArray[j]; map.remove(d.getID()); } } } return map; }
*/
public HashMap getLeafElements() {
HashMap result = new HashMap();
HashSet leafOps = getLeafOperations();
if (!(leafOps.isEmpty())) {
Iterator it = leafOps.iterator();
while (it.hasNext()) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement data = op.getOutputElement();
result.put(data.getID(), data);
}
} else {
Object[] elts = dataElements.values().toArray();
for (int j = 0; j < elts.length; j++) {
PDMDataElement data = (PDMDataElement) elts[j];
result.put(data.getID(), data);
}
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap outs = op.getOutputElements();
Object[] outArray = outs.values().toArray();
for (int j = 0; j < outArray.length; j++) {
PDMDataElement d = (PDMDataElement) outArray[j];
result.remove(d.getID());
}
}
}
return result;
}
public HashSet getLeafOperations() {
HashSet result = new HashSet();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
if ((op.getInputElements().isEmpty())) {
result.add(op);
}
}
return result;
}
/**
* Returns a HashMap with the preceeding data elements of data element
* 'data'
*
* @param data
* PDMDataElement
* @return HashMap
*/
public HashMap getPrecedingElements(PDMDataElement data) {
HashMap precs = new HashMap();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
if (op.getOutputElements().containsValue(data)) {
HashMap ins = op.getInputElements();
Object[] inputs = ins.values().toArray();
for (int j = 0; j < inputs.length; j++) {
PDMDataElement el = (PDMDataElement) inputs[j];
precs.put(el.getID(), el);
}
}
}
return precs;
}
/**
* Returns a HashSet with the operations that have data element 'data' as
* output element.
*
* @param data
* PDMDataElement
* @return HashSet
*/
public HashSet getOperationsWithOutputElement(PDMDataElement data) {
HashSet opso = new HashSet();
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap outputs = op.getOutputElements();
if (outputs.containsValue(data)) {
opso.add(op);
}
}
return opso;
}
public HashSet calculateExecutableOperations(HashSet dataElts,
HashSet executed, HashSet failed, boolean root) {
HashSet result = new HashSet();
HashSet enabledOperations = new HashSet();
if (root) {
// Calculate the enabled operations (i.e. those operation of which
// all input elements are in the set of available elements)
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap inputs = op.getInputElements();
Object[] ins = inputs.values().toArray();
boolean enabled = true;
int k = 0;
while (enabled && k < ins.length) {
PDMDataElement d = (PDMDataElement) ins[k];
if (!(dataElts.contains(d))) {
enabled = false;
}
k++;
}
if (enabled) {
enabledOperations.add(op);
// System.out.println("Enabled operation: "+ op.getID());
}
}
} else if (!(dataElts.contains(this.getRootElement()))) {
// Calculate the enabled operations (i.e. those operation of which
// all input elements are in the set of available elements)
Object[] ops = operations.values().toArray();
for (int i = 0; i < ops.length; i++) {
PDMOperation op = (PDMOperation) ops[i];
HashMap inputs = op.getInputElements();
Object[] ins = inputs.values().toArray();
boolean enabled = true;
int k = 0;
while (enabled && k < ins.length) {
PDMDataElement d = (PDMDataElement) ins[k];
if (!(dataElts.contains(d))) {
enabled = false;
}
k++;
}
if (enabled) {
enabledOperations.add(op);
}
}
}
// remove already executed operations
Iterator exIt = executed.iterator();
while (exIt.hasNext()) {
PDMOperation op = (PDMOperation) exIt.next();
enabledOperations.remove(op);
}
// remove already failed operations
Iterator fIt = failed.iterator();
while (fIt.hasNext()) {
PDMOperation op = (PDMOperation) fIt.next();
enabledOperations.remove(op);
}
result = enabledOperations;
return result;
}
/**
* Calculates which data elements are the input elements of the PDM. In
* order to do so it checks for each operation if the input elements are
* also output elements to another operation. If so, the input element of
* the operation is not een input element of the PDM model. If not, then the
* input element of the operation is an input element to the PDM model.
*
* @return HashSet
*/
/*
* public HashSet getPDMInputElements() { HashSet result = new HashSet();
* HashMap ops = getOperations(); Object[] opsAr = ops.values().toArray();
* // walk through all operations of the PDM for (int i=0; i<opsAr.length;
* i++){ PDMOperation op = (PDMOperation) opsAr[i]; HashMap ins =
* op.getInputElements(); Object[] insAr = ins.values().toArray(); // check
* all input data elements of operation 'op' for (int j=0; j<insAr.length;
* j++){ PDMDataElement data = (PDMDataElement) insAr[j]; Boolean isInputElt
* = true; // check for on of the input data elements of 'op' whether there
* // is an operation that produces this data element for (int k=0;
* k<opsAr.length; k++){ PDMOperation op2 = (PDMOperation) opsAr[k]; if
* (op2.hasOutputDataElement(data)){ isInputElt = false; } } if
* (isInputElt){ result.add(data); //
* System.out.println("PDM input element: "+ data.getID()); } } } return
* result; }
*/
public PDMStateSpace calculateSimpleStateSpace(boolean root,
boolean failure, boolean input, boolean colored, int numStates,
int breadth) {
PDMStateSpace result = new PDMStateSpace(this, colored);
HashSet states = new HashSet();
int j = (operations.size() + 1);
if (!input) {
HashSet empty = new HashSet();
PDMState st = new PDMState(result, "state" + i, empty, empty, empty);
result.addState(st);
states.add(st);
i++;
} else {
// Start with the complete set of input data elements available
HashSet empty = new HashSet();
String name = new String("state" + i);
HashSet ins = new HashSet(); // this hashSet contains the input
// elements to the process (input
// elements of PDM)
HashSet execOps = new HashSet();
// Fill the hashSet with the leaf elements
HashMap leafs = getLeafElements();
Object[] leafElts = leafs.values().toArray();
for (int i = 0; i < leafElts.length; i++) {
PDMDataElement d = (PDMDataElement) leafElts[i];
ins.add(d);
}
HashSet leafOps = getLeafOperations();
Iterator it = leafOps.iterator();
while (it.hasNext()) {
PDMOperation op = (PDMOperation) it.next();
execOps.add(op);
}
PDMState start = new PDMState(result, name, ins, execOps, empty); // start
// state
// of
// the
// statespace
result.addState(start);
i++;
states.add(start);
}
while (!states.isEmpty()) {
HashSet states2 = (HashSet) states.clone();
Iterator it = states2.iterator();
while (it.hasNext()) {
PDMState state = (PDMState) it.next();
HashSet nextStates = calculateNextStates(state, result, root,
failure, numStates, breadth);
Iterator it2 = nextStates.iterator();
// Add the new states to iterator
while (it2.hasNext()) {
PDMState st = (PDMState) it2.next();
states.add(st);
}
states.remove(state);
}
}
i = 0;
j = 0;
Message.add("<PDMMDPStateSpace>", Message.TEST);
Message.add("<NumberOfStates = " + result.getNumberOfStates() + " >",
Message.TEST);
Message.add("</PDMMDPStateSpace>", Message.TEST);
return result;
}
public HashSet calculateNextStates(PDMState state,
PDMStateSpace statespace, boolean root, boolean failure,
int numStates, int breadth) {
HashSet result = new HashSet();
HashSet data = state.dataElements;
HashSet exec1 = state.executedOperations;
HashSet failed = state.failedOperations;
HashSet execOps = calculateExecutableOperations(data, exec1, failed,
root);
Iterator it = execOps.iterator();
int b = 0;
int bLimit = 0;
if (!failure) {
bLimit = breadth;
} else {
bLimit = breadth / 2;
}
// for each executable operation a new state is created
while (it.hasNext() && i < numStates && b < bLimit) {
if (!failure) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement d = op.getOutputElement();
// First, add the state with the operation 'op' succesfully
// executed
HashSet ins2 = (HashSet) data.clone(); // NB: is it necessary to
// clear this clone
// again?
ins2.add(d);
HashSet exec2 = (HashSet) exec1.clone();
exec2.add(op);
PDMState s = checkIfStateExists(statespace, ins2, exec2, failed);
// Check whether the new state already exists
// If so, then another link to this state is made
if (!(s == null)) {
PDMState st = s;
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
1.0);
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
// int num = checkStatusOfState(statespace, )
PDMState st = new PDMState(statespace, name, ins2, exec2,
failed);
statespace.addState(st);
result.add(st);
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
1.0);
statespace.addEdge(edge);
i++;
b++;
}
}
// Then, if failure of operations is considered, add the state with
// the failed operations 'op'.
if (failure) {
PDMOperation op = (PDMOperation) it.next();
PDMDataElement d = op.getOutputElement();
// First, add the state with the operation 'op' succesfully
// executed
HashSet ins2 = (HashSet) data.clone(); // NB: is it necessary to
// clear this clone
// again?
ins2.add(d);
HashSet exec2 = (HashSet) exec1.clone();
exec2.add(op);
PDMState s = checkIfStateExists(statespace, ins2, exec2, failed);
// Check whether the new state already exists
// If so, then another link to this state is made
if (!(s == null)) {
PDMState st = s;
double prob = 1.0 - (op.getFailureProbability());
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
prob);
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
// int num = checkStatusOfState(statespace, )
PDMState st = new PDMState(statespace, name, ins2, exec2,
failed);
statespace.addState(st);
result.add(st);
double prob = 1.0 - (op.getFailureProbability());
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
prob);
statespace.addEdge(edge);
i++;
b++;
}
HashSet failed2 = (HashSet) failed.clone();
failed2.add(op);
PDMState s2 = checkIfStateExists(statespace, data, exec1,
failed2);
if (!(s2 == null)) {
PDMState st = s2;
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
op.getFailureProbability());
statespace.addEdge(edge);
}
// If not, a new state is created and linked to the current
// state
else {
String name = "state" + i;
PDMState st = new PDMState(statespace, name, data, exec1,
failed2);
statespace.addState(st);
result.add(st);
PDMStateEdge edge = new PDMStateEdge(state, st, op.getID(),
op.getFailureProbability());
statespace.addEdge(edge);
i++;
b++;
}
// failed2.clear();
}
}
return result;
}
public PDMState checkIfStateExists(PDMStateSpace statespace, HashSet data,
HashSet exec, HashSet failed) {
PDMState result = null;
boolean bool = false;
HashSet states = statespace.getStates();
Iterator it = states.iterator();
while (it.hasNext() && !bool) {
PDMState state2 = (PDMState) it.next();
boolean one = false;
boolean two = false;
boolean three = false;
HashSet data2 = state2.dataElements;
HashSet exec2 = state2.executedOperations;
HashSet failed2 = state2.failedOperations;
one = hashSetContainsSameDataElements(data, data2);
two = hashSetContainsSameOperations(exec, exec2);
three = hashSetContainsSameOperations(failed, failed2);
if (one && two && three) {
bool = true;
result = state2;
}
}
return result;
}
public boolean hashSetContainsSameDataElements(HashSet set1, HashSet set2) {
boolean result = false;
HashSet s1 = (HashSet) set1.clone();
HashSet s2 = (HashSet) set2.clone();
// first part, are all elements of s1 also in s2?
boolean one = false;
Iterator it = set1.iterator();
while (it.hasNext()) {
PDMDataElement d = (PDMDataElement) it.next();
if (s2.contains(d)) {
s1.remove(d);
}
}
if (s1.isEmpty()) {
one = true;
}
// second part, are all elements of s2 also in s1?
boolean two = false;
HashSet s3 = (HashSet) set1.clone();
HashSet s4 = (HashSet) set2.clone();
Iterator it2 = set2.iterator();
while (it2.hasNext()) {
PDMDataElement d = (PDMDataElement) it2.next();
if (s3.contains(d)) {
s4.remove(d);
}
}
if (s4.isEmpty()) {
two = true;
}
// administrative stuff
s1.clear();
s2.clear();
s3.clear();
s4.clear();
result = one && two;
return result;
}
public boolean hashSetContainsSameOperations(HashSet set1, HashSet set2) {
boolean result = false;
HashSet s1 = (HashSet) set1.clone();
HashSet s2 = (HashSet) set2.clone();
// first part, are all elements of s1 also in s2?
boolean one = false;
Iterator it = set1.iterator();
while (it.hasNext()) {
PDMOperation d = (PDMOperation) it.next();
if (s2.contains(d)) {
s1.remove(d);
}
}
if (s1.isEmpty()) {
one = true;
}
// second part, are all elements of s21 also in s1?
boolean two = false;
HashSet s3 = (HashSet) set1.clone();
HashSet s4 = (HashSet) set2.clone();
Iterator it2 = set2.iterator();
while (it2.hasNext()) {
PDMOperation d = (PDMOperation) it2.next();
if (s3.contains(d)) {
s4.remove(d);
}
}
if (s4.isEmpty()) {
two = true;
}
// administrative stuff
s1.clear();
s2.clear();
s3.clear();
s4.clear();
result = one && two;
return result;
}
/**
* Export to PDM file.
*
* @param bw
* Writer
* @throws IOException
* If writing fails
*/
public void writeToPDM(Writer bw) throws IOException {
bw.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
bw.write("<PDM\n");
bw.write("\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n");
bw
.write("\txsi:noNamespaceSchemaLocation=\"C:/Documents and Settings/ivdfeest/My Documents/Implementatie/PDM.xsd\"\n");
bw.write(">\n");
Iterator it = dataElements.values().iterator();
while (it.hasNext()) {
PDMDataElement dataElement = (PDMDataElement) it.next();
dataElement.writeToPDM(bw);
}
Iterator it2 = resources.values().iterator();
while (it2.hasNext()) {
PDMResource resource = (PDMResource) it.next();
resource.writeToPDM(bw);
}
Iterator it3 = operations.values().iterator();
while (it3.hasNext()) {
PDMOperation operation = (PDMOperation) it.next();
operation.writeToPDM(bw);
}
bw.write("</PDM>\n");
}
/**
* Export PDM model to Declare process model.
*
* @param bw
* Writer
* @throws IOException
* If writing fails
*/
public void writePDMToDeclare(Writer bw) throws IOException {
// write the preamble of the XML file
bw
.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
bw.write("<model>\n");
bw.write("<assignment language=\"ConDec\" name=\"" + name + "\">\n");
// write the activity definitions, i.e. each operation in the PDM is an
// activity definition in Declare
bw.write("<activitydefinitions>\n");
// start with an initial activity that puts the values for the leaf
// elements of the PDM
bw.write("<activity id=\"Initial\" name=\"Initial\">\n");
bw.write("<authorization/>\n");
bw.write("<datamodel>\n");
// all leaf elements
HashMap leafs = getLeafElements();
Object[] leafElts = leafs.values().toArray();
for (int i = 0; i < leafElts.length; i++) {
PDMDataElement data = (PDMDataElement) leafElts[i];
data.writePDMToDeclare(bw, "output");
}
bw.write("</datamodel>\n");
bw.write("<attributes/>\n");
bw.write("</activity>\n");
// first remove input operations from the set of operations and then
// write all real operations
HashMap realOps = (HashMap) operations.clone();
HashSet inputOps = getLeafOperations();
Iterator it7 = inputOps.iterator();
while (it7.hasNext()) {
PDMOperation op = (PDMOperation) it7.next();
realOps.remove(op.getID());
}
Iterator it4 = realOps.values().iterator();
while (it4.hasNext()) {
PDMOperation operation = (PDMOperation) it4.next();
operation.writePDMToDeclare(bw);
}
bw.write("\n");
// write all input operations (i.e. producing input data elements)
Iterator it8 = inputOps.iterator();
while (it8.hasNext()) {
PDMOperation op = (PDMOperation) it8.next();
op.writePDMToDeclare(bw);
}
bw.write("</activitydefinitions>\n");
// write the constraint definition, for now we do not have any
// constraints in the PDM that are translated to Declare
bw.write("<constraintdefinitions>\n");
bw.write("</constraintdefinitions>\n");
// write all dataelements
bw.write("<data>\n");
Iterator it5 = dataElements.values().iterator();
while (it5.hasNext()) {
PDMDataElement dataElement = (PDMDataElement) it5.next();
dataElement.writePDMToDeclare(bw);
}
bw.write("</data>\n");
// write the organizational information
bw.write("<team/>\n");
// TODO: improve graphical positioning of activities. Now they are
// presented in one long line.
// write the graphical positioning information of the Declare model,
// first the initial operation, then the real operations and then the
// input operations.
bw.write("<graphical>\n");
bw.write("<cells>\n");
Iterator it6 = realOps.values().iterator();
Double pos = 10.0;
while (it6.hasNext()) {
PDMOperation operation = (PDMOperation) it6.next();
bw.write("<cell activitydefinition=\"" + operation.getOperationNR()
+ "\" height=\"40.0\" width=\"80.0\" x=\"" + pos
+ "\" y=\"90.0\" />\n");
pos = pos + 85.0;
}
Iterator it9 = inputOps.iterator();
pos = 10.0;
while (it9.hasNext()) {
PDMOperation operation = (PDMOperation) it9.next();
bw.write("<cell activitydefinition=\"" + operation.getOperationNR()
+ "\" height=\"40.0\" width=\"80.0\" x=\"" + pos
+ "\" y=\"180.0\" />\n");
pos = pos + 85.0;
}
bw.write("</cells>\n");
// write the connectors
bw.write("<connectors/>\n");
// close the XML file in the right way
bw.write("</graphical>\n");
bw.write("</assignment>\n");
bw.write("</model>\n");
}
/**
* Writes the model to DOT.
*
* @param bw
* The writer
* @throws IOException
* If writing fails
*/
public void writeToDot(Writer bw) throws IOException {
// super.writeToDot(bw);
// Preamble of dot file
bw
.write("digraph G {ranksep=\".3\"; fontsize=\"8\"; remincross=true; margin=\"0.0,0.0\"; rankdir=TB; ");
bw.write("fontname=\"Arial\"; \n");
bw.write("edge [arrowsize=\"0.5\"];\n");
bw.write("node [fontname=\"Arial\",fontsize=\"8\"];\n");
// Add the Data Element nodes
Iterator it = getVerticeList().iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof PDMDataElement) {
((PDMDataElement) object).writeToDot(bw, this);
}
}
// Add all edges
it = operations.values().iterator();
while (it.hasNext()) {
Object object = it.next();
if (object instanceof PDMOperation) {
((PDMOperation) object).writeToDot(bw, this);
}
}
bw.write("\n}\n");
}
}
| 25,426 | 0.630292 | 0.621212 | 857 | 28.683781 | 22.290468 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.819137 | false | false | 4 |
7687fc126230a3f40dcddb7cf8e651d27394ea5f | 34,694,745,860,329 | 385e3414ccb7458bbd3cec326320f11819decc7b | /packages/apps/ContactsCommon/ext/src/com/mediatek/contacts/ext/DefaultSimServiceExtension.java | bc25f51e1b72088318545ffe49a3da3f4e0af804 | [] | no_license | carlos22211/Tango_AL813 | https://github.com/carlos22211/Tango_AL813 | 14de7f2693c3045b9d3c0cb52017ba2bb6e6b28f | b50b1b7491dc9c5e6b92c2d94503635c43e93200 | refs/heads/master | 2020-03-28T08:09:11.127000 | 2017-06-26T05:05:29 | 2017-06-26T05:05:29 | 147,947,860 | 1 | 0 | null | true | 2018-09-08T15:55:46 | 2018-09-08T15:55:45 | 2017-06-26T04:55:49 | 2017-06-26T05:07:19 | 1,326,535 | 0 | 0 | 0 | null | false | null | package com.mediatek.contacts.ext;
import android.content.ContentResolver;
import android.os.Bundle;
public class DefaultSimServiceExtension implements ISimServiceExtension {
@Override
public void importViaReadonlyContact(Bundle bundle, ContentResolver cr) {
//default do-nothing
}
}
| UTF-8 | Java | 306 | java | DefaultSimServiceExtension.java | Java | [] | null | [] | package com.mediatek.contacts.ext;
import android.content.ContentResolver;
import android.os.Bundle;
public class DefaultSimServiceExtension implements ISimServiceExtension {
@Override
public void importViaReadonlyContact(Bundle bundle, ContentResolver cr) {
//default do-nothing
}
}
| 306 | 0.781046 | 0.781046 | 11 | 26.818182 | 26.332897 | 77 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.363636 | false | false | 4 |
514f4819b8577fcaaa49a6da2821148713c8e2e0 | 39,006,893,006,974 | 7cc6dfc3ef6962578923843bcc0568c3e3b6d661 | /src/main/java/com/amazon/leetcode/ReverseBits.java | e8d3ec3ffcbbbfb45466ac0253a63077c462b245 | [] | no_license | zzhan133/encho | https://github.com/zzhan133/encho | 16b8ceea949683275136f5ee74ec6207aa37a7c3 | 22be17e81312542cac0405046de3e100bea13943 | refs/heads/master | 2020-04-03T04:49:11.944000 | 2018-10-28T08:46:10 | 2018-10-28T08:46:10 | 155,022,583 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.amazon.leetcode;
public class ReverseBits {
public int reverseBits(int n) {
int f = n & 0x0000FFFF;
int s = (n & 0xFFFF0000) >> 16;
return (reverse16Bits(f) << 16) + reverse16Bits(s);
}
private int reverse16Bits(int n) {
int f = n & 0xFF;
int s = (n & 0xFF00) >> 8;
return (reverse8Bits(f) << 8) + reverse8Bits(s);
}
private int reverse8Bits(int n) {
int f = n & 0xF;
int s = (n & 0xF0) >> 4;
return (reverse4Bits(f) << 4) + reverse4Bits(s);
}
private int reverse4Bits (int n) {
int f = n & 0x3;
int s = (n & 0xc) >> 2;
return (reverse2Bits(f) << 2) + reverse2Bits(s);
}
private int reverse2Bits(int n) {
if(n == 1) return 2;
if(n == 2) return 1;
return n;
}
}
| UTF-8 | Java | 855 | java | ReverseBits.java | Java | [] | null | [] | package com.amazon.leetcode;
public class ReverseBits {
public int reverseBits(int n) {
int f = n & 0x0000FFFF;
int s = (n & 0xFFFF0000) >> 16;
return (reverse16Bits(f) << 16) + reverse16Bits(s);
}
private int reverse16Bits(int n) {
int f = n & 0xFF;
int s = (n & 0xFF00) >> 8;
return (reverse8Bits(f) << 8) + reverse8Bits(s);
}
private int reverse8Bits(int n) {
int f = n & 0xF;
int s = (n & 0xF0) >> 4;
return (reverse4Bits(f) << 4) + reverse4Bits(s);
}
private int reverse4Bits (int n) {
int f = n & 0x3;
int s = (n & 0xc) >> 2;
return (reverse2Bits(f) << 2) + reverse2Bits(s);
}
private int reverse2Bits(int n) {
if(n == 1) return 2;
if(n == 2) return 1;
return n;
}
}
| 855 | 0.499415 | 0.442105 | 34 | 24.147058 | 17.841017 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.470588 | false | false | 4 |
e9179334ac74405654b6843da0d31085aa18b1d6 | 37,306,085,950,434 | 4e908d6e968e0c9bc9e70633dc6dda238cb69786 | /src/main/java/pl/codeleak/sbt/dingding/message/Message.java | 75a4ef64c785ca25bccd48fd14a6426388ef682c | [] | no_license | MasterLT/inventroy | https://github.com/MasterLT/inventroy | 71a246ca3b8fede8fbb76dd94cd5fb6d71396a69 | d84d135a4a0a0e86efed9986df71c0c1275ab763 | refs/heads/master | 2021-08-21T21:07:17.765000 | 2017-11-29T02:53:54 | 2017-11-29T02:54:01 | 112,418,195 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.codeleak.sbt.dingding.message;
public abstract class Message {
public abstract String type();
}
| UTF-8 | Java | 110 | java | Message.java | Java | [] | null | [] | package pl.codeleak.sbt.dingding.message;
public abstract class Message {
public abstract String type();
}
| 110 | 0.772727 | 0.772727 | 6 | 17.333334 | 17.326921 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 4 |
e6907531d4365a608b8efa669c5d7cd1076b3800 | 33,904,471,884,380 | d90dbeeb3abe36153dd52a3886d5808e2b46ad84 | /RuoYi/ruoyi-system/src/main/java/com/ruoyi/system/domain/RegisterType.java | 57ed5c0ab017deb9972d7d667495ba68ed7f5a60 | [] | no_license | GuiLinBoy/lingxishiyan | https://github.com/GuiLinBoy/lingxishiyan | b307ee23f953342b1f515f61e5edadf03015a7f9 | 9ca5b472cc5f7f300279a67cf4ad24612d832fcb | refs/heads/master | 2023-02-27T23:13:37.100000 | 2021-02-10T08:01:00 | 2021-02-10T08:01:00 | 327,538,300 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 登记类型对象 register_type
*
* @author ruoyi
* @date 2021-01-11
*/
public class RegisterType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 等级类型 */
private Long id;
/** */
@Excel(name = "")
private String registerName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setRegisterName(String registerName)
{
this.registerName = registerName;
}
public String getRegisterName()
{
return registerName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("registerName", getRegisterName())
.toString();
}
}
| UTF-8 | Java | 1,088 | java | RegisterType.java | Java | [
{
"context": "ntity;\n\n/**\n * 登记类型对象 register_type\n * \n * @author ruoyi\n * @date 2021-01-11\n */\npublic class RegisterType",
"end": 285,
"score": 0.9996387958526611,
"start": 280,
"tag": "USERNAME",
"value": "ruoyi"
}
] | null | [] | package com.ruoyi.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/**
* 登记类型对象 register_type
*
* @author ruoyi
* @date 2021-01-11
*/
public class RegisterType extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 等级类型 */
private Long id;
/** */
@Excel(name = "")
private String registerName;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setRegisterName(String registerName)
{
this.registerName = registerName;
}
public String getRegisterName()
{
return registerName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("registerName", getRegisterName())
.toString();
}
}
| 1,088 | 0.632023 | 0.621723 | 51 | 19.941177 | 19.080235 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.313726 | false | false | 4 |
20e108edf98b47a8396fac7ebaa74b5f008a90af | 38,431,367,372,374 | e0213b531e339105cffb1660720b63ec1f1a0d82 | /src/main/java/com/wd/erp/service/PubCommodityInfoService.java | cb6835a5aafd511316f349330ab52910f9a3a67d | [] | no_license | wjW901314/ERP | https://github.com/wjW901314/ERP | 56e721efe3293890c74371b790bcd7b48943bfa4 | fa56e3b0a29310bf529c696d31b04f5ad23a58e3 | refs/heads/master | 2022-10-15T10:00:28.173000 | 2020-06-12T07:38:24 | 2020-06-12T08:25:52 | 271,745,628 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wd.erp.service;
import com.wd.erp.model.PubCommodityInfo;
import com.wd.erp.model.ResultJson;
public interface PubCommodityInfoService {
ResultJson getAll(String keyWord);
ResultJson getById(String commodityCode);
ResultJson addCommodity(PubCommodityInfo record);
ResultJson modifyCommodity(PubCommodityInfo record);
ResultJson deleteCommodity(String commodityCode);
}
| UTF-8 | Java | 403 | java | PubCommodityInfoService.java | Java | [] | null | [] | package com.wd.erp.service;
import com.wd.erp.model.PubCommodityInfo;
import com.wd.erp.model.ResultJson;
public interface PubCommodityInfoService {
ResultJson getAll(String keyWord);
ResultJson getById(String commodityCode);
ResultJson addCommodity(PubCommodityInfo record);
ResultJson modifyCommodity(PubCommodityInfo record);
ResultJson deleteCommodity(String commodityCode);
}
| 403 | 0.80397 | 0.80397 | 12 | 32.583332 | 20.172003 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 4 |
d65fc0e198c34c14a4bb6302b136455cf7e20d20 | 37,220,186,610,361 | 9f203a41acf15fbe5c6fe8fa5110cb2d2aa1c003 | /backend-service/src/main/java/com/utbm/lo54/backend/controller/ClientController.java | 2557c817ef8b4506eaf50147d1f80527598600b9 | [] | no_license | nartj/cloud-courses | https://github.com/nartj/cloud-courses | b06b2c1732b4db0a6377d5f22f510456d1d7cd6b | a86020bf5f32bfe24c987b3e95dac5b5acf3bff3 | refs/heads/master | 2023-03-24T13:07:54.550000 | 2019-12-12T23:38:31 | 2019-12-12T23:38:31 | 348,832,979 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.utbm.lo54.backend.controller;
import com.utbm.lo54.common.domain.courses.Client;
import com.utbm.lo54.common.exception.ResourceNotFoundException;
import com.utbm.lo54.backend.service.ClientService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@RequestMapping("/api/clients")
public class ClientController {
private static final Logger LOG = LoggerFactory.getLogger(ClientController.class);
@Autowired
private ClientService clientService;
@GetMapping
public ResponseEntity<List<Client>> listClients() {
return ResponseEntity.ok(clientService.getClients());
}
@GetMapping("/{id}")
public ResponseEntity<Object> findClient(@PathVariable Long id) {
try {
return ResponseEntity.ok(clientService.getClient(id));
} catch (ResourceNotFoundException e) {
e.printStackTrace();
return ResponseEntity
.notFound().build();
}
}
@PostMapping("/course-session/{id}")
public ResponseEntity<Client> createClient(@RequestBody Client client, @PathVariable("id") Long id) throws ResourceNotFoundException {
LOG.info("Saving client {}", client);
clientService.save(client, id);
return ResponseEntity.ok(client);
}
@PutMapping("/{id}/course-session/{courseSessionId}")
public ResponseEntity<Client> updateClient(@RequestBody Client client, @PathVariable("id") Long id, @PathVariable("courseSessionId") Long courseSessionId) {
LOG.info("Updating client {}", client);
Client updatedClient = null;
try {
updatedClient = clientService.getClient(id);
updatedClient
.setAddress(client.getAddress())
.setEmail(client.getEmail())
.setFirstName(client.getFirstName())
.setLastName(client.getLastName());
clientService.save(updatedClient, courseSessionId);
return ResponseEntity.ok(updatedClient);
} catch (ResourceNotFoundException e) {
return (ResponseEntity<Client>) ResponseEntity.notFound();
}
}
@DeleteMapping("/{id}")
public ResponseEntity<Long> deleteClient(@PathVariable Long id) {
clientService.deleteClient(id);
return ResponseEntity.ok(id);
}
@GetMapping("/course-session/{id}/filling")
public ResponseEntity<Integer> findCourseSessionNbClients(@PathVariable Long id) {
Integer nbClients = clientService.findCourseSessionNbClients(id);
LOG.info("CourseSession {} has already {} clients.", id, nbClients);
return ResponseEntity.ok(nbClients);
}
}
| UTF-8 | Java | 2,922 | java | ClientController.java | Java | [] | null | [] | package com.utbm.lo54.backend.controller;
import com.utbm.lo54.common.domain.courses.Client;
import com.utbm.lo54.common.exception.ResourceNotFoundException;
import com.utbm.lo54.backend.service.ClientService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Controller
@RequestMapping("/api/clients")
public class ClientController {
private static final Logger LOG = LoggerFactory.getLogger(ClientController.class);
@Autowired
private ClientService clientService;
@GetMapping
public ResponseEntity<List<Client>> listClients() {
return ResponseEntity.ok(clientService.getClients());
}
@GetMapping("/{id}")
public ResponseEntity<Object> findClient(@PathVariable Long id) {
try {
return ResponseEntity.ok(clientService.getClient(id));
} catch (ResourceNotFoundException e) {
e.printStackTrace();
return ResponseEntity
.notFound().build();
}
}
@PostMapping("/course-session/{id}")
public ResponseEntity<Client> createClient(@RequestBody Client client, @PathVariable("id") Long id) throws ResourceNotFoundException {
LOG.info("Saving client {}", client);
clientService.save(client, id);
return ResponseEntity.ok(client);
}
@PutMapping("/{id}/course-session/{courseSessionId}")
public ResponseEntity<Client> updateClient(@RequestBody Client client, @PathVariable("id") Long id, @PathVariable("courseSessionId") Long courseSessionId) {
LOG.info("Updating client {}", client);
Client updatedClient = null;
try {
updatedClient = clientService.getClient(id);
updatedClient
.setAddress(client.getAddress())
.setEmail(client.getEmail())
.setFirstName(client.getFirstName())
.setLastName(client.getLastName());
clientService.save(updatedClient, courseSessionId);
return ResponseEntity.ok(updatedClient);
} catch (ResourceNotFoundException e) {
return (ResponseEntity<Client>) ResponseEntity.notFound();
}
}
@DeleteMapping("/{id}")
public ResponseEntity<Long> deleteClient(@PathVariable Long id) {
clientService.deleteClient(id);
return ResponseEntity.ok(id);
}
@GetMapping("/course-session/{id}/filling")
public ResponseEntity<Integer> findCourseSessionNbClients(@PathVariable Long id) {
Integer nbClients = clientService.findCourseSessionNbClients(id);
LOG.info("CourseSession {} has already {} clients.", id, nbClients);
return ResponseEntity.ok(nbClients);
}
}
| 2,922 | 0.68412 | 0.680698 | 77 | 36.948051 | 30.381084 | 160 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.532468 | false | false | 4 |
59c7f58bbea7ad2e1880ffd5c0db096c1dd3d668 | 32,049,046,025,564 | f953ba86cf877d7d371aa7d0c380c56adaacaf29 | /mojo-descriptor-maven-plugin/src/main/java/com/github/ohaddavid/maven/plugins/mojo/descriptor/MojoDescriptor.java | 9f7a3c0574daa63562906ca8ec2c495536c5483c | [
"Apache-2.0"
] | permissive | DataDrivenEngineer/maven-plugins | https://github.com/DataDrivenEngineer/maven-plugins | abcba308a8b7f9f640b657ac786c671434418e55 | d1c013a0c4adbe21ec7a57ac39bed8d5376a39a0 | refs/heads/master | 2022-01-26T15:32:37.783000 | 2019-05-23T05:53:56 | 2019-05-23T05:53:56 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.github.ohaddavid.maven.plugins.mojo.descriptor;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MojoDescriptor {
private String name;
private String call;
private String phase;
private String requiresDependencyResolution;
private String baseDescriptor;
private boolean isAbstract;
private boolean requiresProject;
private String description;
public boolean isRequiresProject() {
return requiresProject;
}
public void setRequiresProject(boolean requiresProject) {
this.requiresProject = requiresProject;
}
private Map<String,Parameter> paramters = new HashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCall() {
return call;
}
public void setCall(String call) {
this.call = call;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public String getRequiresDependencyResolution() {
return requiresDependencyResolution;
}
public void setRequiresDependencyResolution(String requiresDependencyResolution) {
this.requiresDependencyResolution = requiresDependencyResolution;
}
public String getBaseDescriptor() {
return baseDescriptor;
}
public void setBaseDescriptor(String baseDescriptor) {
this.baseDescriptor = baseDescriptor;
}
public boolean isAbstract() {
return isAbstract;
}
public void setAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void addParam(Parameter param){
if(!paramExist(param.getName())){
paramters.put(param.getName(), param);
}else{
throw new IllegalArgumentException("param " + param.getName() + " already exist in mojo " + getName());
}
}
public boolean paramExist(String paramName){
return paramters.containsKey(paramName);
}
public Collection<Parameter> params(){
return paramters.values();
}
public Set<String> paramKeys(){
return paramters.keySet();
}
}
| UTF-8 | Java | 2,234 | java | MojoDescriptor.java | Java | [
{
"context": "package com.github.ohaddavid.maven.plugins.mojo.descriptor;\r\n\r\nimport java.uti",
"end": 28,
"score": 0.9907302856445312,
"start": 19,
"tag": "USERNAME",
"value": "ohaddavid"
}
] | null | [] | package com.github.ohaddavid.maven.plugins.mojo.descriptor;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
public class MojoDescriptor {
private String name;
private String call;
private String phase;
private String requiresDependencyResolution;
private String baseDescriptor;
private boolean isAbstract;
private boolean requiresProject;
private String description;
public boolean isRequiresProject() {
return requiresProject;
}
public void setRequiresProject(boolean requiresProject) {
this.requiresProject = requiresProject;
}
private Map<String,Parameter> paramters = new HashMap<>();
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCall() {
return call;
}
public void setCall(String call) {
this.call = call;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public String getRequiresDependencyResolution() {
return requiresDependencyResolution;
}
public void setRequiresDependencyResolution(String requiresDependencyResolution) {
this.requiresDependencyResolution = requiresDependencyResolution;
}
public String getBaseDescriptor() {
return baseDescriptor;
}
public void setBaseDescriptor(String baseDescriptor) {
this.baseDescriptor = baseDescriptor;
}
public boolean isAbstract() {
return isAbstract;
}
public void setAbstract(boolean isAbstract) {
this.isAbstract = isAbstract;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public void addParam(Parameter param){
if(!paramExist(param.getName())){
paramters.put(param.getName(), param);
}else{
throw new IllegalArgumentException("param " + param.getName() + " already exist in mojo " + getName());
}
}
public boolean paramExist(String paramName){
return paramters.containsKey(paramName);
}
public Collection<Parameter> params(){
return paramters.values();
}
public Set<String> paramKeys(){
return paramters.keySet();
}
}
| 2,234 | 0.727395 | 0.727395 | 86 | 23.976744 | 20.80864 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.581395 | false | false | 4 |
63c69957ca5d46a676a73b10eb0b4d0b5153163b | 1,374,389,589,452 | b128bbf60cebee3c619984e78da9666c83a9f62b | /Lab8_MetroDeParis/src/it/polito/tdp/metrodeparis/db/MetroDAO.java | 7be7308bcef4efa71f4dc94226f15f25298a5d64 | [] | no_license | s200842/Lab8 | https://github.com/s200842/Lab8 | f5ec968bb5b5cad9863aa55d69c8e15069b13472 | 34b7ad4a85a553b8a39f5db1b22fcecb569898ef | refs/heads/master | 2021-01-21T08:24:16.513000 | 2016-05-23T14:35:01 | 2016-05-23T14:35:01 | 58,033,435 | 0 | 0 | null | true | 2016-05-04T07:53:26 | 2016-05-04T07:53:26 | 2016-04-30T10:06:12 | 2016-05-03T19:15:27 | 3,072 | 0 | 0 | 0 | null | null | null | package it.polito.tdp.metrodeparis.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import it.polito.tdp.metrodeparis.model.Connessione;
import it.polito.tdp.metrodeparis.model.Fermata;
import it.polito.tdp.metrodeparis.model.FermataSuLinea;
import it.polito.tdp.metrodeparis.model.Linea;
public class MetroDAO {
public List<Fermata> getAllFermate() {
final String sql = "SELECT id_fermata, nome, coordx, coordy FROM fermata ORDER BY nome ASC";
List<Fermata> fermate = new ArrayList<Fermata>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
Fermata f = new Fermata(rs.getInt("id_Fermata"), rs.getString("nome"), rs.getDouble("coordx"), rs.getDouble("coordy"));
fermate.add(f);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return fermate;
}
public List<Linea> getAllLinee() {
final String sql = "SELECT id_linea, nome, velocita, intervallo FROM linea ORDER BY nome ASC";
List<Linea> linee = new ArrayList<Linea>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
Linea f = new Linea(rs.getInt("id_linea"), rs.getString("nome"), rs.getDouble("velocita"),
rs.getDouble("intervallo"));
linee.add(f);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return linee;
}
public List<Connessione> getAllConnessione(List<Fermata> fermate, List<Linea> linee) {
final String sql = "select id_connessione, id_linea, id_stazP, id_stazA from connessione";
List<Connessione> connessioni = new ArrayList<Connessione>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
int idLinea = rs.getInt("id_linea");
int idStazP = rs.getInt("id_stazP");
int idStazA = rs.getInt("id_stazA");
Linea myLinea = linee.get(linee.indexOf(new Linea(idLinea)));
Fermata myStazP = fermate.get(fermate.indexOf(new Fermata(idStazP)));
Fermata myStazA = fermate.get(fermate.indexOf(new Fermata(idStazA)));
Connessione cnx = new Connessione(rs.getInt("id_connessione"), myLinea, myStazP, myStazA);
connessioni.add(cnx);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return connessioni;
}
public List<FermataSuLinea> getAllFermateSuLinea(List<Fermata> fermate, List<Linea> linee) {
final String sql = "SELECT DISTINCT fermata.id_fermata, linea.id_linea FROM fermata, linea, connessione WHERE (fermata.id_fermata = connessione.id_stazP OR fermata.id_fermata = connessione.id_stazA) AND connessione.id_linea = linea.id_linea";
List<FermataSuLinea> fermateSuLinea = new ArrayList<FermataSuLinea>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
int idLinea = rs.getInt("id_linea");
int idFermata = rs.getInt("id_fermata");
// Creo un nuovo oggetto, per trovarne uno esistente
Linea linea = linee.get(linee.indexOf(new Linea(idLinea)));
Fermata fermata = fermate.get(fermate.indexOf(new Fermata(idFermata)));
FermataSuLinea fermataSuLinea = new FermataSuLinea(fermata, linea);
fermata.addFermataSuLinea(fermataSuLinea);
fermateSuLinea.add(fermataSuLinea);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return fermateSuLinea;
}
}
| UTF-8 | Java | 4,278 | java | MetroDAO.java | Java | [] | null | [] | package it.polito.tdp.metrodeparis.db;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import it.polito.tdp.metrodeparis.model.Connessione;
import it.polito.tdp.metrodeparis.model.Fermata;
import it.polito.tdp.metrodeparis.model.FermataSuLinea;
import it.polito.tdp.metrodeparis.model.Linea;
public class MetroDAO {
public List<Fermata> getAllFermate() {
final String sql = "SELECT id_fermata, nome, coordx, coordy FROM fermata ORDER BY nome ASC";
List<Fermata> fermate = new ArrayList<Fermata>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
Fermata f = new Fermata(rs.getInt("id_Fermata"), rs.getString("nome"), rs.getDouble("coordx"), rs.getDouble("coordy"));
fermate.add(f);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return fermate;
}
public List<Linea> getAllLinee() {
final String sql = "SELECT id_linea, nome, velocita, intervallo FROM linea ORDER BY nome ASC";
List<Linea> linee = new ArrayList<Linea>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
Linea f = new Linea(rs.getInt("id_linea"), rs.getString("nome"), rs.getDouble("velocita"),
rs.getDouble("intervallo"));
linee.add(f);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return linee;
}
public List<Connessione> getAllConnessione(List<Fermata> fermate, List<Linea> linee) {
final String sql = "select id_connessione, id_linea, id_stazP, id_stazA from connessione";
List<Connessione> connessioni = new ArrayList<Connessione>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
int idLinea = rs.getInt("id_linea");
int idStazP = rs.getInt("id_stazP");
int idStazA = rs.getInt("id_stazA");
Linea myLinea = linee.get(linee.indexOf(new Linea(idLinea)));
Fermata myStazP = fermate.get(fermate.indexOf(new Fermata(idStazP)));
Fermata myStazA = fermate.get(fermate.indexOf(new Fermata(idStazA)));
Connessione cnx = new Connessione(rs.getInt("id_connessione"), myLinea, myStazP, myStazA);
connessioni.add(cnx);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return connessioni;
}
public List<FermataSuLinea> getAllFermateSuLinea(List<Fermata> fermate, List<Linea> linee) {
final String sql = "SELECT DISTINCT fermata.id_fermata, linea.id_linea FROM fermata, linea, connessione WHERE (fermata.id_fermata = connessione.id_stazP OR fermata.id_fermata = connessione.id_stazA) AND connessione.id_linea = linea.id_linea";
List<FermataSuLinea> fermateSuLinea = new ArrayList<FermataSuLinea>();
try {
Connection conn = DBConnect.getConnection();
PreparedStatement st = conn.prepareStatement(sql);
ResultSet rs = st.executeQuery();
while (rs.next()) {
int idLinea = rs.getInt("id_linea");
int idFermata = rs.getInt("id_fermata");
// Creo un nuovo oggetto, per trovarne uno esistente
Linea linea = linee.get(linee.indexOf(new Linea(idLinea)));
Fermata fermata = fermate.get(fermate.indexOf(new Fermata(idFermata)));
FermataSuLinea fermataSuLinea = new FermataSuLinea(fermata, linea);
fermata.addFermataSuLinea(fermataSuLinea);
fermateSuLinea.add(fermataSuLinea);
}
st.close();
conn.close();
} catch (SQLException e) {
e.printStackTrace();
throw new RuntimeException("Errore di connessione al Database.");
}
return fermateSuLinea;
}
}
| 4,278 | 0.681393 | 0.681393 | 143 | 27.916084 | 33.299763 | 244 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.503496 | false | false | 4 |
4fb83c1bd3f1882569c01318b8d52463fc202c0f | 1,374,389,589,059 | 299c52755ad27495fdfc865acb6d2d8dd111429c | /arc.fe.pagebrowser/src/main/java/de/uni_koeln/spinfo/arc/client/pagebrowser/view/widget/impl/TreePageDividerItemWidgetImpl.java | e8c09551fdea80ec0fff0fea8115ca869fc97fa8 | [] | no_license | spinfo/arc | https://github.com/spinfo/arc | 6e84ca18ffb40048201c72b3ae72e200474e74e3 | dd0173ff36673822e3d471fdab09ae59b2240947 | refs/heads/master | 2021-01-22T07:32:25.936000 | 2015-10-22T10:28:30 | 2015-10-22T10:28:30 | 18,134,880 | 0 | 3 | null | false | 2015-10-21T12:36:38 | 2014-03-26T10:46:47 | 2015-04-24T10:15:18 | 2015-10-21T12:36:37 | 8,393 | 0 | 2 | 1 | Java | null | null | package de.uni_koeln.spinfo.arc.client.pagebrowser.view.widget.impl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Widget;
import de.uni_koeln.spinfo.arc.client.pagebrowser.view.widget.TreePageDividerItemWidget;
public class TreePageDividerItemWidgetImpl extends Composite implements
TreePageDividerItemWidget {
private static TreePageDividerItemWidgetImplUiBinder uiBinder = GWT
.create(TreePageDividerItemWidgetImplUiBinder.class);
interface TreePageDividerItemWidgetImplUiBinder extends
UiBinder<Widget, TreePageDividerItemWidgetImpl> {
}
public TreePageDividerItemWidgetImpl() {
initWidget(uiBinder.createAndBindUi(this));
}
private int start;
private int end;
private final static String DELIMITER = " - ";
@UiField
FlexTable table;
public TreePageDividerItemWidgetImpl(int start, int end) {
initWidget(uiBinder.createAndBindUi(this));
setStart(start);
setEnd(end);
}
@Override
public TreePageDividerItemWidgetImpl setStart(int start) {
this.start = start;
table.setText(0, 1, String.valueOf(start));
table.setText(0, 2, DELIMITER);
return this;
}
@Override
public TreePageDividerItemWidgetImpl setEnd(int end) {
this.end = end;
table.setText(0, 3, String.valueOf(end));
return this;
}
@Override
public int getStart() {
return start;
}
@Override
public int getEnd() {
return end;
}
}
| UTF-8 | Java | 1,581 | java | TreePageDividerItemWidgetImpl.java | Java | [] | null | [] | package de.uni_koeln.spinfo.arc.client.pagebrowser.view.widget.impl;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlexTable;
import com.google.gwt.user.client.ui.Widget;
import de.uni_koeln.spinfo.arc.client.pagebrowser.view.widget.TreePageDividerItemWidget;
public class TreePageDividerItemWidgetImpl extends Composite implements
TreePageDividerItemWidget {
private static TreePageDividerItemWidgetImplUiBinder uiBinder = GWT
.create(TreePageDividerItemWidgetImplUiBinder.class);
interface TreePageDividerItemWidgetImplUiBinder extends
UiBinder<Widget, TreePageDividerItemWidgetImpl> {
}
public TreePageDividerItemWidgetImpl() {
initWidget(uiBinder.createAndBindUi(this));
}
private int start;
private int end;
private final static String DELIMITER = " - ";
@UiField
FlexTable table;
public TreePageDividerItemWidgetImpl(int start, int end) {
initWidget(uiBinder.createAndBindUi(this));
setStart(start);
setEnd(end);
}
@Override
public TreePageDividerItemWidgetImpl setStart(int start) {
this.start = start;
table.setText(0, 1, String.valueOf(start));
table.setText(0, 2, DELIMITER);
return this;
}
@Override
public TreePageDividerItemWidgetImpl setEnd(int end) {
this.end = end;
table.setText(0, 3, String.valueOf(end));
return this;
}
@Override
public int getStart() {
return start;
}
@Override
public int getEnd() {
return end;
}
}
| 1,581 | 0.776091 | 0.772296 | 63 | 24.095238 | 23.513397 | 88 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.460317 | false | false | 4 |
a7b45e09c9104ca2e44ee823b8f9f20114478697 | 1,374,389,590,632 | 977e38356b34fe728980dbc9b99c95020d983e80 | /src/main/java/Buider/Shopping.java | b476d1e3e4fcfec4d67c647ec30ee3b661489b92 | [] | no_license | cijaraadrian/APAW-ECP1-Adrian_Rodriguez | https://github.com/cijaraadrian/APAW-ECP1-Adrian_Rodriguez | 86064860db9f37ba01c61d46fc5d1e6590039496 | 4ed71a255a00e97a78dc451d79322c33de13e503 | refs/heads/master | 2021-07-08T17:18:36.789000 | 2017-10-08T09:22:21 | 2017-10-08T09:22:21 | 105,466,076 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package Buider;
public class Shopping {
private int id;
private int amount;
private double cost;
public Shopping(int id) {
this.id = id;
}
public void setId(int id) {
this.id = id;
}
public void setAmount(int amount) {
this.amount = amount;
}
public void setCost(double cost) {
this.cost = cost;
}
public int getId() {
return this.id;
}
public int getAmount() {
return this.amount;
}
public double getCost() {
return this.cost;
}
}
| UTF-8 | Java | 607 | java | Shopping.java | Java | [] | null | [] | package Buider;
public class Shopping {
private int id;
private int amount;
private double cost;
public Shopping(int id) {
this.id = id;
}
public void setId(int id) {
this.id = id;
}
public void setAmount(int amount) {
this.amount = amount;
}
public void setCost(double cost) {
this.cost = cost;
}
public int getId() {
return this.id;
}
public int getAmount() {
return this.amount;
}
public double getCost() {
return this.cost;
}
}
| 607 | 0.507414 | 0.507414 | 39 | 13.564102 | 12.829843 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.282051 | false | false | 4 |
65d89d0ff625632502db780de0e7f4a9de7c252f | 25,881,472,988,473 | 344ea1bad36271982e4ff2350a53e44b1f45bd26 | /PJ2/StackClass.java | 0d462304032c686b2a922720bc3b51d31510aaa0 | [
"MIT"
] | permissive | blai30/lisp-expr-evaluator-blai30 | https://github.com/blai30/lisp-expr-evaluator-blai30 | 710a0f2cf66c6f365441e0a0881251d828200610 | 35ed6f3ec418b1c787454d8c16b1ccd81db72136 | refs/heads/master | 2021-03-19T17:00:23.952000 | 2017-07-10T04:24:56 | 2017-07-10T04:24:56 | 101,462,798 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PJ2;
/**
*
* @author Brian Lai
*/
public class StackClass<T> implements StackInterface {
private T[] items;
private int numItems;
private int currentCap;
private static int INITIAL_CAP = 25;
public StackClass() {
this(INITIAL_CAP);
}
public StackClass(int cap) {
this.items = (T []) new Object[StackClass.INITIAL_CAP];
this.numItems = 0;
this.currentCap = cap;
}
@Override
public void push(Object newEntry) {
if (this.numItems == this.currentCap) {
this.expand();
}
this.items[this.numItems] = (T) newEntry;
this.numItems++;
}
private void expand() {
T[] expansion = (T[]) new Object[this.currentCap+25];
System.arraycopy(this.items, 0, expansion, 0, this.numItems);
this.items = expansion;
}
@Override
public T pop() {
if (this.empty()) {
return null;
}
T removing = this.items[this.numItems-1];
this.items[this.numItems-1] = null;
this.numItems--;
return removing;
}
@Override
public T peek() {
if (!this.empty()) {
return this.items[this.numItems-1];
}
return null;
}
@Override
public boolean empty() {
return this.numItems == 0;
}
// @Override
// public int search(Object entry) {
// for (int i = this.numItems-1; i > -1; i--) {
// if (this.items[i].equals(entry)) {
// return this.numItems - i;
// }
// }
// return -1;
// }
@Override
public void clear() {
while (!this.empty()) {
this.pop();
}
}
@Override
public int size() {
return this.numItems;
}
}
| UTF-8 | Java | 2,009 | java | StackClass.java | Java | [
{
"context": "in the editor.\n */\npackage PJ2;\n\n/**\n *\n * @author Brian Lai\n */\npublic class StackClass<T> implements StackIn",
"end": 226,
"score": 0.9998438358306885,
"start": 217,
"tag": "NAME",
"value": "Brian Lai"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package PJ2;
/**
*
* @author <NAME>
*/
public class StackClass<T> implements StackInterface {
private T[] items;
private int numItems;
private int currentCap;
private static int INITIAL_CAP = 25;
public StackClass() {
this(INITIAL_CAP);
}
public StackClass(int cap) {
this.items = (T []) new Object[StackClass.INITIAL_CAP];
this.numItems = 0;
this.currentCap = cap;
}
@Override
public void push(Object newEntry) {
if (this.numItems == this.currentCap) {
this.expand();
}
this.items[this.numItems] = (T) newEntry;
this.numItems++;
}
private void expand() {
T[] expansion = (T[]) new Object[this.currentCap+25];
System.arraycopy(this.items, 0, expansion, 0, this.numItems);
this.items = expansion;
}
@Override
public T pop() {
if (this.empty()) {
return null;
}
T removing = this.items[this.numItems-1];
this.items[this.numItems-1] = null;
this.numItems--;
return removing;
}
@Override
public T peek() {
if (!this.empty()) {
return this.items[this.numItems-1];
}
return null;
}
@Override
public boolean empty() {
return this.numItems == 0;
}
// @Override
// public int search(Object entry) {
// for (int i = this.numItems-1; i > -1; i--) {
// if (this.items[i].equals(entry)) {
// return this.numItems - i;
// }
// }
// return -1;
// }
@Override
public void clear() {
while (!this.empty()) {
this.pop();
}
}
@Override
public int size() {
return this.numItems;
}
}
| 2,006 | 0.530114 | 0.522648 | 90 | 21.322222 | 18.284071 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
ed0244a34e0e655a171130f08d9faaf89a7ced5d | 23,021,024,763,638 | 1b9fb0b96327d155b7d076daaae749000b9a12b0 | /cs109/CoreAPI/src/lang/StringTest.java | 7c6f76baf9021822d2dff58084dc9617c335d0af | [] | no_license | wangjiezhe/shiyanlou | https://github.com/wangjiezhe/shiyanlou | c929d7ae81ccec4d019e7eaee9cc33b42632c84e | 55f1665814c8a7ce34811fd61126811a9f91e057 | refs/heads/master | 2020-04-15T19:54:02.864000 | 2016-04-27T03:03:05 | 2016-05-10T12:11:49 | 39,290,812 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package lang;
public class StringTest {
public static void main(String[] args) {
String s0 = "abc";
String s1 = new String("abd");
System.out.println("Length of \"abc\": " + s0.length());
String s = new String("java");
String m = "Java";
System.out.println("Using equals() to compare java and Java, the result is " + s.equals(m));
System.out.println("Using equalsIgnoreCase() to compare java and Java, thre result is " + s.equalsIgnoreCase(m));
s0 = new String("Hello ");
s1 = "World" + "!";
String s2 = s0.concat(s1);
System.out.println(s2);
s = "Hello ";
s.concat("World!");
System.out.println(s);
s = s.concat("World!");
System.out.println(s);
StringBuffer b = new StringBuffer("I");
b.append(" java");
b.insert(1, " love");
String t = b.toString();
System.out.println(t);
}
}
| UTF-8 | Java | 875 | java | StringTest.java | Java | [] | null | [] | package lang;
public class StringTest {
public static void main(String[] args) {
String s0 = "abc";
String s1 = new String("abd");
System.out.println("Length of \"abc\": " + s0.length());
String s = new String("java");
String m = "Java";
System.out.println("Using equals() to compare java and Java, the result is " + s.equals(m));
System.out.println("Using equalsIgnoreCase() to compare java and Java, thre result is " + s.equalsIgnoreCase(m));
s0 = new String("Hello ");
s1 = "World" + "!";
String s2 = s0.concat(s1);
System.out.println(s2);
s = "Hello ";
s.concat("World!");
System.out.println(s);
s = s.concat("World!");
System.out.println(s);
StringBuffer b = new StringBuffer("I");
b.append(" java");
b.insert(1, " love");
String t = b.toString();
System.out.println(t);
}
}
| 875 | 0.595429 | 0.584 | 33 | 25.515152 | 25.372522 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.757576 | false | false | 4 |
88779448716371163893218e5f00ecc878d733ea | 12,549,894,470,299 | dd639588439ccdef6d80686bff47c309cfc7ce27 | /feibaoyue/newmyweb3/src/qieshitianxia/action/CartoonName.java | 02a54c7db3c0aed7c37376db73df8271bbd554ef | [] | no_license | q2425940/com | https://github.com/q2425940/com | 375ba901ebdfaba79b1ad91b5c4ab68895934eaf | dc518f7c7d0f997078eee456b1f815f2ed841534 | refs/heads/master | 2015-07-14T15:18:29 | 2015-03-19T04:05:02 | 2015-03-19T04:05:02 | 24,930,769 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package qieshitianxia.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import qieshitianxia.bean.CartoonConfigBean;
import qieshitianxia.bean.CartoonNameBean;
import qieshitianxia.bean.CartoonNumberBean;
import qieshitianxia.util.Db;
public class CartoonName extends HttpServlet {
Db db=new Db();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("id");
String type=request.getParameter("type");
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
String sqln="select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id+" order by time desc " ;
ResultSet rsn= db.query(sqln);
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
if("v".equals(type)){
request.getRequestDispatcher("vcartoon_name.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String method=request.getParameter("method");
if("addcartoon".equals(method)){
addcartoon(request,response);
}else if("delete".equals(method)){
delete(request,response);
}else if("query".equals(method)){
query(request,response);
}else if("updatecom".equals(method)){
updatecom(request,response);
}
}
public void addcartoon(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String cartoon_name=new String(request.getParameter("cartoon_name").getBytes("iso-8859-1"),"utf-8");
String note=new String(request.getParameter("note").getBytes("iso-8859-1"),"utf-8");
String company_id=request.getParameter("company_id");
Date date=new Date();
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time= myFormatter.format(date);
String sql="insert into cartoon_name (cartoon_name,note,time,company_id) values('"+cartoon_name+"','"+note+"','"+time+"','"+company_id+"')";
db.insert(sql);
delepage(request,response,company_id);
}
public void delete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String[] id=request.getParameterValues("id");
String companyid=request.getParameter("companyid");
String ids="";
for(int i=0;i<id.length;i++){
if(i==id.length-1){
ids+="'"+id[i]+"'";
}else{
ids+="'"+id[i]+"',";
}
}
db.update("delete from cartoon_name where id in("+ids+")");
db.update("delete from cartoon_number where cartoon_id in("+ids+")");
delepage(request,response,companyid);
}
public void delepage(HttpServletRequest request, HttpServletResponse response,String id)
throws ServletException, IOException {
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
String sqln="select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id+" order by time desc " ;
ResultSet rsn= db.query(sqln);
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);
}
public void query(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("cartoonconfid");
String cartoonname=new String(request.getParameter("cartoonname").getBytes("iso-8859-1"),"utf-8");
String ftime=request.getParameter("ftime");
String ltime=request.getParameter("ltime");
String type=request.getParameter("type");
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
StringBuffer sbf=new StringBuffer();
sbf.append("select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id);
if(cartoonname!=""&&cartoonname!=null){
sbf.append(" and cartoon_name like '%"+cartoonname+"%' ");
}
sbf.append(" order by time desc ");
ResultSet rsn= db.query(sbf.toString());
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
if(ftime!=""&&ftime!=null){
sb.append(" and time>='"+ftime+"'");
}
if(ltime!=""&<ime!=null){
sb.append(" and time<='"+ltime+"'");
}
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("cartoonname", cartoonname);
request.setAttribute("ftime", ftime);
request.setAttribute("ltime", ltime);
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
if("v".equals(type)){
request.getRequestDispatcher("vcartoon_name.jsp").forward(request, response);
}else{
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);}
}
public void updatecom(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String companyid=request.getParameter("companyid");
String companyname=new String(request.getParameter("companyname").getBytes("iso-8859-1"),"utf-8");
db.update("update cartoon_company set company_name='"+companyname+"' where id="+companyid);
delepage(request,response,companyid);
}
}
| UTF-8 | Java | 11,906 | java | CartoonName.java | Java | [] | null | [] | package qieshitianxia.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import qieshitianxia.bean.CartoonConfigBean;
import qieshitianxia.bean.CartoonNameBean;
import qieshitianxia.bean.CartoonNumberBean;
import qieshitianxia.util.Db;
public class CartoonName extends HttpServlet {
Db db=new Db();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("id");
String type=request.getParameter("type");
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
String sqln="select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id+" order by time desc " ;
ResultSet rsn= db.query(sqln);
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
if("v".equals(type)){
request.getRequestDispatcher("vcartoon_name.jsp").forward(request, response);
}
else{
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String method=request.getParameter("method");
if("addcartoon".equals(method)){
addcartoon(request,response);
}else if("delete".equals(method)){
delete(request,response);
}else if("query".equals(method)){
query(request,response);
}else if("updatecom".equals(method)){
updatecom(request,response);
}
}
public void addcartoon(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String cartoon_name=new String(request.getParameter("cartoon_name").getBytes("iso-8859-1"),"utf-8");
String note=new String(request.getParameter("note").getBytes("iso-8859-1"),"utf-8");
String company_id=request.getParameter("company_id");
Date date=new Date();
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time= myFormatter.format(date);
String sql="insert into cartoon_name (cartoon_name,note,time,company_id) values('"+cartoon_name+"','"+note+"','"+time+"','"+company_id+"')";
db.insert(sql);
delepage(request,response,company_id);
}
public void delete(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String[] id=request.getParameterValues("id");
String companyid=request.getParameter("companyid");
String ids="";
for(int i=0;i<id.length;i++){
if(i==id.length-1){
ids+="'"+id[i]+"'";
}else{
ids+="'"+id[i]+"',";
}
}
db.update("delete from cartoon_name where id in("+ids+")");
db.update("delete from cartoon_number where cartoon_id in("+ids+")");
delepage(request,response,companyid);
}
public void delepage(HttpServletRequest request, HttpServletResponse response,String id)
throws ServletException, IOException {
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
String sqln="select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id+" order by time desc " ;
ResultSet rsn= db.query(sqln);
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);
}
public void query(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String id=request.getParameter("cartoonconfid");
String cartoonname=new String(request.getParameter("cartoonname").getBytes("iso-8859-1"),"utf-8");
String ftime=request.getParameter("ftime");
String ltime=request.getParameter("ltime");
String type=request.getParameter("type");
CartoonConfigBean ccfb=null;
String sql="select id,company_name,company_code,time,note from cartoon_company where id="+id;
ResultSet rs= db.query(sql);
if(rs!=null){
try {
while(rs.next()){
ccfb=new CartoonConfigBean();
ccfb.setId(rs.getInt(1));
ccfb.setCompany_name(rs.getString(2));
ccfb.setCompany_code(rs.getString(3));
ccfb.setTime(rs.getString(4));
ccfb.setNote(rs.getString(5));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
List<CartoonNameBean> list =new ArrayList<CartoonNameBean>();
StringBuffer sbf=new StringBuffer();
sbf.append("select id,cartoon_name,cartoon_code,time,note,company_id from cartoon_name where company_id="+id);
if(cartoonname!=""&&cartoonname!=null){
sbf.append(" and cartoon_name like '%"+cartoonname+"%' ");
}
sbf.append(" order by time desc ");
ResultSet rsn= db.query(sbf.toString());
int count=0;
if(rsn!=null){
try {
while(rsn.next()){
count+=1;
CartoonNameBean cn=new CartoonNameBean();
cn.setId(rsn.getInt(1));
cn.setCartoon_name(rsn.getString(2));
cn.setCartoon_code(rsn.getString(3));
cn.setTime(rsn.getString(4));
cn.setNote(rsn.getString(5));
cn.setCompany_id(rsn.getString(6));
list.add(cn);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
if(list!=null&&list.size()>0){
for(int i=0;i<list.size();i++){
CartoonNameBean cn=list.get(i);
StringBuffer sb=new StringBuffer();
sb.append("select * from visited where cartoon_id="+cn.getId());
if(ftime!=""&&ftime!=null){
sb.append(" and time>='"+ftime+"'");
}
if(ltime!=""&<ime!=null){
sb.append(" and time<='"+ltime+"'");
}
ResultSet rsca= db.query(sb.toString());
int countca=0;
if(rsca!=null){
try {
while(rsca.next()){
countca++;
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
db.closedb();
} }
cn.setVisitornum(countca);
}
}
request.setAttribute("cartoonname", cartoonname);
request.setAttribute("ftime", ftime);
request.setAttribute("ltime", ltime);
request.setAttribute("count", String.valueOf(count));
request.setAttribute("list", list);
request.setAttribute("ccfb", ccfb);
if("v".equals(type)){
request.getRequestDispatcher("vcartoon_name.jsp").forward(request, response);
}else{
request.getRequestDispatcher("cartoon_name.jsp").forward(request, response);}
}
public void updatecom(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String companyid=request.getParameter("companyid");
String companyname=new String(request.getParameter("companyname").getBytes("iso-8859-1"),"utf-8");
db.update("update cartoon_company set company_name='"+companyname+"' where id="+companyid);
delepage(request,response,companyid);
}
}
| 11,906 | 0.593986 | 0.587771 | 333 | 34.753754 | 25.385307 | 153 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.801802 | false | false | 4 |
0d4ada41c446c87c79180d581a7b0e5062b55fd3 | 30,073,361,070,759 | fd14bea493c94e5f1cc5f47ee1ac4868967a0355 | /pizzeria-parent/pizzeria-dao/src/main/java/fr/pizzeria/exception/NotImplementException.java | 1e5fbfde571abebf77a5c58e8c77527a676a67e0 | [
"MIT"
] | permissive | lemattrea/formation-dta | https://github.com/lemattrea/formation-dta | ac65e4e4173cb02da1eaea9dc8132510e4008e36 | c7db0fb2cbd135f75fe44606f14689aa26511370 | refs/heads/master | 2021-01-01T04:27:22.154000 | 2016-06-03T15:11:30 | 2016-06-03T15:11:30 | 57,122,371 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fr.pizzeria.exception;
public class NotImplementException extends DaoException {
/**
*
*/
public NotImplementException() {
super();
}
/**
* @param message
* @param cause
* @param enableSuppression
* @param writableStackTrace
*/
public NotImplementException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
/**
* @param message
* @param cause
*/
public NotImplementException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
*/
public NotImplementException(String message) {
super(message);
}
/**
* @param cause
*/
public NotImplementException(Throwable cause) {
super(cause);
}
}
| UTF-8 | Java | 829 | java | NotImplementException.java | Java | [] | null | [] | package fr.pizzeria.exception;
public class NotImplementException extends DaoException {
/**
*
*/
public NotImplementException() {
super();
}
/**
* @param message
* @param cause
* @param enableSuppression
* @param writableStackTrace
*/
public NotImplementException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
/**
* @param message
* @param cause
*/
public NotImplementException(String message, Throwable cause) {
super(message, cause);
}
/**
* @param message
*/
public NotImplementException(String message) {
super(message);
}
/**
* @param cause
*/
public NotImplementException(Throwable cause) {
super(cause);
}
}
| 829 | 0.662244 | 0.662244 | 44 | 16.84091 | 23.476238 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.204545 | false | false | 4 |
7d74d43c2d1167d6b6bb1cc92b378dee938283fc | 16,372,415,339,469 | a3bf54a47accc969ef1645e3d287a06f8c5ff311 | /src/main/java/leetcode/LeetCode_0087_ScrambleString.java | c8e03806e25b4b356de5c562a99b259015e960cb | [] | no_license | sendwe/algorithm | https://github.com/sendwe/algorithm | 6a0e18418b8b26d9cb52e6df5cc2798e7f17341c | 31b2560d1e18ed6e87752c9fe75a294c3ced914d | refs/heads/master | 2023-08-30T00:13:16.535000 | 2021-11-18T02:58:51 | 2021-11-18T02:58:51 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*We can scramble a string s to get a string t using the following algorithm:
If the length of the string is 1, stop.
If the length of the string is > 1, do the following:
Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
Apply step 1 recursively on each of the two substrings x and y.
Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1, otherwise, return false.
Example 1:
Input: s1 = "great", s2 = "rgeat"
Output: true
Explanation: One possible scenario applied on s1 is:
"great" --> "gr/eat" // divide at random index.
"gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order.
"gr/eat" --> "g/r / e/at" // apply the same algorithm recursively on both substrings. divide at ranom index each of them.
"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substring and to keep the second substring in the same order.
"r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t".
"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substrings in the same order.
The algorithm stops now and the result string is "rgeat" which is s2.
As there is one possible scenario that led s1 to be scrambled to s2, we return true.
Example 2:
Input: s1 = "abcde", s2 = "caebd"
Output: false
Example 3:
Input: s1 = "a", s2 = "a"
Output: true
Constraints:
s1.length == s2.length
1 <= s1.length <= 30
s1 and s2 consist of lower-case English letters.*/
package leetcode;
public class LeetCode_0087_ScrambleString {
public static boolean isScramble(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
int N = str1.length;
boolean[][][] dp = new boolean[N][N][N + 1];
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dp[i][j][1] = (str1[i] == str2[j]);
}
}
for (int k = 2; k < N + 1; k++) {
for (int L1 = 0; L1 <= N - k; L1++) {
for (int L2 = 0; L2 <= N - k; L2++) {
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = dp[L1][L2][cutPoint] && dp[L1 + cutPoint][L2 + cutPoint][k - cutPoint];
boolean case2 = dp[L1 + cutPoint][L2][k - cutPoint] && dp[L1][L2 + k - cutPoint][cutPoint];
if (case1 || case2) {
dp[L1][L2][k] = true;
break;
}
}
}
}
}
return dp[0][0][N];
}
// 记忆化搜索
public static boolean isScramble2(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
int N = str1.length;
// 0表示没算过
// -1表示false
// 1表示true
int[][][] dp = new int[N][N][N + 1];
return f2(str1, str2, 0, 0, N, dp);
}
// str1中,L1往后(包括L1)一共k个字符串 以及 str2中,L2往后(包括L2)一共k个字符串 是否互为扰动串
private static boolean f2(char[] str1, char[] str2, int L1, int L2, int k, int[][][] dp) {
if (dp[L1][L2][k] != 0) {
return dp[L1][L2][k] == 1;
}
if (k == 1) {
// base case, 针对这样的情况,只需要判断str1[L1], str2[L2]
dp[L1][L2][k] = (str1[L1] == str2[L2] ? 1 : -1);
return dp[L1][L2][k] == 1;
}
// 枚举第一刀的位置
boolean ans = false;
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = f2(str1, str2, L1, L2, cutPoint, dp) && f2(str1, str2, L1 + cutPoint, L2 + cutPoint, k - cutPoint, dp);
boolean case2 = f2(str1, str2, L1 + cutPoint, L2, k - cutPoint, dp) && f2(str1, str2, L1, L2 + k - cutPoint, cutPoint, dp);
if (case1 || case2) {
ans = true;
break;
}
}
dp[L1][L2][k] = ans ? 1 : -1;
return ans;
}
// 暴力递归,在Leetcode上超时
public static boolean isScramble3(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
return f(str1, str2, 0, 0, str2.length);
}
// str1中,L1往后(包括L1)一共k个字符串 以及 str2中,L2往后(包括L2)一共k个字符串 是否互为扰动串
private static boolean f(char[] str1, char[] str2, int L1, int L2, int k) {
if (k == 1) {
// base case, 针对这样的情况,只需要判断str1[L1], str2[L2]
return str1[L1] == str2[L2];
}
// 枚举第一刀的位置
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = f(str1, str2, L1, L2, cutPoint) && f(str1, str2, L1 + cutPoint, L2 + cutPoint, k - cutPoint);
boolean case2 = f(str1, str2, L1 + cutPoint, L2, k - cutPoint) && f(str1, str2, L1, L2 + k - cutPoint, cutPoint);
if (case1 || case2) {
return true;
}
}
return false;
}
private static boolean isValid(char[] str1, char[] str2) {
if (str1.length != str2.length) {
return false;
}
int[] map = new int[26];
for (char c : str1) {
map[c - 'a']++;
}
for (char c : str2) {
map[c - 'a']--;
if (map[c - 'a'] < 0) {
return false;
}
}
return true;
}
}
| UTF-8 | Java | 6,833 | java | LeetCode_0087_ScrambleString.java | Java | [] | null | [] | /*We can scramble a string s to get a string t using the following algorithm:
If the length of the string is 1, stop.
If the length of the string is > 1, do the following:
Split the string into two non-empty substrings at a random index, i.e., if the string is s, divide it to x and y where s = x + y.
Randomly decide to swap the two substrings or to keep them in the same order. i.e., after this step, s may become s = x + y or s = y + x.
Apply step 1 recursively on each of the two substrings x and y.
Given two strings s1 and s2 of the same length, return true if s2 is a scrambled string of s1, otherwise, return false.
Example 1:
Input: s1 = "great", s2 = "rgeat"
Output: true
Explanation: One possible scenario applied on s1 is:
"great" --> "gr/eat" // divide at random index.
"gr/eat" --> "gr/eat" // random decision is not to swap the two substrings and keep them in order.
"gr/eat" --> "g/r / e/at" // apply the same algorithm recursively on both substrings. divide at ranom index each of them.
"g/r / e/at" --> "r/g / e/at" // random decision was to swap the first substring and to keep the second substring in the same order.
"r/g / e/at" --> "r/g / e/ a/t" // again apply the algorithm recursively, divide "at" to "a/t".
"r/g / e/ a/t" --> "r/g / e/ a/t" // random decision is to keep both substrings in the same order.
The algorithm stops now and the result string is "rgeat" which is s2.
As there is one possible scenario that led s1 to be scrambled to s2, we return true.
Example 2:
Input: s1 = "abcde", s2 = "caebd"
Output: false
Example 3:
Input: s1 = "a", s2 = "a"
Output: true
Constraints:
s1.length == s2.length
1 <= s1.length <= 30
s1 and s2 consist of lower-case English letters.*/
package leetcode;
public class LeetCode_0087_ScrambleString {
public static boolean isScramble(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
int N = str1.length;
boolean[][][] dp = new boolean[N][N][N + 1];
for (int i = 0; i < N; i++) {
for (int j = 0; j < N; j++) {
dp[i][j][1] = (str1[i] == str2[j]);
}
}
for (int k = 2; k < N + 1; k++) {
for (int L1 = 0; L1 <= N - k; L1++) {
for (int L2 = 0; L2 <= N - k; L2++) {
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = dp[L1][L2][cutPoint] && dp[L1 + cutPoint][L2 + cutPoint][k - cutPoint];
boolean case2 = dp[L1 + cutPoint][L2][k - cutPoint] && dp[L1][L2 + k - cutPoint][cutPoint];
if (case1 || case2) {
dp[L1][L2][k] = true;
break;
}
}
}
}
}
return dp[0][0][N];
}
// 记忆化搜索
public static boolean isScramble2(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
int N = str1.length;
// 0表示没算过
// -1表示false
// 1表示true
int[][][] dp = new int[N][N][N + 1];
return f2(str1, str2, 0, 0, N, dp);
}
// str1中,L1往后(包括L1)一共k个字符串 以及 str2中,L2往后(包括L2)一共k个字符串 是否互为扰动串
private static boolean f2(char[] str1, char[] str2, int L1, int L2, int k, int[][][] dp) {
if (dp[L1][L2][k] != 0) {
return dp[L1][L2][k] == 1;
}
if (k == 1) {
// base case, 针对这样的情况,只需要判断str1[L1], str2[L2]
dp[L1][L2][k] = (str1[L1] == str2[L2] ? 1 : -1);
return dp[L1][L2][k] == 1;
}
// 枚举第一刀的位置
boolean ans = false;
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = f2(str1, str2, L1, L2, cutPoint, dp) && f2(str1, str2, L1 + cutPoint, L2 + cutPoint, k - cutPoint, dp);
boolean case2 = f2(str1, str2, L1 + cutPoint, L2, k - cutPoint, dp) && f2(str1, str2, L1, L2 + k - cutPoint, cutPoint, dp);
if (case1 || case2) {
ans = true;
break;
}
}
dp[L1][L2][k] = ans ? 1 : -1;
return ans;
}
// 暴力递归,在Leetcode上超时
public static boolean isScramble3(String s1, String s2) {
if (s1 == null && s2 == null) {
return true;
}
if (s1 == null) {
return false;
}
if (s2 == null) {
return false;
}
if (s1.equals(s2)) {
return true;
}
char[] str1 = s1.toCharArray();
char[] str2 = s2.toCharArray();
if (!isValid(str1, str2)) {
return false;
}
return f(str1, str2, 0, 0, str2.length);
}
// str1中,L1往后(包括L1)一共k个字符串 以及 str2中,L2往后(包括L2)一共k个字符串 是否互为扰动串
private static boolean f(char[] str1, char[] str2, int L1, int L2, int k) {
if (k == 1) {
// base case, 针对这样的情况,只需要判断str1[L1], str2[L2]
return str1[L1] == str2[L2];
}
// 枚举第一刀的位置
for (int cutPoint = 1; cutPoint < k; cutPoint++) {
boolean case1 = f(str1, str2, L1, L2, cutPoint) && f(str1, str2, L1 + cutPoint, L2 + cutPoint, k - cutPoint);
boolean case2 = f(str1, str2, L1 + cutPoint, L2, k - cutPoint) && f(str1, str2, L1, L2 + k - cutPoint, cutPoint);
if (case1 || case2) {
return true;
}
}
return false;
}
private static boolean isValid(char[] str1, char[] str2) {
if (str1.length != str2.length) {
return false;
}
int[] map = new int[26];
for (char c : str1) {
map[c - 'a']++;
}
for (char c : str2) {
map[c - 'a']--;
if (map[c - 'a'] < 0) {
return false;
}
}
return true;
}
}
| 6,833 | 0.495039 | 0.459014 | 194 | 32.76804 | 30.835661 | 137 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.798969 | false | false | 4 |
41e1c29b8bbc7253069efb65cbb2a585e71e8728 | 10,084,583,269,910 | 0edba52f299002e8428cda680e055d72808b500a | /app/src/main/java/com/xszj/mba/utils/FilesUtils.java | 68e146c5d43418d593702522c8ca618155339964 | [] | no_license | ybxcarrycode/byh_mba | https://github.com/ybxcarrycode/byh_mba | a9de7da0e0823df55c230d8cc543c246f8afa433 | ffd2443c9665aa7d3f3881d794ee8bca24e44b66 | refs/heads/master | 2020-08-16T07:42:13.862000 | 2019-10-16T06:40:25 | 2019-10-16T06:40:25 | 215,475,120 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xszj.mba.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Created by Administrator on 2016/11/28.
*/
public class FilesUtils {
private static final File mParentPath = Environment.getExternalStorageDirectory();
private static String mStoragePath = "";
private static final String DST_FOLDER_NAME = "byh";
/**
* @return
*/
private static String initPath() {
if (mStoragePath.equals("")) {
mStoragePath = mParentPath.getAbsolutePath() + "/" + DST_FOLDER_NAME;
}
return mStoragePath;
}
/**
* 以最省内存的方式读取本地资源的图片
*
* @param context
* @param resId
* @return
*/
public static Bitmap readBitMap(Context context, int resId) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
// 获取资源图片
InputStream is = context.getResources().openRawResource(resId);
return BitmapFactory.decodeStream(is, null, opt);
}
//图片压缩机保存
//压缩图片尺寸
public static Bitmap compressBySize(String path, int w, int h) {
try {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
opts.inSampleSize = 16;
// 这里是整个方法的关键,inJustDecodeBounds设为true时将不为图片分配内存�?
BitmapFactory.decodeFile(path, opts);
int srcWidth = opts.outWidth;// 获取图片的原始宽�?
int srcHeight = opts.outHeight;// 获取图片原始高度
int destWidth = 0;
int destHeight = 0;
// 缩放的比�?
double ratio = 0.0;
if (srcWidth < w || srcHeight < h) {
ratio = 0.0;
destWidth = srcWidth;
destHeight = srcHeight;
} else if (srcWidth > srcHeight) {// 按比例计算缩放后的图片大小,maxLength是长或宽允许的最大长�?
ratio = (double) srcWidth / w;
destWidth = w;
destHeight = (int) (srcHeight / ratio);
} else {
ratio = (double) srcHeight / h;
destHeight = h;
destWidth = (int) (srcWidth / ratio);
}
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 缩放的比例,缩放是很难按准备的比例进行缩放的,目前我只发现只能�?�过inSampleSize来进行缩放,其�?�表明缩放的倍数,SDK中建议其值是2的指数�??
// newOpts.inSampleSize = (int) ratio;
// int minSampleSize =2;
//newOpts.inSampleSize= minSampleSize >(int) ratio?minSampleSize :(int)ratio;
double maxSize = 0.4 * 512 * 512;//最大一兆
int bmpsize;
bmpsize = srcWidth * srcHeight * 32;
if (bmpsize > maxSize) {
newOpts.inSampleSize = bmpsize / (int) maxSize;
} else
newOpts.inSampleSize = 1;
newOpts.inJustDecodeBounds = false; // inJustDecodeBounds设为false表示把图片读进内存中
newOpts.inPreferredConfig = Bitmap.Config.ARGB_8888;
// 设置大小,这个一般是不准确的,是以inSampleSize的为准,但是如果不设置却不能缩放
newOpts.outHeight = destHeight;
newOpts.outWidth = destWidth;
// 获取缩放后图�?
return BitmapFactory.decodeFile(path, newOpts);
} catch (Exception e) {
// TODO: handle exception
return null;
}
}
//保存图片
public static String saveBitmap(Bitmap bm, int position) {
String filePath = initPath();
String path = filePath + "/comment" + position + ".jpg";
try {
File file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
FileOutputStream fos = new FileOutputStream(file+"/comment" + position + ".jpg");
bm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
return path;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static void deleFile(List<String> list){
for (String str: list){
File file = new File (str);
if (file.exists()) {
Log.e("ddddd","wwwww");
file.delete();
Log.e("ddddd","wwwww111");
}
}
}
}
| UTF-8 | Java | 5,189 | java | FilesUtils.java | Java | [
{
"context": "tStream;\nimport java.util.List;\n\n/**\n * Created by Administrator on 2016/11/28.\n */\npublic class FilesUtils {\n ",
"end": 391,
"score": 0.9287562966346741,
"start": 378,
"tag": "USERNAME",
"value": "Administrator"
}
] | null | [] | package com.xszj.mba.utils;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Environment;
import android.util.Log;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
/**
* Created by Administrator on 2016/11/28.
*/
public class FilesUtils {
private static final File mParentPath = Environment.getExternalStorageDirectory();
private static String mStoragePath = "";
private static final String DST_FOLDER_NAME = "byh";
/**
* @return
*/
private static String initPath() {
if (mStoragePath.equals("")) {
mStoragePath = mParentPath.getAbsolutePath() + "/" + DST_FOLDER_NAME;
}
return mStoragePath;
}
/**
* 以最省内存的方式读取本地资源的图片
*
* @param context
* @param resId
* @return
*/
public static Bitmap readBitMap(Context context, int resId) {
BitmapFactory.Options opt = new BitmapFactory.Options();
opt.inPreferredConfig = Bitmap.Config.RGB_565;
opt.inPurgeable = true;
opt.inInputShareable = true;
// 获取资源图片
InputStream is = context.getResources().openRawResource(resId);
return BitmapFactory.decodeStream(is, null, opt);
}
//图片压缩机保存
//压缩图片尺寸
public static Bitmap compressBySize(String path, int w, int h) {
try {
BitmapFactory.Options opts = new BitmapFactory.Options();
opts.inJustDecodeBounds = true;
opts.inSampleSize = 16;
// 这里是整个方法的关键,inJustDecodeBounds设为true时将不为图片分配内存�?
BitmapFactory.decodeFile(path, opts);
int srcWidth = opts.outWidth;// 获取图片的原始宽�?
int srcHeight = opts.outHeight;// 获取图片原始高度
int destWidth = 0;
int destHeight = 0;
// 缩放的比�?
double ratio = 0.0;
if (srcWidth < w || srcHeight < h) {
ratio = 0.0;
destWidth = srcWidth;
destHeight = srcHeight;
} else if (srcWidth > srcHeight) {// 按比例计算缩放后的图片大小,maxLength是长或宽允许的最大长�?
ratio = (double) srcWidth / w;
destWidth = w;
destHeight = (int) (srcHeight / ratio);
} else {
ratio = (double) srcHeight / h;
destHeight = h;
destWidth = (int) (srcWidth / ratio);
}
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 缩放的比例,缩放是很难按准备的比例进行缩放的,目前我只发现只能�?�过inSampleSize来进行缩放,其�?�表明缩放的倍数,SDK中建议其值是2的指数�??
// newOpts.inSampleSize = (int) ratio;
// int minSampleSize =2;
//newOpts.inSampleSize= minSampleSize >(int) ratio?minSampleSize :(int)ratio;
double maxSize = 0.4 * 512 * 512;//最大一兆
int bmpsize;
bmpsize = srcWidth * srcHeight * 32;
if (bmpsize > maxSize) {
newOpts.inSampleSize = bmpsize / (int) maxSize;
} else
newOpts.inSampleSize = 1;
newOpts.inJustDecodeBounds = false; // inJustDecodeBounds设为false表示把图片读进内存中
newOpts.inPreferredConfig = Bitmap.Config.ARGB_8888;
// 设置大小,这个一般是不准确的,是以inSampleSize的为准,但是如果不设置却不能缩放
newOpts.outHeight = destHeight;
newOpts.outWidth = destWidth;
// 获取缩放后图�?
return BitmapFactory.decodeFile(path, newOpts);
} catch (Exception e) {
// TODO: handle exception
return null;
}
}
//保存图片
public static String saveBitmap(Bitmap bm, int position) {
String filePath = initPath();
String path = filePath + "/comment" + position + ".jpg";
try {
File file = new File(filePath);
if (!file.exists()) {
file.mkdir();
}
FileOutputStream fos = new FileOutputStream(file+"/comment" + position + ".jpg");
bm.compress(Bitmap.CompressFormat.JPEG, 100, fos);
fos.flush();
fos.close();
return path;
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
public static void deleFile(List<String> list){
for (String str: list){
File file = new File (str);
if (file.exists()) {
Log.e("ddddd","wwwww");
file.delete();
Log.e("ddddd","wwwww111");
}
}
}
}
| 5,189 | 0.562645 | 0.553771 | 147 | 31.197279 | 23.466763 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.591837 | false | false | 4 |
8b4f193cdccd60e4d32961f0466818136bd04a58 | 11,510,512,404,570 | 891c4599c440429fa98d4fecb2faff052f31db52 | /com.yz.edu.bms/src/main/java/com/yz/service/stdService/StudentXuexinService.java | b1b1024d0e70d2f9907129f075cde5e358334af3 | [] | no_license | zhuliye0927/yz-server | https://github.com/zhuliye0927/yz-server | daa0922dd7fa7ab9affbe6070fd7228337fbb7aa | 23014f0b87f53bb2c14711197041c284523bbd05 | refs/heads/master | 2018-12-08T04:30:48.328000 | 2018-11-14T06:00:05 | 2018-11-14T06:00:05 | 149,573,402 | 1 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.yz.service.stdService;
import com.yz.edu.paging.bean.Page;
import com.yz.edu.paging.common.PageHelper;
import com.yz.core.security.manager.SessionUtil;
import com.yz.core.util.DictExchangeUtil;
import com.yz.dao.stdService.StudentGraduateDataMapper;
import com.yz.dao.stdService.StudentXuexinMapper;
import com.yz.dao.system.SysCityMapper;
import com.yz.dao.system.SysDistrictMapper;
import com.yz.dao.system.SysProvinceMapper;
import com.yz.exception.BusinessException;
import com.yz.model.admin.BaseUser;
import com.yz.model.common.IPageInfo;
import com.yz.model.stdService.StudentGraduateDataInfo;
import com.yz.model.stdService.StudentGraduateDataQuery;
import com.yz.model.stdService.StudentXuexinInfo;
import com.yz.model.stdService.StudentXuexinQuery;
import com.yz.model.system.SysCity;
import com.yz.model.system.SysDistrict;
import com.yz.model.system.SysProvince;
import com.yz.util.ExcelUtil;
import com.yz.util.ExcelUtil.IExcelConfig;
import com.yz.util.StringUtil;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
/**
* 学员服务---学信网信息核对
*
* @author jyt
*/
@Service
@Transactional
public class StudentXuexinService {
private static Logger log = LoggerFactory.getLogger(StudentXuexinService.class);
@Autowired
private StudentXuexinMapper studentXuexinMapper;
public Object findAllXuexinList(StudentXuexinQuery query) {
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
return new IPageInfo<>((Page) list);
}
public StudentXuexinInfo getXuexinInfoById(String xuexinId) {
StudentXuexinQuery query = new StudentXuexinQuery();
query.setXuexinId(xuexinId);
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@SuppressWarnings("unchecked")
public void importStuGraduateDataInfo(MultipartFile stuXuexinImport) {
//对导入工具进行字段填充
IExcelConfig<StudentXuexinInfo> testExcelCofing = new IExcelConfig<StudentXuexinInfo>();
testExcelCofing.setSheetName("index").setType(StudentXuexinInfo.class)
.addTitle(new ExcelUtil.IExcelTitle("学籍编号", "stdNo"))
.addTitle(new ExcelUtil.IExcelTitle("学号", "schoolRoll"))
.addTitle(new ExcelUtil.IExcelTitle("姓名", "stdName"))
.addTitle(new ExcelUtil.IExcelTitle("年级", "grade"))
.addTitle(new ExcelUtil.IExcelTitle("院校", "unvsName"))
.addTitle(new ExcelUtil.IExcelTitle("层次", "pfsnLevel"))
.addTitle(new ExcelUtil.IExcelTitle("专业", "pfsnName"))
.addTitle(new ExcelUtil.IExcelTitle("是否完成", "isView"))
.addTitle(new ExcelUtil.IExcelTitle("完成时间", "viewTime"))
.addTitle(new ExcelUtil.IExcelTitle("信息是否有误", "isError"))
.addTitle(new ExcelUtil.IExcelTitle("学员反馈", "feedback"))
.addTitle(new ExcelUtil.IExcelTitle("备注", "remark"));
// 行数记录
int index = 2;
try {
// 对文件进行分析转对象
List<StudentXuexinInfo> list = ExcelUtil.importWorkbook(stuXuexinImport.getInputStream(), testExcelCofing,
stuXuexinImport.getOriginalFilename());
// 遍历插入
for (StudentXuexinInfo studentXuexinInfo : list) {
if (!StringUtil.hasValue(studentXuexinInfo.getStdNo())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!学籍编号不能为空");
}
if (!StringUtil.hasValue(studentXuexinInfo.getSchoolRoll())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!学号不能为空");
}
if (!StringUtil.hasValue(studentXuexinInfo.getStdName())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!姓名不能为空");
}
if (StringUtil.hasValue(studentXuexinInfo.getViewTime())) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
format.setLenient(false);
format.parse(studentXuexinInfo.getViewTime());
} catch (Exception e) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!完成时间格式错误,正确格式如:2018-01-26 12:00:00");
}
} else {
studentXuexinInfo.setViewTime(null);
}
if (StringUtil.hasValue(studentXuexinInfo.getIsView())) {
if (studentXuexinInfo.getIsView().equals("是")) {
studentXuexinInfo.setIsView("1");
} else {
studentXuexinInfo.setIsView("0");
}
} else {
studentXuexinInfo.setIsView("0");
}
if (StringUtil.hasValue(studentXuexinInfo.getIsError())) {
if (studentXuexinInfo.getIsError().equals("有误")) {
studentXuexinInfo.setIsError("1");
} else if (studentXuexinInfo.getIsError().equals("无误")) {
studentXuexinInfo.setIsError("0");
}
} else {
studentXuexinInfo.setIsError(null);
}
index++;
}
List<Map<String, Object>> resultList = studentXuexinMapper.getNonExistsStudent(list);
if (resultList.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("学信网信息核对以下学员不存在:<br/>");
for (Map<String, Object> map : resultList) {
sb.append(map.get("school_roll") + "-" + map.get("std_name") + "<br/>");
}
throw new IllegalArgumentException(sb.toString());
}
BaseUser user = SessionUtil.getUser();
studentXuexinMapper.insert(list, user);
} catch (IOException e) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!");
}
}
public int updateRemark(String xuexinId, String remark) {
return studentXuexinMapper.updateRemark(xuexinId, remark);
}
public int resetTask(String xuexinId, String taskId, String learnId) {
return studentXuexinMapper.resetTask(xuexinId, taskId, learnId);
}
@SuppressWarnings("unchecked")
public void exportXuexinInfo(StudentXuexinQuery query, HttpServletResponse response) {
// 对导出工具进行字段填充
IExcelConfig<StudentXuexinInfo> testExcelCofing = new IExcelConfig<StudentXuexinInfo>();
testExcelCofing.setSheetName("index").setType(StudentXuexinInfo.class)
.addTitle(new ExcelUtil.IExcelTitle("学籍编号", "stdNo"))
.addTitle(new ExcelUtil.IExcelTitle("学号", "schoolRoll"))
.addTitle(new ExcelUtil.IExcelTitle("姓名", "stdName"))
.addTitle(new ExcelUtil.IExcelTitle("年级", "grade"))
.addTitle(new ExcelUtil.IExcelTitle("院校", "unvsName"))
.addTitle(new ExcelUtil.IExcelTitle("层次", "pfsnLevel"))
.addTitle(new ExcelUtil.IExcelTitle("专业", "pfsnName"))
.addTitle(new ExcelUtil.IExcelTitle("是否完成", "isView"))
.addTitle(new ExcelUtil.IExcelTitle("完成时间", "viewTime"))
.addTitle(new ExcelUtil.IExcelTitle("信息是否有误", "isError"))
.addTitle(new ExcelUtil.IExcelTitle("学员反馈", "feedback"))
.addTitle(new ExcelUtil.IExcelTitle("备注", "remark"))
.addTitle(new ExcelUtil.IExcelTitle("班主任", "tutor"));
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
for (StudentXuexinInfo studentXuexinInfo : list) {
if (studentXuexinInfo.getIsView().equals("0")) {
studentXuexinInfo.setIsView("否");
} else {
studentXuexinInfo.setIsView("是");
}
if (StringUtil.hasValue(studentXuexinInfo.getIsError()) && studentXuexinInfo.getIsError().equals("0")) {
studentXuexinInfo.setIsError("无误");
} else if (StringUtil.hasValue(studentXuexinInfo.getIsError()) && studentXuexinInfo.getIsError().equals("1")) {
studentXuexinInfo.setIsError("有误");
} else {
studentXuexinInfo.setIsError("");
}
if (StringUtil.hasValue(studentXuexinInfo.getPfsnLevel()) && studentXuexinInfo.getPfsnLevel().equals("1")) {
studentXuexinInfo.setPfsnLevel("1>专科升本科类");
} else if (StringUtil.hasValue(studentXuexinInfo.getPfsnLevel()) && studentXuexinInfo.getPfsnLevel().equals("5")) {
studentXuexinInfo.setPfsnLevel("5>高中起点高职高专");
} else {
studentXuexinInfo.setPfsnLevel("");
}
}
SXSSFWorkbook wb = ExcelUtil.exportWorkbook(list, testExcelCofing);
ServletOutputStream out = null;
try {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=stuXuexin.xls");
out = response.getOutputStream();
wb.write(out);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
out.flush();
out.close();
} catch (IOException e) {
log.error(e.getMessage());
}
}
}
private BaseUser getUser(){
BaseUser user = SessionUtil.getUser();
// 部门主任,学籍组长
if (user.getJtList().contains("BMZR") || user.getJtList().contains("CJXJ") || user.getJtList().contains("GKXJ") || user.getJtList().contains("XJZZ")) {
user.setUserLevel("1");
}
return user;
}
}
| UTF-8 | Java | 11,047 | java | StudentXuexinService.java | Java | [
{
"context": "ava.util.Map;\n\n/**\n * 学员服务---学信网信息核对\n *\n * @author jyt\n */\n@Service\n@Transactional\npublic class StudentX",
"end": 1570,
"score": 0.999597430229187,
"start": 1567,
"tag": "USERNAME",
"value": "jyt"
}
] | null | [] | package com.yz.service.stdService;
import com.yz.edu.paging.bean.Page;
import com.yz.edu.paging.common.PageHelper;
import com.yz.core.security.manager.SessionUtil;
import com.yz.core.util.DictExchangeUtil;
import com.yz.dao.stdService.StudentGraduateDataMapper;
import com.yz.dao.stdService.StudentXuexinMapper;
import com.yz.dao.system.SysCityMapper;
import com.yz.dao.system.SysDistrictMapper;
import com.yz.dao.system.SysProvinceMapper;
import com.yz.exception.BusinessException;
import com.yz.model.admin.BaseUser;
import com.yz.model.common.IPageInfo;
import com.yz.model.stdService.StudentGraduateDataInfo;
import com.yz.model.stdService.StudentGraduateDataQuery;
import com.yz.model.stdService.StudentXuexinInfo;
import com.yz.model.stdService.StudentXuexinQuery;
import com.yz.model.system.SysCity;
import com.yz.model.system.SysDistrict;
import com.yz.model.system.SysProvince;
import com.yz.util.ExcelUtil;
import com.yz.util.ExcelUtil.IExcelConfig;
import com.yz.util.StringUtil;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
/**
* 学员服务---学信网信息核对
*
* @author jyt
*/
@Service
@Transactional
public class StudentXuexinService {
private static Logger log = LoggerFactory.getLogger(StudentXuexinService.class);
@Autowired
private StudentXuexinMapper studentXuexinMapper;
public Object findAllXuexinList(StudentXuexinQuery query) {
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
return new IPageInfo<>((Page) list);
}
public StudentXuexinInfo getXuexinInfoById(String xuexinId) {
StudentXuexinQuery query = new StudentXuexinQuery();
query.setXuexinId(xuexinId);
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
if (list.size() > 0) {
return list.get(0);
}
return null;
}
@SuppressWarnings("unchecked")
public void importStuGraduateDataInfo(MultipartFile stuXuexinImport) {
//对导入工具进行字段填充
IExcelConfig<StudentXuexinInfo> testExcelCofing = new IExcelConfig<StudentXuexinInfo>();
testExcelCofing.setSheetName("index").setType(StudentXuexinInfo.class)
.addTitle(new ExcelUtil.IExcelTitle("学籍编号", "stdNo"))
.addTitle(new ExcelUtil.IExcelTitle("学号", "schoolRoll"))
.addTitle(new ExcelUtil.IExcelTitle("姓名", "stdName"))
.addTitle(new ExcelUtil.IExcelTitle("年级", "grade"))
.addTitle(new ExcelUtil.IExcelTitle("院校", "unvsName"))
.addTitle(new ExcelUtil.IExcelTitle("层次", "pfsnLevel"))
.addTitle(new ExcelUtil.IExcelTitle("专业", "pfsnName"))
.addTitle(new ExcelUtil.IExcelTitle("是否完成", "isView"))
.addTitle(new ExcelUtil.IExcelTitle("完成时间", "viewTime"))
.addTitle(new ExcelUtil.IExcelTitle("信息是否有误", "isError"))
.addTitle(new ExcelUtil.IExcelTitle("学员反馈", "feedback"))
.addTitle(new ExcelUtil.IExcelTitle("备注", "remark"));
// 行数记录
int index = 2;
try {
// 对文件进行分析转对象
List<StudentXuexinInfo> list = ExcelUtil.importWorkbook(stuXuexinImport.getInputStream(), testExcelCofing,
stuXuexinImport.getOriginalFilename());
// 遍历插入
for (StudentXuexinInfo studentXuexinInfo : list) {
if (!StringUtil.hasValue(studentXuexinInfo.getStdNo())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!学籍编号不能为空");
}
if (!StringUtil.hasValue(studentXuexinInfo.getSchoolRoll())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!学号不能为空");
}
if (!StringUtil.hasValue(studentXuexinInfo.getStdName())) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!姓名不能为空");
}
if (StringUtil.hasValue(studentXuexinInfo.getViewTime())) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
format.setLenient(false);
format.parse(studentXuexinInfo.getViewTime());
} catch (Exception e) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!完成时间格式错误,正确格式如:2018-01-26 12:00:00");
}
} else {
studentXuexinInfo.setViewTime(null);
}
if (StringUtil.hasValue(studentXuexinInfo.getIsView())) {
if (studentXuexinInfo.getIsView().equals("是")) {
studentXuexinInfo.setIsView("1");
} else {
studentXuexinInfo.setIsView("0");
}
} else {
studentXuexinInfo.setIsView("0");
}
if (StringUtil.hasValue(studentXuexinInfo.getIsError())) {
if (studentXuexinInfo.getIsError().equals("有误")) {
studentXuexinInfo.setIsError("1");
} else if (studentXuexinInfo.getIsError().equals("无误")) {
studentXuexinInfo.setIsError("0");
}
} else {
studentXuexinInfo.setIsError(null);
}
index++;
}
List<Map<String, Object>> resultList = studentXuexinMapper.getNonExistsStudent(list);
if (resultList.size() > 0) {
StringBuilder sb = new StringBuilder();
sb.append("学信网信息核对以下学员不存在:<br/>");
for (Map<String, Object> map : resultList) {
sb.append(map.get("school_roll") + "-" + map.get("std_name") + "<br/>");
}
throw new IllegalArgumentException(sb.toString());
}
BaseUser user = SessionUtil.getUser();
studentXuexinMapper.insert(list, user);
} catch (IOException e) {
throw new IllegalArgumentException("excel数据格式错误,请检查第" + index + "行数据!");
}
}
public int updateRemark(String xuexinId, String remark) {
return studentXuexinMapper.updateRemark(xuexinId, remark);
}
public int resetTask(String xuexinId, String taskId, String learnId) {
return studentXuexinMapper.resetTask(xuexinId, taskId, learnId);
}
@SuppressWarnings("unchecked")
public void exportXuexinInfo(StudentXuexinQuery query, HttpServletResponse response) {
// 对导出工具进行字段填充
IExcelConfig<StudentXuexinInfo> testExcelCofing = new IExcelConfig<StudentXuexinInfo>();
testExcelCofing.setSheetName("index").setType(StudentXuexinInfo.class)
.addTitle(new ExcelUtil.IExcelTitle("学籍编号", "stdNo"))
.addTitle(new ExcelUtil.IExcelTitle("学号", "schoolRoll"))
.addTitle(new ExcelUtil.IExcelTitle("姓名", "stdName"))
.addTitle(new ExcelUtil.IExcelTitle("年级", "grade"))
.addTitle(new ExcelUtil.IExcelTitle("院校", "unvsName"))
.addTitle(new ExcelUtil.IExcelTitle("层次", "pfsnLevel"))
.addTitle(new ExcelUtil.IExcelTitle("专业", "pfsnName"))
.addTitle(new ExcelUtil.IExcelTitle("是否完成", "isView"))
.addTitle(new ExcelUtil.IExcelTitle("完成时间", "viewTime"))
.addTitle(new ExcelUtil.IExcelTitle("信息是否有误", "isError"))
.addTitle(new ExcelUtil.IExcelTitle("学员反馈", "feedback"))
.addTitle(new ExcelUtil.IExcelTitle("备注", "remark"))
.addTitle(new ExcelUtil.IExcelTitle("班主任", "tutor"));
List<StudentXuexinInfo> list = studentXuexinMapper.findAllXuexinList(query, getUser());
for (StudentXuexinInfo studentXuexinInfo : list) {
if (studentXuexinInfo.getIsView().equals("0")) {
studentXuexinInfo.setIsView("否");
} else {
studentXuexinInfo.setIsView("是");
}
if (StringUtil.hasValue(studentXuexinInfo.getIsError()) && studentXuexinInfo.getIsError().equals("0")) {
studentXuexinInfo.setIsError("无误");
} else if (StringUtil.hasValue(studentXuexinInfo.getIsError()) && studentXuexinInfo.getIsError().equals("1")) {
studentXuexinInfo.setIsError("有误");
} else {
studentXuexinInfo.setIsError("");
}
if (StringUtil.hasValue(studentXuexinInfo.getPfsnLevel()) && studentXuexinInfo.getPfsnLevel().equals("1")) {
studentXuexinInfo.setPfsnLevel("1>专科升本科类");
} else if (StringUtil.hasValue(studentXuexinInfo.getPfsnLevel()) && studentXuexinInfo.getPfsnLevel().equals("5")) {
studentXuexinInfo.setPfsnLevel("5>高中起点高职高专");
} else {
studentXuexinInfo.setPfsnLevel("");
}
}
SXSSFWorkbook wb = ExcelUtil.exportWorkbook(list, testExcelCofing);
ServletOutputStream out = null;
try {
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition", "attachment;filename=stuXuexin.xls");
out = response.getOutputStream();
wb.write(out);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
out.flush();
out.close();
} catch (IOException e) {
log.error(e.getMessage());
}
}
}
private BaseUser getUser(){
BaseUser user = SessionUtil.getUser();
// 部门主任,学籍组长
if (user.getJtList().contains("BMZR") || user.getJtList().contains("CJXJ") || user.getJtList().contains("GKXJ") || user.getJtList().contains("XJZZ")) {
user.setUserLevel("1");
}
return user;
}
}
| 11,047 | 0.615612 | 0.612463 | 235 | 43.591488 | 31.104956 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.625532 | false | false | 4 |
be9e0b76a5b5980538222b8e9db740eb1e52ed22 | 25,262,997,703,252 | 97e144be10e2625a65299e46250f6b6f52b7c52b | /src/main/java/com/rocketball/alg/list/SwapList.java | b32ced5375c094f9ce00429c690763ea89ef688f | [] | no_license | rocketballs/rocket2018 | https://github.com/rocketballs/rocket2018 | d4a9337112e03bcdcd2af7fc331235cf1a28770f | 0ab9a28ab22c71d51dcaaf4738148f31c3e04e08 | refs/heads/master | 2022-05-11T22:22:01.707000 | 2022-03-07T05:47:02 | 2022-03-07T05:47:02 | 155,209,440 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.rocketball.alg.list;
import com.rocketball.alg.struct.ListNode;
public class SwapList {
public static ListNode swapPairs(ListNode head) {
if (head == null || head.next == null)
return head;
ListNode f1 = head;
ListNode sec = head.next;
f1.next = sec.next;
sec.next = f1;
f1.next = swapPairs(sec.next.next);
return sec;
}
public static void main(String[] args) {
ListNode la1 = new ListNode(1);
ListNode la2 = new ListNode(2);
ListNode la3 = new ListNode(3);
ListNode la4 = new ListNode(4);
ListNode la5 = new ListNode(5);
// ListNode la6 = new ListNode(6);
la1.next = la2;
la2.next = la3;
la3.next = la4;
la4.next = la5;
// la5.next = la6;
ListNode last = swapPairs(la1);
ListUtils.printList(last);
}
}
| UTF-8 | Java | 905 | java | SwapList.java | Java | [] | null | [] | package com.rocketball.alg.list;
import com.rocketball.alg.struct.ListNode;
public class SwapList {
public static ListNode swapPairs(ListNode head) {
if (head == null || head.next == null)
return head;
ListNode f1 = head;
ListNode sec = head.next;
f1.next = sec.next;
sec.next = f1;
f1.next = swapPairs(sec.next.next);
return sec;
}
public static void main(String[] args) {
ListNode la1 = new ListNode(1);
ListNode la2 = new ListNode(2);
ListNode la3 = new ListNode(3);
ListNode la4 = new ListNode(4);
ListNode la5 = new ListNode(5);
// ListNode la6 = new ListNode(6);
la1.next = la2;
la2.next = la3;
la3.next = la4;
la4.next = la5;
// la5.next = la6;
ListNode last = swapPairs(la1);
ListUtils.printList(last);
}
}
| 905 | 0.562431 | 0.532597 | 33 | 26.424242 | 15.283245 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.727273 | false | false | 4 |
1e625bcc150f08ab48de63697699bad823bd4fb1 | 14,362,370,652,378 | d8e1924b4b229f2e3922aa17654226f7014cea4f | /src/main/java/top/treegrowth/java/string/UUIDTest.java | 6c11dcbd777b451467c4640eb20aa3a5a608452e | [] | no_license | wusi05/tg-algorithms | https://github.com/wusi05/tg-algorithms | c2fdaafedf9979a65bb36b34a4cf4ebc42ca743e | c178da28960e2f50ae673f31e43de75d8739b05f | refs/heads/master | 2022-07-12T04:44:31.616000 | 2020-06-03T01:09:08 | 2020-06-03T01:09:08 | 82,174,541 | 1 | 0 | null | false | 2022-06-29T16:46:48 | 2017-02-16T11:41:14 | 2020-06-03T01:09:20 | 2022-06-29T16:46:47 | 1,032 | 1 | 0 | 5 | Java | false | false | package top.treegrowth.java.string;
import java.util.UUID;
/**
* @author wusi
* @since 2019-09-27 15:22
*/
public class UUIDTest {
public static void main(String[] args) {
System.out.println(UUID.randomUUID().toString().replace("-", ""));
}
}
| UTF-8 | Java | 265 | java | UUIDTest.java | Java | [
{
"context": "va.string;\n\nimport java.util.UUID;\n\n/**\n * @author wusi\n * @since 2019-09-27 15:22\n */\npublic class UUIDT",
"end": 80,
"score": 0.9991635084152222,
"start": 76,
"tag": "USERNAME",
"value": "wusi"
}
] | null | [] | package top.treegrowth.java.string;
import java.util.UUID;
/**
* @author wusi
* @since 2019-09-27 15:22
*/
public class UUIDTest {
public static void main(String[] args) {
System.out.println(UUID.randomUUID().toString().replace("-", ""));
}
}
| 265 | 0.637736 | 0.592453 | 14 | 17.928572 | 20.865091 | 74 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.285714 | false | false | 4 |
d4acb16839c6755a5ad3397df9a4f03e275ab5b5 | 31,344,671,387,298 | ccf735aac4edcf3835bd26224706e094288930b0 | /src/main/java/com/sist/dao/ShoppingMapper.java | 6548c0dd5db4d602816127ded00b3229c032e742 | [] | no_license | bibidibovidiboo/mango-recipe-project | https://github.com/bibidibovidiboo/mango-recipe-project | 4d4a3e23d27bd3fbba904dec4eb20109d411ea94 | 040aabdca06b5ff3b1a5601d33799d0395969471 | refs/heads/main | 2023-04-21T04:25:26.187000 | 2021-05-29T11:28:32 | 2021-05-29T11:28:32 | 328,369,212 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sist.dao;
import java.util.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.sist.vo.*;
public interface ShoppingMapper {
//리스트
@Select("SELECT no,title,image,lprice,category2,category3,num "
+"FROM (SELECT no,title,image,lprice,category2,category3,rownum as num "
+"FROM (SELECT no,title,image,lprice,category2,category3 "
+"FROM naver_shopping WHERE category2=#{category2} ORDER BY no ASC))"
+"WHERE num BETWEEN #{start} AND #{end}")
public List<ShoppingVO> shoppingListData(Map map);
//총페이지
@Select("SELECT CEIL(COUNT(*)/12.0) FROM naver_shopping WHERE category2=#{category2}")
public int shoppingTotalPage(String category2);
// 상세
@Select("SELECT * FROM naver_shopping WHERE no=#{no}")
public ShoppingVO shoppingDetailData(int no);
// 카테고리 분류
@Select("SELECT * FROM naver_shopping WHERE category2=#{category2}")
public List<ShoppingVO> shoppingCateData(String category2);
// 상세보기 레시피 리스트 출력
@Select("SELECT rno,title,img,rownum FROM recipe_table "
+ "WHERE rownum<=7 AND "
+ "REGEXP_LIKE(title,#{category3})")
public List<RecipeVO> shoppingRecipeData(String category3);
// 상세보기 레시피 디테일
@Select("SELECT * FROM recipe_table "
+ "WHERE rno=#{rno}")
public RecipeVO recipeDetailData(int rno);
// 댓글 파트
// 댓글 목록 읽기
@Select("SELECT no,cno,id,name,msg,good,soso,bad,TO_CHAR(regdate,'YYYY-MM-DD HH24:MI:SS') as dbday "
+"FROM shopping_reply "
+"WHERE cno=#{no} "
+"ORDER BY no DESC")
public List<ShoppingReplyVO> shoppingReplyListData(int no);
//댓글 추가
@Insert("INSERT INTO shopping_reply(no,cno,id,name,msg,good,soso,bad) values(shopping_reply_seq.NEXTVAL,#{cno},#{id},#{name},#{msg},#{good},#{soso},#{bad})")
public void shoppingReplyInsertData(ShoppingReplyVO vo);
//댓글 삭제
@Delete("DELETE FROM shopping_reply where no=#{no} AND cno=#{cno}")
public void shoppingReplyDeleteData(ShoppingReplyVO vo);
//댓글 수정
@Update("UPDATE shopping_reply SET no=#{no},cno=#{cno},id=#{id},name=#{name},msg=#{msg},good=#{good},soso=#{soso},bad=#{bad} where cno=#{cno} AND no=#{no}")
public void shoppingReplyUpdateData(ShoppingReplyVO vo);
// 파이그래프
@Select("SELECT SUM(good) as good,"
+ "SUM(soso) as soso,"
+ "SUM(bad) as bad "
+ "FROM shopping_reply WHERE cno=#{no}")
public ShoppingReplyVO productGraphData(int no);
}
| UTF-8 | Java | 2,607 | java | ShoppingMapper.java | Java | [] | null | [] | package com.sist.dao;
import java.util.*;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import com.sist.vo.*;
public interface ShoppingMapper {
//리스트
@Select("SELECT no,title,image,lprice,category2,category3,num "
+"FROM (SELECT no,title,image,lprice,category2,category3,rownum as num "
+"FROM (SELECT no,title,image,lprice,category2,category3 "
+"FROM naver_shopping WHERE category2=#{category2} ORDER BY no ASC))"
+"WHERE num BETWEEN #{start} AND #{end}")
public List<ShoppingVO> shoppingListData(Map map);
//총페이지
@Select("SELECT CEIL(COUNT(*)/12.0) FROM naver_shopping WHERE category2=#{category2}")
public int shoppingTotalPage(String category2);
// 상세
@Select("SELECT * FROM naver_shopping WHERE no=#{no}")
public ShoppingVO shoppingDetailData(int no);
// 카테고리 분류
@Select("SELECT * FROM naver_shopping WHERE category2=#{category2}")
public List<ShoppingVO> shoppingCateData(String category2);
// 상세보기 레시피 리스트 출력
@Select("SELECT rno,title,img,rownum FROM recipe_table "
+ "WHERE rownum<=7 AND "
+ "REGEXP_LIKE(title,#{category3})")
public List<RecipeVO> shoppingRecipeData(String category3);
// 상세보기 레시피 디테일
@Select("SELECT * FROM recipe_table "
+ "WHERE rno=#{rno}")
public RecipeVO recipeDetailData(int rno);
// 댓글 파트
// 댓글 목록 읽기
@Select("SELECT no,cno,id,name,msg,good,soso,bad,TO_CHAR(regdate,'YYYY-MM-DD HH24:MI:SS') as dbday "
+"FROM shopping_reply "
+"WHERE cno=#{no} "
+"ORDER BY no DESC")
public List<ShoppingReplyVO> shoppingReplyListData(int no);
//댓글 추가
@Insert("INSERT INTO shopping_reply(no,cno,id,name,msg,good,soso,bad) values(shopping_reply_seq.NEXTVAL,#{cno},#{id},#{name},#{msg},#{good},#{soso},#{bad})")
public void shoppingReplyInsertData(ShoppingReplyVO vo);
//댓글 삭제
@Delete("DELETE FROM shopping_reply where no=#{no} AND cno=#{cno}")
public void shoppingReplyDeleteData(ShoppingReplyVO vo);
//댓글 수정
@Update("UPDATE shopping_reply SET no=#{no},cno=#{cno},id=#{id},name=#{name},msg=#{msg},good=#{good},soso=#{soso},bad=#{bad} where cno=#{cno} AND no=#{no}")
public void shoppingReplyUpdateData(ShoppingReplyVO vo);
// 파이그래프
@Select("SELECT SUM(good) as good,"
+ "SUM(soso) as soso,"
+ "SUM(bad) as bad "
+ "FROM shopping_reply WHERE cno=#{no}")
public ShoppingReplyVO productGraphData(int no);
}
| 2,607 | 0.701493 | 0.692618 | 75 | 32.053333 | 33.01672 | 159 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.093333 | false | false | 4 |
ca1a71ab065b1fe2c25e253611d018c909a03771 | 4,896,262,773,874 | 25846499ed83cbca727abbca41eb90bed8cc188f | /src/main/java/com/exception/lizk/exception/exception/BaseException.java | 9f2da584e741f6f24d5479ab6dfffa87806ddf0e | [] | no_license | rookieLizk/exceptionHandlerDemo | https://github.com/rookieLizk/exceptionHandlerDemo | a9942c88a400384b4bb896ad9cc801cf45259958 | 82bb20bae157d180ae2b8f2da04a3c4eac73ba83 | refs/heads/master | 2022-12-26T22:50:43.987000 | 2020-10-09T08:34:27 | 2020-10-09T08:34:27 | 302,578,750 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.exception.lizk.exception.exception;
import lombok.Data;
/**
* @author lizk
* @date 2019-07-11 14:57
* @since
**/
@Data
public class BaseException extends RuntimeException {
private String errorKey;
private Object[] values;
public BaseException(String errorKey, Object... values) {
this.errorKey = errorKey;
this.values = values;
}
}
| UTF-8 | Java | 386 | java | BaseException.java | Java | [
{
"context": "on.exception;\n\nimport lombok.Data;\n\n/**\n * @author lizk\n * @date 2019-07-11 14:57\n * @since\n **/\n@Data\npu",
"end": 89,
"score": 0.9996261596679688,
"start": 85,
"tag": "USERNAME",
"value": "lizk"
}
] | null | [] | package com.exception.lizk.exception.exception;
import lombok.Data;
/**
* @author lizk
* @date 2019-07-11 14:57
* @since
**/
@Data
public class BaseException extends RuntimeException {
private String errorKey;
private Object[] values;
public BaseException(String errorKey, Object... values) {
this.errorKey = errorKey;
this.values = values;
}
}
| 386 | 0.673575 | 0.642487 | 21 | 17.380953 | 18.594614 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 4 |
94e8c4ea6b948b5947f9fd89e20bc3d65b81cd0f | 24,386,824,353,392 | e80cb4531f8a4caeae1d25761bdc42cb660ac6c5 | /adaptors/jsaga-adaptor-linux/src/fr/in2p3/jsaga/adaptor/data/LinuxFileAttributes.java | 85419b2bf361e15985101eb6258f79a10b1964e3 | [] | no_license | ccin2p3/jsaga | https://github.com/ccin2p3/jsaga | 67cfbc8f00a4ff8336ec1c977caffdc60108e0cf | 040e268f1a80cb44a4cf449a694b33ac415eac3d | refs/heads/master | 2021-01-20T17:12:30.074000 | 2017-04-25T11:13:18 | 2017-04-25T11:13:18 | 62,138,791 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package fr.in2p3.jsaga.adaptor.data;
import fr.in2p3.commons.filesystem.FileStat;
import fr.in2p3.jsaga.adaptor.data.link.NotLink;
import fr.in2p3.jsaga.adaptor.data.permission.PermissionBytes;
import fr.in2p3.jsaga.adaptor.data.read.FileAttributes;
/* ***************************************************
* *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
* *** http://cc.in2p3.fr/ ***
* ***************************************************
* File: LinuxFileAttributes
* Author: Sylvain Reynaud (sreynaud@in2p3.fr)
* Date: 19 mai 2010
* ***************************************************
* Description: */
/**
*
*/
public class LinuxFileAttributes extends FileAttributes {
private FileStat m_stat;
public LinuxFileAttributes(FileStat stat) {
m_stat = stat;
}
public String getName() {
return m_stat.name;
}
public String readLink() throws NotLink {
if (!m_stat.islink ) {
throw new NotLink("Not a link: " + m_stat.name);
}
return m_stat.target;
}
public int getType() {
if (m_stat.islink) {
return TYPE_LINK;
} else if (m_stat.isfile) {
return TYPE_FILE;
} else if (m_stat.isdir) {
return TYPE_DIRECTORY;
} else {
return TYPE_UNKNOWN;
}
}
public long getSize() {
return m_stat.size;
}
public PermissionBytes getUserPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.user_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.user_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.user_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public PermissionBytes getGroupPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.group_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.group_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.group_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public PermissionBytes getAnyPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.other_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.other_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.other_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public String getOwner() {
return m_stat.owner;
}
public String getGroup() {
return m_stat.group;
}
public long getLastModified() {
return m_stat.getModifiedDate();
}
}
| UTF-8 | Java | 2,883 | java | LinuxFileAttributes.java | Java | [
{
"context": "********\n * File: LinuxFileAttributes\n * Author: Sylvain Reynaud (sreynaud@in2p3.fr)\n * Date: 19 mai 2010\n * ***",
"end": 529,
"score": 0.9998965859413147,
"start": 514,
"tag": "NAME",
"value": "Sylvain Reynaud"
},
{
"context": " LinuxFileAttributes\n * Author: Sylvain Reynaud (sreynaud@in2p3.fr)\n * Date: 19 mai 2010\n * **********************",
"end": 548,
"score": 0.9999357461929321,
"start": 531,
"tag": "EMAIL",
"value": "sreynaud@in2p3.fr"
}
] | null | [] | package fr.in2p3.jsaga.adaptor.data;
import fr.in2p3.commons.filesystem.FileStat;
import fr.in2p3.jsaga.adaptor.data.link.NotLink;
import fr.in2p3.jsaga.adaptor.data.permission.PermissionBytes;
import fr.in2p3.jsaga.adaptor.data.read.FileAttributes;
/* ***************************************************
* *** Centre de Calcul de l'IN2P3 - Lyon (France) ***
* *** http://cc.in2p3.fr/ ***
* ***************************************************
* File: LinuxFileAttributes
* Author: <NAME> (<EMAIL>)
* Date: 19 mai 2010
* ***************************************************
* Description: */
/**
*
*/
public class LinuxFileAttributes extends FileAttributes {
private FileStat m_stat;
public LinuxFileAttributes(FileStat stat) {
m_stat = stat;
}
public String getName() {
return m_stat.name;
}
public String readLink() throws NotLink {
if (!m_stat.islink ) {
throw new NotLink("Not a link: " + m_stat.name);
}
return m_stat.target;
}
public int getType() {
if (m_stat.islink) {
return TYPE_LINK;
} else if (m_stat.isfile) {
return TYPE_FILE;
} else if (m_stat.isdir) {
return TYPE_DIRECTORY;
} else {
return TYPE_UNKNOWN;
}
}
public long getSize() {
return m_stat.size;
}
public PermissionBytes getUserPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.user_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.user_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.user_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public PermissionBytes getGroupPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.group_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.group_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.group_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public PermissionBytes getAnyPermission() {
PermissionBytes perms = PermissionBytes.NONE;
if(FileStat.isReadable(m_stat.other_perms)) perms=perms.or(PermissionBytes.READ);
if(FileStat.isWritable(m_stat.other_perms)) perms=perms.or(PermissionBytes.WRITE);
if(FileStat.isExecutable(m_stat.other_perms)) perms=perms.or(PermissionBytes.EXEC);
return perms;
}
public String getOwner() {
return m_stat.owner;
}
public String getGroup() {
return m_stat.group;
}
public long getLastModified() {
return m_stat.getModifiedDate();
}
}
| 2,864 | 0.600416 | 0.592785 | 89 | 31.393259 | 27.131233 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.426966 | false | false | 4 |
367f732eb43eabe425fc912d003f41493037d097 | 18,880,676,293,748 | e93986354aae40680823ad3e866ac9f09bce44a9 | /MyFirstProject/src/Even_Odd.java | b16c0e0ecf7c6420f4b841b12f6808f29b146903 | [] | no_license | sangeetha2898/MyFirstProject | https://github.com/sangeetha2898/MyFirstProject | 88831f3bd6090f721a907e42844e6943fe62ee70 | da31447ea10ad72c64a5e1471c51e0592e0e8832 | refs/heads/main | 2023-06-06T06:23:44.487000 | 2021-06-23T03:57:12 | 2021-06-23T03:57:12 | 376,843,944 | 0 | 0 | null | false | 2021-06-14T16:15:54 | 2021-06-14T14:02:57 | 2021-06-14T14:51:48 | 2021-06-14T16:15:53 | 1 | 0 | 0 | 2 | null | false | false | import java.io.*;
import java.util.*;
public class Even_Odd {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
int n= sc.nextInt();
System.out.println("ODD NUMBERS:");
for(int i=1;i<=n;i++)
{
if((i%2)!=0)
{
System.out.println(i);
}
}
System.out.println("EVEN NUMBERS:");
for(int i=1;i<=n;i++)
{
if((i%2)==0)
{
System.out.println(i);
}
}
}
}
| UTF-8 | Java | 582 | java | Even_Odd.java | Java | [] | null | [] | import java.io.*;
import java.util.*;
public class Even_Odd {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc=new Scanner(System.in);
System.out.println("Enter the number");
int n= sc.nextInt();
System.out.println("ODD NUMBERS:");
for(int i=1;i<=n;i++)
{
if((i%2)!=0)
{
System.out.println(i);
}
}
System.out.println("EVEN NUMBERS:");
for(int i=1;i<=n;i++)
{
if((i%2)==0)
{
System.out.println(i);
}
}
}
}
| 582 | 0.498282 | 0.487972 | 29 | 19.068966 | 13.848767 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.068966 | false | false | 4 |
57ed2fb858d18dc0472fd64e56180a167f4deca2 | 23,252,952,961,288 | f57c9d57f967289ebc50d9709d8fb6564b1a7898 | /src/main/java/com/ylz/packcommon/common/comEnum/CommonConsultState.java | 7a1795d5f141dbe09a1fb27c8f29fde5cb734e01 | [] | no_license | zzr156/familydoctor | https://github.com/zzr156/familydoctor | dc78838040fcc838f252f498e101900b9ab1eda6 | a0d24b24f27b209c748ce1767109fc46b076d785 | refs/heads/master | 2022-12-23T18:59:12.892000 | 2019-12-14T02:46:48 | 2019-12-14T02:46:48 | 227,955,558 | 2 | 1 | null | false | 2022-12-16T02:48:39 | 2019-12-14T02:37:27 | 2022-12-10T10:43:59 | 2022-12-16T02:48:36 | 24,266 | 1 | 1 | 17 | Java | false | false | package com.ylz.packcommon.common.comEnum;
/**
* 咨询状态
* Created by zzl on 2017/6/26.
*/
public enum CommonConsultState {
/**
* 待回复
*/
DHF("0"),
/**
* 进行中
*/
JXZ("1"),
/**
* 已完成
*/
YWC("2");
private String value;
CommonConsultState(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
| UTF-8 | Java | 438 | java | CommonConsultState.java | Java | [
{
"context": "kcommon.common.comEnum;\n\n/**\n * 咨询状态\n * Created by zzl on 2017/6/26.\n */\npublic enum CommonConsultState ",
"end": 73,
"score": 0.999442458152771,
"start": 70,
"tag": "USERNAME",
"value": "zzl"
}
] | null | [] | package com.ylz.packcommon.common.comEnum;
/**
* 咨询状态
* Created by zzl on 2017/6/26.
*/
public enum CommonConsultState {
/**
* 待回复
*/
DHF("0"),
/**
* 进行中
*/
JXZ("1"),
/**
* 已完成
*/
YWC("2");
private String value;
CommonConsultState(String value){
this.value = value;
}
public String getValue(){
return this.value;
}
}
| 438 | 0.5 | 0.475728 | 28 | 13.714286 | 11.864885 | 42 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 4 |
1d1c90c1d5b2624db7d2b18f99e13698a2b26583 | 11,278,584,148,494 | 80446b718d3a57ac7dc33903313713c14bf07b3b | /fxk-boot-mqbroker/fxk-boot-mqbroker-core/src/main/java/com/fanxuankai/boot/mqbroker/consume/EventListenerContainer.java | 21287b3a22b6f65e16f602358d63af6f512abf1f | [] | no_license | fanxuankai/fxk-boot | https://github.com/fanxuankai/fxk-boot | 2a057f41d89b184eb4825cb1bc940f5840afe600 | 326ecaeceb9c712c7ee076cf0ea996e0543c02b6 | refs/heads/main | 2023-08-24T10:34:24.952000 | 2021-08-07T16:27:31 | 2021-08-07T16:27:31 | 310,165,601 | 9 | 3 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fanxuankai.boot.mqbroker.consume;
import java.util.List;
/**
* @author fanxuankai
*/
public interface EventListenerContainer {
/**
* 获取事件监听者
*
* @return /
*/
List<EventListenerBean> getListeners();
/**
* 设置事件监听者
*
* @param listeners /
*/
void setListeners(List<EventListenerBean> listeners);
}
| UTF-8 | Java | 395 | java | EventListenerContainer.java | Java | [
{
"context": "r.consume;\n\nimport java.util.List;\n\n/**\n * @author fanxuankai\n */\npublic interface EventListenerContainer {\n ",
"end": 96,
"score": 0.9993425607681274,
"start": 86,
"tag": "USERNAME",
"value": "fanxuankai"
}
] | null | [] | package com.fanxuankai.boot.mqbroker.consume;
import java.util.List;
/**
* @author fanxuankai
*/
public interface EventListenerContainer {
/**
* 获取事件监听者
*
* @return /
*/
List<EventListenerBean> getListeners();
/**
* 设置事件监听者
*
* @param listeners /
*/
void setListeners(List<EventListenerBean> listeners);
}
| 395 | 0.607629 | 0.607629 | 22 | 15.681818 | 16.346771 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.181818 | false | false | 4 |
96ee49d97ce7e5e3654151c35007d5a3c1c3ee2e | 7,507,602,865,943 | d528fe4f3aa3a7eca7c5ba4e0aee43421e60857f | /main/com/zfsoft/xgxt/rcsw/tsqktbgl/xqdmwh/XqdmDao.java | f008a01b5ce9f2c999704b7bf22938a9ba53e12a | [] | no_license | gxlioper/xajd | https://github.com/gxlioper/xajd | 81bd19a7c4b9f2d1a41a23295497b6de0dae4169 | b7d4237acf7d6ffeca1c4a5a6717594ca55f1673 | refs/heads/master | 2022-03-06T15:49:34.004000 | 2019-11-19T07:43:25 | 2019-11-19T07:43:25 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* @部门:学工产品事业部
* @日期:2016-3-15 下午02:19:29
*/
package com.zfsoft.xgxt.rcsw.tsqktbgl.xqdmwh;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import xgxt.form.User;
import com.zfsoft.utils.StringUtil;
import com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl;
/**
* @系统名称: 学生工作管理系统
* @模块名称: XXXX管理模块
* @类功能描述: TODO(这里用一句话描述这个类的作用)
* @作者: 柳俊[工号:1282]
* @时间: 2016-3-15 下午02:19:29
* @版本: V1.0
* @修改记录: 类修改者-修改日期-修改说明
*/
public class XqdmDao extends SuperDAOImpl<XqdmForm> {
/*
* 描述: @see
* com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#getPageList(java.lang.Object)
*/
@Override
public List<HashMap<String, String>> getPageList(XqdmForm t)
throws Exception {
List<String> params = new ArrayList<String>();
StringBuilder sql = new StringBuilder(
" select * from xg_bjzyy_xqyb_xqfl where 1=1 ");
if (!StringUtil.isNull(t.getXqmc())) {
params.add(t.getXqmc());
sql.append(" and xqmc like '%'||?||'%'");
}
sql.append(" order by to_number(xqdm) ");
return getPageList(t, sql.toString(), params.toArray(new String[] {}));
}
/*
* 描述: @see
* com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#getPageList(java.lang.Object,
* xgxt.form.User)
*/
@Override
public List<HashMap<String, String>> getPageList(XqdmForm t, User user)
throws Exception {
return null;
}
/*
* 描述: @see com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#setTableInfo()
*/
@Override
protected void setTableInfo() {
super.setClass(XqdmForm.class);
super.setKey("xqdm");
super.setTableName("xg_bjzyy_xqyb_xqfl");
}
public boolean checkExistForAdd(XqdmForm form){
String sql = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ?";
String num = dao.getOneRs(sql, new String[]{form.getXqmc()}, "num");
return Integer.valueOf(num)>0;
}
public boolean checkExistForUpdate(XqdmForm form,String oldxqdm){
if(form.getXqdm().equalsIgnoreCase(oldxqdm)){
String sql = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ? and xqdm <> ?";
String xqmcNum = dao.getOneRs(sql, new String[]{form.getXqmc(),form.getXqdm()}, "num");
return Integer.parseInt(xqmcNum)>0;
}else{
String sqlll = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqdm = ?";
String num = dao.getOneRs(sqlll, new String[]{form.getXqdm()}, "num");
if(Integer.parseInt(num)>0){
return true;
}else{
String sqllll = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ? and xqdm <> ?";
String numm = dao.getOneRs(sqllll, new String[]{form.getXqmc(),oldxqdm}, "num");
if(Integer.parseInt(numm)>0){
return true;
}else{
return false;
}
}
}
}
/**
* @描述:判断是否在申请和结果中存在
* @作者:柳俊[工号:1282]
* @日期:2016-3-15 下午02:52:29
* @修改记录: 修改者名字-修改日期-修改内容
* @param form
* @return boolean 返回类型
* @throws
*/
public boolean checkExistForsqjg(XqdmForm form) {
String sql = ("select count(*) num from xg_bjzyy_tsqktb_sq where xqdm1 = ? or xqdm2 = ?");
String num = dao.getOneRs(sql, new String[] { form.getXqdm(),
form.getXqdm() }, "num");
if (Integer.valueOf(num) > 0) {
return true;
}
String sqll = ("select count(*) num from xg_bjzyy_tsqktb_jg where xqdm1 = ? or xqdm2 = ?");
String numm = dao.getOneRs(sqll, new String[] { form.getXqdm(),
form.getXqdm() }, "num");
return Integer.valueOf(numm) > 0;
}
public int getMaxXqdm() throws SQLException {
String sql = "select nvl(max(xqdm),1) xqdm from xg_bjzyy_xqyb_xqfl";
return dao.getOneRsint(sql) + 1;
}
public boolean update(XqdmForm form,String oldXqdm) throws Exception{
String sql = "update xg_bjzyy_xqyb_xqfl set xqdm = ?,xqmc = ? where xqdm = ?";
return dao.runUpdate(sql, new String[]{form.getXqdm(),form.getXqmc(),oldXqdm});
}
}
| GB18030 | Java | 4,176 | java | XqdmDao.java | Java | [
{
"context": "XXXX管理模块\r\n * @类功能描述: TODO(这里用一句话描述这个类的作用)\r\n * @作者: 柳俊[工号:1282]\r\n * @时间: 2016-3-15 下午02:19:29\r\n * @版本: V",
"end": 423,
"score": 0.9964417219161987,
"start": 421,
"tag": "NAME",
"value": "柳俊"
},
{
"context": "\tsuper.setClass(XqdmForm.class);\r\n\t\tsuper.setKey(\"xqdm\");\r\n\t\tsuper.setTableName(\"xg_bjzyy_xqyb_xqfl\");\r\n",
"end": 1614,
"score": 0.8073921203613281,
"start": 1610,
"tag": "KEY",
"value": "xqdm"
},
{
"context": "}\r\n\t\t\r\n\t}\r\n\r\n\t/**\r\n\t * @描述:判断是否在申请和结果中存在\r\n\t * @作者:柳俊[工号:1282]\r\n\t * @日期:2016-3-15 下午02:52:29\r\n\t * @修改记录",
"end": 2817,
"score": 0.9924377202987671,
"start": 2815,
"tag": "NAME",
"value": "柳俊"
}
] | null | [] | /**
* @部门:学工产品事业部
* @日期:2016-3-15 下午02:19:29
*/
package com.zfsoft.xgxt.rcsw.tsqktbgl.xqdmwh;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import xgxt.form.User;
import com.zfsoft.utils.StringUtil;
import com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl;
/**
* @系统名称: 学生工作管理系统
* @模块名称: XXXX管理模块
* @类功能描述: TODO(这里用一句话描述这个类的作用)
* @作者: 柳俊[工号:1282]
* @时间: 2016-3-15 下午02:19:29
* @版本: V1.0
* @修改记录: 类修改者-修改日期-修改说明
*/
public class XqdmDao extends SuperDAOImpl<XqdmForm> {
/*
* 描述: @see
* com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#getPageList(java.lang.Object)
*/
@Override
public List<HashMap<String, String>> getPageList(XqdmForm t)
throws Exception {
List<String> params = new ArrayList<String>();
StringBuilder sql = new StringBuilder(
" select * from xg_bjzyy_xqyb_xqfl where 1=1 ");
if (!StringUtil.isNull(t.getXqmc())) {
params.add(t.getXqmc());
sql.append(" and xqmc like '%'||?||'%'");
}
sql.append(" order by to_number(xqdm) ");
return getPageList(t, sql.toString(), params.toArray(new String[] {}));
}
/*
* 描述: @see
* com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#getPageList(java.lang.Object,
* xgxt.form.User)
*/
@Override
public List<HashMap<String, String>> getPageList(XqdmForm t, User user)
throws Exception {
return null;
}
/*
* 描述: @see com.zfsoft.xgxt.base.dao.impl.SuperDAOImpl#setTableInfo()
*/
@Override
protected void setTableInfo() {
super.setClass(XqdmForm.class);
super.setKey("xqdm");
super.setTableName("xg_bjzyy_xqyb_xqfl");
}
public boolean checkExistForAdd(XqdmForm form){
String sql = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ?";
String num = dao.getOneRs(sql, new String[]{form.getXqmc()}, "num");
return Integer.valueOf(num)>0;
}
public boolean checkExistForUpdate(XqdmForm form,String oldxqdm){
if(form.getXqdm().equalsIgnoreCase(oldxqdm)){
String sql = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ? and xqdm <> ?";
String xqmcNum = dao.getOneRs(sql, new String[]{form.getXqmc(),form.getXqdm()}, "num");
return Integer.parseInt(xqmcNum)>0;
}else{
String sqlll = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqdm = ?";
String num = dao.getOneRs(sqlll, new String[]{form.getXqdm()}, "num");
if(Integer.parseInt(num)>0){
return true;
}else{
String sqllll = "select count(1) num from xg_bjzyy_xqyb_xqfl where xqmc = ? and xqdm <> ?";
String numm = dao.getOneRs(sqllll, new String[]{form.getXqmc(),oldxqdm}, "num");
if(Integer.parseInt(numm)>0){
return true;
}else{
return false;
}
}
}
}
/**
* @描述:判断是否在申请和结果中存在
* @作者:柳俊[工号:1282]
* @日期:2016-3-15 下午02:52:29
* @修改记录: 修改者名字-修改日期-修改内容
* @param form
* @return boolean 返回类型
* @throws
*/
public boolean checkExistForsqjg(XqdmForm form) {
String sql = ("select count(*) num from xg_bjzyy_tsqktb_sq where xqdm1 = ? or xqdm2 = ?");
String num = dao.getOneRs(sql, new String[] { form.getXqdm(),
form.getXqdm() }, "num");
if (Integer.valueOf(num) > 0) {
return true;
}
String sqll = ("select count(*) num from xg_bjzyy_tsqktb_jg where xqdm1 = ? or xqdm2 = ?");
String numm = dao.getOneRs(sqll, new String[] { form.getXqdm(),
form.getXqdm() }, "num");
return Integer.valueOf(numm) > 0;
}
public int getMaxXqdm() throws SQLException {
String sql = "select nvl(max(xqdm),1) xqdm from xg_bjzyy_xqyb_xqfl";
return dao.getOneRsint(sql) + 1;
}
public boolean update(XqdmForm form,String oldXqdm) throws Exception{
String sql = "update xg_bjzyy_xqyb_xqfl set xqdm = ?,xqmc = ? where xqdm = ?";
return dao.runUpdate(sql, new String[]{form.getXqdm(),form.getXqmc(),oldXqdm});
}
}
| 4,176 | 0.641098 | 0.62391 | 138 | 26.246376 | 27.152498 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.862319 | false | false | 4 |
ab8225d232a33a558acdfbfae349aa425e28a30e | 6,777,458,419,949 | 309198489f0a78f843bc5ab5e63051cb0bab583c | /01-git的基础认识/src/com/gec/web/UserService.java | ef324f7da703b8033bab3a8fcc64ca223acf1437 | [] | no_license | Wlong-art/gz2071 | https://github.com/Wlong-art/gz2071 | 86274c189e1f493bae146933eaa05d85180ac80d | 35875fd63ed754b5ef60acf06d53ddc229a722e2 | refs/heads/master | 2023-02-24T09:01:09.319000 | 2021-01-29T03:15:59 | 2021-01-29T03:15:59 | 333,706,342 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.gec.web;
public interface UserService {
//添加用户
void addUser();
//删除用户
void deleteUser();
}
| UTF-8 | Java | 138 | java | UserService.java | Java | [] | null | [] | package com.gec.web;
public interface UserService {
//添加用户
void addUser();
//删除用户
void deleteUser();
}
| 138 | 0.614754 | 0.614754 | 10 | 10.2 | 9.887365 | 30 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.9 | false | false | 4 |
1c36648df11d301190ec3cc817ab8990eb284d0c | 8,418,135,924,440 | 145656e88cc320101bf8f54af0187855d76199cf | /src/main/java/ar/edu/utn/frba/dds/group5/students/view/BaseScoreWindow.java | 0bdfa7e1eee25e9973e42ea48b476df5dbfb2de1 | [] | no_license | Renkon/ArenaTP | https://github.com/Renkon/ArenaTP | fe378c9413850efbf8888869466820236b576073 | 507de197153b77b137f35f88f6a5fcee80e46b0e | refs/heads/master | 2020-03-22T14:04:45.434000 | 2018-10-03T04:04:40 | 2018-10-03T04:04:40 | 140,152,160 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ar.edu.utn.frba.dds.group5.students.view;
import ar.edu.utn.frba.dds.group5.students.model.Student;
import ar.edu.utn.frba.dds.group5.students.model.Task;
import ar.edu.utn.frba.dds.group5.students.viewmodel.AssignmentsViewModel;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.Selector;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;
public abstract class BaseScoreWindow extends SimpleWindow<AssignmentsViewModel> {
protected Panel taskPanel;
public BaseScoreWindow(WindowOwner parent, Student student) {
super(parent, new AssignmentsViewModel(student));
}
@Override
protected void createFormPanel(Panel panel) {
setTitle("Notas");
new Label(panel).bindValueToProperty("student.completeUniversityName");
taskPanel = new Panel(panel);
taskPanel.setLayout(new HorizontalLayout());
new Label(taskPanel).setText("Tarea:");
Selector<Task> tasksSelector = new Selector<>(taskPanel);
tasksSelector.setWidth(500);
tasksSelector.bindItemsToProperty("student.assignments");
tasksSelector.bindValueToProperty("assignment");
}
}
| UTF-8 | Java | 1,287 | java | BaseScoreWindow.java | Java | [] | null | [] | package ar.edu.utn.frba.dds.group5.students.view;
import ar.edu.utn.frba.dds.group5.students.model.Student;
import ar.edu.utn.frba.dds.group5.students.model.Task;
import ar.edu.utn.frba.dds.group5.students.viewmodel.AssignmentsViewModel;
import org.uqbar.arena.layout.HorizontalLayout;
import org.uqbar.arena.widgets.Label;
import org.uqbar.arena.widgets.Panel;
import org.uqbar.arena.widgets.Selector;
import org.uqbar.arena.windows.SimpleWindow;
import org.uqbar.arena.windows.WindowOwner;
public abstract class BaseScoreWindow extends SimpleWindow<AssignmentsViewModel> {
protected Panel taskPanel;
public BaseScoreWindow(WindowOwner parent, Student student) {
super(parent, new AssignmentsViewModel(student));
}
@Override
protected void createFormPanel(Panel panel) {
setTitle("Notas");
new Label(panel).bindValueToProperty("student.completeUniversityName");
taskPanel = new Panel(panel);
taskPanel.setLayout(new HorizontalLayout());
new Label(taskPanel).setText("Tarea:");
Selector<Task> tasksSelector = new Selector<>(taskPanel);
tasksSelector.setWidth(500);
tasksSelector.bindItemsToProperty("student.assignments");
tasksSelector.bindValueToProperty("assignment");
}
}
| 1,287 | 0.749806 | 0.744367 | 35 | 35.771427 | 25.850212 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.657143 | false | false | 4 |
0d058823957c4e0216b3b77a9562ba72d29c3e93 | 19,868,518,744,708 | e608525f47d41e1da3ae06ee6ac5047d5b4953cc | /src/tetris/model/figure/FigureZ.java | 0b80ca63026b792879da2640ae3ff6eac4ffec55 | [] | no_license | ArtemBashtovyi/tetris | https://github.com/ArtemBashtovyi/tetris | 3be124b1a6f684548b79f436f97e952330320dd5 | 876064a1ce4327574481f29526f8c739be8eef22 | refs/heads/master | 2020-03-08T12:44:21.089000 | 2019-06-23T17:34:14 | 2019-06-23T17:34:14 | 128,135,438 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tetris.model.figure;
import tetris.model.coord.Coordinate;
import tetris.model.figure.state.RotationMode;
import tetris.model.figure.state.StateConstants;
import java.util.ArrayList;
import java.util.List;
public class FigureZ extends BaseFigure {
private List<Coordinate> coordinates = new ArrayList<>();
public FigureZ(Coordinate topLeftCoordinate, RotationMode rotationMode) {
super(topLeftCoordinate, rotationMode);
setFigureMatrix(topLeftCoordinate,rotationMode);
}
@Override
void setFigureMatrix(Coordinate topLeftCoordinate, RotationMode rotationMode) {
coordinates.clear();
switch (rotationMode) {
case ROTATED_180:
case NORMAL: {
coordinates.add(topLeftCoordinate);
coordinates.add(new Coordinate(topLeftCoordinate.x + 1, topLeftCoordinate.y));
coordinates.add(new Coordinate(topLeftCoordinate.x , topLeftCoordinate.y + 1));
coordinates.add(new Coordinate(topLeftCoordinate.x -1, topLeftCoordinate.y+1));
System.out.println("NORMAL_INSTALLED");
break;
}
default:
coordinates.add(topLeftCoordinate);
coordinates.add(new Coordinate(topLeftCoordinate.x,topLeftCoordinate.y+1));
coordinates.add(new Coordinate(topLeftCoordinate.x+1,topLeftCoordinate.y+1));
coordinates.add(new Coordinate(topLeftCoordinate.x+1,topLeftCoordinate.y+2));
System.out.println("ROTATED_270_INSTALLED");
}
}
@Override
List<Coordinate> getFigureMatrix() {
for (Coordinate coordinate : coordinates) {
coordinate.setState(StateConstants.FIGURE_Z);
}
return coordinates;
}
@Override
public String toString() {
return super.toString() + " Z";
}
@Override
public int getState() {
return StateConstants.FIGURE_Z;
}
}
| UTF-8 | Java | 1,985 | java | FigureZ.java | Java | [] | null | [] | package tetris.model.figure;
import tetris.model.coord.Coordinate;
import tetris.model.figure.state.RotationMode;
import tetris.model.figure.state.StateConstants;
import java.util.ArrayList;
import java.util.List;
public class FigureZ extends BaseFigure {
private List<Coordinate> coordinates = new ArrayList<>();
public FigureZ(Coordinate topLeftCoordinate, RotationMode rotationMode) {
super(topLeftCoordinate, rotationMode);
setFigureMatrix(topLeftCoordinate,rotationMode);
}
@Override
void setFigureMatrix(Coordinate topLeftCoordinate, RotationMode rotationMode) {
coordinates.clear();
switch (rotationMode) {
case ROTATED_180:
case NORMAL: {
coordinates.add(topLeftCoordinate);
coordinates.add(new Coordinate(topLeftCoordinate.x + 1, topLeftCoordinate.y));
coordinates.add(new Coordinate(topLeftCoordinate.x , topLeftCoordinate.y + 1));
coordinates.add(new Coordinate(topLeftCoordinate.x -1, topLeftCoordinate.y+1));
System.out.println("NORMAL_INSTALLED");
break;
}
default:
coordinates.add(topLeftCoordinate);
coordinates.add(new Coordinate(topLeftCoordinate.x,topLeftCoordinate.y+1));
coordinates.add(new Coordinate(topLeftCoordinate.x+1,topLeftCoordinate.y+1));
coordinates.add(new Coordinate(topLeftCoordinate.x+1,topLeftCoordinate.y+2));
System.out.println("ROTATED_270_INSTALLED");
}
}
@Override
List<Coordinate> getFigureMatrix() {
for (Coordinate coordinate : coordinates) {
coordinate.setState(StateConstants.FIGURE_Z);
}
return coordinates;
}
@Override
public String toString() {
return super.toString() + " Z";
}
@Override
public int getState() {
return StateConstants.FIGURE_Z;
}
}
| 1,985 | 0.649874 | 0.642317 | 58 | 33.224136 | 29.343414 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.603448 | false | false | 4 |
41df2372569beb2d2e62b437b5f17c49c4e8b0b9 | 6,871,947,707,753 | 58e3d284f0a6f52e071d9ac31285031eed647164 | /CheckSortedBetter.java | 202cb29e59a4c1f8b0d95ff615788fdfc561976f | [] | no_license | rakesh684/recursion | https://github.com/rakesh684/recursion | cf1d6977592cad47c14844d7f06fdbe1a85845cf | 6f8a0b62ccd9ff4e1d9d1d998fb796d2a09274fd | refs/heads/master | 2022-12-19T05:32:08.978000 | 2020-09-25T18:07:40 | 2020-09-25T18:07:40 | 297,869,300 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package recursion;
public class CheckSortedBetter {
public static boolean checkSorted(int arr[],int startIndex){
if(startIndex >= arr.length-1) {
return true;
}
if(arr[startIndex] > arr[startIndex + 1]) {
return false;
}
boolean smallAns = checkSorted(arr , startIndex + 1);
return smallAns;
}
public static void main(String[] args) {
int arr[] = {1,3,4,6,5};
System.out.println(checkSorted(arr,1));
}
}
| UTF-8 | Java | 437 | java | CheckSortedBetter.java | Java | [] | null | [] | package recursion;
public class CheckSortedBetter {
public static boolean checkSorted(int arr[],int startIndex){
if(startIndex >= arr.length-1) {
return true;
}
if(arr[startIndex] > arr[startIndex + 1]) {
return false;
}
boolean smallAns = checkSorted(arr , startIndex + 1);
return smallAns;
}
public static void main(String[] args) {
int arr[] = {1,3,4,6,5};
System.out.println(checkSorted(arr,1));
}
}
| 437 | 0.665904 | 0.645309 | 22 | 18.863636 | 19.447588 | 61 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.909091 | false | false | 4 |
2e3b79095bd8aba56c1cfa447fec7a07b836520b | 9,775,345,604,399 | aa4abdd8b8620695c4eabaae745eb21086d2775e | /Practice3/src/main/java/FiguresV3/Runner.java | 06c1a73ff79a8f2bb7e2fd0302c337a3c3e24ed5 | [] | no_license | chepiga-aleksandr/com.goto.gotojavaonline | https://github.com/chepiga-aleksandr/com.goto.gotojavaonline | a59b7e66ff671e3f0787268c57c2dd95b8eb40f0 | 553ff05c19184249ca95c609d5bdc33c1adf2338 | refs/heads/master | 2020-05-22T08:18:11.906000 | 2016-10-26T15:59:54 | 2016-10-26T15:59:54 | 61,022,609 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package FiguresV3;
import java.io.IOException;
public class Runner {
public static void main(String[] args) throws IOException {
ShapeUtil shape = new ShapeUtil();
Figure figure = shape.readConsole();
double calc = figure.calc();
System.out.println(calc);
}
}
| UTF-8 | Java | 305 | java | Runner.java | Java | [] | null | [] | package FiguresV3;
import java.io.IOException;
public class Runner {
public static void main(String[] args) throws IOException {
ShapeUtil shape = new ShapeUtil();
Figure figure = shape.readConsole();
double calc = figure.calc();
System.out.println(calc);
}
}
| 305 | 0.645902 | 0.642623 | 15 | 19.333334 | 19.94548 | 63 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 4 |
54527f4f8e232fd7db4f7449fad25e0f801b3aca | 26,190,710,622,162 | 488f4bc229589e3db954c023982ba664f6c6e374 | /MTool1.05/app/src/main/java/com/zzkx/mtool/view/iview/ICommentListView.java | 8d74166f8c995844f7de1a7c73170165a4e5eede | [] | no_license | harusty/MTool | https://github.com/harusty/MTool | d17c170afd50f24add6b2c10e5f01287990f9a25 | 2caaaf23c7f930243d4e24a8c0d8e67d4bcee788 | refs/heads/master | 2020-03-11T01:03:06.351000 | 2018-04-24T03:08:37 | 2018-04-24T03:08:37 | 129,679,950 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.zzkx.mtool.view.iview;
import java.util.List;
/**
* Created by sshss on 2017/9/27.
*/
public interface ICommentListView extends IView {
void showData(List<Object> bean);
}
| UTF-8 | Java | 193 | java | ICommentListView.java | Java | [
{
"context": ".iview;\n\nimport java.util.List;\n\n/**\n * Created by sshss on 2017/9/27.\n */\n\npublic interface ICommentListV",
"end": 83,
"score": 0.9996728897094727,
"start": 78,
"tag": "USERNAME",
"value": "sshss"
}
] | null | [] | package com.zzkx.mtool.view.iview;
import java.util.List;
/**
* Created by sshss on 2017/9/27.
*/
public interface ICommentListView extends IView {
void showData(List<Object> bean);
}
| 193 | 0.715026 | 0.678756 | 11 | 16.545454 | 17.854786 | 49 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 4 |
d37eda887225ebc06d984a848484d9b4e562eedf | 9,706,626,130,367 | e7f0e8da5003b2ae33d4ee26c7ed0f128239575c | /src/pl/czubak/patterns/strategy/SuperFlyingDuck.java | b3a579d6d207bd7b8a61acf88ef17b61e0bfc414 | [] | no_license | mczubak/design_patterns | https://github.com/mczubak/design_patterns | a5b4d0c5713c70dce0f65db5ecdebd177759c573 | 599f508ec31f105deacdd4cd034ca2469eb775ad | refs/heads/master | 2016-09-06T10:53:40.079000 | 2015-07-14T17:39:34 | 2015-07-14T17:39:34 | 28,933,303 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package pl.czubak.patterns.strategy;
public class SuperFlyingDuck implements Flyable {
@Override
public void fly() {
System.out.println("Yeah! I can super fly!");
}
}
| UTF-8 | Java | 189 | java | SuperFlyingDuck.java | Java | [] | null | [] | package pl.czubak.patterns.strategy;
public class SuperFlyingDuck implements Flyable {
@Override
public void fly() {
System.out.println("Yeah! I can super fly!");
}
}
| 189 | 0.671958 | 0.671958 | 9 | 20 | 20.08316 | 53 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.222222 | false | false | 4 |
6e0943154d7c5803c71170126ffe2f336e9a39d3 | 30,090,540,875,783 | 2de239dd0921adefaae42f5cddff37781e8c4293 | /agent-system/src/main/java/com/system/service/RoleResourceService.java | d5188c4d0dc3e116f39b5c86b10608d1d512701f | [] | no_license | lijiankangbazi/agent | https://github.com/lijiankangbazi/agent | 2b0323725acee8f4e33300f5643a2af2079558aa | 1b3230da42e4824b4bffa21f711c02331bde466a | refs/heads/master | 2017-11-15T19:36:21.754000 | 2017-11-15T11:56:30 | 2017-11-15T11:56:30 | 82,946,163 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.system.service;
import java.util.List;
import com.system.entity.RoleResource;
public interface RoleResourceService {
List<RoleResource> selectRoleResources(Integer roleId);
void doDeleteByRoleId(Integer roleId,Integer agentId);
void doInserRoleResource(RoleResource roleResource);
}
| UTF-8 | Java | 321 | java | RoleResourceService.java | Java | [] | null | [] | package com.system.service;
import java.util.List;
import com.system.entity.RoleResource;
public interface RoleResourceService {
List<RoleResource> selectRoleResources(Integer roleId);
void doDeleteByRoleId(Integer roleId,Integer agentId);
void doInserRoleResource(RoleResource roleResource);
}
| 321 | 0.778816 | 0.778816 | 14 | 20.928572 | 22.269339 | 56 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.928571 | false | false | 4 |
8038d902f7f01292c02356a6c0d9d9f59f265878 | 2,130,303,782,668 | cc89acef58c872f47e0651e9b6aafbe99f66779f | /workspace/Test/src/com/jh/io/CopyBytes.java | 18662abb5c4962e2a7b1da249ae70f15cb51fa54 | [] | no_license | libelosophy/anjoyo | https://github.com/libelosophy/anjoyo | 63ece81f67b8256abb8076b5c5fbd4dd7d948922 | cb61092486fd4912782106aa63805ff1fda8c8ea | refs/heads/master | 2021-01-17T05:58:17.153000 | 2013-09-13T09:32:42 | 2013-09-13T09:32:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.jh.io;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyBytes {
public static void main(String[] args) throws IOException {
// FileInputStream and FileOutputStream are all Byte streams
// 以一个整形的后 8 位存储
FileInputStream in = null;
FileOutputStream out = null;
StringBuffer str = new StringBuffer("");
// System.out.println(str);
char cc = 120;
System.out.println(cc);
for(int i = 0; i<255; i++){
System.out.print((char)i + "\t");
}
try {
in = new FileInputStream("xanadu.txt");
out = new FileOutputStream("outagain.txt");
int c;
for(int i = 0; i<255; i++){
System.out.print((char)i + "\t");
out.write(i);
//out.write((int)' ');
}
while ((c = in.read()) != -1) {
out.write(c);
str.append((char)c);
System.out.println("The next byte : " + (char)c +
"\n and its int num is :" + c );
System.out.println("String : " + str);
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
} | GB18030 | Java | 1,454 | java | CopyBytes.java | Java | [] | null | [] | package com.jh.io;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class CopyBytes {
public static void main(String[] args) throws IOException {
// FileInputStream and FileOutputStream are all Byte streams
// 以一个整形的后 8 位存储
FileInputStream in = null;
FileOutputStream out = null;
StringBuffer str = new StringBuffer("");
// System.out.println(str);
char cc = 120;
System.out.println(cc);
for(int i = 0; i<255; i++){
System.out.print((char)i + "\t");
}
try {
in = new FileInputStream("xanadu.txt");
out = new FileOutputStream("outagain.txt");
int c;
for(int i = 0; i<255; i++){
System.out.print((char)i + "\t");
out.write(i);
//out.write((int)' ');
}
while ((c = in.read()) != -1) {
out.write(c);
str.append((char)c);
System.out.println("The next byte : " + (char)c +
"\n and its int num is :" + c );
System.out.println("String : " + str);
}
} finally {
if (in != null) {
in.close();
}
if (out != null) {
out.close();
}
}
}
} | 1,454 | 0.449093 | 0.440028 | 51 | 27.137255 | 17.485029 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.72549 | false | false | 4 |
d0efc1a876d623186ad0788a7158e33aa452287e | 30,442,728,200,676 | 102796312a62ef20e44306888bcff4c4d2f43d56 | /day1/src/com/guyi/learn/ThreadTest/ThreadInstance.java | 2c3ed307c79e98ab0caa2b9e140666a50c75e4c2 | [
"MIT"
] | permissive | WGZCELL/Notes | https://github.com/WGZCELL/Notes | 994e713720c76ea0a8d38146a723d5953fcbe375 | 202cf177577a8f392660797514c539067f4c2893 | refs/heads/master | 2023-01-21T07:22:00.027000 | 2020-11-24T15:59:42 | 2020-11-24T15:59:42 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.guyi.learn.ThreadTest;
/**
* 三个窗口抢票,有线程安全问题
*/
public class ThreadInstance {
public static void main(String[] args) {
Window w1 = new Window();
Window w2 = new Window();
Window w3 = new Window();
w1.setName("窗口一");
w2.setName("窗口二");
w3.setName("窗口三");
w1.start();
w2.start();
w3.start();
// ----------------------------------------------
Window1 wv = new Window1();
Thread w4 = new Thread(wv);
Thread w5 = new Thread(wv);
Thread w6 = new Thread(wv);
w4.setName("窗口一");
w5.setName("窗口二");
w6.setName("窗口三");
w4.start();
w5.start();
w6.start();
}
}
class Window extends Thread{
private static int ticket = 100;
@Override
public void run() {
while(true){
if (ticket > 0){
System.out.println(getName() + "买票,票号为: " + ticket);
ticket--;
}else{
break;
}
}
}
}
class Window1 implements Runnable{
private int ticket = 100;
@Override
public void run() {
while(true){
if (ticket > 0){
System.out.println(Thread.currentThread().getName() + "买票,票号为: " + ticket);
ticket--;
}else {
break;
}
}
}
} | UTF-8 | Java | 1,496 | java | ThreadInstance.java | Java | [] | null | [] | package com.guyi.learn.ThreadTest;
/**
* 三个窗口抢票,有线程安全问题
*/
public class ThreadInstance {
public static void main(String[] args) {
Window w1 = new Window();
Window w2 = new Window();
Window w3 = new Window();
w1.setName("窗口一");
w2.setName("窗口二");
w3.setName("窗口三");
w1.start();
w2.start();
w3.start();
// ----------------------------------------------
Window1 wv = new Window1();
Thread w4 = new Thread(wv);
Thread w5 = new Thread(wv);
Thread w6 = new Thread(wv);
w4.setName("窗口一");
w5.setName("窗口二");
w6.setName("窗口三");
w4.start();
w5.start();
w6.start();
}
}
class Window extends Thread{
private static int ticket = 100;
@Override
public void run() {
while(true){
if (ticket > 0){
System.out.println(getName() + "买票,票号为: " + ticket);
ticket--;
}else{
break;
}
}
}
}
class Window1 implements Runnable{
private int ticket = 100;
@Override
public void run() {
while(true){
if (ticket > 0){
System.out.println(Thread.currentThread().getName() + "买票,票号为: " + ticket);
ticket--;
}else {
break;
}
}
}
} | 1,496 | 0.448791 | 0.428165 | 65 | 20.646154 | 16.772167 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.446154 | false | false | 4 |
e92cba044e8ac057476ec02cbca4ef65437f37b3 | 15,951,508,541,019 | 08c98a91d9cc79e4e0ec4cc45143946e8c57e1a8 | /Pathfinder/Pathfinder.java | 254bf3b0bccb3df7baacbd1eae7b892f45ea71e6 | [] | no_license | hanks42/AstarPathfinder | https://github.com/hanks42/AstarPathfinder | 10843e54799f297e42a094c6da6b3d2ab90b5bfc | 6aa62493890e906e112549dce593705a6ece0abd | refs/heads/master | 2016-09-09T22:26:14.358000 | 2014-10-28T21:44:30 | 2014-10-28T21:44:30 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /**
* This is the pathfinder program, it is a program that reads in a square grid map from
* a map file and then uses the A* pathfinding algorithm to find a path between the requested
* start and end points in the map
*
* @author Jonathan Hanks (jonhanks@gmail.com)
* @version 1.0
*
*/
public class Pathfinder {
/**
* @param args
*/
public static void main(String[] args)
{
GridMap myGM = new GridMap();
// initialize the gridmap with the data from the map file
myGM.Init("Map.txt");
// perform the A* search over the map
myGM.performAStarSearch("Results.txt");
}
}
| UTF-8 | Java | 602 | java | Pathfinder.java | Java | [
{
"context": "\n * start and end points in the map\n * \n * @author Jonathan Hanks (jonhanks@gmail.com)\n * @version 1.0\n *\n */\npubli",
"end": 250,
"score": 0.9998775124549866,
"start": 236,
"tag": "NAME",
"value": "Jonathan Hanks"
},
{
"context": " points in the map\n * \n * @author Jonathan Hanks (jonhanks@gmail.com)\n * @version 1.0\n *\n */\npublic class Pathfinder {",
"end": 270,
"score": 0.9999328255653381,
"start": 252,
"tag": "EMAIL",
"value": "jonhanks@gmail.com"
}
] | null | [] | /**
* This is the pathfinder program, it is a program that reads in a square grid map from
* a map file and then uses the A* pathfinding algorithm to find a path between the requested
* start and end points in the map
*
* @author <NAME> (<EMAIL>)
* @version 1.0
*
*/
public class Pathfinder {
/**
* @param args
*/
public static void main(String[] args)
{
GridMap myGM = new GridMap();
// initialize the gridmap with the data from the map file
myGM.Init("Map.txt");
// perform the A* search over the map
myGM.performAStarSearch("Results.txt");
}
}
| 583 | 0.677741 | 0.674419 | 26 | 22.153847 | 26.060125 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.923077 | false | false | 4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.