blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 7 410 | content_id stringlengths 40 40 | detected_licenses listlengths 0 51 | license_type stringclasses 2
values | repo_name stringlengths 5 132 | snapshot_id stringlengths 40 40 | revision_id stringlengths 40 40 | branch_name stringlengths 4 80 | visit_date timestamp[us] | revision_date timestamp[us] | committer_date timestamp[us] | github_id int64 5.85k 684M ⌀ | star_events_count int64 0 209k | fork_events_count int64 0 110k | gha_license_id stringclasses 22
values | gha_event_created_at timestamp[us] | gha_created_at timestamp[us] | gha_language stringclasses 132
values | src_encoding stringclasses 34
values | language stringclasses 1
value | is_vendor bool 1
class | is_generated bool 2
classes | length_bytes int64 3 9.45M | extension stringclasses 28
values | content stringlengths 3 9.45M | authors listlengths 1 1 | author_id stringlengths 0 352 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
63f428dce39e8f0233c4ae9a4edd52a7f028cfec | b33be863c1a67a4a8658fa957f430f2bab63d588 | /src/main/java/com/autobotstech/cyzk/adapter/stickygridheaders/StickyGridHeadersSimpleAdapter.java | c27fa3cb3b6054896ad7d3eb001d1b558d53677b | [] | no_license | zhilee2008/autobotstech | 80624c429a6f753abf415e7e199f4a0ef0523154 | 88b183987b0b21bd4609b139b92a7492175324c6 | refs/heads/master | 2021-05-23T05:25:10.994409 | 2018-03-22T04:24:03 | 2018-03-22T04:24:03 | 95,187,239 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,370 | java | /*
Copyright 2013 Tonic Artos
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.autobotstech.cyzk.adapter.stickygridheaders;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListAdapter;
/**
* Adapter interface for StickyGridHeadersGridView. The adapter expects two sets
* of data, items, and headers. Implement this interface to provide an optimised
* method for generating the header data set.
* <p>
* The is a second interface
* {@link com.autobotstech.cyzk.adapter.stickygridheaders.StickyGridHeadersBaseAdapter}.
*
* @author Tonic Artos
*/
public interface StickyGridHeadersSimpleAdapter extends ListAdapter {
/**
* Get the header id associated with the specified position in the list.
*
* @param position The position of the item within the adapter's data set whose
* header id we want.
* @return The id of the header at the specified position.
*/
long getHeaderId(int position);
/**
* Get a View that displays the header data at the specified position in the
* set. You can either create a View manually or inflate it from an XML
* layout file.
*
* @param position The position of the header within the adapter's header data
* set.
* @param convertView The old view to reuse, if possible. Note: You should check
* that this view is non-null and of an appropriate type before
* using. If it is not possible to convert this view to display
* the correct data, this method can create a new view.
* @param parent The parent that this view will eventually be attached to.
* @return A View corresponding to the data at the specified position.
*/
View getHeaderView(int position, View convertView, ViewGroup parent);
}
| [
"bjlizhi@cn.ibm.com"
] | bjlizhi@cn.ibm.com |
85ecf622f9acbd7c7263d747c0d6725acc07087b | 590b41d7116d78cda4b41a6787ec520d3eb5ffa3 | /src/newone/HelloWorld.java | 06590b4b331ad804762855089d8b6b3ba9daf39e | [] | no_license | Jeremy-april/20200511_HelleWorld | d027c13233debbe4b49f734876ae99f6def2ac8e | 10bb8c7c37457daa5ae63f28af6a7826da16e4fd | refs/heads/master | 2022-07-28T14:02:14.040585 | 2020-05-15T10:44:44 | 2020-05-15T10:44:44 | 264,167,988 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 846 | java | package newone;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Date;
public class HelloWorld {
private static int num;
public static void main(String[] args) {
System.out.println("hellowored!");
ArrayList listnew = new ArrayList();
Date date = new Date();
// listnew.add(1);
// ddfd();
//
/*=*/ /*System.arraycopy();
System.arraycopy();
System.arraycopy();*/
}
//region Description
public static void ddfd(){
int a = 12;
num = 10;
System.out.println("Person1");
try {
FileInputStream fis = new FileInputStream("hello2.txt");
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}
//endregion
}
//单行注释
/*
多行注释
*/ | [
"591291582@qq.com"
] | 591291582@qq.com |
c21a2cec855d4caaa926ec6e05bd5a611e91ce2f | f4e3b1c2b2c5c860a1ca3a5eefc406f43f0b9787 | /src/Figura/PruebaFiguras.java | 581ab0112f9edc2098ae14530e8269374abcc90e | [] | no_license | alber87/programacion | ed8e2351ad87020fc84a3184029e5be29a45df46 | 370c995008a1e44d7c730fab30c587130c3399f0 | refs/heads/master | 2020-03-08T14:36:43.177193 | 2018-04-19T18:42:14 | 2018-04-19T18:42:14 | 128,123,290 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,815 | java |
package Figura;
import java.util.Scanner;
import java.util.InputMismatchException;
public class PruebaFiguras {
@SuppressWarnings("SuspiciousIndentAfterControlStatement")
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean salir = false;
int opcion;
Figura ultFigura = null;
while(!salir){
System.out.println("1. Crear Rectángulo");
System.out.println("2. Crear Cuadrado");
System.out.println("3. Crear Triángulo");
System.out.println("4. Ver Figura");
System.out.println("5. Salir");
try{
System.out.print("\nElige la opción deseada: ");
opcion = sc.nextInt();
switch(opcion){
case 1:
System.out.print("Introduce la base: ");
double base = sc.nextDouble();
System.out.print("Introduce la altura: ");
double altura = sc.nextDouble();
Rectangulo r = new Rectangulo(base, altura);
ultFigura = r;
break;
case 2:
System.out.print("Introduce el lado del cuadrado: ");
double lado = sc.nextDouble();
Cuadrado c = new Cuadrado(lado);
ultFigura = c;
break;
case 3:
System.out.print("Introduce el lado del triangulo: ");
double cateto = sc.nextDouble();
Triangulo t = new TrianguloRectangulo(cateto);
ultFigura = t;
break;
case 4:
if(ultFigura == null){
System.out.println("No se ha creado aún ninguna figura.");
}
else{
System.out.println(ultFigura.devNombFigura());
ultFigura.dibujarFigura();
System.out.println(ultFigura.devArea());
System.out.println(ultFigura.devPerimetro());
}
break;
case 5:
salir = true;
break;
default:
System.out.println("Solo números del 1 al 5.");
}
}catch(InputMismatchException e){
System.out.println("Introduce solamente números.");
sc.next();
}
}
}
}
| [
"albertorodriguezochandio@gmail.com"
] | albertorodriguezochandio@gmail.com |
e251a360980b4a35728f49d1606f17e22ad2e533 | c05b1d3993b23e13f62b6fb7289de1ff8460db4b | /src/com/섬나라아일랜드_DFS/Main.java | 4e726853bf9e3d46553a4aee75cc288d9f0eb510 | [] | no_license | Sangbeen-dev/Algorithm_Recursive-Tree-Graph_DFS_BFS | 6c765a0f7b45ff4844c547bf26b0161f680d31b3 | 87235f3f12652f84f8fc32d39fd605d2e88da263 | refs/heads/master | 2023-06-13T23:19:24.746179 | 2021-07-21T09:40:51 | 2021-07-21T09:40:51 | 380,778,858 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 956 | java | package com.섬나라아일랜드_DFS;
import java.util.Scanner;
public class Main {
static int answer=0, n;
static int[][] arr;
static int[] dx = {-1, -1, 0, 1, 1, 1, 0, -1};
static int[] dy = {0, 1, 1, 1, 0, -1, -1, -1};
public void DFS(int x, int y, int[][] arr) {
for (int i = 0; i < 8; i++) {
int nx = x+dx[i];
int ny = y+dy[i];
if(nx>=0 && nx<n && ny>=0 && ny<n && arr[nx][ny]==1) {
arr[nx][ny]=0;
DFS(nx, ny, arr);
}
}
}
public void solution(int[][] arr) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if(arr[i][j]==1) {
answer++;
arr[i][j]=0;
DFS(i, j, arr);
}
}
}
}
public static void main(String[] args) {
Main t = new Main();
Scanner kb = new Scanner(System.in);
n = kb.nextInt();
arr = new int[n][n];
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++) {
arr[i][j] = kb.nextInt();
}
}
t.solution(arr);
System.out.println(answer);
}
}
| [
"tkdqls960@naver.com"
] | tkdqls960@naver.com |
ef087c59b1698837e957ef6ae0b977b51dd0b052 | 26e611565ce0e9eed154caaf6548a281a829d356 | /onvif-ws-client/src/main/java/org/onvif/ver10/recording/wsdl/ExportRecordedDataResponse.java | 4395949b2fc71fff29614ab5b81cd3006c5611ea | [
"Apache-2.0"
] | permissive | doniexun/onvif-1 | ecb366070dca73781c7baf3b9bcff94dd68001f5 | ff9839c099e5f81d877a1753598a508c5c0bfc6b | refs/heads/master | 2020-05-27T09:14:42.784064 | 2017-12-20T18:15:59 | 2017-12-20T18:15:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,356 | java |
package org.onvif.ver10.recording.wsdl;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import org.w3c.dom.Element;
/**
* <p>Classe Java per anonymous complex type.
*
* <p>Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="OperationToken" type="{http://www.onvif.org/ver10/schema}ReferenceToken"/>
* <element name="FileNames" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
* <element name="Extension" minOccurs="0">
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any processContents='lax'/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </element>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"operationToken",
"fileNames",
"extension"
})
@XmlRootElement(name = "ExportRecordedDataResponse")
public class ExportRecordedDataResponse {
@XmlElement(name = "OperationToken", required = true)
protected String operationToken;
@XmlElement(name = "FileNames")
protected List<String> fileNames;
@XmlElement(name = "Extension")
protected ExportRecordedDataResponse.Extension extension;
/**
* Recupera il valore della proprietà operationToken.
*
* @return
* possible object is
* {@link String }
*
*/
public String getOperationToken() {
return operationToken;
}
/**
* Imposta il valore della proprietà operationToken.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setOperationToken(String value) {
this.operationToken = value;
}
/**
* Gets the value of the fileNames property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the fileNames property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getFileNames().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
public List<String> getFileNames() {
if (fileNames == null) {
fileNames = new ArrayList<String>();
}
return this.fileNames;
}
/**
* Recupera il valore della proprietà extension.
*
* @return
* possible object is
* {@link ExportRecordedDataResponse.Extension }
*
*/
public ExportRecordedDataResponse.Extension getExtension() {
return extension;
}
/**
* Imposta il valore della proprietà extension.
*
* @param value
* allowed object is
* {@link ExportRecordedDataResponse.Extension }
*
*/
public void setExtension(ExportRecordedDataResponse.Extension value) {
this.extension = value;
}
/**
* <p>Classe Java per anonymous complex type.
*
* <p>Il seguente frammento di schema specifica il contenuto previsto contenuto in questa classe.
*
* <pre>
* <complexType>
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <any processContents='lax'/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"any"
})
public static class Extension {
@XmlAnyElement(lax = true)
protected Object any;
/**
* Recupera il valore della proprietà any.
*
* @return
* possible object is
* {@link Element }
* {@link Object }
*
*/
public Object getAny() {
return any;
}
/**
* Imposta il valore della proprietà any.
*
* @param value
* allowed object is
* {@link Element }
* {@link Object }
*
*/
public void setAny(Object value) {
this.any = value;
}
}
}
| [
"f.pompermaier@gmail.com"
] | f.pompermaier@gmail.com |
7ce0745f814eef25401b157b274d135c347e051e | 5a1d6752ef215efaddf6b55e1bb88c0575d3d7cd | /erp/app.contractmanagement/domain/src/main/java/org/flowframe/erp/app/contractmanagement/domain/CustomSubscriptionPlan.java | 02304a6d6610cbfe678cb2e7a1be8419739e94f0 | [] | no_license | mduduzik/flowframe | 5849eddfed53a82e65f6d1e815db0ba2cc85e263 | 71245bf70688a08cf91a6b105fd8aae62cdab2ab | refs/heads/master | 2021-01-20T05:49:44.876366 | 2013-08-05T02:11:54 | 2013-08-05T02:11:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 502 | java | package org.flowframe.erp.app.contractmanagement.domain;
import javax.persistence.Entity;
import javax.persistence.ManyToOne;
@Entity
public class CustomSubscriptionPlan extends SubscriptionPlan {
@ManyToOne
private Customer tenant;
public Customer getTenant() {
return tenant;
}
public void setTenant(Customer tenant) {
this.tenant = tenant;
}
public CustomSubscriptionPlan() {
super();
}
public CustomSubscriptionPlan(Customer tenant) {
super();
this.tenant = tenant;
}
}
| [
"mduduzi.keswa@bconv.com"
] | mduduzi.keswa@bconv.com |
33c88edf03d17d199d7fbb83c9682975ff102075 | b9eeda66337c934252a392f13f6fb139365b99a1 | /src/main/java/br/com/atuafinanceira/atuafinanceira/model/UserLogin.java | 1d48a4b9a843f5b991cdb554067e60979130e1ff | [] | no_license | NatyDuarte/AtuaFin | 93ff60335dfdaff8e3e280b1b775c490e68ee43f | bab141a662c412d68ef901227638cca8df567502 | refs/heads/master | 2023-05-01T05:51:14.562888 | 2021-05-20T19:30:21 | 2021-05-20T19:30:21 | 369,316,944 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 644 | java | package br.com.atuafinanceira.atuafinanceira.model;
public class UserLogin {
private String nome;
private String usuario;
private String senha;
private String token;
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
}
| [
"natacha96@hotmail.com"
] | natacha96@hotmail.com |
2380c8b3a068fe1e29c98f1bade51eb47fb98b4f | d07304a99b4637b919eb4e91fafb7dc34ccc0f41 | /src/main/java/de/tu_darmstadt/stud/lukas/marckmiller/pki/bonus/task4/Task4.java | 1cb5a742fb488c5a0db2ba7f71f5facc3f33728e | [] | no_license | LukasMarckmiller/PKI_2020_Exc | 3af3287e4c42b71ee089b05a3369b67671bd56fc | 6f073cc263ef6639899a70c82c3da7a113be9802 | refs/heads/master | 2022-11-16T00:42:13.933078 | 2020-07-04T16:32:21 | 2020-07-04T16:32:21 | 265,233,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,810 | java | package de.tu_darmstadt.stud.lukas.marckmiller.pki.bonus.task4;
import de.tu_darmstadt.stud.lukas.marckmiller.pki.bonus.utils.CryptoUtilsProvider;
import org.bouncycastle.asn1.x500.X500Name;
import org.bouncycastle.asn1.x500.X500NameBuilder;
import org.bouncycastle.asn1.x500.style.BCStyle;
import org.bouncycastle.asn1.x509.*;
import org.bouncycastle.cert.HybridCertificateBuilder;
import org.bouncycastle.cert.X509CertificateHolder;
import org.bouncycastle.crypto.AsymmetricCipherKeyPair;
import org.bouncycastle.openssl.jcajce.JcaMiscPEMGenerator;
import org.bouncycastle.operator.OperatorCreationException;
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
import org.bouncycastle.pqc.crypto.qtesla.*;
import org.bouncycastle.util.io.pem.PemObjectGenerator;
import org.bouncycastle.util.io.pem.PemWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.util.Calendar;
import java.util.Date;
public class Task4 extends CryptoUtilsProvider{
private final String CAPublicKeyPath = "/home/lukas/Dokumente/tu/pki/ca/caPub.pem";
private final String CAPrivateKeyPath = "/home/lukas/Dokumente/tu/pki/ca/ca.pem";
private final String CAQteslaPublicKeyPath = "/home/lukas/Dokumente/tu/pki/1.qteslaPub";
private final String CAQteslaPrivateKeyPath = "/home/lukas/Dokumente/tu/pki/1.qtesla";
private final String EEPublicKeyPath = "/home/lukas/Dokumente/tu/pki/ee/eePub.pem";
private final String EEPrivateKeyPath = "/home/lukas/Dokumente/tu/pki/ee/ee.pem";
private final String EEQteslaPublicKeyPath = "/home/lukas/Dokumente/tu/pki/2.qteslaPub";
private final String EEQteslaPrivateKeyPath = "/home/lukas/Dokumente/tu/pki/2.qtesla";
private static final String signatureAlgorithm = "SHA256WithRSA";
private X509CertificateHolder generateX509HybridEECertificate(X509CertificateHolder caCert) throws
NoSuchAlgorithmException,
NoSuchProviderException,
InvalidKeySpecException,
IOException,
OperatorCreationException {
var x500NameBuilder = new X500NameBuilder();
x500NameBuilder.addRDN(BCStyle.C,"DE")
.addRDN(BCStyle.ST, "Hessen")
.addRDN(BCStyle.L, "Darmstadt")
.addRDN(BCStyle.O,"TU Darmstadt")
.addRDN(BCStyle.OU,"PKI")
.addRDN(BCStyle.CN,"E6");
RSAPublicKey publicEEKey= importRsaPublicKey(EEPublicKeyPath);
Date now = new Date(System.currentTimeMillis());
Calendar notBefor = Calendar.getInstance();
notBefor.setTime(now);
notBefor.add(Calendar.MONTH,-1);
Calendar notAfter = Calendar.getInstance();
notAfter.setTime(now);
notAfter.add(Calendar.MONTH,3);
HybridCertificateBuilder builder = new HybridCertificateBuilder(
caCert.getSubject(),
new BigInteger(String.valueOf(System.currentTimeMillis())),
notBefor.getTime(),
notAfter.getTime(),
x500NameBuilder.build(),
publicEEKey,
importQteslaPublicKey(EEQteslaPublicKeyPath));
builder.addExtension(Extension.authorityKeyIdentifier,false,
new AuthorityKeyIdentifier(
hash("SHA-1", caCert.getSubjectPublicKeyInfo().getPublicKeyData().getBytes()),
new GeneralNames(new GeneralName(GeneralName.directoryName,caCert.getIssuer())),caCert.getSerialNumber()));
builder.addExtension(Extension.basicConstraints,false,new BasicConstraints(false));
builder.addExtension(Extension.subjectAlternativeName,false,new GeneralNames(new GeneralName(GeneralName.rfc822Name, "fDqi5sU062iLUOLfW+IcR27ASASEipF75YkCBEaZge8=")));
builder.addExtension(Extension.keyUsage, true, new KeyUsage(KeyUsage.digitalSignature));
var signerPrimary = new JcaContentSignerBuilder(signatureAlgorithm).build(importRsaPrivateKey(CAPrivateKeyPath));
var signerSecondary = new QTESLAContentSigner(importQteslaPrivateKey(CAQteslaPrivateKeyPath));
return builder.buildHybrid(signerPrimary,signerSecondary);
}
private X509CertificateHolder generateX509HybridCACertificate() throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException, IOException, OperatorCreationException {
X500Name x500Name = getCAX500Name();
Date now = new Date(System.currentTimeMillis());
Calendar notBefore = Calendar.getInstance();
notBefore.setTime(now);
notBefore.add(Calendar.MONTH,-1);
Calendar notAfter = Calendar.getInstance();
notAfter.setTime(now);
notAfter.add(Calendar.MONTH,2);
RSAPublicKey publicKey = importRsaPublicKey(CAPublicKeyPath);
var builder = new HybridCertificateBuilder(
x500Name,
new BigInteger(String.valueOf(System.currentTimeMillis())),
notBefore.getTime(),
notAfter.getTime(),
x500Name,
publicKey,
importQteslaPublicKey(CAQteslaPublicKeyPath)
);
builder.addExtension(Extension.subjectKeyIdentifier,false,
new SubjectKeyIdentifier(hash("SHA-1",
SubjectPublicKeyInfo.getInstance(publicKey.getEncoded()).getPublicKeyData().getBytes())));
builder.addExtension(Extension.basicConstraints,true,new BasicConstraints(true));
builder.addExtension(Extension.keyUsage,true,new KeyUsage(KeyUsage.keyCertSign | KeyUsage.cRLSign));
var signerPrimary = new JcaContentSignerBuilder(signatureAlgorithm).build(importRsaPrivateKey(CAPrivateKeyPath));
var signerSecondary = new QTESLAContentSigner(importQteslaPrivateKey(CAQteslaPrivateKeyPath));
return builder.buildHybrid(signerPrimary,signerSecondary);
}
private void generateQTeslaKeyPair(String outPath, int keyCount){
for (int i = 0; i < keyCount; i++){
var keyPairGenerator = new QTESLAKeyPairGenerator();
var qteslaGenParams = new QTESLAKeyGenerationParameters(QTESLASecurityCategory.PROVABLY_SECURE_I,new SecureRandom());
keyPairGenerator.init(qteslaGenParams);
AsymmetricCipherKeyPair qTeslaPair = keyPairGenerator.generateKeyPair();
QTESLAPrivateKeyParameters privKey = (QTESLAPrivateKeyParameters) qTeslaPair.getPrivate();
QTESLAPublicKeyParameters pubKey = (QTESLAPublicKeyParameters) qTeslaPair.getPublic();
try (FileWriter pemWriter = new FileWriter(outPath + (i+1) + ".qtesla")) {
pemWriter.write(
CryptoUtilsProvider.base64Encode(
CryptoUtilsProvider.convertToBytes(
new QTESLAPrivateKeyWrapper(privKey))));
pemWriter.flush();
} catch (IOException e) {
e.printStackTrace();
}
try (FileWriter pemWriter = new FileWriter(outPath + (i+1) + ".qteslaPub")) {
pemWriter.write(
CryptoUtilsProvider.base64Encode(
CryptoUtilsProvider.convertToBytes(
new QTESLAPublicKeyWrapper(pubKey))));
pemWriter.flush();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public void mainTask() {
//generateQTeslaKeyPair("/home/lukas/Dokumente/tu/pki/",2);
X509CertificateHolder caCert = null;
try {
caCert = generateX509HybridCACertificate();
} catch (NoSuchAlgorithmException | NoSuchProviderException | InvalidKeySpecException | IOException | OperatorCreationException e) {
e.printStackTrace();
}
try(PemWriter writer = new PemWriter(new FileWriter("CAcert_CA6.crt"))) {
PemObjectGenerator objectGenerator = new JcaMiscPEMGenerator(caCert);
writer.writeObject(objectGenerator);
} catch (IOException e) {
e.printStackTrace();
}
try(PemWriter writer = new PemWriter(new FileWriter("EEcert_E6.crt"))) {
PemObjectGenerator objectGenerator = new JcaMiscPEMGenerator(generateX509HybridEECertificate(caCert));
writer.writeObject(objectGenerator);
} catch (IOException | InvalidKeySpecException | OperatorCreationException | NoSuchProviderException | NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
}
| [
"lmarckmiller@gmail.com"
] | lmarckmiller@gmail.com |
474da96e0b99dd17c7bcb0c59744713537cd8b92 | f01c8fe3681ce98fc63d34cd8b927b9c95edb3a0 | /bcm-login/src/main/java/cn/com/unary/bcm/login/pojo/RegCodeInfo.java | b17f9d916b93189847159244def16a4073a8b8b1 | [] | no_license | lwgboy/online-register | 36f88c669bf0f409ea7b51dab2327d7cc15ae93b | c5f52d8016284de25f03f96ea1621575a6e15597 | refs/heads/master | 2020-06-14T04:04:43.889919 | 2018-11-08T08:21:38 | 2018-11-08T08:21:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,534 | java | package cn.com.unary.bcm.login.pojo;
/**
* Created by Administrator on 2018/10/17.
*/
public class RegCodeInfo {
private int id;
private String name;
private String mobile;
private String email;
private String location;
private String validPeriod;
private boolean active;
private String registrationCode;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getMobile() {
return mobile;
}
public void setMobile(String mobile) {
this.mobile = mobile;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getValidPeriod() {
return validPeriod;
}
public void setValidPeriod(String validPeriod) {
this.validPeriod = validPeriod;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public String getRegistrationCode() {
return registrationCode;
}
public void setRegistrationCode(String registrationCode) {
this.registrationCode = registrationCode;
}
}
| [
"15850546725@163.com"
] | 15850546725@163.com |
dcd92276475dbba503da76a33dbd6ab12f5f8dd1 | e7109987b069c11bb2d07092e7559f43ab43096b | /src/main/java/com/cainiao/manage/web/user/UserController.java | 39a5146527f994db5c660f728d70c87c82fd94a6 | [] | no_license | fanrencainiao/cainiao-manage | 4883f2e1c3ee5712d6e3a257132c3789797f9c56 | 20a4e4e8800b540cd1c638ecad9e17d0bf42e5c2 | refs/heads/master | 2022-02-21T17:38:55.879059 | 2019-09-05T03:39:08 | 2019-09-05T03:39:08 | 203,762,083 | 1 | 0 | null | 2022-02-09T22:18:26 | 2019-08-22T09:34:28 | JavaScript | UTF-8 | Java | false | false | 31,491 | java | package com.cainiao.manage.web.user;
import com.cainiao.manage.common.DateUtil;
import com.cainiao.manage.common.ValidateUtil;
import com.cainiao.manage.entity.ResponseResult;
import com.cainiao.manage.entity.UserDTO;
import com.cainiao.manage.entity.UserRolesVO;
import com.cainiao.manage.entity.UserSearchDTO;
import com.cainiao.manage.pojo.Role;
import com.cainiao.manage.pojo.User;
import com.cainiao.manage.service.AuthService;
import com.cainiao.manage.service.UserService;
import com.cainiao.manage.utils.IStatusMessage;
import com.cainiao.manage.utils.PageDataResult;
import net.sf.oval.ConstraintViolation;
import net.sf.oval.Validator;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.ehcache.EhCacheManager;
import org.apache.shiro.subject.Subject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.text.ParseException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @项目名称:cainiao-manage
* @包名:com.cainiao.manage.web.user
* @类描述:
* @创建人:cainiao
* @version:V1.0
*/
@Controller
@RequestMapping("/user")
public class UserController {
private static final Logger logger = LoggerFactory
.getLogger(UserController.class);
@Autowired
private UserService userService;
@Autowired
private AuthService authService;
@Autowired
private EhCacheManager ecm;
//private static final Pattern MOBILE_PATTERN = Pattern.compile("^1\\d{10}$");
@RequestMapping("/userList")
public String toUserList() {
return "/auth/userList";
}
/**
* 分页查询用户列表
* @return ok/fail
*/
@RequestMapping(value = "/getUsers", method = RequestMethod.POST)
@ResponseBody
@RequiresPermissions(value = "usermanage")
public PageDataResult getUsers(@RequestParam("page") Integer page,
@RequestParam("limit") Integer limit, UserSearchDTO userSearch) {
logger.debug("分页查询用户列表!搜索条件:userSearch:" + userSearch + ",page:" + page
+ ",每页记录数量limit:" + limit);
PageDataResult pdr = new PageDataResult();
try {
if (null == page) {
page = 1;
}
if (null == limit) {
limit = 10;
}
// 获取用户和角色列表
pdr = userService.getUsers(userSearch, page, limit);
logger.debug("用户列表查询=pdr:" + pdr);
} catch (Exception e) {
e.printStackTrace();
logger.error("用户列表查询异常!", e);
}
return pdr;
}
/**
* 设置用户是否离职
* @return ok/fail
*/
@RequestMapping(value = "/setJobUser", method = RequestMethod.POST)
@ResponseBody
public String setJobUser(@RequestParam("id") Integer id,
@RequestParam("job") Integer isJob,
@RequestParam("version") Integer version) {
logger.debug("设置用户是否离职!id:" + id + ",isJob:" + isJob + ",version:"
+ version);
String msg = "";
try {
if (null == id || null == isJob || null == version) {
logger.debug("设置用户是否离职,结果=请求参数有误,请您稍后再试");
return "请求参数有误,请您稍后再试";
}
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
logger.debug("设置用户是否离职,结果=您未登录或登录超时,请您登录后再试");
return "您未登录或登录超时,请您登录后再试";
}
// 设置用户是否离职
msg = userService.setJobUser(id, isJob, existUser.getId(),version);
logger.info("设置用户是否离职成功!userID=" + id + ",isJob:" + isJob
+ ",操作的用户ID=" + existUser.getId());
} catch (Exception e) {
e.printStackTrace();
logger.error("设置用户是否离职异常!", e);
msg = "操作异常,请您稍后再试!";
}
return msg;
}
/**
* 设置用户[新增或更新]
* @return ok/fail
*/
@RequestMapping(value = "/setUser", method = RequestMethod.POST)
@ResponseBody
public String setUser(@RequestParam("roleIds") String roleIds, User user) {
logger.debug("设置用户[新增或更新]!user:" + user + ",roleIds:" + roleIds);
try {
if (null == user) {
logger.debug("置用户[新增或更新],结果=请您填写用户信息");
return "请您填写用户信息";
}
if (StringUtils.isEmpty(roleIds)) {
logger.debug("置用户[新增或更新],结果=请您给用户设置角色");
return "请您给用户设置角色";
}
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
logger.debug("置用户[新增或更新],结果=您未登录或登录超时,请您登录后再试");
return "您未登录或登录超时,请您登录后再试";
}
user.setInsertUid(existUser.getId());
// 设置用户[新增或更新]
logger.info("设置用户[新增或更新]成功!user=" + user + ",roleIds=" + roleIds
+ ",操作的用户ID=" + existUser.getId());
return userService.setUser(user, roleIds);
} catch (Exception e) {
e.printStackTrace();
logger.error("设置用户[新增或更新]异常!", e);
return "操作异常,请您稍后再试";
}
}
/**
* 删除用户
* @return ok/fail
*/
@RequestMapping(value = "/delUser", method = RequestMethod.POST)
@ResponseBody
public String delUser(@RequestParam("id") Integer id,
@RequestParam("version") Integer version) {
logger.debug("删除用户!id:" + id + ",version:" + version);
String msg = "";
try {
if (null == id || null == version) {
logger.debug("删除用户,结果=请求参数有误,请您稍后再试");
return "请求参数有误,请您稍后再试";
}
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
logger.debug("删除用户,结果=您未登录或登录超时,请您登录后再试");
return "您未登录或登录超时,请您登录后再试";
}
// 删除用户
msg = userService.setDelUser(id, 1, existUser.getId(), version);
logger.info("删除用户:" + msg + "!userId=" + id + ",操作用户id:"
+ existUser.getId() + ",version:" + version);
} catch (Exception e) {
e.printStackTrace();
logger.error("删除用户异常!", e);
msg = "操作异常,请您稍后再试";
}
return msg;
}
/**
*
* @描述:恢复用户
* @创建人:wyait
* @创建时间:2018年4月27日 上午9:49:14
* @param id
* @return
*/
@RequestMapping(value = "/recoverUser", method = RequestMethod.POST)
@ResponseBody
public String recoverUser(@RequestParam("id") Integer id,
@RequestParam("version") Integer version) {
logger.debug("恢复用户!id:" + id + ",version:" + version);
String msg = "";
try {
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
return "您未登录或登录超时,请您登录后再试";
}
if (null == id || null == version) {
return "请求参数有误,请您稍后再试";
}
// 删除用户
msg = userService.setDelUser(id, 0, existUser.getId(), version);
logger.info("恢复用户【" + this.getClass().getName() + ".recoverUser】"
+ msg + "。用户userId=" + id + ",操作的用户ID=" + existUser.getId() + ",version:" + version);
} catch (Exception e) {
e.printStackTrace();
logger.error("恢复用户【" + this.getClass().getName()
+ ".recoverUser】用户异常!", e);
msg = "操作异常,请您稍后再试";
}
return msg;
}
/**
* 查询用户数据
* @return map
*/
@RequestMapping(value = "/getUserAndRoles", method = RequestMethod.GET)
@ResponseBody
public Map<String, Object> getUserAndRoles(@RequestParam("id") Integer id) {
logger.debug("查询用户数据!id:" + id);
Map<String, Object> map = new HashMap<>();
try {
if (null == id) {
logger.debug("查询用户数据==请求参数有误,请您稍后再试");
map.put("msg", "请求参数有误,请您稍后再试");
return map;
}
// 查询用户
UserRolesVO urvo = userService.getUserAndRoles(id);
logger.debug("查询用户数据!urvo=" + urvo);
if (null != urvo) {
map.put("user", urvo);
// 获取全部角色数据
List<Role> roles = this.authService.getRoles();
logger.debug("查询角色数据!roles=" + roles);
if (null != roles && roles.size() > 0) {
map.put("roles", roles);
}
map.put("msg", "ok");
} else {
map.put("msg", "查询用户信息有误,请您稍后再试");
}
logger.debug("查询用户数据成功!map=" + map);
return map;
} catch (Exception e) {
e.printStackTrace();
map.put("msg", "查询用户错误,请您稍后再试");
logger.error("查询用户数据异常!", e);
}
return map;
}
/**
* 发送短信验证码
* @param user
* @return
*/
@RequestMapping(value = "sendMsg", method = RequestMethod.POST)
@ResponseBody
public ResponseResult sendMsg(UserDTO user) {
logger.debug("发送短信验证码!user:" + user);
ResponseResult responseResult = new ResponseResult();
try {
if (null == user) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("请求参数有误,请您稍后再试");
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
if (!validatorRequestParam(user, responseResult)) {
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
// 送短信验证码
// String msg=userService.sendMsg(user);
String msg = "ok";
if (msg != "ok") {
responseResult.setCode(IStatusMessage.SystemStatus.ERROR
.getCode());
responseResult.setMessage(msg == "no" ? "发送验证码失败,请您稍后再试" : msg);
}
} catch (Exception e) {
e.printStackTrace();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("发送短信验证码失败,请您稍后再试");
logger.error("发送短信验证码异常!", e);
}
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
/**
* 登录【使用shiro中自带的HashedCredentialsMatcher结合ehcache(记录输错次数)配置进行密码输错次数限制】
* </br>缺陷是,无法友好的在后台提供解锁用户的功能,当然,可以直接提供一种解锁操作,清除ehcache缓存即可,不记录在用户表中;
* </br>
* @param user
* @param rememberMe
* @return
*/
@RequestMapping(value = "login", method = RequestMethod.POST)
@ResponseBody
public ResponseResult login(
UserDTO user,
@RequestParam(value = "rememberMe", required = false) boolean rememberMe) {
logger.debug("用户登录,请求参数=user:" + user + ",是否记住我:" + rememberMe);
ResponseResult responseResult = new ResponseResult();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
if (null == user) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("请求参数有误,请您稍后再试");
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
}
if (!validatorRequestParam(user, responseResult)) {
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
}
// 用户是否存在
User existUser = this.userService.findUserByMobile(user.getMobile());
if (existUser == null) {
responseResult.setMessage("该用户不存在,请您联系管理员");
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
} else {
// 是否离职
if (existUser.getIsJob()) {
responseResult.setMessage("登录用户已离职,请您联系管理员");
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
}
// 校验验证码
/*if(!existUser.getMcode().equals(user.getSmsCode())){ //不等
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码输入有误");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
} //1分钟
long beginTime =existUser.getSendTime().getTime();
long endTime = new Date().getTime();
if(((endTime-beginTime)-60000>0)){
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码超时");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
}*/
}
// 用户登录
try {
// 1、 封装用户名、密码、是否记住我到token令牌对象 [支持记住我]
AuthenticationToken token = new UsernamePasswordToken(
user.getMobile(), DigestUtils.md5Hex(user.getPassword()),
rememberMe);
// 2、 Subject调用login
Subject subject = SecurityUtils.getSubject();
// 在调用了login方法后,SecurityManager会收到AuthenticationToken,并将其发送给已配置的Realm执行必须的认证检查
// 每个Realm都能在必要时对提交的AuthenticationTokens作出反应
// 所以这一步在调用login(token)方法时,它会走到MyRealm.doGetAuthenticationInfo()方法中,具体验证方式详见此方法
logger.debug("用户登录,用户验证开始!user=" + user.getMobile());
subject.login(token);
responseResult.setCode(IStatusMessage.SystemStatus.SUCCESS
.getCode());
logger.info("用户登录,用户验证通过!user=" + user.getMobile());
} catch (UnknownAccountException uae) {
logger.error("用户登录,用户验证未通过:未知用户!user=" + user.getMobile(), uae);
responseResult.setMessage("该用户不存在,请您联系管理员");
} catch (IncorrectCredentialsException ice) {
// 获取输错次数
logger.error("用户登录,用户验证未通过:错误的凭证,密码输入错误!user=" + user.getMobile(),
ice);
responseResult.setMessage("用户名或密码不正确");
} catch (LockedAccountException lae) {
logger.error("用户登录,用户验证未通过:账户已锁定!user=" + user.getMobile(), lae);
responseResult.setMessage("账户已锁定");
} catch (ExcessiveAttemptsException eae) {
logger.error(
"用户登录,用户验证未通过:错误次数大于5次,账户已锁定!user=.getMobile()" + user, eae);
responseResult
.setMessage("用户名或密码错误次数大于5次,账户已锁定!</br><span style='color:red;font-weight:bold; '>2分钟后可再次登录,或联系管理员解锁</span>");
// 这里结合了,另一种密码输错限制的实现,基于redis或mysql的实现;也可以直接使用RetryLimitHashedCredentialsMatcher限制5次
} /*catch (DisabledAccountException sae){
logger.error("用户登录,用户验证未通过:帐号已经禁止登录!user=" +
user.getMobile(),sae);
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("帐号已经禁止登录");
}*/catch (AuthenticationException ae) {
// 通过处理Shiro的运行时AuthenticationException就可以控制用户登录失败或密码错误时的情景
logger.error("用户登录,用户验证未通过:认证异常,异常信息如下!user=" + user.getMobile(),
ae);
responseResult.setMessage("用户名或密码不正确");
} catch (Exception e) {
logger.error("用户登录,用户验证未通过:操作异常,异常信息如下!user=" + user.getMobile(), e);
responseResult.setMessage("用户登录失败,请您稍后再试");
}
Cache<String, AtomicInteger> passwordRetryCache = ecm
.getCache("passwordRetryCache");
if (null != passwordRetryCache) {
int retryNum = (passwordRetryCache.get(existUser.getMobile()) == null ? 0
: passwordRetryCache.get(existUser.getMobile())).intValue();
logger.debug("输错次数:" + retryNum);
if (retryNum > 0 && retryNum < 6) {
responseResult.setMessage("用户名或密码错误" + retryNum + "次,再输错"
+ (6 - retryNum) + "次账号将锁定");
}
}
logger.debug("用户登录,user=" + user.getMobile() + ",登录结果=responseResult:"
+ responseResult);
return responseResult;
}
/**
* 登录【使用redis和mysql实现,用户密码输错次数限制,和锁定解锁用户的功能//TODO】
* 该实现后续会提供!TODO
* @param user
* @param rememberMe
* @return
*/
@RequestMapping(value = "logina", method = RequestMethod.POST)
@ResponseBody
public ResponseResult logina(
UserDTO user,
@RequestParam(value = "rememberMe", required = false) boolean rememberMe) {
logger.debug("用户登录,请求参数=user:" + user + ",是否记住我:" + rememberMe);
ResponseResult responseResult = new ResponseResult();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
if (null == user) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("请求参数有误,请您稍后再试");
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
}
if (!validatorRequestParam(user, responseResult)) {
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
}
// 用户是否存在
User existUser = this.userService.findUserByMobile(user.getMobile());
if (existUser == null) {
responseResult.setMessage("该用户不存在,请您联系管理员");
logger.debug("用户登录,结果=responseResult:" + responseResult);
return responseResult;
} else {
// 校验验证码
/*if(!existUser.getMcode().equals(user.getSmsCode())){ //不等
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码输入有误");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
} //1分钟
long beginTime =existUser.getSendTime().getTime();
long endTime = new Date().getTime();
if(((endTime-beginTime)-60000>0)){
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码超时");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
}*/
}
// 是否锁定
boolean flag = false;
// 用户登录
try {
// 1、 封装用户名和密码到token令牌对象 [支持记住我]
AuthenticationToken token = new UsernamePasswordToken(
user.getMobile(), DigestUtils.md5Hex(user.getPassword()),
rememberMe);
// 2、 Subject调用login
Subject subject = SecurityUtils.getSubject();
// 在调用了login方法后,SecurityManager会收到AuthenticationToken,并将其发送给已配置的Realm执行必须的认证检查
// 每个Realm都能在必要时对提交的AuthenticationTokens作出反应
// 所以这一步在调用login(token)方法时,它会走到MyRealm.doGetAuthenticationInfo()方法中,具体验证方式详见此方法
logger.debug("用户登录,用户验证开始!user=" + user.getMobile());
subject.login(token);
responseResult.setCode(IStatusMessage.SystemStatus.SUCCESS
.getCode());
logger.info("用户登录,用户验证通过!user=" + user.getMobile());
} catch (UnknownAccountException uae) {
logger.error("用户登录,用户验证未通过:未知用户!user=" + user.getMobile(), uae);
responseResult.setMessage("该用户不存在,请您联系管理员");
} catch (IncorrectCredentialsException ice) {
// 获取输错次数
logger.error("用户登录,用户验证未通过:错误的凭证,密码输入错误!user=" + user.getMobile(),
ice);
responseResult.setMessage("用户名或密码不正确");
} catch (LockedAccountException lae) {
logger.error("用户登录,用户验证未通过:账户已锁定!user=" + user.getMobile(), lae);
responseResult.setMessage("账户已锁定");
} catch (ExcessiveAttemptsException eae) {
logger.error(
"用户登录,用户验证未通过:错误次数大于5次,账户已锁定!user=.getMobile()" + user, eae);
responseResult.setMessage("用户名或密码错误次数大于5次,账户已锁定,2分钟后可再次登录或联系管理员解锁");
// 这里结合了,另一种密码输错限制的实现,基于redis或mysql的实现;也可以直接使用RetryLimitHashedCredentialsMatcher限制5次
flag = true;
} /*catch (DisabledAccountException sae){
logger.error("用户登录,用户验证未通过:帐号已经禁止登录!user=" +
user.getMobile(),sae);
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("帐号已经禁止登录");
}*/catch (AuthenticationException ae) {
// 通过处理Shiro的运行时AuthenticationException就可以控制用户登录失败或密码错误时的情景
logger.error("用户登录,用户验证未通过:认证异常,异常信息如下!user=" + user.getMobile(),
ae);
responseResult.setMessage("用户名或密码不正确");
} catch (Exception e) {
logger.error("用户登录,用户验证未通过:操作异常,异常信息如下!user=" + user.getMobile(), e);
responseResult.setMessage("用户登录失败,请您稍后再试");
}
if (flag) {
// 已经输错6次了,将进行锁定!【也可以使用redis记录密码输错次数,然后进行锁定//TODO】
int num = this.userService.setUserLockNum(existUser.getId(), 1);
if (num < 1) {
logger.info("用户登录,用户名或密码错误次数大于5次,账户锁定失败!user="
+ user.getMobile());
}
}
logger.debug("用户登录,user=" + user.getMobile() + ",登录结果=responseResult:"
+ responseResult);
return responseResult;
}
/**
* 发送短信验证码
* @param mobile
* @param picCode
* @return
*/
@RequestMapping(value = "sendMessage", method = RequestMethod.POST)
@ResponseBody
public ResponseResult sendMessage(@RequestParam("mobile") String mobile,
@RequestParam("picCode") String picCode) {
logger.debug("发送短信验证码!mobile:" + mobile + ",picCode=" + picCode);
ResponseResult responseResult = new ResponseResult();
try {
if (!ValidateUtil.isMobilephone(mobile)) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("手机号格式有误,请您重新填写");
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
if (!ValidateUtil.isPicCode(picCode)) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("图片验证码有误,请您重新填写");
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
// 判断用户是否登录
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
responseResult.setCode(IStatusMessage.SystemStatus.NO_LOGIN
.getCode());
responseResult.setMessage("您未登录或登录超时,请您重新登录后再试");
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
// 送短信验证码
// String msg=userService.sendMessage(existUser.getId(),mobile);
String msg = "ok";
if (msg != "ok") {
responseResult.setCode(IStatusMessage.SystemStatus.ERROR
.getCode());
responseResult.setMessage(msg == "no" ? "发送验证码失败,请您稍后再试" : msg);
}
} catch (Exception e) {
e.printStackTrace();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("发送短信验证码失败,请您稍后再试");
logger.error("发送短信验证码异常!", e);
}
logger.debug("发送短信验证码,结果=responseResult:" + responseResult);
return responseResult;
}
/**
* 修改密码之确认手机号
* @param mobile
* @param picCode
* @return
*/
@RequestMapping(value = "updatePwd", method = RequestMethod.POST)
@ResponseBody
public ResponseResult updatePwd(@RequestParam("mobile") String mobile,
@RequestParam("picCode") String picCode,
@RequestParam("mobileCode") String mobileCode) {
logger.debug("修改密码之确认手机号!mobile:" + mobile + ",picCode=" + picCode
+ ",mobileCode=" + mobileCode);
ResponseResult responseResult = new ResponseResult();
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
try {
if (!ValidateUtil.isMobilephone(mobile)) {
responseResult.setMessage("手机号格式有误,请您重新填写");
logger.debug("修改密码之确认手机号,结果=responseResult:" + responseResult);
return responseResult;
}
if (!ValidateUtil.isPicCode(picCode)) {
responseResult.setMessage("图片验证码有误,请您重新填写");
logger.debug("发修改密码之确认手机号,结果=responseResult:" + responseResult);
return responseResult;
}
if (!ValidateUtil.isCode(mobileCode)) {
responseResult.setMessage("短信验证码有误,请您重新填写");
logger.debug("发修改密码之确认手机号,结果=responseResult:" + responseResult);
return responseResult;
}
// 判断用户是否登录
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
responseResult.setMessage("您未登录或登录超时,请您重新登录后再试");
logger.debug("修改密码之确认手机号,结果=responseResult:" + responseResult);
return responseResult;
} else {
// 校验验证码
/*if(!existUser.getMcode().equals(user.getSmsCode())){ //不等
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码输入有误");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
} //1分钟
long beginTime =existUser.getSendTime().getTime();
long endTime = new Date().getTime();
if(((endTime-beginTime)-60000>0)){
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
responseResult.setMessage("短信验证码超时");
logger.debug("用户登录,结果=responseResult:"+responseResult);
return responseResult;
}*/
}
} catch (Exception e) {
e.printStackTrace();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("操作失败,请您稍后再试");
logger.error("修改密码之确认手机号异常!", e);
return responseResult;
}
responseResult.setCode(IStatusMessage.SystemStatus.SUCCESS.getCode());
responseResult.setMessage("SUCCESS");
logger.debug("修改密码之确认手机号,结果=responseResult:" + responseResult);
return responseResult;
}
/**
* 修改密码
* @param pwd
* @param isPwd
* @return
*/
@RequestMapping(value = "setPwd", method = RequestMethod.POST)
@ResponseBody
public ResponseResult setPwd(@RequestParam("pwd") String pwd,
@RequestParam("isPwd") String isPwd) {
logger.debug("修改密码!pwd:" + pwd + ",isPwd=" + isPwd);
ResponseResult responseResult = new ResponseResult();
try {
if (!ValidateUtil.isSimplePassword(pwd)
|| !ValidateUtil.isSimplePassword(isPwd)) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("密码格式有误,请您重新填写");
logger.debug("修改密码,结果=responseResult:" + responseResult);
return responseResult;
}
if (!pwd.equals(isPwd)) {
responseResult.setCode(IStatusMessage.SystemStatus.PARAM_ERROR
.getCode());
responseResult.setMessage("两次密码输入不一致,请您重新填写");
logger.debug("发修改密码,结果=responseResult:" + responseResult);
return responseResult;
}
// 判断用户是否登录
User existUser = (User) SecurityUtils.getSubject().getPrincipal();
if (null == existUser) {
responseResult.setCode(IStatusMessage.SystemStatus.NO_LOGIN
.getCode());
responseResult.setMessage("您未登录或登录超时,请您重新登录后再试");
logger.debug("修改密码,结果=responseResult:" + responseResult);
return responseResult;
}
// 修改密码
int num = this.userService.updatePwd(existUser.getId(),
DigestUtils.md5Hex(pwd));
if (num != 1) {
responseResult.setCode(IStatusMessage.SystemStatus.ERROR
.getCode());
responseResult.setMessage("操作失败,请您稍后再试");
logger.debug("修改密码失败,已经离职或该用户被删除!结果=responseResult:"
+ responseResult);
}
} catch (Exception e) {
e.printStackTrace();
responseResult.setCode(IStatusMessage.SystemStatus.ERROR.getCode());
responseResult.setMessage("操作失败,请您稍后再试");
logger.error("修改密码异常!", e);
}
logger.debug("修改密码,结果=responseResult:" + responseResult);
return responseResult;
}
public static void main(String[] args) throws ParseException {
Date date = DateUtil.parse("2018-01-04 20:15:21");
Date date1 = DateUtil.parse("2018-01-04 20:11:21");
Date date2 = DateUtil.parse("2018-01-04 20:12:21");
long beginTime = date.getTime();
long beginTime1 = date1.getTime();
long end1 = date2.getTime();
long endTime = System.currentTimeMillis();
// main
long betweenDays = endTime - beginTime;
long betweenDays1 = endTime - beginTime1;
long eq = end1 - beginTime1;
boolean flag = betweenDays - (60000) > 0;// 超时
boolean flag1 = betweenDays1 - (60000) > 0;// 超时
boolean flag2 = eq - (60000) == 0;//
System.out.println(betweenDays);
System.out.println(betweenDays1);
System.out.println(eq);
System.out.println(flag);
System.out.println(flag1);
System.out.println(flag2);
}
/**
* @描述:校验请求参数
* @param obj
* @param response
* @return
*/
protected boolean validatorRequestParam(Object obj, ResponseResult response) {
boolean flag = false;
Validator validator = new Validator();
List<ConstraintViolation> ret = validator.validate(obj);
if (ret.size() > 0) {
// 校验参数有误
response.setCode(IStatusMessage.SystemStatus.PARAM_ERROR.getCode());
response.setMessage(ret.get(0).getMessageTemplate());
} else {
flag = true;
}
return flag;
}
}
| [
"1063977059@qq.com"
] | 1063977059@qq.com |
1a96bc5a93813887348cbc47ad11f0598d577c9c | 35fcaaecbdb535a74c2d2ddb298b9d2383841e9b | /Posttest/src/tugas3/posttest3.java | f460b64ca076dd8ee8d0abc2f1f2af04b4ab0eea | [] | no_license | hanifaulia/VISUAL_A_1515015012_889011 | 2c42907fa3383b268f73d3a2a4e706081157c5a0 | 29ef253bdeaaca14fbd438bc3290aa9ce0019d6b | refs/heads/master | 2020-05-27T21:14:56.257634 | 2017-04-13T13:08:04 | 2017-04-13T13:08:04 | 83,643,012 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 20,501 | java | /*
* 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 tugas3;
/**
*
* @author hanif
*/
public class posttest3 extends javax.swing.JFrame {
/**
* Creates new form posttest3
*/
public posttest3() {
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() {
HOME = new javax.swing.JPanel();
about = new javax.swing.JPanel();
jLabel8 = new javax.swing.JLabel();
register = new javax.swing.JPanel();
tbnama = new javax.swing.JTextField();
tbumur = new javax.swing.JTextField();
tbbidang = new javax.swing.JTextField();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
b1 = new javax.swing.JButton();
jLabel9 = new javax.swing.JLabel();
jLabel12 = new javax.swing.JLabel();
jLabel13 = new javax.swing.JLabel();
home = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jPanel7 = new javax.swing.JPanel();
jPanel6 = new javax.swing.JPanel();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jButton3 = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel19 = new javax.swing.JLabel();
jLabel20 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
jPanel5 = new javax.swing.JPanel();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setModalExclusionType(java.awt.Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
setResizable(false);
HOME.setBackground(new java.awt.Color(255, 204, 102));
HOME.setLayout(new java.awt.CardLayout());
about.setBackground(new java.awt.Color(204, 204, 204));
jLabel8.setText("Infinedd adalah sebuah label multimedia");
javax.swing.GroupLayout aboutLayout = new javax.swing.GroupLayout(about);
about.setLayout(aboutLayout);
aboutLayout.setHorizontalGroup(
aboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(aboutLayout.createSequentialGroup()
.addGap(94, 94, 94)
.addComponent(jLabel8)
.addContainerGap(113, Short.MAX_VALUE))
);
aboutLayout.setVerticalGroup(
aboutLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(aboutLayout.createSequentialGroup()
.addGap(126, 126, 126)
.addComponent(jLabel8)
.addContainerGap(208, Short.MAX_VALUE))
);
HOME.add(about, "card3");
register.setBackground(new java.awt.Color(255, 255, 255));
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
b1.setText("send");
b1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
b1ActionPerformed(evt);
}
});
jLabel9.setText("Nama");
jLabel12.setText("Umur");
jLabel13.setText("Bidang");
javax.swing.GroupLayout registerLayout = new javax.swing.GroupLayout(register);
register.setLayout(registerLayout);
registerLayout.setHorizontalGroup(
registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(registerLayout.createSequentialGroup()
.addContainerGap()
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1)
.addGroup(registerLayout.createSequentialGroup()
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel9)
.addComponent(jLabel12)
.addComponent(jLabel13))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(registerLayout.createSequentialGroup()
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tbumur, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(tbnama, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(registerLayout.createSequentialGroup()
.addComponent(tbbidang, javax.swing.GroupLayout.PREFERRED_SIZE, 202, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE)
.addComponent(b1, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)))))
.addContainerGap())
);
registerLayout.setVerticalGroup(
registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(registerLayout.createSequentialGroup()
.addContainerGap()
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tbnama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel9))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tbumur, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel12))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(registerLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(tbbidang, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel13)
.addComponent(b1))
.addGap(18, 18, 18)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 228, Short.MAX_VALUE)
.addContainerGap())
);
HOME.add(register, "card4");
home.setBackground(new java.awt.Color(255, 255, 255));
jLabel6.setText("Home");
javax.swing.GroupLayout homeLayout = new javax.swing.GroupLayout(home);
home.setLayout(homeLayout);
homeLayout.setHorizontalGroup(
homeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(homeLayout.createSequentialGroup()
.addGap(167, 167, 167)
.addComponent(jLabel6)
.addContainerGap(204, Short.MAX_VALUE))
);
homeLayout.setVerticalGroup(
homeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(homeLayout.createSequentialGroup()
.addGap(141, 141, 141)
.addComponent(jLabel6)
.addContainerGap(193, Short.MAX_VALUE))
);
HOME.add(home, "card2");
getContentPane().add(HOME, java.awt.BorderLayout.CENTER);
jPanel2.setBackground(new java.awt.Color(0, 51, 51));
jPanel7.setBackground(new java.awt.Color(0, 51, 51));
jPanel6.setBackground(new java.awt.Color(0, 51, 51));
jPanel6.setLayout(new java.awt.GridLayout(1, 0, 30, 0));
jButton1.setText("home");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel6.add(jButton1);
jButton2.setText("register");
jButton2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton2ActionPerformed(evt);
}
});
jPanel6.add(jButton2);
jButton3.setText("about");
jButton3.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton3ActionPerformed(evt);
}
});
jPanel6.add(jButton3);
jButton4.setText("exit");
jButton4.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton4ActionPerformed(evt);
}
});
jPanel6.add(jButton4);
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
.addContainerGap(110, Short.MAX_VALUE)
.addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(102, 102, 102))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jLabel1.setBackground(new java.awt.Color(255, 255, 255));
jLabel1.setFont(new java.awt.Font("Arial", 0, 48)); // NOI18N
jLabel1.setForeground(new java.awt.Color(255, 255, 255));
jLabel1.setText("Infinedd");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(jLabel2)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(211, 211, 211))
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_START);
jPanel3.setBackground(new java.awt.Color(0, 102, 102));
jLabel19.setText("Hanif Aulia");
jLabel20.setText("Copyright@2015");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
.addContainerGap(498, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel20)
.addComponent(jLabel19))
.addGap(19, 19, 19))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel20)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
getContentPane().add(jPanel3, java.awt.BorderLayout.PAGE_END);
jPanel4.setBackground(new java.awt.Color(0, 51, 51));
jPanel4.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 303, Short.MAX_VALUE)
);
getContentPane().add(jPanel4, java.awt.BorderLayout.LINE_END);
jPanel5.setBackground(new java.awt.Color(0, 51, 51));
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 100, Short.MAX_VALUE)
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 303, Short.MAX_VALUE)
);
getContentPane().add(jPanel5, java.awt.BorderLayout.LINE_START);
pack();
setLocationRelativeTo(null);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
home.setVisible(true);
register.setVisible(false);
about.setVisible(false);
}//GEN-LAST:event_jButton1ActionPerformed
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
// TODO add your handling code here:
home.setVisible(false);
register.setVisible(true);
about.setVisible(false);
}//GEN-LAST:event_jButton2ActionPerformed
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
// TODO add your handling code here:
home.setVisible(false);
register.setVisible(false);
about.setVisible(true);
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
// TODO add your handling code here:
System.exit(0);
}//GEN-LAST:event_jButton4ActionPerformed
private void b1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_b1ActionPerformed
// TODO add your handling code here:
String nm=tbnama.getText();
String um=tbumur.getText();
String bd=tbbidang.getText();
jTextArea1.setText("Nama\t: "+nm+"\nKota Awal\t: "+um+"\nKota Tujuan\t: "+bd);
}//GEN-LAST:event_b1ActionPerformed
/**
* @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(posttest3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(posttest3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(posttest3.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(posttest3.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 posttest3().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel HOME;
private javax.swing.JPanel about;
private javax.swing.JButton b1;
private javax.swing.JPanel home;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JButton jButton4;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
private javax.swing.JPanel register;
private javax.swing.JTextField tbbidang;
private javax.swing.JTextField tbnama;
private javax.swing.JTextField tbumur;
// End of variables declaration//GEN-END:variables
}
| [
"cinema.hanifaulia@gmail.com"
] | cinema.hanifaulia@gmail.com |
ed0af512f5a4db68301451932e6631d723fd8aaf | 83897e6fa4edf252b740d2d103e29bd15a4badef | /1_Integral image & Max Value Stack/A1Q2/IntegralImage.java | c5e95ddb66b172215d854cd5564ce11197d8f7a8 | [] | no_license | sophiiae/DataStrucutre_Java | 020481f440c3f03a045167c6301a2d406dc8f394 | 16def6afbedde1b0ccbc15a3ce01b1ed0d84404a | refs/heads/master | 2020-04-09T05:19:53.493266 | 2018-12-25T00:05:34 | 2018-12-25T00:05:34 | 160,060,342 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,512 | java | package A1Q2;
/**
* Represents an integer integral image, which allows the user to query the mean
* value of an arbitrary rectangular subimage in O(1) time. Uses O(n) memory,
* where n is the number of pixels in the image.
*
*/
public class IntegralImage {
private final int[][] integralImage;
private final int imageHeight; // height of image (first index)
private final int imageWidth; // width of image (second index)
/**
* Constructs an integral image from the given input image.
*
* @author jameselder
* @param image The image represented
* @throws InvalidImageException Thrown if input array is not rectangular
*/
public IntegralImage(int[][] image) throws InvalidImageException {
//implement this method.
int compare = image[0].length;
int i;
for (i = 1; i < image.length; i++) {
if (image[i].length != compare) {
throw new InvalidImageException();
}
compare = image[i].length;
}
this.imageHeight = image.length;
this.imageWidth = image[0].length;
this.integralImage = new int[this.imageHeight][this.imageWidth];
integralImage[0][0] = image[0][0];
for (i = 1; i < image[0].length; i++) {
integralImage[0][i] = integralImage[0][i-1] + image[0][i];
}
for (i = 1; i < image.length; i++) {
integralImage[i][0] = integralImage[i-1][0] + image[i][0];
}
i = 1;
int j = 1;
while (i < this.imageHeight && j < this.imageWidth) {
integralImage[i][j] = image[i][j] + integralImage[i-1][j] + integralImage[i][j-1] - integralImage[i-1][j-1];
if (j == this.imageWidth - 1) {
j = 1;
i++;
} else {
j++;
}
}
}
/**
* Returns the mean value of the rectangular sub-image specified by the
* top, bottom, left and right parameters. The sub-image should include
* pixels in rows top and bottom and columns left and right. For example,
* top = 1, bottom = 2, left = 1, right = 2 specifies a 2 x 2 sub-image starting
* at (top, left) coordinate (1, 1).
*
* @author jameselder
* @param top top row of sub-image
* @param bottom bottom row of sub-image
* @param left left column of sub-image
* @param right right column of sub-image
* @return
* @throws BoundaryViolationException if image indices are out of range
* @throws NullSubImageException if top > bottom or left > right
*/
public double meanSubImage(int top, int bottom, int left, int right) throws BoundaryViolationException, NullSubImageException {
//implement this method
if (top > this.imageHeight || bottom < 0 || left < 0 || right > this.imageWidth) {
throw new BoundaryViolationException();
}
if (top > bottom || left > right) {
throw new NullSubImageException();
}
double area = (bottom - top + 1) * (right - left + 1);
if (top == 0 && left == 0) {
return integralImage[bottom][right] / area;
}
if (top == 0) {
return (integralImage[bottom][right] - integralImage[bottom][left-1]) / area;
}
if (left == 0) {
return (integralImage[bottom][right] - integralImage[top-1][right]) / area;
}
return (integralImage[bottom][right] - integralImage[top-1][right] - integralImage[bottom][left-1] + integralImage[top-1][left-1]) / area;
}
}
| [
"feifeizheng@outlook.com"
] | feifeizheng@outlook.com |
ec9a20b66b50d079d07d42d2c0aceeb73fbf1722 | 5f4e7b18c82bca2f3f8ff944a5b0ef31aaf5248e | /hapi-fhir-server/src/main/java/ca/uhn/fhir/rest/server/method/MethodUtil.java | 5d0241f87d8036064807c660b1381bbd9c4d6919 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | shayaanmunshi/hapi-fhir | 1e080ac18393f43cbe069229b674a34dd42a6535 | be07ebc4ef73feb776192cc7ce91d95fde466d8d | refs/heads/master | 2021-06-30T18:53:51.655542 | 2017-09-21T12:33:20 | 2017-09-21T12:33:20 | 201,999,525 | 1 | 0 | Apache-2.0 | 2019-08-12T19:55:49 | 2019-08-12T19:55:49 | null | UTF-8 | Java | false | false | 12,170 | java | package ca.uhn.fhir.rest.server.method;
/*-
* #%L
* HAPI FHIR - Server Framework
* %%
* Copyright (C) 2014 - 2017 University Health Network
* %%
* 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.
* #L%
*/
import static org.apache.commons.lang3.StringUtils.isNotBlank;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.*;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
import org.hl7.fhir.instance.model.api.IBaseResource;
import ca.uhn.fhir.context.ConfigurationException;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Include;
import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.Description;
import ca.uhn.fhir.rest.annotation.*;
import ca.uhn.fhir.rest.api.*;
import ca.uhn.fhir.rest.api.server.IRequestOperationCallback;
import ca.uhn.fhir.rest.api.server.RequestDetails;
import ca.uhn.fhir.rest.param.binder.CollectionBinder;
import ca.uhn.fhir.rest.server.method.OperationParameter.IOperationParamConverter;
import ca.uhn.fhir.rest.server.method.ResourceParameter.Mode;
import ca.uhn.fhir.util.ParametersUtil;
import ca.uhn.fhir.util.ReflectionUtil;
public class MethodUtil {
public static void extractDescription(SearchParameter theParameter, Annotation[] theAnnotations) {
for (Annotation annotation : theAnnotations) {
if (annotation instanceof Description) {
Description desc = (Description) annotation;
if (isNotBlank(desc.formalDefinition())) {
theParameter.setDescription(desc.formalDefinition());
} else {
theParameter.setDescription(desc.shortDefinition());
}
}
}
}
@SuppressWarnings("unchecked")
public static List<IParameter> getResourceParameters(final FhirContext theContext, Method theMethod, Object theProvider, RestOperationTypeEnum theRestfulOperationTypeEnum) {
List<IParameter> parameters = new ArrayList<IParameter>();
Class<?>[] parameterTypes = theMethod.getParameterTypes();
int paramIndex = 0;
for (Annotation[] annotations : theMethod.getParameterAnnotations()) {
IParameter param = null;
Class<?> parameterType = parameterTypes[paramIndex];
Class<? extends java.util.Collection<?>> outerCollectionType = null;
Class<? extends java.util.Collection<?>> innerCollectionType = null;
if (TagList.class.isAssignableFrom(parameterType)) {
// TagList is handled directly within the method bindings
param = new NullParameter();
} else {
if (Collection.class.isAssignableFrom(parameterType)) {
innerCollectionType = (Class<? extends java.util.Collection<?>>) parameterType;
parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(theMethod, paramIndex);
}
if (Collection.class.isAssignableFrom(parameterType)) {
outerCollectionType = innerCollectionType;
innerCollectionType = (Class<? extends java.util.Collection<?>>) parameterType;
parameterType = ReflectionUtil.getGenericCollectionTypeOfMethodParameter(theMethod, paramIndex);
}
if (Collection.class.isAssignableFrom(parameterType)) {
throw new ConfigurationException("Argument #" + paramIndex + " of Method '" + theMethod.getName() + "' in type '" + theMethod.getDeclaringClass().getCanonicalName()
+ "' is of an invalid generic type (can not be a collection of a collection of a collection)");
}
}
if (ServletRequest.class.isAssignableFrom(parameterType)) {
param = new ServletRequestParameter();
} else if (ServletResponse.class.isAssignableFrom(parameterType)) {
param = new ServletResponseParameter();
} else if (parameterType.equals(RequestDetails.class) || parameterType.equals(ServletRequestDetails.class)) {
param = new RequestDetailsParameter();
} else if (parameterType.equals(IRequestOperationCallback.class)) {
param = new RequestOperationCallbackParameter();
} else if (parameterType.equals(SummaryEnum.class)) {
param = new SummaryEnumParameter();
} else if (parameterType.equals(PatchTypeEnum.class)) {
param = new PatchTypeParameter();
} else {
for (int i = 0; i < annotations.length && param == null; i++) {
Annotation nextAnnotation = annotations[i];
if (nextAnnotation instanceof RequiredParam) {
SearchParameter parameter = new SearchParameter();
parameter.setName(((RequiredParam) nextAnnotation).name());
parameter.setRequired(true);
parameter.setDeclaredTypes(((RequiredParam) nextAnnotation).targetTypes());
parameter.setCompositeTypes(((RequiredParam) nextAnnotation).compositeTypes());
parameter.setChainlists(((RequiredParam) nextAnnotation).chainWhitelist(), ((RequiredParam) nextAnnotation).chainBlacklist());
parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType);
MethodUtil.extractDescription(parameter, annotations);
param = parameter;
} else if (nextAnnotation instanceof OptionalParam) {
SearchParameter parameter = new SearchParameter();
parameter.setName(((OptionalParam) nextAnnotation).name());
parameter.setRequired(false);
parameter.setDeclaredTypes(((OptionalParam) nextAnnotation).targetTypes());
parameter.setCompositeTypes(((OptionalParam) nextAnnotation).compositeTypes());
parameter.setChainlists(((OptionalParam) nextAnnotation).chainWhitelist(), ((OptionalParam) nextAnnotation).chainBlacklist());
parameter.setType(theContext, parameterType, innerCollectionType, outerCollectionType);
MethodUtil.extractDescription(parameter, annotations);
param = parameter;
} else if (nextAnnotation instanceof RawParam) {
param = new RawParamsParmeter(parameters);
} else if (nextAnnotation instanceof IncludeParam) {
Class<? extends Collection<Include>> instantiableCollectionType;
Class<?> specType;
if (parameterType == String.class) {
instantiableCollectionType = null;
specType = String.class;
} else if ((parameterType != Include.class) || innerCollectionType == null || outerCollectionType != null) {
throw new ConfigurationException("Method '" + theMethod.getName() + "' is annotated with @" + IncludeParam.class.getSimpleName() + " but has a type other than Collection<"
+ Include.class.getSimpleName() + ">");
} else {
instantiableCollectionType = (Class<? extends Collection<Include>>) CollectionBinder.getInstantiableCollectionType(innerCollectionType, "Method '" + theMethod.getName() + "'");
specType = parameterType;
}
param = new IncludeParameter((IncludeParam) nextAnnotation, instantiableCollectionType, specType);
} else if (nextAnnotation instanceof ResourceParam) {
Mode mode;
if (IBaseResource.class.isAssignableFrom(parameterType)) {
mode = Mode.RESOURCE;
} else if (String.class.equals(parameterType)) {
mode = ResourceParameter.Mode.BODY;
} else if (byte[].class.equals(parameterType)) {
mode = ResourceParameter.Mode.BODY_BYTE_ARRAY;
} else if (EncodingEnum.class.equals(parameterType)) {
mode = Mode.ENCODING;
} else {
StringBuilder b = new StringBuilder();
b.append("Method '");
b.append(theMethod.getName());
b.append("' is annotated with @");
b.append(ResourceParam.class.getSimpleName());
b.append(" but has a type that is not an implemtation of ");
b.append(IBaseResource.class.getCanonicalName());
b.append(" or String or byte[]");
throw new ConfigurationException(b.toString());
}
param = new ResourceParameter((Class<? extends IBaseResource>) parameterType, theProvider, mode);
} else if (nextAnnotation instanceof IdParam) {
param = new NullParameter();
} else if (nextAnnotation instanceof ServerBase) {
param = new ServerBaseParamBinder();
} else if (nextAnnotation instanceof Elements) {
param = new ElementsParameter();
} else if (nextAnnotation instanceof Since) {
param = new SinceParameter();
((SinceParameter) param).setType(theContext, parameterType, innerCollectionType, outerCollectionType);
} else if (nextAnnotation instanceof At) {
param = new AtParameter();
((AtParameter) param).setType(theContext, parameterType, innerCollectionType, outerCollectionType);
} else if (nextAnnotation instanceof Count) {
param = new CountParameter();
} else if (nextAnnotation instanceof GraphQLQuery) {
param = new GraphQLQueryParameter();
} else if (nextAnnotation instanceof Sort) {
param = new SortParameter(theContext);
} else if (nextAnnotation instanceof TransactionParam) {
param = new TransactionParameter(theContext);
} else if (nextAnnotation instanceof ConditionalUrlParam) {
param = new ConditionalParamBinder(theRestfulOperationTypeEnum, ((ConditionalUrlParam) nextAnnotation).supportsMultiple());
} else if (nextAnnotation instanceof OperationParam) {
Operation op = theMethod.getAnnotation(Operation.class);
param = new OperationParameter(theContext, op.name(), ((OperationParam) nextAnnotation));
} else if (nextAnnotation instanceof Validate.Mode) {
if (parameterType.equals(ValidationModeEnum.class) == false) {
throw new ConfigurationException(
"Parameter annotated with @" + Validate.class.getSimpleName() + "." + Validate.Mode.class.getSimpleName() + " must be of type " + ValidationModeEnum.class.getName());
}
param = new OperationParameter(theContext, Constants.EXTOP_VALIDATE, Constants.EXTOP_VALIDATE_MODE, 0, 1).setConverter(new IOperationParamConverter() {
@Override
public Object incomingServer(Object theObject) {
if (isNotBlank(theObject.toString())) {
ValidationModeEnum retVal = ValidationModeEnum.forCode(theObject.toString());
if (retVal == null) {
OperationParameter.throwInvalidMode(theObject.toString());
}
return retVal;
}
return null;
}
@Override
public Object outgoingClient(Object theObject) {
return ParametersUtil.createString(theContext, ((ValidationModeEnum) theObject).getCode());
}
});
} else if (nextAnnotation instanceof Validate.Profile) {
if (parameterType.equals(String.class) == false) {
throw new ConfigurationException(
"Parameter annotated with @" + Validate.class.getSimpleName() + "." + Validate.Profile.class.getSimpleName() + " must be of type " + String.class.getName());
}
param = new OperationParameter(theContext, Constants.EXTOP_VALIDATE, Constants.EXTOP_VALIDATE_PROFILE, 0, 1).setConverter(new IOperationParamConverter() {
@Override
public Object incomingServer(Object theObject) {
return theObject.toString();
}
@Override
public Object outgoingClient(Object theObject) {
return ParametersUtil.createString(theContext, theObject.toString());
}
});
} else {
continue;
}
}
}
if (param == null) {
throw new ConfigurationException(
"Parameter #" + ((paramIndex + 1)) + "/" + (parameterTypes.length) + " of method '" + theMethod.getName() + "' on type '" + theMethod.getDeclaringClass().getCanonicalName()
+ "' has no recognized FHIR interface parameter annotations. Don't know how to handle this parameter");
}
param.initializeTypes(theMethod, outerCollectionType, innerCollectionType, parameterType);
parameters.add(param);
paramIndex++;
}
return parameters;
}
}
| [
"jamesagnew@gmail.com"
] | jamesagnew@gmail.com |
d87792623a86fd68e476f63a58c5fcde0895acf7 | 58dafff63212d9f6c291edbea615c98575047dbc | /src/main/java/example/business/FooPersistenceService.java | 1675bc32cef76a489baf63882443f5eca36a9189 | [] | no_license | slu-it/example-spring-security-component-scan-issue | d7cb95e274a3432c2ace2d98c0eabf1ad5cb8250 | dc6fdbbd197225a344e623da7af6f403c6f88e68 | refs/heads/master | 2020-12-03T03:54:34.828265 | 2017-06-29T14:54:23 | 2017-06-29T14:54:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 70 | java | package example.business;
public interface FooPersistenceService {
}
| [
"stefan.ludwig@novatec-gmbh.de"
] | stefan.ludwig@novatec-gmbh.de |
1e84c8143a8056885b842f7d39993a81c5358634 | 3942ca1ace35dd8e38e13436ede69468ff2a16a2 | /p2pSSM/src/main/java/com/zking/p2pSSM/utils/PasswordHelper.java | 7cb616e11746396ba5a906b3787c1c45e23eb56c | [] | no_license | whap2p/p2pSSM | 1927b4c6cf0ceee371ef81d966861244edba823b | cfce90e733ea8b9fe8787ac60f93a8460150b7c1 | refs/heads/master | 2020-04-24T19:50:01.130123 | 2019-03-11T05:29:00 | 2019-03-11T05:29:00 | 172,224,697 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,620 | java | package com.zking.p2pSSM.utils;
import org.apache.shiro.crypto.RandomNumberGenerator;
import org.apache.shiro.crypto.SecureRandomNumberGenerator;
import org.apache.shiro.crypto.hash.SimpleHash;
/**
* 用于shiro权限认证的密码工具类
*/
public class PasswordHelper {
/**
* 随机数生成器
*/
private static RandomNumberGenerator randomNumberGenerator = new SecureRandomNumberGenerator();
/**
* 指定hash算法为MD5
*/
private static final String hashAlgorithmName = "md5";
/**
* 指定散列次数为1024次,即加密1024次
*/
private static final int hashIterations = 1024;
/**
* true指定Hash散列值使用Hex加密存. false表明hash散列值用用Base64-encoded存储
*/
private static final boolean storedCredentialsHexEncoded = true;
/**
* 获得加密用的盐
*
* @return
*/
public static String createSalt() {
return randomNumberGenerator.nextBytes().toHex();
}
/**
* 获得加密后的凭证
*
* @param credentials 凭证(即密码)
* @param salt 盐
* @return
*/
public static String createCredentials(String credentials, String salt) {
SimpleHash simpleHash = new SimpleHash(hashAlgorithmName, credentials,
salt, hashIterations);
return storedCredentialsHexEncoded ? simpleHash.toHex() : simpleHash.toBase64();
}
/**
* 进行密码验证
*
* @param credentials 未加密的密码
* @param salt 盐
* @param encryptCredentials 加密后的密码
* @return
*/
public static boolean checkCredentials(String credentials, String salt, String encryptCredentials) {
return encryptCredentials.equals(createCredentials(credentials, salt));
}
public static void main(String[] args) {
//盐
String salt = createSalt();
System.out.println("盐"+salt);
System.out.println(salt.length());
//凭证+盐加密后得到的密码
String credentials = createCredentials("123", salt);
System.out.println("password:"+credentials);
System.out.println(credentials.length());
boolean b = checkCredentials("123", salt, credentials);
System.out.println(b);
System.out.println(on(credentials));
System.out.println(on(salt));
}
public static String on(String intr){
char[] a=intr.toCharArray();
for(int i=0;i<a.length;i++){
a[i]=(char) (a[i]^'t');
}
return new String(a);
}
}
| [
"2143370064@qq.com"
] | 2143370064@qq.com |
b5944f1d8405ea302cfb57d5c91aae678b09f5fe | ac808277839cfa3ae5f186ef41521eca6ebea663 | /src/main/java/fr/Operation/Withdrawal.java | cb167b54beeda39945a0fbd173b72e4e01ca768c | [] | no_license | BorisBlngr/Kata-Bank-Account | 8e12431bce07a25624985d0cb84829c6699df7e1 | 5188300a846984a084a0fc98fd88fa9d8c27a21c | refs/heads/master | 2020-05-17T10:17:28.817897 | 2019-05-03T16:00:38 | 2019-05-03T16:00:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 373 | java | package fr.Operation;
import fr.Money;
public class Withdrawal implements Operation {
@Override
public Money operate(Money money, Money amount) {
return money.minus(amount);
}
@Override
public String symbol() {
return "-";
}
@Override
public boolean equals(Object obj) {
return obj instanceof Withdrawal;
}
}
| [
"boris.thibaut.boulanger@gmail.com"
] | boris.thibaut.boulanger@gmail.com |
c6ad91b8c1e0d2be6fa8d657733aec09995d4af0 | 7f0c98401bb8ad14f407d343ac750778afcbfba3 | /hrm_course_parent/hrm_course_service_9002/src/main/java/cn/itsource/hrm/mapper/CourseTypeMapper.java | 080273d189f056846888b03c68506855bbc32c08 | [] | no_license | a3705348/hrm_ZYC | 152f5f04056db5cffdce5ec546f3abac67ee146f | 98d6fba775ab0e1e813407340254b9dac2ffbefd | refs/heads/master | 2020-07-15T17:07:24.690734 | 2019-09-01T02:16:54 | 2019-09-01T02:16:54 | 205,613,923 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 293 | java | package cn.itsource.hrm.mapper;
import cn.itsource.hrm.domain.CourseType;
import com.baomidou.mybatisplus.mapper.BaseMapper;
/**
* <p>
* 课程目录 Mapper 接口
* </p>
*
* @author yhptest
* @since 2019-08-31
*/
public interface CourseTypeMapper extends BaseMapper<CourseType> {
}
| [
"a3705348.163.com"
] | a3705348.163.com |
3db2e2671b98c1dc2df06ff63ac7900c0ec111b3 | 9c35febd351c20d91b665d6ec2946683be4c65da | /src/main/java/com/example/springbootstudy/service/MyService2.java | 74c777a8190dbc4dab9ca6dbb1b0b8e7106b9a96 | [] | no_license | quyixiao/spring-boot-study | 37f7ef7351894cb8a21b76cacc227956d0371a7b | b225ed789a7a044b0ea9968e044050a17bc19241 | refs/heads/master | 2023-06-14T10:46:41.096208 | 2021-07-05T06:07:41 | 2021-07-05T06:07:41 | 360,837,080 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 81 | java | package com.example.springbootstudy.service;
public @interface MyService2 {
}
| [
"2621048238@qq.com"
] | 2621048238@qq.com |
e43f403d08f19af25a239e221c2e6e64284867d1 | d5f8da5cfad4df0ad592f125cea0332a4c53e59f | /m.krasnoshchekov/src/main/java/action06_homework/MainCalc.java | 0a8deeeb9d9d3a2614b405d99f22daa5f6320c67 | [] | no_license | MaxProff3/Proff3 | 7ecd0ab566ce9d5fef40cbda94c67bb9279be3a7 | f43873ec720136f3d2f9df14649ad46ea3271dbc | refs/heads/master | 2020-05-29T16:38:52.883171 | 2016-07-17T10:55:56 | 2016-07-17T10:55:56 | 58,258,039 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 274 | java | package action06_homework;
public class MainCalc {
public static void main(String[] args) {
Calculator calc = new Calc();
String str = "15*2=";
for(char p:str.toCharArray()){
System.out.println("Input "+p);
calc.inChar(p);
System.out.println();
}
}
}
| [
"Natali@Nats"
] | Natali@Nats |
62041d21e89d22c12ae1567d486d85a285ffa131 | 85eff3b7cabd0c21a6e08fe863a959f11b232126 | /app/src/main/java/me/tmgg/viewsdemoapp/fragments/BottomBehaviorFragment.java | 4db5fdf160dfe79c1ea022e1e12b588cb304f26b | [] | no_license | Aidenat9/CustomViewsDemo | b969cdcadbea0785e24b50b6fd7a28b8e257d453 | fc114503a4029ef342376c2dc39f485916cd83dc | refs/heads/master | 2020-04-27T11:52:43.861470 | 2019-12-11T03:53:35 | 2019-12-11T03:53:35 | 174,312,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,369 | java | package me.tmgg.viewsdemoapp.fragments;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.design.widget.BottomSheetBehavior;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import me.tmgg.viewsdemoapp.R;
/**
* @author sunwei
* email:tianmu19@gmail.com
* date:2019/4/29 11:48
* version:1.0
* <p>description:BottomBehaviorFragment </p>
*/
public class BottomBehaviorFragment extends Fragment {
private LinearLayout llContentBottomSheet;
public BottomBehaviorFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_bottom_behavior, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
llContentBottomSheet = view.findViewById(R.id.ll_content_bottom_sheet);
initListen();
}
private void initListen(){
/**
* STATE_COLLAPSED:折叠状态,bottom sheets只在底部显示一部分布局。显示高度可以通过 app:behavior_peekHeight 设置;
* STATE_DRAGGING:过渡状态,此时用户正在向上或者向下拖动bottom sheet;
* STATE_SETTLING: 视图从脱离手指自由滑动到最终停下的这一小段时间
* STATE_EXPANDED: 完全展开的状态
* STATE_HIDDEN: 隐藏状态。默认是false,可通过app:behavior_hideable属性设置是否能隐藏
*
* 这种使用方法是没有蒙层,可以对其他控件进行操作。
*/
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(llContentBottomSheet);
bottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View bottomSheet, int newState) {
switch (newState) {
case BottomSheetBehavior.STATE_COLLAPSED:
Log.e("Bottom Sheet Behaviour", "STATE_COLLAPSED");
break;
case BottomSheetBehavior.STATE_DRAGGING:
Log.e("Bottom Sheet Behaviour", "STATE_DRAGGING");
break;
case BottomSheetBehavior.STATE_EXPANDED:
Log.e("Bottom Sheet Behaviour", "STATE_EXPANDED");
break;
case BottomSheetBehavior.STATE_HIDDEN:
Log.e("Bottom Sheet Behaviour", "STATE_HIDDEN");
break;
case BottomSheetBehavior.STATE_SETTLING:
Log.e("Bottom Sheet Behaviour", "STATE_SETTLING");
break;
default:
break;
}
}
@Override
public void onSlide(@NonNull View bottomSheet, float slideOffset) {
}
});
}
}
| [
"tianmu19@gmail.com"
] | tianmu19@gmail.com |
a34de1335ccead3f304ffc8af2451da66f401766 | 465b02a7eff2bf2436da960c1afcca5be8af33bd | /app/src/main/java/com/example/moderndashboardui/HomeActivity.java | 81ffe271c1fea8afbabd50e3471355077a5e9c86 | [] | no_license | SagarBChauhan/Modern-UI-Android | 4efc5dc125d23f8ee1fe6dd0cd0f57d72752a44c | 528f55088e882f7ae01730f366e56e36fd1419ae | refs/heads/main | 2022-12-24T10:40:19.214195 | 2020-10-05T04:58:49 | 2020-10-05T04:58:49 | 301,297,636 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 703 | java | package com.example.moderndashboardui;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
public class HomeActivity extends AppCompatActivity {
private static int SPLASH_TIMEOUT=500;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(HomeActivity.this,AppIntroActivity.class));
finish();
}
},SPLASH_TIMEOUT);
}
}
| [
"chauhansagar373@gmail.com"
] | chauhansagar373@gmail.com |
83eaa38fa26ed5dae03cb789aa6a3792cfd3f150 | 04245ecc554d8021a3e23c1cd96caf0fa37bfd58 | /java-basic/src/main/java/bitcamp/java100/ch06/ex3/Test4.java | cc9b49ee0870af1a860980cf6dbfb50fe236d9ab | [] | no_license | soso1525/bitcamp | e2514059aac58566992f761dc1daa63091eb26ce | 993ad9e06d8fa4fa336a20a78eb31c5ee9bd9a8e | refs/heads/master | 2021-09-02T09:05:17.220450 | 2018-01-01T08:18:10 | 2018-01-01T08:18:10 | 104,423,404 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 132 | java | package bitcamp.java100.ch06.ex3;
public class Test4 {
public static void main(String[] args) {
MyClass3.m1();
}
}
| [
"clean"
] | clean |
58e0bc59df186c141fae3bf8a48957176ab0a446 | 3b232eff647d0db230f95ac3c315850f4d79c7ba | /src/main/java/io/sdb/sys/oauth2/TokenGenerator.java | a98882352f4eac95ba704ab77e839c7e218031a5 | [
"Apache-2.0"
] | permissive | mankycat/sdb-mall | dd6945028e477afead4175937efc7bf508d83484 | 1c9f88aeff3b1d7ab70ff90393f5a6c35d770f34 | refs/heads/master | 2021-09-28T16:42:43.745050 | 2018-11-18T14:57:56 | 2018-11-18T15:09:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,225 | java | package io.sdb.sys.oauth2;
import io.sdb.common.exception.RRException;
import java.security.MessageDigest;
import java.util.UUID;
/**
* 生成token
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2017-05-20 14:41
*/
public class TokenGenerator {
public static String generateValue() {
return generateValue(UUID.randomUUID().toString());
}
private static final char[] hexCode = "0123456789abcdef".toCharArray();
public static String toHexString(byte[] data) {
if(data == null) {
return null;
}
StringBuilder r = new StringBuilder(data.length*2);
for ( byte b : data) {
r.append(hexCode[(b >> 4) & 0xF]);
r.append(hexCode[(b & 0xF)]);
}
return r.toString();
}
public static String generateValue(String param) {
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(param.getBytes());
byte[] messageDigest = algorithm.digest();
return toHexString(messageDigest);
} catch (Exception e) {
throw new RRException("生成Token失败", e);
}
}
}
| [
"40612328@qq.com"
] | 40612328@qq.com |
749835c7a7b1268815ff06442c46ff59c08a905d | 8782051a18d608de4c0c64229153f1636b60c528 | /plugins/android-designer/src/com/intellij/android/designer/model/ModelParser.java | e67384ab57f74bdf6307d989d32ffd45e78dd728 | [
"Apache-2.0"
] | permissive | DavyLin/intellij-community | 1401c4b79fae36bbcfd6fa540496c29edfd80c83 | 713829cd75a25e2f8fa43439771dd3a7feb1df9d | refs/heads/master | 2020-12-25T05:16:52.553204 | 2012-06-27T23:02:15 | 2012-06-27T23:03:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,527 | java | /*
* Copyright 2000-2012 JetBrains s.r.o.
*
* 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.intellij.android.designer.model;
import com.android.ide.common.rendering.api.RenderSession;
import com.android.ide.common.rendering.api.ViewInfo;
import com.intellij.android.designer.designSurface.AndroidPasteFactory;
import com.intellij.android.designer.designSurface.RootView;
import com.intellij.designer.model.MetaManager;
import com.intellij.designer.model.MetaModel;
import com.intellij.designer.model.RadComponent;
import com.intellij.designer.model.RadLayout;
import com.intellij.lang.Language;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.fileTypes.StdFileTypes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Computable;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiErrorElement;
import com.intellij.psi.XmlElementFactory;
import com.intellij.psi.XmlRecursiveElementVisitor;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlFile;
import com.intellij.psi.xml.XmlTag;
import com.intellij.xml.util.XmlUtil;
import org.jdom.Attribute;
import org.jdom.Element;
import org.jetbrains.annotations.Nullable;
import java.util.List;
/**
* @author Alexander Lobas
*/
public class ModelParser extends XmlRecursiveElementVisitor {
public static final String NO_ROOT_CONTENT =
"<?xml version=\"1.0\" encoding=\"utf-8\"?><LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:layout_width=\"fill_parent\" android:layout_height=\"fill_parent\" android:orientation=\"vertical\"></LinearLayout>";
public static final String XML_FILE_KEY = "XML_FILE";
public static final String MODULE_KEY = "MODULE";
private static final int EMPTY_COMPONENT_SIZE = 5;
private final IdManager myIdManager = new IdManager();
private final MetaManager myMetaManager;
private final XmlFile myXmlFile;
private RadViewComponent myRootComponent;
private RadViewComponent myComponent;
private String myLayoutXmlText;
public ModelParser(Project project, XmlFile xmlFile) {
myMetaManager = ViewsMetaManager.getInstance(project);
myXmlFile = xmlFile;
parse();
}
//////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////
private void parse() {
myLayoutXmlText = ApplicationManager.getApplication().runReadAction(new Computable<String>() {
@Override
public String compute() {
XmlTag root = myXmlFile.getRootTag();
if (checkTag(root)) {
root.accept(ModelParser.this);
return myXmlFile.getText();
}
return NO_ROOT_CONTENT;
}
});
}
@Override
public void visitXmlTag(XmlTag tag) {
try {
MetaModel metaModel = myMetaManager.getModelByTag(tag.getName());
if (metaModel == null) {
metaModel = myMetaManager.getModelByTag("view");
}
RadViewComponent component = createComponent(tag, metaModel);
myIdManager.addComponent(component);
if (myRootComponent == null) {
myRootComponent = component;
}
if (myComponent != null) {
myComponent.add(component, null);
}
myComponent = component;
super.visitXmlTag(tag);
myComponent = (RadViewComponent)component.getParent();
}
catch (Throwable e) {
throw new RuntimeException(e);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////
public static RadViewComponent createComponent(@Nullable XmlTag tag, MetaModel metaModel) throws Exception {
RadViewComponent component = (RadViewComponent)metaModel.getModel().newInstance();
component.setMetaModel(metaModel);
component.setTag(tag);
Class<RadLayout> layout = metaModel.getLayout();
if (layout == null) {
component.setLayout(RadViewLayout.INSTANCE);
}
else {
component.setLayout(layout.newInstance());
}
return component;
}
public static void moveComponent(final RadViewComponent container,
final RadViewComponent movedComponent,
@Nullable final RadViewComponent insertBefore)
throws Exception {
movedComponent.removeFromParent();
container.add(movedComponent, insertBefore);
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
XmlTag xmlTag = movedComponent.getTag();
XmlTag parentTag = container.getTag();
XmlTag nextTag = insertBefore == null ? null : insertBefore.getTag();
XmlTag newXmlTag;
if (nextTag == null) {
newXmlTag = parentTag.addSubTag(xmlTag, false);
}
else {
newXmlTag = (XmlTag)parentTag.addBefore(xmlTag, nextTag);
}
xmlTag.delete();
movedComponent.updateTag(newXmlTag);
}
});
XmlFile xmlFile = container.getRoot().getClientProperty(XML_FILE_KEY);
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(xmlFile.getProject());
psiDocumentManager.commitDocument(psiDocumentManager.getDocument(xmlFile));
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
propertyParser.load(movedComponent);
}
public static void addComponent(RadViewComponent container, final RadViewComponent newComponent, @Nullable RadViewComponent insertBefore)
throws Exception {
container.add(newComponent, insertBefore);
addComponentTag(container.getTag(), newComponent, insertBefore == null ? null : insertBefore.getTag(), new Computable<String>() {
@Override
public String compute() {
String creation = newComponent.getMetaModel().getCreation();
return creation == null ? newComponent.getCreationXml() : creation;
}
});
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
propertyParser.load(newComponent);
if (!newComponent.getTag().isEmpty()) {
addComponent(newComponent, ViewsMetaManager.getInstance(newComponent.getTag().getProject()), propertyParser);
}
IdManager.get(container).ensureIds(newComponent);
}
private static void addComponent(RadViewComponent parentComponent,
MetaManager metaManager,
PropertyParser propertyParser) throws Exception {
for (XmlTag tag : parentComponent.getTag().getSubTags()) {
MetaModel metaModel = metaManager.getModelByTag(tag.getName());
if (metaModel == null) {
metaModel = metaManager.getModelByTag("view");
}
RadViewComponent component = createComponent(tag, metaModel);
parentComponent.add(component, null);
propertyParser.load(component);
addComponent(component, metaManager, propertyParser);
}
}
public static void pasteComponent(RadViewComponent container, RadViewComponent newComponent, @Nullable RadViewComponent insertBefore)
throws Exception {
container.add(newComponent, insertBefore);
PropertyParser propertyParser = container.getRoot().getClientProperty(PropertyParser.KEY);
pasteComponent(newComponent, container.getTag(), insertBefore == null ? null : insertBefore.getTag(), propertyParser);
IdManager.get(container).ensureIds(newComponent);
}
private static void pasteComponent(final RadViewComponent component,
XmlTag parentTag,
XmlTag nextTag,
PropertyParser propertyParser) throws Exception {
addComponentTag(parentTag, component, nextTag, new Computable<String>() {
@Override
public String compute() {
Element pasteProperties = component.extractClientProperty(AndroidPasteFactory.KEY);
if (pasteProperties == null) {
return component.getMetaModel().getCreation();
}
StringBuilder builder = new StringBuilder();
builder.append("<").append(component.getMetaModel().getTag());
for (Object object : pasteProperties.getAttributes()) {
Attribute attribute = (Attribute)object;
builder.append(" ").append(attribute.getName()).append("=\"").append(attribute.getValue()).append("\"");
}
for (Object object : pasteProperties.getChildren()) {
Element element = (Element)object;
String namespace = element.getName();
for (Object child : element.getAttributes()) {
Attribute attribute = (Attribute)child;
builder.append(" ").append(namespace).append(":").append(attribute.getName()).append("=\"").append(attribute.getValue()).append(
"\"");
}
}
if (builder.indexOf("android:layout_width=\"") == -1) {
builder.append(" android:layout_width=\"wrap_content\"");
}
if (builder.indexOf("android:layout_height=\"") == -1) {
builder.append(" android:layout_height=\"wrap_content\"");
}
return builder.append("/>").toString();
}
});
XmlTag xmlTag = component.getTag();
List<RadComponent> children = component.getChildren();
int size = children.size();
for (int i = 0; i < size; i++) {
RadViewComponent child = (RadViewComponent)children.get(i);
XmlTag nextChildTag = null;
if (i + 1 < size) {
nextChildTag = ((RadViewComponent)children.get(i + 1)).getTag();
}
pasteComponent(child, xmlTag, nextChildTag, propertyParser);
}
propertyParser.load(component);
}
public static void addComponentTag(final XmlTag parentTag,
final RadViewComponent component,
final XmlTag nextTag,
final Computable<String> tagBuilder) {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
Project project;
RadViewComponent root = null;
XmlFile xmlFile = null;
if (!checkTag(parentTag) && component.getParent() == component.getRoot()) {
root = (RadViewComponent)component.getParent();
xmlFile = root.getClientProperty(XML_FILE_KEY);
project = xmlFile.getProject();
}
else {
project = parentTag.getProject();
}
Language language = StdFileTypes.XML.getLanguage();
XmlTag xmlTag =
XmlElementFactory.getInstance(project).createTagFromText("\n" + tagBuilder.compute(), language);
if (checkTag(parentTag)) {
if (nextTag == null) {
xmlTag = parentTag.addSubTag(xmlTag, false);
}
else {
xmlTag = (XmlTag)parentTag.addBefore(xmlTag, nextTag);
}
}
else {
xmlTag.setAttribute("xmlns:android", "http://schemas.android.com/apk/res/android");
xmlTag = (XmlTag)xmlFile.getDocument().add(xmlTag);
XmlUtil.expandTag(xmlTag);
root.setTag(xmlFile.getDocument().getRootTag());
}
component.setTag(xmlTag);
}
});
}
public static boolean checkTag(XmlTag tag) {
try {
return tag != null && tag.getFirstChild() != null && !(tag.getFirstChild() instanceof PsiErrorElement) && tag.getProject() != null;
}
catch (Throwable e) {
return false;
}
}
public static void deleteAttribute(RadComponent component, String name) {
deleteAttribute(((RadViewComponent)component).getTag(), name);
}
public static void deleteAttribute(XmlTag tag, String name) {
XmlAttribute attribute = tag.getAttribute(name);
if (attribute != null) {
attribute.delete();
}
}
//////////////////////////////////////////////////////////////////////////////////////////
//
//
//
//////////////////////////////////////////////////////////////////////////////////////////
public RadViewComponent getRootComponent() {
return myRootComponent;
}
public String getLayoutXmlText() {
return myLayoutXmlText;
}
public void updateRootComponent(RenderSession session, RootView nativeComponent) throws Exception {
if (myRootComponent == null) {
myRootComponent = createComponent(myXmlFile.getRootTag(), myMetaManager.getModelByTag("<root>"));
}
else if (myRootComponent.getMetaModel() != myMetaManager.getModelByTag("merge")) {
RadViewComponent rootComponent = myRootComponent;
myRootComponent = createComponent(myXmlFile.getRootTag(), myMetaManager.getModelByTag("<root>"));
myRootComponent.add(rootComponent, null);
}
updateRootComponent(myRootComponent, session, nativeComponent);
myRootComponent.setClientProperty(IdManager.KEY, myIdManager);
}
public static void updateRootComponent(RadViewComponent rootComponent,
RenderSession session,
RootView nativeComponent) {
updateChildren(rootComponent, session.getRootViews(), nativeComponent, 0, 0);
rootComponent.setNativeComponent(nativeComponent);
rootComponent.setBounds(0, 0, nativeComponent.getWidth(), nativeComponent.getHeight());
}
private static void updateComponent(RadViewComponent component,
ViewInfo view,
RootView nativeComponent,
int parentX,
int parentY) {
component.setViewInfo(view);
component.setNativeComponent(nativeComponent);
int left = parentX + view.getLeft();
int top = parentY + view.getTop();
int width = view.getRight() - view.getLeft();
int height = view.getBottom() - view.getTop();
if (width < EMPTY_COMPONENT_SIZE && height < EMPTY_COMPONENT_SIZE) {
nativeComponent.addEmptyRegion(left, top, EMPTY_COMPONENT_SIZE, EMPTY_COMPONENT_SIZE);
}
component.setBounds(left, top, Math.max(width, EMPTY_COMPONENT_SIZE), Math.max(height, EMPTY_COMPONENT_SIZE));
updateChildren(component, view.getChildren(), nativeComponent, left, top);
}
private static void updateChildren(RadViewComponent component, List<ViewInfo> views, RootView nativeComponent, int left, int top) {
List<RadComponent> children = component.getChildren();
int size = children.size();
for (int componentIndex = 0, viewIndex = 0; componentIndex < size; componentIndex++) {
RadViewComponent childComponent = (RadViewComponent)children.get(componentIndex);
if (!(childComponent instanceof RadRequestFocus)) {
updateComponent(childComponent, views.get(viewIndex++), nativeComponent, left, top);
}
}
}
} | [
"Alexander.Lobas@jetbrains.com"
] | Alexander.Lobas@jetbrains.com |
005fad29dc6013497007b4f0eb0525499c742e2e | 7d31655830c9e6d7fae764190262661d2f4d6942 | /app/src/main/java/com/example/myapplication/Activity_2.java | 1e57d64d7312dfb8312f27f327d54032aac4aec2 | [] | no_license | yang-haohao/Experiment1 | 5a4066910008ec493a8f217ff4de95e0ac7a2038 | cd94d465318b582347fe65427621feed8634cdc7 | refs/heads/master | 2021-02-28T22:01:37.063560 | 2020-03-07T13:55:28 | 2020-03-07T13:55:28 | 245,639,184 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 644 | java | package com.example.myapplication;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class Activity_2 extends AppCompatActivity {
Button btn2_5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_2);
btn2_5=(Button)findViewById(R.id.btn2_5);
btn2_5.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
}
| [
"963347149@qq.com"
] | 963347149@qq.com |
fdb1b93216dd611bdab84fe4a0dc720c3ca810ef | fcf845eda05398434698d5e1527bb561c7ddc100 | /zm-study-common/src/main/java/com/spring/common/util/FileUtil.java | d7e28cb3e9259a0bc8bd16ae1e1249e98308dc68 | [] | no_license | lovezmming/zm-study | f41b4e7f461c7a4e13cd4440521dd3a8a62a5b18 | 046840180261e2729304fdb18df43dee66df8804 | refs/heads/master | 2020-04-11T20:54:34.703524 | 2019-04-25T07:52:15 | 2019-04-25T07:52:15 | 162,087,958 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,737 | java | package com.spring.common.util;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileUtil
{
public static String getFileExtention(String fileName)
{
if (TextUtil.isEmpty(fileName))
return null;
return fileName.substring(fileName.lastIndexOf("."));
}
public static void deleteFile(String filePath)
{
File file = new File(filePath);
if (file.exists())
file.delete();
}
public static byte[] file2byte(String filePath)
{
return file2byte(new File(filePath));
}
public static byte[] file2byte(File file)
{
byte[] buffer = null;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream(file);
bos = new ByteArrayOutputStream();
byte[] b = new byte[1024];
int n;
while ((n = fis.read(b)) != -1)
{
bos.write(b, 0, n);
}
fis.close();
bos.close();
buffer = bos.toByteArray();
}
catch (Exception e)
{
throw new RuntimeException(e);
}
finally
{
try
{
if (fis != null)
{
fis.close();
fis = null;
}
if (bos != null)
{
bos.close();
bos = null;
}
} catch (Exception e2) {}
}
return buffer;
}
public static void byte2File(byte[] buf, String dest, String name)
{
BufferedOutputStream bos = null;
FileOutputStream fos = null;
File file = null;
try
{
File dir = new File(dest);
if (!dir.exists())
dir.mkdirs();
file = new File(dest + File.separator + name);
fos = new FileOutputStream(file);
bos = new BufferedOutputStream(fos);
bos.write(buf);
} catch (Exception e)
{
throw new RuntimeException(e);
} finally
{
try
{
if (bos != null)
{
bos.close();
bos = null;
}
if (fos != null)
{
fos.close();
fos = null;
}
} catch (IOException e)
{
}
}
}
}
| [
"zmzmlla@163.com"
] | zmzmlla@163.com |
9c44e897ac080ce0f6f58f3e232c46b57ff70990 | d49a923cbf90b65a3f0a5e903686fa90959c9f5c | /app/src/androidTest/java/com/lonja/calculator/ExampleInstrumentedTest.java | 237a17d714f9392a5915f9644584fc3cc62a0735 | [] | no_license | lonja/Calculator | 2db0574da13336929ae7bf9352a2298ab3c66c3b | 7cb45864a1d22a79250d5867bd1636da3aa66c85 | refs/heads/master | 2021-01-19T00:54:12.976451 | 2016-08-18T10:34:36 | 2016-08-18T10:34:36 | 64,851,518 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package com.lonja.calculator;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumentation test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.lonja.calculator", appContext.getPackageName());
}
}
| [
"lonja007@gmail.com"
] | lonja007@gmail.com |
4a9cda82fbc0d3a079dafc56dc05dba6ca8e86ba | 4ad89a9887a62984a37c96af51dcfc20f3bcc430 | /app/src/androidTest/java/com/yasar/yasar/ApplicationTest.java | 8b8ec616c55ace942e31f0a2cdf0a74e17e54ad8 | [] | no_license | rmcconkey/Yasar | 347446a8216d5f463b57820127a769c6a9197b70 | 7ee39fbe768fb2c74381b16bf17d1142e34042d8 | refs/heads/master | 2021-01-02T09:15:06.863189 | 2015-04-30T14:04:23 | 2015-04-30T14:04:23 | 22,198,701 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package com.yasar.yasar;
import android.app.Application;
import android.test.ApplicationTestCase;
/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
} | [
"robert.mcconkey@cont.scientificgames.com"
] | robert.mcconkey@cont.scientificgames.com |
81c96fd132a9773c320d728e0670e2445e2ec758 | 92ce0c6cf4973c7b81af7187a1c1c1de4e9ac655 | /src/robosorter/MartianEgg.java | d72be159981ef1b6c78cdf5a58881b581e1d9a96 | [] | no_license | AustinHyunwooLee/Game | fd936dc5cb36f9b3077c36583288d7e250ef99be | 6dab83ecc05910071a724fe219b68edce2232363 | refs/heads/master | 2020-03-16T19:57:32.777622 | 2018-05-10T18:42:06 | 2018-05-10T18:42:06 | 132,939,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,372 | java | /*
* 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 robosorter;
import basicgraphics.BasicFrame;
import basicgraphics.Sprite;
import basicgraphics.SpriteComponent;
import basicgraphics.images.Picture;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
/**
*
* @author sbrandt
*/
public class MartianEgg extends Sprite {
final int num;
public MartianEgg(SpriteComponent sc,int num) {
this.num = num;
BufferedImage image = BasicFrame.createImage(Robo.BLOCK_SIZE, Robo.BLOCK_SIZE);
Graphics g = image.getGraphics();
g.setColor(Color.white);
g.fillRect(0, 0, Robo.BLOCK_SIZE, Robo.BLOCK_SIZE);
g.setColor(new Color(0xEE,0xEE,0xFF));
g.fillOval(0, 0, Robo.BLOCK_SIZE, Robo.BLOCK_SIZE);
g.setColor(Color.BLACK);
g.drawOval(0, 0, Robo.BLOCK_SIZE, Robo.BLOCK_SIZE);
g.setFont(new Font(Font.MONOSPACED, Font.BOLD, Robo.BLOCK_SIZE/2));
g.drawString(""+num, Robo.BLOCK_SIZE/5, Robo.BLOCK_SIZE*3/4);
setPicture(new Picture(image));
getPicture().transparentWhite();
sc.addSprite(this);
}
public String toString() {
return "Egg("+num+")";
}
}
| [
"austinkwonlee@gmail.com"
] | austinkwonlee@gmail.com |
7904bc07389a839c97734b4a54c2f4037fe72f10 | fea154b7f411b5aa40d1155d5b18372fc32c3e7f | /Exercícios de Aulas/10-15/TratamentoExecao/src/com/Fatec/Conta.java | e0cfca48c364f98923ea14e54e431b297c0c0327 | [
"MIT"
] | permissive | Felix-xilef/Programacao-Orientada-a-Objeto | 2983c38244b51297f2c4148838b2ba730b13c219 | ed30d6c8f8bb13ee0cadcfe4fb8a7d51c24ad12f | refs/heads/master | 2023-02-15T23:44:18.066683 | 2021-01-10T01:01:54 | 2021-01-10T01:01:54 | 289,007,696 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,242 | java | /*
* 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 com.Fatec;
/**
*
* @author Felix Petiz Bonilho
*/
public class Conta {
private String correntista;
private double saldo;
public boolean saca(double valor) throws Exception{
if(valor > saldo) {
//Gerar uma Exceção
throw new Exception("Saldo da conta não permite esse saque!!!");
} else {
saldo -= valor;
return true;
}
}
public void saca2(double valor) throws SaldoInsuficienteException {
if(valor > saldo) {
//Gerar uma Exceção
throw new SaldoInsuficienteException("Saldo da conta não permite esse saque!!!");
} else {
saldo -= valor;
}
}
//Getters & Setters
public String getCorrentista() {
return correntista;
}
public void setCorrentista(String correntista) {
this.correntista = correntista;
}
public double getSaldo() {
return saldo;
}
public void setSaldo(double saldo) {
this.saldo = saldo;
}
}
| [
"felixpb@yahoo.com.br"
] | felixpb@yahoo.com.br |
e7e5a558f98cc18a7a64813d19d58623af983a79 | ce9d7ba4f41e7a168c2da48ef44b9e3c18ea3545 | /src/main/java/com/com/crc/test/TestApi.java | 5c572d8c3cd853db6b77c89880a9962d1cba0a2f | [] | no_license | clickear/neteasemusic | af22f78f1ec1dca19e9eb8abe7c9967561f181b3 | bbf3f1f5d7fb291371f72d09c3ba8bf5efbf76f7 | refs/heads/master | 2021-01-12T17:47:14.196283 | 2017-02-18T13:52:46 | 2017-02-18T13:52:46 | 69,390,812 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 817 | java | package com.com.crc.test;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
/**
* Created by Administrator on 2016/10/1.
*/
public class TestApi {
public TestApi() throws UnirestException {
HttpResponse<JsonNode> jsonResponse = Unirest.post("http://httpbin.org/post")
.header("accept", "application/json")
.queryString("apiKey", "123")
.field("parameter", "value")
.field("foo", "bar")
.asJson();
System.out.println(jsonResponse.getBody().getObject());
}
public static void main(String[] args) throws UnirestException {
TestApi a = new TestApi();
}
}
| [
"434647670@qq.com"
] | 434647670@qq.com |
014325132f816620cb03a8196aacb705a9bdb2e5 | 6f26f208788308b62dd6dc9e8fd0a7a3c89ae0c4 | /foundation/src/main/java/com/doublev2v/foundation/core/rest/RequestResult.java | 866f03b6bc4ea6b7281e1ee8558e1fe3a8e08624 | [] | no_license | lysun/Integralmall | 4da7d0349c91116d77925ceb85f4d647476eb236 | bf853a5f70d9ce1053174ef2c9d1af9ffba31dcd | refs/heads/master | 2021-01-25T12:23:57.863338 | 2015-11-11T06:19:14 | 2015-11-11T06:19:14 | 42,639,212 | 2 | 4 | null | null | null | null | UTF-8 | Java | false | false | 2,402 | java | package com.doublev2v.foundation.core.rest;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.doublev2v.foundation.utils.JsonSerializer;
/**
* 请求结果,分成功结果和错误结果两种
* @author pc
*
*/
public abstract class RequestResult {
private static Logger logger=LoggerFactory.getLogger(RequestResult.class);
public static <T> SuccessResult<T> success(T result) {
SuccessResult<T> successResult=new SuccessResult<>();
successResult.result=result;
return successResult;
}
public static FailResult error(Integer code, String error, String errorDescription) {
FailResult failResult=new FailResult();
failResult.setCode(code);
failResult.setError(error);
failResult.setErrorDescription(errorDescription);
return failResult;
}
public static FailResult error(ErrorCode code, String errorDescription) {
return error(code.getCode(), code.getError(), errorDescription);
}
public String toJson() {
try {
return JsonSerializer.Serialize(this);
} catch (IOException e) {
logger.debug(e.getMessage(), e);
return e.getMessage();
}
}
public abstract RequestStatus getStatus();
public static enum RequestStatus {
OK,ERROR
}
public static class SuccessResult<T> extends RequestResult {
private SuccessResult(){}
private T result;
public T getResult() {
return result;
}
public void setResult(T result) {
this.result = result;
}
@Override
public RequestStatus getStatus() {
return RequestStatus.OK;
}
}
public static class FailResult extends RequestResult {
private FailResult(){}
private Integer code;
private String error;
private String errorDescription;
/**
* @return the code
*/
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
/**
* @return the error
*/
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
/**
* @return the errorDescription
*/
public String getErrorDescription() {
return errorDescription;
}
/**
* @param errorDescription the errorDescription to set
*/
public void setErrorDescription(String errorDescription) {
this.errorDescription = errorDescription;
}
@Override
public RequestStatus getStatus() {
return RequestStatus.ERROR;
}
}
}
| [
"sunli_200704@126.com"
] | sunli_200704@126.com |
ddd7de6311220da12b8bd834f5e212e11d7a5932 | 60d3b2699f658f025b3fe7f1117e1ed1601320de | /Minol/src/main/java/com/minoapp/adapter/CustomerListAdapter.java | 34979e9e12c21f4a8c6df1996887a80c2a382996 | [] | no_license | jt19880807/MinoApp | 495611f1a61d7867f04adddfd5cffb70645c84a3 | 3e92df29e080970ee3a727aa1bb6e55b760ed37c | refs/heads/master | 2021-01-02T08:55:03.579816 | 2017-10-13T08:44:58 | 2017-10-13T08:44:58 | 99,096,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,585 | java | package com.minoapp.adapter;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseSectionQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.minoapp.R;
import com.minoapp.data.bean.CustomerBean;
import com.minoapp.data.bean.CustomerSectionEntity;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Devin on 2017/6/28.
*/
public class CustomerListAdapter extends BaseSectionQuickAdapter<CustomerSectionEntity<CustomerBean>,BaseViewHolder>{
/**
* Same as QuickAdapter#QuickAdapter(Context,int) but with
* some initialization data.
*
* @param layoutResId The layout resource id of each item.
* @param sectionHeadResId The section head layout id for each item
* @param data A new list is created out of this one to avoid mutable list
*/
public CustomerListAdapter(int layoutResId, int sectionHeadResId, List<CustomerSectionEntity<CustomerBean>> data) {
super(layoutResId, sectionHeadResId, data);
}
@Override
protected void convertHead(BaseViewHolder helper, CustomerSectionEntity<CustomerBean> item) {
helper.setText(R.id.tv_hca_reading_header,item.title);
}
@Override
protected void convert(BaseViewHolder helper, CustomerSectionEntity<CustomerBean> item) {
helper.setText(R.id.tv_customerarea,item.customerBean.getName());
}
}
| [
"422836331@qq.com"
] | 422836331@qq.com |
97a4b37283fe3b3c02c4b9ee1b1992a2b43ba2c8 | 3f7a5d7c700199625ed2ab3250b939342abee9f1 | /src/gcom/gui/faturamento/credito/AtualizarTipoCreditoAction.java | 41e44d488b75391f9ca2b80c92653a29d374c081 | [] | no_license | prodigasistemas/gsan-caema | 490cecbd2a784693de422d3a2033967d8063204d | 87a472e07e608c557e471d555563d71c76a56ec5 | refs/heads/master | 2021-01-01T06:05:09.920120 | 2014-10-08T20:10:40 | 2014-10-08T20:10:40 | 24,958,220 | 1 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 6,620 | java | /*
* Copyright (C) 2007-2007 the GSAN - Sistema Integrado de Gestão de Serviços de Saneamento
*
* This file is part of GSAN, an integrated service management system for Sanitation
*
* GSAN 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 2 of the License.
*
* GSAN 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
/*
* GSAN - Sistema Integrado de Gestão de Serviços de Saneamento
* Copyright (C) <2007>
* Adriano Britto Siqueira
* Alexandre Santos Cabral
* Ana Carolina Alves Breda
* Ana Maria Andrade Cavalcante
* Aryed Lins de Araújo
* Bruno Leonardo Rodrigues Barros
* Carlos Elmano Rodrigues Ferreira
* Cláudio de Andrade Lira
* Denys Guimarães Guenes Tavares
* Eduardo Breckenfeld da Rosa Borges
* Fabíola Gomes de Araújo
* Flávio Leonardo Cavalcanti Cordeiro
* Francisco do Nascimento Júnior
* Homero Sampaio Cavalcanti
* Ivan Sérgio da Silva Júnior
* José Edmar de Siqueira
* José Thiago Tenório Lopes
* Kássia Regina Silvestre de Albuquerque
* Leonardo Luiz Vieira da Silva
* Márcio Roberto Batista da Silva
* Maria de Fátima Sampaio Leite
* Micaela Maria Coelho de Araújo
* Nelson Mendonça de Carvalho
* Newton Morais e Silva
* Pedro Alexandre Santos da Silva Filho
* Rafael Corrêa Lima e Silva
* Rafael Francisco Pinto
* Rafael Koury Monteiro
* Rafael Palermo de Araújo
* Raphael Veras Rossiter
* Roberto Sobreira Barbalho
* Rodrigo Avellar Silveira
* Rosana Carvalho Barbosa
* Sávio Luiz de Andrade Cavalcante
* Tai Mu Shih
* Thiago Augusto Souza do Nascimento
* Tiago Moreno Rodrigues
* Vivianne Barbosa Sousa
*
* Este programa é software livre; você pode redistribuí-lo e/ou
* modificá-lo sob os termos de Licença Pública Geral GNU, conforme
* publicada pela Free Software Foundation; versão 2 da
* Licença.
* Este programa é distribuído na expectativa de ser útil, mas SEM
* QUALQUER GARANTIA; sem mesmo a garantia implícita de
* COMERCIALIZAÇÃO ou de ADEQUAÇÃO A QUALQUER PROPÓSITO EM
* PARTICULAR. Consulte a Licença Pública Geral GNU para obter mais
* detalhes.
* Você deve ter recebido uma cópia da Licença Pública Geral GNU
* junto com este programa; se não, escreva para Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA.
*/
package gcom.gui.faturamento.credito;
import gcom.fachada.Fachada;
import gcom.faturamento.credito.CreditoTipo;
import gcom.financeiro.lancamento.FiltroLancamentoItemContabil;
import gcom.financeiro.lancamento.LancamentoItemContabil;
import gcom.gui.GcomAction;
import gcom.seguranca.acesso.usuario.Usuario;
import gcom.util.ConstantesSistema;
import gcom.util.filtro.ParametroSimples;
import java.math.BigDecimal;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
public class AtualizarTipoCreditoAction extends GcomAction {
public ActionForward execute(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) {
// Seta o retorno
ActionForward retorno = actionMapping.findForward("telaSucesso");
// Obtém a instância da fachada
Fachada fachada = Fachada.getInstancia();
// Mudar isso quando tiver esquema de segurança
HttpSession sessao = httpServletRequest.getSession(false);
// Usuario logado no sistema
Usuario usuarioLogado = (Usuario)sessao.getAttribute(Usuario.USUARIO_LOGADO);
AtualizarTipoCreditoActionForm atualizarTipoCreditoActionForm = (AtualizarTipoCreditoActionForm) actionForm;
CreditoTipo creditoTipo = (CreditoTipo) sessao
.getAttribute("creditoTipoAtualizar");
// creditoTipo.setId(new Integer(atualizarTipoCreditoActionForm
// .getCodigo()));
creditoTipo.setDescricao(atualizarTipoCreditoActionForm.getDescricao());
creditoTipo.setDescricaoAbreviada(atualizarTipoCreditoActionForm
.getAbreviatura());
creditoTipo.setIndicadorGeracaoAutomatica(new Short(
atualizarTipoCreditoActionForm.getIndicadorgeracaoAutomaica()));
creditoTipo.setIndicadorUso(new Integer(atualizarTipoCreditoActionForm
.getIndicativoUso()));
String valorLimiteCredito = atualizarTipoCreditoActionForm
.getValorLimiteCredito();
valorLimiteCredito = valorLimiteCredito.replace(".", "");
valorLimiteCredito = valorLimiteCredito.replace(",", ".");
creditoTipo.setValorLimite(new BigDecimal(valorLimiteCredito));
// AtendimentoMotivoEncerramento atendimentoMotivoEncerramento = null;
if (atualizarTipoCreditoActionForm.getTipoLancamentoContabil() != null) {
Integer idTipoLancamentoContabil = new Integer(
atualizarTipoCreditoActionForm.getTipoLancamentoContabil());
if (idTipoLancamentoContabil
.equals(ConstantesSistema.NUMERO_NAO_INFORMADO)) {
creditoTipo.setLancamentoItemContabil(null);
} else {
FiltroLancamentoItemContabil filtroLancamentoItemContabil = new FiltroLancamentoItemContabil();
filtroLancamentoItemContabil
.adicionarParametro(new ParametroSimples(
FiltroLancamentoItemContabil.ID,
atualizarTipoCreditoActionForm
.getTipoLancamentoContabil().toString()));
Collection colecaoTipoLancamentoContabil = (Collection) fachada
.pesquisar(filtroLancamentoItemContabil,
LancamentoItemContabil.class.getName());
// setando
creditoTipo
.setLancamentoItemContabil((LancamentoItemContabil) colecaoTipoLancamentoContabil
.iterator().next());
}
}
fachada.atualizarTipoCredito(creditoTipo, usuarioLogado);
montarPaginaSucesso(httpServletRequest, "Tipo de Crédito "
+ creditoTipo.getId().toString() + " atualizado com sucesso.",
"Realizar outra Manutenção de Tipo de Crédito",
"exibirFiltrarTipoCreditoAction.do?menu=sim");
return retorno;
}
}
| [
"felipesantos2089@gmail.com"
] | felipesantos2089@gmail.com |
5adf0937fd4d4c176bff6aab0f0f0de12180ae49 | 80e79f339105a2a83ba5a363ec0f531a83fd06d5 | /SpringBootWithMVCAndThymeleaf/src/main/java/com/msilva/controller/GreetingController.java | f33d96bfae5ce5b1ec3b74035e6e9bdc46affd00 | [] | no_license | maransi/SpringBootWithMVCAndThymeleaf | a124f2abc91814d92d6f3eefc8686a0746e83b7b | 924c5ee3c3193eeef67d04d4880105ec6dd2840a | refs/heads/master | 2022-09-10T00:57:26.576379 | 2020-05-23T22:05:45 | 2020-05-23T22:05:45 | 266,418,978 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,116 | java | package com.msilva.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.msilva.model.Greeting;
@Controller
public class GreetingController {
// @GetMapping("/greeting")
// public String greetingForm(Model model) {
// model.addAttribute("greeting", new Greeting());
// return "greeting";
// }
@PostMapping("/greeting")
public String greeting(@RequestParam(name = "content", required = false, defaultValue = "World") String content,
@RequestParam(name= "id", required = true, defaultValue = "0" ) Long id,
Model model) {
Greeting greeting = new Greeting();
greeting.setContent(content);
greeting.setId(id);
model.addAttribute("greeting", greeting);
return "result";
}
@GetMapping("/greeting")
public String greetingSubmit(Greeting greeting) {
return "greeting";
}
} | [
"maransi"
] | maransi |
674a9eff0253441ab576689d124b88faafe87839 | 7b36dd6bef919ad8570e9ed09d98e37a4c62805e | /javaStmt/src/part1/test/Gugudan.java | a5b679bcdcc9295b527be6a673e522d6bd81fe65 | [] | no_license | HyeonJay/java-Stmt | d6cf3b8a735841736ecdd1f242302dc6569de446 | e268e5371bb52901dbf59c76717d70e0d011145d | refs/heads/master | 2021-01-10T19:51:10.505020 | 2015-07-03T05:58:40 | 2015-07-03T05:58:40 | 38,474,928 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 478 | java | package part1.test;
public class Gugudan
{
public static void main(String[] args)
{
for (int i = 1; i < 10; i++) // ´Ü
{
for (int j = 1; j < 6; j++)
{
System.out.print(j + " * " + i + " = " + (i * j) + "\t"); // Çà
}
System.out.println();
}
System.out.println();
for (int i = 1; i < 10; i++)
{
for (int j = 6; j < 10; j++)
{
System.out.print(j + " * " + i + " = " + (i * j) + "\t"); // Çà
}
System.out.println();
}
}
}
| [
"onsoftel@hanmail.net"
] | onsoftel@hanmail.net |
1da77b53f3bf892a7b18cce223a084e643a81cb0 | 37a30835fcea9664afa873871e479cd28e280378 | /app/src/main/java/com/duy/pascal/interperter/exceptions/parsing/missing/MissingSemicolonTokenException.java | 3e4dfaa29cc5a30173046a8ac09629e1ffdfd10a | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | DereckySany/pascalnide | 2e2ad859ff91809a52817f2a61dac92f048ece85 | c7f3f79ecf4cf6a81b32c7d389aad7f4034c8f01 | refs/heads/master | 2022-01-03T08:00:37.935504 | 2018-03-18T14:02:17 | 2018-03-18T14:02:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,529 | java | /*
* Copyright (c) 2017 Tran Le Duy
*
* 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.duy.pascal.interperter.exceptions.parsing.missing;
import android.content.Context;
import android.support.annotation.NonNull;
import android.text.Spanned;
import com.duy.pascal.interperter.linenumber.LineNumber;
import com.duy.pascal.ui.R;
import static com.duy.pascal.ui.code.ExceptionManager.formatMessageFromResource;
public class MissingSemicolonTokenException extends MissingTokenException {
public MissingSemicolonTokenException(@NonNull LineNumber line) {
super(line);
}
@NonNull
public String getMissingToken() {
return ";";
}
@Override
public boolean canQuickFix() {
return true;
}
@Override
public Spanned getFormattedMessage(@NonNull Context context) {
return formatMessageFromResource(this,
context,
R.string.MissingSemicolonTokenException,
getLineNumber().getLine());
}
}
| [
"tranleduy1233@gmail.com"
] | tranleduy1233@gmail.com |
793ec5d1cbf8042947a021cff80180187a4e5fa9 | 742d9e6fae5a17393f33dfe50fe5c8cf678e89d1 | /MyApplication10/app/src/main/java/com/example/myapplication10/entity/Person.java | 1204ece7e97d4ab7853abedd4db9bd0339efafe9 | [] | no_license | Pistachiout/AndroidProject | c9852f7e9a8018382daf2d6d8511e5f73f2e31e7 | 631accbf525600d82ec759521e75298f4f29de8e | refs/heads/master | 2023-05-09T03:33:03.848169 | 2021-06-02T14:55:15 | 2021-06-02T14:55:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 849 | java | package com.example.myapplication10.entity;
public class Person {
private String name;
private String sex;
private String phone;
public Person() {
}
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getSex() {
return sex;
}
public void setId(int id) {
this.id = id;
}
public void setName(String name) {
this.name = name;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getPhone() {
return phone;
}
public Person(int id, String name, String sex, String phone) {
this.id = id;
this.name = name;
this.sex = sex;
this.phone = phone;
}
}
| [
"63298680+1105358600@users.noreply.github.com"
] | 63298680+1105358600@users.noreply.github.com |
28cbf08b478c36004f8d9f01dbd2f591eceacd6d | cb349a50eeeb658dabe851e6bd4fea02926d9522 | /ParkingEJB/ejbModule/uy/com/parking/bean/IRegistroTipoBean.java | 63801bfcd024da30137af13b6867cc599923aebe | [] | no_license | batliber/Parking | 8003cc8e5cce6b8ec088784cd8abe8afcb6603d0 | 68d680bb47c8b6d96aff0ef1bda2cb7b27261f25 | refs/heads/master | 2020-08-10T15:56:06.227340 | 2014-10-30T03:44:28 | 2014-10-30T03:44:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package uy.com.parking.bean;
import java.util.Collection;
import javax.ejb.Remote;
import uy.com.parking.entities.RegistroTipo;
@Remote
public interface IRegistroTipoBean {
public Collection<RegistroTipo> list();
public void save(RegistroTipo registroTipo);
public void remove(RegistroTipo registroTipo);
public void update(RegistroTipo registroTipo);
} | [
"batliber@gmail.com"
] | batliber@gmail.com |
a4ad3ea067b78a39ef608dfb277c8927f3c13ea2 | 9c9806544de6b11f17ab7eed47d8cee0b0aaac9b | /app/src/main/java/com/mobila/project/today/model/KeyGenerator.java | afb0fd4c01e9d82c608edbf28dc930b3e5854d7e | [] | no_license | jdsee/today | 5c8d5ecec8941c17f310bed45d078bd433f36bb8 | 0a96bd277e112d9e5482252b4a6438fcf4cfba5e | refs/heads/master | 2022-03-27T07:43:39.403860 | 2020-01-14T10:26:03 | 2020-01-14T10:26:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package com.mobila.project.today.model;
import java.util.UUID;
class KeyGenerator {
private KeyGenerator(){}
static String getUniqueKey(){
return UUID.randomUUID().toString();
}
}
| [
"46045816+zink-l@users.noreply.github.com"
] | 46045816+zink-l@users.noreply.github.com |
a02049b497f5f8f8bf5124f18378575fbad3f1da | 88225e1e02f087e7efd2a2e8e625ee229aca0790 | /uk.co.dancowan.robots.hal/src/uk/co/dancowan/robots/hal/core/CommandEvent.java | d8f030295763e036875b21f030000b07c825b6b7 | [] | no_license | mpmyanaga/roboworkbench | 4c59504db36e3ebfa0126ebff14761505023ea62 | 571705d176d3133d271a5db05fa23ec935461859 | refs/heads/master | 2021-01-19T20:19:05.561987 | 2010-05-01T20:33:28 | 2010-05-01T20:33:28 | 35,653,361 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,132 | java | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright (C) 2009 Dan Cowan
*
* This program 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 2 of the License, or
* (at your option) 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 (www.gnu.org/licenses)
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
package uk.co.dancowan.robots.hal.core;
/**
* Event class thrown by <code>Command</code> instances to indicate events in the life
* cycle of the <code>Command</code>.
*
* @author Dan Cowan
* @since version 1.0.0
*/
public class CommandEvent
{
// Event fields are traditionally public :(
public final Command mSource;
public final String mCommandID;
public final String mMessage;
public final long mTime;
/**
* C'tor.
*
* @param source the Command which fired the event
* @param message String, the event's message
*/
public CommandEvent(Command source, String message)
{
mSource = source;
mCommandID = mSource.getName();
mMessage = message;
mTime = System.currentTimeMillis();
}
/**
* Returns the <code>Command</code> which caused this event.
*
* @return Command the source of this event
*/
public Command getSource()
{
return mSource;
}
/**
* Returns the event's Command ID.
*
* @return String Command ID
*/
public String getCommandID()
{
return mCommandID;
}
/**
* Returns the event's message.
*
* @return String, the ebent's message
*/
public String getMessage()
{
return mMessage;
}
/**
* Returns the time in ms that the event was created (fired).
*
* @return time of event in ms
*/
public long getTime()
{
return mTime;
}
}
| [
"dan@dancowan.co.uk@60abb826-fd37-11de-9a2d-79d510f670ec"
] | dan@dancowan.co.uk@60abb826-fd37-11de-9a2d-79d510f670ec |
36c90ff1e8985eb5a0b7354330762e056565dbc0 | adeeb9b29f24aec68a8191dbf80827fb5905e672 | /src/main/java/com/example/dorm/bean/DormBuild.java | 06d5a9b83e2d52c6709cf90cb3c1d76dc858e1c4 | [] | no_license | TeamMZT/DormManager | 8456a414ededac38e8db9c3e45155fc73953b6ce | a9744a34d0c8bca9902e61d6b005053102b0bca4 | refs/heads/master | 2023-01-07T09:33:13.242489 | 2020-11-05T09:37:21 | 2020-11-05T09:37:21 | 309,866,410 | 0 | 0 | null | 2020-11-06T08:03:20 | 2020-11-04T03:00:35 | Java | UTF-8 | Java | false | false | 799 | java | package com.example.dorm.bean;
/**
* projectName: dorm
*
* @author: 12510
* time: 2020/11/4 14:40
* description:宿舍楼实体类
*/
public class DormBuild {
private int dormBuildId;
private String dormBuildName;
private String dormBuildNote;
public int getDormBuildId() {
return dormBuildId;
}
public void setDormBuildId(int dormBuildId) {
this.dormBuildId = dormBuildId;
}
public String getDormBuildName() {
return dormBuildName;
}
public void setDormBuildName(String dormBuildName) {
this.dormBuildName = dormBuildName;
}
public String getDormBuildNote() {
return dormBuildNote;
}
public void setDormBuildNote(String dormBuildNote) {
this.dormBuildNote = dormBuildNote;
}
}
| [
"1251031046@qq.com"
] | 1251031046@qq.com |
e18722b216ae388bb64377dd1808d5369aa5c989 | a7c85a1e89063038e17ed2fa0174edf14dc9ed56 | /spring-aop-perf-tests/src/main/java/coas/perf/ComplexCondition250/Advice116.java | f2008b6c938d1d0642074fbea862f3ec704d1e19 | [] | no_license | pmaslankowski/java-contracts | 28b1a3878f68fdd759d88b341c8831716533d682 | 46518bb9a83050956e631faa55fcdf426589830f | refs/heads/master | 2021-03-07T13:15:28.120769 | 2020-09-07T20:06:31 | 2020-09-07T20:06:31 | 246,267,189 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,644 | java |
package coas.perf.ComplexCondition250;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import coas.perf.ComplexCondition250.Subject250;
@Aspect
@Component("Advice_250_116_cc")
public class Advice116 {
@Around("execution(* coas.perf.ComplexCondition250.Subject250.*(..)) and (execution(* *.junk0(..)) or execution(* *.junk1(..)) or execution(* *.junk2(..)) or execution(* *.junk3(..)) or execution(* *.junk4(..)) or execution(* *.junk5(..)) or execution(* *.junk6(..)) or execution(* *.junk7(..)) or execution(* *.junk8(..)) or execution(* *.junk9(..)) or execution(* *.junk10(..)) or execution(* *.junk11(..)) or execution(* *.junk12(..)) or execution(* *.junk13(..)) or execution(* *.junk14(..)) or execution(* *.junk15(..)) or execution(* *.junk16(..)) or execution(* *.junk17(..)) or execution(* *.junk18(..)) or execution(* *.junk19(..)) or execution(* *.junk20(..)) or execution(* *.junk21(..)) or execution(* *.junk22(..)) or execution(* *.junk23(..)) or execution(* *.junk24(..)) or execution(* *.junk25(..)) or execution(* *.junk26(..)) or execution(* *.junk27(..)) or execution(* *.junk28(..)) or execution(* *.junk29(..)) or execution(* *.target(..)))")
public Object onTarget(ProceedingJoinPoint joinPoint) throws Throwable {
int res = (int) joinPoint.proceed();
for (int i=0; i < 1000; i++) {
if (res % 2 == 0) {
res /= 2;
} else {
res = 2 * res + 1;
}
}
return res;
}
}
| [
"pmaslankowski@gmail.com"
] | pmaslankowski@gmail.com |
715a0f29253e6e4d55e51ca261e4df6dea7f5a54 | 7fafa321cae2049b353fac7bb2ea72db7343380d | /src/controlador/TeamServlet.java | 6c610ae0504d6b03f9854275606611cf783e7be6 | [] | no_license | joserafaelpm/SegundoPrevio2021 | 9b39ffebc70af3526733e62dabb453087ec59d55 | 7d2766b086b635631d779b2d8db73093978aacbe | refs/heads/main | 2023-04-30T18:12:01.924933 | 2021-05-20T13:20:12 | 2021-05-20T13:20:12 | 369,179,491 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,223 | java | package controlador;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class TeamServlet
*/
@WebServlet("/TeamServlet")
public class TeamServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public TeamServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
response.getWriter().append("Served at: ").append(request.getContextPath());
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
| [
"joserafaelpm@ufps.edu.co"
] | joserafaelpm@ufps.edu.co |
0026215460097f30dd9c464a1f9b857b3969035a | 71d110eb47ce8a1c2b963ddad9438ab4084f3530 | /src/StructuralPatterns/BridgePattern/GreenCircle.java | a6b58f4d1d5558442d846c478a31de1278894f6c | [] | no_license | xzenge/DesignPattern | b021418574fe17e16bf96c7f80915c89b056a615 | 4418aa97f8628dfc6bd0e51319d4288dcb0f43a2 | refs/heads/master | 2021-01-24T10:35:39.525585 | 2016-10-14T05:56:53 | 2016-10-14T05:56:53 | 70,308,832 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 329 | java | package StructuralPatterns.BridgePattern;
/**
* Created by Administrator on 2016/10/9.
*/
public class GreenCircle implements DrawAPI {
@Override
public void drawCircle(int radius, int x, int y) {
System.out.println("Drawing Circle[ color: green, radius: " + radius + ", x: " + x + ", y:" + y + "]");
}
}
| [
"shixiang.sh@superjia.com"
] | shixiang.sh@superjia.com |
11e4521ec0641a327984162b876c802ae5ac4af5 | a662c696678b3e333084d35d18052444a78ac180 | /Day0721_2cocos2dbase/src/com/anjoyo/day0721_1cocos2dbase/MyLayer.java | 02cd618553ddf9fd7774ceafe248daddd63ba393 | [] | no_license | guoxiaojun001/cocos_2d | 7ed44af37a50e2c82b29225b7947888655102739 | d3bd79f578dcf627e81093ed74a12def95660f8c | refs/heads/master | 2016-09-11T02:54:01.748407 | 2015-04-11T13:51:17 | 2015-04-11T13:51:17 | 33,776,157 | 0 | 1 | null | null | null | null | GB18030 | Java | false | false | 653 | java | package com.anjoyo.day0721_1cocos2dbase;
import org.cocos2d.layers.CCLayer;
import org.cocos2d.nodes.CCSprite;
public class MyLayer extends CCLayer {
public MyLayer(){
init();
}
private void init() {
CCSprite zombie = CCSprite.sprite("z_1_01.png");
zombie.setAnchorPoint(0, 0);
zombie.setPosition(200, 150);
zombie.setFlipX(true);//x镜像,x方向反转
// zombie.setFlipY(true);//y镜像,y方向反转
CCSprite cover = CCSprite.sprite("cover.jpg");
cover.setAnchorPoint(0, 0);
//缩小为0.65
cover.setScale(0.65);
//int z,表示重要性,越大越最后绘制
addChild(cover,0);
this.addChild(zombie,1);
}
}
| [
"guoxiaojun8804@126.com"
] | guoxiaojun8804@126.com |
78fa2bf11eb2c06175af27684a49d4bf50f64c20 | 8bb9e4753477bcc28147c2344ee3008261b11db8 | /src/src/com/pages/StepsPage.java | 64503247d290d850a05c919433e141d9a6612f65 | [] | no_license | nischalramineni/Tc-automation | 06841356228d27b333e8523986d5a8114bc50749 | 48866bb8b397667ecaf1c86243545ef108da82d7 | refs/heads/master | 2021-03-22T04:52:06.750967 | 2017-06-28T18:42:15 | 2017-06-28T18:42:15 | 94,480,776 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 24,753 | java | package src.com.pages;
import java.io.IOException;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class StepsPage {
WebDriver driver;
public StepsPage(WebDriver driver){
this.driver = driver;
}
//Object Repository
private By StepID = By.xpath("//div[contains(text(),'Add Step')]");
//Step Template
private By StepTemplate = By.xpath("//div[contains(@class,'selectize-dropdown-content')]//div[text()='Create your own Learning Plan Step!']");
//StepTitle
private By StepTitle = By.xpath("//input[contains(@name,'learning_plan_step[title]')]");
//Step Description
//private By StepDesc = By.xpath("//div[contains(@class,'mce-edit-area mce-container mce-panel mce-last mce-stack-layout-item')]");
//private By StepDesc = By.id("tinymce");
//Attach Resources
private By AttachResources = By.xpath("//button[contains(@class,'js-action-menu-open js-action-menu-spinner')]");
//Add New Resource
private By NewResource = By.xpath("//li[contains(@class,'action-add menu-item attachment-type a-add-new-resource')]");
//File
private By FileType = By.xpath("//div[contains(text(),'File')]");
//ChooseFile
private By ChooseFile = By.xpath("//span[contains(text(),'Choose File')]");
//ResourceTitle
private By ResourceTitle = By.id("resource_title");
//ResourceDescription
private By ResourceDesc = By.id("resource_description");
//Link
private By LinkType = By.xpath("//div[contains(text(),'Link')]");
//URL
private By URL = By.xpath("//input[contains(@id,'resource_url')]");
//Title
private By resTitle = By.xpath("//input[contains(@id,'resource_title')]");
//Description
private By resDesc = By.xpath("//textarea[contains(@id,'resource_description')]");
//Google Doc
private By DocType = By.xpath("//div[contains(text(),'Google Doc')]");
//ChooseDoc
private By ChooseDoc = By.xpath("//span[contains(text(),'Choose Google Doc')]");
//Connect to Google Account
private By ConnectGoogle = By.xpath("//a[contains(text(),'Connect to your Google account')]");
//Disconnect existing connection
private By DisconnectGoogle = By.xpath("//a[contains(text(),'Disconnect from your Google account')]");
//Use Another Account
private By UseAnotherAccount = By.xpath("//p[contains(text(),'Use another account')]");
//Email
private By Email = By.xpath("//input[contains(@id,'identifierId')]");
//Password
private By Password = By.xpath("//input[contains(@name,'password')]");
//Next Button
private By btnNext = By.xpath("//span[contains(text(),'Next')]");
//Allow Button
private By btnAllow = By.xpath("//span[contains(text(),'ALLOW')]");
//Resource selection
private By resSelect = By.xpath("//div[contains(@class,'card--link js-resource-list-item')]");
//Select Doc
private By selectDoc = By.xpath("//button[contains(text(),'Select')]");
//Add Existing Resource
private By ExistingResource = By.xpath("//a[contains(text(),'Existing Resource')]");
private By ResourceContainer = By.xpath("//li[contains(@class,'js-resource-list-item resource spaced-list--item')]");
private By AttachRes = By.xpath("//button[contains(text(),'Attach')]");
//Add Existing Resource
private By TchResource = By.xpath("//a[contains(text(),'Tch Video')]");
private By TchSearch = By.xpath("//button[contains(@class,'search-field--button')]");
private By TchVideo = By.xpath("//li[contains(@class,'spaced-list--item video')]");
//Add Action
private By AddAction= By.xpath("//a[contains(text(),'Add an Action')]");
private By ActionTitle = By.xpath("//input[contains(@class,'js-add-list-item-on-enter')]");
//Submit Resource
private By SubmitRes = By.xpath("//input[contains(@class,'btn primary js-attach icon-spinner res-form-submit')]");
//Submit
private By SubmitButn = By.name("commit");
//public methods
public void clickStepID(){
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(StepID));
element.click();
}
public void selectStepTemplate(){
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement stepTemp = wait.until(ExpectedConditions.elementToBeClickable(StepTemplate));
stepTemp.click();
}
public void enterStepTitle(String stepTitle){
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(StepTitle));
element.click();
element.sendKeys(stepTitle);
}
public void enterStepDesc(String stepDesc){
//WebDriverWait wait = new WebDriverWait(driver,10);
driver.switchTo().defaultContent();
WebElement frame = driver.findElement(By.xpath("//*[contains(@id, 'mce_1_ifr')]"));
driver.switchTo().frame(frame);
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
WebElement eleBody = driver.findElement(By.cssSelector("body"));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleBody);
} catch (Exception e) {}
eleBody.sendKeys(stepDesc);
driver.switchTo().defaultContent();
}
public void AttachFileResource() throws IOException{
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement eleAttachRes = wait.until(ExpectedConditions.elementToBeClickable(AttachResources));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {}
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(NewResource));
//String parentWindow = driver.getWindowHandle();
element.click();
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
//Checking File Type
WebElement eleFileType = wait.until(ExpectedConditions.elementToBeClickable(FileType));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleFileType);
} catch (Exception e) {}
//Choose File
WebElement eleChooseFile = wait.until(ExpectedConditions.elementToBeClickable(ChooseFile));
eleChooseFile.click();
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
// below line execute the AutoIT script .
Runtime.getRuntime().exec("D:\\AutoIT\\FileUpload.exe");
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//Entering Resource Title
WebElement eleResourceTitle = wait.until(ExpectedConditions.visibilityOfElementLocated(ResourceTitle));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {
}
eleResourceTitle.sendKeys("Sample Step Resource");
//Entering Resource Description
WebElement eleResourceDesc = wait.until(ExpectedConditions.elementToBeClickable(ResourceDesc));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleResourceDesc);
} catch (Exception e) {}
eleResourceDesc.sendKeys("Sample Description");
//Clicking on Submit Button
WebElement eleSubmit = wait.until(ExpectedConditions.elementToBeClickable(SubmitButn));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleSubmit);
} catch (Exception e) {}
//driver.switchTo().window(parentWindow);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
}
public void AttachLinkResource(String strURL,String GradeValue) throws IOException{
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement eleAttachRes = wait.until(ExpectedConditions.elementToBeClickable(AttachResources));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {}
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(NewResource));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", element);
} catch (Exception e) {}
//String parentWindow = driver.getWindowHandle();
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
try {
Thread.sleep(4000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Checking Link Type
WebElement eleLink = wait.until(ExpectedConditions.elementToBeClickable(LinkType));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleLink);
} catch (Exception e) {}
//Entering URL value
List<WebElement> eleURLVals = driver.findElements(URL);
WebElement eleURL = eleURLVals.get(1);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleURL);
} catch (Exception e) {
}
eleURL.sendKeys(strURL);
//Entering Resource Title
List<WebElement> eleTitleVals = driver.findElements(resTitle);
WebElement eleTitle = eleTitleVals.get(1);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleTitle);
} catch (Exception e) {
}
eleTitle.sendKeys("Sample Resource Title");
//Entering Resource Description
List<WebElement> eleDescVals = driver.findElements(resDesc);
WebElement eleDesc = eleDescVals.get(1);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleDesc);
} catch (Exception e) {
}
eleDesc.sendKeys("Sample Resource Description");
//Entering Grades
driver.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
//driver.findElement(grades).click();
List<WebElement> eleText = driver.findElements(By.xpath("//div[contains(@class,'margin-bottom-12 text-12 heavy')]"));
WebElement eletxt = eleText.get(1);
eletxt.click();
driver.switchTo().activeElement().sendKeys(Keys.TAB);
driver.findElement(By.xpath("//div[contains(@class,'selectize-dropdown-content')]//div[text()='"+GradeValue+"']")).click();
eletxt.click();
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Clicking on Submit Button
List<WebElement> eleSubmits = driver.findElements(SubmitRes);
WebElement eleSubmit = eleSubmits.get(1);
wait.until(ExpectedConditions.elementToBeClickable(eleSubmit));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleSubmit);
} catch (Exception e) {}
}
public void AttachDocResource(String strEmail, String strPwd,String GradeValue) throws IOException{
WebDriverWait wait = new WebDriverWait(driver,10);
driver.switchTo().defaultContent();
WebElement eleAttachRes = wait.until(ExpectedConditions.elementToBeClickable(AttachResources));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {}
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(NewResource));
//String parentWindow = driver.getWindowHandle();
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", element);
} catch (Exception e) {}
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
try {
Thread.sleep(4000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Checking Doc Type
WebElement eleDocType = wait.until(ExpectedConditions.elementToBeClickable(DocType));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleDocType);
} catch (Exception e) {}
//Clicking on ChooseDoc
WebElement eleChooseDoc = wait.until(ExpectedConditions.elementToBeClickable(ChooseDoc));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleChooseDoc);
} catch (Exception e) {}
String ParWindow = driver.getWindowHandle();
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
try{
WebElement eleDisconnect = wait.until(ExpectedConditions.elementToBeClickable(DisconnectGoogle));
if(eleDisconnect.isDisplayed())
{
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleDisconnect);
} catch (Exception e) {}
driver.switchTo().alert().accept();
}
}catch(Exception e){
e.printStackTrace();
}
try{
//Connect to google account
WebElement eleConnect = wait.until(ExpectedConditions.elementToBeClickable(ConnectGoogle));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleConnect);
} catch (Exception e) {}
} catch(Exception e){
e.printStackTrace();
}
try{
//Use Another Account
WebElement eleUseAA = wait.until(ExpectedConditions.elementToBeClickable(UseAnotherAccount));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleUseAA);
} catch (Exception e) {}
}catch(Exception e){
e.printStackTrace();
}
//String ParWindow = driver.getWindowHandle();
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
//Entering Email ID
WebElement eleEmail = wait.until(ExpectedConditions.elementToBeClickable(Email));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleEmail);
} catch (Exception e) {}
eleEmail.sendKeys(strEmail);
//clicking on Next
WebElement eleNext = wait.until(ExpectedConditions.elementToBeClickable(btnNext));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleNext);
} catch (Exception e) {}
//Entering password
WebElement elePwd = wait.until(ExpectedConditions.elementToBeClickable(Password));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", elePwd);
} catch (Exception e) {}
elePwd.sendKeys(strPwd);
//clicking on Next
WebElement eleNext2 = wait.until(ExpectedConditions.elementToBeClickable(btnNext));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleNext2);
} catch (Exception e) {}
//Clicking on Allow
WebElement eleAllow = wait.until(ExpectedConditions.elementToBeClickable(btnAllow));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAllow);
} catch (Exception e) {}
driver.switchTo().window(ParWindow);
//Selecting resource
List<WebElement> resCont = driver.findElements(resSelect);
//System.out.println(resCont.size());
WebElement res = resCont.get(2);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", res);
} catch (Exception e) {
}
WebElement btnAttach = wait.until(ExpectedConditions.elementToBeClickable(selectDoc));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", btnAttach);
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", btnAttach);
} catch (Exception e) {
}
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//switch to parent window
driver.switchTo().window(ParWindow);
try {
Thread.sleep(2000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Entering Resource Description
List<WebElement> resDescr = driver.findElements(resDesc);
//System.out.println(resCont.size());
WebElement resDesc = resDescr.get(2);
WebElement eleDesc = wait.until(ExpectedConditions.elementToBeClickable(resDesc));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleDesc);
} catch (Exception e) {}
eleDesc.sendKeys("Sample Resource Description");
//Entering Grades
driver.manage().timeouts().implicitlyWait(2,TimeUnit.SECONDS);
//driver.findElement(grades).click();
List<WebElement> eleText = driver.findElements(By.xpath("//div[contains(@class,'margin-bottom-12 text-12 heavy')]"));
WebElement eletxt = eleText.get(2);
eletxt.click();
driver.switchTo().activeElement().sendKeys(Keys.TAB);
driver.findElement(By.xpath("//div[contains(@class,'selectize-dropdown-content')]//div[text()='"+GradeValue+"']")).click();
eletxt.click();
try {
Thread.sleep(1000);
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
//Clicking on Submit Button
List<WebElement> eleSubmits = driver.findElements(SubmitRes);
WebElement eleSubmit = eleSubmits.get(2);
wait.until(ExpectedConditions.elementToBeClickable(eleSubmit));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleSubmit);
} catch (Exception e) {}
}
public void AttachExistingResource() throws IOException{
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement eleAttachRes = driver.findElement(AttachResources);
//WebElement eleAttachRes = wait.until(ExpectedConditions.visibilityOfElementLocated(AttachResources));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {
}
//eleAttachRes.click();
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(ExistingResource));
String parentWindow = driver.getWindowHandle();
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", element);
} catch (Exception e) {
}
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
List<WebElement> resCont = driver.findElements(ResourceContainer);
System.out.println(resCont.size());
WebElement res = resCont.get(2);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", res);
} catch (Exception e) {
}
WebElement btnAttach = wait.until(ExpectedConditions.elementToBeClickable(AttachRes));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", btnAttach);
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", btnAttach);
} catch (Exception e) {
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.switchTo().window(parentWindow);
}
public void AttachTchResource() throws IOException{
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement eleAttachRes = driver.findElement(AttachResources);
//WebElement eleAttachRes = wait.until(ExpectedConditions.visibilityOfElementLocated(AttachResources));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", eleAttachRes);
} catch (Exception e) {
}
//eleAttachRes.click();
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(TchResource));
String parentWindow = driver.getWindowHandle();
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", element);
} catch (Exception e) {
}
driver.manage().timeouts().implicitlyWait(6, TimeUnit.SECONDS);
for (String winHandle : driver.getWindowHandles()) {
driver.switchTo().window(winHandle); // switch focus of WebDriver to the next found window handle (that's your newly opened window)
}
WebElement TchSearchIcon = wait.until(ExpectedConditions.elementToBeClickable(TchSearch));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", TchSearchIcon);
} catch (Exception e) {
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
List <WebElement> allChildobjs = driver.findElements(TchVideo);
int count = allChildobjs.size();
System.out.println("Number of child objects:"+count);
WebElement res = allChildobjs.get(2);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", res);
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", res);
} catch (Exception e) {
}
WebElement btnAttach = wait.until(ExpectedConditions.elementToBeClickable(AttachRes));
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", btnAttach);
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", btnAttach);
} catch (Exception e) {
}
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.switchTo().window(parentWindow);
}
//Adding Action
public void clickAddAction(){
/* WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(AddAction));
element.click(); */
WebElement element = driver.findElement(AddAction);
try {
((JavascriptExecutor) driver).executeScript(
"arguments[0].scrollIntoView(true);", element);
((JavascriptExecutor) driver).executeScript(
"arguments[0].click()", element);
} catch (Exception e) {
}
}
//Entering Action value
public void enterAction(){
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(ActionTitle));
element.click();
element.sendKeys("Sample Action");
}
//Clicking on Add Step Button
public void clickAddStep(){
WebDriverWait wait = new WebDriverWait(driver,10);
WebElement element = wait.until(ExpectedConditions.elementToBeClickable(SubmitButn));
element.click();
}
}
| [
"nischalramineni@gmail.com"
] | nischalramineni@gmail.com |
dd701c46ff1eeb4b95727fa5ae9bae109a0e636d | f52a0da0a414ae1d4fd1a4ceba71a2a8c5af7e14 | /src/main/java/com/basic/advance/advanced_class_01/Code_03_LongestPathSum.java | 4671288de164fd9d75096b05ead5f87e59d2776f | [] | no_license | xiejinwen113/niuke-1 | 8783d95240cb97abac6dde1a2b3207c0a7127e58 | e1d5d37b612d3509859e4d915f13e08b8b56d22c | refs/heads/master | 2022-12-28T12:00:29.024228 | 2019-08-06T09:30:50 | 2019-08-06T09:30:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,344 | java | package com.basic.advance.advanced_class_01;
import java.util.HashMap;
public class Code_03_LongestPathSum {
public static class Node {
public int value;
public Node left;
public Node right;
public Node(int data) {
this.value = data;
}
}
public static int getMaxLength(Node head, int sum) {
HashMap<Integer, Integer> sumMap = new HashMap<Integer, Integer>();
sumMap.put(0, 0); // important
return preOrder(head, sum, 0, 1, 0, sumMap);
}
public static int preOrder(Node head, int sum, int preSum, int level,
int maxLen, HashMap<Integer, Integer> sumMap) {
if (head == null) {
return maxLen;
}
int curSum = preSum + head.value;
if (!sumMap.containsKey(curSum)) {
sumMap.put(curSum, level);
}
if (sumMap.containsKey(curSum - sum)) {
maxLen = Math.max(level - sumMap.get(curSum - sum), maxLen);
}
maxLen = preOrder(head.left, sum, curSum, level + 1, maxLen, sumMap);
maxLen = preOrder(head.right, sum, curSum, level + 1, maxLen, sumMap);
if (level == sumMap.get(curSum)) {
sumMap.remove(curSum);
}
return maxLen;
}
// for test -- print tree
public static void printTree(Node head) {
System.out.println("Binary Tree:");
printInOrder(head, 0, "H", 17);
System.out.println();
}
public static void printInOrder(Node head, int height, String to, int len) {
if (head == null) {
return;
}
printInOrder(head.right, height + 1, "v", len);
String val = to + head.value + to;
int lenM = val.length();
int lenL = (len - lenM) / 2;
int lenR = len - lenM - lenL;
val = getSpace(lenL) + val + getSpace(lenR);
System.out.println(getSpace(height * len) + val);
printInOrder(head.left, height + 1, "^", len);
}
public static String getSpace(int num) {
String space = " ";
StringBuffer buf = new StringBuffer("");
for (int i = 0; i < num; i++) {
buf.append(space);
}
return buf.toString();
}
public static void main(String[] args) {
Node head = new Node(-3);
head.left = new Node(3);
head.right = new Node(-9);
head.left.left = new Node(1);
head.left.right = new Node(0);
head.left.right.left = new Node(1);
head.left.right.right = new Node(6);
head.right.left = new Node(2);
head.right.right = new Node(1);
printTree(head);
System.out.println(getMaxLength(head, 6));
System.out.println(getMaxLength(head, -9));
}
}
| [
"878147704@qq.com"
] | 878147704@qq.com |
936a834a8150443ac259b47ee4dce3d39904097e | a554f07b3fbd4a672abf50eb2525e892e300da07 | /BenchSystem/src/main/java/com/benchapp/models/Project.java | 7663334c66e263d0e9db6e29748d4222ca588097 | [] | no_license | jmirandas/benchapp | ecb6727aeab0a3b8f81046a82567f6cdd2e67e5b | 3577ecd2d45bbe7a82cf3f0eee7fa6cb765bf0ce | refs/heads/master | 2020-05-16T22:44:52.248097 | 2013-01-21T23:41:45 | 2013-01-22T16:31:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,595 | java | /**
*
*/
package com.benchapp.models;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import org.hibernate.annotations.Entity;
/**
* @author eduardo.bran
*
*/
@SuppressWarnings("serial")
@Entity
@Table(name = "Proyecto")
public class Project implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name = "idProyecto")
private int projectId;
@Column(name = "nombre")
private String name;
@OneToOne(cascade = CascadeType.PERSIST)
private Client client;
@Column(name = "")
private Rol rol;
/**
* @return the projectId
*/
public int getProjectId() {
return projectId;
}
/**
* @param projectId
* the projectId to set
*/
public void setProjectId(int projectId) {
this.projectId = projectId;
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name
* the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @return the client
*/
public Client getClient() {
return client;
}
/**
* @param client
* the client to set
*/
public void setClient(Client client) {
this.client = client;
}
/**
* @return the rol
*/
public Rol getRol() {
return rol;
}
/**
* @param rol
* the rol to set
*/
public void setRol(Rol rol) {
this.rol = rol;
}
}
| [
"eduardo.bran@avantica.net"
] | eduardo.bran@avantica.net |
5e521bf579ed16999dab1e316bcff5763fdb20d6 | 60e1a7df2076c835a47959979cc2a277a9ba7546 | /vapor-server/src/main/java/evymind/vapor/server/supertcp/RequestEvent.java | b53b56535157c6cb07c203525ccef7a55efe86aa | [] | no_license | torworx/Vapor | 09243f4c871d6711df5f0eba3e6b7cf12359c0e6 | 4dc7156e50a2b72095f37e539ea0388b518f18ed | refs/heads/master | 2021-01-25T04:02:38.658132 | 2013-03-18T12:54:06 | 2013-03-18T12:54:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 442 | java | package evymind.vapor.server.supertcp;
import evymind.vapor.server.Request;
import evymind.vapor.server.Response;
public class RequestEvent {
private final Request request;
private final Response response;
public RequestEvent(Request request, Response response) {
this.request = request;
this.response = response;
}
public Request getRequest() {
return request;
}
public Response getResponse() {
return response;
}
}
| [
"torworx@gmail.com"
] | torworx@gmail.com |
0dd8491bcbc9a85266bb8eaea866157dcc731b71 | 1a8546151a2f2bce8ae64739916cbbaaafc9e975 | /leARn-Navigation/app/src/main/java/com/example/learnnavigation/HomeFragment.java | 905f21de478e8a91fbdfb1ff926ab17c09adc088 | [] | no_license | diyaw/leARn | f22e5b32e515feaabf647e838740c1fdd320b05d | b1af026ee9211349655f373d95df2e0a542c7791 | refs/heads/master | 2022-08-01T14:24:20.293700 | 2020-05-22T08:09:33 | 2020-05-22T08:09:33 | 256,872,853 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 790 | java | package com.example.learnnavigation;
import androidx.lifecycle.ViewModelProviders;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class HomeFragment extends Fragment {
//private HomeViewModel mViewModel;
public static HomeFragment newInstance() {
return new HomeFragment();
}
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
View RootView = inflater.inflate(R.layout.home_fragment, container, false);
return RootView;
}
}
| [
"chiragb99@gmail.com"
] | chiragb99@gmail.com |
c95438acbb43ac6aaa9f71df621e37f56c003f10 | 9ab5bdb918b886f1f2d09d81efb63ff83a86bfb0 | /core/src/main/java/com/jdt/fedlearn/core/entity/localModel/LocalLinearModel.java | ce2d606031ca576990eec59fcbdf4d03642e45ff | [
"Apache-2.0"
] | permissive | BestJex/fedlearn | 75a795ec51c4a37af34886c551874df419da3a9c | 15395f77ac3ddd983ae3affb1c1a9367287cc125 | refs/heads/master | 2023-06-17T01:27:36.143351 | 2021-07-19T10:43:09 | 2021-07-19T10:43:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,887 | java | /* Copyright 2020 The FedLearn Authors. All Rights Reserved.
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.jdt.fedlearn.core.entity.localModel;
import com.jdt.fedlearn.core.model.common.loss.SquareLoss;
import com.jdt.fedlearn.core.entity.randomForest.DataUtils;
import org.ejml.data.SingularMatrixException;
import org.ejml.equation.Equation;
import org.ejml.simple.SimpleMatrix;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.IntStream;
public class LocalLinearModel implements LocalModel {
/**
* Local linear model: Y = X * beta + alpha
*/
// column vector
SimpleMatrix beta;
// scalar
double alpha;
// ridge regression parameter
double lambda;
// 线性模型默认拟合MSE
SquareLoss loss = new SquareLoss();
// 构造函数
public LocalLinearModel() {
this.lambda = 1e-6;
}
public LocalLinearModel(double lambda) {
this.lambda = lambda;
}
@Override
public String getModelType() {
return "LinearModel";
}
@Override
public void train(SimpleMatrix X, SimpleMatrix y) {
// compute (X.T * X + lambda * I) \ (X.T * y)
SimpleMatrix y1 = y;
if (y1.numRows() == 1) {
y1 = y1.transpose();
}
Equation eq = new Equation();
int numRows = X.numRows();
eq.alias(X, "X", numRows, "n");
eq.process("X1 = [X,ones(n,1)]");
SimpleMatrix X1 = new SimpleMatrix(eq.lookupSimple("X1"));
SimpleMatrix eye = SimpleMatrix.identity(X.numCols() + 1);
SimpleMatrix X2 = X1.transpose().mult(X1).plus(eye.scale(lambda));
try {
SimpleMatrix res = X2.solve(X1.transpose().mult(y1));
// set beta
res.print();
beta = res.extractMatrix(0, res.numRows() - 1, 0, 1);
alpha = res.get(res.numRows() - 1, 0);
} catch (SingularMatrixException e) {
throw new IllegalArgumentException("Singular matrix");
}
}
@Override
public double predict(SimpleMatrix X) {
return X.dot(beta) + alpha;
}
@Override
public double[] batchPredict(SimpleMatrix X) {
if (X.numCols() == beta.numRows()) {
// X * beta
return doBatchPredict(X);
} else if (X.numRows() == beta.numRows()) {
// X.T * beta
return doBatchPredict(X.transpose());
} else {
throw new IllegalArgumentException("Matrix dimensions of X and beta are not compatible");
}
}
private double[] doBatchPredict(SimpleMatrix X) {
SimpleMatrix y = X.mult(beta).plus(alpha);
return DataUtils.toArray(y);
}
@Override
public double[] getResidual(SimpleMatrix X, SimpleMatrix y) {
double[] pred = batchPredict(X);
return IntStream.range(0, pred.length).mapToDouble(i -> pred[i] - y.get(i)).toArray();
}
@Override
public double[] getGradient(SimpleMatrix X, SimpleMatrix y) {
double[] pred = batchPredict(X);
return loss.grad(pred, DataUtils.toArray(y));
}
@Override
public double[] getHessian(SimpleMatrix X, SimpleMatrix y) {
double[] pred = batchPredict(X);
return loss.hess(pred, DataUtils.toArray(y));
}
@Override
public double[] getPseudoLabel(SimpleMatrix X, SimpleMatrix y) {
double[] gradient = getGradient(X, y);
double[] hessian = getHessian(X, y);
// formula: (sqrt(h) * f - (-g) / sqrt(h))^2
// MSE loss 的话 hessian 是 1
return IntStream.range(0, gradient.length).mapToDouble(i -> -gradient[i] / Math.sqrt(hessian[i])).toArray();
}
@Override
public String serialize() {
Map<String, String> map = new HashMap<>();
map.put("beta", DataUtils.doubleArrayToString(DataUtils.toArray(beta)));
map.put("alpha", String.valueOf(alpha));
return DataUtils.mapToString(map);
}
@Override
public LocalLinearModel deserialize(String s) {
Map<String, String> map = DataUtils.stringToMap(s, true, true);
double[] tmp = DataUtils.stringToDoubleArray(map.get("beta"));
beta = new SimpleMatrix(tmp.length, 1);
for (int i = 0; i < beta.numRows(); i++) {
beta.set(i, 0, tmp[i]);
}
alpha = Double.parseDouble(map.get("alpha"));
return this;
}
}
| [
"wangpeiqi@jd.com"
] | wangpeiqi@jd.com |
dcbd23ac6fcfc6e5be9af286c4aeec29929f870d | 279b06d38332a87ded97015e0df2ec06f85bc6b5 | /banbanle/src/main/java/com/sf/banbanle/bean/BaiduPushInfo.java | 04f2d6f2a3726b4e48a7dd951affdc71f8f9eec4 | [] | no_license | xieningtao/WakeUp | 19d27dd656d32bc363773544264f5d6582329103 | d622b2bd77aee1f2dabba0f8a3f8cda305d64ddd | refs/heads/master | 2020-06-16T13:59:47.473881 | 2017-01-18T13:45:03 | 2017-01-18T13:45:03 | 75,094,017 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | package com.sf.banbanle.bean;
/**
* Created by mac on 16/12/3.
*/
public class BaiduPushInfo {
public final String userId;
public final String channelId;
public BaiduPushInfo(String userId, String channelId) {
this.userId = userId;
this.channelId = channelId;
}
}
| [
"1"
] | 1 |
c0eec5bb848494835f7d43622c0d1f568eec7473 | 10be1e248267f630bc7019f09b5529b40cd83e7b | /src/lwh/java/zhujie/junit/DemoTest1.java | 05d8e9b218665724424bcf3c457ca996ba31e6ff | [] | no_license | liwanghonggc/JavaBase | 746233c3185f07939ecf8fe2a048969fa9a7be9c | c9ce0b96240bfddceb08a8421640bbe73fa275f1 | refs/heads/master | 2021-07-11T05:45:30.810974 | 2019-03-11T01:08:07 | 2019-03-11T01:08:07 | 148,955,380 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 370 | java | package lwh.java.zhujie.junit;
public class DemoTest1 {
@Test(time = 1000)
public void test1(){
try {
Thread.sleep(1500);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("test1执行了");
}
public void test2(){
System.out.println("test2执行了");
}
}
| [
"2391519868@qq.com"
] | 2391519868@qq.com |
59006a16b77b013f666d562fc392080aaa9ee6ce | 3a0abbd2c4eeedb7e5c4e9a0f6f3f793984723d7 | /In Class/TestBankAccount.java | 3fe4f3ae7aed1290000709f56a15ba7e6aa77cf0 | [] | no_license | Unix-Code/Computer-Science_Java | 87f69df2d913ece644bf06c142624bceb22023ad | c7eb539032781be0743217815718049485872537 | refs/heads/master | 2021-01-10T15:25:20.201675 | 2016-01-15T03:12:25 | 2016-01-15T03:12:25 | 47,480,506 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | public class TestBankAccount {
public static void main(String [] args) {
BankAccount b1 = new BankAccount("Grace Hopper", 99);
b1.printSlip();
b1.deposit(100);
b1.printSlip();
}
} | [
"dmalakh@comcast.net"
] | dmalakh@comcast.net |
3bb8f909f3bf5072459b03fec41d52bef4002cd1 | bfed0d992f925ee137eb94026f0283724eba17fa | /V5.0/ZDK/src/nl/zeesoft/zdk/grid/ColumnFunction.java | 1cc1d9fae1b430d90faf09762afe31986a96b733 | [] | no_license | DyzLecticus/Zeesoft | c17c469b000f15301ff2be6c19671b12bba25f99 | b5053b762627762ffeaa2de4f779d6e1524a936d | refs/heads/master | 2023-04-15T01:42:36.260351 | 2023-04-10T06:50:40 | 2023-04-10T06:50:40 | 28,697,832 | 7 | 2 | null | 2023-02-27T16:30:37 | 2015-01-01T22:57:39 | Java | UTF-8 | Java | false | false | 344 | java | package nl.zeesoft.zdk.grid;
public class ColumnFunction {
public Object[] applyFunction(GridColumn column, Object[] values) {
for (int z = 0; z < values.length; z++) {
values[z] = applyFunction(column,z,values[z]);
}
return values;
}
public Object applyFunction(GridColumn column, int posZ, Object value) {
return value;
}
}
| [
"dyz@xs4all.nl"
] | dyz@xs4all.nl |
31bfe69a7541ec57a9c190cb402a9e50056e0b0b | a0961570f84c946b0653ed92048dd9a59f69da84 | /src/com/sanki/hackingclass/Cc.java | 5af58e5b61b73447540edffbb1d84c51909dc80d | [] | no_license | sanket-naik/HackingClass-app-of-hacking-tricks-using-java | 426362efde9085f75b4037a8bf03345130e1fde2 | d0396f93ed7264773bb34b437866ef39d773d691 | refs/heads/master | 2020-03-28T07:29:50.325150 | 2018-09-08T05:55:29 | 2018-09-08T05:55:29 | 147,905,616 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,827 | java | package com.sanki.hackingclass;
import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdView;
public class Cc extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ColorDrawable colorDrawable = new ColorDrawable(
Color.parseColor("#4b4b4b"));
getActionBar().setBackgroundDrawable(colorDrawable);
ActionBar actionBar = getActionBar();
actionBar.setTitle(Html.fromHtml("<small>Going Pro</SMALL>"));
setContentView(R.layout.activity_cc);
AdView mAdView = (AdView) findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
mAdView.loadAd(adRequest);
final ImageView a = (ImageView) findViewById(R.id.imageView3);
a.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
a.setImageResource(R.drawable.previous2);
Intent tutorial = new Intent(getApplicationContext(), Cb.class);
startActivity(tutorial);
overridePendingTransition(R.anim.slidein, R.anim.slideout);
finish();
}
});
final ImageView b = (ImageView) findViewById(R.id.imageView5);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
b.setImageResource(R.drawable.rateintxt2);
final String appPackageName = "com.sanki.hackingclass";
try {
startActivity(new Intent(Intent.ACTION_VIEW, Uri
.parse("market://details?id=" + appPackageName)));
} catch (android.content.ActivityNotFoundException anfe) {
startActivity(new Intent(
Intent.ACTION_VIEW,
Uri.parse("http://play.google.com/store/apps/details?id="
+ appPackageName)));
}
}
});
final ImageView c = (ImageView) findViewById(R.id.imageView7);
c.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
c.setImageResource(R.drawable.next2);
Intent tutorial = new Intent(getApplicationContext(), Cd.class);
startActivity(tutorial);
overridePendingTransition(R.anim.wipeout, R.anim.wipein);
finish();
}
});
}
@Override
public void onBackPressed() {
Intent strtpg = new Intent(getApplicationContext(), Expert.class);
startActivity(strtpg);
overridePendingTransition(R.anim.fadein, R.anim.fadeout);
finish();
}
}
| [
"1100sanket@gmail.com"
] | 1100sanket@gmail.com |
1bc24a625ca34c9b6d753eebd32870dceeadb3a9 | 8f094e759aa8dcc10e43187824311a4b23693514 | /src/jersey/server/resources/Resource.java | 2c82fb2ca6aadd0db653f1ed5dbb3235a55b924f | [] | no_license | jordanhudgens/java-api-server | 616a6e683273420601d81a903b48b27988dc2e68 | 5b410e9a15e2e465e47b94af20954bc448ea4dc0 | refs/heads/master | 2016-09-11T03:28:46.804232 | 2015-02-14T23:52:56 | 2015-02-14T23:52:56 | 30,812,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,297 | java | package jersey.server.resources;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
import javax.xml.bind.JAXBElement;
import jersey.server.object.Object;
import jersey.server.java.ToDo;
public class Resource {
@Context UriInfo uriInfo;
@Context Request request;
String id;
public Resource(UriInfo uriInfo, Request request, String id)
{
this.uriInfo = uriInfo;
this.request = request;
this.id = id;
}
/**
* Get Integration for Applications
* @return
*/
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public ToDo getTodo()
{
ToDo getExample = Object.instance.getModel().get(id);
if(getExample==null) throw new RuntimeException("GET Failed, Id='" + id + "' not found");
return getExample;
}
/**
* Get Integration for Browsers
* @return
*/
@GET
@Produces(MediaType.TEXT_XML)
public ToDo getTodoHTML()
{
ToDo getExample = Object.instance.getModel().get(id);
if(getExample==null) throw new RuntimeException("GET Failed, Id='" + id + "' not found");
return getExample;
}
/**
* Put Functionality
* @param todo
* @return
*/
@PUT
@Consumes(MediaType.APPLICATION_XML)
public Response putTodo(JAXBElement<ToDo> todo)
{
ToDo putExample = todo.getValue();
return putAndGetResponse(putExample);
}
/**
* Delete Functionality
*/
@DELETE
public void deleteTodo()
{
ToDo deleteExample = Object.instance.getModel().remove(id);
if(deleteExample==null) throw new RuntimeException("DELETE Failed, Id='" + id + "' not found");
}
/**
* Create the Responses
* @param todo
* @return
*/
private Response putAndGetResponse(ToDo toDoItem) {
Response res;
if(Object.instance.getModel().containsKey(toDoItem.getId()))
{
res = Response.noContent().build();
}
else
{
res = Response.created(uriInfo.getAbsolutePath()).build();
}
Object.instance.getModel().put(toDoItem.getId(), toDoItem);
return res;
}
}
| [
"jordan@wow.com"
] | jordan@wow.com |
1c50745b44f5cedd5d9c665e51d7f6b5e748658b | 6f8587a68e2e296bd43d1035fccefd7e476b66b1 | /flink-streaming-web/src/main/java/com/flink/streaming/web/service/SystemConfigService.java | 856299d106c3ee139370867c2d4df789ff601bb9 | [
"MIT"
] | permissive | zhuimengrenweijian/flink-streaming-platform-web | 6c5a5b09282585eb0bbfee3f21ab8e377fdf9971 | b3856750a0c23a160273f076b83fe75042eba708 | refs/heads/master | 2023-03-13T09:58:25.205155 | 2021-05-07T15:10:58 | 2021-05-07T15:10:58 | 327,022,011 | 1 | 0 | MIT | 2021-03-08T14:54:26 | 2021-01-05T14:23:05 | null | UTF-8 | Java | false | false | 1,567 | java | package com.flink.streaming.web.service;
import com.flink.streaming.web.enums.DeployModeEnum;
import com.flink.streaming.web.enums.SysConfigEnumType;
import com.flink.streaming.web.model.dto.SystemConfigDTO;
import java.util.List;
/**
* @author zhuhuipei
* @Description:
* @date 2020-07-20
* @time 01:06
*/
public interface SystemConfigService {
/**
* 新增或者修改配置
*
* @author zhuhuipei
* @date 2020-08-06
* @time 23:48
*/
void addOrUpdateConfigByKey(String key, String value);
/**
* 查询配置
*
* @author zhuhuipei
* @date 2020-07-20
* @time 01:11
*/
List<SystemConfigDTO> getSystemConfig(SysConfigEnumType sysConfigEnumType);
/**
* 删除一个配置
*
* @author zhuhuipei
* @date 2020-08-06
* @time 20:18
*/
void deleteConfigByKey(String key);
/**
* 根据key获取配置的值
*
* @author zhuhuipei
* @date 2020-08-06
* @time 20:21
*/
String getSystemConfigByKey(String key);
/**
* 获取yarn的rm Http地址
*
* @author zhuhuipei
* @date 2020-09-18
* @time 01:23
*/
String getYarnRmHttpAddress();
/**
* 获取flink地址
*
* @author zhuhuipei
* @date 2020/11/4
* @time 10:52
*/
String getFlinkHttpAddress(DeployModeEnum deployModeEnum);
/**
* 检查配置是否存在
*
* @author zhuhuipei
* @date 2020-10-14
* @time 21:41
*/
boolean isExist(String key);
}
| [
"huipei.zhu@hipac.cn"
] | huipei.zhu@hipac.cn |
976c47d46a201a7f0b9ce32521f74ee2dfbb83bb | d29d56fb910937a9167dd0883b26476f2edb132e | /horizontalbarchartview/src/main/java/com/kishannareshpal/horizontalbarchartview/models/Data.java | 18513710bd10876d7579347aeea4e35c5c7ebb60 | [
"Apache-2.0"
] | permissive | kishannareshpal/HorizontalBarChartView | 7c453fbf80b895b91eadd245709aea38e8f83a23 | 40fa57b5d8059d0d9c448c229903cb38c53578c8 | refs/heads/master | 2020-04-10T10:25:50.771544 | 2019-03-15T04:24:39 | 2019-03-15T04:24:39 | 160,966,116 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 810 | java | package com.kishannareshpal.horizontalbarchartview.models;
/**
* Model
* Created by Kishan Nareshpal Jadav. 2018.
* Description: contains the storage details.
*/
public class Data {
private int id;
private int color;
private int percentage;
public Data(int id, int color, int percentage) {
this.id = id;
this.color = color;
this.percentage = percentage;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public int getPercentage() {
return percentage;
}
public void setPercentage(int percentage) {
this.percentage = percentage;
}
}
| [
"kishan_jadav@hotmail.com"
] | kishan_jadav@hotmail.com |
aab23a48b434f89dbc694a00ce9509f08bc1c80a | ed175e181343132144fec57f330d2bafae72115a | /maframe/src/main/java/com/yuelinghui/personal/maframe/util/DateUtil.java | 7a6dddd6b123314d503cf6ec2a5a2b8c999e7262 | [] | no_license | Yuelinghui/MyApplication | 32204e1235aa13249151efc9c521b986333b68bc | 8ad162771a2cd37daf41e6dbbdd0338bb8bd18a3 | refs/heads/master | 2021-01-18T19:31:41.930783 | 2017-02-28T08:46:02 | 2017-02-28T08:46:02 | 72,101,782 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,659 | java | package com.yuelinghui.personal.maframe.util;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.AbsoluteSizeSpan;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
/**
* Created by yuelinghui on 16/8/30.
* 日期工具类
*/
public class DateUtil {
/**
* riqi
*/
private static Calendar sCalendar = Calendar.getInstance();
private static SimpleDateFormat mDefaultFormat = new SimpleDateFormat();
/**
* 如:2012-12-12 12:12:12
*/
private static SimpleDateFormat commonDateFormat = new SimpleDateFormat(
"yyyy-MM-dd HH:mm:ss");
/**
* 如:20121212121212 场景:时间生成序列号
*/
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
/**
* 如:2012-12-12
*/
private static SimpleDateFormat ymdDateFormat = new SimpleDateFormat(
"yyyy-MM-dd");
/**
* 如:2012-12
*/
private static SimpleDateFormat ymDateFormat = new SimpleDateFormat(
"yyyy-MM");
/**
* 如:2012年12月12日
*/
private static SimpleDateFormat ymdCHDateFormat = new SimpleDateFormat(
"yyyy年MM月dd日");
/**
* 如:2012年12月
*/
private static SimpleDateFormat ymCHDateFormat = new SimpleDateFormat(
"yyyy年MM月");
/**
* 如:2012 年12 月
*/
private static SimpleDateFormat ymCHSpaceDateFormat = new SimpleDateFormat(
"yyyy 年 MM 月 ");
/**
* 如:12月30日
*/
private static SimpleDateFormat mdCHDateFormat = new SimpleDateFormat(
"MM月dd日");
/**
* 如:12:12 场景:12点12分
*/
private static SimpleDateFormat hmDateFormat = new SimpleDateFormat("HH:mm");
/**
* 日期前加0
*/
private static DecimalFormat mDayFormat = new DecimalFormat("00");
private static SimpleDateFormat commonYMDFormat = new SimpleDateFormat("yyyyMMdd");
/**
* 返回自定义格式的时间
*
* @param pattern
* @param date
* @return
*/
public static String format(String pattern, Date date) {
if (date == null) {
return null;
}
mDefaultFormat.applyPattern(pattern);
return mDefaultFormat.format(date);
}
/**
* 返回自定义格式的时间
*
* @param pattern
* @param date
* @return
*/
public static Date parse(String pattern, String date) {
if (TextUtils.isEmpty(date)) {
return null;
}
mDefaultFormat.applyPattern(pattern);
try {
return mDefaultFormat.parse(date);
} catch (ParseException e) {
}
return null;
}
/**
* 根据字符串返回字符串日期
*
* @param curPattern 当前字符串格式类型
* @param tarPattern 目标字符串格式类型
* @param date
* @return
*/
public static String parseFormat(String curPattern, String tarPattern,
String date) {
return format(tarPattern, parse(curPattern, date));
}
/**
* 日期转换成字符
*
* @param date
* @return
*/
public static String format(Date date) {
return commonDateFormat.format(date);
}
/**
* 构造年月日日期字符串
*
* @param date
* @return
*/
public static String formatYMD(Date date) {
return ymdDateFormat.format(date);
}
/**
* 构造年月日期字符串
*
* @param date
* @return
*/
public static String formatYM(Date date) {
return ymDateFormat.format(date);
}
/**
* 单位日期前加0
*
* @param number
* @return
*/
public static String formatDateNum(int number) {
return mDayFormat.format(number);
}
/**
* 可扩展的日期格式函数
*
* @param date
* @param dateFormat
* @return
*/
public static String format(Date date, SimpleDateFormat dateFormat) {
return dateFormat.format(date);
}
/**
* 字符转换成日期
*
* @param date
* @return
* @throws ParseException
*/
public static Date parse(String date) throws ParseException {
return commonDateFormat.parse(date);
}
/**
* 字符转换成年月日日期
*
* @param date
* @return
* @throws ParseException
*/
public static Date parseYMD(String date) throws ParseException {
return ymdDateFormat.parse(date + " 00:00:00");
}
/**
* 获取系统时间
*
* @return
*/
public static String getSysDate() {
return format(new Date(), commonDateFormat);
}
/**
* 获取不带分隔符的系统时间
*
* @return
*/
public static String getSysDateVersion() {
return format(new Date(), sdf);
}
/**
* 获取不带分隔符的系统时间
*
* @return
*/
public static String getDateVersion(Date date) {
return format(date, sdf);
}
/**
* 根据字符串获取交易格式时间 若是今天返回:"今天:HH:mm"; 非今天返回:"yyyy-MM-dd"
*
* @param dateString
* @return
* @throws ParseException
*/
public static String getTradeDate(String dateString) {
if (dateString == null) {
return "";
}
String sysDate = ymdDateFormat.format(new Date());
try {
String outDate = ymdDateFormat.format(ymdDateFormat
.parse(dateString));
if (!sysDate.equals(outDate)) {
return outDate;
} else {
dateString = "今天\u0020\u0020";
dateString += hmDateFormat.format(commonDateFormat
.parse(dateString));
}
} catch (ParseException e) {
// e.printStackTrace();
}
return dateString;
}
/**
* 计算当前日期与规定日期的时间差
*
* @param dateString datePoint 2014-01-23 12:22:00
*/
public static int getLeftDays(String dateString, String datePoint) {
if (TextUtils.isEmpty(dateString)) {
return 0;
}
long days = 0;
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal1 = Calendar.getInstance();
cal1.setTime(sdf.parse(dateString));
Calendar cal2 = Calendar.getInstance();
cal2.setTime(sdf.parse(datePoint));
long l = cal1.getTimeInMillis() - cal2.getTimeInMillis();
days = Long.valueOf(l / (1000 * 60 * 60 * 24));
} catch (ParseException e) {
// e.printStackTrace();
}
return (int) days;
}
/**
* yyyy-MM-dd转化为yyyy年MM月dd日 add 20151214 by xiayundong
*
* @param date
* @return
*/
public static String ymdFormatCH(String date) {
try {
return ymdCHDateFormat.format(ymdDateFormat.parse(date));
} catch (ParseException e) {
// e.printStackTrace();
}
return date;
}
/**
* 带下划线的年月,转化为中文年月
*
* @param date
* @return
*/
public static String ymFormatCH(String date) {
try {
return ymCHDateFormat.format(ymDateFormat.parse(date));
} catch (ParseException e) {
// e.printStackTrace();
}
return date;
}
/**
* yyyy-MM-dd转化为MM月dd日
*
* @param date
* @return
*/
public static String mdFormatCH(String date) {
try {
return mdCHDateFormat.format(ymdDateFormat.parse(date));
} catch (ParseException e) {
// e.printStackTrace();
}
return date;
}
/**
* 带下划线的年月,转化为中文年月 获取附带样式的年月标题
*
* @param date
* @return
*/
public static Spannable ymSpaceFormatCH(String date, int numberSize,
int wordSize) {
try {
Spannable word = new SpannableString(
ymCHSpaceDateFormat.format(ymDateFormat.parse(date)));
word.setSpan(new AbsoluteSizeSpan(numberSize), 0, 4,
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
word.setSpan(new AbsoluteSizeSpan(wordSize), 4, 6,
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
word.setSpan(new AbsoluteSizeSpan(numberSize), 6, 9,
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
word.setSpan(new AbsoluteSizeSpan(wordSize), 9, 10,
Spannable.SPAN_INCLUSIVE_INCLUSIVE);
return word;
} catch (Exception e) {
}
return new SpannableString(date);
}
public static String addDay(String date, int i) {
try {
Date date1 = ymdDateFormat.parse(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);
calendar.add(Calendar.DAY_OF_MONTH, i);
return ymdDateFormat.format(calendar.getTime());
} catch (Exception e) {
return "";
}
}
/**
* 返回与今天的对比值 大于0表示未来 小于0表示过去
*
* @param date
* @return
*/
public static long compareToday(String date) {
try {
Date date1 = ymdDateFormat.parse(date);
Calendar calendar = Calendar.getInstance();
calendar.setTime(date1);
long l = calendar.getTimeInMillis();
String date2 = ymdDateFormat.format(new Date());
calendar.setTime(ymdDateFormat.parse(date2));
l = l - calendar.getTimeInMillis();
return l / (1000L * 60 * 60 * 24);
} catch (Exception e) {
return Long.MAX_VALUE;
}
}
/**
* 返回下个月的当日
*/
public static String getNextDate(String date) {
try {
Date date1 = ymdDateFormat.parse(date);
sCalendar.setTime(date1);
int month = sCalendar.get(Calendar.MONTH) + 1;
int bit = month / 12;
if (month > 11) {
month = month - 12;
}
int year = sCalendar.get(Calendar.YEAR) + bit;
int day = sCalendar.get(Calendar.DAY_OF_MONTH);
sCalendar.set(year, month, 1);
int day1 = sCalendar.getMaximum(Calendar.DAY_OF_MONTH);
day = day1 < day ? day1 : day;
sCalendar.set(year, month, day);
return ymdDateFormat.format(sCalendar.getTime());
} catch (Exception e) {
return date;
}
}
;
/**
* 全日期格式化成yyyy-MM-dd
*
* @return
*/
public static String ymdFormat(String date) {
if (TextUtils.isEmpty(date)) {
return null;
}
try {
return ymdDateFormat.format(commonDateFormat.parse(date));
} catch (ParseException e) {
// e.printStackTrace();
}
return date;
}
public static String getYesterDay(String dateString) {
if (TextUtils.isEmpty(dateString)) {
return null;
}
Date currentDate = null;
try {
currentDate = commonYMDFormat.parse(dateString);
} catch (ParseException e) {
currentDate = null;
}
if (currentDate == null) {
return null;
}
Calendar calendar = Calendar.getInstance();
calendar.setTime(currentDate);
calendar.add(Calendar.DAY_OF_YEAR, -1);
return commonYMDFormat.format(calendar.getTime());
}
/**
* 从日期字符串中获取日
*
* @param dateString 2014-01-23 12:22:00
*/
public static String getStringDateOfDay(String dateString) {
String day = "";
if (dateString == null) {
return day;
}
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal1 = Calendar.getInstance();
cal1.setTime(sdf.parse(dateString));
Date date = cal1.getTime();
day = getDay(date);
} catch (ParseException e) {
}
return day;
}
/**
* 从日期字符串中获取日小写
*
* @param dateString 2014-01-23 12:22:00
*/
public static String getNStringDateOfDay(String dateString) {
String day = "";
if (dateString == null) {
return day;
}
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar cal1 = Calendar.getInstance();
cal1.setTime(sdf.parse(dateString));
Date date = cal1.getTime();
day = getDay(date);
} catch (ParseException e) {
}
if (day != null && day.length() == 2) {
if (day.charAt(0) == '0') {
day = day.substring(1);
}
}
return day;
}
/**
* 得到2013年01月 格式
*
* @param dateString
* @return
*/
public static String parseYYMMdate(String dateString) {
String date = "";
if (dateString == null) {
return dateString;
}
try {
SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月");
Date dataDate = commonDateFormat.parse(dateString);
date = sdf2.format(dataDate);
return date;
} catch (ParseException e) {
return date;
}
}
/**
* 获取年
*
* @param date
* @return
*/
public static String getYear(Date date) {
if (sCalendar == null) {
sCalendar = Calendar.getInstance();
}
sCalendar.setTime(date);
return String.valueOf(sCalendar.get(Calendar.YEAR));
}
/**
* 获取月
*
* @param date
* @return
*/
public static String getMonth(Date date) {
if (sCalendar == null) {
sCalendar = Calendar.getInstance();
}
sCalendar.setTime(date);
return String.valueOf(sCalendar.get(Calendar.MONTH) + 1);
}
/**
* 获取星期几
*
* @param date
* @return
*/
public static String getWeek(Date date) {
SimpleDateFormat dateFm = new SimpleDateFormat("EEEE");
return dateFm.format(date);
}
/**
* 获取日期中的日
*
* @param date
* @return
*/
public static String getDay(Date date) {
if (sCalendar == null) {
sCalendar = Calendar.getInstance();
}
sCalendar.setTime(date);
return formatDateNum(sCalendar.get(Calendar.DAY_OF_MONTH));
}
/**
* 判断后面时间是否在前面时间之后
*
* @param startTime 2010-10-10
* @param endTime 2010-10-12
* @return true
*/
public static boolean isAfterDate(String startTime, String endTime) {
try {
Date startDate = ymdDateFormat.parse(startTime);
Date enDate = ymdDateFormat.parse(endTime);
return !enDate.before(startDate);
} catch (ParseException e) {
}
return false;
}
}
| [
"linghui.yue@qdaily.com"
] | linghui.yue@qdaily.com |
c0e88e0dcc612672b4e25d7da7de693b0078e3e8 | c8688db388a2c5ac494447bac90d44b34fa4132c | /sources/com/google/android/gms/internal/measurement/C2880u4.java | 110a16ed1e6dacf629b7eb9b17f8f5065d11616e | [] | no_license | mred312/apk-source | 98dacfda41848e508a0c9db2c395fec1ae33afa1 | d3ca7c46cb8bf701703468ddc88f25ba4fb9d975 | refs/heads/master | 2023-03-06T05:53:50.863721 | 2021-02-23T13:34:20 | 2021-02-23T13:34:20 | 341,481,669 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 679 | java | package com.google.android.gms.internal.measurement;
import java.util.Map;
/* renamed from: com.google.android.gms.internal.measurement.u4 */
/* compiled from: com.google.android.gms:play-services-measurement-base@@17.6.0 */
interface C2880u4 {
/* renamed from: a */
Map<?, ?> mo18859a(Object obj);
/* renamed from: b */
boolean mo18860b(Object obj);
/* renamed from: c */
Map<?, ?> mo18861c(Object obj);
/* renamed from: d */
Object mo18862d(Object obj, Object obj2);
/* renamed from: e */
int mo18863e(int i, Object obj, Object obj2);
C2864s4<?, ?> zzb(Object obj);
Object zze(Object obj);
Object zzf(Object obj);
}
| [
"mred312@gmail.com"
] | mred312@gmail.com |
08191d202f5d8f5d2d47b7049c34db4b71530c46 | 9992154231dac834b7a274491e2cb7bd2e335479 | /web/src/main/java/com/hou/web/web03/MyController.java | d1bf040ef67a7b19719f01a48efd2208c6fe4321 | [] | no_license | Loveli9/springbootbase | e3e3408ab029c8a2ecd23303d3073b06db585920 | c1bba2769dc51add7ac9e8f6c232d23563325904 | refs/heads/master | 2022-06-23T18:58:11.484983 | 2020-04-30T23:43:47 | 2020-04-30T23:43:47 | 252,118,222 | 0 | 0 | null | 2022-06-21T03:06:46 | 2020-04-01T08:36:56 | Java | UTF-8 | Java | false | false | 575 | java | package com.hou.web.web03;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class MyController {
//只在本Controller有效
@ExceptionHandler(value = Exception.class)
public String error(Exception e) {
//可以根据参数获取具体异常信息
return "found Exception:" + e.getMessage();
}
@GetMapping("/list")
public String list() {
return "list";
}
}
| [
"huyapeng@chinasoftinc.com"
] | huyapeng@chinasoftinc.com |
f943c13e18eb3d33d9eb31d8f480a5f72a628c89 | 484630636b275f57ca03dce69bde7a8dad3cf991 | /JavaCore/Thinking_in_Java/src/Part6/Lesson4/TestProtected2/TestProtected2.java | 4a8f52c7d0e1d748ae789896ac9cf975a16f9124 | [] | no_license | savra/Education_projects | 2ffc9395f91e3c7818f9283175d5247fc17d07d9 | a8c38c80ddd10692df243b3187e4a3230d6d286e | refs/heads/master | 2022-11-21T14:24:39.879891 | 2020-07-28T19:57:10 | 2020-07-28T19:57:10 | 283,288,648 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 466 | java | package Part6.Lesson4.TestProtected2;
import Part6.Lesson4.TestProtected1.TestProtected1;
public class TestProtected2 {
public static void main(String ... args)
{
TestProtected1 tp1 = new TestProtected1();
tp1.field1 = 5;
//tp1.field2 = 5; default
//tp1.field3 = 5; protected
//tp1.field4 = 5; private
tp1.f1();
//tp1.f2(); default
//tp1.f3(); protected
//tp1.f4(); private
}
}
| [
"savrawar@mail.ru"
] | savrawar@mail.ru |
d4a229dbafe1d057f80e2a2fb3d96e83c494e61d | 0a532b9d7ebc356ab684a094b3cf840b6b6a17cd | /java-source/src/main/javax/tools/ForwardingFileObject.java | a177666ab6695565ad6ede70f4a0eba1d36dccc8 | [
"Apache-2.0"
] | permissive | XWxiaowei/JavaCode | ac70d87cdb0dfc6b7468acf46c84565f9d198e74 | a7e7cd7a49c36db3ee479216728dd500eab9ebb2 | refs/heads/master | 2022-12-24T10:21:28.144227 | 2020-08-22T08:01:43 | 2020-08-22T08:01:43 | 98,070,624 | 10 | 4 | Apache-2.0 | 2022-12-16T04:23:38 | 2017-07-23T02:51:51 | Java | UTF-8 | Java | false | false | 2,911 | java | /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package javax.tools;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.net.URI;
/**
* Forwards calls to a given file object. Subclasses of this class
* might override some of these methods and might also provide
* additional fields and methods.
*
* @param <F> the kind of file object forwarded to by this object
* @author Peter von der Ahé
* @since 1.6
*/
public class ForwardingFileObject<F extends FileObject> implements FileObject {
/**
* The file object which all methods are delegated to.
*/
protected final F fileObject;
/**
* Creates a new instance of ForwardingFileObject.
* @param fileObject delegate to this file object
*/
protected ForwardingFileObject(F fileObject) {
fileObject.getClass(); // null check
this.fileObject = fileObject;
}
public URI toUri() {
return fileObject.toUri();
}
public String getName() {
return fileObject.getName();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public InputStream openInputStream() throws IOException {
return fileObject.openInputStream();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public OutputStream openOutputStream() throws IOException {
return fileObject.openOutputStream();
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
return fileObject.openReader(ignoreEncodingErrors);
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
return fileObject.getCharContent(ignoreEncodingErrors);
}
/**
* @throws IllegalStateException {@inheritDoc}
* @throws UnsupportedOperationException {@inheritDoc}
* @throws IOException {@inheritDoc}
*/
public Writer openWriter() throws IOException {
return fileObject.openWriter();
}
public long getLastModified() {
return fileObject.getLastModified();
}
public boolean delete() {
return fileObject.delete();
}
}
| [
"2809641033@qq.com"
] | 2809641033@qq.com |
ef5b7cb42635b6b976b6d592c9a7c78e3e40e4ea | 78b5a74f88aeb2eb9620774bf0a61f15d49d2ca0 | /employee-jdbc/src/main/java/com/javainuse/service/EmployeeServiceImpl.java | a547aa3725cd4871f6ae96bd6b3bc6b108fb8995 | [] | no_license | vidhipatel201/employee-jdbc | 08000fc4e197c85d744a5860cc4762bf979135fb | 9c44f410504a7d096f64a6218004f5a47716120a | refs/heads/master | 2020-08-26T15:56:46.512666 | 2019-10-23T13:27:11 | 2019-10-23T13:27:11 | 217,063,730 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 623 | java | package com.javainuse.service;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.javainuse.dao.EmployeeDao;
import com.javainuse.model.Employee;
import com.javainuse.service.EmployeeService;
@Service
public class EmployeeServiceImpl implements EmployeeService {
@Autowired
EmployeeDao employeeDao;
public List<Employee> getAllEmployees() {
List<Employee> employees = employeeDao.getAllEmployees();
return employees;
}
public void insertEmployee(Employee employee) {
employeeDao.insertEmployee(employee);
}
} | [
"VPatel@cyphersystems.com"
] | VPatel@cyphersystems.com |
617c9d8c209b04e1ff0fbee114b961f213be8589 | 4c6adf0ce6ef3f02dcef9c345e0e5e4ff139d886 | /MPS/app-website/src/main/java/com/pay/app/controller/base/login/LoginController.java | 9a6b0545c796edb42ef187f3a167bf12cebd505d | [] | no_license | happyjianguo/pay-1 | 8631906be62707316f0ed3eb6b2337c90d213bc0 | 40ae79738cfe4e5d199ca66468f3a33e9d8f2007 | refs/heads/master | 2020-07-27T19:51:54.958859 | 2016-12-19T07:34:24 | 2016-12-19T07:34:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,482 | java | package com.pay.app.controller.base.login;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;
import com.pay.app.common.helper.AppConf;
public class LoginController extends MultiActionController{
private String enterpriceLogin;
private String individualLogin;
public ModelAndView individualLogin(HttpServletRequest request,
HttpServletResponse response) {
String returnUrl=request.getParameter("returnUrl");
if(StringUtils.isBlank(returnUrl)){
returnUrl=AppConf.defaultCallBack;
}
return new ModelAndView(individualLogin).addObject("returnUrl",returnUrl);
}
public ModelAndView enterpriceLogin(HttpServletRequest request,
HttpServletResponse response) {
String returnUrl=request.getParameter("returnUrl");
if(StringUtils.isBlank(returnUrl)){
returnUrl=AppConf.defaultCorpCallBack;
}
return new ModelAndView(enterpriceLogin).addObject("returnUrl",returnUrl);
}
public void setEnterpriceLogin(String enterpriceLogin) {
this.enterpriceLogin = enterpriceLogin;
}
public void setIndividualLogin(String individualLogin) {
this.individualLogin = individualLogin;
}
}
| [
"stanley.zou@hrocloud.com"
] | stanley.zou@hrocloud.com |
e2a078054c3060f79ca2b5515b2673316164adc2 | 4b26b0848caa3ce7f9e1c94b7dbe878c011fcc9f | /src/baselivre/ui/rubrique/jiGestionRubrique.java | 54a40dd34cad6f28dc775406b689830381fc4433 | [] | no_license | garzgul/baselivre | 367976ffd354fc6a483ea6fcf45a278069bf9e74 | 8e39cf134d67503a013db2e85f7af93a7a3544e1 | refs/heads/master | 2021-01-13T02:22:23.257215 | 2014-08-21T14:13:59 | 2014-08-21T14:13:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,843 | java | package baselivre.ui.rubrique;
import baselivre.produit.Auteur;
import baselivre.produit.Editeur;
import baselivre.produit.Livre;
import baselivre.ui.frame.InterfaceRoot;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.print.event.PrintJobEvent;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JDesktopPane;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
/**
*
* @author cdi111/cdi108
*/
public class jiGestionRubrique extends javax.swing.JInternalFrame {
private String sqlConnexion;
private InterfaceRoot ir;
private int idRubrique;
private String rubriqueNom;
private Date rubriqueDateDbt;
private Date rubriqueDateFin;
private int rubriqueActive;
private Statement stmt;
private Connection connexion;
/*
private DefaultTableModel initTable() {
DefaultTableModel tm = new DefaultTableModel()
{
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
return tm;
}//*/
/**
* Constructeur pour la frame
* @param ir InterfaceRoot
*/
public jiGestionRubrique(InterfaceRoot ir) {
this.ir = ir;
this.sqlConnexion = ir.SqlConnexion();
initComponents();
}
//Procédure d'affichage des rubriques
private DefaultTableModel initTable() {
Vector rub = new Vector();
Vector vtitre = new Vector();
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, "Erreur de connexion" + ex.getMessage());
return null;
}
try {
connexion = DriverManager.getConnection(sqlConnexion);
stmt = connexion.createStatement();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erreur connexion !" + ex.getMessage());
return null;
}
ResultSet rs = null;
try {
rs = stmt.executeQuery("SELECT * FROM rubrique");
// Recupératiojn des données de la base de données (table rubrique).
String etat;
while (rs.next()) {
Vector vv = new Vector();
if (rs.getInt("rubrique_actif") == 1) {
etat = "Actif";
} else {
etat = "Inactif";
}
vv.add(rs.getInt("id_rubrique"));
vv.add(rs.getString("rubrique_nom"));
vv.add(rs.getDate("rubrique_datedbt"));
vv.add(rs.getDate("rubrique_datefin"));
vv.add(etat);
rub.add(vv);
}
// Ajout de titre pour chaque colonne de la table rubrique
vtitre.add("Id Rubrique");
vtitre.add("Nom Rubrique");
vtitre.add("Date de début");
vtitre.add("Date de fin");
vtitre.add("Etat");
rs.close();
stmt.close();
connexion.close();
} catch (SQLException ex) {
JOptionPane.showMessageDialog(this, "SQL !! " + ex.getErrorCode());
return null;
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erreur a l'affichage\n" + e.getMessage());
return null;
}
DefaultTableModel dt = new DefaultTableModel(rub, vtitre) {
@Override
public boolean isCellEditable(int row, int column) {
return false;
}
};
return dt;
}
// Procéure modifierRubrique
private void modifierRubrique() {
int selectedRow = jtRubrique.getSelectedRow();
int idRub;
int actif;
if (JOptionPane.showConfirmDialog(null, "Confirmer la modification\n", "Modifier", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
try {
if (selectedRow != -1) {
idRub = (int) jtRubrique.getValueAt(selectedRow, 0);
if (jtfEtat.getText().equalsIgnoreCase("Actif")) {
actif = 1;
} else {
actif = 0;
}
String sql = "UPDATE rubrique SET rubrique_nom = '" + jtfRubriqueNom.getText()
+ "', rubrique_datedbt = '" + jtfRubriqueDateDbt.getText() + "', rubrique_datefin = '"
+ jtfRubriqueDateFin.getText() + "', rubrique_actif = " + Integer.toString(actif) + " WHERE id_rubrique = '" + idRub + "'";
stmt.executeUpdate(sql);
} else {
JOptionPane.showMessageDialog(null, "Selectionnez une ligne !");
}
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Erreur !\n" + e.getMessage());
}
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane4 = new javax.swing.JTabbedPane();
jPanel4 = new javax.swing.JPanel();
jpRubrique = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jtRubrique = new javax.swing.JTable();
jbtnCreation = new javax.swing.JButton();
jbtnModifierTheme = new javax.swing.JButton();
jbtnSuppression = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jtfRubriqueNom = new javax.swing.JTextField();
jtfRubriqueDateDbt = new javax.swing.JTextField();
jtfRubriqueDateFin = new javax.swing.JTextField();
jLabel5 = new javax.swing.JLabel();
jtfEtat = new javax.swing.JTextField();
jlblIdRubrique = new javax.swing.JLabel();
setClosable(true);
setTitle("Gestion des Stocks Librairie");
getContentPane().setLayout(null);
jPanel4.setLayout(null);
jTabbedPane4.addTab("Promotion ", jPanel4);
jpRubrique.setLayout(null);
jtRubrique.setModel(initTable());
jtRubrique.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jtRubriqueMouseClicked(evt);
}
});
jScrollPane2.setViewportView(jtRubrique);
jpRubrique.add(jScrollPane2);
jScrollPane2.setBounds(350, 20, 540, 200);
jbtnCreation.setText("Création ");
jbtnCreation.setMaximumSize(new java.awt.Dimension(100, 25));
jbtnCreation.setMinimumSize(new java.awt.Dimension(100, 25));
jbtnCreation.setPreferredSize(new java.awt.Dimension(100, 25));
jbtnCreation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnCreationActionPerformed(evt);
}
});
jpRubrique.add(jbtnCreation);
jbtnCreation.setBounds(10, 230, 100, 25);
jbtnModifierTheme.setText("Modification ");
jbtnModifierTheme.setMaximumSize(new java.awt.Dimension(100, 25));
jbtnModifierTheme.setMinimumSize(new java.awt.Dimension(100, 25));
jbtnModifierTheme.setPreferredSize(new java.awt.Dimension(100, 25));
jbtnModifierTheme.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnModifierThemeActionPerformed(evt);
}
});
jpRubrique.add(jbtnModifierTheme);
jbtnModifierTheme.setBounds(120, 230, 100, 25);
jbtnSuppression.setText("Suppression ");
jbtnSuppression.setMaximumSize(new java.awt.Dimension(100, 25));
jbtnSuppression.setMinimumSize(new java.awt.Dimension(100, 25));
jbtnSuppression.setPreferredSize(new java.awt.Dimension(100, 25));
jbtnSuppression.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jbtnSuppressionActionPerformed(evt);
}
});
jpRubrique.add(jbtnSuppression);
jbtnSuppression.setBounds(230, 230, 120, 25);
jLabel1.setText("id Rubrique : ");
jpRubrique.add(jLabel1);
jLabel1.setBounds(10, 20, 70, 14);
jLabel2.setText("Rubrique : ");
jpRubrique.add(jLabel2);
jLabel2.setBounds(10, 60, 70, 14);
jLabel3.setText("Date début : ");
jpRubrique.add(jLabel3);
jLabel3.setBounds(10, 100, 70, 14);
jLabel4.setText("Date de fin : ");
jpRubrique.add(jLabel4);
jLabel4.setBounds(10, 140, 70, 14);
jpRubrique.add(jtfRubriqueNom);
jtfRubriqueNom.setBounds(110, 50, 230, 30);
jpRubrique.add(jtfRubriqueDateDbt);
jtfRubriqueDateDbt.setBounds(110, 90, 230, 30);
jpRubrique.add(jtfRubriqueDateFin);
jtfRubriqueDateFin.setBounds(110, 130, 230, 30);
jLabel5.setText("Etat :");
jpRubrique.add(jLabel5);
jLabel5.setBounds(10, 180, 60, 14);
jpRubrique.add(jtfEtat);
jtfEtat.setBounds(110, 170, 230, 30);
jlblIdRubrique.setBackground(new java.awt.Color(255, 255, 255));
jlblIdRubrique.setEnabled(false);
jlblIdRubrique.setOpaque(true);
jpRubrique.add(jlblIdRubrique);
jlblIdRubrique.setBounds(110, 20, 230, 20);
jTabbedPane4.addTab("Rubrique ", jpRubrique);
getContentPane().add(jTabbedPane4);
jTabbedPane4.setBounds(10, 10, 900, 310);
setBounds(0, 0, 933, 795);
}// </editor-fold>//GEN-END:initComponents
private void jbtnModifierThemeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnModifierThemeActionPerformed
// Connection à la base
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, "Erreur de connexion" + ex.getMessage());
}
try {
connexion = DriverManager.getConnection(sqlConnexion);
stmt = connexion.createStatement();
modifierRubrique();
stmt.close();
connexion.close();
jtRubrique.setModel(initTable());
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erreur connexion !" + ex.getMessage());
}
}//GEN-LAST:event_jbtnModifierThemeActionPerformed
private void jtRubriqueMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jtRubriqueMouseClicked
int selectedRow = jtRubrique.getSelectedRow();
if (selectedRow != -1) {
jlblIdRubrique.setText(jtRubrique.getValueAt(selectedRow, 0).toString());
jtfRubriqueNom.setText(jtRubrique.getValueAt(selectedRow, 1).toString());
jtfRubriqueDateDbt.setText(jtRubrique.getValueAt(selectedRow, 2).toString());
jtfRubriqueDateFin.setText(jtRubrique.getValueAt(selectedRow, 3).toString());
jtfEtat.setText(jtRubrique.getValueAt(selectedRow, 4).toString());
}
}//GEN-LAST:event_jtRubriqueMouseClicked
private void jbtnSuppressionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnSuppressionActionPerformed
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, "Erreur de connexion" + ex.getMessage());
}
try {
connexion = DriverManager.getConnection(sqlConnexion);
stmt = connexion.createStatement();
//////////////////////
if (JOptionPane.showConfirmDialog(null, "Confirmer la modification\n", "Modifier", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) {
int selectedRow = jtRubrique.getSelectedRow();
if (selectedRow != -1) {
String sql = "UPDATE rubrique SET rubrique_actif = 0 WHERE id_rubrique = " + jlblIdRubrique.getText();
stmt.executeUpdate(sql);
stmt.close();
connexion.close();
jtRubrique.setModel(initTable());
}
}
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erreur connexion !" + ex.getMessage());
}
}//GEN-LAST:event_jbtnSuppressionActionPerformed
private void jbtnCreationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbtnCreationActionPerformed
// Connection à la base
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
} catch (ClassNotFoundException ex) {
JOptionPane.showMessageDialog(null, "Erreur de connexion" + ex.getMessage());
}
try {
connexion = DriverManager.getConnection(sqlConnexion);
stmt = connexion.createStatement();
suppressionRubrique();
stmt.close();
connexion.close();
jtRubrique.setModel(initTable());
} catch (SQLException ex) {
JOptionPane.showMessageDialog(null, "Erreur connexion !" + ex.getMessage());
}
}//GEN-LAST:event_jbtnCreationActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel4;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JTabbedPane jTabbedPane4;
private javax.swing.JButton jbtnCreation;
private javax.swing.JButton jbtnModifierTheme;
private javax.swing.JButton jbtnSuppression;
private javax.swing.JLabel jlblIdRubrique;
private javax.swing.JPanel jpRubrique;
private javax.swing.JTable jtRubrique;
private javax.swing.JTextField jtfEtat;
private javax.swing.JTextField jtfRubriqueDateDbt;
private javax.swing.JTextField jtfRubriqueDateFin;
private javax.swing.JTextField jtfRubriqueNom;
// End of variables declaration//GEN-END:variables
private void suppressionRubrique() {
try{
boolean b = false;
for(int j = 0; j < jtRubrique.getRowCount() - 1; j++){
if(jtfRubriqueNom.getText().equalsIgnoreCase((jtRubrique.getValueAt(j, 1)).toString())){
b = true;
break;
}
}
if(b == false){
if(jtfRubriqueNom.getText().equals("")){
JOptionPane.showConfirmDialog(null, "Veuillez saisir le nom de la rubrique");
}
//Affaire a suivre, run run run
//if(jtfRubriqueDateDbt.getText().matches(())){
// }
stmt.executeUpdate("");
}
}catch(Exception e){
}
}
}
| [
"cdi116@pltz901.AFPA-PARIS-DI"
] | cdi116@pltz901.AFPA-PARIS-DI |
5b3dc1988d545951c8cbe7acd00dc07a00615b82 | b0875549e24f4e5956ea2ab822d4bb42e8b68563 | /aula-06-02-junit/src/test/java/br/com/tt/test.java | 9769d1f36dfc05cb9148851a0eba12cc40e44d16 | [] | no_license | laguirre171/TargetTrustNivel3 | 34ce930e5d46b4544c7832893e1a253d7d521905 | b4317ea6de8bbdcf4db81be5cc6c6c8644a6f509 | refs/heads/master | 2020-12-24T19:46:31.478834 | 2016-04-30T00:28:21 | 2016-04-30T00:28:21 | 56,723,161 | 0 | 0 | null | null | null | null | MacCentralEurope | Java | false | false | 766 | java | package br.com.tt;
import static org.junit.Assert.*;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import org.junit.Test;
import br.com.tt.model.Estado;
public class test {
@Test
public void test() {
EntityManager em = Persistence.createEntityManagerFactory("pu_jpa").createEntityManager();
Estado estado = new Estado();
estado.setSigla("AA");
em.getTransaction().begin();
em.persist(estado);
em.getTransaction().commit();
em.close();
em = null;
//Abrindo novamente a conex„o
em = Persistence.createEntityManagerFactory("pu_jpa").createEntityManager();
Estado e = em.find(Estado.class, 1);
System.out.println(e.getSigla());
em.close();
}
}
| [
"sala03@targettrust.local"
] | sala03@targettrust.local |
4f46ebb12f6dd9350d122c852fa5a5e9a68384ff | 0f9a7bb5f792bbced6cb0e4bd70c67b91a55c95f | /src/Goblin.java | 02f9817c80ba17841699002775c03fde84d09aee | [] | no_license | Dasuvorov/FirstRepository | 1679013d96ae61c60fcc21fd70ac04a8ea87b245 | 833625cee2507a7709ed778084334017768f7ea8 | refs/heads/master | 2020-12-14T22:18:13.875795 | 2020-04-10T06:43:50 | 2020-04-10T06:43:50 | 234,888,817 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 251 | java | public class Goblin implements Monster {
int id;
String name;
public Goblin(int id, String name) {
this.id = id;
this.name = name;
}
@Override
public void bye() {
System.out.println("bye");
}
} | [
"a9120294578@ya.ru"
] | a9120294578@ya.ru |
40aeddfcad5d8f6bf4a0d744a0ebd968f865dddd | 0da977fcdeafc69954357af9ebef0c6d770ab784 | /src/bperhaps/lecture11/ToStringExample2.java | 2057e049463c3b544f91c25092bd05849baa8060 | [] | no_license | bperhaps/java_init_my_brain | 6b72f4d8e2ea13bbffc4a41e1f7214c896d1d700 | c78ffebc1d1317304a832009d07b4e7f7c4a1dda | refs/heads/master | 2021-01-06T17:10:51.326392 | 2020-10-24T12:13:56 | 2020-10-24T12:13:56 | 241,411,396 | 1 | 2 | null | 2020-03-05T05:44:14 | 2020-02-18T16:31:46 | Java | UTF-8 | Java | false | false | 389 | java | package bperhaps.lecture11;
import java.util.Objects;
public class ToStringExample2 {
public static void main(String[] args) {
String str1 = "홍길동";
String str2 = null;
System.out.println(Objects.toString(str1));
System.out.println(Objects.toString(str2));
System.out.println(Objects.toString(str2, "이름이 없습니다. "));
}
}
| [
"sns2831@gmail.com"
] | sns2831@gmail.com |
0df05f495a443a3939ff618d441e33a4a93da8eb | a30bf2bd0d22e0db4dc1f91087655f59dfa440f4 | /projeto_integrador/app/build/tmp/kapt3/stubs/debug/com/sheyla/projeto_integrador/domain/Cast.java | 12796c89f024c7682d8d02750afac6faef61e7c6 | [] | no_license | sheylabarrientos/vitoriaCode | b2169588df6d2674d62a696457174fdd19ab725e | c0b4c97c18ec873d2e7f9b21681ce30f3c711400 | refs/heads/main | 2023-07-13T06:05:17.821875 | 2021-08-24T17:30:51 | 2021-08-24T17:30:51 | 369,212,770 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,836 | java | package com.sheyla.projeto_integrador.domain;
import java.lang.System;
@kotlin.Metadata(mv = {1, 5, 1}, k = 1, d1 = {"\u0000\"\n\u0002\u0018\u0002\n\u0002\u0010\u0000\n\u0000\n\u0002\u0010\u000e\n\u0002\b\f\n\u0002\u0010\u000b\n\u0002\b\u0002\n\u0002\u0010\b\n\u0002\b\u0002\b\u0086\b\u0018\u00002\u00020\u0001B)\u0012\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u0012\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u0003\u0012\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\u0002\u0010\u0006J\u000b\u0010\u000b\u001a\u0004\u0018\u00010\u0003H\u00c6\u0003J\u000b\u0010\f\u001a\u0004\u0018\u00010\u0003H\u00c6\u0003J\u000b\u0010\r\u001a\u0004\u0018\u00010\u0003H\u00c6\u0003J-\u0010\u000e\u001a\u00020\u00002\n\b\u0002\u0010\u0002\u001a\u0004\u0018\u00010\u00032\n\b\u0002\u0010\u0004\u001a\u0004\u0018\u00010\u00032\n\b\u0002\u0010\u0005\u001a\u0004\u0018\u00010\u0003H\u00c6\u0001J\u0013\u0010\u000f\u001a\u00020\u00102\b\u0010\u0011\u001a\u0004\u0018\u00010\u0001H\u00d6\u0003J\t\u0010\u0012\u001a\u00020\u0013H\u00d6\u0001J\t\u0010\u0014\u001a\u00020\u0003H\u00d6\u0001R\u0013\u0010\u0005\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\b\n\u0000\u001a\u0004\b\u0007\u0010\bR\u0013\u0010\u0002\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\b\n\u0000\u001a\u0004\b\t\u0010\bR\u0013\u0010\u0004\u001a\u0004\u0018\u00010\u0003\u00a2\u0006\b\n\u0000\u001a\u0004\b\n\u0010\b\u00a8\u0006\u0015"}, d2 = {"Lcom/sheyla/projeto_integrador/domain/Cast;", "", "name", "", "profile_path", "character", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "getCharacter", "()Ljava/lang/String;", "getName", "getProfile_path", "component1", "component2", "component3", "copy", "equals", "", "other", "hashCode", "", "toString", "app_debug"})
public final class Cast {
@org.jetbrains.annotations.Nullable()
private final java.lang.String name = null;
@org.jetbrains.annotations.Nullable()
private final java.lang.String profile_path = null;
@org.jetbrains.annotations.Nullable()
private final java.lang.String character = null;
@org.jetbrains.annotations.NotNull()
public final com.sheyla.projeto_integrador.domain.Cast copy(@org.jetbrains.annotations.Nullable()
java.lang.String name, @org.jetbrains.annotations.Nullable()
java.lang.String profile_path, @org.jetbrains.annotations.Nullable()
java.lang.String character) {
return null;
}
@java.lang.Override()
public boolean equals(@org.jetbrains.annotations.Nullable()
java.lang.Object other) {
return false;
}
@java.lang.Override()
public int hashCode() {
return 0;
}
@org.jetbrains.annotations.NotNull()
@java.lang.Override()
public java.lang.String toString() {
return null;
}
public Cast() {
super();
}
public Cast(@org.jetbrains.annotations.Nullable()
java.lang.String name, @org.jetbrains.annotations.Nullable()
java.lang.String profile_path, @org.jetbrains.annotations.Nullable()
java.lang.String character) {
super();
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String component1() {
return null;
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String getName() {
return null;
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String component2() {
return null;
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String getProfile_path() {
return null;
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String component3() {
return null;
}
@org.jetbrains.annotations.Nullable()
public final java.lang.String getCharacter() {
return null;
}
} | [
"sheylaaraujobarrientos@gmail.com"
] | sheylaaraujobarrientos@gmail.com |
449fe45ed8280fe77dcf7449af5dd2cb0ec10110 | 28bb8f9e29a821a15c8262b89f7aa968088ee3d0 | /src/by/it/examples/lesson15/listing14/DynQueue.java | 7348a55d47049f806c7241fe9983aa5f88582ae4 | [] | no_license | Khmelov/CS2017-09 | 0ffee1e1054b965b76ee8cf36993f0f3ca310ff2 | 793e0adb7468a62eac9a49f984955070927b55f7 | refs/heads/master | 2021-08-26T09:46:59.063670 | 2017-11-23T06:54:45 | 2017-11-23T06:54:45 | 105,267,925 | 0 | 89 | null | 2017-11-23T06:55:45 | 2017-09-29T12:06:36 | Java | UTF-8 | Java | false | false | 989 | java | package by.it.examples.lesson15.listing14;
// A dynamic queue.
class DynQueue implements ICharQ {
private char q[]; // this array holds the queue
private int putloc, getloc; // the put and get indices
// Construct an empty queue given its size.
public DynQueue(int size) {
q = new char[size]; // allocate memory for queue
putloc = getloc = 0;
}
// Put a characer into the queue.
public void put(char ch) {
if(putloc==q.length) {
// increase queue size
char t[] = new char[q.length * 2];
// copy elements into new queue
for(int i=0; i < q.length; i++)
t[i] = q[i];
q = t;
}
q[putloc++] = ch;
}
// Get a character from the queue.
public char get() {
if(getloc == putloc) {
System.out.println(" -- Queue is empty.");
return (char) 0;
}
return q[getloc++];
}
} | [
"375336849110@tut.by"
] | 375336849110@tut.by |
41ce5959572601bd1d1e2e1e9869ee58e56ca37f | 419a44f9874be15b4be4ff3504ca1db6f3535b19 | /src/main/java/com/softtek/academia/controller/StateController.java | 24380e86348d3dfaf4210e424582f28c626905e7 | [] | no_license | Eli2404/ExamenProblema13 | b62e1cb487d472bcb72545ea5cf3c8cf8edff935 | 5c41be4c59e64114af819d270cc936566b06888d | refs/heads/master | 2022-12-21T11:27:58.837279 | 2019-12-24T00:16:03 | 2019-12-24T00:16:03 | 229,840,598 | 0 | 0 | null | 2022-12-15T23:55:55 | 2019-12-24T00:09:00 | Java | UTF-8 | Java | false | false | 3,807 | java | //package com.softtek.academia.controller;
//
//import java.io.IOException;
//import java.util.HashMap;
//import java.util.LinkedHashMap;
//import java.util.List;
//import java.util.Map;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.stereotype.Controller;
//import org.springframework.validation.BindingResult;
//import org.springframework.web.bind.annotation.ModelAttribute;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestMethod;
//import org.springframework.web.servlet.ModelAndView;
//
//import com.softtek.academia.entity.State;
//import com.softtek.academia.service.StateService;
//
//@Controller
//public class StateController {
// // Constructor based Dependency Injection
// private StateService stateService;
//
// public StateController() {
//
// }
//
// @Autowired
// public StateController(StateService stateService) {
// this.stateService = stateService;
// }
//
// @RequestMapping(value = { "/", "/home" }, method = RequestMethod.GET)
// public ModelAndView hello(HttpServletResponse response) throws IOException {
// ModelAndView mv = new ModelAndView();
// mv.setViewName("home");
// return mv;
// }
//
// // Get All States
// @RequestMapping(value = "/allStates", method = RequestMethod.POST)
// public ModelAndView displayAllStates() {
// System.out.println("State Page Requested : All States");
// ModelAndView mv = new ModelAndView();
// List<State> stateList = stateService.getAllStates();
// mv.addObject("stateList", stateList);
// mv.setViewName("allStates");
// return mv;
// }
//
// @RequestMapping(value = "/addState", method = RequestMethod.GET)
// public ModelAndView displayNewStateForm() {
// ModelAndView mv = new ModelAndView("addState");
// mv.addObject("headerMessage", "Add State Details");
// mv.addObject("state", new State());
// return mv;
// }
//
// @RequestMapping(value = "/addState", method = RequestMethod.POST)
// public ModelAndView saveNewState(@ModelAttribute State state, BindingResult result) {
// ModelAndView mv = new ModelAndView("redirect:/home");
//
// if (result.hasErrors()) {
// return new ModelAndView("error");
// }
// boolean isAdded = stateService.saveState(state);
// if (isAdded) {
// mv.addObject("message", "New state successfully added");
// } else {
// return new ModelAndView("error");
// }
//
// return mv;
// }
//
// @RequestMapping(value = "/editState/{id}", method = RequestMethod.GET)
// public ModelAndView displayEditStateForm(@PathVariable Long id) {
// ModelAndView mv = new ModelAndView("/editState");
// State state = stateService.getStateById(id);
// mv.addObject("headerMessage", "Edit State Details");
// mv.addObject("state", state);
// return mv;
// }
//
// @RequestMapping(value = "/editState/{id}", method = RequestMethod.POST)
// public ModelAndView saveEditedState(@ModelAttribute State state, BindingResult result) {
// ModelAndView mv = new ModelAndView("redirect:/home");
//
// if (result.hasErrors()) {
// System.out.println(result.toString());
// return new ModelAndView("error");
// }
// boolean isSaved = stateService.saveState(state);
// if (!isSaved) {
//
// return new ModelAndView("error");
// }
//
// return mv;
// }
//
// @RequestMapping(value = "/deleteState/{id}", method = RequestMethod.GET)
// public ModelAndView deleteStateById(@PathVariable Long id) {
// boolean isDeleted = stateService.deleteStateById(id);
// System.out.println("State deletion respone: " + isDeleted);
// ModelAndView mv = new ModelAndView("redirect:/home");
// return mv;
//
// }
//
//}
| [
"curso@stktrainning.com"
] | curso@stktrainning.com |
2a47f7741c3352774c0a639215ff70c8775e5af3 | b39e2eb2e8ef82c113fac35eb44cad792c9f94e5 | /AP Assignment 2/ArrayListExample.java | 99c9bf623b632c1a809d6b1d27eed68a34f499d6 | [] | no_license | Fatima-Naseer/Advanced-Programming | 2e81ef08a5ec1e7133da3c697de0bdf16583abab | 46b5831921427fd449cb75c26bae4c9ac7f87f46 | refs/heads/master | 2020-04-26T05:29:56.783476 | 2019-03-01T17:17:01 | 2019-03-01T17:17:01 | 173,336,182 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 833 | java | /*
* 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 arraylistexample;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
*
* @author Fatima
*/
public class ArrayListExample {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
List<String> al=new ArrayList<String>();//creating arraylist
al.add("Sonoo");//adding object in arraylist
al.add("Michael");
al.add("James");
al.add("Andy");
//traversing elements using Iterator
Iterator itr=al.iterator();
while(itr.hasNext())
{
System.out.println(itr.next());
}
}
}
| [
"fatimanaseer05@gmail.com"
] | fatimanaseer05@gmail.com |
10edd134682e161cf85455e6db5aeb8fbc5777d9 | 5a0bfac7ad00c079fe8e0bdf1482f4271c46eeab | /app/src/main/wechat6.5.3/com/tencent/mm/plugin/freewifi/ui/FreewifiActivateWeChatNoAuthStateUI.java | 78654d550f4da9c164b40e46d86d00ad6c6d47e4 | [] | no_license | newtonker/wechat6.5.3 | 8af53a870a752bb9e3c92ec92a63c1252cb81c10 | 637a69732afa3a936afc9f4679994b79a9222680 | refs/heads/master | 2020-04-16T03:32:32.230996 | 2017-06-15T09:54:10 | 2017-06-15T09:54:10 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,773 | java | package com.tencent.mm.plugin.freewifi.ui;
import android.net.NetworkInfo.State;
import com.tencent.mm.model.ak;
import com.tencent.mm.plugin.freewifi.d.a;
import com.tencent.mm.plugin.freewifi.m;
import com.tencent.mm.plugin.freewifi.model.d;
import com.tencent.mm.plugin.freewifi.model.j;
import com.tencent.mm.sdk.platformtools.v;
import com.tencent.mm.v.e;
import com.tencent.mm.v.k;
@Deprecated
public class FreewifiActivateWeChatNoAuthStateUI extends FreeWifiActivateNoAuthStateUI {
private int bcb;
private String gcX;
private String gcY;
protected final String apQ() {
return getString(2131232984);
}
public final void a(State state) {
v.i("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "now network state : %s", new Object[]{state.toString()});
if (state == State.CONNECTED && d.tH(this.ssid) && this.gaY) {
apT();
this.gaY = false;
this.gcX = d.aoW();
this.gcY = d.aoY();
this.bcb = d.aoX();
v.i("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "now has connect the ap, check from server rssi is : %d, mac : %s, ssid is : %s", new Object[]{Integer.valueOf(this.bcb), this.gcX, this.gcY});
new a(this.fZD, this.gcX, this.gcY, this.bcb, this.aPW, m.s(getIntent())).b(new e(this) {
final /* synthetic */ FreewifiActivateWeChatNoAuthStateUI gcZ;
{
this.gcZ = r1;
}
public final void a(int i, int i2, String str, k kVar) {
ak.vy().b(640, this);
v.i("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "onSceneEnd, errType = %d, errCode = %d", new Object[]{Integer.valueOf(i), Integer.valueOf(i2)});
if (i == 0 && i2 == 0) {
v.i("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "check ap ok");
d.a(this.gcZ.ssid, 2, this.gcZ.getIntent());
return;
}
v.e("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "check ap failed : rssi is : %d, mac : %s, ssid is : %s", new Object[]{Integer.valueOf(this.gcZ.bcb), this.gcZ.gcX, this.gcZ.gcY});
this.gcZ.ku(-2014);
d.tJ(this.gcZ.gcY);
}
});
}
}
protected void onDestroy() {
super.onDestroy();
}
protected final int apP() {
j.api();
int tG = d.tG(this.ssid);
v.i("MicroMsg.FreeWifi.FreewifiActivateWeChatNoAuthStateUI", "get connect state = %d", new Object[]{Integer.valueOf(tG)});
if (tG == 0) {
return -2014;
}
return tG;
}
}
| [
"zhangxhbeta@gmail.com"
] | zhangxhbeta@gmail.com |
833859df37aca04d5a93b2a0088d3cb0e400ecc3 | c609b045ef0bd0dfbc1b0ac5caac869915bfba6d | /src/test/java/com/liujun/command/processbuilder/TestSynchronousLocalShellCommand.java | 67c3697e5343ff515d47579fbcc438b6a0920a14 | [] | no_license | kkzfl22/demojava8 | de0c8d877b7b980f2ee4bef9227af9470d79842f | 5d0030a27a8ffcac2a619e9bf5b7d8dc9eba171f | refs/heads/master | 2022-06-27T08:21:31.257326 | 2021-04-23T01:36:23 | 2021-04-23T01:36:23 | 208,544,311 | 3 | 0 | null | 2022-05-20T22:01:43 | 2019-09-15T04:58:48 | Java | UTF-8 | Java | false | false | 961 | java | package com.liujun.command.processbuilder;
import org.junit.Assert;
import org.junit.Test;
import java.util.Arrays;
import java.util.List;
/**
* 测试同步命令的执行
*
* @author liujun
* @version 0.0.1
*/
public class TestSynchronousLocalShellCommand {
/** 同步执行命令 */
@Test
public void synchornousDoCommand() {
// 运行一个正常的命令
this.runCommand("ping www.baidu.com");
// 运行一个bat脚本
this.runCommand("D:/run/bat/run.bat");
// 错误命令
this.runCommand("abcdef");
}
/**
* 运行command
*
* @param commandStr 错误命令行
*/
private void runCommand(String commandStr) {
List<String> commandList = Arrays.asList("cmd.exe","/C",commandStr);
SynchronousLocalShellCommand command = new SynchronousLocalShellCommand(commandList);
String commandRsp = command.doCommand();
Assert.assertNotNull(commandRsp);
System.out.println(commandRsp);
}
}
| [
"liujun@paraview.cn"
] | liujun@paraview.cn |
0f98de72d506ee84dc37d20dad9e31492ef999c7 | 54b9e132bbb6f8baf850846925fd7126c5022772 | /5.implementation/VT/redsun/src/main/java/com/redsun/controller/DirectoryController.java | 00ed19e0cca2d67ecfaac67825c3ddbdfa2e3365 | [] | no_license | treviets/BIM | 40a10afdf6ff57939ac1c2105e23c0330b0a8fdc | ab6c85dd90ec4d8b6b89f79b07325aa54bafa09f | refs/heads/master | 2020-03-18T18:51:45.697405 | 2018-05-28T06:36:25 | 2018-05-28T06:36:25 | 135,119,151 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,725 | java | package com.redsun.controller;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.InputStreamResource;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import com.redsun.utils.RedSunURLs;
import com.redsun.utils.RestAPIHelper;
import com.redsun.utils.UserUtil;
@Controller
@EnableWebMvc
@RequestMapping(value = "directory")
public class DirectoryController extends BaseController{
@Autowired
UserUtil userUtil;
// Insert.
@RequestMapping(value = "insert", method = RequestMethod.POST)
@ResponseBody
public Object addDirectory(@RequestBody Map<String, Object> directory, HttpServletRequest request) throws Exception{
int clientId = userUtil.getClientIdOfLoginedUser();
directory.put("clientId", clientId);
String userName = userUtil.getLoginedUsername();
directory.put("createUserName", userName);
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_INSERT;
Object result = RestAPIHelper.post(redsunServiceUrl, directory);
return result;
}
@RequestMapping(value = "insertdef", method = RequestMethod.POST)
@ResponseBody
public Object addDirectoryDef(@RequestBody Map<String, Object> directory, HttpServletRequest request) throws Exception{
int clientId = userUtil.getClientIdOfLoginedUser();
directory.put("clientId", clientId);
String userName = userUtil.getLoginedUsername();
directory.put("createUserName", userName);
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_INSERT_DEF;
Object result = RestAPIHelper.post(redsunServiceUrl, directory);
return result;
}
// Insert.
@RequestMapping(value = "createlistdirectory/{id}/{projectName}", method = RequestMethod.GET)
@ResponseBody
public Object createListDirectory(@PathVariable("id") Integer id, @PathVariable("projectName") String projectName, HttpServletRequest request) throws Exception{
int clientId = userUtil.getClientIdOfLoginedUser();
String userName = userUtil.getLoginedUsername();
Map<String, Object> resultDoc = new HashMap<String, Object>();
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_CREATE_LIST + id + "/" + projectName + "/" + userName + "/" + clientId;
Object result = RestAPIHelper.get(redsunServiceUrl, resultDoc);
return result;
}
// Update.
@RequestMapping(value = "update/{id}", method = RequestMethod.PUT)
@ResponseBody
public Object updateDirectory(@PathVariable("id") Integer id, @RequestBody Map<String, Object> directory, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
directory.put("clientId", clientId);
String userName = userUtil.getLoginedUsername();
directory.put("createUserName", userName);
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_UPDATE + id;
Object result = RestAPIHelper.put(redsunServiceUrl, directory, null);
return result;
}
@RequestMapping(value = "updatedef/{id}", method = RequestMethod.PUT)
@ResponseBody
public Object updateDirectoryDef(@PathVariable("id") Integer id, @RequestBody Map<String, Object> directory, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
directory.put("clientId", clientId);
String userName = userUtil.getLoginedUsername();
directory.put("createUserName", userName);
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_UPDATE_DEF + id;
Object result = RestAPIHelper.put(redsunServiceUrl, directory, null);
return result;
}
// Update.
@RequestMapping(value = "updatetrash/{id}/{location}", method = RequestMethod.PUT)
@ResponseBody
public Object moveFolderToTrash(@PathVariable("id") Integer id, @PathVariable("location") String location, HttpServletRequest request) throws Exception {
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_UPDATE_TRASH + id + "/" + location;
Object result = RestAPIHelper.put(redsunServiceUrl, null, null);
return result;
}
@RequestMapping(value = "undofromtrash/{ids}", method = RequestMethod.PUT)
@ResponseBody
public Object undoFolderFromTrash(@PathVariable("ids") String ids, HttpServletRequest request) throws Exception {
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_UNDO_TRASH + ids;
Object result = RestAPIHelper.put(redsunServiceUrl, null, null);
return result;
}
// Delete.
@RequestMapping(value = "delete/{id}/{location}", method = RequestMethod.DELETE)
@ResponseBody
public Object deleteDirectory(@PathVariable("id") Integer id, @PathVariable("location") String location, HttpServletRequest request){
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_DELETE + id + "/" + location;
Object result = RestAPIHelper.delete(redsunServiceUrl, null, null);
return result;
}
@RequestMapping(value = "deletedef/{id}/{location}", method = RequestMethod.DELETE)
@ResponseBody
public Object deleteDirectoryDef(@PathVariable("id") Integer id, @PathVariable("location") String location, HttpServletRequest request){
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_DELETE_DEF + id + "/" + location;
Object result = RestAPIHelper.delete(redsunServiceUrl, null, null);
return result;
}
// List by Id.
@RequestMapping("getbyid/{id}")
@ResponseBody
public Object getDirectoryById(@PathVariable("id") Integer id, HttpServletRequest request){
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_GET_BY_ID + id;
Object result = RestAPIHelper.get(redsunServiceUrl, new HashMap<String, Object>());
return result;
}
@RequestMapping("getdefbyid/{id}")
@ResponseBody
public Object getDirectoryDefById(@PathVariable("id") Integer id, HttpServletRequest request){
String redsunServiceUrl = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_GET_DEF_BY_ID + id;
Object result = RestAPIHelper.get(redsunServiceUrl, new HashMap<String, Object>());
return result;
}
@RequestMapping(value = "", method = { RequestMethod.GET })
public String index(@RequestParam(value = "name", required = false, defaultValue = "World") String name,
Model model) {
model.addAttribute("name", name);
return "doc_directory_display";
}
@RequestMapping(value="/list", method = {RequestMethod.GET})
@ResponseBody
public Object getDirectory(Model model, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
String userName = userUtil.getLoginedUsername();
Map<String, Object> listDirectories = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DIRECTORY_GET_ALL + clientId + "/" + userName + "/";
return RestAPIHelper.get(getDataURL, listDirectories);
}
@RequestMapping(value="/listdefault", method = {RequestMethod.GET})
@ResponseBody
public Object getDefaultDirectory(Model model, HttpServletRequest request) throws Exception {
Map<String, Object> lisDefaultDirectories = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DIRECTORY_GET_DEFAULT;
return RestAPIHelper.get(getDataURL, lisDefaultDirectories);
}
@RequestMapping(value="/list/{userName}", method = {RequestMethod.GET})
@ResponseBody
public Object getDirectoryByUser(@PathVariable("userName") String userName, Model model, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
Map<String, Object> listDirectories = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DIRECTORY_GET_ALL + clientId + "/" + userName + "/";
return RestAPIHelper.get(getDataURL, listDirectories);
}
@RequestMapping(value="/list/resourceassigned", method = {RequestMethod.GET})
@ResponseBody
public Object getResourceAssigned(Model model, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
Map<String, Object> listDirectories = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DIRECTORY_GET_ALL + "resourceassigned/" + clientId;
return RestAPIHelper.get(getDataURL, listDirectories);
}
@RequestMapping(value="/list/fromtrash", method = {RequestMethod.GET})
@ResponseBody
public Object getDirectoryFromTrash(Model model, HttpServletRequest request) throws Exception {
int clientId = userUtil.getClientIdOfLoginedUser();
String userName = userUtil.getLoginedUsername();
Map<String, Object> listDirectories = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DIRECTORY_URL_SERVICE_LIST_FROM_TRASH + clientId + "/" + userName + "/";
return RestAPIHelper.get(getDataURL, listDirectories);
}
@RequestMapping(value="/doc/{directoryId}", method = {RequestMethod.GET})
@ResponseBody
public Object getDocument(@PathVariable("directoryId") Integer directoryId, HttpServletRequest request) throws Exception {
Map<String, Object> docs = new HashMap<String, Object>();
String getDataURL = getMainDomain(request) + RedSunURLs.DOCUMENT_GET_BY_FOLDER + directoryId;
return RestAPIHelper.get(getDataURL, docs);
}
@SuppressWarnings("rawtypes")
@RequestMapping(value = "/download/{id}/{fileName}/", method = RequestMethod.GET)
public ResponseEntity<InputStreamResource> download(@PathVariable final Integer id, @PathVariable final String fileName, HttpServletRequest request) throws IOException {
final ResponseEntity responseEntity = new RestTemplate().exchange(getMainDomain(request) + RedSunURLs.DOWNLOAD_DOCUMENT + id, HttpMethod.GET, null, Resource.class);
final Resource resource = (Resource)responseEntity.getBody();
final InputStream file = resource.getInputStream();
final Long contentLength = resource.contentLength();
final HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
headers.add("content-disposition", "inline;filename=\"" + fileName + "\"");
return ResponseEntity.ok().headers(headers).contentLength(contentLength).contentType(MediaType.parseMediaType("application/octet-stream")).body(new InputStreamResource(file));
}
}
| [
"caohongvu@gmail.com"
] | caohongvu@gmail.com |
4c72330000798191ab7a445d65e6612ba0b86a43 | 7e914febe2b6aaa9830c49deaadb70b791cd9f80 | /src/main/BMI.java | 24b3cbe1b319c007b4f00565768bfad144b9e44e | [
"MIT"
] | permissive | predodamiao/Java-Unit-Testing | 6f8cfcd0d09a2c2d4abc83e7e0c37d6c954ee015 | c998886733d92a6cc7488fbd8e459c20b8d3a9cc | refs/heads/main | 2023-03-28T10:42:16.925694 | 2021-03-27T20:18:12 | 2021-03-27T20:18:12 | 352,166,846 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,129 | java | package main;
public class BMI {
private double height;
private double weight;
private Gender gender;
public BMI(double height, double weight, Gender gender){
this.setHeight(height);
this.setWeight(weight);
this.setGender(gender);
}
public BMI(){
}
public Double getHeight() {
return height;
}
public void setHeight(Double height) {
this.height = height;
}
public Double getWeight() {
return weight;
}
public void setWeight(Double weight) {
this.weight = weight;
}
public Gender getGender() {
return gender;
}
public void setGender(Gender gender) {
this.gender = gender;
}
public Double calculateBMI(){
return (this.weight / (this.height * this.height));
}
public String getBMIClassification(){
Double bmi = this.calculateBMI();
if(Gender.FEMALE.equals(this.gender)){ //1
if(bmi < 19.1) //2
return "Under weight"; //3
else if(bmi < 25.8) //4
return "Normal weight"; //5
else if(bmi < 27.3) //6
return "Marginally overweight"; //7
else if(bmi < 32.3) //8
return "Overweight"; //9
else
return "Obese"; //10
}else {
if(bmi < 20.7) //11
return "Under weight"; //12
else if(bmi < 26.4) //13
return "Normal weight"; //14
else if(bmi < 27.8) //15
return "Marginally overweight"; //16
else if(bmi < 31.1) //17
return "Overweight"; //18
else
return "Obese"; //19
} //20
}
}
| [
"pedrohfcd@hotmail.com"
] | pedrohfcd@hotmail.com |
4a714ab3cad928d22586cb27d4f4f968a5bfd9e2 | 5b5ba0d3ceaab05dbeeb16aa4d0a785214441019 | /model/src/main/java/com/wat/model/HealthService.java | 6783439d87e759faaa9070b217dc420447441705 | [] | no_license | Lucas4088/zpm | b75bb3c65dc8afa595935bf9a895f8af3afd9335 | 6b48868d6a39703773df0fed89f86a8bda2fe712 | refs/heads/master | 2020-04-19T12:56:35.955362 | 2019-01-29T18:24:38 | 2019-01-29T18:24:38 | 168,204,995 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 213 | java | package com.wat.model;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class HealthService {
private String name;
}
| [
"salamonikp@wp.pl"
] | salamonikp@wp.pl |
ac9221d9157d3b3fd1a429048ca6ad77d8d734c0 | 83df6991f3e20392e3f19256cd8dd8b4ce188916 | /src/com/jorgoandres/picoplacatest/CarTest.java | 0ccadd24f25745893382bea39db37983a7610fef | [
"Apache-2.0"
] | permissive | jorgeoandres/PicoPlaca | 28c0164ce763cbca68310a9c8c6d4b2dcf42461a | ddf61811e1d4dc39fd9d28efafb0873aaf6f4ffd | refs/heads/master | 2021-01-20T02:33:06.323461 | 2017-08-24T20:03:58 | 2017-08-24T20:03:58 | 101,326,528 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,017 | java | package com.jorgoandres.picoplacatest;
import com.jorgeoandres.picoplaca.Car;
import org.junit.*;
import java.util.InputMismatchException;
import static junit.framework.TestCase.assertEquals;
public class CarTest {
@Test (expected = InputMismatchException.class)
public void setLicencePlateNumberWithANotValidLicencePlateNumberShouldThrowException() throws InputMismatchException{
Car tester = new Car();
tester.setLicencePlateNumber("AAA12122");
}
@Test
public void getLastDigitOfLicencePlateNumberShouldReturnZero() throws Exception {
Car tester = new Car("AAA1210");
assertEquals("AAA1210 licence plate number last digit is 0", 0, tester.getLastDigitOfLicencePlateNumber());
tester.setLicencePlateNumber("AAA120");
assertEquals("AAA120 licence plate number last digit is 0", 0, tester.getLastDigitOfLicencePlateNumber());
}
@Test
public void validateAValidLicencePlateNumberShouldReturnTrue() throws Exception {
Car tester = new Car("AAA1210");
assertEquals("AAA1210 licence plate number is valid", true, tester.validateLicencePlateNumber(tester.getLicencePlateNumber()));
tester.setLicencePlateNumber("AAA120");
assertEquals("AAA120 licence plate number last digit is valid", true, tester.validateLicencePlateNumber(tester.getLicencePlateNumber()));
tester.setLicencePlateNumber("aaa1210");
assertEquals("aaa1210 licence plate number is valid", true, tester.validateLicencePlateNumber(tester.getLicencePlateNumber()));
tester.setLicencePlateNumber("aaa120");
assertEquals("aaa120 licence plate number last digit is valid", true, tester.validateLicencePlateNumber(tester.getLicencePlateNumber()));
}
@Test
public void validateAnInvalidLicencePlateNumberShouldReturnFalse() throws Exception {
Car tester = new Car();
assertEquals("AAAA1210 licence plate number is invalid", false, tester.validateLicencePlateNumber("AAAA1210"));
assertEquals("AAA120123 licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("AAA120123"));
assertEquals("AA113 licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("AA113"));
assertEquals("A1 licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("A1"));
assertEquals("AA11A licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("AA11A"));
assertEquals(" licence plate number last digit is invalid", false, tester.validateLicencePlateNumber(""));
assertEquals("a-a licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("a-a"));
assertEquals("aaaa1210 licence plate number is invalid", false, tester.validateLicencePlateNumber("aaaa1210"));
assertEquals("aaa120123 licence plate number last digit is invalid", false, tester.validateLicencePlateNumber("aaa120123"));
}
} | [
"jorgeorozcosanchez@hotmail.com"
] | jorgeorozcosanchez@hotmail.com |
6175a6740020e71bb9b4ecd56b5cb85da5fa63a2 | 8369a35178e281d7444929c15195b3e89137d5b9 | /Block Game/src/com/idkstudios/game/rendering/particles/Smoke.java | 337f11702e765a6ef23ae20a32f219c49e21d186 | [] | no_license | TobyDrane/Java-3D-Voxel-Game | 10c4ae56d4cfec3fb7070acc3ef3b587450f2cce | b9012595cb53c0e4f8795176a0ed374ef3985312 | refs/heads/master | 2021-04-03T05:23:48.594800 | 2018-03-08T13:10:29 | 2018-03-08T13:10:29 | 124,393,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,638 | java | package com.idkstudios.game.rendering.particles;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import org.newdawn.slick.opengl.Texture;
import com.idkstudios.game.GameObject;
import com.idkstudios.game.game.Game;
import com.idkstudios.game.game.TextureStorage;
import com.idkstudios.game.math.MathHelper;
import com.idkstudios.game.math.Vec3f;
public class Smoke extends GameObject {
private static final int CALL_LIST_BASE;
private static final int PARTICLE_COUNT;
private static final Vec3f UP_VECTOR;
private static final Texture PARTICLES_TEXTURE;
static {
UP_VECTOR = new Vec3f(0.0f, 2.0f, 0.0f);
PARTICLE_COUNT = 8;
float PARTICLE_SIZE = 0.1f;
PARTICLES_TEXTURE = TextureStorage.getTexture("particles");
CALL_LIST_BASE = GL11.glGenLists(PARTICLE_COUNT);
float tileSize = 16.0f / PARTICLES_TEXTURE.getImageWidth();
for (int i = 0; i < PARTICLE_COUNT; ++i) {
GL11.glNewList(CALL_LIST_BASE + i, GL11.GL_COMPILE);
GL11.glBegin(GL11.GL_QUADS);
GL11.glTexCoord2f(i * tileSize, 0.0f);
GL11.glVertex2f(-PARTICLE_SIZE, PARTICLE_SIZE);
GL11.glTexCoord2f((i + 1) * tileSize, 0.0f);
GL11.glVertex2f(PARTICLE_SIZE, PARTICLE_SIZE);
GL11.glTexCoord2f((i + 1) * tileSize, tileSize);
GL11.glVertex2f(PARTICLE_SIZE, -PARTICLE_SIZE);
GL11.glTexCoord2f(i * tileSize, tileSize);
GL11.glVertex2f(-PARTICLE_SIZE, -PARTICLE_SIZE);
GL11.glEnd();
GL11.glEndList();
}
}
private List<Particle> particles;
private Vec3f origin;
private Vec3f vector;
private Vec3f playerPosition;
private static class Particle {
public Vec3f position;
public float size;
public float speed;
public float rotation;
public float rotationSpeed;
public int texture;
public Particle(float x, float y, float z, float size) {
position = new Vec3f(x, y, z);
this.size = size;
}
}
public Smoke(float x, float y, float z) {
particles = new ArrayList<Particle>();
origin = new Vec3f(x, y, z);
vector = new Vec3f();
}
public void addParticle() {
float size = (float) (Math.random() * 0.2d + 0.2d);
Particle p = new Particle(origin.x(), origin.y(), origin.z(), size);
p.rotationSpeed = (float) (Math.random() * 40.0d - 20.0d);
p.texture = PARTICLE_COUNT - 1;
particles.add(p);
}
@Override
public void update() {
float step = Game.getInstance().getStep();
for (int i = 0; i < particles.size(); ++i) {
Particle p = particles.get(i);
p.position.addFactor(UP_VECTOR, p.speed * step);
p.speed += step * 0.8f;
p.rotation += p.rotationSpeed * step;
p.size -= step * 0.4f;
p.texture = MathHelper.clamp((int) (p.size * 20.0f), 0,
PARTICLE_COUNT - 1);
if (p.size <= 0.0f) {
/* Remove this particle */
particles.remove(i--);
}
}
}
@Override
public void render() {
if (playerPosition == null) {
playerPosition = Game.getInstance().getWorld().getActivePlayer()
.getPosition();
}
PARTICLES_TEXTURE.bind();
/* Compute the angle of rotation around the Y axis to the player */
vector.set(origin);
vector.sub(playerPosition);
float angle = MathHelper.atan2(vector.z(), vector.x())
- (MathHelper.f_PI * 0.5f);
for (int i = 0; i < particles.size(); ++i) {
Particle p = particles.get(i);
/* Prepare the model matrix */
GL11.glPushMatrix();
GL11.glTranslatef(p.position.x(), p.position.y(), p.position.z());
GL11.glRotatef(p.rotation, 0, 0, 1);
GL11.glRotatef(-MathHelper.toDegrees(angle), 0, 1, 0);
/* Draw all the particles */
GL11.glCallList(CALL_LIST_BASE + p.texture);
/* Restore the original matrix */
GL11.glPopMatrix();
}
}
}
| [
"tobydrane@gmail.com"
] | tobydrane@gmail.com |
81670c20d2c47ac068057811d0e69db3a1df2806 | cde4358da2cbef4d8ca7caeb4b90939ca3f1f1ef | /java/quantserver/snmpagent/src/main/java/deltix/snmp/smi/SMIRowImpl.java | 83fe0ade82cda222f4ff14b3314a724d3d84d898 | [
"Apache-2.0"
] | permissive | ptuyo/TimeBase | e17a33e0bfedcbbafd3618189e4de45416ec7259 | 812e178b814a604740da3c15cc64e42c57d69036 | refs/heads/master | 2022-12-18T19:41:46.084759 | 2020-09-29T11:03:50 | 2020-09-29T11:03:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,062 | java | package deltix.snmp.smi;
/**
*
*/
public class SMIRowImpl
extends SMIPrimitiveContainerImpl <SMITableImpl>
implements SMIRow
{
private final SMIIndexInfo indexInfo;
/**
* Row with primary index
*/
public SMIRowImpl(
SMITableImpl parent,
SMIOID oid,
String name,
String description,
int numIndexedChildren,
boolean lastIndexImplicit
)
{
super (parent, oid, name, description);
if (numIndexedChildren < 1)
throw new IllegalArgumentException ("No indexes defined");
indexInfo = new SMIPrimaryIndexImpl (numIndexedChildren, lastIndexImplicit);
}
/**
* Augmenting row
*/
SMIRowImpl (
SMITableImpl parent,
SMIOID oid,
String name,
String description,
SMIRow augmentsRow
)
{
super (parent, oid, name, description);
indexInfo = new SMIAugmentedIndexImpl (augmentsRow);
}
@Override
public SMIIndexInfo getIndexInfo () {
return (indexInfo);
}
@Override
public SMIPrimitive addObjectType (
int id,
String name,
SMIType type,
SMIAccess access,
String description,
int indexDepth
)
{
checkChild (id, name);
SMIPrimitiveNodeImpl node =
new SMIPrimitiveNodeImpl (
this,
new SMIOID (getOid (), id),
name,
type,
access,
description
);
registerChild (node);
if (indexDepth >= 0) {
if (!(indexInfo instanceof SMIPrimaryIndexImpl))
throw new IllegalArgumentException (
this + " was not constructed with the primary index flags"
);
SMIPrimaryIndexImpl pi = (SMIPrimaryIndexImpl) indexInfo;
SMIPrimitive [] indexes = pi.indexedChildren;
if (indexDepth >= indexes.length)
throw new IllegalArgumentException (
"Index depth " + indexDepth + " > max " + indexes.length
);
if (indexes [indexDepth] != null)
throw new IllegalArgumentException(
String.format("Index at depth %d is already set: %s [%s] clashes with %s [%s]", indexDepth,
indexes[indexDepth], indexes[indexDepth].getDescription(),
node, node.getDescription())
);
indexes [indexDepth] = node;
}
return (node);
}
}
| [
"akarpovich@deltixlab.com"
] | akarpovich@deltixlab.com |
c7070c8b42110180a615c79789f16280e3cbe300 | b047dfacae18397d75400c3ed29dfc1aa5d5c039 | /src/main/java/com/mar/algotools/markov/MarkovChainSparse.java | a535a2ac8695d5bc08bff6770d8abc42475474cb | [] | no_license | mrenauld/com-mar-algotools | c39fd0fac8c61e21c1cced1fe3b2ae9ba4bd47fb | da98464a8c15f41b27da01cb75503316a46f4aeb | refs/heads/master | 2021-01-15T22:39:22.659727 | 2018-03-05T12:37:17 | 2018-03-05T12:37:17 | 99,906,221 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,184 | java | package com.mar.algotools.markov;
import java.util.ArrayList;
import com.mar.algotools.matrix.SparseMatrix;
public class MarkovChainSparse implements IMarkovChain {
private int nbNodes;
private SparseMatrix chainData;
private ArrayList<String> nodeNames;
public MarkovChainSparse(int pNbNodes) {
nbNodes = pNbNodes;
chainData = new SparseMatrix(nbNodes, nbNodes);
nodeNames = new ArrayList<String>();
for (int i = 0; i < nodeNames.size(); ++i) {
nodeNames.add("");
}
}
@Override
public int getNbNodes() {
return nbNodes;
}
@Override
public int getNextIndexWithProba(int pNodeIdx) {
float[] proba = chainData.getValueData()[pNodeIdx];
int[] column = chainData.getColumnData()[pNodeIdx];
int nextIdx = -1;
if (proba.length > 0) {
float rand = (float) Math.random();
float sum = 0.0f;
for (int i = 0; i < proba.length; ++i) {
if (sum > rand) {
nextIdx = column[i - 1];
break;
}
sum += proba[i];
}
if (nextIdx == -1) {
nextIdx = column[column.length - 1];
}
}
return nextIdx;
}
@Override
public String getNodeName(int pNodeIdx) {
return nodeNames.get(pNodeIdx);
}
@Override
public float getTransitionProba(int pNodeIdx1, int pNodeIdx2) {
return chainData.get(pNodeIdx1, pNodeIdx2);
}
@Override
public void normalizeProba() {
float[][] valueData = chainData.getValueData();
for (int i = 0; i < valueData.length; ++i) {
float sum = 0.0f;
for (int j = 0; j < valueData[i].length; ++j) {
sum += valueData[i][j];
}
for (int j = 0; j < valueData[i].length; ++j) {
valueData[i][j] /= sum;
}
}
}
@Override
public void setNbNodes(int pNbNodes) {
nbNodes = pNbNodes;
chainData = new SparseMatrix(nbNodes, nbNodes);
}
@Override
public void setNodeName(int pNodeIdx, String pNodeName) {
nodeNames.set(pNodeIdx, pNodeName);
}
@Override
public void setNodeNameList(ArrayList<String> pNodeNameList) {
nodeNames = pNodeNameList;
}
@Override
public void setTransitionProba(int pNodeIdx1, int pNodeIdx2, float pProba) {
chainData.set(pNodeIdx1, pNodeIdx2, pProba);
}
@Override
public String toString() {
int[][] columnData = chainData.getColumnData();
float[][] valueData = chainData.getValueData();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < columnData.length; ++i) {
if (columnData[i].length > 0) {
sb.append(nodeNames.get(i) + " -> ");
for (int j = 0; j < columnData[i].length; ++j) {
sb.append("[" + nodeNames.get(columnData[i][j]) + " " + valueData[i][j] + "]");
}
sb.append("\n");
}
}
return sb.toString();
}
}
| [
"mrenauld@gmail.com"
] | mrenauld@gmail.com |
fd3ea6fb83618d6a201b7cba32b1d8bedb806aee | 740224f1a49b275aca308bd55620481441c73e28 | /app/src/main/java/com/tugba/cevizci/spacex/network/SpaceXApi.java | ffcedc69fb188b7e0ce8ddbaa9fa78dec930ab4c | [] | no_license | tugbaa/SpaceX | 84daf1ffb532d08578d141d8f7a949c21bb010ba | b2edb0012759eb818b18dd2877d024cc36ea219b | refs/heads/master | 2020-03-30T16:19:02.040278 | 2018-10-04T08:19:22 | 2018-10-04T08:19:22 | 151,403,390 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 257 | java | package com.tugba.cevizci.spacex.network;
import com.tugba.cevizci.spacex.data.Launch;
import java.util.List;
import retrofit2.Call;
import retrofit2.http.GET;
public interface SpaceXApi {
@GET("launches/")
Call<List<Launch>> getLaunches();
}
| [
"tugbacevizci.840@gmail.com"
] | tugbacevizci.840@gmail.com |
9546b9ba53bcbfb118ee283e20c936da916621e2 | 13a41dc7bcec73978ea4b714557e86790bc3ed26 | /src/test/java/com/yorosoft/enoticeboard/controller/NoticeControllerTest.java | bd5c8dbb9f412b9c01e6eb03a1f5057b4d152efb | [
"MIT"
] | permissive | codeur47/e-notice-board | e49ac50efcf27851ade5f38d74c05f8f1dd502a4 | 7fe15f2882792495305937adb7984090f4c8cba3 | refs/heads/main | 2023-07-08T01:04:04.166581 | 2021-09-04T17:22:57 | 2021-09-04T17:22:57 | 402,155,126 | 0 | 0 | null | 2021-09-02T00:46:17 | 2021-09-01T17:56:43 | Java | UTF-8 | Java | false | false | 6,568 | java | package com.yorosoft.enoticeboard.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yorosoft.enoticeboard.dto.NoticeDTO;
import com.yorosoft.enoticeboard.service.NoticeService;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.http.MediaType;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.web.servlet.MockMvc;
import java.util.Optional;
import static com.yorosoft.enoticeboard.util.TestDataFactory.*;
import static org.hamcrest.Matchers.hasSize;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
@ExtendWith(SpringExtension.class)
@WebMvcTest(NoticeController.class)
@DisplayName("Unit tests of NoticeController")
class NoticeControllerTest {
@Autowired
private MockMvc mockMvc;
@MockBean
private NoticeService noticeService;
@Test
@DisplayName("GET a list with single Notice")
void givenSingleNotice_whenGETNotices_thenGetSingleNoticeList() throws Exception {
//given
when(noticeService.findAll())
.thenReturn(getNoticeListDTO(1L));
mockMvc.perform(
get("/notices/")
)
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$", hasSize(1)))
.andExpect(jsonPath("[0].title").value("Notice 1"))
.andExpect(jsonPath("[0].description").value("Notice description 1"));
}
@Test
@DisplayName("GET a Notice by Id")
void givenNoticeId_whenGETNoticesById_thenGetSingleNotice() throws Exception {
//given
when(noticeService.findById(1L))
.thenReturn(Optional.of(getSingleNoticeDTO(1L)));
//when & then
mockMvc.perform(
get("/notices/1")
)
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON))
.andExpect(jsonPath("$.title").value("Notice 1"))
.andExpect(jsonPath("$.description").value("Notice description 1"));
}
@Test
@DisplayName("GET a Notice by Id and return 404 Not Found")
void givenIncorrectNoticeId_whenGETNoticesById_thenGetNotFoundNotice() throws Exception {
//given
when(noticeService.findById(1L))
.thenReturn(Optional.empty());
//when & then
mockMvc.perform(
get("/notices/1")
)
.andDo(print())
.andExpect(status().isNotFound());
}
@Test
@DisplayName("POST a Notice to create it")
void givenNotice_whenPOSTSave_thenGetSavedNotice() throws Exception {
//given
NoticeDTO noticeDTO = getSingleNoticeDTO(1L);
noticeDTO.setId(null);
//when
mockMvc.perform(
post("/notices/")
.contentType(MediaType.APPLICATION_JSON)
.content(asJsonString(noticeDTO))
.characterEncoding("utf-8")
)
.andDo(print())
.andExpect(status().isCreated());
}
@Test
@DisplayName("DELETE a Notice by Id")
void givenNoticeId_whenDELETENotice_thenNoticeIsDeleted() throws Exception {
//given
long noticeId = 1L;
when(noticeService.findById(1L))
.thenReturn(Optional.of(getSingleNoticeDTO(1L)));
//when
mockMvc.perform(
delete("/notices/" + noticeId)
)
.andDo(print())
.andExpect(status().isNoContent());
}
@Test
@DisplayName("DELETE a Notice by Id and return 404 HTTP Not Found")
void givenNoticeId_whenDELETENotice_thenNoticeNotFound() throws Exception {
//given
long noticeId = 1L;
when(noticeService.findById(1L))
.thenReturn(Optional.empty());
//when
mockMvc.perform(
delete("/notices/" + noticeId)
)
.andDo(print())
.andExpect(status().isNotFound());
}
@Test
@DisplayName("PUT a Notice by Id to update it")
void givenIdAndUpdatedNotice_whenPUTUpdate_thenNoticeIsUpdated() throws Exception {
//given
long noticeId = 1L;
NoticeDTO noticeDTO = getSingleNoticeDTO(1L);
when(noticeService.findById(1L))
.thenReturn(Optional.of(noticeDTO));
NoticeDTO updatedNotice = noticeDTO;
updatedNotice.setTitle("New Title");
updatedNotice.setDescription("New Description");
//when
mockMvc.perform(
put("/notices/" + noticeId)
.contentType(MediaType.APPLICATION_JSON)
.content(asJsonString(noticeDTO))
.characterEncoding("utf-8")
)
.andDo(print())
.andExpect(status().isOk())
.andExpect(content().string("Object with id 1 was updated."));
}
@Test
@DisplayName("PUT a Notice by Id to update it and return 404 HTTP Not Found")
void givenIdAndUpdatedNotice_whenPUTUpdate_thenNoticeNotFound() throws Exception {
//given
long noticeId = 1L;
NoticeDTO noticeDTO = getSingleNoticeDTO(1L);
when(noticeService.findById(1L))
.thenReturn(Optional.empty());
//when
mockMvc.perform(
put("/notices/" + noticeId)
.contentType(MediaType.APPLICATION_JSON)
.content(asJsonString(noticeDTO))
.characterEncoding("utf-8")
)
.andDo(print())
.andExpect(status().isNotFound());
}
private String asJsonString(Object object){
try {
return new ObjectMapper().writeValueAsString(object);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
| [
"yoropapers@gmail.com"
] | yoropapers@gmail.com |
f3e6c4ef939058e77e293d597ba11b43e21fc23c | ce3014bb6eed65d35480135d2306ba6114d93abd | /src/main/java/com/yanan/plugin/spring/SpringBeansResource.java | 3496aaa003245e6d4e26a7c561858c3a6a973d40 | [
"Apache-2.0"
] | permissive | tja414312570/plugin.spring | d1c356a58bb7a05976bb1dfd043a980124fe4761 | 931f03c4ecc5de224d22497685a427b627f727e1 | refs/heads/main | 2023-08-26T08:25:19.244494 | 2021-10-12T09:48:54 | 2021-10-12T09:48:54 | 353,289,698 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 221 | java | package com.yanan.plugin.spring;
import com.yanan.framework.plugin.decoder.StandScanResource;
public class SpringBeansResource extends StandScanResource{
public SpringBeansResource(String path) {
super(path);
}
}
| [
"414312570@qq.com"
] | 414312570@qq.com |
b63fc97c638c3c897ec6324e362e453b07c8db78 | 7874efca5c893507654a4c6f488baaa65a8569e8 | /src/b/xwriter.java | bb926d94255462690c4b2f29a975e532298f25ec | [] | no_license | calint/b-blobs | 54c6be24ed9a659fcb71d0fc9cc27a0becb77432 | 720a09715165dc6c82b6b0e50582c600ce93486d | refs/heads/master | 2021-01-10T12:59:55.729141 | 2016-03-01T22:25:58 | 2016-03-01T22:25:58 | 43,054,406 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,473 | java | package b;
import static b.b.isempty;
import static b.b.tobytes;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
public final class xwriter{
public xwriter(final OutputStream os){this.os=os;}
public xwriter(){os=new ByteArrayOutputStream();}
public OutputStream outputstream(){return os;}
public xwriter p(final String s){if(s==null)return this;try{os.write(tobytes(s));}catch(final IOException e){throw new Error(e);}return this;}
public xwriter nl(){return p('\n');}
public xwriter nl(final int number_of_newlines){for(int i=0;i<number_of_newlines;i++)p('\n');return this;}
public xwriter p(final byte n){return p(Byte.toString(n));}
public xwriter p(final char n){return p(Character.toString(n));}
public xwriter p(final int n){return p(Integer.toString(n));}
public xwriter p(final float n){return p(Float.toString(n));}
public xwriter p(final long n){return p(Long.toString(n));}
public xwriter p(final double n){return p(Double.toString(n));}
public xwriter pl(final String s){return p(s).nl();}
public xwriter pl(){return nl();}
public xwriter tag(final String name){return p("<").p(name).p(">");}
public xwriter tag(final String name,final String id){return p("<").p(name).p(" id=").p(id).p(">");}
public xwriter tago(final String name){return p("<").p(name);}
public xwriter attrdef(final a e){final String id=e.id();return attr("id",id);}
public xwriter attr(final String name,final int value){return p(" ").p(name).p("=").p(value);}
public xwriter attr(final String name,final String value){return p(" ").p(name).p("=\"").p(encquot(value)).p("\"");}
public xwriter attr(final String name){return p(" ").p(name);}
public xwriter tagoe(){return p(">");}
public xwriter tage(final String name){return p("</").p(name).p(">");}
public xwriter a(final String href){return tago("a").attr("href",href).tagoe();}
public xwriter a_(){return tage("a");}
public xwriter a(final String href,final String txt){return a(href).p(txt).a_();}
public xwriter ax(final a e,final String func){return ax(e,func,func);}
public xwriter ax(final a e,final String func,final String html){
final String wid=e.id();
p("<a href=\"javascript:").axjs(wid,func,"").p("\">").p(html).p("</a>");
return this;
}
public xwriter ax(final a e,final String func,final String param,final String html){
final String wid=e.id();
p("<a href=\"javascript:").axjs(wid,func,param).p("\">").p(html).p("</a>");
return this;
}
public xwriter ax(final a e,final String func,final String param,final String html,final String accesskey){
final String wid=e.id();
p("<a");
if(accesskey!=null)spc().p("accesskey=").p(accesskey).attr("title",accesskey);
p(" href=\"javascript:").axjs(wid,func,param).p("\">").p(html).p("</a>");
return this;
}
public xwriter axjs(final String eid,final String func,final String param){
p("$x('").p(eid);
if(!isempty(func))p(" ").p(func);
if(!isempty(param))p(" ").p(param);
return p("')");
}
public xwriter ajx(final a e,final String args){return tago("a").attr("href","javascript:$x('"+e.id()+" "+args+"')").attr("id",e.id()).tagoe();}
public xwriter ajx(final a e){return tago("a").attr("href","javascript:$x('"+e.id()+"')").tagoe();}
public xwriter ajx_(){return tage("a");}
public xwriter br(){return tag("br");}
// public xwriter divo(final String cls){return tago("div").attr("class",cls).tagoe();}
public xwriter divo(){return tag("div");}
public xwriter divo(final a e){return tago("div").attr("id",e.id()).tagoe();}
public xwriter divo(final a e,final String cls){return divo(e,cls,"");}
public xwriter divo(final String cls,final String style){return divo(null,cls,style);}
public xwriter divo(final String cls){return divo(null,cls,null);}
public xwriter divo(final a e,final String cls,final String style){
tago("div");
if(e!=null)attr("id",e.id());
if(!isempty(cls))attr("class",cls);
if(!isempty(style))attr("style",style);
// if(!isempty(intaginline))spc().p(intaginline);
return tagoe();
}
public xwriter divh(final a e){return divh(e,null,null);}
public xwriter divh(final a e,final String cls){return divh(e,cls,null);}
public xwriter divh(final a e,final String cls,final String style){
tago("div");
if(e!=null)attr("id",e.id());
if(!isempty(cls))attr("class",cls);
if(!isempty(style))attr("style",style);
// if(!isempty(intaginline))spc().p(intaginline);
tagoe();
try{e.to(this);}catch(Throwable t){throw new Error(t);}//? printerror
return div_();
}
// public xwriter ph_div(final a e){return tago("div").attr("id",e.id()).tagoe().tage("div");}
public xwriter div_(){return tage("div");}
public xwriter focus(final a e){return script().p("$f('").p(e.id()).p("')").script_();}
public xwriter inpint(final a e){return tago("input").attr("value",e.toString()).attrdef(e).attr("type","text").attr("class","nbr").attr("size",5).attr("onchange","$b(this)").tagoe();}
public xwriter inpflt(final a e){return tago("input").attr("value",e.toString()).attrdef(e).attr("type","text").attr("class","nbr").attr("size",5).attr("onchange","$b(this)").tagoe();}
public xwriter inplng(final a e){return inpint(e);}
public xwriter pre(){return tag("pre");}
public xwriter pre(final String cls){return tago("pre").attr("class",cls).tagoe();}
public xwriter pre_(){return tage("pre");}
public xwriter script(){return tag("script");}
public xwriter script_(){return tage("script");}
public xwriter spanx(final a e){return spanx(e,null);}
public xwriter spanx(final a e,final String style){
tago("span").attr("id",e.id());
if(style!=null)attr("style",style);
return tagoe().tage("span");
}
public xwriter span(final a e){return span(e,null);}
public xwriter span(final a e,final String style){
tago("span").attr("id",e.id());
if(style!=null)attr("style",style);
tagoe();
try{e.to(new osltgt(os));}catch(Throwable t){throw new Error(t);}
return span_();
}
public xwriter spanh(final a e){return spanh(e,null,null);}
public xwriter spanh(final a e,final String cls){return spanh(e,cls,null);}
public xwriter spanh(final a e,final String cls,final String style){
tago("span").attr("id",e.id());
if(cls!=null)attr("class",cls);
if(style!=null)attr("style",style);
tagoe();
try{e.to(os);}catch(Throwable t){throw new Error(t);}
return span_();
}
public xwriter span_(){return tage("span");}
public xwriter table(){return tag("table");}
public xwriter table(final String cls){return tago("table").attr("class",cls).tagoe();}
public xwriter table(final String cls,final String style){
tago("table");
if(!isempty(cls))attr("class",cls);
if(!isempty(style))attr("style",style);
tagoe();
return this;
}
public xwriter table_(){return tage("table");}
public xwriter style(){return p("<style scoped>");}
public xwriter style_(){return tage("style");}
public xwriter td(){return tag("td");}
public xwriter td(final String cls){return td(cls,"");}
public xwriter td(final String cls,final String style){
tago("td");
if(cls!=null&&cls.length()!=0)
attr("class",cls);
if(style!=null&&style.length()!=0)
attr("style",style);
return tagoe();
}
public xwriter td_(){return tage("td");}
public xwriter th(){return tag("th");}
public xwriter th(final int colspan){return tago("th").attr("colspan",colspan).tagoe();}
public xwriter th(final String cls){return tago("th").attr("class",cls).tagoe();}
public xwriter th_(){return tage("th");}
public xwriter tr(){return tag("tr");}
public xwriter tr(final String cls){return tago("tr").attr("class",cls).tagoe();}
public xwriter tr_(){return tage("tr");}
public xwriter ul(){return tag("ul");}
public xwriter ul_(){return tage("ul");}
public xwriter li(){return tag("li");}
public xwriter li(final String cls){if(cls==null)return li();return tago("li").attr("class",cls).tagoe();}
public xwriter code(){return tag("code");}
public xwriter code_(){return tage("code");}
// public xwriter rend(final a e)throws Throwable{if(e==null)return this;e.to(this);return this;}
public xwriter inptxt(final a e){return inp(e,"text",null,null,null,null,null,null,null);}
public xwriter inptxt(final a e,final a axonreturn){return inp(e,"text",null,null,axonreturn,null,null,null,null);}
public xwriter inptxt(final a e,final a axonreturn,final String axp){return inp(e,"text",null,null,axonreturn,axp,null,null,null);}
public xwriter inptxt(final a e,final a axonreturn,final String axp,final String stylecls){return inp(e,"text",null,stylecls,axonreturn,axp,null,null,null);}
public xwriter inptxt(final a e,final a axonreturn,final String axp,final String txt,final String stylecls){return inp(e,"text",null,stylecls,axonreturn,axp,txt,null,null);}
public xwriter inpcolr(final a e){return inp(e,"color",null,null,null,null,null,null,null);}
public xwriter inp(final a e,final String type,final String style,final String stylecls,final a on_enter_ajax_elem,final String on_enter_ajax_param,final String txt,final a on_change_ajax_elem,final String on_change_ajax_param){
final String value=txt==null?e.toString():txt;
tago("input").attr("value",value).attrdef(e);
if(!isempty(type))attr("type",type);
if(!isempty(stylecls))attr("class",stylecls);
if(!isempty(style))attr("style",style);
if(on_enter_ajax_elem!=null){
final String ax=on_enter_ajax_elem.id()+(on_enter_ajax_param!=null?(" "+on_enter_ajax_param):"");
attr("onkeypress","return $r(event,this,'"+ax+"')");
}
final StringBuilder sb=new StringBuilder();
if("checkbox".equals(type)){
if(value.equals(Boolean.TRUE.toString()))attr("checked","checked");
sb.append("this.value=this.checked?'1':'0';$b(this)");
if(on_change_ajax_elem!=null){
final String ax=on_enter_ajax_elem.id()+(on_enter_ajax_param!=null?(" "+on_change_ajax_param):"");
sb.append(";$x('"+ax+"')");
}
}else{
sb.append("$b(this)");
if(on_change_ajax_elem!=null){
final String ax=on_enter_ajax_elem.id()+(on_enter_ajax_param!=null?(" "+on_change_ajax_param):"");
sb.append(";$x('"+ax+"')");
}
}
attr("onchange",sb.toString());
return tagoe();//? <input hidden value="false">
}
public xwriter inptxtarea(final a e){return inptxtarea(e,null);}
public xwriter inptxtarea(final a e,final String cls){
tago("textarea").attrdef(e)
.attr("onchange","$b(this)")
// .attr("onkeydown","$b(this);if(event.keyCode==9){console.log(this.id+' '+this.selectionStart);this.value=this.value.substring(0,this.selectionStart)+' '+this.value.substring(this.selectionStart,this.value.length);console.log(this.selectionStart);this.selectionStart=this.selectionEnd=this.selectionStart-2;return false;}return true;")
.attr("onkeydown","$b(this)")
;
if(cls!=null)attr("class",cls);
attr("wrap","off").attr("spellcheck","false").tagoe();
try{e.to(new osltgt(outputstream()));}catch(final Throwable t){b.log(t);p(b.stacktrace(t));}
return tage("textarea");
}
public xwriter flush(){try{os.flush();return this;}catch(final IOException e){throw new Error(e);}}
public String toString(){return os.toString();}
public xwriter hr(){return tag("hr");}
public xwriter spc(){return p(' ');}
public xwriter tab(){return p('\t');}
public xwriter enter(){return p('\r');}
public xwriter bell(){return p('\07');}
public xwriter p(final CharSequence cs){return p(cs.toString());}
public xwriter title(final String s){return tag("title").p(s).tage("title");}
public xwriter css(final String selector,final String stl){return p(selector).p("{").p(stl).p("}");}
public xwriter css(final a e,final String style){return p("#").p(e.id()).p("{").p(style).p("}");}
public xwriter inpax(final a e,final String stylecls,final a ax,final String axp){
tago("input").attr("value",e.toString()).attrdef(e).attr("type","text");
if(!isempty(stylecls))attr("class",stylecls);
attr("onfocus","this.setSelectionRange(this.value.length,this.value.length)");
final StringBuilder sb=new StringBuilder();
sb.append((ax==null?e:ax).id());
if(!isempty(axp))sb.append(" ").append(axp);
final String sbs=sb.toString();
attr("oninput","$b(this);$x('"+sbs+"');return true;");
attr("onkeypress","return $r(event,this,'"+ax.id()+" sel')");
return tagoe();
}
public xwriter inpax(final a e,final String stylecls,final a ax,final String onchangeaxp,final String onselectaxp){
tago("input").attr("value",e.toString()).attrdef(e).attr("type","text");
if(!isempty(stylecls))attr("class",stylecls);
final String eid=ax.id();
attr("onfocus","this.setSelectionRange(this.value.length,this.value.length)");
attr("oninput","$b(this);$x('"+eid+" "+onchangeaxp+"');return true;");
if(onselectaxp!=null)attr("onkeypress","if(!event)event=window.event;if(event.keyCode!=13)return true;$x('"+eid+" "+onselectaxp+"');return false;");
return tagoe();
}
public xwriter inputax(final a e){return inpax(e,null,e.pt(),null);}
public xwriter output_holder(final a e){return tago("output").attr("id",e.id()).tagoe().tage("output");}//? value
public xwriter spc(final int n){for(int i=0;i<n;i++)spc();return this;}
public xwriter ul(final String cls){return tago("ul").attr("class",cls).tagoe();}
public xwriter cssfont(final String name,final String url){return p("@font-face{font-family:").p(name).p(";src:url(").p(url).p(");}");}
public xwriter jsstr(final String s){try{new osjsstr(os).write(tobytes(s));return this;}catch(final IOException e){throw new Error(e);}}
public xwriter xu(final String id,final String s){return p("$s('").p(id).p("','").jsstr(s).pl("');");}
public xwriter xu(final a e,final String s){return xu(e.id(),s);}
public xwriter xub(final a e,final boolean inner,final boolean escltgt){p("$").p(inner?"s":"o").p("('").p(e.id()).p("','");return new xwriter(new osjsstr(escltgt?new osltgt(os):os));}
public xwriter xube(){return pl("');");}
public xwriter xu(final a e)throws Throwable{e.to(xub(e,true,false));return xube();}
public xwriter xu(final a...es)throws Throwable{
for(a e:es){
e.to(xub(e,true,false));xube();
}
return this;
}
public xwriter xu(final a e,final boolean escltgt)throws Throwable{e.to(xub(e,true,escltgt));return xube();}
public xwriter xuo(final a e)throws Throwable{e.to(xub(e,false,false));return xube();}
public xwriter xinterval(final a e,final String ax,final int ms){return p("setInterval(\"$x('").p(e.id()).p(" ").p(ax).p("')\",").p(ms).pl(");");}
private xwriter xhide(final a e,final boolean hide){
//? bug style block display:inherit
return p("$('").p(e.id()).p("').style.display='").p(hide?"none":"inline").pl("';");
}
public xwriter xhide(final a e){return xhide(e,true);}
public xwriter xshow(final a e){return xhide(e,false);}
public xwriter xalert(final String s){return p("ui.alert('").jsstr(s).pl("');");}
public xwriter xreload(){return pl("location.reload(true);");}
public xwriter xfocus(final a e){return p("$f('").p(e.id()).pl("');");}
public xwriter xfocus(final String id){return p("$f('").p(id).pl("');");}
public xwriter xtitle(final String s){return p("$t('").jsstr(b.isempty(s,"")).pl("');");}
public xwriter xp(final a e,final String s){return p("$p('").p(e.id()).p("','").jsstr(s).pl("');");}
public xwriter el(){return p("<span>");}
public xwriter el(final String style){return p("<span style=\"").p(style).p("\">");}
public xwriter el(final a e){return p("<span id=").p(e.id()).p(">");}
public xwriter el(final a e,final String style){return p("<span id=").p(e.id()).p(" style=\"").p(style).p("\">");}
public xwriter el_(){return p("</span>");}
public xwriter r(final a e)throws Throwable{if(e==null)return this;e.to(this);return this;}
public xwriter rel(final a e)throws Throwable{
if(e==null)return this;
el(e);
e.to(this);
return el_();
}
public xwriter rdiv(final a e)throws Throwable{
if(e==null)return this;
divo(e);
e.to(this);
return div_();
}
public xwriter td(final int colspan){return p("<td colspan=").p(colspan).p(">");}
public xwriter style(final a e,final String style){return style().css(e,style).style_();}
public xwriter style(final a e,final String selector,final String style){return style().css(e,selector,style).style_();}
public xwriter style(final String selector,final String style){return style().css(selector,style).style_();}
public xwriter ax(final a e){return ax(e,"","::");}
public xwriter dived(final a e,final a axe,final String axp,final String style)throws Throwable{
p("<div id=").p(e.id()).p(" contenteditable=true spellcheck=false ");
if(style!=null&&style.length()>0)
p("style=\"").p(style).p("\" ");
p("onkeypress=\"");
if(axe!=null){
p("if(event.charCode==13){$x('");
p(axe.id());
if(axp!=null&&axp.length()>0){
p(" ");
p(axp);
}
p("');return false;}");
}
p("$b(this)\">");
e.to(os);
return p("</div>");
}
public xwriter dived(final a e,final a axe,final String axp)throws Throwable{return dived(e,axe,axp,null);}
public xwriter dived(final a e)throws Throwable{return dived(e,null,null,null);}
public xwriter css(final a e,final String selector,final String style){return css("#"+e.id()+" "+selector,style);}
public xwriter ol(){return tag("ol");}
public xwriter ol_(){return tage("ol");}
public xwriter xlocation(final String uri){return p("location='").p(uri).pl("';");}
public xwriter span(final String style){
return span("",style);
}
public xwriter span(final String cls,final String style){
tago("span");
if(!isempty(cls))attr("class",cls);
if(!isempty(style))attr("style",style);
return tagoe();
}
public xwriter nbsp(){return p(" ");}
private final OutputStream os;
private static String encquot(final String text){if(text==null)return"";return text.replaceAll("\"",""");}
public xwriter spaned(final a e){
tago("span").attrdef(e).attr("contenteditable").p(" onkeydown=\"$b(this)\" spellcheck=false");
// p(" oncopy=\"var e=event;e.preventDefault();var r=window.getSelection();e.clipboardData.setData('text/plain',r);\"");
p(" onpaste=\"var e=event;e.preventDefault();var t=e.clipboardData.getData('text/plain');document.execCommand('inserttext',false,t);\"");
tagoe();
try{e.to(new osltgt(os));}catch(Throwable t){throw new Error(t);}
return span_();
}
public xwriter p_data_size(final long i){
long x=i;
final long megs=(x>>20);
if(megs>0){
x-=(megs<<20);
p(megs).p("m");
return this;
}
final long kilos=(x>>10);
if(kilos>0){
x-=(kilos<<10);
p(kilos).p("k");
return this;
}
if(x>0)p(x);
return this;
}
}
| [
"calin.tenitchi@gmail.com"
] | calin.tenitchi@gmail.com |
bdaac95dc84fd17abc89baf025651caa71e90a79 | 8a1bb4d51c94536c7ecbaa4c2cd81f51cad40fc7 | /src/main/java/siroswaldo/magicchat/channel/ChannelMap.java | 6b12cfd55ec752e75c4e9e898b2b5407511e95fe | [] | no_license | SirOswaldo/MagicChat | a07bb2c96e06953ab36b9040963c6e4892522ccc | 0ec60c92bb8a38cc5a10f66f40b783c03fbc2777 | refs/heads/master | 2022-06-09T01:25:47.819643 | 2020-05-11T18:13:14 | 2020-05-11T18:13:14 | 261,070,426 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,074 | java | package siroswaldo.magicchat.channel;
import org.bukkit.configuration.file.FileConfiguration;
import siroswaldo.magicchat.bukkit.MagicChat;
import java.util.*;
public class ChannelMap {
private final MagicChat magicChat;
private Map<String, Channel> channels;
public ChannelMap(MagicChat magicChat){
this.magicChat = magicChat;
channels = new HashMap<>();
}
public void loadChannels(){
FileConfiguration settings = magicChat.getYamlFiles().getFileConfiguration("settings");
Set<String> names = settings.getConfigurationSection("channels").getValues(false).keySet();
for (String name:names){
boolean enable = true;
boolean Default = false;
String format = "";
String color = "&f";
String permission = "none";
boolean autoJoin = false;
String command = "";
boolean bungee = false;
if (settings.contains("channels."+name+".default")){
Default = settings.getBoolean("channels."+name+".default");
}
// Format
if (settings.contains("channels."+name+".format")){
format = settings.getString("channels."+name+".format");
} else {
enable = false;
}
// Color
if (settings.contains("channels."+name+".color")){
color = settings.getString("channels."+name+".color");
}
// Permission
if (settings.contains("channels."+name+".permission")){
permission = settings.getString("channels."+name+".permission");
}
// AutoJoin
if (settings.contains("channels."+name+".autoJoin")){
autoJoin = settings.getBoolean("channels."+name+".autoJoin");
}
// Command
if (settings.contains("channels."+name+".command")){
autoJoin = settings.getBoolean("channels."+name+".command");
} else {
enable = false;
}
// Bungee
if (settings.contains("channels."+name+".bungee")){
bungee = settings.getBoolean("channels."+name+".bungee");
}
if (enable){
Channel channel = new Channel(name, Default, format, color, permission, autoJoin, command, bungee);
channels.put(name, channel);
}
}
}
public void reloadChannels(){
channels = new HashMap<>();
loadChannels();
}
public boolean containChannel(String channel){
return channels.containsKey(channel);
}
public void addChannel(Channel channel){
channels.put(channel.getName(), channel);
}
public void removeChannel(String channel){
channels.remove(channel);
}
public Channel getChannel(String channel){
return channels.get(channel);
}
public List<String> getChannels(){
return new ArrayList<>(channels.keySet());
}
}
| [
"DeveloperOswaldo@gmail.com"
] | DeveloperOswaldo@gmail.com |
c353822532461a71e65f7d381a6f822f9922247f | 3bb4d644c3b84fa51d9de9e8cd8fc6b1414245da | /Library/src/main/java/net/avicus/libraries/tracker/plugin/EntityDamageEventListener.java | 4cb02641ca35da9692a3a8a0efe2255169d3be8a | [
"LGPL-3.0-only",
"MIT",
"GPL-3.0-only"
] | permissive | jasoryeh/AvicusNetwork | 5062ecc8d152ebc28d3c0de3c9fef4b5f206f32c | a552beff1fc9c9b87477fae84cb52b8d79c10121 | refs/heads/master | 2020-12-14T14:07:02.068893 | 2020-07-09T05:21:23 | 2020-07-09T05:21:23 | 128,274,419 | 0 | 0 | MIT | 2018-04-05T23:13:03 | 2018-04-05T23:13:02 | null | UTF-8 | Java | false | false | 4,168 | java | package net.avicus.libraries.tracker.plugin;
import com.google.common.base.Preconditions;
import net.avicus.libraries.tracker.DamageInfo;
import net.avicus.libraries.tracker.DamageResolvers;
import net.avicus.libraries.tracker.Lifetime;
import net.avicus.libraries.tracker.Lifetimes;
import net.avicus.libraries.tracker.event.EntityDamageEvent;
import net.avicus.libraries.tracker.event.PlayerDamageEvent;
import net.avicus.libraries.tracker.util.EventUtil;
import org.bukkit.Location;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.*;
import org.bukkit.plugin.EventExecutor;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.joda.time.Instant;
import javax.annotation.Nonnull;
public class EntityDamageEventListener implements Listener {
public void register(@Nonnull Plugin plugin) {
Preconditions.checkNotNull(plugin, "plugin");
PluginManager pm = plugin.getServer().getPluginManager();
for (EventPriority priority : EventPriority.values()) {
pm.registerEvent(org.bukkit.event.entity.EntityDamageEvent.class, this, priority,
new EntityDamageEventRunner(this, priority), plugin, false);
}
}
public void unregister() {
HandlerList.unregisterAll(this);
}
public static class EntityDamageEventRunner implements EventExecutor {
private final
@Nonnull
EntityDamageEventListener parent;
private final
@Nonnull
EventPriority priority;
public EntityDamageEventRunner(@Nonnull EntityDamageEventListener parent,
@Nonnull EventPriority priority) {
Preconditions.checkNotNull(parent, "parent");
Preconditions.checkNotNull(priority, "event priority");
this.parent = parent;
this.priority = priority;
}
public void execute(Listener listener, Event event) throws EventException {
if (listener != this.parent) {
return;
}
if (!(event instanceof org.bukkit.event.entity.EntityDamageEvent)) {
return;
}
org.bukkit.event.entity.EntityDamageEvent bukkit = (org.bukkit.event.entity.EntityDamageEvent) event;
if (!(bukkit.getEntity() instanceof LivingEntity)) {
return;
}
LivingEntity entity = (LivingEntity) bukkit.getEntity();
if (entity.isDead()) {
return;
}
DamageAPIHelper helper = DamageAPIHelper.get();
Lifetime lifetime = Lifetimes.getLifetime(entity);
// get our version of the event
EntityDamageEvent our = DamageAPIHelper.get().getOurEvent(bukkit);
if (our == null) {
int hearts = (int) bukkit.getDamage();
Location location = entity.getLocation();
Instant time = Instant.now();
DamageInfo info = DamageResolvers.getManager().resolve(entity, lifetime, bukkit);
if (entity instanceof Player) {
our = new PlayerDamageEvent((Player) entity, lifetime, hearts, location, time, info);
} else {
our = new EntityDamageEvent(entity, lifetime, hearts, location, time, info);
}
helper.setOurEvent(bukkit, our);
}
// update mutable information
our.setCancelled(bukkit.isCancelled());
our.setDamage((int) bukkit.getDamage());
// call
EventUtil.callEvent(our, EntityDamageEvent.getHandlerList(), this.priority);
// update bukkit event
bukkit.setCancelled(our.isCancelled());
bukkit.setDamage(our.getDamage());
// clean up
if (this.priority == EventPriority.MONITOR) {
DamageAPIHelper.get().setOurEvent(bukkit, null);
if (!bukkit.isCancelled()) {
lifetime.addDamage(our.toDamageObject());
}
}
}
}
}
| [
"jason@jasonho.tk"
] | jason@jasonho.tk |
649671109ad95973e843e6b8771b4b87bcfd0139 | 232ef7ae446bd6977d5b6409e0519e427ae83098 | /src/com/shubhendu/javaworld/datastructures/graphs/DirectedEdge.java | 61474fa381284a2db143cd11289d7a0c0422236f | [] | no_license | Shubhendu/algorithms | b4fb3163c4fcdd7d0c0052818c9cb31631cb0a12 | 7fa04797760c49270257b11d18aaffeb16128a5b | refs/heads/master | 2021-04-30T04:39:29.163956 | 2018-02-14T17:50:07 | 2018-02-14T17:50:07 | 80,980,673 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,938 | java | package com.shubhendu.javaworld.datastructures.graphs;
public class DirectedEdge {
private final int v;
private final int w;
private final double weight;
/**
* Initializes a directed edge from vertex {@code v} to vertex {@code w}
* with the given {@code weight}.
*
* @param v
* the tail vertex
* @param w
* the head vertex
* @param weight
* the weight of the directed edge
* @throws IllegalArgumentException
* if either {@code v} or {@code w} is a negative integer
* @throws IllegalArgumentException
* if {@code weight} is {@code NaN}
*/
public DirectedEdge(int v, int w, double weight) {
if (v < 0)
throw new IllegalArgumentException("Vertex names must be nonnegative integers");
if (w < 0)
throw new IllegalArgumentException("Vertex names must be nonnegative integers");
if (Double.isNaN(weight))
throw new IllegalArgumentException("Weight is NaN");
this.v = v;
this.w = w;
this.weight = weight;
}
/**
* Returns the tail vertex of the directed edge.
*
* @return the tail vertex of the directed edge
*/
public int from() {
return v;
}
/**
* Returns the head vertex of the directed edge.
*
* @return the head vertex of the directed edge
*/
public int to() {
return w;
}
/**
* Returns the weight of the directed edge.
*
* @return the weight of the directed edge
*/
public double weight() {
return weight;
}
/**
* Returns a string representation of the directed edge.
*
* @return a string representation of the directed edge
*/
public String toString() {
return v + "->" + w + " " + String.format("%5.2f", weight);
}
/**
* Unit tests the {@code DirectedEdge} data type.
*
* @param args
* the command-line arguments
*/
public static void main(String[] args) {
DirectedEdge e = new DirectedEdge(12, 34, 5.67);
System.out.println(e);
}
}
| [
"mail2shubhendu@gmail.com"
] | mail2shubhendu@gmail.com |
8f96cab092ddaf4190d9f7c32f946baa9569dd6c | 9e9870bca87d1f7686aa5c03f70666728647b2f2 | /src/main/java/com/tatsinktech/web/controller/PushSMS_SubmitController.java | dadddaa73b308435943d57ebb340fa92099b0235 | [
"MIT"
] | permissive | olivier741/schoolAlert | 5abc934a067e7b2f9ae52e14cf1a2851eb78519d | 419a24d656bf83e684f3756f380f352b488cbabd | refs/heads/master | 2022-11-23T23:50:05.351949 | 2020-08-05T10:34:50 | 2020-08-05T10:34:50 | 285,251,139 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,978 | java | /*
* 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 com.tatsinktech.web.controller;
import com.tatsinktech.web.encrypt.PasswordUtils;
import com.tatsinktech.web.model.pushsms.PushLevel;
import com.tatsinktech.web.model.pushsms.PushSMS;
import com.tatsinktech.web.model.register.ServiceProvider;
import com.tatsinktech.web.repository.PushSMSRepository;
import com.tatsinktech.web.repository.ServiceProviderRepository;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Logger;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang.StringUtils;
import org.keycloak.adapters.springsecurity.account.SimpleKeycloakAccount;
import org.keycloak.representations.AccessToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.support.SessionStatus;
import org.springframework.web.servlet.ModelAndView;
/**
*
* @author olivier.tatsinkou
*/
@Controller
@RequestMapping("pushsms_submit")
public class PushSMS_SubmitController {
private Logger logger = Logger.getLogger(this.getClass().getName());
private HashMap<String, ServiceProvider> HashService = new HashMap<String, ServiceProvider>();
private boolean enableSave = true;
private boolean enableEdit = true;
@Autowired
private PushSMSRepository pushSMSRepo;
@Autowired
private ServiceProviderRepository serviceRepo;
public boolean isEnableSave() {
return enableSave;
}
public void setEnableSave(boolean enableSave) {
this.enableSave = enableSave;
}
public boolean isEnableEdit() {
return enableEdit;
}
public void setEnableEdit(boolean enableEdit) {
this.enableEdit = enableEdit;
}
@InitBinder
public void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
@GetMapping("/list")
public ModelMap getlist(@PageableDefault(size = 10) Pageable pageable,
@RequestParam(name = "value", required = false) String value,
Model model, @NotNull Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String id = acceToken.getPreferredUsername();
loadMode(model, auth);
List<PushLevel> listLevel = new ArrayList<PushLevel>();
listLevel.add(PushLevel.SUBMIT);
listLevel.add(PushLevel.DENY);
listLevel.add(PushLevel.CANCEL);
if (value != null) {
model.addAttribute("key", value);
return new ModelMap().addAttribute("pushsms_submit", pushSMSRepo.findByPushNameContainingIgnoreCaseAndSubmitUserIDAndPushLevelIn(value, id,listLevel, pageable));
} else {
return new ModelMap().addAttribute("pushsms_submit", pushSMSRepo.findBySubmitUserIDAndPushLevelIn(id,listLevel, pageable));
}
}
@GetMapping("/view")
public ModelMap getView(@RequestParam(value = "id", required = true) long id, Model model, @NotNull Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String user_id = acceToken.getPreferredUsername();
loadMode(model, auth);
PushSMS entity = pushSMSRepo.findPushSMSById(id);
enableEdit = true;
Iterable<ServiceProvider> listService = serviceRepo.findAll();
List<ServiceProvider> listSrv = new ArrayList<ServiceProvider>();
HashService.clear();
for (ServiceProvider serv : listService) {
if (serv.getServiceProviderID()!=null && PasswordUtils.verifyUserPassword(user_id, serv.getServiceProviderID(), serv.getServiceProviderSalt())) {
listSrv.add(serv);
HashService.put(serv.getServiceName(), serv);
}
}
model.addAttribute("listService", listSrv);
model.addAttribute("enableEdit", enableEdit);
return new ModelMap("phsms", entity);
}
@GetMapping("/form")
public ModelMap getForm(@RequestParam(value = "id", required = false) Long id, Model model, @NotNull Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String user_id = acceToken.getPreferredUsername();
loadMode(model, auth);
PushSMS entity = new PushSMS();
enableSave = true;
if (id != null) {
enableSave = false;
entity = pushSMSRepo.findPushSMSById(id);
}
Iterable<ServiceProvider> listService = serviceRepo.findAll();
List<ServiceProvider> listSrv = new ArrayList<ServiceProvider>();
HashService.clear();
for (ServiceProvider serv : listService) {
if (serv.getServiceProviderID()!=null && PasswordUtils.verifyUserPassword(user_id, serv.getServiceProviderID(), serv.getServiceProviderSalt())) {
listSrv.add(serv);
HashService.put(serv.getServiceName(), serv);
}
}
model.addAttribute("listService", listSrv);
model.addAttribute("enableSave", enableSave);
return new ModelMap("phsms", entity);
}
@PostMapping("/form")
public String postForm(@Valid @ModelAttribute("phsms") PushSMS entity,
BindingResult errors, SessionStatus status, Model model, @NotNull Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String user_id = acceToken.getPreferredUsername();
loadMode(model, auth);
boolean is_error = false;
String result = "pushsms_submit/form";
if (errors.hasErrors()) {
is_error = true;
}
String serv_name = entity.getService().getServiceName();
ServiceProvider serv = null;
if (!StringUtils.isBlank(serv_name) && !serv_name.equals("NONE")) {
serv = HashService.get(serv_name);
}
entity.setService(serv);
entity.setSubmitUserID(user_id);
entity.setPushLevel(PushLevel.SUBMIT);
pushSMSRepo.save(entity);
status.setComplete();
result = "redirect:/pushsms_submit/list";
if (is_error) {
Iterable<ServiceProvider> listService = serviceRepo.findAll();
List<ServiceProvider> listSrv = new ArrayList<ServiceProvider>();
HashService.clear();
for (ServiceProvider srv : listService) {
if (serv.getServiceProviderID()!=null && PasswordUtils.verifyUserPassword(user_id, serv.getServiceProviderID(), serv.getServiceProviderSalt())) {
listSrv.add(srv);
HashService.put(srv.getServiceName(), srv);
}
}
model.addAttribute("listService", listSrv);
result = "pushsms_submit/form";
}
return result;
}
@GetMapping("/delete")
public ModelMap getDelete(@RequestParam(value = "id", required = true) long id, Model model, @NotNull Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String user_id = acceToken.getPreferredUsername();
loadMode(model, auth);
PushSMS entity = pushSMSRepo.findPushSMSById(id);
enableEdit = true;
Iterable<ServiceProvider> listService = serviceRepo.findAll();
List<ServiceProvider> listSrv = new ArrayList<ServiceProvider>();
HashService.clear();
for (ServiceProvider serv : listService) {
if (serv.getServiceProviderID()!=null && PasswordUtils.verifyUserPassword(user_id, serv.getServiceProviderID(), serv.getServiceProviderSalt())) {
listSrv.add(serv);
HashService.put(serv.getServiceName(), serv);
}
}
model.addAttribute("listService", listSrv);
model.addAttribute("enableEdit", enableEdit);
return new ModelMap("phsms", entity);
}
@PostMapping("/delete")
public Object postDelete(@Valid @ModelAttribute("phsms") PushSMS entity, SessionStatus status, Model model, @NotNull Authentication auth) {
loadMode(model, auth);
try {
pushSMSRepo.delete(entity);
} catch (DataIntegrityViolationException exception) {
status.setComplete();
return new ModelAndView("error/errorHapus")
.addObject("entityId", entity.getPushName())
.addObject("entityName", "pushsms_submit")
.addObject("errorCause", exception.getRootCause().getMessage())
.addObject("backLink", "/pushsms_submit/list");
}
status.setComplete();
return "redirect:/pushsms_submit/list";
}
private void loadMode(Model model, Authentication auth) {
AccessToken acceToken = ((SimpleKeycloakAccount) auth.getDetails())
.getKeycloakSecurityContext()
.getToken();
String id = acceToken.getId();
String username = acceToken.getPreferredUsername();
String birtdate = acceToken.getBirthdate();
String name = acceToken.getName();
String email = acceToken.getEmail();
String firstName = acceToken.getFamilyName();
String genre = acceToken.getGender();
String givenName = acceToken.getGivenName();
String midleName = acceToken.getMiddleName();
String nickName = acceToken.getNickName();
String phone_number = acceToken.getPhoneNumber();
model.addAttribute("keycloak_username", username);
model.addAttribute("keycloak_id", id);
model.addAttribute("keycloak_lastname", firstName);
model.addAttribute("keycloak_name", name);
model.addAttribute("keycloak_email", email);
model.addAttribute("keycloak_firstname", givenName);
model.addAttribute("keycloak_genre", genre);
model.addAttribute("keycloak_midlename", midleName);
model.addAttribute("keycloak_nickname", nickName);
model.addAttribute("keycloak_phone", phone_number);
}
}
| [
"oliviertatsink@gmail.com"
] | oliviertatsink@gmail.com |
cf07a18701d3876befde620494054d4d6eb4aff1 | 101125341931d25f3a669062b3c61c313fac2fe0 | /src/main/java/fit/basic/FlowControl.java | 4fcaa45cd052192672c4f168454d185ff7e841cf | [] | no_license | prof-emilio-resende/walkthrough-java | a241fce2fd012aa41602ef15c9311cf0f8ba7aa0 | fea42954c28d6747fa0a74408d0ab1b9a758c177 | refs/heads/main | 2023-08-28T19:04:43.800044 | 2021-10-30T01:41:13 | 2021-10-30T01:41:13 | 422,757,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 957 | java | package fit.basic;
import javax.print.event.PrintEvent;
public class FlowControl {
public static final int ONE = 1;
public static final int TWO = 2;
public static final int THREE = 3;
public static void doTry(int number) {
System.out.println("FlowControl...");
boolean isEven = ((number % 2) == 0);
if (isEven) {
System.out.println("is even!");
switch (number) {
case 10:
System.out.println("The number is ten");
break;
case 2:
System.out.println("The number is two...");
break;
default:
System.out.println("The number is unkown");
}
}
String name = "UmTextoQualquer";
for (int i = 0; i < name.length(); i++) {
System.out.printf("caractere %d : %s%n", i, name.charAt(i));
}
int any = switch(number) {
case ONE, TWO -> 0;
case THREE -> 1;
default -> 2;
};
System.out.println(any);
}
}
| [
"emilio.murta@msitbrasil.com"
] | emilio.murta@msitbrasil.com |
b0d8e1d7f862d062917236a6f41e2e61f2c8228a | c08aeeab3b80902405367c97761130cac31843b2 | /01_flow_control/src/main/java/com/lucky/loop/for_loop/ForTest_1.java | 7fb7d77158e4af841cee8ca7903523dc76cfee47 | [] | no_license | ZXyy2627/SpringRush | d0fb58462dbab176872bfc4b594f1ad89cbfce9f | f174d95e2d85cce5ec9e0ab849f6566250958ec7 | refs/heads/master | 2023-06-15T06:56:22.717769 | 2021-07-09T12:57:46 | 2021-07-09T12:57:46 | 376,056,246 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 660 | java | package com.lucky.loop.for_loop;
/**
* 编写程序 打印1到150 如果是3的倍数,那么就在后面加上foo
* 如果是5的倍数 就在后面加上biz
* 如果是7的倍数 就在后面加上baz
*/
public class ForTest_1 {
public static void main(String[] args) {
for (int i = 1; i <= 150; i++) {
System.out.println(i+" ");
if (i % 3 == 0) {
System.out.println(i + " foo");
}
if (i % 5 == 0) {
System.out.println(i + " baz");
}
if (i % 7 == 0) {
System.out.println(i + " biz");
}
}
}
} | [
"1375423395@qq.com"
] | 1375423395@qq.com |
4c1067992152487fc64bc01c90c260da1220a4a9 | 9dfdb114e9645ee31d4f20fe002e734f636aaeaf | /app/src/main/java/br/net/netfitness/netfitness/SelecionarGraficoFragment.java | 9155610a643c2dea774ae55d759f45c841c8be0e | [] | no_license | karter76/NetFitnessMOBILE | 3c4c9147bbe1c3f199671f240c8a53875f0ec672 | d262c33bf441ae19afc87b94db7e3e4408e49cdd | refs/heads/master | 2016-09-11T02:21:24.728179 | 2015-06-15T14:34:13 | 2015-06-15T14:34:13 | 35,730,016 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,547 | java | package br.net.netfitness.netfitness;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.Toast;
import java.util.ArrayList;
import interfaces.ClicouNoCompararGraficos;
public class SelecionarGraficoFragment extends Fragment {
public static SelecionarGraficoFragment newInstance() {
SelecionarGraficoFragment fragment = new SelecionarGraficoFragment();
return fragment;
}
public SelecionarGraficoFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState)
{
View view = inflater.inflate(R.layout.fragment_selecionar_grafico, container, false);
final CheckBox checkBoxPeso = (CheckBox) view.findViewById(R.id.checkBoxPeso);
final CheckBox checkBoxIMC = (CheckBox) view.findViewById(R.id.checkBoxIMC);
final CheckBox checkBoxTorax = (CheckBox) view.findViewById(R.id.checkBoxTorax);
final CheckBox checkBoxAbdomen = (CheckBox) view.findViewById(R.id.checkBoxAbdomen);
final CheckBox checkBoxBraco = (CheckBox) view.findViewById(R.id.checkBoxBraco);
final CheckBox checkBoxAntebraco = (CheckBox) view.findViewById(R.id.checkBoxAntebraco);
final CheckBox checkBoxCoxa = (CheckBox) view.findViewById(R.id.checkBoxCoxa);
final CheckBox checkBoxPanturrilha = (CheckBox) view.findViewById(R.id.checkBoxPanturrilha);
Button btnCompararGraficos = (Button) view.findViewById(R.id.buttonCompararGraficos);
btnCompararGraficos.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
String graficosSelecionados = "#comparar#";
int count = 0;
if(checkBoxPeso.isChecked())
{
graficosSelecionados+="peso,";
count++;
}
if(checkBoxIMC.isChecked())
{
graficosSelecionados+="imc,";
count++;
}
if(checkBoxTorax.isChecked())
{
graficosSelecionados+="circTorax,";
count++;
}
if(checkBoxAbdomen.isChecked())
{
graficosSelecionados+="circAbdomen,";
count++;
}
if(checkBoxBraco.isChecked())
{
graficosSelecionados+="circBraco,";
count++;
}
if(checkBoxAntebraco.isChecked())
{
graficosSelecionados+="circAntebraco,";
count++;
}
if(checkBoxCoxa.isChecked())
{
graficosSelecionados+="circCoxa,";
count++;
}
if(checkBoxPanturrilha.isChecked())
{
graficosSelecionados+="circPanturrilha";
count++;
}
if( graficosSelecionados.substring(graficosSelecionados.length() - 1).equals(",") )
{
graficosSelecionados = graficosSelecionados.substring(0, graficosSelecionados.length()-1);
}
if (getActivity() instanceof ClicouNoCompararGraficos)
{
if(count < 2)
{
Toast toast = Toast.makeText(getActivity(), R.string.no_element_comparar_grafico, Toast.LENGTH_SHORT);
toast.show();
}
else if(count>4)
{
Toast toast = Toast.makeText(getActivity(), R.string.too_much_elements_comparar_grafico, Toast.LENGTH_SHORT);
toast.show();
}
else
{
ClicouNoCompararGraficos listener = (ClicouNoCompararGraficos) getActivity();
listener.aoCompararGraficos(graficosSelecionados);
}
}
}
});
return view;
}
}
| [
"karter76@gmail.com"
] | karter76@gmail.com |
03b7d9be8a48639311bee30f5b9e9c341066515e | e351794d7dd9414e22308040c0aba98c345f1bbf | /spring-boot-tutorial-search/src/main/java/com/nandulabs/service/SearchService.java | f8f86980e212059fd502f3ba71ac1947567e9398 | [
"MIT"
] | permissive | narendrask89/spring-boot | 48d4f6272dc5e106b5fddd6241e643ce9aa704e9 | 58a833a58fccb81e81cdece867584ae2a9a026b3 | refs/heads/master | 2020-03-09T17:31:49.441140 | 2018-04-10T10:03:27 | 2018-04-10T10:03:27 | 128,910,694 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,098 | java | package com.nandulabs.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.convert.converter.Converter;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import com.nandulabs.model.dto.SearchResult;
import com.nandulabs.model.entity.Profile;
import com.nandulabs.model.repository.ProfileDao;
@Service
public class SearchService {
@Value("${results.pagesize}")
private int pageSize;
@Autowired
private ProfileDao profileDao;
public Page<SearchResult> search(String text, int pageNumber) {
PageRequest request = new PageRequest(pageNumber-1, pageSize);
Page<Profile> results = profileDao.findByInterestsNameContainingIgnoreCase(text, request);
Converter<Profile, SearchResult> converter = new Converter<Profile, SearchResult>() {
public SearchResult convert(Profile profile) {
return new SearchResult(profile);
}
};
return results.map(converter);
}
}
| [
"nasahu@DIN66007718.corp.capgemini.com"
] | nasahu@DIN66007718.corp.capgemini.com |
7c54c353591a2480350b3f3a2ec4e054b04b952d | d6441b1f36fd723ebcbe97e386167af81106b437 | /src/main/java/com/example/actuator/config/CustomFeatureEndPoint.java | 6d5c285b639366fb8a317102954779b3960ac44a | [] | no_license | sandhu5/Actuators | e5d8b161a3cc2b19294cbb5b39a1707ad54888be | 4a2e91c4becc1891e4ee64ebed6288f4ccd6ad03 | refs/heads/master | 2020-03-28T13:56:32.862429 | 2018-09-12T08:02:17 | 2018-09-12T08:02:17 | 148,443,790 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 592 | java | package com.example.actuator.config;
import java.time.LocalTime;
import org.springframework.boot.actuate.health.Health;
import org.springframework.boot.actuate.health.HealthIndicator;
import org.springframework.stereotype.Component;
@Component
public class CustomFeatureEndPoint implements HealthIndicator {
@Override
public Health health() {
int errorCode = 0;
LocalTime now = LocalTime.now();
if (now.getMinute() % 2 != 0) {
errorCode = 1;
}
if (errorCode != 0) {
return Health.down().withDetail("Error Code", errorCode).build();
}
return Health.up().build();
}
} | [
"sandhu@bahadur.singh"
] | sandhu@bahadur.singh |
184e8b2221cac3d83e2f78a5653e564218cebea6 | c24219e6c07ed17df0a3283b31a2287a00cee654 | /core/src/main/java/com/zd/core/utils/type/BTree.java | a39bde9ad3671c1281c1d5cba802f1fc6d4ba4ab | [] | no_license | q66217910/clean-spring-cloud | 922685495785923d8e31109223b5cf41d861787b | d76833413bcbb58dfffe3e961993946ddfd1ca3e | refs/heads/master | 2022-06-22T06:28:15.475996 | 2020-08-28T09:10:59 | 2020-08-28T09:10:59 | 192,641,944 | 9 | 0 | null | 2022-06-21T04:00:00 | 2019-06-19T02:12:30 | Java | UTF-8 | Java | false | false | 8,256 | java | package com.zd.core.utils.type;
public class BTree<K extends Comparable<K>, V> {
private Node<K, V> root = new LeafNode<K, V>();
/**
* 非叶子节点节点数量
*/
private static final int M = 4;
public V find(K key) {
if (root != null) return root.find(key);
return null;
}
public void insert(K key, V value) {
Node<K, V> t = this.root.insert(key, value);
//只有非叶子节点插入,并且直接插入才会返回非null
if (t != null) {
this.root = t;
}
}
class Entry<K extends Comparable<K>, V> {
private K key;
private V value;
private Node<K, V> node;
public Entry(K key, V value) {
this.key = key;
this.value = value;
}
public Entry(Entry<K, V> entry, Node node) {
this.key = entry.key;
this.value = entry.value;
this.node = node;
}
}
/**
* 节点抽象类(节点分两种,叶子节点和非叶子节点)
*/
abstract class Node<K extends Comparable<K>, V> {
protected Node<K, V> parent;//父节点
protected Entry<K, V>[] entries; //键
protected int keyNum;//键的数量
abstract V find(K key);//查询
abstract Node<K, V> insert(K key, V value);//插入
protected Node<K, V> insertNode(Node<K, V> node1, Node<K, V> node2, K key) {
return null;
}
}
/**
* 非叶子节点,只用来索引不包含数据
*/
class BPlusNode<K extends Comparable<K>, V> extends Node<K, V> {
/**
* 递归查询,只为确定落在哪个区间
* 找到叶子节点会调用叶子节点的find方法
*/
@Override
V find(K key) {
for (int i = 0; i < this.keyNum; i++) {
if (key.compareTo(this.entries[i].key) <= 0) {
return this.entries[i].node.find(key);
}
}
return null;
}
/**
* 递归查询,只为确定落在哪个区间
* 在该区间插入
*/
@Override
Node<K, V> insert(K key, V value) {
for (int i = 0; i < this.keyNum; i++) {
if (key.compareTo(this.entries[i].key) <= 0) {
return this.entries[i].node.insert(key, value);
}
}
return this.entries[keyNum - 1].node.insert(key, value);
}
/**
* 当叶子节点,节点数超过m个,分裂结束后,递归向父节点插入元素
*/
protected Node<K, V> insertNode(Node<K, V> node1, Node<K, V> node2, K key) {
K oldKey = null;//原始key
if (this.keyNum > 0) oldKey = this.entries[this.keyNum - 1].key;
if (key == null || this.keyNum == 0) {
//空节点,直接插入两个节点
this.entries[0] = new Entry<>(node1.entries[node1.keyNum - 1], node1);
this.entries[1] = new Entry<>(node1.entries[node1.keyNum - 1], node2);
this.keyNum += 2;
return this;
}
//当前节点为非空节点
int i = 0;
while (key.compareTo(this.entries[i].key) != 0) {
i++;
}
//左边节点的最大值可以直接插入,右边的要挪一挪再进行插入
this.entries[i] = node1.entries[node1.keyNum - 1];
Entry<K, V>[] temp = new Entry[M];
System.arraycopy(this.entries, 0, temp, 0, i);
System.arraycopy(this.entries, i, temp, i + 1, this.keyNum - i);
temp[i + 1] = node2.entries[node2.keyNum - 1];
this.keyNum++;
//判断是否分裂
if (this.keyNum <= M) {
System.arraycopy(temp, 0, this.entries, 0, this.keyNum);
return null;
}
BPlusNode<K, V> tempNode = new BPlusNode<K, V>();
tempNode.keyNum = this.keyNum - this.keyNum / 2;
tempNode.parent = this.parent;
if (this.parent == null) {
//若没有父节点,创建一个非叶子节点
BPlusNode<K, V> parentNode = new BPlusNode<>();
tempNode.parent = parentNode;
this.parent = parentNode;
oldKey = null;
}
//将数据复制到新节点,原来的叶子节点只留左半边
System.arraycopy(temp, this.keyNum / 2, tempNode.entries, 0, tempNode.keyNum);
for (int j = this.keyNum / 2; j < this.entries.length; j++) this.entries[j] = null;
return this.parent.insertNode(this, tempNode, oldKey);
}
}
/**
* 叶子节点,其中包含全部元素的信息,
* 所有叶子是一个双向链表
*/
class LeafNode<K extends Comparable<K>, V> extends Node<K, V> {
protected LeafNode<K, V> left;//链表前节点
protected LeafNode<K, V> right; //链表后节点
@Override
V find(K key) {
//二分查找
int l = 0, r = this.keyNum;
while (l < r) {
int m = (l + r) >>> 1;
K midKey = this.entries[m].key;
if (key.compareTo(midKey) == 0) {
return this.entries[m].value;
} else if (key.compareTo(midKey) < 0) {
r = m;
} else {
l = m;
}
}
return null;
}
@Override
Node<K, V> insert(K key, V value) {
K oldKey = null;//原始key
if (this.keyNum > 0) oldKey = this.entries[this.keyNum - 1].key;
//寻找要插入的区间
int i = 0;
while (i++ < this.keyNum) {
if (key.compareTo(this.entries[i].key) < 0) break;
}
//copy一个新的子节点数组,第i位后向后移,新元素插入i的位置,当前节点存储数量+1
Entry<K, V>[] temp = new Entry[M];
System.arraycopy(this.entries, 0, temp, 0, i);
System.arraycopy(this.entries, i, temp, i + 1, this.keyNum - i);
temp[i] = new Entry<>(key, value);
this.keyNum++;
if (this.keyNum <= M) {
//没超过上限不需要分裂
System.arraycopy(temp, 0, this.entries, 0, this.keyNum);
//判断是否更新父节点的边界值,递归往上赋值
Node<K, V> node = this;
while (node.parent != null) {
if (node.entries[node.keyNum - 1].key
.compareTo(node.parent.entries[node.parent.keyNum - 1].key) > 0) {
//若当前最大节点比父节点最大节点值大
node.parent.entries[node.parent.keyNum - 1].key = node.entries[node.keyNum - 1].key;
}
node = node.parent;
}
//不分裂提前返回
return null;
}
//开始分裂
//新建叶子节点(迁移数量为当前节点数量的一半)
LeafNode<K, V> tempNode = new LeafNode<K, V>();
tempNode.keyNum = this.keyNum - this.keyNum / 2;
tempNode.parent = this.parent;
if (this.parent == null) {
//若没有父节点,创建一个非叶子节点
BPlusNode<K, V> parentNode = new BPlusNode<>();
tempNode.parent = parentNode;
this.parent = parentNode;
oldKey = null;
}
//将数据复制到新节点,原来的叶子节点只留左半边
System.arraycopy(temp, this.keyNum / 2, tempNode.entries, 0, tempNode.keyNum);
for (int j = this.keyNum / 2; j < this.entries.length; j++) this.entries[j] = null;
//设置叶子节点链表
this.right = tempNode;
tempNode.left = this;
//插入父节点
return this.parent.insertNode(this, tempNode, oldKey);
}
}
}
| [
"dezhang@homeinns.com"
] | dezhang@homeinns.com |
358580943f979ff81a08bbb8ece82c905c6c5dd7 | 655eea1d72bd31c906c0656fcd497104400de983 | /MarsRoverProb/src/com/marsroverprob/parser/AbstractParser.java | ed3127116537a5d9d0316328177ca63ce44f4a1e | [] | no_license | ShreyasVenkatesh/MarsRoverProblem | 61d0484ff8da9efb4553298a645633b3a4ad5348 | 7265abdcb5e2343dd45598164d9818eb4b9f4476 | refs/heads/master | 2021-04-29T23:01:46.542967 | 2018-08-30T09:52:36 | 2018-08-30T09:52:36 | 121,547,896 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 179 | java | package com.marsroverprob.parser;
import com.marsroverprob.model.Rover;
public interface AbstractParser {
Rover parse(Rover rover, String roverInput, String maxPos);
}
| [
"venkas39@INENVENKAS3L2C.corp.emc.com"
] | venkas39@INENVENKAS3L2C.corp.emc.com |
2726de8c79154546a20f7508fda39151a67082a4 | 85dac003e4c76606ab54be45a2d0a15bc1e461ca | /interfacesegregation/src/main/java/com/julioluis/interfacesegregation/model/Customer.java | 2d218d6f136f5abd0b3c89753f9f1b1f1bf18efc | [] | no_license | jpelegrino/solid | dedd0f05c92b050a8e3192c283ae020e2f748773 | b1459e4b54d63bb03680c78fccffb41c7ba5b56f | refs/heads/develop | 2023-01-19T21:46:25.728285 | 2019-10-19T16:44:01 | 2019-10-19T16:44:01 | 200,430,999 | 0 | 0 | null | 2023-01-07T10:50:47 | 2019-08-03T23:48:11 | Java | UTF-8 | Java | false | false | 293 | java | package com.julioluis.interfacesegregation.model;
import org.springframework.stereotype.Component;
@Component
public class Customer {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| [
"jpelegrino@gmail.com"
] | jpelegrino@gmail.com |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.