blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 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
689M
⌀ | 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 131
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 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
a721d4fbe14d8dc6e962735ee0c16439e53f84e8 | def2d1d4ed229159a4377fee596e52bb24ef2047 | /app/src/main/java/com/ufpso/catatumboplay/gcm/MessagingServices.java | f8b609172871f0f00f106c85217280718c7415ce | [] | no_license | jeidevelopers/CatatumboPlay | 729f8058b8441e82cffe5bd3613ae0e0524caa03 | d30a54716a41c9a19292be362fd6855860f1a2e7 | refs/heads/master | 2020-07-20T14:52:35.650330 | 2019-09-05T21:55:26 | 2019-09-05T21:55:26 | 206,662,596 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,031 | java | package com.ufpso.catatumboplay.gcm;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Build;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import com.google.firebase.messaging.FirebaseMessagingService;
import com.google.firebase.messaging.RemoteMessage;
import com.ufpso.catatumboplay.R;
import com.ufpso.catatumboplay.ui.activity.MainActivity;
import com.ufpso.catatumboplay.ui.activity.VideoPageActivity;
import java.util.Map;
public class MessagingServices extends FirebaseMessagingService {
private static final String TAG = "FCM Message";
public MessagingServices() {
super();
}
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
try {
Log.d("msg", "onMessageReceived: " + remoteMessage.getData().get("message"));
Log.e("data", "msg" + remoteMessage.getData());
for (Map.Entry<String, String> entry : remoteMessage.getData().entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
Log.d(TAG, "key, " + key + " value " + value);
}
Log.e("video_id", "admin_video_id" + remoteMessage.getData().get("admin_video_id"));
String video_id = remoteMessage.getData().get("admin_video_id");
Intent intent = new Intent(getApplicationContext(), VideoPageActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("videoID", video_id);
intent.putExtra("userName", "");
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
String channelId = "Default";
NotificationCompat.Builder builder = new NotificationCompat.Builder(this, channelId)
.setSmallIcon(R.mipmap.ic_launcher)
.setContentTitle("Catatumbo Play")
.setContentText(remoteMessage.getNotification().getBody()).setAutoCancel(true).setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
NotificationChannel channel = new NotificationChannel(channelId, "Default channel", NotificationManager.IMPORTANCE_DEFAULT);
if (manager != null) {
manager.createNotificationChannel(channel);
}
}
if (manager != null) {
manager.notify(0, builder.build());
}
} catch (Exception e) {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
startActivity(i);
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
ec47d739683a8e3d803504146fd99ec339bc7933 | 0a66aacc45e0295551e64deeac537ac6f3719d77 | /apidoc-test/src/main/java/com/ztianzeng/apidoc/test/Result.java | 410e724a3fb87c5f4a9b01bda1fc0f2c67887a21 | [] | no_license | zxcvbnmzsedr/apidoc | 0d2e4977c996c20b735581894545b0db0c82ba79 | 5ae97cbed45e9a561270487dbe7ba9f4f2eb7309 | refs/heads/master | 2022-12-21T08:41:57.573105 | 2022-04-17T06:02:31 | 2022-04-17T06:02:31 | 188,857,939 | 31 | 8 | null | 2022-12-10T04:49:58 | 2019-05-27T14:24:41 | Java | UTF-8 | Java | false | false | 337 | java | package com.ztianzeng.apidoc.test;
import lombok.Getter;
/**
* @author zhaotianzeng
* @version V1.0
* @date 2019-06-11 13:13
*/
@Getter
public class Result<T> {
private String msg;
private T data;
protected Result() {
}
private Result(String msg, T t) {
this.msg = msg;
this.data = t;
}
} | [
"[email protected]"
] | |
0fe4e16f65a2523bc9cf3944c6d52050af9f8a26 | ddf0d861a600e9271198ed43be705debae15bafd | /src/Java8/DevoxxAndOracleDevelopers/CompletableFutureThePromisesOfJava/Sample.java | 1f5921e54db196a3087a5644f0b178f55fec6de1 | [] | no_license | bibhuty-did-this/MyCodes | 79feea385b055edc776d4a9d5aedbb79a9eb55f4 | 2b8c1d4bd3088fc28820145e3953af79417c387f | refs/heads/master | 2023-02-28T09:20:36.500579 | 2021-02-07T17:17:54 | 2021-02-07T17:17:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,841 | java | package Java8.DevoxxAndOracleDevelopers.CompletableFutureThePromisesOfJava;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ForkJoinPool;
public class Sample {
public static ForkJoinPool forkJoinPool=new ForkJoinPool(10);
public static int compute(){
System.out.println("Thread where compute method runs is "+Thread.currentThread().getName());
return new Random().nextInt();
}
public static void printIt(int value){
// Note: It can run in either of main thread or commonPool
System.out.println("Thread where printIt method runs is "+Thread.currentThread().getName());
System.out.println(value);
}
public static CompletableFuture<Integer> create(){
System.out.println("Thread where create method runs is "+Thread.currentThread().getName());
return CompletableFuture.supplyAsync(()->compute(),forkJoinPool);
}
public static boolean sleep(int millis){
try {
Thread.sleep(millis);
return true;
} catch (InterruptedException e) {
return false;
}
}
public static void main(String[] args) {
System.out.println("Thread running inside main is "+Thread.currentThread().getName());
CompletableFuture<Integer> createFuture=create();
sleep(1000);
createFuture
.thenApply(data->data*0) // Just like map
.thenApply(data->data+1)
.thenAccept(data-> printIt(data)) // Just like for each
.thenRun(()-> System.out.println("All done"))
.thenRun(()-> System.out.println("Not really"))
.thenRun(()-> System.out.println("Keep running"));
sleep(1000);
}
}
| [
"[email protected]"
] | |
23032304f4151edd19534690219d2e84ce3fc240 | d9fc33efba5753357554d22f254c4809cf22f096 | /boundless/org/jivesoftware/smackx/provider/DiscoverInfoProvider.java | b01510b6059e51613d6bf3cca162c2a9f2a11b44 | [] | no_license | cdfx2016/AndroidDecompilePractice | 05bab3f564387df6cfe2c726cdb3f877500414f0 | 1657bc397606b9caadc75bd6d8a5b6db533a1cb5 | refs/heads/master | 2021-01-22T20:03:00.256531 | 2017-03-17T06:37:36 | 2017-03-17T06:37:36 | 85,275,937 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,321 | java | package org.jivesoftware.smackx.provider;
import com.fanyu.boundless.config.Preferences;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smack.util.PacketParserUtils;
import org.jivesoftware.smackx.packet.DiscoverInfo;
import org.jivesoftware.smackx.packet.DiscoverInfo.Identity;
import org.xmlpull.v1.XmlPullParser;
public class DiscoverInfoProvider implements IQProvider {
public IQ parseIQ(XmlPullParser xmlPullParser) throws Exception {
IQ discoverInfo = new DiscoverInfo();
Object obj = null;
String str = "";
String str2 = "";
String str3 = "";
String str4 = "";
String str5 = "";
discoverInfo.setNode(xmlPullParser.getAttributeValue("", "node"));
while (obj == null) {
int next = xmlPullParser.next();
if (next == 2) {
if (xmlPullParser.getName().equals("identity")) {
str = xmlPullParser.getAttributeValue("", "category");
str2 = xmlPullParser.getAttributeValue("", Preferences.sbry);
str3 = xmlPullParser.getAttributeValue("", MessageEncoder.ATTR_TYPE);
str5 = xmlPullParser.getAttributeValue(xmlPullParser.getNamespace("xml"), "lang");
} else if (xmlPullParser.getName().equals("feature")) {
str4 = xmlPullParser.getAttributeValue("", "var");
} else {
discoverInfo.addExtension(PacketParserUtils.parsePacketExtension(xmlPullParser.getName(), xmlPullParser.getNamespace(), xmlPullParser));
}
} else if (next == 3) {
if (xmlPullParser.getName().equals("identity")) {
Identity identity = new Identity(str, str2, str3);
if (str5 != null) {
identity.setLanguage(str5);
}
discoverInfo.addIdentity(identity);
}
if (xmlPullParser.getName().equals("feature")) {
discoverInfo.addFeature(str4);
}
if (xmlPullParser.getName().equals("query")) {
obj = 1;
}
}
}
return discoverInfo;
}
}
| [
"残刀飞雪"
] | 残刀飞雪 |
4284b1a182ef57d2e2fcf456ea079233a228d231 | 252c7afb7dfe22874b1b45e59f8c748515cf2ec1 | /GSE/src/main/java/br/com/gestmax/GSE/domain/Produto.java | 347fb45d092cfafa3b2444f8a586541ccbce17f8 | [] | no_license | BrunoSzczuk/GSE | 00b51c1492ec6fd93ad309d3161d4cbaaf815c22 | 55575b7ca738ca5349edb0dbbf8d5fe68d8aa502 | refs/heads/master | 2023-07-29T14:37:18.685770 | 2021-09-03T19:19:28 | 2021-09-03T19:19:28 | 210,967,444 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,556 | java | package br.com.gestmax.GSE.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;
@Entity
@Data
public class Produto implements BasicDomain {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Column(nullable = false, length = 15)
private String cdProduto;
@Column(length = 60)
private String dsProduto;
@Column(length = 100)
private String tpProduto;
private Boolean stAtivo;
private Integer qtBaseestrutura;
private BigDecimal ftConversao;
private String tpConversao;
private Timestamp dtAtualizacao;
private Boolean stLote;
private BigDecimal psProduto;
private BigDecimal vlIpipauta;
private BigDecimal vlPispauta;
private BigDecimal vlCofpauta;
private Boolean stBloqueado;
@Column(length = 10)
private String nrNcm;
@Column(length = 3)
private String cdSegum;
private BigDecimal psBruto;
@Column(length = 100)
private String dsOrigem;
private BigDecimal qtMultiplicador;
@Column(length = 15)
private String cdEan;
@JsonIgnore
@OneToMany(mappedBy = "produto")
private Collection<ImpostoItem> impostoItems;
@ManyToOne
private UnidadeMedida unidadeMedida;
@ManyToOne
private Marca marca;
@ManyToOne
private SubGrupoProduto subGrupoProduto;
@OneToMany(mappedBy = "produto")
@JsonIgnore
private Collection<RateioCustoItem> rateioCustoItems;
@OneToMany(mappedBy = "produto")
@JsonIgnore
private Collection<TabPrecoItem> tabPrecoItems;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Produto produto = (Produto) o;
return Objects.equals(id, produto.id) &&
Objects.equals(cdProduto, produto.cdProduto) &&
Objects.equals(dsProduto, produto.dsProduto) &&
Objects.equals(tpProduto, produto.tpProduto) &&
Objects.equals(stAtivo, produto.stAtivo) &&
Objects.equals(qtBaseestrutura, produto.qtBaseestrutura) &&
Objects.equals(ftConversao, produto.ftConversao) &&
Objects.equals(tpConversao, produto.tpConversao) &&
Objects.equals(dtAtualizacao, produto.dtAtualizacao) &&
Objects.equals(stLote, produto.stLote) &&
Objects.equals(psProduto, produto.psProduto) &&
Objects.equals(vlIpipauta, produto.vlIpipauta) &&
Objects.equals(vlPispauta, produto.vlPispauta) &&
Objects.equals(vlCofpauta, produto.vlCofpauta) &&
Objects.equals(stBloqueado, produto.stBloqueado) &&
Objects.equals(nrNcm, produto.nrNcm) &&
Objects.equals(cdSegum, produto.cdSegum) &&
Objects.equals(psBruto, produto.psBruto) &&
Objects.equals(dsOrigem, produto.dsOrigem) &&
Objects.equals(qtMultiplicador, produto.qtMultiplicador) &&
Objects.equals(cdEan, produto.cdEan);
}
@Override
public int hashCode() {
return Objects.hash(id, cdProduto, dsProduto, tpProduto, stAtivo, qtBaseestrutura, ftConversao, tpConversao, dtAtualizacao, stLote, psProduto, vlIpipauta, vlPispauta, vlCofpauta, stBloqueado, nrNcm, cdSegum, psBruto, dsOrigem, qtMultiplicador, cdEan);
}
}
| [
"[email protected]"
] | |
d9eff5c9eb7dddf4d0f9a444c5e9218c329cfd4e | a55949397e31f0f85583f464c25e3c5dbaada246 | /springsecurity-06-smscode/src/main/java/com/springboot/security/handler/CustomAuthenticationFailureHandler.java | a808f65e0ec3508be4b797366ef5c2e433f0ee6d | [] | no_license | Dawei-Fang/SpringBoot-SpringSecurity | 3abdfb08416e33e8c6fb0b88eac22af5ae7b50f6 | ea630d0fe03b87f2eed708368571bd932334d959 | refs/heads/master | 2022-12-26T13:08:09.177618 | 2020-10-15T14:22:51 | 2020-10-15T14:22:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,507 | java | package com.springboot.security.handler;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* @author Louis
* @title: CustomAuthenticationFailureHandler
* @projectName springboot-chapter
* @description: TODO 验证失败处理
* @date 2019/7/5 19:49
*/
@Component
@Slf4j
public class CustomAuthenticationFailureHandler implements AuthenticationFailureHandler {
@Autowired
private ObjectMapper objectMapper;
@Override
public void onAuthenticationFailure(HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
log.info("登陆失败");
httpServletResponse.setStatus(HttpStatus.INTERNAL_SERVER_ERROR.value());
httpServletResponse.setContentType("application/json;charset=UTF-8");
httpServletResponse.getWriter().write(objectMapper.writeValueAsString(e.getMessage()));
}
}
| [
"[email protected]"
] | |
39c3f508549ced933e898c46ad2ab4db84f62fa5 | a7d2ad5a6b170cdd31407c82f2d5453aa0c3e9fa | /src/main/java/bgroup/ccard/api/model/CardBalance.java | e0abac98a6ac240ebc373f8928ba2a6cac095dfe | [] | no_license | vsb2007/CCardApi | 7d9e55c18e457f073efbd69289c9ff2fcf437615 | 76acbf50f90e4704935c57123116c2f1f7cb35c0 | refs/heads/master | 2021-11-11T02:50:34.424378 | 2021-11-07T13:18:27 | 2021-11-07T13:18:27 | 103,365,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 659 | java | package bgroup.ccard.api.model;
/**
* Created by VSB on 11.09.2017.
* ccardApi
*/
public class CardBalance {
private String cardNumber;
private Double balance;
public CardBalance(String cardNumber, Double balance) {
this.cardNumber = cardNumber;
this.balance = balance;
}
public CardBalance() {
}
public String getCardNumber() {
return cardNumber;
}
public void setCardNumber(String cardNumber) {
this.cardNumber = cardNumber;
}
public Double getBalance() {
return balance;
}
public void setBalance(Double balance) {
this.balance = balance;
}
}
| [
"[email protected]"
] | |
97cd87546947cbcb2d09e581fb638db00d9691c1 | 1c94134f0fb6392cb38b3f91c93d4799ce3b92c5 | /05 - TypeCheck/Atividade 5/src/test/resources/LinkedList.java | c5b3bd47e42cf82548a8ccff03d3e9edc3be0b06 | [] | no_license | rpss2/Compiladores-IF688 | 07d57b10b8157fbf76d4aa11fa1bd8789585b24f | fdd07ddbe037c13ac44b068beacca1ee71a71894 | refs/heads/master | 2021-04-15T13:17:39.648503 | 2018-06-22T20:34:36 | 2018-06-22T20:34:36 | 126,556,754 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,492 | java | //package test.resources;
class LinkedList{
public static void main(String[] a){
System.out.println(new LL().Start());
}
}
class Element {
int Age ;
int Salary ;
boolean Married ;
// Initialize some class variables
public boolean Init(int v_Age, int v_Salary, boolean v_Married){
Age = v_Age ;
Salary = v_Salary ;
Married = v_Married ;
return true ;
}
public int GetAge(){
return Age ;
}
public int GetSalary(){
return Salary ;
}
public boolean GetMarried(){
return Married ;
}
// This method returns true if the object "other"
// has the same values for age, salary and
public boolean Equal(Element other){
boolean ret_val ;
int aux01 ;
int aux02 ;
int nt ;
ret_val = true ;
aux01 = other.GetAge();
if (!this.Compare(aux01,Age)) ret_val = false ;
else {
aux02 = other.GetSalary();
if (!this.Compare(aux02,Salary)) ret_val = false ;
else
if (Married)
if (!other.GetMarried()) ret_val = false;
else nt = 0 ;
else
if (other.GetMarried()) ret_val = false;
else nt = 0 ;
}
return ret_val ;
}
// This method compares two integers and
// returns true if they are equal and false
// otherwise
public boolean Compare(int num1 , int num2){
boolean retval ;
int aux02 ;
retval = false ;
aux02 = num2 + 1 ;
if (num1 < num2) retval = false ;
else if (!(num1 < aux02)) retval = false ;
else retval = true ;
return retval ;
}
}
class List{
Element elem ;
List next ;
boolean end ;
// Initialize the node list as the last node
public boolean Init(){
end = true ;
return true ;
}
// Initialize the values of a new node
public boolean InitNew(Element v_elem, List v_next, boolean v_end){
end = v_end ;
elem = v_elem ;
next = v_next ;
return true ;
}
// Insert a new node at the beginning of the list
public List Insert(Element new_elem){
boolean ret_val ;
List aux03 ;
List aux02 ;
aux03 = this ;
aux02 = new List();
ret_val = aux02.InitNew(new_elem,aux03,false);
return aux02 ;
}
// Update the the pointer to the next node
public boolean SetNext(List v_next){
next = v_next ;
return true ;
}
// Delete an element e from the list
public List Delete(Element e){
List my_head ;
boolean ret_val ;
boolean aux05;
List aux01 ;
List prev ;
boolean var_end ;
Element var_elem ;
int aux04 ;
int nt ;
my_head = this ;
ret_val = false ;
aux04 = 0 - 1 ;
aux01 = this ;
prev = this ;
var_end = end;
var_elem = elem ;
while ((!var_end) && (!ret_val)){
if (e.Equal(var_elem)){
ret_val = true ;
if (aux04 < 0) {
// delete first element
my_head = aux01.GetNext() ;
}
else{ // delete a non first element
System.out.println(0-555);
aux05 = prev.SetNext(aux01.GetNext());
System.out.println(0-555);
}
} else nt = 0 ;
if (!ret_val){
prev = aux01 ;
aux01 = aux01.GetNext() ;
var_end = aux01.GetEnd();
var_elem = aux01.GetElem();
aux04 = 1 ;
} else nt = 0 ;
}
return my_head ;
}
// Search for an element e on the list
public int Search(Element e){
int int_ret_val ;
List aux01 ;
Element var_elem ;
boolean var_end ;
int nt ;
int_ret_val = 0 ;
aux01 = this ;
var_end = end;
var_elem = elem ;
while (!var_end){
if (e.Equal(var_elem)){
int_ret_val = 1 ;
}
else nt = 0 ;
aux01 = aux01.GetNext() ;
var_end = aux01.GetEnd();
var_elem = aux01.GetElem();
}
return int_ret_val ;
}
public boolean GetEnd(){
return end ;
}
public Element GetElem(){
return elem ;
}
public List GetNext(){
return next ;
}
// Print the linked list
public boolean Print(){
List aux01 ;
boolean var_end ;
Element var_elem ;
aux01 = this ;
var_end = end ;
var_elem = elem ;
while (!var_end){
System.out.println(var_elem.GetAge());
aux01 = aux01.GetNext() ;
var_end = aux01.GetEnd();
var_elem = aux01.GetElem();
}
return true ;
}
}
// this class invokes the methods to insert, delete,
// search and print the linked list
class LL{
public int Start(){
List head ;
List last_elem ;
boolean aux01 ;
Element el01 ;
Element el02 ;
Element el03 ;
last_elem = new List();
aux01 = last_elem.Init();
head = last_elem ;
aux01 = head.Init();
aux01 = head.Print();
// inserting first element
el01 = new Element();
aux01 = el01.Init(25,37000,false);
head = head.Insert(el01);
aux01 = head.Print();
System.out.println(10000000);
// inserting second element
el01 = new Element();
aux01 = el01.Init(39,42000,true);
el02 = el01 ;
head = head.Insert(el01);
aux01 = head.Print();
System.out.println(10000000);
// inserting third element
el01 = new Element();
aux01 = el01.Init(22,34000,false);
head = head.Insert(el01);
aux01 = head.Print();
el03 = new Element();
aux01 = el03.Init(27,34000,false);
System.out.println(head.Search(el02));
System.out.println(head.Search(el03));
System.out.println(10000000);
// inserting fourth element
el01 = new Element();
aux01 = el01.Init(28,35000,false);
head = head.Insert(el01);
aux01 = head.Print();
System.out.println(2220000);
head = head.Delete(el02);
aux01 = head.Print();
System.out.println(33300000);
head = head.Delete(el01);
aux01 = head.Print();
System.out.println(44440000);
return 0 ;
}
}
| [
"[email protected]"
] | |
d6dedc91e6321badc35b3a91ecf74f9dbf676853 | ced34ada1724457ddd553e205311509637eb3d84 | /src/Player.java | 12f7fb06e75a4157b2c073dc66f6e1a2068a8856 | [] | no_license | ag8731/Rack-O-Design-Project | 1d2a63e01fc70d1b31e036725467eab0f7115328 | fe4f926425c9c518a1b3cb4076574d5a5ed3872f | refs/heads/master | 2020-12-25T13:23:16.089369 | 2015-02-20T16:19:20 | 2015-02-20T16:19:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 972 | java | import java.util.ArrayList;
public class Player {
private ArrayList<Integer> hand;
private ArrayList<Integer> rack;
private int score = 0;
public Player(ArrayList<Integer> h, ArrayList<Integer> r, int s){
hand=h; //the value to player is currently waiting to swap or discard
rack=r; //the ten cards in front of a player
score=s;
}
private int drawDraw(){
//draw from the draw stack
hand.add(draw.pop());
}
private int drawDiscard(){
//draw from the discard stack
hand.add(discard.pop());
}
private void swap(){
//changes desired card in rack with card in hand
}
private int discardHand(){
//put unwantted card on top of discard pile
discard.push(hand.remove(0));
}
private boolean rackO(){
//check to see if a player has "RACK-O" (ascending number array list)
}
private int sumScore(){
//adds player's hand score at end of each round with total score
}
private int getScore(){
//shows current player score
return score;
}
}
| [
"[email protected]"
] | |
886e5854cb434d7b0cb90009030276add11ead31 | 4699a2417bb8898c642dba0fc652c323b96da061 | /13_java/src/application/Zabky.java | e25348c8b2101e1c6912d64b00d1e4debd25645a | [] | no_license | CaptSkallz/Java2019 | 94fe86e4048d8b2963db2e95ba13859f1cc3f92b | 2d44466123b73ba38cfefe2489036ffc712609d7 | refs/heads/master | 2020-09-17T10:54:33.430101 | 2019-05-14T19:59:06 | 2019-05-14T19:59:06 | 224,080,426 | 1 | 0 | null | 2019-11-26T02:01:08 | 2019-11-26T02:01:08 | null | UTF-8 | Java | false | false | 5,611 | java | package application;
import javafx.animation.AnimationTimer;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
public class Zabky extends Application {
final double rychlostSimulacie = 10; // ms
final double horizontalnyPosun = 1; // pixel
// brvno sa posunie o 1 pixel za 10 ms
final double velkostZabky = 50; // pixel
final double sirkaBrvna = 15; // pixel
long lastTimeUpdated;
Brvno[][] brvna = { // predpripravene brvna, nemusite generovat
{ new Brvno(10,80, true), new Brvno(200,90, true), new Brvno(400,80, true), new Brvno(600,90, true) },
{ new Brvno(10,120, false), new Brvno(250,110, false), new Brvno(470,80, false) },
{ new Brvno(25,60, true), new Brvno(220,40, true), new Brvno(430,50, true), new Brvno(620,60, true), new Brvno(720,40, true) },
{ new Brvno(10,80, false), new Brvno(400,50, false), new Brvno(600,80, false) },
{ new Brvno(30,80, true), new Brvno(170,30, true), new Brvno(330,40, true), new Brvno(500,60, true) },
{ new Brvno(20,60, false), new Brvno(220,40, false), new Brvno(400,40, false), new Brvno(500,50, false) }
};
Playground playground;
Zabka zabka;
int newGame = 0;
@Override
public void start(Stage primaryStage) {
try {
playground = new Playground();
AnimationTimer at = new AnimationTimer() {
@Override
public void handle(long now) {
//System.out.println("zabka sedi na " + zabka.x + ":" + zabka.y + " az " + zabka.x+velkostZabky + ":" + zabka.y + velkostZabky);
if (now/1000000 > lastTimeUpdated/1000000 + rychlostSimulacie) {
//System.out.println("jo");
playground.update();
playground.paintPlayground();
}
}
};
at.start();
Scene scene = new Scene(playground, 800, 600);
zabka = new Zabka();
scene.setOnKeyPressed(event -> {
if (event.getCode() == KeyCode.DOWN) {
zabka.skok(false);
}
else if (event.getCode() == KeyCode.UP){
zabka.skok(true);
}
for (int i = 0; i < brvna.length; i++) {
for (int j = 0; j < brvna[i].length; j++) {
Brvno b = brvna[i][j];
// System.out.println(Math.abs((b.x + b.dlzka/2) - (zabka.x + velkostZabky/2)));
// System.out.println(Math.abs((i+2)*75+10 - (zabka.y + velkostZabky)));
// Math.abs((b.x + b.dlzka/2) - (zabka.x + velkostZabky/2)) <= b.dlzka/2
// && Math.abs((i+2)*75+10 - (zabka.y + velkostZabky)) <= 20
if (b.x <= zabka.x + velkostZabky/2 && zabka.x + velkostZabky/2 <= b.x+b.dlzka
&& ((i+2)*75 <= zabka.y && zabka.y <= (i+2)*75 + 20) ) {
zabka.sittingOnALog = true;
zabka.log = b;
System.out.println("nasiel som log");
break;
}
}
}
});
primaryStage.setScene(scene);
primaryStage.show();
} catch(Exception e) {
e.printStackTrace();
}
}
//---------------------------------------------------
public class Brvno {
double x; // lavy koniec brvna
double dlzka; // jeho dlzka
boolean doPrava; // ide doprava/dolava
public Brvno(double x, double dlzka, boolean doPrava) {
this.x = x; this.dlzka = dlzka; this.doPrava = doPrava;
}
// public void paint(int riadok) {
// // ...
// }
public void update() {
if (doPrava) {
this.x += horizontalnyPosun;
}
else {
this.x -= horizontalnyPosun;
}
}
}
//---------------------------------------------------
public class Zabka {
public double x=400;
public double y=600;
boolean sittingOnALog = false;
Brvno log;
// public void paint() {
// // ...
// }
public void update() {
if (sittingOnALog) {
if (log.doPrava) {
x += horizontalnyPosun;
}
else {
x -= horizontalnyPosun;
}
}
}
public void skok(boolean hore) {
if (hore) {
y -= 75;
}
else {
y += 75;
}
}
}
//---------------------------------------------------
public class Playground extends Pane {
public void update(){
for (int i = 0; i < brvna.length; i++) {
for (int j = 0; j < brvna[i].length; j++) {
brvna[i][j].update();
//if (//zab)
}
}
zabka.update();
}
public void paintPlayground() {
getChildren().clear();
for (int i = 0; i < brvna.length; i++) {
for (int j = 0; j < brvna[i].length; j++) {
Brvno b = brvna[i][j];
Line lb = new Line(b.x, (i+2)*75, b.x + b.dlzka, (i+2)*75);
lb.setStrokeWidth(20);
lb.setStroke(Color.BLACK);
getChildren().add(lb);
//if (b.x)
}
}
Image img = new Image("zaba.png");
ImageView iv = new ImageView(img);
iv.setX(zabka.x-velkostZabky);
iv.setY(zabka.y-velkostZabky);
iv.setFitWidth(velkostZabky);
iv.setPreserveRatio(true);
getChildren().add(iv);
}
}
public static void main(String[] args) {
launch(args);
}
} | [
"[email protected]"
] | |
f53e8551601698133b576d67227955d2181ce8c8 | afddfc1c0e485cf2d031637a6ec6a263aafdc171 | /src/main/java/com/example/wangwangweather/WeatherActivity.java | 1961e6b7125dc6081cdf3dc53a51ab9bed522231 | [] | no_license | MarshMarline/wangwangweather | 3776a3f937e0eaaf7b4fc5101873850a3b9cccd6 | b03420a249473737abbc6322a9e2a6500ecbb18f | refs/heads/master | 2023-02-01T16:07:27.987641 | 2020-12-26T06:16:20 | 2020-12-26T06:16:20 | 316,679,528 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,157 | java | package com.example.wangwangweather;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.view.GravityCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bumptech.glide.Glide;
import com.example.wangwangweather.R;
import com.example.wangwangweather.gson.Forecast;
import com.example.wangwangweather.gson.Weather;
import com.example.wangwangweather.service.AutoUpdateService;
import com.example.wangwangweather.util.HttpUtil;
import com.example.wangwangweather.util.Utility;
import java.io.IOException;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.Response;
public class WeatherActivity extends AppCompatActivity {
public DrawerLayout drawerLayout;
private Button navButton;
public SwipeRefreshLayout swipeRefresh;
private ScrollView weatherLayout;
private TextView titleCity;
private TextView titleUpdateTime;
private TextView degreeText;
private TextView weatherInfoText;
private LinearLayout forecastLayout;
private TextView aqiText;
private TextView pm25Text;
private TextView comfortText;
private TextView carWashText;
private TextView sportText;
private ImageView bingPicImg;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_weather);
//滑动菜单
drawerLayout=findViewById(R.id.drawer_layout);
navButton=findViewById(R.id.nav_button);
navButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
drawerLayout.openDrawer(GravityCompat.START);
}
});
//状态栏
if(Build.VERSION.SDK_INT>=21){
View decorView=getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
//初始化各控件
weatherLayout=findViewById(R.id.weather_layout);
titleCity=findViewById(R.id.title_city);
titleUpdateTime=findViewById(R.id.title_update_time);
degreeText=findViewById(R.id.degree_text);
weatherInfoText=findViewById(R.id.weather_info_text);
forecastLayout=findViewById(R.id.forecast_layout);
aqiText=findViewById(R.id.aqi_text);
pm25Text=findViewById(R.id.pm25_text);
comfortText=findViewById(R.id.comfort_text);
carWashText=findViewById(R.id.car_wash_text);
sportText=findViewById(R.id.sport_text);
swipeRefresh=findViewById(R.id.swipe_refresh);
swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
SharedPreferences prefs= PreferenceManager.getDefaultSharedPreferences(this);
String weatherString=prefs.getString("weather",null);
final String weatherId;
if (weatherString!=null){
//有缓存时直接解析天气数据
Weather weather= Utility.handleWeatherResponse(weatherString);
weatherId=weather.basic.weatherId;
showWeatherInfo(weather);
}else {
//无缓存时去服务器查询天气
weatherId=getIntent().getStringExtra("weather_id");
weatherLayout.setVisibility(View.INVISIBLE);
requestWeather(weatherId);
}
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
requestWeather(weatherId);
}
});
bingPicImg=findViewById(R.id.bing_pic_img);
String bingPic=prefs.getString("bing_pic",null);
if(bingPic!=null){
Glide.with(this).load(bingPic).into(bingPicImg);
}else {
loadBingPic();
}
}
/**
* 根据天气id请求城市天气信息
*/
public void requestWeather(final String weatherId){
String weatherUrl="http://guolin.tech/api/weather?cityid="+weatherId+"&key=";//a3a928f078314931b6d212e75f4a1dfb
HttpUtil.sendOkHttpRequest(weatherUrl, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(WeatherActivity.this,"获取天气信息失败",Toast.LENGTH_SHORT).show();
swipeRefresh.setRefreshing(false);
}
});
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String responseText=response.body().string();
final Weather weather=Utility.handleWeatherResponse(responseText);
runOnUiThread(new Runnable() {
@Override
public void run() {
if(weather!=null && "ok".equals(weather.status)){
SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(WeatherActivity.this).edit();
editor.putString("weather",responseText);
editor.apply();
showWeatherInfo(weather);
}else {
Toast.makeText(WeatherActivity.this,"获取天气信息失败",Toast.LENGTH_SHORT).show();
}
swipeRefresh.setRefreshing(false);
}
});
}
});
}
/**
* 处理并展示Weather实体类中的数据
*/
private void showWeatherInfo(Weather weather){
String cityName=weather.basic.cityName;
String updateTime=weather.basic.update.updateTime.split(" ")[1];
String degree=weather.now.temperature+"℃";
String weatherInfo=weather.now.mroe.info;
titleCity.setText(cityName);
titleUpdateTime.setText(updateTime);
degreeText.setText(degree);
weatherInfoText.setText(weatherInfo);
forecastLayout.removeAllViews();
for(Forecast forecast:weather.forecastList){
View view = LayoutInflater.from(this).inflate(R.layout.forecast_item,forecastLayout,false);
TextView dateText=view.findViewById(R.id.date_text);
TextView infoText=view.findViewById(R.id.info_text);
TextView maxText=view.findViewById(R.id.max_text);
TextView minText=view.findViewById(R.id.min_text);
dateText.setText(forecast.date);
infoText.setText(forecast.more.info);
maxText.setText(forecast.temperature.max);
minText.setText(forecast.temperature.min);
forecastLayout.addView(view);
}
if(weather.aqi!=null){
aqiText.setText(weather.aqi.city.aqi);
pm25Text.setText(weather.aqi.city.pm25);
}
String comfort="舒适度:"+weather.suggestion.comfort.info;
String carWash="洗车指数:"+weather.suggestion.carWash.info;
String sport="运动建议:"+weather.suggestion.sport.info;
comfortText.setText(comfort);
carWashText.setText(carWash);
sportText.setText(sport);
weatherLayout.setVisibility(View.VISIBLE);
Intent intent=new Intent(this, AutoUpdateService.class);
startService(intent);
}
/**
* 加载必应每日一图
*/
private void loadBingPic(){
String requestBingPic="http://guolin.tech/api/bing_pic";
HttpUtil.sendOkHttpRequest(requestBingPic, new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
final String bingPic=response.body().string();
SharedPreferences.Editor editor=PreferenceManager.getDefaultSharedPreferences(WeatherActivity.this).edit();
editor.putString("bing_pic",bingPic);
editor.apply();
runOnUiThread(new Runnable() {
@Override
public void run() {
Glide.with(WeatherActivity.this).load(bingPic).into(bingPicImg);
}
});
}
});
}
}
| [
"[email protected]"
] | |
515c3e93f681e8fba5bf42e99aaee37b26d386ed | c4aca4156c8c0b6e6afb57d8fbe2e77571947553 | /src/test/java/it/io/openliberty/guides/rest/ARegisterTest.java | 772d5108babbf9206eabc730537dafa587b1384e | [] | no_license | EmotionalLove/SMS_x_Discord_Web | 681fceade4c8a18446399b8bc0c711e4dcaea86c | e7127d5938f981d95db857dc0df1f08ad18b9d57 | refs/heads/master | 2020-05-07T15:00:11.007274 | 2019-04-11T08:46:52 | 2019-04-11T08:46:52 | 180,618,594 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 722 | java | // tag::comment[]
/*******************************************************************************
* Copyright (c) 2017 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
// end::comment[]
package it.io.openliberty.guides.rest;
import org.junit.Test;
public class ARegisterTest {
@Test
public void testGetProperties() {
}
}
| [
"[email protected]"
] | |
2e3b365ba5c6db77f9c7a692d99081ab71c0dd1b | b506b4b9963aeb3b4fa06e6f9bae19f8ffc9430f | /app/src/main/java/com/example/lenovo/scsxapp/util/Utility.java | 7ce28d250ee33c1ff6a2b613c2acf59e2761fb63 | [
"Apache-2.0"
] | permissive | CXBEBE/scsxweather | d2da728b7040702aa373368d4480271e5ff13c29 | 2bf708d4b55cbd552c6f34e768a807a947e971b3 | refs/heads/master | 2021-01-22T13:26:22.796597 | 2017-08-21T06:58:50 | 2017-08-21T06:58:50 | 100,660,326 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,446 | java | package com.example.lenovo.scsxapp.util;
import android.text.TextUtils;
import com.example.lenovo.scsxapp.db.City;
import com.example.lenovo.scsxapp.db.County;
import com.example.lenovo.scsxapp.db.Province;
import com.example.lenovo.scsxapp.gson.Weather;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
/**
* Created by lenovo on 2017/8/18.
*/
public class Utility {
//解析和处理服务器返回的省级数据
public static boolean handleProvinceResponse(String response){
if(!TextUtils.isEmpty(response)){
try{
JSONArray allProvinces=new JSONArray(response);
for (int i=0;i<allProvinces.length();i++){
JSONObject provinceObject=allProvinces.getJSONObject(i);
Province province=new Province();
province.setProvinceName(provinceObject.getString("name"));
province.setProvinceCode(provinceObject.getInt("id"));
province.save();
}
return true;
}catch (JSONException e){
e.printStackTrace();
}
}
return false;
}
//解析和处理服务器返回的市级数据
public static boolean handleCityResponse(String response,int provinceId){
if(!TextUtils.isEmpty(response)){
try{
JSONArray allCities=new JSONArray(response);
for (int i=0;i<allCities.length();i++){
JSONObject cityObject=allCities.getJSONObject(i);
City city=new City();
city.setCityName(cityObject.getString("name"));
city.setCityCode(cityObject.getInt("id"));
city.setProvinceId(provinceId);
city.save();
}
return true;
}catch (JSONException e){
e.printStackTrace();
}
}
return false;
}
//解析和处理服务器返回的县级数据
public static boolean handleCountyResponse(String response,int cityId){
if(!TextUtils.isEmpty(response)){
try{
JSONArray allCounties=new JSONArray(response);
for (int i=0;i<allCounties.length();i++){
JSONObject countyObject=allCounties.getJSONObject(i);
County county=new County();
county.setCountyName(countyObject.getString("name"));
county.setWeatherId(countyObject.getString("weather_id"));
county.setCityId(cityId);
county.save();
}
return true;
}catch (JSONException e){
e.printStackTrace();
}
}
return false;
}
//将返回的JSON数据解析成Weather实体类
public static Weather handleWeatherResponse(String response){
try{
JSONObject jsonObject=new JSONObject(response);
JSONArray jsonArray=jsonObject.getJSONArray("HeWeather");
String weatherContent=jsonArray.getJSONObject(0).toString();
return new Gson().fromJson(weatherContent,Weather.class);
}catch(Exception e){
e.printStackTrace();
}
return null;
}
}
| [
"[email protected]"
] | |
9f45b2b778319c42ad64a323c0aed7045d2657a5 | 6bfb25c006e8d66b3b3225d7e474569e4d81cb99 | /app/src/test/java/com/zhaolongzhong/todo/ExampleUnitTest.java | 1e8137293f4236ae3d5f17475bbd8632d9b35c63 | [
"Apache-2.0"
] | permissive | eclipsegst/android-todo | b086ec8bc047d5e0e0a6cf8e141d281a8226e2c0 | ddfedb294218099eb8b1d7cf9a6a74e9d53bd0ed | refs/heads/master | 2021-03-19T11:30:22.671150 | 2016-07-14T06:20:16 | 2016-07-14T06:20:16 | 60,567,592 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | package com.zhaolongzhong.todo;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
4558685b99d544cbf12326209a2d27139496f650 | bd4f65d667e2b7f9b5fb7fa1cf797035119a2e56 | /project/LibIntegracion/src/com/utez/integracion/dao/TipoBajaJpaController.java | 0c4feebdd7ead811e3dd3cf08f2febfa32b8ae90 | [] | no_license | angellagunas/MigracionBD | 13bdc27355e0436ecb0f49f4f13fa965462de5ff | 96552a4022bbfb0039225ae70ba3987f63eee7d9 | refs/heads/master | 2021-03-27T16:09:06.819932 | 2014-07-23T14:17:53 | 2014-07-23T14:17:53 | 22,110,124 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,355 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.utez.integracion.dao;
import com.utez.integracion.dao.exceptions.NonexistentEntityException;
import java.io.Serializable;
import javax.persistence.Query;
import javax.persistence.EntityNotFoundException;
import com.utez.integracion.entity.SolicitudBaja;
import com.utez.integracion.entity.TipoBaja;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.transaction.UserTransaction;
/**
*
* @author Sergio
*/
public class TipoBajaJpaController implements Serializable {
public TipoBajaJpaController(UserTransaction utx, EntityManagerFactory emf) {
this.utx = utx;
this.emf = emf;
}
private UserTransaction utx = null;
private EntityManagerFactory emf = null;
public EntityManager getEntityManager() {
return emf.createEntityManager();
}
public void create(TipoBaja tipoBaja) {
if (tipoBaja.getSolicitudBajaList() == null) {
tipoBaja.setSolicitudBajaList(new ArrayList<SolicitudBaja>());
}
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
List<SolicitudBaja> attachedSolicitudBajaList = new ArrayList<SolicitudBaja>();
for (SolicitudBaja solicitudBajaListSolicitudBajaToAttach : tipoBaja.getSolicitudBajaList()) {
solicitudBajaListSolicitudBajaToAttach = em.getReference(solicitudBajaListSolicitudBajaToAttach.getClass(), solicitudBajaListSolicitudBajaToAttach.getIdSolicitudbaja());
attachedSolicitudBajaList.add(solicitudBajaListSolicitudBajaToAttach);
}
tipoBaja.setSolicitudBajaList(attachedSolicitudBajaList);
em.persist(tipoBaja);
for (SolicitudBaja solicitudBajaListSolicitudBaja : tipoBaja.getSolicitudBajaList()) {
TipoBaja oldIdTipobajaOfSolicitudBajaListSolicitudBaja = solicitudBajaListSolicitudBaja.getIdTipobaja();
solicitudBajaListSolicitudBaja.setIdTipobaja(tipoBaja);
solicitudBajaListSolicitudBaja = em.merge(solicitudBajaListSolicitudBaja);
if (oldIdTipobajaOfSolicitudBajaListSolicitudBaja != null) {
oldIdTipobajaOfSolicitudBajaListSolicitudBaja.getSolicitudBajaList().remove(solicitudBajaListSolicitudBaja);
oldIdTipobajaOfSolicitudBajaListSolicitudBaja = em.merge(oldIdTipobajaOfSolicitudBajaListSolicitudBaja);
}
}
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public void edit(TipoBaja tipoBaja) throws NonexistentEntityException, Exception {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
TipoBaja persistentTipoBaja = em.find(TipoBaja.class, tipoBaja.getIdTipobaja());
List<SolicitudBaja> solicitudBajaListOld = persistentTipoBaja.getSolicitudBajaList();
List<SolicitudBaja> solicitudBajaListNew = tipoBaja.getSolicitudBajaList();
List<SolicitudBaja> attachedSolicitudBajaListNew = new ArrayList<SolicitudBaja>();
for (SolicitudBaja solicitudBajaListNewSolicitudBajaToAttach : solicitudBajaListNew) {
solicitudBajaListNewSolicitudBajaToAttach = em.getReference(solicitudBajaListNewSolicitudBajaToAttach.getClass(), solicitudBajaListNewSolicitudBajaToAttach.getIdSolicitudbaja());
attachedSolicitudBajaListNew.add(solicitudBajaListNewSolicitudBajaToAttach);
}
solicitudBajaListNew = attachedSolicitudBajaListNew;
tipoBaja.setSolicitudBajaList(solicitudBajaListNew);
tipoBaja = em.merge(tipoBaja);
for (SolicitudBaja solicitudBajaListOldSolicitudBaja : solicitudBajaListOld) {
if (!solicitudBajaListNew.contains(solicitudBajaListOldSolicitudBaja)) {
solicitudBajaListOldSolicitudBaja.setIdTipobaja(null);
solicitudBajaListOldSolicitudBaja = em.merge(solicitudBajaListOldSolicitudBaja);
}
}
for (SolicitudBaja solicitudBajaListNewSolicitudBaja : solicitudBajaListNew) {
if (!solicitudBajaListOld.contains(solicitudBajaListNewSolicitudBaja)) {
TipoBaja oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja = solicitudBajaListNewSolicitudBaja.getIdTipobaja();
solicitudBajaListNewSolicitudBaja.setIdTipobaja(tipoBaja);
solicitudBajaListNewSolicitudBaja = em.merge(solicitudBajaListNewSolicitudBaja);
if (oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja != null && !oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja.equals(tipoBaja)) {
oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja.getSolicitudBajaList().remove(solicitudBajaListNewSolicitudBaja);
oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja = em.merge(oldIdTipobajaOfSolicitudBajaListNewSolicitudBaja);
}
}
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Long id = tipoBaja.getIdTipobaja();
if (findTipoBaja(id) == null) {
throw new NonexistentEntityException("The tipoBaja with id " + id + " no longer exists.");
}
}
throw ex;
} finally {
if (em != null) {
em.close();
}
}
}
public void destroy(Long id) throws NonexistentEntityException {
EntityManager em = null;
try {
em = getEntityManager();
em.getTransaction().begin();
TipoBaja tipoBaja;
try {
tipoBaja = em.getReference(TipoBaja.class, id);
tipoBaja.getIdTipobaja();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tipoBaja with id " + id + " no longer exists.", enfe);
}
List<SolicitudBaja> solicitudBajaList = tipoBaja.getSolicitudBajaList();
for (SolicitudBaja solicitudBajaListSolicitudBaja : solicitudBajaList) {
solicitudBajaListSolicitudBaja.setIdTipobaja(null);
solicitudBajaListSolicitudBaja = em.merge(solicitudBajaListSolicitudBaja);
}
em.remove(tipoBaja);
em.getTransaction().commit();
} finally {
if (em != null) {
em.close();
}
}
}
public List<TipoBaja> findTipoBajaEntities() {
return findTipoBajaEntities(true, -1, -1);
}
public List<TipoBaja> findTipoBajaEntities(int maxResults, int firstResult) {
return findTipoBajaEntities(false, maxResults, firstResult);
}
private List<TipoBaja> findTipoBajaEntities(boolean all, int maxResults, int firstResult) {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery("select object(o) from TipoBaja as o");
if (!all) {
q.setMaxResults(maxResults);
q.setFirstResult(firstResult);
}
return q.getResultList();
} finally {
em.close();
}
}
public TipoBaja findTipoBaja(Long id) {
EntityManager em = getEntityManager();
try {
return em.find(TipoBaja.class, id);
} finally {
em.close();
}
}
public int getTipoBajaCount() {
EntityManager em = getEntityManager();
try {
Query q = em.createQuery("select count(o) from TipoBaja as o");
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
}
| [
"[email protected]"
] | |
1cdc4617a8dee06603b4506d06b5bc129b519829 | 098b6cd2fd41900af8b3dddea98f477141421306 | /payment-service/src/main/java/com/example/demo/service/PaymentService.java | 19f33f2f358d9239536e4083c33b5a618920e94e | [] | no_license | nikithakaluvagadda/Project | 746bbbf5a923dbe44d59af20615368b1bfc7584b | 84299f50536bb9d5a69891d768b5fd55cc98795c | refs/heads/main | 2023-06-19T01:37:58.489450 | 2021-07-20T02:12:59 | 2021-07-20T02:12:59 | 385,343,640 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,582 | java | package com.example.demo.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.*;
import com.example.demo.entity.Payment;
import com.example.demo.repos.PaymentRepository;
@Service
public class PaymentService {
@Autowired
private PaymentRepository repo;
public List<Payment> getAll(){
return this.repo.findAll();
}
public Payment add( Payment entity) {
return this.repo.save(entity);
}
public Payment update( Payment entity) {
return this.repo.save(entity);
}
public Payment remove(Payment entity) {
Optional<Payment> found=this.repo.findById(entity.getTxnId());
if(found.isPresent()) {
this.repo.delete(entity);
}else {
throw new NoSuchElementException("Element with that Id not available");
}
return entity;
}
public Payment getById( int Id) {
return this.repo.findById(Id)
.orElseThrow(()-> new NoSuchElementException("Element with that Id available"));
}
public List<Payment> getByDescription(String description){
return this.repo.findByDescriptionEquals(description);
}
public List<Payment> getByAmountGreaterThan(double amount){
return this.repo.findByAmountGreaterThan(amount);
}
public int updateAmount( double amount,int txnId) {
return this.repo.updateAmount(amount, txnId);
}
} | [
"[email protected]"
] | |
860e2652b2696dbeaa3413b09a10089a7ef4569e | fce6b878c9d1e91d6e49d191e7fb8cb2ae7fd23c | /src/main/game/Scissors.java | d0e9264cc72fe6ac40afda041176364e9d3a6bb9 | [] | no_license | Katerina-codes/rock_paper_scissors | 6e31456317d1080ba5b8b97ae0708bf62a855a2d | f3d79686b6bc31729bfd0df033d12ae3022fec5c | refs/heads/master | 2021-05-07T09:48:42.574914 | 2017-11-27T13:34:17 | 2017-11-27T13:34:17 | 109,575,067 | 0 | 0 | null | 2021-11-28T22:57:05 | 2017-11-05T11:53:27 | Java | UTF-8 | Java | false | false | 357 | java | package main.game;
import static main.game.Moves.ROCK;
import static main.game.Moves.SCISSORS;
public class Scissors implements Move {
@Override
public String scoreAgainst(Moves playerTwoMove) {
if (playerTwoMove.equals(ROCK)) {
return ROCK.getMove();
} else {
return SCISSORS.getMove();
}
}
}
| [
"[email protected]"
] | |
9fd824c5e47a4be85816e25ccbf0c707d0e7bf8d | 0f1a73dc0329cead4fa60981c1c1eb141d758a5d | /kfs-parent/core/src/main/java/org/kuali/kfs/module/purap/document/validation/impl/PurchasingAccountsPayableItemConsideredEnteredBranchingValidation.java | 5284621d8704b884098e37f3a628e9899c392917 | [] | no_license | r351574nc3/kfs-maven | 20d9f1a65c6796e623c4845f6d68834c30732503 | 5f213604df361a874cdbba0de057d4cd5ea1da11 | refs/heads/master | 2016-09-06T15:07:01.034167 | 2012-06-01T07:40:46 | 2012-06-01T07:40:46 | 3,441,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,730 | java | /*
* Copyright 2011 The Kuali Foundation.
*
* Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kuali.kfs.module.purap.document.validation.impl;
import org.kuali.kfs.module.purap.businessobject.PurApItem;
import org.kuali.kfs.sys.KFSConstants;
import org.kuali.kfs.sys.document.validation.BranchingValidation;
import org.kuali.kfs.sys.document.validation.event.AttributedDocumentEvent;
public class PurchasingAccountsPayableItemConsideredEnteredBranchingValidation extends BranchingValidation {
public static final String NEEDS_INDIVIDUAL_ITEM_VALIDATION = "needsIndividualItemValidation";
private PurApItem itemForValidation;
@Override
protected String determineBranch(AttributedDocumentEvent event) {
if (itemForValidation.isConsideredEntered()) {
return NEEDS_INDIVIDUAL_ITEM_VALIDATION;
} else {
return KFSConstants.EMPTY_STRING;
}
}
public PurApItem getItemForValidation() {
return itemForValidation;
}
public void setItemForValidation(PurApItem itemForValidation) {
this.itemForValidation = itemForValidation;
}
}
| [
"[email protected]"
] | |
8a3d28152f398312534f4e041d2b69a899568a07 | b473c2f1ccf7b67e3d061a2d11e669c33982e7bf | /apache-batik/sources/org/apache/batik/svggen/font/table/PostTable.java | 23593dfd32d1ab7c43be738e18eede8b3ecb2da7 | [
"Apache-2.0"
] | permissive | eGit/appengine-awt | 4ab046498bad79eddf1f7e74728bd53dc0044526 | 4262657914eceff1fad335190613a272cc60b940 | refs/heads/master | 2021-01-01T15:36:07.658506 | 2015-08-26T11:40:24 | 2015-08-26T11:40:24 | 41,421,915 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,802 | java | /*
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package org.apache.batik.svggen.font.table;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
*
* @author <a href="mailto:[email protected]">David Schweinsberg</a>
* @version $Id: PostTable.java 475685 2006-11-16 11:16:05Z cam $
*/
public class PostTable implements Table {
/**
* TODO: Mac Glyph names for 210 & 257
*/
private static final String[] macGlyphName = {
".notdef", // 0
"null", // 1
"CR", // 2
"space", // 3
"exclam", // 4
"quotedbl", // 5
"numbersign", // 6
"dollar", // 7
"percent", // 8
"ampersand", // 9
"quotesingle", // 10
"parenleft", // 11
"parenright", // 12
"asterisk", // 13
"plus", // 14
"comma", // 15
"hyphen", // 16
"period", // 17
"slash", // 18
"zero", // 19
"one", // 20
"two", // 21
"three", // 22
"four", // 23
"five", // 24
"six", // 25
"seven", // 26
"eight", // 27
"nine", // 28
"colon", // 29
"semicolon", // 30
"less", // 31
"equal", // 32
"greater", // 33
"question", // 34
"at", // 35
"A", // 36
"B", // 37
"C", // 38
"D", // 39
"E", // 40
"F", // 41
"G", // 42
"H", // 43
"I", // 44
"J", // 45
"K", // 46
"L", // 47
"M", // 48
"N", // 49
"O", // 50
"P", // 51
"Q", // 52
"R", // 53
"S", // 54
"T", // 55
"U", // 56
"V", // 57
"W", // 58
"X", // 59
"Y", // 60
"Z", // 61
"bracketleft", // 62
"backslash", // 63
"bracketright", // 64
"asciicircum", // 65
"underscore", // 66
"grave", // 67
"a", // 68
"b", // 69
"c", // 70
"d", // 71
"e", // 72
"f", // 73
"g", // 74
"h", // 75
"i", // 76
"j", // 77
"k", // 78
"l", // 79
"m", // 80
"n", // 81
"o", // 82
"p", // 83
"q", // 84
"r", // 85
"s", // 86
"t", // 87
"u", // 88
"v", // 89
"w", // 90
"x", // 91
"y", // 92
"z", // 93
"braceleft", // 94
"bar", // 95
"braceright", // 96
"asciitilde", // 97
"Adieresis", // 98
"Aring", // 99
"Ccedilla", // 100
"Eacute", // 101
"Ntilde", // 102
"Odieresis", // 103
"Udieresis", // 104
"aacute", // 105
"agrave", // 106
"acircumflex", // 107
"adieresis", // 108
"atilde", // 109
"aring", // 110
"ccedilla", // 111
"eacute", // 112
"egrave", // 113
"ecircumflex", // 114
"edieresis", // 115
"iacute", // 116
"igrave", // 117
"icircumflex", // 118
"idieresis", // 119
"ntilde", // 120
"oacute", // 121
"ograve", // 122
"ocircumflex", // 123
"odieresis", // 124
"otilde", // 125
"uacute", // 126
"ugrave", // 127
"ucircumflex", // 128
"udieresis", // 129
"dagger", // 130
"degree", // 131
"cent", // 132
"sterling", // 133
"section", // 134
"bullet", // 135
"paragraph", // 136
"germandbls", // 137
"registered", // 138
"copyright", // 139
"trademark", // 140
"acute", // 141
"dieresis", // 142
"notequal", // 143
"AE", // 144
"Oslash", // 145
"infinity", // 146
"plusminus", // 147
"lessequal", // 148
"greaterequal", // 149
"yen", // 150
"mu", // 151
"partialdiff", // 152
"summation", // 153
"product", // 154
"pi", // 155
"integral'", // 156
"ordfeminine", // 157
"ordmasculine", // 158
"Omega", // 159
"ae", // 160
"oslash", // 161
"questiondown", // 162
"exclamdown", // 163
"logicalnot", // 164
"radical", // 165
"florin", // 166
"approxequal", // 167
"increment", // 168
"guillemotleft",// 169
"guillemotright",//170
"ellipsis", // 171
"nbspace", // 172
"Agrave", // 173
"Atilde", // 174
"Otilde", // 175
"OE", // 176
"oe", // 177
"endash", // 178
"emdash", // 179
"quotedblleft", // 180
"quotedblright",// 181
"quoteleft", // 182
"quoteright", // 183
"divide", // 184
"lozenge", // 185
"ydieresis", // 186
"Ydieresis", // 187
"fraction", // 188
"currency", // 189
"guilsinglleft",// 190
"guilsinglright",//191
"fi", // 192
"fl", // 193
"daggerdbl", // 194
"middot", // 195
"quotesinglbase",//196
"quotedblbase", // 197
"perthousand", // 198
"Acircumflex", // 199
"Ecircumflex", // 200
"Aacute", // 201
"Edieresis", // 202
"Egrave", // 203
"Iacute", // 204
"Icircumflex", // 205
"Idieresis", // 206
"Igrave", // 207
"Oacute", // 208
"Ocircumflex", // 209
"", // 210
"Ograve", // 211
"Uacute", // 212
"Ucircumflex", // 213
"Ugrave", // 214
"dotlessi", // 215
"circumflex", // 216
"tilde", // 217
"overscore", // 218
"breve", // 219
"dotaccent", // 220
"ring", // 221
"cedilla", // 222
"hungarumlaut", // 223
"ogonek", // 224
"caron", // 225
"Lslash", // 226
"lslash", // 227
"Scaron", // 228
"scaron", // 229
"Zcaron", // 230
"zcaron", // 231
"brokenbar", // 232
"Eth", // 233
"eth", // 234
"Yacute", // 235
"yacute", // 236
"Thorn", // 237
"thorn", // 238
"minus", // 239
"multiply", // 240
"onesuperior", // 241
"twosuperior", // 242
"threesuperior",// 243
"onehalf", // 244
"onequarter", // 245
"threequarters",// 246
"franc", // 247
"Gbreve", // 248
"gbreve", // 249
"Idot", // 250
"Scedilla", // 251
"scedilla", // 252
"Cacute", // 253
"cacute", // 254
"Ccaron", // 255
"ccaron", // 256
"" // 257
};
private int version;
private int italicAngle;
private short underlinePosition;
private short underlineThickness;
private int isFixedPitch;
private int minMemType42;
private int maxMemType42;
private int minMemType1;
private int maxMemType1;
// v2
private int numGlyphs;
private int[] glyphNameIndex;
private String[] psGlyphName;
/** Creates new PostTable */
protected PostTable(DirectoryEntry de, RandomAccessFile raf) throws IOException {
raf.seek(de.getOffset());
version = raf.readInt();
italicAngle = raf.readInt();
underlinePosition = raf.readShort();
underlineThickness = raf.readShort();
isFixedPitch = raf.readInt();
minMemType42 = raf.readInt();
maxMemType42 = raf.readInt();
minMemType1 = raf.readInt();
maxMemType1 = raf.readInt();
if (version == 0x00020000) {
numGlyphs = raf.readUnsignedShort();
glyphNameIndex = new int[numGlyphs];
for (int i = 0; i < numGlyphs; i++) {
glyphNameIndex[i] = raf.readUnsignedShort();
}
int h = highestGlyphNameIndex();
if (h > 257) {
h -= 257;
psGlyphName = new String[h];
for (int i = 0; i < h; i++) {
int len = raf.readUnsignedByte();
byte[] buf = new byte[len];
raf.readFully(buf);
psGlyphName[i] = new String(buf);
}
}
} else if (version == 0x00020005) {
}
}
private int highestGlyphNameIndex() {
int high = 0;
for (int i = 0; i < numGlyphs; i++) {
if (high < glyphNameIndex[i]) {
high = glyphNameIndex[i];
}
}
return high;
}
public String getGlyphName(int i) {
if (version == 0x00020000) {
return (glyphNameIndex[i] > 257)
? psGlyphName[glyphNameIndex[i] - 258]
: macGlyphName[glyphNameIndex[i]];
} else {
return null;
}
}
/** Get the table type, as a table directory value.
* @return The table type
*/
public int getType() {
return post;
}
}
| [
"[email protected]"
] | |
dfd6bdb6934772529f9b7ffee6eea6ad7c4e2009 | fd916e7a517f838d2a3bca759402fc278ed9b488 | /SpringMVC/MavenBase/src/main/java/com/base/config/SecurityConfig.java | 403dd379b9fb5125f834b8e473d896c52e75e034 | [] | no_license | KariR61/JavaEE | cd1258e326e3d83fb7fb7b3a8435fb80fd1f86c8 | c21d54af89f2b26992def0b82493a45a0954dc28 | refs/heads/master | 2021-01-10T15:56:29.436477 | 2016-02-15T12:34:01 | 2016-02-15T12:34:01 | 51,428,734 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,162 | 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.base.config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.UserDetailsService;
@Configuration
@ComponentScan("com.base.service")
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter{
@Autowired
@Qualifier(value="userDetailsService")
UserDetailsService userDetailsService;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
//http.headers().cacheControl().disable();
//http.headers().defaultsDisabled();
System.out.println("CONFIGURE HTTPSECURITY");
http.authorizeRequests().antMatchers("/").permitAll()
.antMatchers("/second").access("hasRole('ROLE_ADMIN')")
.antMatchers("/teacher").access("hasRole('ADMIN') and hasRole('DBA')")
.and().formLogin()
.defaultSuccessUrl("/second")
.loginPage("/login").failureUrl("/login?error")
.usernameParameter("username")
.passwordParameter("password").and()
.logout().logoutSuccessUrl("/login?logout")
.and().csrf()
.and().exceptionHandling().accessDeniedPage("/403");
}
}
| [
"[email protected]"
] | |
e0a1f22ec91ec767890621bddf37784be73c3434 | a96cc23d649caeb906a89c9c5f30c08274598913 | /SpringApp1/src/main/java/hibernate/SpringApp1/model/TextEditor.java | c3004548adfe61e52ed97bd3a22388f5512a45fe | [] | no_license | snehamalav/spring_projects | 742b94e3069c72e41be00b5028edcf735a294aa4 | de7ee5ee52289467402cfedafd5678a350c3b187 | refs/heads/master | 2022-12-20T20:55:58.086243 | 2019-11-14T12:37:56 | 2019-11-14T12:37:56 | 221,212,528 | 0 | 0 | null | 2022-12-16T03:00:09 | 2019-11-12T12:27:18 | Java | UTF-8 | Java | false | false | 499 | java | package hibernate.SpringApp1.model;
public class TextEditor
{
private SpellChecker sc;
public SpellChecker getSc() {
return sc;
}
public void setSc(SpellChecker sc) {
this.sc = sc;
}
/*public TextEditor(SpellChecker sc) {
super();
this.sc=sc; }
*/
/*
public TextEditor(SpellChecker sc) {
super();
this.sc = sc;
}*/
public void display()
{
System.out.println("Writing starts");
sc.checks();
}
}
| [
"[email protected]"
] | |
2371b208252c79ed57ecd3abd6345f5855db69e7 | 8388d3009c0be9cb4e3ea25abbce7a0ad6f9b299 | /business/txnlist/txnlist-api/src/main/java/com/sinosoft/txnlist/api/gisinsurelist/dto/GisHerdFieldListDto.java | 342250f4beed60e276d1494537fff406ed23b461 | [] | no_license | foxhack/NewAgri2018 | a182bd34d0c583a53c30d825d5e2fa569f605515 | be8ab05e0784c6e7e7f46fea743debb846407e4f | refs/heads/master | 2021-09-24T21:58:18.577979 | 2018-10-15T11:24:21 | 2018-10-15T11:24:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,680 | java | package com.sinosoft.txnlist.api.gisinsurelist.dto;
import com.sinosoft.framework.dto.BaseRequest;
import java.io.Serializable;
/**
* 预投保清单农户标的清单明细表(物)Dto
*
* @Author: 何伟东
* @Date: 2018/1/15 16:23
*/
public class GisHerdFieldListDto extends BaseRequest implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 属性清单编号/清单编号
*/
private String insureListCode;
/**
* 属性序列号/序列号
*/
private Integer serialNo;
/**
* 属性农户代码/农户代码
*/
private String fCode;
/**
* 属性标的代码/标的代码
*/
private String itemCode;
/**
* 属性耳标号/脚环号/耳标号/脚环号
*/
private String earLabel;
/**
* 属性养殖地点代码/养殖地点代码
*/
private String breedingAreaCode;
/**
* 属性养殖地点名称/养殖地点名称
*/
private String breedingAreaName;
/**
* 属性养殖品种/养殖品种
*/
private String species;
/**
* 属性畜龄/畜龄
*/
private Double animalAge;
public String getInsureListCode() {
return insureListCode;
}
public void setInsureListCode(String insureListCode) {
this.insureListCode = insureListCode;
}
public Integer getSerialNo() {
return serialNo;
}
public void setSerialNo(Integer serialNo) {
this.serialNo = serialNo;
}
public String getfCode() {
return fCode;
}
public void setfCode(String fCode) {
this.fCode = fCode;
}
public String getItemCode() {
return itemCode;
}
public void setItemCode(String itemCode) {
this.itemCode = itemCode;
}
public String getEarLabel() {
return earLabel;
}
public void setEarLabel(String earLabel) {
this.earLabel = earLabel;
}
public String getBreedingAreaCode() {
return breedingAreaCode;
}
public void setBreedingAreaCode(String breedingAreaCode) {
this.breedingAreaCode = breedingAreaCode;
}
public String getBreedingAreaName() {
return breedingAreaName;
}
public void setBreedingAreaName(String breedingAreaName) {
this.breedingAreaName = breedingAreaName;
}
public String getSpecies() {
return species;
}
public void setSpecies(String species) {
this.species = species;
}
public Double getAnimalAge() {
return animalAge;
}
public void setAnimalAge(Double animalAge) {
this.animalAge = animalAge;
}
}
| [
"[email protected]"
] | |
02bc214fe27ea302c325ee56b5ed99b45368262a | 43cb9c718e016441ddacbbeb92ff4b8e2c95e967 | /src/main/java/gojava/module3/homework/task3/Student.java | 56b98c301b7bc0f769912cfede8d94d0db94a5c7 | [] | no_license | Sheptytskyid/GoJava5 | c6a40a792b5fd1de970454107407d4eca8cac036 | 29231d58e4a190f45e0fb398c584a313572fe637 | refs/heads/master | 2021-01-13T10:48:34.616525 | 2020-02-02T13:05:43 | 2020-02-02T13:05:43 | 72,290,106 | 0 | 0 | null | 2020-10-13T06:48:42 | 2016-10-29T14:38:47 | Java | UTF-8 | Java | false | false | 1,266 | java | package gojava.module3.homework.task3;
public class Student {
private String firstName;
private String lastName;
private int group;
private Course[] coursesTaken;
private int age;
public Student(String firstName, String lastName, int group) {
this.firstName = firstName;
this.lastName = lastName;
this.group = group;
}
public Student(String lastName, Course[] coursesTaken) {
this.lastName = lastName;
this.coursesTaken = coursesTaken;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public int getGroup() {
return group;
}
public int getAge() {
return age;
}
public Course[] getCoursesTaken() {
return coursesTaken;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public void setGroup(int group) {
this.group = group;
}
public void setCoursesTaken(Course[] coursesTaken) {
this.coursesTaken = coursesTaken;
}
public void setAge(int age) {
this.age = age;
}
}
| [
"[email protected]"
] | |
8f02a41aff194d8f0af159ef64904c8f26eec255 | a00326c0e2fc8944112589cd2ad638b278f058b9 | /src/main/java/000/133/971/CWE197_Numeric_Truncation_Error__short_URLConnection_68a.java | d388730c0314fef88ead692fd5f17cf114c512ea | [] | no_license | Lanhbao/Static-Testing-for-Juliet-Test-Suite | 6fd3f62713be7a084260eafa9ab221b1b9833be6 | b095b11c7cb6d4a5bb2b76181e35d6ee00e96e68 | refs/heads/master | 2020-08-24T13:34:04.004149 | 2019-10-25T09:26:00 | 2019-10-25T09:26:00 | 216,822,684 | 0 | 1 | null | 2019-11-08T09:51:54 | 2019-10-22T13:37:13 | Java | UTF-8 | Java | false | false | 4,301 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE197_Numeric_Truncation_Error__short_URLConnection_68a.java
Label Definition File: CWE197_Numeric_Truncation_Error__short.label.xml
Template File: sources-sink-68a.tmpl.java
*/
/*
* @description
* CWE: 197 Numeric Truncation Error
* BadSource: URLConnection Read data from a web server with URLConnection
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* BadSink: to_byte Convert data to a byte
* Flow Variant: 68 Data flow: data passed as a member variable in the "a" class, which is used by a method in another class in the same package
*
* */
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
public class CWE197_Numeric_Truncation_Error__short_URLConnection_68a extends AbstractTestCase
{
public static short data;
public void bad() throws Throwable
{
data = Short.MIN_VALUE; /* Initialize data */
/* read input from URLConnection */
{
URLConnection urlConnection = (new URL("http://www.example.org/")).openConnection();
BufferedReader readerBuffered = null;
InputStreamReader readerInputStream = null;
try
{
readerInputStream = new InputStreamReader(urlConnection.getInputStream(), "UTF-8");
readerBuffered = new BufferedReader(readerInputStream);
/* FLAW: Read data from a web server with URLConnection */
/* This will be reading the first "line" of the response body,
* which could be very long if there are no newlines in the HTML */
String stringNumber = readerBuffered.readLine();
if (stringNumber != null) // avoid NPD incidental warnings
{
try
{
data = Short.parseShort(stringNumber.trim());
}
catch (NumberFormatException exceptNumberFormat)
{
IO.logger.log(Level.WARNING, "Number format exception parsing data from string", exceptNumberFormat);
}
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
}
finally
{
/* clean up stream reading objects */
try
{
if (readerBuffered != null)
{
readerBuffered.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing BufferedReader", exceptIO);
}
try
{
if (readerInputStream != null)
{
readerInputStream.close();
}
}
catch (IOException exceptIO)
{
IO.logger.log(Level.WARNING, "Error closing InputStreamReader", exceptIO);
}
}
}
(new CWE197_Numeric_Truncation_Error__short_URLConnection_68b()).badSink();
}
public void good() throws Throwable
{
goodG2B();
}
/* goodG2B() - use goodsource and badsink */
private void goodG2B() throws Throwable
{
/* FIX: Use a hardcoded number that won't cause underflow, overflow, divide by zero, or loss-of-precision issues */
data = 2;
(new CWE197_Numeric_Truncation_Error__short_URLConnection_68b()).goodG2BSink();
}
/* Below is the main(). It is only used when building this testcase on
* its own for testing or for building a binary to use in testing binary
* analysis tools. It is not used when compiling all the testcases as one
* application, which is how source code analysis tools are tested.
*/
public static void main(String[] args) throws ClassNotFoundException,
InstantiationException, IllegalAccessException
{
mainFromParent(args);
}
}
| [
"[email protected]"
] | |
e316c5d314e691ff3a20349c72b51d86ce3dc1a9 | 805872ac253337a411300317407c6053fdfde981 | /java/ca/blogspot/sjatyourservice/allaboutjharkhand/Google_Location/GetDirectionsData.java | 2d462d012b268140f29b5f2b1e0d748cf75726af | [] | no_license | Mylifewithmyexperiment/ALL-ABOUT-JHARKHAND | f2c9976b9f28421a00a7c29a3c78f95368bba2bc | a8c7b28aec5f878a04e8b9e0b4744498ae33076d | refs/heads/master | 2020-04-15T02:57:05.002764 | 2019-01-06T17:53:30 | 2019-01-06T17:53:30 | 164,330,058 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,957 | java | package ca.blogspot.sjatyourservice.allaboutjharkhand.Google_Location;
import android.graphics.Color;
import android.os.AsyncTask;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.android.PolyUtil;
import java.io.IOException;
import java.util.HashMap;
import ca.blogspot.sjatyourservice.allaboutjharkhand.DownloadUrl;
//this java class has been used for to button function
public class GetDirectionsData extends AsyncTask<Object,String,String> {
GoogleMap mMap;
String url;
String googleDirectionsData;
String duration, distance;
LatLng latLng;
@Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap)objects[0];
url = (String)objects[1];
latLng = (LatLng)objects[2];
DownloadUrl downloadUrl = new DownloadUrl();
try {
googleDirectionsData = downloadUrl.readUrl(url);
} catch (IOException e) {
e.printStackTrace();
}
return googleDirectionsData;
}
@Override
protected void onPostExecute(String s) {
HashMap<String,String> directionsList = null;
DataParser parser = new DataParser();
//directionsList = parser.parseDirections(s);
duration = directionsList.get("duration");
distance = directionsList.get("distance");
mMap.clear();
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.draggable(true);
markerOptions.title("Duration ="+duration);
markerOptions.snippet("Distance = "+distance);
mMap.addMarker(markerOptions);
}
public void displayDirection(String[] directionsList)
{
int count = directionsList.length;
for (int i =0; i<count;i++)
{
PolylineOptions options=new PolylineOptions();
options.color(Color.RED);
options.width(10);
options.addAll(PolyUtil.decode(directionsList[i]));
mMap.addPolyline(options);
}
}
}
/**
import android.graphics.Color;
import android.os.AsyncTask;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.maps.android.PolyUtil;
import java.io.IOException;
import ca.blogspot.sjatyourservice.allaboutjharkhand.Google_Location.DataParser;
import ca.blogspot.sjatyourservice.allaboutjharkhand.DownloadUrl;
public class GetDirectionsData extends AsyncTask<Object,String,String> {
GoogleMap mMap;
String url;
String googleDirectionsData;
String duration, distance;
LatLng latLng;
@Override
protected String doInBackground(Object... objects) {
mMap = (GoogleMap) objects[0];
url = (String) objects[1];
latLng = (LatLng) objects[2];
DownloadUrl downloadUrl = new DownloadUrl();
try {
googleDirectionsData = downloadUrl.readUrl(url);
} catch (IOException e) {
e.printStackTrace();
}
return googleDirectionsData;
}
@Override
protected void onPostExecute(String s) {
//HashMap<String,String> directionsList = null;
String[] directionsList;
DataParser parser = new DataParser();
//directionsList = parser.parseDirections(s);
//displayDirection(directionsList);
duration = directionsList.get("duration");
distance = directionsList.get("distance");
mMap.clear();
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.draggable(true);
markerOptions.title("Duration =" + duration);
markerOptions.snippet("Distance = " + distance);
mMap.addMarker(markerOptions);
}
}
public void displayDirection(String[] directionsList)
{
int count = directionsList.length;
for (int i =0; i<count;i++)
{
PolylineOptions options=new PolylineOptions();
options.color(Color.RED);
options.width(10);
options.addAll(PolyUtil.decode(directionsList[i]));
mMap.addPolyline(options);
}
}
}
**/
| [
"[email protected]"
] | |
41c1ed38b8d5d7c87c699d84d600ea9670b27e75 | 081e678a279e39b7b44c9e1df8bff2ecfc4c7232 | /src/jp/co/ziro/gs/server/ws/GestureWebSocket.java | 4c30c2b908fb5b2253882fb0df770bead5e0abb7 | [] | no_license | secondarykey/GestureSocket | 8e7d3aa8686ebb1933bee6e1ccd1e74cd618afac | b05ce350d6dde21936c6f826093df8c159d6312a | refs/heads/master | 2020-06-03T14:14:40.963554 | 2012-01-19T06:34:34 | 2012-01-19T06:34:34 | 3,178,165 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 860 | java | package jp.co.ziro.gs.server.ws;
import java.io.IOException;
import org.eclipse.jetty.websocket.WebSocket;
public class GestureWebSocket implements WebSocket.OnTextMessage{
private Connection connection = null;
public GestureWebSocket() {
}
@Override
public void onOpen(Connection con) {
connection = con;
WebSocketFactory.getInstance().join(this);
}
@Override
public void onClose(int arg0, String arg1) {
WebSocketFactory.getInstance().leave(this);
}
@Override
public void onMessage(String msg) {
WebSocketFactory.getInstance().onMessage(this, msg);
}
/**
* メッセージ送信
* @param msg
* @throws IOException
*/
public void send(String msg) throws IOException {
connection.sendMessage(msg);
}
}
| [
"[email protected]"
] | |
fc877aec81ed958dfb6e55a9c8906d85dcda1bc5 | de05b6af997209935530212f03990e10c9c5cb14 | /MP3Extractor/src/main/java/com/lumar/validation/DirectoryValidator.java | 0b0049ecce08a4637b61af2361942a58f4df5927 | [] | no_license | Aaronj1989/MP3Extractor | 52e79463690645cacc3dc71ed1c795b19b8c4fa9 | ebbd6701fe298ee18275f11ac939198e0c65bfde | refs/heads/master | 2022-12-25T09:21:13.867829 | 2019-08-07T14:59:29 | 2019-08-07T14:59:29 | 200,517,805 | 0 | 0 | null | 2022-12-16T00:39:03 | 2019-08-04T16:44:29 | Java | UTF-8 | Java | false | false | 520 | java | package com.lumar.validation;
import java.io.File;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
public class DirectoryValidator implements ConstraintValidator<DirectoryPath,String> {
@Override
public void initialize(DirectoryPath path){}
@Override
public boolean isValid(String value, ConstraintValidatorContext context) {
System.out.println("checking if valid");
File file = new File(value);
return file.isDirectory();
}
}
| [
"[email protected]"
] | |
ba98c72bd52b90b93fdafcf50b589e897327a9e8 | b9464a750cf41f57595e64687a02e273593b4da4 | /Utils.java | 98256d9b21fe654cc82cd5de5bcf88b044b8ab32 | [] | no_license | din14000/hospital-project | 30a2141317f3d3694112947e9d5ca5b09dff367d | c4aa0016311dca350c6e7f02312d82bdf3cd84bc | refs/heads/main | 2023-04-03T06:36:51.484199 | 2021-04-10T14:09:10 | 2021-04-10T14:09:10 | 356,600,004 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,571 | java | import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Set;
import java.util.stream.*;
public class Utils {
static List<Person> doctorsList = new ArrayList<>();
static List<Person> nursesList = new ArrayList<>();
static List<Person> patientsList = new ArrayList<>();
static List<Room> roomsList = new ArrayList<>();
static Hospital hospital = new Hospital();
public static Map<Room, Person[]> map = new HashMap<>();
private final static int PATIENTS_PER_ROOM = 5;
private static final int AMOUNT_OF_DISEASES = 5;
public static final String hospitalStatsBanner = " __ __ _______ _______ _______ ___ _______ _______ ___ _______ _______ _______ _______ ___ _______ _______ ___ _______ _______ \r\n"
+ "| | | || || || || | | || _ || | | || || _ || || | | || || | | || |\r\n"
+ "| |_| || _ || _____|| _ || | |_ _|| |_| || | | _____||_ _|| |_| ||_ _|| | | _____||_ _|| | | || _____|\r\n"
+ "| || | | || |_____ | |_| || | | | | || | | |_____ | | | | | | | | | |_____ | | | | | || |_____ \r\n"
+ "| || |_| ||_____ || ___|| | | | | || |___ |_____ | | | | | | | | | |_____ | | | | | | _||_____ |\r\n"
+ "| _ || | _____| || | | | | | | _ || | _____| | | | | _ | | | | | _____| | | | | | | |_ _____| |\r\n"
+ "|__| |__||_______||_______||___| |___| |___| |__| |__||_______| |_______| |___| |__| |__| |___| |___| |_______| |___| |___| |_______||_______|\r\n";
public static final String hospitalOutputBanner = " __ __ _______ _______ _______ ___ _______ _______ ___ _______ __ __ _______ _______ __ __ _______ \r\n"
+ "| | | || || || || | | || _ || | | || | | || || || | | || |\r\n"
+ "| |_| || _ || _____|| _ || | |_ _|| |_| || | | _ || | | ||_ _|| _ || | | ||_ _|\r\n"
+ "| || | | || |_____ | |_| || | | | | || | | | | || |_| | | | | |_| || |_| | | | \r\n"
+ "| || |_| ||_____ || ___|| | | | | || |___ | |_| || | | | | ___|| | | | \r\n"
+ "| _ || | _____| || | | | | | | _ || | | || | | | | | | | | | \r\n"
+ "|__| |__||_______||_______||___| |___| |___| |__| |__||_______| |_______||_______| |___| |___| |_______| |___| \r\n";
public static void amountOfPeople() {
System.out.println("Amount of Patients: " + patientsList.size());
System.out.println("Amount of Nurses: " + nursesList.size());
System.out.println("Amount of Doctors: " + doctorsList.size() + "\n");
}
public static void allPatientsSickTimeAvg() {
System.out.println("The average time to cure of all the patients is " + patientsList.stream()
.mapToInt(patient -> ((Patient) patient).getDisease().getTimeToCure()).average().orElse(0) + " days\n");
}
public static void avgSickTimePerDisease() {
double[] sums = new double[PATIENTS_PER_ROOM];
double[] amounts = new double[PATIENTS_PER_ROOM];
for (int i = 0; i < sums.length; i++) {
patientsList.forEach(
patients -> sums[((Patient) patients).getDisease().getDiseaseValue()] += ((Patient) patients)
.getDisease().getTimeToCure());
patientsList.forEach(patients -> amounts[((Patient) patients).getDisease().getDiseaseValue()] += 1);
}
for (int i = 0; i < sums.length; i++) {
if (amounts[i] == 0)
sums[i] = 0;
else
sums[i] /= amounts[i];
}
System.out.println("The average time to cure for each disease is: ");
for (int i = 0; i < sums.length; i++)
System.out.println(DiseaseDescription.getDiseaseName(i) + ": "
+ Double.parseDouble(new DecimalFormat("##.##").format(sums[i])) + " days");
System.out.println();
}
public static void avgPatientsAgePerRoom() {
double[] sums = new double[PATIENTS_PER_ROOM];
double[] amounts = new double[PATIENTS_PER_ROOM];
map.forEach((room, person) -> {
int currRoom = room.getRoomNumber() - 1;
for (int i = 0; i < person.length; i++) {
if (person[i] instanceof Patient) {
sums[currRoom] += person[i].getAge();
amounts[currRoom] += 1;
}
}
});
System.out.println("The average age of patients per room is: ");
for (int i = 0; i < sums.length; i++)
System.out.println("Room number: " + (i + 1) + " Average patient age: " + sums[i] / amounts[i] + " years");
System.out.println();
}
public static void mostCommonDisease() {
System.out.print("The most common disease among all patients is ");
int[] amounts = new int[AMOUNT_OF_DISEASES];
patientsList.forEach(patient -> {
int curr = ((Patient) patient).getDisease().getDiseaseValue();
amounts[curr] += 1;
});
int max = Arrays.stream(amounts).max().getAsInt();
for (int i = 0; i < amounts.length; i++) {
if (amounts[i] == max)
System.out.print(
DiseaseDescription.getDiseaseName(i) + " with " + max + " patients having this disease; ");
}
System.out.println("\n");
}
public static void mostUncommonDisease() {
System.out.print("The most uncommon (rare) disease among all patients is ");
int[] amounts = new int[AMOUNT_OF_DISEASES];
patientsList.forEach(patient -> {
int curr = ((Patient) patient).getDisease().getDiseaseValue();
amounts[curr] += 1;
});
int min = Arrays.stream(amounts).min().getAsInt();
for (int i = 0; i < amounts.length; i++) {
if (amounts[i] == min)
System.out.print(
DiseaseDescription.getDiseaseName(i) + " with " + min + " patients having this disease; ");
}
System.out.println("\n");
}
public static void avgStaffAge() {
List<Person> staffList = new ArrayList<>();
staffList.addAll(doctorsList);
staffList.addAll(nursesList);
System.out.println( "The average age of all the staff (doctors and nurses) is " + staffList.stream()
.mapToInt(staff -> staff.getAge()).average().orElse(0) + " years\n" );
}
public static void initHospital() {
initRoom();
Hospital.setRoomsList(roomsList);
Hospital.setDoctorsList(doctorsList);
Hospital.setNursesList(nursesList);
Hospital.setPatientsList(patientsList);
System.out.println(hospital);
}
public static void initRoom() {
for (int i = 0; i < PATIENTS_PER_ROOM; i++) {
Room room = new Room();
Doctor doctor = new Doctor();
Nurse nurse = new Nurse();
Patient[] patients = new Patient[PATIENTS_PER_ROOM];
for (int j = 0; j < patients.length; j++) {
patients[j] = new Patient();
}
room.setDoctor(doctor);
room.setNurse(nurse);
room.setPatients(patients);
Person[] people = new Person[patients.length + 2];
for (int j = 0; j < people.length; j++) {
if (j < patients.length)
people[j] = patients[j];
else if (j == patients.length)
people[j] = nurse;
else
people[j] = doctor;
}
maintainLists(room, people);
}
}
public static void maintainLists(Room room, Person person[]) {
for (int i = 0; i < person.length; i++) {
if (person[i] instanceof Doctor) {
Doctor doctor = (Doctor) person[i];
doctorsList.add(doctor);
doctor.setRoomNumber(room.getRoomNumber());
} else if (person[i] instanceof Nurse) {
Nurse nurse = (Nurse) person[i];
nurse.setFirstRoom(room.getRoomNumber());
nursesList.add(nurse);
} else if (person[i] instanceof Patient) {
patientsList.add(person[i]);
}
}
map.put(room, person);
roomsList.add(room);
}
public static String printRoomList(List<Room> list) {
String s = "";
Iterator<Room> iterator = list.iterator();
while (iterator.hasNext()) {
s += iterator.next().toString()
+ "---------------------------------------------------------------------------------------------------------\n";
}
s.trim();
return s;
}
public static String printArray(Object[] arr) {
String s = "";
for (int i = 0; i < arr.length - 1; i++) {
s += arr[i].toString() + "\n ";
}
s += arr[arr.length - 1].toString() + "\n";
s.trim();
return s;
}
}
| [
"[email protected]"
] | |
a46436cbc43ba0872e220e67dfb670025f268ff3 | bd769033990236eccb0ead384abe015ef4e07aaa | /pinyougou-sellergoods-service/src/main/java/com/pinyougou/sellergoods/service/impl/GoodsServiceImpl.java | c1ccc48f8bfcaf3721d8e49884d461019e1fe3d9 | [] | no_license | RaintLee/pinyougou | 23bd3b2802b10161a53797a82fe56c9e96845792 | 262d394ceda638bd792a5d04040b9e8dd6c83953 | refs/heads/master | 2020-03-30T00:38:40.029134 | 2018-10-24T03:05:42 | 2018-10-24T03:05:42 | 150,534,569 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,171 | java | package com.pinyougou.sellergoods.service.impl;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.pinyougou.mapper.TbBrandMapper;
import com.pinyougou.mapper.TbGoodsDescMapper;
import com.pinyougou.mapper.TbItemCatMapper;
import com.pinyougou.mapper.TbItemMapper;
import com.pinyougou.mapper.TbSellerMapper;
import com.pinyougou.pojo.TbBrand;
import com.pinyougou.pojo.TbGoodsDesc;
import com.pinyougou.pojo.TbItem;
import com.pinyougou.pojo.TbItemCat;
import com.pinyougou.pojo.TbItemExample;
import com.pinyougou.pojo.TbSeller;
import com.pinyougou.pojo.group.Goods;
import org.springframework.beans.factory.annotation.Autowired;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.pinyougou.mapper.TbGoodsMapper;
import com.pinyougou.pojo.TbGoods;
import com.pinyougou.pojo.TbGoodsExample;
import com.pinyougou.pojo.TbGoodsExample.Criteria;
import com.pinyougou.sellergoods.service.GoodsService;
import entity.PageResult;
/**
* 服务实现层
* @author Administrator
*
*/
@Service
public class GoodsServiceImpl implements GoodsService {
@Autowired
private TbGoodsMapper goodsMapper;
@Autowired
private TbGoodsDescMapper goodsDescMapper;
@Autowired
private TbItemMapper itemMapper;
@Autowired
private TbItemCatMapper itemCatMapper;
@Autowired
private TbBrandMapper brandMapper;
@Autowired
private TbSellerMapper sellerMapper;
/**
* 查询全部
*/
@Override
public List<TbGoods> findAll() {
return goodsMapper.selectByExample(null);
}
/**
* 按分页查询
*/
@Override
public PageResult findPage(int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
Page<TbGoods> page= (Page<TbGoods>) goodsMapper.selectByExample(null);
return new PageResult(page.getTotal(), page.getResult());
}
/**
* 增加
*/
@Override
public void add(Goods goods) {
goods.getGoods().setAuditStatus("0");//状态:未审核
goodsMapper.insert(goods.getGoods());//插入商品基本信息
goods.getGoodsDesc().setGoodsId(goods.getGoods().getId());//将商品基本表的ID给商品扩展表
goodsDescMapper.insert(goods.getGoodsDesc());//插入商品扩展表数据
saveItemList(goods);//插入SKU商品数据
}
private void setItemValues(TbItem item,Goods goods){
//商品分类
item.setCategoryid(goods.getGoods().getCategory3Id());//三级分类ID
item.setCreateTime(new Date());//创建日期
item.setUpdateTime(new Date());//更新日期
item.setGoodsId(goods.getGoods().getId());//商品ID
item.setSellerId(goods.getGoods().getSellerId());//商家ID
//分类名称
TbItemCat itemCat = itemCatMapper.selectByPrimaryKey(goods.getGoods().getCategory3Id());
item.setCategory(itemCat.getName());
//品牌名称
TbBrand brand = brandMapper.selectByPrimaryKey(goods.getGoods().getBrandId());
item.setBrand(brand.getName());
//商家名称(店铺名称)
TbSeller seller = sellerMapper.selectByPrimaryKey(goods.getGoods().getSellerId());
item.setSeller(seller.getNickName());
//图片
List<Map> imageList = JSON.parseArray( goods.getGoodsDesc().getItemImages(), Map.class) ;
if(imageList.size()>0){
item.setImage( (String)imageList.get(0).get("url"));
}
}
/**
* 修改
*/
@Override
public void update(Goods goods){
//更新基本表数据
goodsMapper.updateByPrimaryKey(goods.getGoods());
//更新扩展表数据
goodsDescMapper.updateByPrimaryKey(goods.getGoodsDesc());
//删除原有的SKU列表数据
TbItemExample example=new TbItemExample();
com.pinyougou.pojo.TbItemExample.Criteria criteria = example.createCriteria();
criteria.andGoodsIdEqualTo(goods.getGoods().getId());
itemMapper.deleteByExample(example);
//插入新的SKU列表数据
saveItemList(goods);//插入SKU商品数据
}
//插入sku列表数据
private void saveItemList(Goods goods){
if("1".equals(goods.getGoods().getIsEnableSpec())){
for(TbItem item: goods.getItemList()){
//构建标题 SPU名称+ 规格选项值
String title=goods.getGoods().getGoodsName();//SPU名称
Map<String,Object> map= JSON.parseObject(item.getSpec());
for(String key:map.keySet()) {
title+=" "+map.get(key);
}
item.setTitle(title);
setItemValues(item,goods);
itemMapper.insert(item);
}
}else{//没有启用规格
TbItem item=new TbItem();
item.setTitle(goods.getGoods().getGoodsName());//标题
item.setPrice(goods.getGoods().getPrice());//价格
item.setNum(99999);//库存数量
item.setStatus("1");//状态
item.setIsDefault("1");//默认
item.setSpec("{}");//规格
setItemValues(item,goods);
itemMapper.insert(item);
}
}
/**
* 根据ID获取实体
* @param id
* @return
*/
@Override
public Goods findOne(Long id){
Goods goods=new Goods();
//商品基本表
TbGoods tbGoods = goodsMapper.selectByPrimaryKey(id);
goods.setGoods(tbGoods);
//商品扩展表
TbGoodsDesc goodsDesc = goodsDescMapper.selectByPrimaryKey(id);
goods.setGoodsDesc(goodsDesc);
//读取SKU列表
TbItemExample example=new TbItemExample();
com.pinyougou.pojo.TbItemExample.Criteria criteria = example.createCriteria();
criteria.andGoodsIdEqualTo(id);
List<TbItem> itemList = itemMapper.selectByExample(example);
goods.setItemList(itemList);
return goods;
// return goodsMapper.selectByPrimaryKey(id);
}
/**
* 批量删除
*/
@Override
public void delete(Long[] ids) {
for(Long id:ids){
TbGoods goods = goodsMapper.selectByPrimaryKey(id);
goods.setIsDelete("1");//表示逻辑删除
goodsMapper.updateByPrimaryKey(goods);
}
}
@Override
public PageResult findPage(TbGoods goods, int pageNum, int pageSize) {
PageHelper.startPage(pageNum, pageSize);
TbGoodsExample example=new TbGoodsExample();
Criteria criteria = example.createCriteria();
criteria.andIsDeleteIsNull();//指定条件为未逻辑删除记录
if(goods!=null){
if(goods.getSellerId()!=null && goods.getSellerId().length()>0){
// criteria.andSellerIdLike("%"+goods.getSellerId()+"%");
criteria.andSellerIdLike(goods.getSellerId());
}
if(goods.getGoodsName()!=null && goods.getGoodsName().length()>0){
criteria.andGoodsNameLike("%"+goods.getGoodsName()+"%");
}
if(goods.getAuditStatus()!=null && goods.getAuditStatus().length()>0){
criteria.andAuditStatusLike("%"+goods.getAuditStatus()+"%");
}
if(goods.getIsMarketable()!=null && goods.getIsMarketable().length()>0){
criteria.andIsMarketableLike("%"+goods.getIsMarketable()+"%");
}
if(goods.getCaption()!=null && goods.getCaption().length()>0){
criteria.andCaptionLike("%"+goods.getCaption()+"%");
}
if(goods.getSmallPic()!=null && goods.getSmallPic().length()>0){
criteria.andSmallPicLike("%"+goods.getSmallPic()+"%");
}
if(goods.getIsEnableSpec()!=null && goods.getIsEnableSpec().length()>0){
criteria.andIsEnableSpecLike("%"+goods.getIsEnableSpec()+"%");
}
if(goods.getIsDelete()!=null && goods.getIsDelete().length()>0){
criteria.andIsDeleteLike("%"+goods.getIsDelete()+"%");
}
}
Page<TbGoods> page= (Page<TbGoods>)goodsMapper.selectByExample(example);
return new PageResult(page.getTotal(), page.getResult());
}
@Override
public void updateStatus(Long[] ids, String status) {
for(Long id:ids){
TbGoods goods = goodsMapper.selectByPrimaryKey(id);
goods.setAuditStatus(status);
goodsMapper.updateByPrimaryKey(goods);
}
}
/**
* 根据SPU的ID集合查询SKU列表
* @param goodsIds
* @param status
* @return
*/
@Override
public List<TbItem> findItemListByGoodsIdListAndStatus(Long []goodsIds,String status){
TbItemExample example=new TbItemExample();
com.pinyougou.pojo.TbItemExample.Criteria criteria = example.createCriteria();
criteria.andStatusEqualTo(status);//状态
criteria.andGoodsIdIn( Arrays.asList(goodsIds));//指定条件:SPUID集合
return itemMapper.selectByExample(example);
}
}
| [
"[email protected]"
] | |
3d027193cb215444163d1abd7a38be9cb69ef1d1 | 3cbf94fc5b9a5449527c283c9cab593933c18b42 | /v2ray-jdk/src/main/java/com/v2ray/core/transport/internet/websocket/Config.java | 560273c510590551df842c0cc4e1a7ee4ee1c57f | [
"MIT"
] | permissive | master-coder-ll/v2ray-web-manager | f7dc9e96010d7e83d5250957890b8e1bd9306cd3 | bb5e32c3820b269381aa5bf80ac259b3783fac59 | refs/heads/master | 2023-08-23T18:13:43.370529 | 2023-05-04T07:10:08 | 2023-05-04T07:10:08 | 231,087,400 | 1,488 | 540 | MIT | 2023-07-07T21:43:46 | 2019-12-31T12:44:50 | Go | UTF-8 | Java | false | true | 29,313 | java | // Generated by the protocol buffer compiler. DO NOT EDIT!
// source: v2ray.com/core/transport/internet/websocket/config.proto
package com.v2ray.core.transport.internet.websocket;
/**
* Protobuf type {@code v2ray.core.transport.internet.websocket.Config}
*/
public final class Config extends
com.google.protobuf.GeneratedMessageV3 implements
// @@protoc_insertion_point(message_implements:v2ray.core.transport.internet.websocket.Config)
ConfigOrBuilder {
private static final long serialVersionUID = 0L;
// Use Config.newBuilder() to construct.
private Config(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
super(builder);
}
private Config() {
path_ = "";
header_ = java.util.Collections.emptyList();
}
@Override
public final com.google.protobuf.UnknownFieldSet
getUnknownFields() {
return this.unknownFields;
}
private Config(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
this();
if (extensionRegistry == null) {
throw new NullPointerException();
}
int mutable_bitField0_ = 0;
com.google.protobuf.UnknownFieldSet.Builder unknownFields =
com.google.protobuf.UnknownFieldSet.newBuilder();
try {
boolean done = false;
while (!done) {
int tag = input.readTag();
switch (tag) {
case 0:
done = true;
break;
case 18: {
String s = input.readStringRequireUtf8();
path_ = s;
break;
}
case 26: {
if (!((mutable_bitField0_ & 0x00000002) != 0)) {
header_ = new java.util.ArrayList<com.v2ray.core.transport.internet.websocket.Header>();
mutable_bitField0_ |= 0x00000002;
}
header_.add(
input.readMessage(com.v2ray.core.transport.internet.websocket.Header.parser(), extensionRegistry));
break;
}
default: {
if (!parseUnknownField(
input, unknownFields, extensionRegistry, tag)) {
done = true;
}
break;
}
}
}
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
throw e.setUnfinishedMessage(this);
} catch (java.io.IOException e) {
throw new com.google.protobuf.InvalidProtocolBufferException(
e).setUnfinishedMessage(this);
} finally {
if (((mutable_bitField0_ & 0x00000002) != 0)) {
header_ = java.util.Collections.unmodifiableList(header_);
}
this.unknownFields = unknownFields.build();
makeExtensionsImmutable();
}
}
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.v2ray.core.transport.internet.websocket.ConfigOuterClass.internal_static_v2ray_core_transport_internet_websocket_Config_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return com.v2ray.core.transport.internet.websocket.ConfigOuterClass.internal_static_v2ray_core_transport_internet_websocket_Config_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Config.class, Builder.class);
}
private int bitField0_;
public static final int PATH_FIELD_NUMBER = 2;
private volatile Object path_;
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public String getPath() {
Object ref = path_;
if (ref instanceof String) {
return (String) ref;
} else {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
path_ = s;
return s;
}
}
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public com.google.protobuf.ByteString
getPathBytes() {
Object ref = path_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
path_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
public static final int HEADER_FIELD_NUMBER = 3;
private java.util.List<com.v2ray.core.transport.internet.websocket.Header> header_;
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public java.util.List<com.v2ray.core.transport.internet.websocket.Header> getHeaderList() {
return header_;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public java.util.List<? extends com.v2ray.core.transport.internet.websocket.HeaderOrBuilder>
getHeaderOrBuilderList() {
return header_;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public int getHeaderCount() {
return header_.size();
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.Header getHeader(int index) {
return header_.get(index);
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.HeaderOrBuilder getHeaderOrBuilder(
int index) {
return header_.get(index);
}
private byte memoizedIsInitialized = -1;
@Override
public final boolean isInitialized() {
byte isInitialized = memoizedIsInitialized;
if (isInitialized == 1) return true;
if (isInitialized == 0) return false;
memoizedIsInitialized = 1;
return true;
}
@Override
public void writeTo(com.google.protobuf.CodedOutputStream output)
throws java.io.IOException {
if (!getPathBytes().isEmpty()) {
com.google.protobuf.GeneratedMessageV3.writeString(output, 2, path_);
}
for (int i = 0; i < header_.size(); i++) {
output.writeMessage(3, header_.get(i));
}
unknownFields.writeTo(output);
}
@Override
public int getSerializedSize() {
int size = memoizedSize;
if (size != -1) return size;
size = 0;
if (!getPathBytes().isEmpty()) {
size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, path_);
}
for (int i = 0; i < header_.size(); i++) {
size += com.google.protobuf.CodedOutputStream
.computeMessageSize(3, header_.get(i));
}
size += unknownFields.getSerializedSize();
memoizedSize = size;
return size;
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof Config)) {
return super.equals(obj);
}
Config other = (Config) obj;
if (!getPath()
.equals(other.getPath())) return false;
if (!getHeaderList()
.equals(other.getHeaderList())) return false;
if (!unknownFields.equals(other.unknownFields)) return false;
return true;
}
@Override
public int hashCode() {
if (memoizedHashCode != 0) {
return memoizedHashCode;
}
int hash = 41;
hash = (19 * hash) + getDescriptor().hashCode();
hash = (37 * hash) + PATH_FIELD_NUMBER;
hash = (53 * hash) + getPath().hashCode();
if (getHeaderCount() > 0) {
hash = (37 * hash) + HEADER_FIELD_NUMBER;
hash = (53 * hash) + getHeaderList().hashCode();
}
hash = (29 * hash) + unknownFields.hashCode();
memoizedHashCode = hash;
return hash;
}
public static Config parseFrom(
java.nio.ByteBuffer data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Config parseFrom(
java.nio.ByteBuffer data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Config parseFrom(
com.google.protobuf.ByteString data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Config parseFrom(
com.google.protobuf.ByteString data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Config parseFrom(byte[] data)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data);
}
public static Config parseFrom(
byte[] data,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return PARSER.parseFrom(data, extensionRegistry);
}
public static Config parseFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Config parseFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
public static Config parseDelimitedFrom(java.io.InputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input);
}
public static Config parseDelimitedFrom(
java.io.InputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseDelimitedWithIOException(PARSER, input, extensionRegistry);
}
public static Config parseFrom(
com.google.protobuf.CodedInputStream input)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input);
}
public static Config parseFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
return com.google.protobuf.GeneratedMessageV3
.parseWithIOException(PARSER, input, extensionRegistry);
}
@Override
public Builder newBuilderForType() { return newBuilder(); }
public static Builder newBuilder() {
return DEFAULT_INSTANCE.toBuilder();
}
public static Builder newBuilder(Config prototype) {
return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
}
@Override
public Builder toBuilder() {
return this == DEFAULT_INSTANCE
? new Builder() : new Builder().mergeFrom(this);
}
@Override
protected Builder newBuilderForType(
BuilderParent parent) {
Builder builder = new Builder(parent);
return builder;
}
/**
* Protobuf type {@code v2ray.core.transport.internet.websocket.Config}
*/
public static final class Builder extends
com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
// @@protoc_insertion_point(builder_implements:v2ray.core.transport.internet.websocket.Config)
com.v2ray.core.transport.internet.websocket.ConfigOrBuilder {
public static final com.google.protobuf.Descriptors.Descriptor
getDescriptor() {
return com.v2ray.core.transport.internet.websocket.ConfigOuterClass.internal_static_v2ray_core_transport_internet_websocket_Config_descriptor;
}
@Override
protected FieldAccessorTable
internalGetFieldAccessorTable() {
return com.v2ray.core.transport.internet.websocket.ConfigOuterClass.internal_static_v2ray_core_transport_internet_websocket_Config_fieldAccessorTable
.ensureFieldAccessorsInitialized(
Config.class, Builder.class);
}
// Construct using com.v2ray.core.transport.internet.websocket.Config.newBuilder()
private Builder() {
maybeForceBuilderInitialization();
}
private Builder(
BuilderParent parent) {
super(parent);
maybeForceBuilderInitialization();
}
private void maybeForceBuilderInitialization() {
if (com.google.protobuf.GeneratedMessageV3
.alwaysUseFieldBuilders) {
getHeaderFieldBuilder();
}
}
@Override
public Builder clear() {
super.clear();
path_ = "";
if (headerBuilder_ == null) {
header_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
} else {
headerBuilder_.clear();
}
return this;
}
@Override
public com.google.protobuf.Descriptors.Descriptor
getDescriptorForType() {
return com.v2ray.core.transport.internet.websocket.ConfigOuterClass.internal_static_v2ray_core_transport_internet_websocket_Config_descriptor;
}
@Override
public Config getDefaultInstanceForType() {
return Config.getDefaultInstance();
}
@Override
public Config build() {
Config result = buildPartial();
if (!result.isInitialized()) {
throw newUninitializedMessageException(result);
}
return result;
}
@Override
public Config buildPartial() {
Config result = new Config(this);
int from_bitField0_ = bitField0_;
int to_bitField0_ = 0;
result.path_ = path_;
if (headerBuilder_ == null) {
if (((bitField0_ & 0x00000002) != 0)) {
header_ = java.util.Collections.unmodifiableList(header_);
bitField0_ = (bitField0_ & ~0x00000002);
}
result.header_ = header_;
} else {
result.header_ = headerBuilder_.build();
}
result.bitField0_ = to_bitField0_;
onBuilt();
return result;
}
@Override
public Builder clone() {
return super.clone();
}
@Override
public Builder setField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.setField(field, value);
}
@Override
public Builder clearField(
com.google.protobuf.Descriptors.FieldDescriptor field) {
return super.clearField(field);
}
@Override
public Builder clearOneof(
com.google.protobuf.Descriptors.OneofDescriptor oneof) {
return super.clearOneof(oneof);
}
@Override
public Builder setRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
int index, Object value) {
return super.setRepeatedField(field, index, value);
}
@Override
public Builder addRepeatedField(
com.google.protobuf.Descriptors.FieldDescriptor field,
Object value) {
return super.addRepeatedField(field, value);
}
@Override
public Builder mergeFrom(com.google.protobuf.Message other) {
if (other instanceof Config) {
return mergeFrom((Config)other);
} else {
super.mergeFrom(other);
return this;
}
}
public Builder mergeFrom(Config other) {
if (other == Config.getDefaultInstance()) return this;
if (!other.getPath().isEmpty()) {
path_ = other.path_;
onChanged();
}
if (headerBuilder_ == null) {
if (!other.header_.isEmpty()) {
if (header_.isEmpty()) {
header_ = other.header_;
bitField0_ = (bitField0_ & ~0x00000002);
} else {
ensureHeaderIsMutable();
header_.addAll(other.header_);
}
onChanged();
}
} else {
if (!other.header_.isEmpty()) {
if (headerBuilder_.isEmpty()) {
headerBuilder_.dispose();
headerBuilder_ = null;
header_ = other.header_;
bitField0_ = (bitField0_ & ~0x00000002);
headerBuilder_ =
com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ?
getHeaderFieldBuilder() : null;
} else {
headerBuilder_.addAllMessages(other.header_);
}
}
}
this.mergeUnknownFields(other.unknownFields);
onChanged();
return this;
}
@Override
public final boolean isInitialized() {
return true;
}
@Override
public Builder mergeFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws java.io.IOException {
Config parsedMessage = null;
try {
parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
} catch (com.google.protobuf.InvalidProtocolBufferException e) {
parsedMessage = (Config) e.getUnfinishedMessage();
throw e.unwrapIOException();
} finally {
if (parsedMessage != null) {
mergeFrom(parsedMessage);
}
}
return this;
}
private int bitField0_;
private Object path_ = "";
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public String getPath() {
Object ref = path_;
if (!(ref instanceof String)) {
com.google.protobuf.ByteString bs =
(com.google.protobuf.ByteString) ref;
String s = bs.toStringUtf8();
path_ = s;
return s;
} else {
return (String) ref;
}
}
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public com.google.protobuf.ByteString
getPathBytes() {
Object ref = path_;
if (ref instanceof String) {
com.google.protobuf.ByteString b =
com.google.protobuf.ByteString.copyFromUtf8(
(String) ref);
path_ = b;
return b;
} else {
return (com.google.protobuf.ByteString) ref;
}
}
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public Builder setPath(
String value) {
if (value == null) {
throw new NullPointerException();
}
path_ = value;
onChanged();
return this;
}
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public Builder clearPath() {
path_ = getDefaultInstance().getPath();
onChanged();
return this;
}
/**
* <pre>
* URL path to the WebSocket service. Empty value means root(/).
* </pre>
*
* <code>string path = 2;</code>
*/
public Builder setPathBytes(
com.google.protobuf.ByteString value) {
if (value == null) {
throw new NullPointerException();
}
checkByteStringIsUtf8(value);
path_ = value;
onChanged();
return this;
}
private java.util.List<com.v2ray.core.transport.internet.websocket.Header> header_ =
java.util.Collections.emptyList();
private void ensureHeaderIsMutable() {
if (!((bitField0_ & 0x00000002) != 0)) {
header_ = new java.util.ArrayList<com.v2ray.core.transport.internet.websocket.Header>(header_);
bitField0_ |= 0x00000002;
}
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.v2ray.core.transport.internet.websocket.Header, com.v2ray.core.transport.internet.websocket.Header.Builder, com.v2ray.core.transport.internet.websocket.HeaderOrBuilder> headerBuilder_;
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public java.util.List<com.v2ray.core.transport.internet.websocket.Header> getHeaderList() {
if (headerBuilder_ == null) {
return java.util.Collections.unmodifiableList(header_);
} else {
return headerBuilder_.getMessageList();
}
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public int getHeaderCount() {
if (headerBuilder_ == null) {
return header_.size();
} else {
return headerBuilder_.getCount();
}
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.Header getHeader(int index) {
if (headerBuilder_ == null) {
return header_.get(index);
} else {
return headerBuilder_.getMessage(index);
}
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder setHeader(
int index, com.v2ray.core.transport.internet.websocket.Header value) {
if (headerBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureHeaderIsMutable();
header_.set(index, value);
onChanged();
} else {
headerBuilder_.setMessage(index, value);
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder setHeader(
int index, com.v2ray.core.transport.internet.websocket.Header.Builder builderForValue) {
if (headerBuilder_ == null) {
ensureHeaderIsMutable();
header_.set(index, builderForValue.build());
onChanged();
} else {
headerBuilder_.setMessage(index, builderForValue.build());
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder addHeader(com.v2ray.core.transport.internet.websocket.Header value) {
if (headerBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureHeaderIsMutable();
header_.add(value);
onChanged();
} else {
headerBuilder_.addMessage(value);
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder addHeader(
int index, com.v2ray.core.transport.internet.websocket.Header value) {
if (headerBuilder_ == null) {
if (value == null) {
throw new NullPointerException();
}
ensureHeaderIsMutable();
header_.add(index, value);
onChanged();
} else {
headerBuilder_.addMessage(index, value);
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder addHeader(
com.v2ray.core.transport.internet.websocket.Header.Builder builderForValue) {
if (headerBuilder_ == null) {
ensureHeaderIsMutable();
header_.add(builderForValue.build());
onChanged();
} else {
headerBuilder_.addMessage(builderForValue.build());
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder addHeader(
int index, com.v2ray.core.transport.internet.websocket.Header.Builder builderForValue) {
if (headerBuilder_ == null) {
ensureHeaderIsMutable();
header_.add(index, builderForValue.build());
onChanged();
} else {
headerBuilder_.addMessage(index, builderForValue.build());
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder addAllHeader(
Iterable<? extends com.v2ray.core.transport.internet.websocket.Header> values) {
if (headerBuilder_ == null) {
ensureHeaderIsMutable();
com.google.protobuf.AbstractMessageLite.Builder.addAll(
values, header_);
onChanged();
} else {
headerBuilder_.addAllMessages(values);
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder clearHeader() {
if (headerBuilder_ == null) {
header_ = java.util.Collections.emptyList();
bitField0_ = (bitField0_ & ~0x00000002);
onChanged();
} else {
headerBuilder_.clear();
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public Builder removeHeader(int index) {
if (headerBuilder_ == null) {
ensureHeaderIsMutable();
header_.remove(index);
onChanged();
} else {
headerBuilder_.remove(index);
}
return this;
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.Header.Builder getHeaderBuilder(
int index) {
return getHeaderFieldBuilder().getBuilder(index);
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.HeaderOrBuilder getHeaderOrBuilder(
int index) {
if (headerBuilder_ == null) {
return header_.get(index); } else {
return headerBuilder_.getMessageOrBuilder(index);
}
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public java.util.List<? extends com.v2ray.core.transport.internet.websocket.HeaderOrBuilder>
getHeaderOrBuilderList() {
if (headerBuilder_ != null) {
return headerBuilder_.getMessageOrBuilderList();
} else {
return java.util.Collections.unmodifiableList(header_);
}
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.Header.Builder addHeaderBuilder() {
return getHeaderFieldBuilder().addBuilder(
com.v2ray.core.transport.internet.websocket.Header.getDefaultInstance());
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public com.v2ray.core.transport.internet.websocket.Header.Builder addHeaderBuilder(
int index) {
return getHeaderFieldBuilder().addBuilder(
index, com.v2ray.core.transport.internet.websocket.Header.getDefaultInstance());
}
/**
* <code>repeated .v2ray.core.transport.internet.websocket.Header header = 3;</code>
*/
public java.util.List<com.v2ray.core.transport.internet.websocket.Header.Builder>
getHeaderBuilderList() {
return getHeaderFieldBuilder().getBuilderList();
}
private com.google.protobuf.RepeatedFieldBuilderV3<
com.v2ray.core.transport.internet.websocket.Header, com.v2ray.core.transport.internet.websocket.Header.Builder, com.v2ray.core.transport.internet.websocket.HeaderOrBuilder>
getHeaderFieldBuilder() {
if (headerBuilder_ == null) {
headerBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3<
com.v2ray.core.transport.internet.websocket.Header, com.v2ray.core.transport.internet.websocket.Header.Builder, com.v2ray.core.transport.internet.websocket.HeaderOrBuilder>(
header_,
((bitField0_ & 0x00000002) != 0),
getParentForChildren(),
isClean());
header_ = null;
}
return headerBuilder_;
}
@Override
public final Builder setUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.setUnknownFields(unknownFields);
}
@Override
public final Builder mergeUnknownFields(
final com.google.protobuf.UnknownFieldSet unknownFields) {
return super.mergeUnknownFields(unknownFields);
}
// @@protoc_insertion_point(builder_scope:v2ray.core.transport.internet.websocket.Config)
}
// @@protoc_insertion_point(class_scope:v2ray.core.transport.internet.websocket.Config)
private static final Config DEFAULT_INSTANCE;
static {
DEFAULT_INSTANCE = new Config();
}
public static Config getDefaultInstance() {
return DEFAULT_INSTANCE;
}
private static final com.google.protobuf.Parser<Config>
PARSER = new com.google.protobuf.AbstractParser<Config>() {
@Override
public Config parsePartialFrom(
com.google.protobuf.CodedInputStream input,
com.google.protobuf.ExtensionRegistryLite extensionRegistry)
throws com.google.protobuf.InvalidProtocolBufferException {
return new Config(input, extensionRegistry);
}
};
public static com.google.protobuf.Parser<Config> parser() {
return PARSER;
}
@Override
public com.google.protobuf.Parser<Config> getParserForType() {
return PARSER;
}
@Override
public Config getDefaultInstanceForType() {
return DEFAULT_INSTANCE;
}
}
| [
"[email protected]"
] | |
9610c1a9bfcffc31340f59b3382dbe6bd3275023 | 52b453449fabb6d70e568966db6c32b7642721a1 | /common/src/main/java/com/lly835/bestpay/model/wxpay/response/WxPaySyncResponse.java | b70bf24f07aee6d780308e962805aa22786b8b4a | [] | no_license | Super262/emall-dev | 48aece213bec5f6dbf6d504cca22647a46f48452 | aa78f3a14141e3233f3b73687d0cb0b0b765f8fd | refs/heads/master | 2023-07-13T21:58:42.473934 | 2021-08-29T23:10:40 | 2021-08-29T23:10:40 | 365,671,275 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,365 | java | package com.lly835.bestpay.model.wxpay.response;
import org.simpleframework.xml.Element;
import org.simpleframework.xml.Root;
import java.util.Objects;
/**
* 同步返回参数
*/
@Root(name = "xml", strict = false)
public class WxPaySyncResponse {
@Element(name = "return_code")
private String returnCode;
@Element(name = "return_msg", required = false)
private String returnMsg;
/**
* 以下字段在return_code为SUCCESS的时候有返回.
*/
@Element(name = "appid", required = false)
private String appid;
@Element(name = "mch_id", required = false)
private String mchId;
@Element(name = "device_info", required = false)
private String deviceInfo;
@Element(name = "nonce_str", required = false)
private String nonceStr;
@Element(name = "sign", required = false)
private String sign;
@Element(name = "result_code", required = false)
private String resultCode;
@Element(name = "err_code", required = false)
private String errCode;
@Element(name = "err_code_des", required = false)
private String errCodeDes;
/**
* 以下字段在return_code 和result_code都为SUCCESS的时候有返回.
*/
@Element(name = "trade_type", required = false)
private String tradeType;
@Element(name = "prepay_id", required = false)
private String prepayId;
@Element(name = "code_url", required = false)
private String codeUrl;
@Element(name = "mweb_url", required = false)
private String mwebUrl;
public WxPaySyncResponse() {
}
public String getReturnCode() {
return this.returnCode;
}
public void setReturnCode(String returnCode) {
this.returnCode = returnCode;
}
public String getReturnMsg() {
return this.returnMsg;
}
public void setReturnMsg(String returnMsg) {
this.returnMsg = returnMsg;
}
public String getAppid() {
return this.appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getMchId() {
return this.mchId;
}
public void setMchId(String mchId) {
this.mchId = mchId;
}
public String getDeviceInfo() {
return this.deviceInfo;
}
public void setDeviceInfo(String deviceInfo) {
this.deviceInfo = deviceInfo;
}
public String getNonceStr() {
return this.nonceStr;
}
public void setNonceStr(String nonceStr) {
this.nonceStr = nonceStr;
}
public String getSign() {
return this.sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getResultCode() {
return this.resultCode;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
public String getErrCode() {
return this.errCode;
}
public void setErrCode(String errCode) {
this.errCode = errCode;
}
public String getErrCodeDes() {
return this.errCodeDes;
}
public void setErrCodeDes(String errCodeDes) {
this.errCodeDes = errCodeDes;
}
public String getTradeType() {
return this.tradeType;
}
public void setTradeType(String tradeType) {
this.tradeType = tradeType;
}
public String getPrepayId() {
return this.prepayId;
}
public void setPrepayId(String prepayId) {
this.prepayId = prepayId;
}
public String getCodeUrl() {
return this.codeUrl;
}
public void setCodeUrl(String codeUrl) {
this.codeUrl = codeUrl;
}
public String getMwebUrl() {
return this.mwebUrl;
}
public void setMwebUrl(String mwebUrl) {
this.mwebUrl = mwebUrl;
}
public boolean equals(final Object o) {
if (o == this) return true;
if (!(o instanceof WxPaySyncResponse)) return false;
final WxPaySyncResponse other = (WxPaySyncResponse) o;
if (!other.canEqual(this)) return false;
final Object this$returnCode = this.getReturnCode();
final Object other$returnCode = other.getReturnCode();
if (!Objects.equals(this$returnCode,other$returnCode)) return false;
final Object this$returnMsg = this.getReturnMsg();
final Object other$returnMsg = other.getReturnMsg();
if (!Objects.equals(this$returnMsg,other$returnMsg)) return false;
final Object this$appid = this.getAppid();
final Object other$appid = other.getAppid();
if (!Objects.equals(this$appid,other$appid)) return false;
final Object this$mchId = this.getMchId();
final Object other$mchId = other.getMchId();
if (!Objects.equals(this$mchId,other$mchId)) return false;
final Object this$deviceInfo = this.getDeviceInfo();
final Object other$deviceInfo = other.getDeviceInfo();
if (!Objects.equals(this$deviceInfo,other$deviceInfo)) return false;
final Object this$nonceStr = this.getNonceStr();
final Object other$nonceStr = other.getNonceStr();
if (!Objects.equals(this$nonceStr,other$nonceStr)) return false;
final Object this$sign = this.getSign();
final Object other$sign = other.getSign();
if (!Objects.equals(this$sign,other$sign)) return false;
final Object this$resultCode = this.getResultCode();
final Object other$resultCode = other.getResultCode();
if (!Objects.equals(this$resultCode,other$resultCode)) return false;
final Object this$errCode = this.getErrCode();
final Object other$errCode = other.getErrCode();
if (!Objects.equals(this$errCode,other$errCode)) return false;
final Object this$errCodeDes = this.getErrCodeDes();
final Object other$errCodeDes = other.getErrCodeDes();
if (!Objects.equals(this$errCodeDes,other$errCodeDes)) return false;
final Object this$tradeType = this.getTradeType();
final Object other$tradeType = other.getTradeType();
if (!Objects.equals(this$tradeType,other$tradeType)) return false;
final Object this$prepayId = this.getPrepayId();
final Object other$prepayId = other.getPrepayId();
if (!Objects.equals(this$prepayId,other$prepayId)) return false;
final Object this$codeUrl = this.getCodeUrl();
final Object other$codeUrl = other.getCodeUrl();
if (!Objects.equals(this$codeUrl,other$codeUrl)) return false;
final Object this$mwebUrl = this.getMwebUrl();
final Object other$mwebUrl = other.getMwebUrl();
return Objects.equals(this$mwebUrl,other$mwebUrl);
}
protected boolean canEqual(final Object other) {
return other instanceof WxPaySyncResponse;
}
public int hashCode() {
final int PRIME = 59;
int result = 1;
final Object $returnCode = this.getReturnCode();
result = result * PRIME + ($returnCode == null ? 43 : $returnCode.hashCode());
final Object $returnMsg = this.getReturnMsg();
result = result * PRIME + ($returnMsg == null ? 43 : $returnMsg.hashCode());
final Object $appid = this.getAppid();
result = result * PRIME + ($appid == null ? 43 : $appid.hashCode());
final Object $mchId = this.getMchId();
result = result * PRIME + ($mchId == null ? 43 : $mchId.hashCode());
final Object $deviceInfo = this.getDeviceInfo();
result = result * PRIME + ($deviceInfo == null ? 43 : $deviceInfo.hashCode());
final Object $nonceStr = this.getNonceStr();
result = result * PRIME + ($nonceStr == null ? 43 : $nonceStr.hashCode());
final Object $sign = this.getSign();
result = result * PRIME + ($sign == null ? 43 : $sign.hashCode());
final Object $resultCode = this.getResultCode();
result = result * PRIME + ($resultCode == null ? 43 : $resultCode.hashCode());
final Object $errCode = this.getErrCode();
result = result * PRIME + ($errCode == null ? 43 : $errCode.hashCode());
final Object $errCodeDes = this.getErrCodeDes();
result = result * PRIME + ($errCodeDes == null ? 43 : $errCodeDes.hashCode());
final Object $tradeType = this.getTradeType();
result = result * PRIME + ($tradeType == null ? 43 : $tradeType.hashCode());
final Object $prepayId = this.getPrepayId();
result = result * PRIME + ($prepayId == null ? 43 : $prepayId.hashCode());
final Object $codeUrl = this.getCodeUrl();
result = result * PRIME + ($codeUrl == null ? 43 : $codeUrl.hashCode());
final Object $mwebUrl = this.getMwebUrl();
result = result * PRIME + ($mwebUrl == null ? 43 : $mwebUrl.hashCode());
return result;
}
public String toString() {
return "WxPaySyncResponse(returnCode=" + this.getReturnCode() + ", returnMsg=" + this.getReturnMsg() + ", appid=" + this.getAppid() + ", mchId=" + this.getMchId() + ", deviceInfo=" + this.getDeviceInfo() + ", nonceStr=" + this.getNonceStr() + ", sign=" + this.getSign() + ", resultCode=" + this.getResultCode() + ", errCode=" + this.getErrCode() + ", errCodeDes=" + this.getErrCodeDes() + ", tradeType=" + this.getTradeType() + ", prepayId=" + this.getPrepayId() + ", codeUrl=" + this.getCodeUrl() + ", mwebUrl=" + this.getMwebUrl() + ")";
}
}
| [
"[email protected]"
] | |
aec42da91cb2b2ec3d768e3ec6cf86e859010e54 | c544677eff452d86b9509d2bc7e0844fb4ce0b35 | /src/main/java/br/com/salazar/projAluno/ProjAlunoApplication.java | f53873f3816dd69e753dfbb427b94de6685ed2dd | [] | no_license | Leonardkill/ProjetoAluno | a76ad640da40802b36f502e18bfe26c12a9c524a | a1975151d2448d0ca6f55b4b55a6c59bcb76678e | refs/heads/master | 2022-07-18T04:18:47.285499 | 2020-05-15T01:25:55 | 2020-05-15T01:25:55 | 264,065,079 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 323 | java | package br.com.salazar.projAluno;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ProjAlunoApplication {
public static void main(String[] args) {
SpringApplication.run(ProjAlunoApplication.class, args);
}
}
| [
"[email protected]"
] | |
c78c1d15117fc06582183b3e7b72b9a4e0ee8f1d | 4da3979fb605c86c52f7df0bd1b2b085d195587e | /app/src/test/java/com/neha/butterknife/ExampleUnitTest.java | 261a54452c212edd910aa9c145de8808eb6c0f5b | [] | no_license | nehaanand/DataBinding_With_RoomDB | 7fb358d522a8e3327dfde875e640a5aa0b80c73d | cedd955a086bbc17643d5b069028eda3a027eaa4 | refs/heads/master | 2021-03-29T13:04:00.281576 | 2020-03-20T11:43:51 | 2020-03-20T11:43:51 | 247,956,001 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 381 | java | package com.neha.butterknife;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
b24ead9d5bc668b417d3bfd4ea484d4c92b1b23b | aa0eaad7645e4ee34bdd4ded15a30cfd6c5f8481 | /src/main/java/HealthPassage/PassageGet.java | 1baf321b50e99d8ce9a2a33ddf64e950b3888e52 | [] | no_license | steven900516/Jsoup_Increase-pageviews-Hexo-blog- | c603e74dafb60033484b6f8337ee72d54c17d818 | 317be4d9f163f2efe4bd274986e0afba9b393473 | refs/heads/master | 2023-08-21T15:56:11.869269 | 2021-10-22T12:15:37 | 2021-10-22T12:15:37 | 397,648,362 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,912 | java | package HealthPassage;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.junit.Test;
import java.io.IOException;
/**
* @author Steven0516
* @create 2021-10-22
*/
public class PassageGet {
public String info2(Document document){
Elements txt = document.getElementsByClass("yxl-editor-article ");
System.out.println(txt.text().length());
return txt.text();
}
public static void info(Document document){
Elements txt = document.getElementsByClass("yxl-editor-article ");
Elements span = txt.select("p span");
StringBuilder sb = new StringBuilder();
for (Element line: span){
if(!line.select("strong span").text().equals("")){
continue;
}
String text = line.text();
System.out.println(text);
sb.append(text);
}
System.out.println("--------------------");
System.out.println(sb.toString());
System.out.println(sb.toString().length());
}
public static void main(String[] args) throws IOException, InterruptedException {
PassageGet passageGet = new PassageGet();
int size = 0;
Document doc = Jsoup.connect("https://www.xinli001.com/").get();
Elements content = doc.getElementsByClass("content");
for(Element passage: content){
Elements mainTitle = passage.select("p.main-title");
String mainTitleS = mainTitle.text();
System.out.println(mainTitleS);
Elements smallTitle = passage.select("p.small-title");
String smallTitleS = smallTitle.text();
if(smallTitleS.equals("")) continue;
System.out.println(smallTitleS);
Elements category = passage.select("p.ci-title");
String catgoryS = category.text();
System.out.println(catgoryS);
Elements img = passage.select("img");
String imgUrl = img.attr("abs:src");
System.out.println(imgUrl);
Elements info = passage.select("a.common-a");
String infoHref = info.attr("href");
System.out.println(infoHref);
Connection connection = Jsoup.connect(infoHref);
//获取网页的Document对象
Document document = connection.timeout(10*1000).get();
String detail = passageGet.info2(document);
System.out.println(detail);
System.out.println("------------------------------------------");
size ++;
Thread.sleep(3000);
}
System.out.println(size);
}
@Test
public void temp() throws IOException {
// PassageGet.info2(Jsoup.connect("https://www.xinli001.com/info/100478729?source=pc-home").get());
}
}
| [
"[email protected]"
] | |
74566aa535f096e2d7978f1714fca1a261f2378e | e77ae6642255bb08b338e0a0c52dccfa133bc497 | /20170312/04CycleStructure/DoWhileTest.java | b2c3ecd1c81d4160c1d33ce31fe48b849ec05b5a | [] | no_license | gujiacun/Homework | a20bc47a89738c85e978af26b32cc8c8df0ff276 | e263434724219fb35c3745474b1971758d874fdc | refs/heads/master | 2021-01-19T20:06:02.161355 | 2017-05-22T18:02:52 | 2017-05-22T18:02:52 | 88,486,667 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 682 | java | //需求:用do - while按顺序打印大写字母A到Z
//定义一个类,叫DoWhileTest
class DoWhileTest {
//定义主方法
public static void main(String[] args) {
//初始化变量值alphabet,输入第一个打印的元素A
char alphabet = 'A';
do{
//输出第一个元素A
System.out.println(alphabet);
//变量自增1,由于char类型在底层是存储为int类型,所以把它当作一个整型变量
alphabet ++;
//循环控制条件,当变量等于时,执行最后一次循环,返回打印语句
}while (alphabet <= 'Z');
}
}
/*
小结:char类型在底层是存储为int类型,所以char类型变量可以执行自增自减
*/ | [
"[email protected]"
] | |
448633ab40ffe68b03fb26cbe347ef06c9bf1b68 | c81011aab1a2c07946f0fbe96acd5bcff68b3c58 | /src/com/hdfc/banking/Bank.java | aeb136e33f18f0ffbed8125e217a9e288562bfea | [] | no_license | JavaK2/JavaConcept | 6b0ddab5d8149597caaade39946d7ea82dc78dad | 8ed0778b379dbac698f5611aa3215c1cf8477091 | refs/heads/master | 2021-01-17T17:21:31.252924 | 2016-11-05T06:06:16 | 2016-11-05T06:06:16 | 66,184,923 | 0 | 0 | null | 2016-08-21T06:40:05 | 2016-08-21T06:40:05 | null | UTF-8 | Java | false | false | 311 | java | package com.hdfc.banking;
public class Bank {
public void withDraw() {
checkPin();
checkAccountLocked();
checkNoOfTrans();
checkBalance();
}
protected void checkNoOfTrans() {
}
protected void checkAccountLocked() {
}
protected void checkBalance() {
}
protected void checkPin() {
}
}
| [
"[email protected]"
] | |
fcc4ed067007dc45be646378ea144d308e69fbf6 | da2dd965336fdf6bc9cf99dfbff1b761fcb64d91 | /src/main/java/car/CarType.java | fa2643734a2bf9c698aa3b7b0bdc9db89659e52e | [] | no_license | jh-project-repo/java_oop-parking-project | 0e0de5158d024b59bc056f1bc9885ba4bcf56b0a | 2acbba07ab625fcf5cab8aa40ec76f116beca39e | refs/heads/main | 2023-03-01T08:11:38.614901 | 2021-02-11T03:47:11 | 2021-02-11T03:47:11 | 313,952,512 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 250 | java | package car;
public enum CarType {
ELECTRIC_CAR("승용차"),
GENERAL_CAR("전기차");
private final String car;
CarType(final String car) {
this.car = car;
}
public String getCar() {
return car;
}
}
| [
"[email protected]"
] | |
782a9aee2bb0b13b0861696ebaf8f74eed75efc1 | 3c1b9a7e7c83325cfee3246ff2339cb1be7476c1 | /app/src/main/java/com/jaemo/jaemo/customer/dropoff/DropoffViewModel.java | 72d051abb685ac5226b54480df16cc3119b9d3d6 | [] | no_license | strikerhac/FYP | 2476dd61752fed5dcb9e996837130073045b0f14 | 384a254bdd253fca7efd605418722b32620345e4 | refs/heads/master | 2020-09-22T04:40:57.725730 | 2019-11-30T18:19:37 | 2019-11-30T18:19:37 | 225,052,500 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 77 | java | package com.jaemo.jaemo.customer.dropoff;
public class DropoffViewModel {
}
| [
"[email protected]"
] | |
c294a40ae95ec9d992ee05fba621877c8fef82b9 | 429d0d13b672202b10c1b7ae930731457eb98bbc | /src/com/class12/Repl64.java | 023c1de811325cc5b6cbb67179f3fcc6b85bd28e | [] | no_license | Husson34/Java-Code-Syntax | dd4a8aec0081bc9a83e36297466425119bf14cab | 68fd9a0d9f3b2d001734ea48b698037cfe5b431e | refs/heads/master | 2020-06-06T19:10:17.351883 | 2019-06-20T02:28:44 | 2019-06-20T02:28:44 | 192,830,807 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 583 | java | package com.class12;
public class Repl64 {
public static void main(String[] args) {
int[][] a = {
{1,1,2}, //sum = 4
{3,1,2}, //sum = 6
{3,5,3}, //sum = 11
{0,1,2} //sum = 3
};
int sums[] = new int[a.length];
for (int i = 0; i < a.length; i++) {
int rowSum = 0;
for (int j = 0; j < a[i].length; j++) {
rowSum += a[i][j];
}
sums[i] = rowSum;
}
for(int sum : sums) {
System.out.println(sum);
}
}
}
| [
"[email protected]"
] | |
2d8380cce213161eeb885a966d9c10da37a3c0b3 | cbf27b3a5804e6e89773b7088fe10924e06e0f11 | /app/src/androidTest/java/com/example/prasad/permissionshelpersample/ExampleInstrumentedTest.java | 9654d09853948d25f3bf1584156da562e1cc5708 | [
"MIT"
] | permissive | prasadshirvandkar/Permissions-Handler | 5847da605cf4578a7abbad65e412465325f78a78 | 26f1f42db372fef811636bcbea43ff5d4ada494d | refs/heads/master | 2021-06-24T22:20:03.185734 | 2017-07-16T19:22:03 | 2017-07-16T19:22:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 785 | java | package com.example.prasad.permissionshelpersample;
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.example.prasad.permissionsassistant", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
23885f8781abe358a08018308e07ee57b61da461 | b51ce70cdf1496a6470a56b983f07ef9f724092f | /Common/src/main/java/dev/brighten/antivpn/utils/json/CDL.java | 6af74b3ff430bb758bf7c1346d5d20ceb5853f4c | [
"Apache-2.0"
] | permissive | funkemunky/AntiVPN | 7259ecfe59bc2115b8ca6e274a9a4d88eebf6bfb | 96e48594d89419f7fd9bc7104243f0ab120a36ec | refs/heads/master | 2023-08-07T15:11:09.525431 | 2023-07-12T12:45:39 | 2023-07-12T12:45:39 | 233,082,218 | 24 | 18 | Apache-2.0 | 2023-07-31T18:43:45 | 2020-01-10T16:03:14 | Java | UTF-8 | Java | false | false | 10,135 | java | package dev.brighten.antivpn.utils.json;
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The Software shall be used for Good, not Evil.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
/**
* This provides static methods to convert comma delimited text into a
* JSONArray, and to covert a JSONArray into comma delimited text. Comma
* delimited text is a very popular format for data interchange. It is
* understood by most database, spreadsheet, and organizer programs.
* <p>
* Each row of text represents a row in a table or a data record. Each row
* ends with a NEWLINE character. Each row contains one or more values.
* Values are separated by commas. A value can contain any character except
* for comma, unless is is wrapped in single quotes or double quotes.
* <p>
* The first row usually contains the names of the columns.
* <p>
* A comma delimited list can be converted into a JSONArray of JSONObjects.
* The names for the elements in the JSONObjects can be taken from the names
* in the first row.
*
* @author JSON.org
* @version 2010-12-24
*/
public class CDL {
/**
* Get the next value. The value can be wrapped in quotes. The value can
* be empty.
*
* @param x A JSONTokener of the source text.
* @return The value string, or null if empty.
* @throws JSONException if the quoted string is badly formed.
*/
private static String getValue(JSONTokener x) throws JSONException {
char c;
char q;
StringBuffer sb;
do {
c = x.next();
} while (c == ' ' || c == '\t');
switch (c) {
case 0:
return null;
case '"':
case '\'':
q = c;
sb = new StringBuffer();
for (; ; ) {
c = x.next();
if (c == q) {
break;
}
if (c == 0 || c == '\n' || c == '\r') {
throw x.syntaxError("Missing close quote '" + q + "'.");
}
sb.append(c);
}
return sb.toString();
case ',':
x.back();
return "";
default:
x.back();
return x.nextTo(',');
}
}
/**
* Produce a JSONArray of strings from a row of comma delimited values.
*
* @param x A JSONTokener of the source text.
* @return A JSONArray of strings.
* @throws JSONException
*/
public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
JSONArray ja = new JSONArray();
for (; ; ) {
String value = getValue(x);
char c = x.next();
if (value == null ||
(ja.length() == 0 && value.length() == 0 && c != ',')) {
return null;
}
ja.put(value);
for (; ; ) {
if (c == ',') {
break;
}
if (c != ' ') {
if (c == '\n' || c == '\r' || c == 0) {
return ja;
}
throw x.syntaxError("Bad character '" + c + "' (" +
(int) c + ").");
}
c = x.next();
}
}
}
/**
* Produce a JSONObject from a row of comma delimited text, using a
* parallel JSONArray of strings to provides the names of the elements.
*
* @param names A JSONArray of names. This is commonly obtained from the
* first row of a comma delimited text file using the rowToJSONArray
* method.
* @param x A JSONTokener of the source text.
* @return A JSONObject combining the names and values.
* @throws JSONException
*/
public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x)
throws JSONException {
JSONArray ja = rowToJSONArray(x);
return ja != null ? ja.toJSONObject(names) : null;
}
/**
* Produce a comma delimited text row from a JSONArray. Values containing
* the comma character will be quoted. Troublesome characters may be
* removed.
*
* @param ja A JSONArray of strings.
* @return A string ending in NEWLINE.
*/
public static String rowToString(JSONArray ja) {
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ja.length(); i += 1) {
if (i > 0) {
sb.append(',');
}
Object object = ja.opt(i);
if (object != null) {
String string = object.toString();
if (string.length() > 0 && (string.indexOf(',') >= 0 ||
string.indexOf('\n') >= 0 || string.indexOf('\r') >= 0 ||
string.indexOf(0) >= 0 || string.charAt(0) == '"')) {
sb.append('"');
int length = string.length();
for (int j = 0; j < length; j += 1) {
char c = string.charAt(j);
if (c >= ' ' && c != '"') {
sb.append(c);
}
}
sb.append('"');
} else {
sb.append(string);
}
}
}
sb.append('\n');
return sb.toString();
}
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
*
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
public static JSONArray toJSONArray(String string) throws JSONException {
return toJSONArray(new JSONTokener(string));
}
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string,
* using the first row as a source of names.
*
* @param x The JSONTokener containing the comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
public static JSONArray toJSONArray(JSONTokener x) throws JSONException {
return toJSONArray(rowToJSONArray(x), x);
}
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
*
* @param names A JSONArray of strings.
* @param string The comma delimited text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
public static JSONArray toJSONArray(JSONArray names, String string)
throws JSONException {
return toJSONArray(names, new JSONTokener(string));
}
/**
* Produce a JSONArray of JSONObjects from a comma delimited text string
* using a supplied JSONArray as the source of element names.
*
* @param names A JSONArray of strings.
* @param x A JSONTokener of the source text.
* @return A JSONArray of JSONObjects.
* @throws JSONException
*/
public static JSONArray toJSONArray(JSONArray names, JSONTokener x)
throws JSONException {
if (names == null || names.length() == 0) {
return null;
}
JSONArray ja = new JSONArray();
for (; ; ) {
JSONObject jo = rowToJSONObject(names, x);
if (jo == null) {
break;
}
ja.put(jo);
}
if (ja.length() == 0) {
return null;
}
return ja;
}
/**
* Produce a comma delimited text from a JSONArray of JSONObjects. The
* first row will be a list of names obtained by inspecting the first
* JSONObject.
*
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
public static String toString(JSONArray ja) throws JSONException {
JSONObject jo = ja.optJSONObject(0);
if (jo != null) {
JSONArray names = jo.names();
if (names != null) {
return rowToString(names) + toString(names, ja);
}
}
return null;
}
/**
* Produce a comma delimited text from a JSONArray of JSONObjects using
* a provided list of names. The list of names is not included in the
* output.
*
* @param names A JSONArray of strings.
* @param ja A JSONArray of JSONObjects.
* @return A comma delimited text.
* @throws JSONException
*/
public static String toString(JSONArray names, JSONArray ja)
throws JSONException {
if (names == null || names.length() == 0) {
return null;
}
StringBuffer sb = new StringBuffer();
for (int i = 0; i < ja.length(); i += 1) {
JSONObject jo = ja.optJSONObject(i);
if (jo != null) {
sb.append(rowToString(jo.toJSONArray(names)));
}
}
return sb.toString();
}
}
| [
"[email protected]"
] | |
29c7a7259218dacdf3d62f39c2c7a812b4a25d3c | 5142a8986e7a80420357a7f1b1bbfdf94ad02767 | /hybris-commerce-suite-5.5.1.2/Mobile-Commerce-SDK/Mobile-Commerce-SDK-Android/hybrisMobileHTTPClientLibrary/src/com/hybris/mobile/lib/http/listener/OnRequestListener.java | cc9b1994920975ffeaa3de84b0b58032a222488f | [] | no_license | gerardoram/research1 | 613ef2143ba60a440bb577362bcf1ce2a646664b | 2a4515e3f8901f0b3b510653d61dac059c6521a8 | refs/heads/master | 2020-05-20T17:04:39.574621 | 2015-06-23T17:53:26 | 2015-06-23T17:53:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 964 | java | /*******************************************************************************
* [y] hybris Platform
*
* Copyright (c) 2000-2015 hybris AG
* All rights reserved.
*
* This software is the confidential and proprietary information of hybris
* ("Confidential Information"). You shall not disclose such Confidential
* Information and shall use it only in accordance with the terms of the
* license agreement you entered into with hybris.
******************************************************************************/
package com.hybris.mobile.lib.http.listener;
/**
* Interface that its methods (before/after) will be called when the request is sent
*/
public interface OnRequestListener
{
/**
* Before the request is sent
*/
public void beforeRequest();
/**
* After the request is sent
*
* @param isDataSynced
* Whether or not the request is synced with remote data
*/
public void afterRequest(boolean isDataSynced);
}
| [
"[email protected]"
] | |
b53ee6df586537fd804d43479763657956849def | 360ed5accc25138244afc986cdadbea687163543 | /proj2/tablut/Board.java | c23e713ff4b12cf32f9702e38f59d8b82d909009 | [] | no_license | michaelchien512/Tablut | d6e45b768c1d4c8ea4ffab1c156c15f6cc588967 | 8ce93651de8eb105f73abd675692d6f2ff534f6f | refs/heads/master | 2020-09-11T23:43:43.240090 | 2020-01-08T08:48:03 | 2020-01-08T08:48:03 | 222,229,215 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 18,867 | java | package tablut;
import java.util.Formatter;
import java.util.Stack;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import static tablut.Piece.*;
import static tablut.Square.*;
import static tablut.Move.mv;
import java.util.List;
/** The state of a Tablut Game.
* @author Michael Chien
*/
class Board {
/** The number of squares on a side of the board. */
static final int SIZE = 9;
/** The throne (or castle) square and its four surrounding squares.. */
static final Square THRONE = sq(4, 4),
NTHRONE = sq(4, 5),
STHRONE = sq(4, 3),
WTHRONE = sq(3, 4),
ETHRONE = sq(5, 4);
/** Initial positions of attackers. */
static final Square[] INITIAL_ATTACKERS = {
sq(0, 3), sq(0, 4), sq(0, 5), sq(1, 4),
sq(8, 3), sq(8, 4), sq(8, 5), sq(7, 4),
sq(3, 0), sq(4, 0), sq(5, 0), sq(4, 1),
sq(3, 8), sq(4, 8), sq(5, 8), sq(4, 7)
};
/** Initial positions of defenders of the king. */
static final Square[] INITIAL_DEFENDERS = {
NTHRONE, ETHRONE, STHRONE, WTHRONE,
sq(4, 6), sq(4, 2), sq(2, 4), sq(6, 4)
};
/** Initializes a game board with SIZE squares on a side in the
* initial position. */
Board() {
init();
}
/** Initializes a copy of MODEL. */
Board(Board model) {
copy(model);
}
/** Copies MODEL into me. */
void copy(Board model) {
if (model == this) {
return;
}
init();
this._board = new Piece[SIZE][SIZE];
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board[i].length; j++) {
this._board[i][j] = model._board[i][j];
}
}
for (Square s : INITIAL_DEFENDERS) {
this._board[s.row()][s.col()] = model._board[s.row()][s.col()];
}
for (Square s : INITIAL_ATTACKERS) {
this._board[s.row()][s.col()] = model._board[s.row()][s.col()];
}
this._board[THRONE.row()][THRONE.col()] =
model._board[THRONE.row()][THRONE.col()];
this._moves = model.moves();
this._turn = model.turn();
this._winner = model._winner;
this._moveCount = model.moveCount();
this._bpositions = model.bpositions();
this.capturedmap = model.capturedmap;
this.locs = model.locs;
}
/** Clears the board to the initial position. */
void init() {
_limit = Integer.MAX_VALUE;
_turn = BLACK;
_winner = null;
_moveCount = 0;
_bpositions = new ArrayList<>();
_moves = new Stack<>();
_board = new Piece[SIZE][SIZE];
capturedmap = new HashMap<>();
locs = new ArrayList<>();
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board[i].length; j++) {
_board[i][j] = EMPTY;
}
}
for (Square s : INITIAL_ATTACKERS) {
_board[s.row()][s.col()] = BLACK;
}
for (Square s : INITIAL_DEFENDERS) {
_board[s.row()][s.col()] = WHITE;
}
_board[THRONE.row()][THRONE.col()] = KING;
_bpositions.add(encodedBoard());
}
/** @param n is the move limit Set the move limit to n. */
void setMoveLimit(int n) {
_limit = n;
if (2 * _limit <= moveCount()) {
throw new IllegalArgumentException("Over movecount!");
}
}
/** Return a Piece representing whose move it is (WHITE or BLACK). */
Piece turn() {
return _turn;
}
/** Return the winner in the current position, or null if there is no winner
* yet. */
Piece winner() {
return _winner;
}
/** Returns true iff this is a win due to a repeated position. */
boolean repeatedPosition() {
return _repeated;
}
/** Returns true iff I captured a piece. */
boolean captured() {
return _captured;
}
/** Record current position and set winner() next mover if the current
* position is a repeat. */
private void checkRepeated() {
for (int i = 0; i < _bpositions.size(); i++) {
for (int j = i + 1; j < _bpositions.size(); j++) {
if (_bpositions.get(i).equals(_bpositions.get(j))) {
_repeated = true;
_winner = _turn;
}
}
}
}
/** @return My movestack. */
Stack<Move> moves() {
return _moves;
}
/** Return the number of moves since the initial position that have not been
* undone. */
int moveCount() {
return _moveCount;
}
/** Return location of the king. */
Square kingPosition() {
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board[i].length; j++) {
if (get(i, j) == KING) {
return Square.sq(i, j);
}
}
}
return null;
}
/** Return the contents the square at S. */
final Piece get(Square s) {
return this._board[s.row()][s.col()];
}
/** return boardpositions. */
ArrayList<String> bpositions() {
return _bpositions;
}
/** Return the contents of the square at (COL, ROW), where
* 0 <= COL, ROW <= 9. */
final Piece get(int col, int row) {
return get(Square.sq(col, row));
}
/** Return the contents of the square at COL ROW. */
final Piece get(char col, char row) {
return get(col - 'a', row - '1');
}
/** Set square S to P. */
final void put(Piece p, Square s) {
_board[s.row()][s.col()] = p;
}
/** @param m Set piece to s and record for undoing
* @param p piece
* @param s square*/
final void revPut(Move m, Piece p, Square s) {
_board[s.row()][s.col()] = p;
locs.add(s);
String string = _moveCount + " " + m.toString();
if (capturedmap.containsKey(string)) {
capturedmap.replace(string, locs);
} else {
capturedmap.put(_moveCount + " " + m.toString(), locs);
}
}
/** Set square COL ROW to P. */
final void put(Piece p, char col, char row) {
put(p, sq(col - 'a', row - '1'));
}
/** Return true iff FROM - TO is an unblocked rook move on the current
* board. For this to be true, FROM-TO must be a rook move and the
* squares along it, other than FROM, must be empty. */
boolean isUnblockedMove(Square from, Square to) {
Square copy;
if (from.isRookMove(to)) {
int dir = from.direction(to);
if (dir == 0 || dir == 2) {
for (int i = 1; i <= Math.abs(to.row() - from.row()); i++) {
copy = from.rookMove(dir, i);
if (get(copy) != EMPTY) {
return false;
}
}
} else if (dir == 1 || dir == 3) {
for (int i = 1; i <= Math.abs(to.col() - from.col()); i++) {
copy = from.rookMove(dir, i);
if (get(copy) != EMPTY) {
return false;
}
}
}
return true;
}
return false;
}
/** Return true iff FROM is a valid starting square for a move. */
boolean isLegal(Square from) {
return get(from).side() == _turn;
}
/** Return true iff FROM-TO is a valid move. */
boolean isLegal(Square from, Square to) {
if (exists(from.col(), from.row())) {
if (get(from) == KING && turn() == WHITE) {
return isUnblockedMove(from, to);
}
if (to == THRONE && get(from) != KING) {
return false;
}
if (get(from) == turn() && get(to) == EMPTY) {
return isUnblockedMove(from, to);
}
}
return false;
}
/** Return true iff MOVE is a legal move in the current
* position. */
boolean isLegal(Move move) {
return isLegal(move.from(), move.to());
}
/** Move FROM-TO, assuming this is a legal move. */
void makeMove(Square from, Square to) {
Move m = mv(from, to);
_moves.push(m);
if (moveCount() > _limit) {
_winner = turn().opponent();
}
_moveCount += 1;
if (get(from) == KING) {
if (to.isEdge()) {
put(KING, to);
put(EMPTY, from);
_winner = WHITE;
} else {
put(KING, to);
put(EMPTY, from);
_turn = KING;
if (!partner(to).isEmpty() && !partner(to).contains(null)) {
for (Square s : partner(to)) {
capture(to, s);
}
}
_turn = BLACK;
}
} else {
put(turn(), to);
put(EMPTY, from);
if (!partner(to).isEmpty()) {
for (Square s : partner(to)) {
capture(to, s);
}
}
if (_turn == BLACK) {
if (to.adjacent(NTHRONE) || to.adjacent(STHRONE)
|| to.adjacent(WTHRONE) || to.adjacent(ETHRONE)) {
specialCapture(to, THRONE);
}
}
_turn = turn().opponent();
}
_bpositions.add(encodedBoard());
checkRepeated();
}
/** @param current Return my partner to help me capture a piece */
ArrayList<Square> partner(Square current) {
ArrayList<Square> partners = new ArrayList<>();
HashSet<Square> possiblesquares = pieceLocations(turn());
for (int i = 0; i < 4; i++) {
Square twoaway = current.rookMove(i, 2);
if (possiblesquares.contains(twoaway)) {
partners.add(twoaway);
}
if (twoaway == THRONE && get(twoaway) == EMPTY) {
partners.add(twoaway);
}
}
return partners;
}
/** Move according to MOVE, assuming it is a legal move. */
void makeMove(Move move) {
makeMove(move.from(), move.to());
}
/** Capture the piece between SQ0 and SQ2, assuming a piece just moved to
* SQ0 and the necessary conditions are satisfied. */
private void capture(Square sq0, Square sq2) {
Piece turn = this.turn();
Square captured = sq0.between(sq2);
Move m = _moves.get(_moves.size() - 1);
if (turn == WHITE || turn == KING) {
if (get(captured) == BLACK) {
revPut(m, EMPTY, captured);
}
} else {
if (get(captured) == KING) {
if (captured == THRONE) {
if (get(NTHRONE) == BLACK && get(STHRONE) == BLACK
&& get(ETHRONE) == BLACK && get(WTHRONE) == BLACK) {
revPut(m, EMPTY, THRONE);
_winner = BLACK;
} else {
return;
}
} else if ((captured == NTHRONE || captured == STHRONE
|| captured == WTHRONE || captured == ETHRONE
&& get(THRONE) == EMPTY)) {
if (thrones()) {
revPut(m, EMPTY, captured);
_winner = BLACK;
}
} else if (captured != THRONE || captured != NTHRONE
|| captured != STHRONE
|| captured != ETHRONE || captured != WTHRONE) {
revPut(m, EMPTY, captured);
_winner = BLACK;
}
} else if (get(captured) == WHITE) {
revPut(m, EMPTY, captured);
}
}
}
/** @param throne use the throne.
* @param black Special case of capture. */
private void specialCapture(Square black, Square throne) {
int blackcount = 0;
int whitecount = 0;
Move m = _moves.get(_moves.size() - 1);
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board.length; j++) {
if (throne.adjacent(Square.sq(i, j))
&& get(Square.sq(i, j)) == BLACK) {
blackcount += 1;
} else if (throne.adjacent(Square.sq(i, j))
&& get(Square.sq(i, j)) == WHITE) {
whitecount += 1;
}
if (blackcount == 3 && whitecount == 1) {
Square captured = black.between(throne);
revPut(m, EMPTY, captured);
}
}
}
}
/** @return Capture if kings on a different throne. */
private boolean thrones() {
Square k = kingPosition();
int blackcount = 0;
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board.length; j++) {
if (k.adjacent(Square.sq(i, j))
&& get(Square.sq(i, j)) == BLACK) {
blackcount += 1;
}
if (get(THRONE) == EMPTY && blackcount == 3) {
return true;
}
}
}
return false;
}
/** Undo one move. Has no effect on the initial board. */
void undo() {
if (_moveCount > 0) {
undoPosition();
_moveCount = _moveCount - 1;
Move m = _moves.pop();
Piece a = get(m.to());
for (String move : capturedmap.keySet()) {
ArrayList<Square> squares = capturedmap.get(move);
for (Square s : squares) {
put(a, s);
}
}
put(_turn.opponent(), m.from());
put(EMPTY, m.to());
_turn = turn().opponent();
}
}
/** Remove record of current position in the set of positions encountered,
* unless it is a repeated position or we are at the first move. */
private void undoPosition() {
checkRepeated();
if (_repeated) {
return;
}
_bpositions.remove(_bpositions.size() - 1);
_repeated = false;
}
/** Clear the undo stack and board-position counts. Does not modify the
* current position or win status. */
void clearUndo() {
while (_moves != null) {
_moves.pop();
}
_bpositions.clear();
}
/** Return a new mutable list of all legal moves on the current board for
* SIDE (ignoring whose turn it is at the moment). */
List<Move> legalMoves(Piece side) {
_legalmoves = new ArrayList<>();
HashSet<Square> locations = pieceLocations(side);
Piece temp = _turn;
_turn = side;
for (Square s : locations) {
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board[i].length; j++) {
if (exists(i, j)) {
if (isLegal(s, Square.sq(i, j))) {
_legalmoves.add(Move.mv(s, Square.sq(i, j)));
}
}
}
}
}
_turn = temp;
if (_legalmoves.size() == 0) {
_winner = _turn.opponent();
}
return _legalmoves;
}
/** Return true iff SIDE has a legal move. */
boolean hasMove(Piece side) {
List<Move> check = legalMoves(side);
return !check.isEmpty();
}
@Override
public String toString() {
return toString(true);
}
/** Return a text representation of this Board. If COORDINATES, then row
* and column designations are included along the left and bottom sides.
*/
String toString(boolean coordinates) {
Formatter out = new Formatter();
for (int r = SIZE - 1; r >= 0; r -= 1) {
if (coordinates) {
out.format("%2d", r + 1);
} else {
out.format(" ");
}
for (int c = 0; c < SIZE; c += 1) {
out.format(" %s", get(c, r));
}
out.format("%n");
}
if (coordinates) {
out.format(" ");
for (char c = 'a'; c <= 'i'; c += 1) {
out.format(" %c", c);
}
out.format("%n");
}
return out.toString();
}
/** Return the locations of all pieces on SIDE. */
HashSet<Square> pieceLocations(Piece side) {
assert side != EMPTY;
HashSet<Square> p = new HashSet<>();
if (side == WHITE || side == KING) {
if (kingPosition() != null) {
p.add(kingPosition());
}
}
for (int i = 0; i < _board.length; i++) {
for (int j = 0; j < _board[i].length; j++) {
if (get(i, j) == side) {
p.add(Square.sq(i, j));
} else if (_turn == KING) {
if (get(i, j) == WHITE) {
p.add(Square.sq(i, j));
}
}
}
}
return p;
}
/** Return the contents of _board in the order of SQUARE_LIST as a sequence
* of characters: the toString values of the current turn and Pieces. */
String encodedBoard() {
char[] result = new char[Square.SQUARE_LIST.size() + 1];
result[0] = turn().toString().charAt(0);
for (Square sq : SQUARE_LIST) {
result[sq.index() + 1] = get(sq).toString().charAt(0);
}
return new String(result);
}
/** Piece whose turn it is (WHITE or BLACK). */
private Piece _turn;
/** Cached value of winner on this board, or EMPTY if it has not been
* computed. */
private Piece _winner;
/** Number of (still undone) moves since initial position. */
private int _moveCount;
/** True when current board is a repeated position (ending the game). */
private boolean _repeated;
/** 2d array board with the pieces inside. */
private Piece[][] _board;
/** Stack of moves. */
private Stack<Move> _moves;
/** Arraylist for previous board positions. */
private ArrayList<String> _bpositions;
/** Legalmoves for one side. */
private ArrayList<Move> _legalmoves;
/** Hashmaps to store captured pieces. */
private HashMap<String, ArrayList<Square>> capturedmap;
/** Arraylist for captured pieces locations. */
private ArrayList<Square> locs;
/** True when I capture a piece. */
private boolean _captured;
/** MoveLimit. */
private int _limit;
}
| [
"[email protected]"
] | |
2ca36f9159b9896e19e5ce2e906203d5152a0c56 | 54c1dcb9a6fb9e257c6ebe7745d5008d29b0d6b6 | /app/src/main/java/com/google/android/gms/internal/firebase_ml/zzql.java | f683258c295bed599ae89e7611496434a830edb3 | [] | no_license | rcoolboy/guilvN | 3817397da465c34fcee82c0ca8c39f7292bcc7e1 | c779a8e2e5fd458d62503dc1344aa2185101f0f0 | refs/heads/master | 2023-05-31T10:04:41.992499 | 2021-07-07T09:58:05 | 2021-07-07T09:58:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,245 | java | package com.google.android.gms.internal.firebase_ml;
import android.graphics.Rect;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.google.android.gms.common.internal.GmsLogger;
import com.google.android.gms.common.internal.Preconditions;
import com.google.firebase.p027ml.vision.text.FirebaseVisionText;
import com.google.firebase.p027ml.vision.text.RecognizedLanguage;
import com.xiaomi.mipush.sdk.Constants;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
public final class zzql {
public static final GmsLogger zzaoz = new GmsLogger("TextAnnotationConverter", "");
@Nullable
@VisibleForTesting
public static String zza(@NonNull zzjx zzjx) {
Preconditions.checkNotNull(zzjx, "Input Word can not be null");
if (zzjx.getSymbols() == null || zzjx.getSymbols().size() <= 0) {
return null;
}
zzjr zzjr = zzjx.getSymbols().get(zzjx.getSymbols().size() - 1);
if (zzjr.zzhr() == null || zzjr.zzhr().zzhz() == null) {
return null;
}
return zzjx.getSymbols().get(zzjx.getSymbols().size() - 1).zzhr().zzhz().getType();
}
@Nullable
public static FirebaseVisionText zzb(@NonNull zzjs zzjs, float f) {
Iterator<zziu> it;
Iterator<zzjl> it2;
FirebaseVisionText.TextBlock textBlock;
Iterator<zzjm> it3;
Iterator<zziu> it4;
Iterator<zzjl> it5;
String str;
FirebaseVisionText.Element element;
Preconditions.checkNotNull(zzjs, "The input TextAnnotation can not be null");
FirebaseVisionText.TextBlock textBlock2 = null;
if (zzjs.getPages().size() <= 0) {
zzaoz.mo10801d("TextAnnotationConverter", "Text Annotation is null, return null");
return null;
}
if (zzjs.getPages().size() > 1) {
zzaoz.mo10801d("TextAnnotationConverter", "Text Annotation has more than one page, which should not happen");
}
ArrayList arrayList = new ArrayList();
Iterator<zzjl> it6 = zzjs.getPages().iterator();
while (it6.hasNext()) {
Iterator<zziu> it7 = it6.next().getBlocks().iterator();
while (it7.hasNext()) {
zziu next = it7.next();
Preconditions.checkNotNull(next, "Input block can not be null");
ArrayList arrayList2 = new ArrayList();
if (next.getParagraphs() == null) {
it2 = it6;
textBlock = textBlock2;
it = it7;
} else {
Iterator<zzjm> it8 = next.getParagraphs().iterator();
while (it8.hasNext()) {
zzjm next2 = it8.next();
if (next2 != null) {
Preconditions.checkNotNull(next2, "Input Paragraph can not be null");
ArrayList arrayList3 = new ArrayList();
ArrayList arrayList4 = new ArrayList();
HashSet<RecognizedLanguage> hashSet = new HashSet();
StringBuilder sb = new StringBuilder();
int i = 0;
float f2 = 0.0f;
while (i < next2.getWords().size()) {
zzjx zzjx = next2.getWords().get(i);
if (zzjx != null) {
Preconditions.checkNotNull(zzjx, "Input Word can not be null");
Rect zza = zzpm.zza(zzjx.zzhq(), f);
it5 = it6;
List<RecognizedLanguage> zze = zze(zzjx.zzhr());
Preconditions.checkNotNull(zzjx, "Input Word can not be null");
String str2 = "";
if (zzjx.getSymbols() == null) {
it4 = it7;
str = str2;
} else {
StringBuilder sb2 = new StringBuilder();
for (zzjr zzjr : zzjx.getSymbols()) {
sb2.append(zzjr.getText());
it7 = it7;
}
it4 = it7;
str = sb2.toString();
}
if (str.isEmpty()) {
it3 = it8;
element = null;
} else {
it3 = it8;
element = new FirebaseVisionText.Element(str, zza, zze, zzjx.getConfidence());
}
if (element != null) {
arrayList4.add(element);
float zza2 = f2 + zzpm.zza(element.getConfidence());
hashSet.addAll(element.getRecognizedLanguages());
sb.append(element.getText());
Preconditions.checkNotNull(zzjx, "Input word can not be null");
String zza3 = zza(zzjx);
if (zza3 != null) {
if (zza3.equals("SPACE") || zza3.equals("SURE_SPACE")) {
str2 = " ";
} else if (zza3.equals("HYPHEN")) {
str2 = Constants.ACCEPT_TIME_SEPARATOR_SERVER;
}
}
sb.append(str2);
Preconditions.checkNotNull(zzjx, "Input word can not be null");
String zza4 = zza(zzjx);
if (!(zza4 != null && (zza4.equals("EOL_SURE_SPACE") || zza4.equals("LINE_BREAK") || zza4.equals("HYPHEN")))) {
if (i != next2.getWords().size() - 1) {
f2 = zza2;
}
}
Preconditions.checkNotNull(arrayList4, "Input elements can not be null");
int size = arrayList4.size();
int i2 = 0;
Rect rect = null;
while (i2 < size) {
Object obj = arrayList4.get(i2);
i2++;
FirebaseVisionText.Element element2 = (FirebaseVisionText.Element) obj;
if (element2.getBoundingBox() != null) {
Rect rect2 = rect == null ? new Rect() : rect;
rect2.union(element2.getBoundingBox());
rect = rect2;
}
}
String sb3 = sb.toString();
ArrayList arrayList5 = new ArrayList();
for (RecognizedLanguage recognizedLanguage : hashSet) {
if (!(recognizedLanguage == null || recognizedLanguage.getLanguageCode() == null || recognizedLanguage.getLanguageCode().isEmpty())) {
arrayList5.add(recognizedLanguage);
}
}
arrayList3.add(new FirebaseVisionText.Line(sb3, rect, arrayList5, arrayList4, Float.compare(zza2, 0.0f) > 0 ? Float.valueOf(zza2 / ((float) arrayList4.size())) : null));
ArrayList arrayList6 = new ArrayList();
hashSet.clear();
arrayList4 = arrayList6;
sb = new StringBuilder();
f2 = 0.0f;
i++;
it6 = it5;
it7 = it4;
it8 = it3;
}
} else {
it5 = it6;
it4 = it7;
it3 = it8;
}
i++;
it6 = it5;
it7 = it4;
it8 = it3;
}
arrayList2.addAll(arrayList3);
}
}
it2 = it6;
it = it7;
if (arrayList2.isEmpty()) {
textBlock = null;
} else {
StringBuilder sb4 = new StringBuilder();
int size2 = arrayList2.size();
int i3 = 0;
while (i3 < size2) {
Object obj2 = arrayList2.get(i3);
i3++;
sb4.append(((FirebaseVisionText.Line) obj2).getText());
sb4.append("\n");
}
textBlock = new FirebaseVisionText.TextBlock(sb4.toString(), zzpm.zza(next.zzhq(), f), zze(next.zzhr()), arrayList2, next.getConfidence());
}
}
if (textBlock != null) {
arrayList.add(textBlock);
}
textBlock2 = null;
it6 = it2;
it7 = it;
}
textBlock2 = null;
}
return new FirebaseVisionText(zzjs.getText(), arrayList);
}
public static List<RecognizedLanguage> zze(@Nullable zzjt zzjt) {
ArrayList arrayList = new ArrayList();
if (!(zzjt == null || zzjt.zzia() == null)) {
for (zziz zziz : zzjt.zzia()) {
RecognizedLanguage zza = RecognizedLanguage.zza(zziz);
if (zza != null) {
arrayList.add(zza);
}
}
}
return arrayList;
}
}
| [
"[email protected]"
] | |
99b113a138b5f57ecee81524036a10eb4a86ae0a | c583e42f22064bc5f3814b3d3c5f8bc62ee47a75 | /src/main/java/com/woime/iboss/bpm/web/BpmConfCountersignController.java | df3682de15b0a271a9d70dfa79eecafa12b3b23d | [] | no_license | vipsql/iboss | c42ab22f553b71cb56431f1e507e25434b238ede | 9329b9a9f29d1289ffc047b44baa184f6e3636ab | refs/heads/master | 2020-03-07T17:21:39.373944 | 2017-04-03T04:19:57 | 2017-04-03T04:19:57 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,079 | java | package com.woime.iboss.bpm.web;
import javax.annotation.Resource;
import org.activiti.engine.ProcessEngine;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.woime.iboss.bpm.persistence.domain.BpmConfCountersign;
import com.woime.iboss.bpm.persistence.manager.BpmConfCountersignManager;
import com.woime.iboss.bpm.persistence.manager.BpmConfNodeManager;
import com.woime.iboss.bpm.persistence.manager.BpmConfUserManager;
import com.woime.iboss.bpm.persistence.manager.BpmProcessManager;
import com.woime.iboss.core.mapper.BeanMapper;
import com.woime.iboss.spi.humantask.CounterSignDTO;
import com.woime.iboss.spi.humantask.TaskDefinitionConnector;
@Controller
@RequestMapping("bpm")
public class BpmConfCountersignController
{
private BpmConfNodeManager bpmConfNodeManager;
private BpmConfUserManager bpmConfUserManager;
private BeanMapper beanMapper = new BeanMapper();
private ProcessEngine processEngine;
private BpmProcessManager bpmProcessManager;
private BpmConfCountersignManager bpmConfCountersignManager;
private TaskDefinitionConnector taskDefinitionConnector;
@RequestMapping("bpm-conf-countersign-save")
public String save(@ModelAttribute BpmConfCountersign bpmConfCountersign, @RequestParam("bpmConfNodeId") Long bpmConfNodeId)
{
BpmConfCountersign dest = bpmConfCountersignManager.get(bpmConfCountersign.getId());
beanMapper.copy(bpmConfCountersign, dest);
bpmConfCountersignManager.save(dest);
String taskDefinitionKey = dest.getBpmConfNode().getCode();
String processDefinitionId = dest.getBpmConfNode().getBpmConfBase().getProcessDefinitionId();
CounterSignDTO counterSign = new CounterSignDTO();
counterSign.setStrategy((dest.getType() == 0) ? "all" : "percent");
counterSign.setRate(dest.getRate());
taskDefinitionConnector.saveCounterSign(taskDefinitionKey, processDefinitionId, counterSign);
return "redirect:/bpm/bpm-conf-user-list.do?bpmConfNodeId=" + bpmConfNodeId;
}
// ~ ======================================================================
@Resource
public void setBpmConfNodeManager(BpmConfNodeManager bpmConfNodeManager)
{
this.bpmConfNodeManager = bpmConfNodeManager;
}
@Resource
public void setBpmConfUserManager(BpmConfUserManager bpmConfUserManager)
{
this.bpmConfUserManager = bpmConfUserManager;
}
@Resource
public void setBpmProcessManager(BpmProcessManager bpmProcessManager)
{
this.bpmProcessManager = bpmProcessManager;
}
@Resource
public void setProcessEngine(ProcessEngine processEngine)
{
this.processEngine = processEngine;
}
@Resource
public void setBpmConfCountersignManager(BpmConfCountersignManager bpmConfCountersignManager)
{
this.bpmConfCountersignManager = bpmConfCountersignManager;
}
@Resource
public void setTaskDefinitionConnector(TaskDefinitionConnector taskDefinitionConnector)
{
this.taskDefinitionConnector = taskDefinitionConnector;
}
}
| [
"[email protected]"
] | |
68d7a78ac17773bb4394e13e2e80f7cc4354bc41 | f5398748ea435d203248eb208850a1d36939e3a8 | /Plugins/EASy-Producer/de.uni-hildesheim.sse.PLugin/src/net/ssehub/easy/producer/eclipse/persistency/eclipse/EASyNature.java | 064184d152e2d68c5c201bfeabefaca45af72125 | [
"Apache-2.0"
] | permissive | SSEHUB/EASyProducer | 20b5a01019485428b642bf3c702665a257e75d1b | eebe4da8f957361aa7ebd4eee6fff500a63ba6cd | refs/heads/master | 2023-06-25T22:40:15.997438 | 2023-06-22T08:54:00 | 2023-06-22T08:54:00 | 16,176,406 | 12 | 2 | null | null | null | null | UTF-8 | Java | false | false | 984 | java |
package net.ssehub.easy.producer.eclipse.persistency.eclipse;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
/**
* The nature for all EASy-Producer projects.
* @author El-Sharkawy
*
*/
public class EASyNature implements IProjectNature {
/**
* ID of this project nature.
*/
public static final String NATURE_ID = "de.uni_hildesheim.sse.EASy-Producer";
/**
* ID copied from Xtext.UI plug-in.
*/
public static final String XTEXT_NATURE_ID = "org.eclipse.xtext.ui.shared.xtextNature";
private IProject project;
@Override
public void configure() throws CoreException {
}
@Override
public void deconfigure() throws CoreException {
}
@Override
public IProject getProject() {
return project;
}
@Override
public void setProject(IProject project) {
this.project = project;
}
}
| [
"[email protected]"
] | |
54d2ce50be92b309458abfea7a0379188ef79189 | 8f9c267bb66d0b0a4309cff5e248fb98a7975af7 | /Toko Buku/Pembeli.java | 1fe0dc5ac51e638ec7f3e73b0452367ffb6a714d | [] | no_license | HoirurRosikin/TugasAkhir | 2addad368cf7fc66377a236bc8e6895526994965 | 552a6149f05627d4925098fbbe7c94328fc76727 | refs/heads/master | 2023-05-23T21:06:51.591610 | 2021-06-16T12:38:31 | 2021-06-16T12:38:31 | 377,482,984 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 849 | java | package PembelianBuku;
public class Pembeli {
String id;
String nama;
String judul;
int jumlah;
long harga;
public Pembeli(String id, String nama, String judul, int jumlah, long harga) {
super();
this.id = id;
this.nama = nama;
this.judul = judul;
this.jumlah = jumlah;
this.harga = harga;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getNama() {
return nama;
}
public void setNama(String nama) {
this.nama = nama;
}
public String getJudul() {
return judul;
}
public void setJudul(String judul) {
this.judul = judul;
}
public int getJumlah() {
return jumlah;
}
public void setJumlah(int jumlah) {
this.jumlah = jumlah;
}
public long getHarga() {
return harga;
}
public void setHarga(long harga) {
this.harga = harga;
}
}
| [
"[email protected]"
] | |
e0edf3e24057fcde2dc83c5fb099e0828c65f479 | 6aed6dfacf4f45c5b4ff1df55368dd7df5e48023 | /MusicdriodNew/MusicdroidUiTest/src/org/catrobat/musicdroid/menutest/TimelineTest.java | 6f69db4031e863b2856057712770c16d14c3182b | [] | no_license | abhiMishka/musicdroid | 21c9e2878e49667e3a5888e7bbf5b6013111ce80 | 9f27b7d4aa5bd96003f051e4c32ad204b26158e3 | refs/heads/master | 2020-12-25T23:20:18.053812 | 2013-11-24T11:31:36 | 2013-11-24T11:31:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,545 | java | /*******************************************************************************
* Catroid: An on-device visual programming system for Android devices
* Copyright (C) 2010-2013 The Catrobat Team
* (<http://developer.catrobat.org/credits>)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* An additional term exception under section 7 of the GNU Affero
* General Public License, version 3, is available at
* http://www.catroid.org/catroid/licenseadditionalterm
*
* 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
******************************************************************************/
package org.catrobat.musicdroid.menutest;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import com.jayway.android.robotium.solo.Solo;
import org.catrobat.musicdroid.MainActivity;
import org.catrobat.musicdroid.R;
import org.catrobat.musicdroid.soundmixer.SoundMixer;
import org.catrobat.musicdroid.soundmixer.timeline.Timeline;
import org.catrobat.musicdroid.soundmixer.timeline.TimelineProgressBar;
import org.catrobat.musicdroid.tools.DeviceInfo;
import org.catrobat.musicdroid.types.SoundType;
public class TimelineTest extends ActivityInstrumentationTestCase2<MainActivity> {
protected Solo solo = null;
protected SoundMixer mixer = null;
protected Timeline timeline = null;
protected UITestHelper helper;
protected ImageButton playImageButton = null;
protected TimelineProgressBar timelineProgressBar = null;
public TimelineTest() {
super(MainActivity.class);
}
@Override
protected void setUp() {
solo = new Solo(getInstrumentation(), getActivity());
mixer = SoundMixer.getInstance();
helper = new UITestHelper(solo, getActivity());
timeline = (Timeline) getActivity().findViewById(R.id.timeline);
playImageButton = (ImageButton) getActivity().findViewById(R.id.btn_play);
timelineProgressBar = (TimelineProgressBar) timeline.findViewById(R.id.timeline_progressBar);
}
@Override
protected void tearDown() {
solo.finishOpenedActivities();
}
public void testTrackLengthSettings() {
int numTextViewsTopBegin = ((RelativeLayout) timeline.getChildAt(0)).getChildCount();
int numViewsBottomBegin = ((RelativeLayout) timeline.getChildAt(1)).getChildCount();
solo.clickOnView(getActivity().findViewById(R.id.btn_settings));
solo.waitForText(getActivity().getString(R.string.soundmixer_context_title));
solo.clickOnView(getActivity().findViewById(R.id.soundmixer_context_length));
solo.sleep(1000);
solo.drag(DeviceInfo.getScreenWidth(solo.getCurrentActivity()) / 2 - 50,
DeviceInfo.getScreenHeight(solo.getCurrentActivity()) / 2,
DeviceInfo.getScreenWidth(solo.getCurrentActivity()) / 2 - 50,
DeviceInfo.getScreenHeight(solo.getCurrentActivity()) / 3, 1);
solo.sleep(1000);
solo.clickOnText(getActivity().getString(R.string.settings_button_apply));
solo.sleep(1000);
assertTrue("SoundMixer is not scrollable", helper.scrollToSide(timeline));
int numTextViewsTopEnd = ((RelativeLayout) timeline.getChildAt(0)).getChildCount();
int numViewsBottomEnd = ((RelativeLayout) timeline.getChildAt(1)).getChildCount();
Log.i("Begin: " + numTextViewsTopBegin, "End: " + numTextViewsTopEnd);
Log.i("Begin: " + numViewsBottomBegin, "End: " + numViewsBottomEnd);
assertFalse(numTextViewsTopBegin == numTextViewsTopEnd);
assertFalse(numViewsBottomBegin == numViewsBottomEnd);
//add one View for each second but only one TextView each 5 seconds
assertTrue(numViewsBottomBegin >= numTextViewsTopBegin * 5);
assertTrue(numViewsBottomEnd >= numTextViewsTopEnd * 5);
}
public void startEndMarkerTest() {
int[] timelineLocation = { 0, 0 };
timeline.getLocationOnScreen(timelineLocation);
int clickXPosition = timelineLocation[0] + 200;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_start_point);
View startMarker = timeline.findViewById(R.id.timeline_start_point);
int margin = ((RelativeLayout.LayoutParams) startMarker.getLayoutParams()).leftMargin;
int pixelPerSecond = SoundMixer.getInstance().getPixelPerSecond();
Log.i("StartEndMarkerTest", "Margin: " + margin + " ClickX: " + clickXPosition + " PpS: " + pixelPerSecond);
assertTrue(margin >= clickXPosition - pixelPerSecond * 2 && margin <= clickXPosition + pixelPerSecond * 2);
//End Marker
clickXPosition = timelineLocation[0] + 600;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_end_point);
View endMarker = timeline.findViewById(R.id.timeline_end_point);
int marginEnd = ((RelativeLayout.LayoutParams) endMarker.getLayoutParams()).leftMargin;
Log.i("StartEndMarkerTest", "Margin: " + marginEnd + " ClickX: " + clickXPosition + " PpS: " + pixelPerSecond);
assertTrue(marginEnd >= clickXPosition - pixelPerSecond && marginEnd <= clickXPosition + pixelPerSecond);
}
public void testStartMarkerBeforeEndMarker() {
int[] timelineLocation = { 0, 0 };
timeline.getLocationOnScreen(timelineLocation);
int clickXPosition = timelineLocation[0] + 200;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_start_point);
View startMarker = timeline.findViewById(R.id.timeline_start_point);
//place endMarker before startMarker - will fail
clickXPosition = timelineLocation[0] + 100;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_end_point);
View endMarker = timeline.findViewById(R.id.timeline_end_point);
assertTrue(endMarker.getVisibility() == View.GONE);
//place endMarker behind startMarker
clickXPosition = timelineLocation[0] + 400;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_end_point);
//place startMarker behind endMarker - will fail
int oldMarginStartMarker = ((RelativeLayout.LayoutParams) startMarker.getLayoutParams()).leftMargin;
clickXPosition = timelineLocation[0] + 600;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_start_point);
int newMarginStartMarker = ((RelativeLayout.LayoutParams) startMarker.getLayoutParams()).leftMargin;
assertTrue(oldMarginStartMarker == newMarginStartMarker);
}
public void testMoveMarker() {
int[] timelineLocation = { 0, 0 };
timeline.getLocationOnScreen(timelineLocation);
int clickXPosition = timelineLocation[0] + 200;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_start_point);
View startMarker = timeline.findViewById(R.id.timeline_start_point);
clickXPosition = timelineLocation[0] + 400;
helper.addTimelineMarker(clickXPosition, timelineLocation[1], R.string.timeline_menu_entry_end_point);
View endMarker = timeline.findViewById(R.id.timeline_end_point);
int[] startMarkerLocation = { 0, 0 };
startMarker.getLocationOnScreen(startMarkerLocation);
int startMargin = ((RelativeLayout.LayoutParams) startMarker.getLayoutParams()).leftMargin;
int endMargin = ((RelativeLayout.LayoutParams) endMarker.getLayoutParams()).leftMargin;
int drag = endMargin - startMargin;
solo.drag(startMarkerLocation[0], startMarkerLocation[0] + drag + 10, startMarkerLocation[1],
startMarkerLocation[1], 20);
solo.sleep(1000);
assertTrue(((RelativeLayout.LayoutParams) startMarker.getLayoutParams()).leftMargin < ((RelativeLayout.LayoutParams) endMarker
.getLayoutParams()).leftMargin);
}
public void testTimelineProgressBar() {
LayoutParams lp = (LayoutParams) timelineProgressBar.getLayoutParams();
assertTrue(lp.width == 0);
helper.addTrack(SoundType.DRUMS);
solo.clickOnView(playImageButton);
solo.sleep(5000);
lp = (LayoutParams) timelineProgressBar.getLayoutParams();
assertTrue(lp.width >= SoundMixer.getInstance().getPixelPerSecond() * 4);
//assert progressbar remains unchanged after pressing stop button
solo.clickOnView(playImageButton);
lp = (LayoutParams) timelineProgressBar.getLayoutParams();
assertTrue(lp.width >= SoundMixer.getInstance().getPixelPerSecond() * 5);
}
public void testTimelineProgessBarResetOnRewind() {
testTimelineProgressBar();
ImageButton rewindImageButton = (ImageButton) getActivity().findViewById(R.id.btn_rewind);
solo.clickOnView(rewindImageButton);
LayoutParams lp = (LayoutParams) timelineProgressBar.getLayoutParams();
assertTrue(lp.width == 0);
}
public void testTimelineProgressBarUnchangedOnPause() {
testTimelineProgressBar();
LayoutParams lp = (LayoutParams) timelineProgressBar.getLayoutParams();
int startWidth = lp.width;
solo.clickOnView(playImageButton);
solo.sleep(1000);
lp = (LayoutParams) timelineProgressBar.getLayoutParams();
assertTrue(lp.width >= startWidth + SoundMixer.getInstance().getPixelPerSecond());
solo.clickOnView(playImageButton);
}
}
| [
"[email protected]"
] | |
96a1968ebe038f04915f218e08de80e38ad277a9 | a66a4d91639836e97637790b28b0632ba8d0a4f9 | /src/generators/graph/prim/Prim.java | 53819a7a9792e7d5d97c58e0c72b39dd14d20201 | [] | no_license | roessling/animal-av | 7d0ba53dda899b052a6ed19992fbdfbbc62cf1c9 | 043110cadf91757b984747750aa61924a869819f | refs/heads/master | 2021-07-13T05:31:42.223775 | 2020-02-26T14:47:31 | 2020-02-26T14:47:31 | 206,062,707 | 0 | 2 | null | 2020-10-13T15:46:14 | 2019-09-03T11:37:11 | Java | UTF-8 | Java | false | false | 15,621 | java | package generators.graph.prim;
import extras.lifecycle.common.Variable;
import extras.lifecycle.monitor.CheckpointUtils;
import generators.framework.Generator;
import generators.framework.GeneratorType;
import generators.framework.properties.AnimationPropertiesContainer;
import java.awt.Color;
import java.awt.Font;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.Vector;
import algoanim.animalscript.AnimalScript;
import algoanim.primitives.Graph;
import algoanim.primitives.IntMatrix;
import algoanim.primitives.SourceCode;
import algoanim.primitives.Text;
import algoanim.primitives.generators.Language;
import algoanim.properties.AnimationPropertiesKeys;
import algoanim.properties.GraphProperties;
import algoanim.properties.MatrixProperties;
import algoanim.properties.RectProperties;
import algoanim.properties.SourceCodeProperties;
import algoanim.properties.TextProperties;
import algoanim.util.Coordinates;
import algoanim.util.DisplayOptions;
import algoanim.util.Node;
public class Prim implements Generator {
protected Language lang;
Node node;
MatrixProperties matrixprops;
RectProperties rectprops;
GraphProperties graphprops;
TextProperties textprops;
IntMatrix matrix;
String name;
int[][] graphAdjacencyMatrix;
static Node[] graphNodes;
static String[] labels;
DisplayOptions display;
public SourceCode sc, labelnode, distancenode; // to
// ensure
// it
// is
// visible
// out
// side
// the
// method...
public Graph gr;
public int[] nodeIndices;
public AnimationPropertiesContainer animationProperties;
Node start;
int[] distance;
Node[] predecessor;
boolean[] besucht;
int indextarjet, indexstart;
int size;
public int inc = 0;
SourceCodeProperties scProps = new SourceCodeProperties();
// private Node n1;
public void showGraph(Graph graph) {
int size = graph.getSize();
graphNodes = new Node[size];
labels = new String[size];
// int [][] mat= graph.getAdjacencyMatrix();
for (int i = 0; i < graph.getSize(); i++) {
graphNodes[i] = graph.getNode(i);
labels[i] = graph.getNodeLabel(i);
}
graphprops = (GraphProperties) animationProperties
.getPropertiesByName("graph");
gr = lang.newGraph(graph.getName(), graph.getAdjacencyMatrix(), graphNodes,
labels, graph.getDisplayOptions(), graphprops);
}
public void prim(Node start, Graph gra) {
showGraph(gra);
showSourceCode();
Text text5 = lang.newText(new Coordinates(600, 400), "", "text", display,
textprops);
// TicksTiming timing = new TicksTiming(1);
// TicksTiming timing1 = new TicksTiming(2);
size = gra.getSize();
graphNodes = new Node[size];
labels = new String[size];
// int [][] mat= gra.getAdjacencyMatrix();
distance = new int[size];
predecessor = new Node[size];
besucht = new boolean[size];
Vector<Node> set = new Vector<Node>();
// initialisierung Distance und Alle Knoten sind unbesucht
sc.highlight(0);
lang.nextStep();
sc.toggleHighlight(0, 1);
sc.highlight(2);
sc.highlight(3);
sc.highlight(5);
for (int i = 0; i < gra.getSize(); i++) {
distancenode = lang.newSourceCode(new Coordinates(80, 500 + inc),
"distancenode" + i, null, scProps);
distancenode.addCodeLine("Distance", null, 0, null);
distancenode
.addCodeLine("" + gr.getNodeLabel(i), null, 6 + (3 * i), null);
graphNodes[i] = gr.getNode(i);
labels[i] = gr.getNodeLabel(i);
set.add(gr.getNode(i));
if (start == gr.getNode(i)) {
distancenode = lang.newSourceCode(new Coordinates(80, 545 + inc),
"distancenode" + i, null, scProps);
distancenode.hide();
distancenode.addCodeLine("", null, 6 + (3 * i), null);
distancenode = lang.newSourceCode(new Coordinates(80, 545 + inc),
"distancenode" + i, null, scProps);
distancenode.addCodeLine("0", null, 6 + (3 * i), null);
distance[i] = 0;
predecessor[i] = null;
indexstart = i;
} else {
distance[i] = 5000;
besucht[i] = false;
predecessor[i] = null;
distancenode = lang.newSourceCode(new Coordinates(80, 545 + inc),
"distancenode" + i, null, scProps);
distancenode.addCodeLine("*", null, 6 + (3 * i), null);
}
text5.setText("Initialisierung Distance Alle Knoten ", null, null);
}
lang.nextStep();
sc.unhighlight(1);
sc.unhighlight(2);
sc.unhighlight(3);
sc.toggleHighlight(5, 6);
text5.setText(
"Füge alle Knoten in der Set ein. Start with node "
+ gr.getNodeLabel(indexstart), null, null);
lang.nextStep();
sc.toggleHighlight(6, 7);
while (!set.isEmpty()) {
sc.highlight(7);
text5
.setText(
"Prüfe ob Set leer ist, andernfalls besuche nächste Knoten des Graphes",
null, null);
lang.nextStep();
sc.toggleHighlight(7, 8);
Node n = getNeighbour(set);
int y = getByName(n);
set.remove(n);
gr.highlightNode(y, null, null);
if (y != indexstart)
gr.highlightEdge(getByName(predecessor[y]), y, null, null);
if (getByName(predecessor[y]) >= 0)
CheckpointUtils.checkpointEvent(this, "chooseEdge", new Variable(
"node1", gr.getNodeLabel(getByName(predecessor[y]))), new Variable(
"node2", gr.getNodeLabel(y)));
text5.setText(
"Die nächste noch nicht besuchte Knoten mit der kleinsten Distance "
+ gr.getNodeLabel(y) + " wird aus dem Set geholt", null, null);
CheckpointUtils.checkpointEvent(this, "getNextNode", new Variable("node",
gr.getNodeLabel(y)));// ////////////////////////////////
lang.nextStep();
text5.setText("", null, null);
sc.toggleHighlight(8, 9);
int[] Edge = gr.getEdgesForNode(y);
gr.highlightNode(y, null, null);
labelnode = lang.newSourceCode(new Coordinates(50, 578 + inc),
"labelnode", null, scProps);
labelnode.addCodeLine(gr.getNodeLabel(y), null, 0, null);
labelnode = lang.newSourceCode(new Coordinates(50, 578 + inc),
"labelnode", null, scProps);
labelnode.addCodeLine("|", null, 4, null);
for (int j = 0; j < Edge.length; j++) {
sc.highlight(9);
gr.highlightEdge(y, j, null, null);
gr.highlightNode(j, null, null);
text5.setText(
"Alle Knoten auf die Kanten der aktuellen Knoten ("
+ gr.getNodeLabel(y) + ") verweise, werden überprüft", null,
null);
if ((gr.getEdgeWeight(y, j) != 0)
&& (gr.getEdgeWeight(y, j) < distance[j]) && (besucht[j] == false)) {
lang.nextStep();
sc.toggleHighlight(9, 11);
sc.highlight(12);
sc.highlight(13);
// text5.setText("", null, null);
distance[j] = gr.getEdgeWeight(y, j);
predecessor[j] = gr.getNode(y);
lang.nextStep();
}
else if (gr.getEdgeWeight(y, j) != 0) {
gr.highlightEdge(y, j, null, null);
lang.nextStep();
}
sc.unhighlight(11);
sc.unhighlight(12);
sc.unhighlight(13);
distancenode = lang.newSourceCode(new Coordinates(80, 580 + inc),
"distancenode" + j, null, scProps);
if (distance[j] < 5000)
distancenode.addCodeLine("" + distance[j], null, 6 + (j * 3), null);
else
distancenode.addCodeLine("*", null, 6 + (j * 3), null);
gr.unhighlightEdge(y, j, null, null);
if ((besucht[j] == false) && (j != y))
gr.unhighlightNode(j, null, null);
}
gr.highlightNode(y, null, null);
sc.unhighlight(13);
sc.unhighlight(9);
besucht[y] = true;
lang.addLine("************************************************************");
inc = inc + 20;
}
int cost = 0;
for (int j = 0; j < distance.length; j++) {
cost = distance[j] + cost;
}
CheckpointUtils.checkpointEvent(this, "miniCost", new Variable(
"costOfTree", cost));// /////////////////////////////////////
sc.unhighlight(7);
text5.setText("", null, null);
}
public Node getNeighbour(Vector<Node> t) {
int kleinsteGewicht = 90000;
Node nodemitKleinsteGewicht = null;
Enumeration<Node> u = t.elements();
while (u.hasMoreElements()) {
Node m = u.nextElement();
int x = getByName(m);
if (distance[x] < kleinsteGewicht) {
kleinsteGewicht = distance[x];
nodemitKleinsteGewicht = m;
}
}
return nodemitKleinsteGewicht;
}
public int getByName(Node node) {
for (int i = 0; i < gr.getSize(); i++) {
if (node == gr.getNode(i)) {
return i;
}
}
return -1;
}
public Node getpredecessor(Node node) {
int x = getByName(node);
return predecessor[x];
}
public void init() { // initialize the main elements
// Generate a new Language instance for content creation
// Parameter: Animation title, author, width, height
lang = new AnimalScript("Dijkstra Animation", "Madieha + Bouchra", 620, 480);
// Activate step control
lang.setStepMode(true);
// create array properties with default values
matrixprops = new MatrixProperties();
textprops = new TextProperties();
rectprops = new RectProperties();
// Redefine properties: border red, filled with gray
matrixprops.set(AnimationPropertiesKeys.ELEMENTCOLOR_PROPERTY, Color.BLACK);// color
// red
matrixprops.set(AnimationPropertiesKeys.ELEMHIGHLIGHT_PROPERTY, Color.red);
matrixprops.set(AnimationPropertiesKeys.FILLED_PROPERTY, true); // filled
matrixprops.set(AnimationPropertiesKeys.FILL_PROPERTY, Color.pink); // fill
// color
// gray
matrixprops.set(AnimationPropertiesKeys.CELLHIGHLIGHT_PROPERTY,
Color.MAGENTA);
matrixprops.set(AnimationPropertiesKeys.DEPTH_PROPERTY, 1);
textprops.set(AnimationPropertiesKeys.COLOR_PROPERTY, Color.blue);
textprops.set(AnimationPropertiesKeys.FONT_PROPERTY, new Font("Monospaced",
Font.BOLD, 14));
}
public void showSourceCode() {
// first, set the visual properties for the source code
scProps.set(AnimationPropertiesKeys.CONTEXTCOLOR_PROPERTY, Color.CYAN);
scProps.set(AnimationPropertiesKeys.FONT_PROPERTY, new Font("Monospaced",
Font.BOLD, 16));
scProps.set(AnimationPropertiesKeys.HIGHLIGHTCOLOR_PROPERTY, Color.red);
scProps.set(AnimationPropertiesKeys.COLOR_PROPERTY, Color.BLACK);
// now, create the source code entity
sc = lang.newSourceCode(new Coordinates(40, 100), "sourceCode", null,
scProps);
labelnode = lang.newSourceCode(new Coordinates(50, 530), "labelnode", null,
scProps);
distancenode = lang.newSourceCode(new Coordinates(55, 600), "distancenode",
null, scProps);
sc.addCodeLine("public void Prim(Node start,Graph G) {", null, 0, null);
sc.addCodeLine("for(Node u :g.getNode()){", null, 1, null);
sc.addCodeLine("Vorgänger[u]== nil;", null, 2, null);
sc.addCodeLine("Distance[u] == 9000;", null, 2, null);
sc.addCodeLine("}", null, 1, null);
sc.addCodeLine("start.distance = 0;", null, 1, null);
sc.addCodeLine("Q <- G[u]", null, 1, null);
sc.addCodeLine("while(!Q.isEmpty(){", null, 1, null);
sc.addCodeLine("Node n = Q.Extract-Min(Q);", null, 2, null);
sc.addCodeLine("for(Edge e:n.getEdges()){", null, 3, null);
sc.addCodeLine("v = e.getDestinations();", null, 4, null);
sc.addCodeLine("if (getEdgeWeight(u,v)<distance[v]){", null, 4, null);
sc.addCodeLine("distance[v]==getEdgeWeight(u,v)", null, 5, null);
sc.addCodeLine("predecessor[v]==u;", null, 5, null);
sc.addCodeLine("}", null, 4, null);
sc.addCodeLine("}", null, 3, null);
sc.addCodeLine("}", null, 1, null);
sc.addCodeLine("}", null, 0, null);
sc.addCodeLine("", null, 0, null);
labelnode
.addCodeLine(
"---------------------------------------------------------------------------",
null, 0, null);
labelnode.addCodeLine("|", null, 4, null);
}
public String getCodeExample() {
return "Straight forward Warshall Algorithm"; // to give readers an
// impression
}
public Locale getContentLocale() {
return Locale.US; // US-English
}
public String getDescription() {
return "Animates Warshall with Source Code + Highlighting"; // description
}
public String getFileExtension() {
return Generator.ANIMALSCRIPT_FORMAT_EXTENSION;
}
public GeneratorType getGeneratorType() {
return new GeneratorType(GeneratorType.GENERATOR_TYPE_GRAPH); // this is
// about
// sorting!
}
public String getName() {
return "Prim"; // the title to be displayed
}
public String generate(AnimationPropertiesContainer props,
Hashtable<String, Object> primitives) {
init(); // ensure all properties are set up :-)
Enumeration<String> iter = primitives.keys();
while (iter.hasMoreElements()) {
String Element = (String) iter.nextElement();
if (Element.contains("graph"))
gr = (Graph) primitives.get(Element);
}
animationProperties = props;
prim(gr.getStartNode(), gr);
return lang.toString();
}
@Override
public String getAlgorithmName() {
return "Prim Algorithm";
}
@Override
public String getOutputLanguage() {
return Generator.JAVA_OUTPUT;
}
@Override
public String getAnimationAuthor() {
return "Bouchra Elfakir";
}
}
| [
"[email protected]"
] | |
832bfc0d44958ee84010676893dbbda5dc1c6cd4 | 19b37c9c820485707b62555dd4b052741a11851b | /src/com/company/startingMenu.java | 18cc440788ada24a5c372def7d4de348dae54e89 | [] | no_license | MarioPardo/MiniSpaceInvaders | a76ccede3163c50af5266f50680ed08a3ecc57ee | 45fc4107513662cc4fecca5a1929bbb374c793c2 | refs/heads/master | 2021-07-11T05:08:05.399787 | 2020-08-30T22:07:12 | 2020-08-30T22:07:12 | 195,665,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,730 | java | package com.company;
import javax.swing.*;
import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class startingMenu extends JPanel
{
private JLabel titleLbl = new JLabel(" SPACE INVADERS");
private JButton startBtn = new JButton(); //start game butotn
private JTextField bulletSpeedTxt = new JTextField(); //text field to enter bullet speed
private JTextField nameTxt = new JTextField();
public int bulletSpeed; //stores bulletspeed
public static String name;
public startingMenu() //constructor, copies this alienlist to the shooter's alienlist
{
setLayout(new BorderLayout()); //sets layout
//start button
startBtn.setBackground(Color.white); //makes butotn white
startBtn.setFont(new Font("TimesRoman", Font.PLAIN, 30)); //sets button font
startBtn.setText("START!"); //makes button say start
startBtn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{ //this is when pressed
bulletSpeed = Integer.parseInt(bulletSpeedTxt.getText()); //store the bullet speed entered
name = nameTxt.getText();
Main.startGame(); //calls start game method on main
}
});
add(startBtn,BorderLayout.SOUTH); //puts the button at bottom of screen
//bullet speed
bulletSpeedTxt.setText("Enter your desired Bullet Speed!");
add(bulletSpeedTxt,BorderLayout.LINE_START); //puts textbox in middle of screen
bulletSpeedTxt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{ //when enter key is pressed
bulletSpeed = Integer.parseInt(bulletSpeedTxt.getText()); //save the bulletspeed
}
});
//name
nameTxt.setText("Please Enter your Name");
add(nameTxt,BorderLayout.LINE_END); //puts textbox in middle of screen
bulletSpeedTxt.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e)
{ //when enter key is pressed
name = nameTxt.getText(); //save the bulletspeed
}
});
titleLbl.setBackground(Color.white);
titleLbl.setFont(new Font("TimesRoman", Font.PLAIN, 30)); //sets button font
add(titleLbl, BorderLayout.PAGE_START);
}
}
| [
"[email protected]"
] | |
a782ead23c18c7d6d8c642605ba6a36e2d634480 | b52cd5efdc1fb07c0e7cf3c79fef788017368dd3 | /icu4j/main/tests/core/src/com/ibm/icu/dev/test/format/MessageRegressionTest.java | 28a574314654201867fd8fc31e051577430058f7 | [
"LicenseRef-scancode-unicode",
"ICU",
"BSD-3-Clause",
"NAIST-2003",
"LicenseRef-scancode-public-domain",
"BSD-2-Clause"
] | permissive | scto/external_icu | 5e5fa83e1d0aca62e9021e9476fad6e4243dddec | dd2d1b20b229e5a4960c3030b117574f215e7f80 | refs/heads/pie-caf | 2023-04-16T13:38:54.928083 | 2019-06-14T13:40:34 | 2019-06-14T13:40:34 | 195,273,605 | 0 | 0 | NOASSERTION | 2023-04-04T00:03:14 | 2019-07-04T16:32:11 | Java | UTF-8 | Java | false | false | 37,866 | java | // © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html#License
/*
**********************************************************************
* Copyright (c) 2005-2011, International Business Machines
* Corporation and others. All Rights Reserved.
**********************************************************************
* Author: Alan Liu
* Created: April 12, 2004
* Since: ICU 3.0
**********************************************************************
*/
/**
* MessageRegressionTest.java
*
* @test 1.29 01/03/12
* @bug 4031438 4058973 4074764 4094906 4104976 4105380 4106659 4106660 4106661
* 4111739 4112104 4113018 4114739 4114743 4116444 4118592 4118594 4120552
* 4142938 4169959 4232154 4293229
* @summary Regression tests for MessageFormat and associated classes
*/
/*
(C) Copyright Taligent, Inc. 1996 - All Rights Reserved
(C) Copyright IBM Corp. 1996 - All Rights Reserved
The original version of this source code and documentation is copyrighted and
owned by Taligent, Inc., a wholly-owned subsidiary of IBM. These materials are
provided under terms of a License Agreement between Taligent and Sun. This
technology is protected by multiple US and International patents. This notice and
attribution to Taligent may not be removed.
Taligent is a registered trademark of Taligent, Inc.
*/
package com.ibm.icu.dev.test.format;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.text.ChoiceFormat;
import java.text.ParsePosition;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.text.MessageFormat;
import com.ibm.icu.text.NumberFormat;
import com.ibm.icu.util.ULocale;
@RunWith(JUnit4.class)
public class MessageRegressionTest extends TestFmwk {
/* @bug 4074764
* Null exception when formatting pattern with MessageFormat
* with no parameters.
*/
@Test
public void Test4074764() {
String[] pattern = {"Message without param",
"Message with param:{0}",
"Longer Message with param {0}"};
//difference between the two param strings are that
//in the first one, the param position is within the
//length of the string without param while it is not so
//in the other case.
MessageFormat messageFormatter = new MessageFormat("");
try {
//Apply pattern with param and print the result
messageFormatter.applyPattern(pattern[1]);
Object[] paramArray = {new String("BUG"), new Date()};
String tempBuffer = messageFormatter.format(paramArray);
if (!tempBuffer.equals("Message with param:BUG"))
errln("MessageFormat with one param test failed.");
logln("Formatted with one extra param : " + tempBuffer);
//Apply pattern without param and print the result
messageFormatter.applyPattern(pattern[0]);
tempBuffer = messageFormatter.format(null);
if (!tempBuffer.equals("Message without param"))
errln("MessageFormat with no param test failed.");
logln("Formatted with no params : " + tempBuffer);
tempBuffer = messageFormatter.format(paramArray);
if (!tempBuffer.equals("Message without param"))
errln("Formatted with arguments > subsitution failed. result = " + tempBuffer.toString());
logln("Formatted with extra params : " + tempBuffer);
//This statement gives an exception while formatting...
//If we use pattern[1] for the message with param,
//we get an NullPointerException in MessageFormat.java(617)
//If we use pattern[2] for the message with param,
//we get an StringArrayIndexOutOfBoundsException in MessageFormat.java(614)
//Both are due to maxOffset not being reset to -1
//in applyPattern() when the pattern does not
//contain any param.
} catch (Exception foo) {
errln("Exception when formatting with no params.");
}
}
/* @bug 4058973
* MessageFormat.toPattern has weird rounding behavior.
*
* ICU 4.8: This test is commented out because toPattern() has been changed to return
* the original pattern string, rather than reconstituting a new (equivalent) one.
* This trivially eliminates issues with rounding or any other pattern string differences.
*/
/*public void Test4058973() {
MessageFormat fmt = new MessageFormat("{0,choice,0#no files|1#one file|1< {0,number,integer} files}");
String pat = fmt.toPattern();
if (!pat.equals("{0,choice,0.0#no files|1.0#one file|1.0< {0,number,integer} files}")) {
errln("MessageFormat.toPattern failed");
}
}*/
/* @bug 4031438
* More robust message formats.
*/
@Test
public void Test4031438() {
String pattern1 = "Impossible {1} has occurred -- status code is {0} and message is {2}.";
String pattern2 = "Double '' Quotes {0} test and quoted '{1}' test plus 'other {2} stuff'.";
MessageFormat messageFormatter = new MessageFormat("");
try {
logln("Apply with pattern : " + pattern1);
messageFormatter.applyPattern(pattern1);
Object[] paramArray = {new Integer(7)};
String tempBuffer = messageFormatter.format(paramArray);
if (!tempBuffer.equals("Impossible {1} has occurred -- status code is 7 and message is {2}."))
errln("Tests arguments < substitution failed");
logln("Formatted with 7 : " + tempBuffer);
ParsePosition status = new ParsePosition(0);
Object[] objs = messageFormatter.parse(tempBuffer, status);
if (objs[paramArray.length] != null)
errln("Parse failed with more than expected arguments");
for (int i = 0; i < objs.length; i++) {
if (objs[i] != null && !objs[i].toString().equals(paramArray[i].toString())) {
errln("Parse failed on object " + objs[i] + " at index : " + i);
}
}
tempBuffer = messageFormatter.format(null);
if (!tempBuffer.equals("Impossible {1} has occurred -- status code is {0} and message is {2}."))
errln("Tests with no arguments failed");
logln("Formatted with null : " + tempBuffer);
logln("Apply with pattern : " + pattern2);
messageFormatter.applyPattern(pattern2);
tempBuffer = messageFormatter.format(paramArray);
if (!tempBuffer.equals("Double ' Quotes 7 test and quoted {1} test plus 'other {2} stuff'."))
errln("quote format test (w/ params) failed.");
logln("Formatted with params : " + tempBuffer);
tempBuffer = messageFormatter.format(null);
if (!tempBuffer.equals("Double ' Quotes {0} test and quoted {1} test plus 'other {2} stuff'."))
errln("quote format test (w/ null) failed.");
logln("Formatted with null : " + tempBuffer);
logln("toPattern : " + messageFormatter.toPattern());
} catch (Exception foo) {
warnln("Exception when formatting in bug 4031438. "+foo.getMessage());
}
}
@Test
public void Test4052223()
{
ParsePosition pos = new ParsePosition(0);
if (pos.getErrorIndex() != -1) {
errln("ParsePosition.getErrorIndex initialization failed.");
}
MessageFormat fmt = new MessageFormat("There are {0} apples growing on the {1} tree.");
String str = new String("There is one apple growing on the peach tree.");
Object[] objs = fmt.parse(str, pos);
logln("unparsable string , should fail at " + pos.getErrorIndex());
if (pos.getErrorIndex() == -1)
errln("Bug 4052223 failed : parsing string " + str);
pos.setErrorIndex(4);
if (pos.getErrorIndex() != 4)
errln("setErrorIndex failed, got " + pos.getErrorIndex() + " instead of 4");
if (objs != null) {
errln("objs should be null");
}
ChoiceFormat f = new ChoiceFormat(
"-1#are negative|0#are no or fraction|1#is one|1.0<is 1+|2#are two|2<are more than 2.");
pos.setIndex(0); pos.setErrorIndex(-1);
Number obj = f.parse("are negative", pos);
if (pos.getErrorIndex() != -1 && obj.doubleValue() == -1.0)
errln("Parse with \"are negative\" failed, at " + pos.getErrorIndex());
pos.setIndex(0); pos.setErrorIndex(-1);
obj = f.parse("are no or fraction ", pos);
if (pos.getErrorIndex() != -1 && obj.doubleValue() == 0.0)
errln("Parse with \"are no or fraction\" failed, at " + pos.getErrorIndex());
pos.setIndex(0); pos.setErrorIndex(-1);
obj = f.parse("go postal", pos);
if (pos.getErrorIndex() == -1 && !Double.isNaN(obj.doubleValue()))
errln("Parse with \"go postal\" failed, at " + pos.getErrorIndex());
}
/* @bug 4104976
* ChoiceFormat.equals(null) throws NullPointerException
*/
@Test
public void Test4104976()
{
double[] limits = {1, 20};
String[] formats = {"xyz", "abc"};
ChoiceFormat cf = new ChoiceFormat(limits, formats);
try {
log("Compares to null is always false, returned : ");
logln(cf.equals(null) ? "TRUE" : "FALSE");
} catch (Exception foo) {
errln("ChoiceFormat.equals(null) throws exception.");
}
}
/* @bug 4106659
* ChoiceFormat.ctor(double[], String[]) doesn't check
* whether lengths of input arrays are equal.
*/
@Test
public void Test4106659()
{
double[] limits = {1, 2, 3};
String[] formats = {"one", "two"};
ChoiceFormat cf = null;
try {
cf = new ChoiceFormat(limits, formats);
} catch (Exception foo) {
logln("ChoiceFormat constructor should check for the array lengths");
cf = null;
}
if (cf != null) errln(cf.format(5));
}
/* @bug 4106660
* ChoiceFormat.ctor(double[], String[]) allows unordered double array.
* This is not a bug, added javadoc to emphasize the use of limit
* array must be in ascending order.
*/
@Test
public void Test4106660()
{
double[] limits = {3, 1, 2};
String[] formats = {"Three", "One", "Two"};
ChoiceFormat cf = new ChoiceFormat(limits, formats);
double d = 5.0;
String str = cf.format(d);
if (!str.equals("Two"))
errln("format(" + d + ") = " + cf.format(d));
}
/* @bug 4111739
* MessageFormat is incorrectly serialized/deserialized.
*/
@Test
public void Test4111739()
{
MessageFormat format1 = null;
MessageFormat format2 = null;
ObjectOutputStream ostream = null;
ByteArrayOutputStream baos = null;
ObjectInputStream istream = null;
try {
baos = new ByteArrayOutputStream();
ostream = new ObjectOutputStream(baos);
} catch(IOException e) {
errln("Unexpected exception : " + e.getMessage());
return;
}
try {
format1 = new MessageFormat("pattern{0}");
ostream.writeObject(format1);
ostream.flush();
byte bytes[] = baos.toByteArray();
istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
format2 = (MessageFormat)istream.readObject();
} catch(Exception e) {
errln("Unexpected exception : " + e.getMessage());
}
if (!format1.equals(format2)) {
errln("MessageFormats before and after serialization are not" +
" equal\nformat1 = " + format1 + "(" + format1.toPattern() + ")\nformat2 = " +
format2 + "(" + format2.toPattern() + ")");
} else {
logln("Serialization for MessageFormat is OK.");
}
}
/* @bug 4114743
* MessageFormat.applyPattern allows illegal patterns.
*/
@Test
public void Test4114743()
{
String originalPattern = "initial pattern";
MessageFormat mf = new MessageFormat(originalPattern);
String illegalPattern = "ab { '}' de";
try {
mf.applyPattern(illegalPattern);
errln("illegal pattern: \"" + illegalPattern + "\"");
} catch (IllegalArgumentException foo) {
if (illegalPattern.equals(mf.toPattern()))
errln("pattern after: \"" + mf.toPattern() + "\"");
}
}
/* @bug 4116444
* MessageFormat.parse has different behavior in case of null.
*/
@Test
public void Test4116444()
{
String[] patterns = {"", "one", "{0,date,short}"};
MessageFormat mf = new MessageFormat("");
for (int i = 0; i < patterns.length; i++) {
String pattern = patterns[i];
mf.applyPattern(pattern);
try {
Object[] array = mf.parse(null, new ParsePosition(0));
logln("pattern: \"" + pattern + "\"");
log(" parsedObjects: ");
if (array != null) {
log("{");
for (int j = 0; j < array.length; j++) {
if (array[j] != null)
err("\"" + array[j].toString() + "\"");
else
log("null");
if (j < array.length - 1) log(",");
}
log("}") ;
} else {
log("null");
}
logln("");
} catch (Exception e) {
errln("pattern: \"" + pattern + "\"");
errln(" Exception: " + e.getMessage());
}
}
}
/* @bug 4114739 (FIX and add javadoc)
* MessageFormat.format has undocumented behavior about empty format objects.
*/
@Test
public void Test4114739()
{
MessageFormat mf = new MessageFormat("<{0}>");
Object[] objs1 = null;
Object[] objs2 = {};
Object[] objs3 = {null};
try {
logln("pattern: \"" + mf.toPattern() + "\"");
log("format(null) : ");
logln("\"" + mf.format(objs1) + "\"");
log("format({}) : ");
logln("\"" + mf.format(objs2) + "\"");
log("format({null}) :");
logln("\"" + mf.format(objs3) + "\"");
} catch (Exception e) {
errln("Exception thrown for null argument tests.");
}
}
/* @bug 4113018
* MessageFormat.applyPattern works wrong with illegal patterns.
*/
@Test
public void Test4113018()
{
String originalPattern = "initial pattern";
MessageFormat mf = new MessageFormat(originalPattern);
String illegalPattern = "format: {0, xxxYYY}";
logln("pattern before: \"" + mf.toPattern() + "\"");
logln("illegal pattern: \"" + illegalPattern + "\"");
try {
mf.applyPattern(illegalPattern);
errln("Should have thrown IllegalArgumentException for pattern : " + illegalPattern);
} catch (IllegalArgumentException e) {
if (illegalPattern.equals(mf.toPattern()))
errln("pattern after: \"" + mf.toPattern() + "\"");
}
}
/* @bug 4106661
* ChoiceFormat is silent about the pattern usage in javadoc.
*/
@Test
public void Test4106661()
{
ChoiceFormat fmt = new ChoiceFormat(
"-1#are negative| 0#are no or fraction | 1#is one |1.0<is 1+ |2#are two |2<are more than 2.");
logln("Formatter Pattern : " + fmt.toPattern());
logln("Format with -INF : " + fmt.format(Double.NEGATIVE_INFINITY));
logln("Format with -1.0 : " + fmt.format(-1.0));
logln("Format with 0 : " + fmt.format(0));
logln("Format with 0.9 : " + fmt.format(0.9));
logln("Format with 1.0 : " + fmt.format(1));
logln("Format with 1.5 : " + fmt.format(1.5));
logln("Format with 2 : " + fmt.format(2));
logln("Format with 2.1 : " + fmt.format(2.1));
logln("Format with NaN : " + fmt.format(Double.NaN));
logln("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
}
/* @bug 4094906
* ChoiceFormat should accept \u221E as eq. to INF.
*/
@Test
public void Test4094906()
{
ChoiceFormat fmt = new ChoiceFormat(
"-\u221E<are negative|0<are no or fraction|1#is one|1.0<is 1+|\u221E<are many.");
if (!fmt.toPattern().startsWith("-\u221E<are negative|0.0<are no or fraction|1.0#is one|1.0<is 1+|\u221E<are many."))
errln("Formatter Pattern : " + fmt.toPattern());
logln("Format with -INF : " + fmt.format(Double.NEGATIVE_INFINITY));
logln("Format with -1.0 : " + fmt.format(-1.0));
logln("Format with 0 : " + fmt.format(0));
logln("Format with 0.9 : " + fmt.format(0.9));
logln("Format with 1.0 : " + fmt.format(1));
logln("Format with 1.5 : " + fmt.format(1.5));
logln("Format with 2 : " + fmt.format(2));
logln("Format with +INF : " + fmt.format(Double.POSITIVE_INFINITY));
}
/* @bug 4118592
* MessageFormat.parse fails with ChoiceFormat.
*/
@Test
public void Test4118592()
{
MessageFormat mf = new MessageFormat("");
String pattern = "{0,choice,1#YES|2#NO}";
String prefix = "";
for (int i = 0; i < 5; i++) {
String formatted = prefix + "YES";
mf.applyPattern(prefix + pattern);
prefix += "x";
Object[] objs = mf.parse(formatted, new ParsePosition(0));
logln(i + ". pattern :\"" + mf.toPattern() + "\"");
log(" \"" + formatted + "\" parsed as ");
if (objs == null) logln(" null");
else logln(" " + objs[0]);
}
}
/* @bug 4118594
* MessageFormat.parse fails for some patterns.
*/
@Test
public void Test4118594()
{
MessageFormat mf = new MessageFormat("{0}, {0}, {0}");
String forParsing = "x, y, z";
Object[] objs = mf.parse(forParsing, new ParsePosition(0));
logln("pattern: \"" + mf.toPattern() + "\"");
logln("text for parsing: \"" + forParsing + "\"");
if (!objs[0].toString().equals("z"))
errln("argument0: \"" + objs[0] + "\"");
mf.setLocale(Locale.US);
mf.applyPattern("{0,number,#.##}, {0,number,#.#}");
Object[] oldobjs = {new Double(3.1415)};
String result = mf.format( oldobjs );
logln("pattern: \"" + mf.toPattern() + "\"");
logln("text for parsing: \"" + result + "\"");
// result now equals "3.14, 3.1"
if (!result.equals("3.14, 3.1"))
errln("result = " + result);
Object[] newobjs = mf.parse(result, new ParsePosition(0));
// newobjs now equals {new Double(3.1)}
if (((Number)newobjs[0]).doubleValue() != 3.1) // was (Double) [alan]
errln( "newobjs[0] = " + newobjs[0]);
}
/* @bug 4105380
* When using ChoiceFormat, MessageFormat is not good for I18n.
*/
@Test
public void Test4105380()
{
String patternText1 = "The disk \"{1}\" contains {0}.";
String patternText2 = "There are {0} on the disk \"{1}\"";
MessageFormat form1 = new MessageFormat(patternText1);
MessageFormat form2 = new MessageFormat(patternText2);
double[] filelimits = {0,1,2};
String[] filepart = {"no files","one file","{0,number} files"};
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
form1.setFormat(1, fileform);
form2.setFormat(0, fileform);
Object[] testArgs = {new Long(12373), "MyDisk"};
logln(form1.format(testArgs));
logln(form2.format(testArgs));
}
/* @bug 4120552
* MessageFormat.parse incorrectly sets errorIndex.
*/
@Test
public void Test4120552()
{
MessageFormat mf = new MessageFormat("pattern");
String texts[] = {"pattern", "pat", "1234"};
logln("pattern: \"" + mf.toPattern() + "\"");
for (int i = 0; i < texts.length; i++) {
ParsePosition pp = new ParsePosition(0);
Object[] objs = mf.parse(texts[i], pp);
log(" text for parsing: \"" + texts[i] + "\"");
if (objs == null) {
logln(" (incorrectly formatted string)");
if (pp.getErrorIndex() == -1)
errln("Incorrect error index: " + pp.getErrorIndex());
} else {
logln(" (correctly formatted string)");
}
}
}
/**
* @bug 4142938
* MessageFormat handles single quotes in pattern wrong.
* This is actually a problem in ChoiceFormat; it doesn't
* understand single quotes.
*/
@Test
public void Test4142938() {
String pat = "''Vous'' {0,choice,0#n''|1#}avez s\u00E9lectionne\u00E9 " +
"{0,choice,0#aucun|1#{0}} client{0,choice,0#s|1#|2#s} " +
"personnel{0,choice,0#s|1#|2#s}.";
MessageFormat mf = new MessageFormat(pat);
String[] PREFIX = {
"'Vous' n'avez s\u00E9lectionne\u00E9 aucun clients personnels.",
"'Vous' avez s\u00E9lectionne\u00E9 ",
"'Vous' avez s\u00E9lectionne\u00E9 "
};
String[] SUFFIX = {
null,
" client personnel.",
" clients personnels."
};
for (int i=0; i<3; i++) {
String out = mf.format(new Object[]{new Integer(i)});
if (SUFFIX[i] == null) {
if (!out.equals(PREFIX[i]))
errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"");
}
else {
if (!out.startsWith(PREFIX[i]) ||
!out.endsWith(SUFFIX[i]))
errln("" + i + ": Got \"" + out + "\"; Want \"" + PREFIX[i] + "\"...\"" +
SUFFIX[i] + "\"");
}
}
}
/**
* @bug 4142938
* Test the applyPattern and toPattern handling of single quotes
* by ChoiceFormat. (This is in here because this was a bug reported
* against MessageFormat.) The single quote is used to quote the
* pattern characters '|', '#', '<', and '\u2264'. Two quotes in a row
* is a quote literal.
*/
@Test
public void TestChoicePatternQuote() {
String[] DATA = {
// Pattern 0 value 1 value
"0#can''t|1#can", "can't", "can",
"0#'pound(#)=''#'''|1#xyz", "pound(#)='#'", "xyz",
"0#'1<2 | 1\u22641'|1#''", "1<2 | 1\u22641", "'",
};
for (int i=0; i<DATA.length; i+=3) {
try {
ChoiceFormat cf = new ChoiceFormat(DATA[i]);
for (int j=0; j<=1; ++j) {
String out = cf.format(j);
if (!out.equals(DATA[i+1+j]))
errln("Fail: Pattern \"" + DATA[i] + "\" x "+j+" -> " +
out + "; want \"" + DATA[i+1+j] + '"');
}
String pat = cf.toPattern();
String pat2 = new ChoiceFormat(pat).toPattern();
if (!pat.equals(pat2))
errln("Fail: Pattern \"" + DATA[i] + "\" x toPattern -> \"" + pat + '"');
else
logln("Ok: Pattern \"" + DATA[i] + "\" x toPattern -> \"" + pat + '"');
}
catch (IllegalArgumentException e) {
errln("Fail: Pattern \"" + DATA[i] + "\" -> " + e);
}
}
}
/**
* @bug 4112104
* MessageFormat.equals(null) throws a NullPointerException. The JLS states
* that it should return false.
*/
@Test
public void Test4112104() {
MessageFormat format = new MessageFormat("");
try {
// This should NOT throw an exception
if (format.equals(null)) {
// It also should return false
errln("MessageFormat.equals(null) returns false");
}
}
catch (NullPointerException e) {
errln("MessageFormat.equals(null) throws " + e);
}
}
/**
* @bug 4169959
* MessageFormat does not format null objects. CANNOT REPRODUCE THIS BUG.
*/
@Test
public void Test4169959() {
// This works
logln(MessageFormat.format("This will {0}", new Object[]{"work"}));
// This fails
logln(MessageFormat.format("This will {0}", new Object[]{ null }));
}
@Test
public void test4232154() {
boolean gotException = false;
try {
new MessageFormat("The date is {0:date}");
} catch (Exception e) {
gotException = true;
if (!(e instanceof IllegalArgumentException)) {
throw new RuntimeException("got wrong exception type");
}
if ("argument number too large at ".equals(e.getMessage())) {
throw new RuntimeException("got wrong exception message");
}
}
if (!gotException) {
throw new RuntimeException("didn't get exception for invalid input");
}
}
@Test
public void test4293229() {
MessageFormat format = new MessageFormat("'''{'0}'' '''{0}'''");
Object[] args = { null };
String expected = "'{0}' '{0}'";
String result = format.format(args);
if (!result.equals(expected)) {
throw new RuntimeException("wrong format result - expected \"" +
expected + "\", got \"" + result + "\"");
}
}
// This test basically ensures that the tests defined above also work with
// valid named arguments.
@Test
public void testBugTestsWithNamesArguments() {
{ // Taken from Test4031438().
String pattern1 = "Impossible {arg1} has occurred -- status code is {arg0} and message is {arg2}.";
String pattern2 = "Double '' Quotes {ARG_ZERO} test and quoted '{ARG_ONE}' test plus 'other {ARG_TWO} stuff'.";
MessageFormat messageFormatter = new MessageFormat("");
try {
logln("Apply with pattern : " + pattern1);
messageFormatter.applyPattern(pattern1);
HashMap paramsMap = new HashMap();
paramsMap.put("arg0", new Integer(7));
String tempBuffer = messageFormatter.format(paramsMap);
if (!tempBuffer.equals("Impossible {arg1} has occurred -- status code is 7 and message is {arg2}."))
errln("Tests arguments < substitution failed");
logln("Formatted with 7 : " + tempBuffer);
ParsePosition status = new ParsePosition(0);
Map objs = messageFormatter.parseToMap(tempBuffer, status);
if (objs.get("arg1") != null || objs.get("arg2") != null)
errln("Parse failed with more than expected arguments");
for (Iterator keyIter = objs.keySet().iterator();
keyIter.hasNext();) {
String key = (String) keyIter.next();
if (objs.get(key) != null && !objs.get(key).toString().equals(paramsMap.get(key).toString())) {
errln("Parse failed on object " + objs.get(key) + " with argument name : " + key );
}
}
tempBuffer = messageFormatter.format(null);
if (!tempBuffer.equals("Impossible {arg1} has occurred -- status code is {arg0} and message is {arg2}."))
errln("Tests with no arguments failed");
logln("Formatted with null : " + tempBuffer);
logln("Apply with pattern : " + pattern2);
messageFormatter.applyPattern(pattern2);
paramsMap.clear();
paramsMap.put("ARG_ZERO", new Integer(7));
tempBuffer = messageFormatter.format(paramsMap);
if (!tempBuffer.equals("Double ' Quotes 7 test and quoted {ARG_ONE} test plus 'other {ARG_TWO} stuff'."))
errln("quote format test (w/ params) failed.");
logln("Formatted with params : " + tempBuffer);
tempBuffer = messageFormatter.format(null);
if (!tempBuffer.equals("Double ' Quotes {ARG_ZERO} test and quoted {ARG_ONE} test plus 'other {ARG_TWO} stuff'."))
errln("quote format test (w/ null) failed.");
logln("Formatted with null : " + tempBuffer);
logln("toPattern : " + messageFormatter.toPattern());
} catch (Exception foo) {
warnln("Exception when formatting in bug 4031438. "+foo.getMessage());
}
}{ // Taken from Test4052223().
ParsePosition pos = new ParsePosition(0);
if (pos.getErrorIndex() != -1) {
errln("ParsePosition.getErrorIndex initialization failed.");
}
MessageFormat fmt = new MessageFormat("There are {numberOfApples} apples growing on the {whatKindOfTree} tree.");
String str = new String("There is one apple growing on the peach tree.");
Map objs = fmt.parseToMap(str, pos);
logln("unparsable string , should fail at " + pos.getErrorIndex());
if (pos.getErrorIndex() == -1)
errln("Bug 4052223 failed : parsing string " + str);
pos.setErrorIndex(4);
if (pos.getErrorIndex() != 4)
errln("setErrorIndex failed, got " + pos.getErrorIndex() + " instead of 4");
if (objs != null)
errln("unparsable string, should return null");
}{ // Taken from Test4111739().
MessageFormat format1 = null;
MessageFormat format2 = null;
ObjectOutputStream ostream = null;
ByteArrayOutputStream baos = null;
ObjectInputStream istream = null;
try {
baos = new ByteArrayOutputStream();
ostream = new ObjectOutputStream(baos);
} catch(IOException e) {
errln("Unexpected exception : " + e.getMessage());
return;
}
try {
format1 = new MessageFormat("pattern{argument}");
ostream.writeObject(format1);
ostream.flush();
byte bytes[] = baos.toByteArray();
istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
format2 = (MessageFormat)istream.readObject();
} catch(Exception e) {
errln("Unexpected exception : " + e.getMessage());
}
if (!format1.equals(format2)) {
errln("MessageFormats before and after serialization are not" +
" equal\nformat1 = " + format1 + "(" + format1.toPattern() + ")\nformat2 = " +
format2 + "(" + format2.toPattern() + ")");
} else {
logln("Serialization for MessageFormat is OK.");
}
}{ // Taken from Test4116444().
String[] patterns = {"", "one", "{namedArgument,date,short}"};
MessageFormat mf = new MessageFormat("");
for (int i = 0; i < patterns.length; i++) {
String pattern = patterns[i];
mf.applyPattern(pattern);
try {
Map objs = mf.parseToMap(null, new ParsePosition(0));
logln("pattern: \"" + pattern + "\"");
log(" parsedObjects: ");
if (objs != null) {
log("{");
for (Iterator keyIter = objs.keySet().iterator();
keyIter.hasNext();) {
String key = (String)keyIter.next();
if (objs.get(key) != null) {
err("\"" + objs.get(key).toString() + "\"");
} else {
log("null");
}
if (keyIter.hasNext()) {
log(",");
}
}
log("}") ;
} else {
log("null");
}
logln("");
} catch (Exception e) {
errln("pattern: \"" + pattern + "\"");
errln(" Exception: " + e.getMessage());
}
}
}{ // Taken from Test4114739().
MessageFormat mf = new MessageFormat("<{arg}>");
Map objs1 = null;
Map objs2 = new HashMap();
Map objs3 = new HashMap();
objs3.put("arg", null);
try {
logln("pattern: \"" + mf.toPattern() + "\"");
log("format(null) : ");
logln("\"" + mf.format(objs1) + "\"");
log("format({}) : ");
logln("\"" + mf.format(objs2) + "\"");
log("format({null}) :");
logln("\"" + mf.format(objs3) + "\"");
} catch (Exception e) {
errln("Exception thrown for null argument tests.");
}
}{ // Taken from Test4118594().
String argName = "something_stupid";
MessageFormat mf = new MessageFormat("{"+ argName + "}, {" + argName + "}, {" + argName + "}");
String forParsing = "x, y, z";
Map objs = mf.parseToMap(forParsing, new ParsePosition(0));
logln("pattern: \"" + mf.toPattern() + "\"");
logln("text for parsing: \"" + forParsing + "\"");
if (!objs.get(argName).toString().equals("z"))
errln("argument0: \"" + objs.get(argName) + "\"");
mf.setLocale(Locale.US);
mf.applyPattern("{" + argName + ",number,#.##}, {" + argName + ",number,#.#}");
Map oldobjs = new HashMap();
oldobjs.put(argName, new Double(3.1415));
String result = mf.format( oldobjs );
logln("pattern: \"" + mf.toPattern() + "\"");
logln("text for parsing: \"" + result + "\"");
// result now equals "3.14, 3.1"
if (!result.equals("3.14, 3.1"))
errln("result = " + result);
Map newobjs = mf.parseToMap(result, new ParsePosition(0));
// newobjs now equals {new Double(3.1)}
if (((Number)newobjs.get(argName)).doubleValue() != 3.1) // was (Double) [alan]
errln( "newobjs.get(argName) = " + newobjs.get(argName));
}{ // Taken from Test4105380().
String patternText1 = "The disk \"{diskName}\" contains {numberOfFiles}.";
String patternText2 = "There are {numberOfFiles} on the disk \"{diskName}\"";
MessageFormat form1 = new MessageFormat(patternText1);
MessageFormat form2 = new MessageFormat(patternText2);
double[] filelimits = {0,1,2};
String[] filepart = {"no files","one file","{numberOfFiles,number} files"};
ChoiceFormat fileform = new ChoiceFormat(filelimits, filepart);
form1.setFormat(1, fileform);
form2.setFormat(0, fileform);
Map testArgs = new HashMap();
testArgs.put("diskName", "MyDisk");
testArgs.put("numberOfFiles", new Long(12373));
logln(form1.format(testArgs));
logln(form2.format(testArgs));
}{ // Taken from test4293229().
MessageFormat format = new MessageFormat("'''{'myNamedArgument}'' '''{myNamedArgument}'''");
Map args = new HashMap();
String expected = "'{myNamedArgument}' '{myNamedArgument}'";
String result = format.format(args);
if (!result.equals(expected)) {
throw new RuntimeException("wrong format result - expected \"" +
expected + "\", got \"" + result + "\"");
}
}
}
private MessageFormat serializeAndDeserialize(MessageFormat original) {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
ObjectOutputStream ostream = new ObjectOutputStream(baos);
ostream.writeObject(original);
ostream.flush();
byte bytes[] = baos.toByteArray();
ObjectInputStream istream = new ObjectInputStream(new ByteArrayInputStream(bytes));
MessageFormat reconstituted = (MessageFormat)istream.readObject();
return reconstituted;
} catch(IOException e) {
throw new RuntimeException(e);
} catch (ClassNotFoundException e) {
throw new RuntimeException(e);
}
}
@Test
public void TestSerialization() {
MessageFormat format1 = null;
MessageFormat format2 = null;
format1 = new MessageFormat("", ULocale.GERMAN);
format2 = serializeAndDeserialize(format1);
assertEquals("MessageFormats (empty pattern) before and after serialization are not equal", format1, format2);
format1.applyPattern("ab{1}cd{0,number}ef{3,date}gh");
format1.setFormat(2, null);
format1.setFormatByArgumentIndex(1, NumberFormat.getInstance(ULocale.ENGLISH));
format2 = serializeAndDeserialize(format1);
assertEquals("MessageFormats (with custom formats) before and after serialization are not equal", format1, format2);
assertEquals(
"MessageFormat (with custom formats) does not "+
"format correctly after serialization",
"ab3.3cd4,4ef***gh",
format2.format(new Object[] { 4.4, 3.3, "+++", "***" }));
}
}
| [
"[email protected]"
] | |
2d14c2e985914bd1c883f44cd510af2e51dea5bb | 31fc4ecab54687c9986665a0aa2ea6fc82ce7631 | /src/day14_StringContinue/Stringmanipulations3.java | 00caf8a94602b2cf417864a9c87eb95e48c5996f | [] | no_license | ogulle/Java_CyberTek | 9f14bd46de2c1595dde5998285a5c1e2f63a4312 | 79af18f79e89ce61236df96cbbea7085783a06c0 | refs/heads/master | 2022-11-16T05:17:31.368623 | 2020-07-06T15:25:20 | 2020-07-06T15:25:20 | 258,610,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 241 | java | package day14_StringContinue;
public class Stringmanipulations3 {
public static void main(String[] args) {
String s1 = "Cybertek School";
boolean r1 = s1. contains("School");
System.out.println(r1);
}
}
| [
"[email protected]"
] | |
ad7328b6bfcf4f44f424b8cd5037b92c90884a0c | d8c52b0f6c5d8a15d6c22e10434e2be4dac5bd2a | /app/src/main/java/com/proyecto/quedemos/ActivitiesAndFragments/SplashScreen.java | 3afd29a2bb4fcb7130c82db8f1bf1009f59a19a0 | [] | no_license | millanky/Quedemos | c6cb69cf7becfec88c3124f86aba5b5cd415b294 | bc57008b925c415284086dbaaa05b8d535e468fe | refs/heads/master | 2020-04-02T07:53:51.384374 | 2016-07-29T13:35:41 | 2016-07-29T13:35:41 | 60,693,601 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,667 | java | package com.proyecto.quedemos.ActivitiesAndFragments;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.RelativeLayout;
import com.proyecto.quedemos.R;
import com.proyecto.quedemos.VisualResources.Utils;
/**
* Created by Usuario on 25/05/2016.
*/
public class SplashScreen extends AppCompatActivity {
@Override
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Utils.onActivityCreateSetTheme(this);
setContentView(R.layout.splash);
RelativeLayout splashContainer = (RelativeLayout) findViewById(R.id.splashContainer);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setIcon(R.drawable.q_logo);
SharedPreferences prefs = getSharedPreferences("Usuario", Context.MODE_PRIVATE);
int currentColor = prefs.getInt("themeColor", -11443780); //azul oscuro por defecto
if (currentColor == -10066330) { //gris
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_gris));
} else if (currentColor == -6903239) { //verde
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_verde));
} else if (currentColor == -3716282) { //rojo
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_rojo));
} else if (currentColor == -752595) { //naranja
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_naranja));
} else if (currentColor == -12607520) { //azul claro
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_azulclaro));
} else {
splashContainer.setBackground(getResources().getDrawable(R.drawable.bg_azuloscuro));
}
Thread timerThread = new Thread (){ //nuevo hilo, se ejecuta en background
public void run() {
try {
sleep(500); //se duerme 0,5 segundos, doy tiempo a cargar calendario
}catch (InterruptedException e){
e.printStackTrace();
}finally { //lanzar la MainActivity
Intent intent = new Intent(SplashScreen.this, MainActivity.class);
startActivity(intent);
}
}
};
timerThread.start();
}
@Override
protected void onPause(){ //poner en pausa si se lanza este metodo
super.onPause();
finish();
}
} | [
"[email protected]"
] | |
96e491de4cc47d79454939e92eadfe997c83255d | 4ff86cc5f3acfcb67725913f4215e28916bd8ba7 | /app/src/androidTest/java/com/example/now/testproject/ExampleInstrumentedTest.java | 7c927e217faadf00e84692bb26eeaaa06b5cbfac | [] | no_license | DaiTranIT/HelloGitHub | 39f94059c5be0d6eb0ddba2a404cec579ad04963 | 95221b86fea954256aac88cc0b9cf7db49ddf7ff | refs/heads/master | 2020-06-11T02:11:13.253589 | 2016-12-10T02:02:19 | 2016-12-10T02:02:19 | 76,026,825 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 758 | java | package com.example.now.testproject;
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.example.now.testproject", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
232fdaf2ce85cccbfd62c6e709b6aef340f16442 | 4ff2e8fec5679b4fa516fa2a60960e9732e33150 | /src/ca/uvic/csr/shrimp/PanelModeConstants.java | 05a7b834f86a3347af49f35a8f83f945723b4e4f | [] | no_license | bramfeld/jambalaya | 71f55657590010a6e2db2625794ebce0c5058b55 | e119dcccca118b891aa4621caeed71741d65a3d1 | refs/heads/master | 2016-08-11T20:11:48.065136 | 2015-12-06T19:02:44 | 2015-12-06T19:02:44 | 47,508,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,124 | java | /**
* Copyright 1998-2008, CHISEL Group, University of Victoria, Victoria, BC, Canada.
* All rights reserved.
*/
package ca.uvic.csr.shrimp;
public class PanelModeConstants {
/**
* Constant for showing a node as "closed"
* Note: There is not actually a "closed" panel, just a mode of displaying
*/
public static final String CLOSED = "Closed";
/**
* Constant for showing a node's "children"
* Note: There is not actually a "children" panel, just a mode of displaying
*/
public static final String CHILDREN = "Children";
/**
* Name for the Annotation panel.
*/
public final static String PANEL_ANNOTATION = "Annotation";
/**
* Name for the Attributes panel.
*/
public final static String PANEL_ATTRIBUTES = "Attributes";
/**
* Name for the default panel.
* The defult panel will vary from domain to domain.
*/
public final static String PANEL_DEFAULT = "Default";
/**
* Name for the panel that displays documents.
*/
public final static String PANEL_DOCUMENTS = "Documents & Annotations";
}
| [
"[email protected]"
] | |
bdd165fc9469daff38dd1a19b5b21fff4616d83a | 5b652af09e8392353a86bccb59427c22ebdd5a7d | /src/com/kingdee/eas/fdc/finance/app/NewOldAccountRelationController.java | cbbb3785a0a183572752e4d06a1d45fbacf66785 | [] | no_license | yangpengfei0810/ypfGit | 595384192a8349634931e318303959cbabf7ea49 | b5fc6a79f2cbb9ea817ba10766a061359ad7c006 | refs/heads/master | 2016-09-12T13:01:47.560657 | 2016-04-18T04:29:18 | 2016-04-18T04:29:18 | 56,286,364 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,264 | java | package com.kingdee.eas.fdc.finance.app;
import com.kingdee.bos.BOSException;
//import com.kingdee.bos.metadata.*;
import com.kingdee.bos.framework.*;
import com.kingdee.bos.util.*;
import com.kingdee.bos.Context;
import java.lang.String;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.eas.fdc.finance.NewOldAccountRelationInfo;
import com.kingdee.eas.basedata.org.CompanyOrgUnitInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.bos.metadata.entity.SorterItemCollection;
import java.util.HashSet;
import com.kingdee.bos.util.*;
import com.kingdee.bos.metadata.entity.FilterInfo;
import com.kingdee.eas.fdc.finance.NewOldAccountRelationCollection;
import com.kingdee.bos.BOSException;
import com.kingdee.bos.Context;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.bos.framework.*;
import com.kingdee.eas.framework.app.CoreBaseController;
import java.rmi.RemoteException;
import com.kingdee.bos.framework.ejb.BizController;
public interface NewOldAccountRelationController extends CoreBaseController
{
public boolean exists(Context ctx, IObjectPK pk) throws BOSException, EASBizException, RemoteException;
public boolean exists(Context ctx, FilterInfo filter) throws BOSException, EASBizException, RemoteException;
public boolean exists(Context ctx, String oql) throws BOSException, EASBizException, RemoteException;
public NewOldAccountRelationInfo getNewOldAccountRelationInfo(Context ctx, IObjectPK pk) throws BOSException, EASBizException, RemoteException;
public NewOldAccountRelationInfo getNewOldAccountRelationInfo(Context ctx, IObjectPK pk, SelectorItemCollection selector) throws BOSException, EASBizException, RemoteException;
public NewOldAccountRelationInfo getNewOldAccountRelationInfo(Context ctx, String oql) throws BOSException, EASBizException, RemoteException;
public IObjectPK addnew(Context ctx, NewOldAccountRelationInfo model) throws BOSException, EASBizException, RemoteException;
public void addnew(Context ctx, IObjectPK pk, NewOldAccountRelationInfo model) throws BOSException, EASBizException, RemoteException;
public void update(Context ctx, IObjectPK pk, NewOldAccountRelationInfo model) throws BOSException, EASBizException, RemoteException;
public void updatePartial(Context ctx, NewOldAccountRelationInfo model, SelectorItemCollection selector) throws BOSException, EASBizException, RemoteException;
public void updateBigObject(Context ctx, IObjectPK pk, NewOldAccountRelationInfo model) throws BOSException, RemoteException;
public void delete(Context ctx, IObjectPK pk) throws BOSException, EASBizException, RemoteException;
public IObjectPK[] getPKList(Context ctx) throws BOSException, EASBizException, RemoteException;
public IObjectPK[] getPKList(Context ctx, String oql) throws BOSException, EASBizException, RemoteException;
public IObjectPK[] getPKList(Context ctx, FilterInfo filter, SorterItemCollection sorter) throws BOSException, EASBizException, RemoteException;
public NewOldAccountRelationCollection getNewOldAccountRelationCollection(Context ctx) throws BOSException, RemoteException;
public NewOldAccountRelationCollection getNewOldAccountRelationCollection(Context ctx, EntityViewInfo view) throws BOSException, RemoteException;
public NewOldAccountRelationCollection getNewOldAccountRelationCollection(Context ctx, String oql) throws BOSException, RemoteException;
public IObjectPK[] delete(Context ctx, FilterInfo filter) throws BOSException, EASBizException, RemoteException;
public IObjectPK[] delete(Context ctx, String oql) throws BOSException, EASBizException, RemoteException;
public void delete(Context ctx, IObjectPK[] arrayPK) throws BOSException, EASBizException, RemoteException;
public void submitAll(Context ctx, NewOldAccountRelationCollection accountRelationColl, String company) throws BOSException, EASBizException, RemoteException;
public void importGroupData(Context ctx, HashSet prjIdSet, CompanyOrgUnitInfo company) throws BOSException, EASBizException, RemoteException;
} | [
"[email protected]"
] | |
2cf2a345dad67ca73dbec976be9e34e48c5341ac | 1797e07a118eb3cd357b867fd28135747dec1ed1 | /TalkLumenToMe/app/src/androidTest/java/cs11d/com/talklumentome/ApplicationTest.java | c19bcc56c2c136e0b9ed0d055b08156bdf1595ee | [] | no_license | fjeljabali/Android | 1e462a783ac310c72296886955fb5d1c331b8ef4 | aabf7da5dc342efc2ffe5c42d158a2ccb0e7d819 | refs/heads/master | 2016-09-06T17:36:07.914181 | 2015-05-12T01:24:04 | 2015-05-12T01:24:04 | 10,729,275 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 354 | java | package cs11d.com.talklumentome;
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);
}
} | [
"[email protected]"
] | |
e150e3551e49acb32e2ad1885eecadc96dd07de6 | c7bcf7e7409457bf9c6e679c6ba7c1596aeae4a7 | /plugins/org.ptolemy.moml/src/org/ptolemy/moml/RenditionType.java | 4fd2a710bce82b7bf210dd0155df6c36d8fe5763 | [
"MIT-Modern-Variant"
] | permissive | flymolon/de.cau.cs.kieler | 9a4a91251c84b112f472ded83595de77e5380027 | ead1a8fba7fca2072b36d931f62df735f818b94e | refs/heads/master | 2021-01-18T11:08:18.636739 | 2012-08-09T12:28:23 | 2012-08-09T12:28:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,111 | java | /**
* <copyright>
* </copyright>
*
* $Id$
*/
package org.ptolemy.moml;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.FeatureMap;
/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Rendition Type</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link org.ptolemy.moml.RenditionType#getGroup <em>Group</em>}</li>
* <li>{@link org.ptolemy.moml.RenditionType#getConfigure <em>Configure</em>}</li>
* <li>{@link org.ptolemy.moml.RenditionType#getLocation <em>Location</em>}</li>
* <li>{@link org.ptolemy.moml.RenditionType#getProperty <em>Property</em>}</li>
* <li>{@link org.ptolemy.moml.RenditionType#getClass_ <em>Class</em>}</li>
* </ul>
* </p>
*
* @see org.ptolemy.moml.MomlPackage#getRenditionType()
* @model extendedMetaData="name='rendition_._type' kind='elementOnly'"
* @generated
*/
public interface RenditionType extends EObject {
/**
* Returns the value of the '<em><b>Group</b></em>' attribute list.
* The list contents are of type {@link org.eclipse.emf.ecore.util.FeatureMap.Entry}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Group</em>' attribute list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Group</em>' attribute list.
* @see org.ptolemy.moml.MomlPackage#getRenditionType_Group()
* @model unique="false" dataType="org.eclipse.emf.ecore.EFeatureMapEntry" many="true"
* extendedMetaData="kind='group' name='group:0'"
* @generated
*/
FeatureMap getGroup();
/**
* Returns the value of the '<em><b>Configure</b></em>' containment reference list.
* The list contents are of type {@link org.ptolemy.moml.ConfigureType}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Configure</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Configure</em>' containment reference list.
* @see org.ptolemy.moml.MomlPackage#getRenditionType_Configure()
* @model containment="true" transient="true" volatile="true" derived="true"
* extendedMetaData="kind='element' name='configure' namespace='##targetNamespace' group='group:0'"
* @generated
*/
EList<ConfigureType> getConfigure();
/**
* Returns the value of the '<em><b>Location</b></em>' containment reference list.
* The list contents are of type {@link org.ptolemy.moml.LocationType}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Location</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Location</em>' containment reference list.
* @see org.ptolemy.moml.MomlPackage#getRenditionType_Location()
* @model containment="true" transient="true" volatile="true" derived="true"
* extendedMetaData="kind='element' name='location' namespace='##targetNamespace' group='group:0'"
* @generated
*/
EList<LocationType> getLocation();
/**
* Returns the value of the '<em><b>Property</b></em>' containment reference list.
* The list contents are of type {@link org.ptolemy.moml.PropertyType}.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Property</em>' containment reference list isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Property</em>' containment reference list.
* @see org.ptolemy.moml.MomlPackage#getRenditionType_Property()
* @model containment="true" transient="true" volatile="true" derived="true"
* extendedMetaData="kind='element' name='property' namespace='##targetNamespace' group='group:0'"
* @generated
*/
EList<PropertyType> getProperty();
/**
* Returns the value of the '<em><b>Class</b></em>' attribute.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Class</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Class</em>' attribute.
* @see #setClass(String)
* @see org.ptolemy.moml.MomlPackage#getRenditionType_Class()
* @model required="true"
* extendedMetaData="kind='attribute' name='class' namespace='##targetNamespace'"
* @generated
*/
String getClass_();
/**
* Sets the value of the '{@link org.ptolemy.moml.RenditionType#getClass_ <em>Class</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Class</em>' attribute.
* @see #getClass_()
* @generated
*/
void setClass(String value);
} // RenditionType
| [
"[email protected]"
] | |
78a786e2203dab266bb114d61b37b5d92ecfb304 | b7af29bd772574350fa419ed2682aff43210580b | /javaEE/JDBC读取xml/src/com/oracle/demo2/CreatXml.java | 02a2f82f16ec447dd7df40c132d32033a21adc43 | [] | no_license | koala0018/java | a1d440a50bce876ee69e6ccaecb578ae47127889 | 992f7f01353347f79c6c05a4c7081b7aabfcec92 | refs/heads/master | 2023-01-12T10:13:42.100250 | 2020-11-22T03:18:20 | 2020-11-22T03:18:20 | 296,346,664 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,476 | java | package com.oracle.demo2;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
public class CreatXml {
public static void Create(List<Emp> list){
if(list.size()>0){//若查出的数据没有就不需要创建xml了
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = null;
SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd-:mm:ss");
try {
builder = factory.newDocumentBuilder();
Document document = builder.newDocument();
Element employees = document.createElement("employees");
//数据库查出数据写入标签
for(Emp e:list){//list里面是emp对象,有几个对象就循环几次,每次给标签赋值,第二次循环标签就失效了,所以重复赋值不会覆盖之前的标签
Element Emp = document.createElement("Emp");
Element empid = document.createElement("empid");
Element ename = document.createElement("ename");
Element job = document.createElement("job");
Element sals = document.createElement("sals");
Element hiredate = document.createElement("hiredate");
empid.setTextContent(e.getEmpid()+"");
ename.setTextContent(e.getEname());
job.setTextContent(e.getJob());
sals.setTextContent(e.getSal()+"");
hiredate.setTextContent(time.format(e.getHiredate()));//将Date类型转为SimpleDateFormat的字符串型
//设计每个标签的关系
Emp.appendChild(empid);
Emp.appendChild(ename);
Emp.appendChild(job);
Emp.appendChild(sals);
Emp.appendChild(hiredate);
employees.appendChild(Emp);
}
document.appendChild(employees);
//开始转化
TransformerFactory tf = TransformerFactory.newInstance();
Transformer former = tf.newTransformer();
former.setOutputProperty(OutputKeys.ENCODING,"GBK");
DOMSource domSource = new DOMSource(document);
StreamResult sr = new StreamResult(new FileOutputStream(new File("C:"+File.separator+"java"+File.separator+"sql xml.xml")));
former.transform(domSource, sr);//记住dom方式解析中,transform需要两个参数,一个Source资源,一个StreamResult,Source是接口,用其实现类domSource(需要传入你要转化的document),
//StreamResult类,直接实例化,构造方法用文件输出流对象
} catch (TransformerConfigurationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (FileNotFoundException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (TransformerException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} catch (ParserConfigurationException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
}
| [
"[email protected]"
] | |
6dceb3995fbab71fd1573aee698ac6d231db1e6c | 56c2664895d95bda913d4d1b9128d5512dba8b80 | /app/src/main/java/eu/theinvaded/mastondroid/ui/adapter/FollowersAdapter.java | 3c01e004335a07e867471e7fa684a4b5a2d9c340 | [] | no_license | zhaozw/mastodroid | 548fd5264bafe0a5fda880502cdad3d63fde7773 | 8f80f984d159ab2558b2e3b4f9c0557f736c4b3f | refs/heads/master | 2020-12-31T00:54:57.756373 | 2017-01-31T09:17:58 | 2017-01-31T09:17:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,345 | java | package eu.theinvaded.mastondroid.ui.adapter;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.List;
import eu.theinvaded.mastondroid.R;
import eu.theinvaded.mastondroid.databinding.ItemFollowerBinding;
import eu.theinvaded.mastondroid.model.MastodonAccount;
import eu.theinvaded.mastondroid.ui.activity.MainActivity;
import eu.theinvaded.mastondroid.ui.fragment.FragmentUser;
import eu.theinvaded.mastondroid.utils.Constants;
import eu.theinvaded.mastondroid.viewmodel.ItemFollowerViewModel;
import eu.theinvaded.mastondroid.viewmodel.ItemFollowerViewModelContract;
/**
* Created by alin on 09.01.2017.
*/
public class FollowersAdapter extends RecyclerView.Adapter<FollowersAdapter.FollowerViewHolder> {
private List<MastodonAccount> accountsList = new ArrayList<>();
@Override
public FollowersAdapter.FollowerViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
ItemFollowerBinding binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()),
R.layout.item_follower, parent, false);
return new FollowerViewHolder(binding);
}
@Override
public void onBindViewHolder(FollowersAdapter.FollowerViewHolder holder, int position) {
holder.bindFollower(accountsList.get(position));
}
public void setAccountList(List<MastodonAccount> accountsList) {
if (accountsList.size() == 0) return;
this.accountsList.addAll(accountsList);
notifyDataSetChanged();
}
@Override
public int getItemCount() {
return accountsList.size();
}
public long getLastId() {
return accountsList.get(accountsList.size() - 1).id;
}
public class FollowerViewHolder extends RecyclerView.ViewHolder implements ItemFollowerViewModelContract.FollowerView {
ItemFollowerBinding binding;
public FollowerViewHolder(ItemFollowerBinding binding) {
super(binding.itemFollower);
this.binding = binding;
}
@Override
public Context getContext() {
return itemView.getContext();
}
@Override
public String getCredentials() {
return ((MainActivity) getContext())
.getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE)
.getString(Constants.AUTH_KEY, "");
}
@Override
public String getUsername() {
return ((MainActivity) getContext())
.getSharedPreferences(Constants.PREFERENCES, Context.MODE_PRIVATE)
.getString(Constants.CURRENT_USERNAME, "");
}
@Override
public void expandUser(MastodonAccount account) {
((MainActivity) getContext()).getSupportFragmentManager().beginTransaction()
.addToBackStack("user")
.replace(R.id.container, FragmentUser.getInstance(account))
.commit();
}
public void bindFollower(MastodonAccount account) {
binding.setViewModel(new ItemFollowerViewModel(account, itemView.getContext(), this));
}
}
}
| [
"[email protected]"
] | |
601abf254a955a5051ac7ba90d43112bfc15fc2a | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/35/35_1058d2272529176043c90edf282129d4ba79fb2f/StatisticController/35_1058d2272529176043c90edf282129d4ba79fb2f_StatisticController_t.java | 8ef908a33eb69313f68a754a157c892a4777aadb | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 3,759 | java | /*
* Copyright 2012 SURFnet bv, The Netherlands
*
* 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 nl.surfnet.coin.selfservice.control.stats;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import nl.surfnet.coin.selfservice.control.BaseController;
import nl.surfnet.coin.selfservice.dao.StatisticDao;
import nl.surfnet.coin.selfservice.domain.ChartSerie;
import nl.surfnet.coin.selfservice.domain.CompoundServiceProviderRepresenter;
import nl.surfnet.coin.selfservice.domain.IdentityProvider;
import nl.surfnet.coin.selfservice.domain.IdentityProviderRepresenter;
import nl.surfnet.coin.selfservice.interceptor.AuthorityScopeInterceptor;
import nl.surfnet.coin.selfservice.service.IdentityProviderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
/**
* Controller for statistics
*/
@Controller
@RequestMapping(value = "/stats/*")
public class StatisticController extends BaseController {
@Autowired
private StatisticDao statisticDao;
@Resource(name = "providerService")
private IdentityProviderService idpService;
@RequestMapping("/stats.shtml")
public String stats(ModelMap model, @ModelAttribute(value = "selectedidp") IdentityProvider selectedidp) {
model.put("selectedidp", selectedidp);
// Get all idp's which are known in selfservice and available in the statistics database
if (AuthorityScopeInterceptor.isDistributionChannelAdmin()) {
List<IdentityProviderRepresenter> idpRepresenters = new ArrayList<IdentityProviderRepresenter>();
List<IdentityProvider> allIdps = idpService.getAllIdentityProviders();
for (IdentityProviderRepresenter idpRepresenter : statisticDao.getIdpLoginIdentifiers()) {
if (containsIdpWithEntityId(allIdps, idpRepresenter.getEntityId())) {
idpRepresenters.add(idpRepresenter);
}
}
model.put("allIdps", idpRepresenters);
}
return "stats/statistics";
}
private boolean containsIdpWithEntityId(List<IdentityProvider> allIdps, String entityId) {
for (IdentityProvider idp : allIdps) {
if (idp.getId().equals(entityId)) {
return true;
}
}
return false;
}
@RequestMapping("/loginsperspperdaybyidp.json")
public @ResponseBody
List<ChartSerie> getLoginsPerSPByIdp(@ModelAttribute(value = "selectedidp") IdentityProvider selectedidp) {
return statisticDao.getLoginsPerSpPerDay(selectedidp.getId());
}
@RequestMapping("/loginsperspperday.json")
public @ResponseBody
List<ChartSerie> getLoginsPerSP() {
return statisticDao.getLoginsPerSpPerDay();
}
@RequestMapping("/spcspcombis.json")
public @ResponseBody
List<CompoundServiceProviderRepresenter> getCspSpIds() {
return statisticDao.getCompoundServiceProviderSpLinks();
}
public void setStatisticDao(StatisticDao statisticDao) {
this.statisticDao = statisticDao;
}
}
| [
"[email protected]"
] | |
81ea38f3b5e72cf2c466a148e81a6a34c4a8d9e4 | ddf269f87f3d5a7d811dc171679dc4aa44946ccf | /src/com/ds/binarysearchtree/App.java | e1f9e8453e7db6b4223f380c846bbc498dd95956 | [] | no_license | syam22587/javaexcercices | 6f1fded12f1948bb5e4c4a506f7e5fd22ad709f3 | 60a2de50c3c8083aaa98ccffc13db2a156a7c447 | refs/heads/master | 2020-09-16T00:55:37.601683 | 2019-11-23T16:27:19 | 2019-11-23T16:27:19 | 223,602,510 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 370 | java | package com.ds.binarysearchtree;
public class App {
public static void main(String[] args) {
BST bst = new BST();
bst.insertNode(100);
bst.insertNode(20);
bst.insertNode(10);
bst.insertNode(15);
bst.insertNode(25);
bst.insertNode(65);
bst.insertNode(3);
bst.insertNode(5);
System.out.println(bst.deleteNode(5));
bst.printTree() ;
}
}
| [
"[email protected]"
] | |
40fbb2ed27d87f3555d7c781dd9fbaaf95d7230d | 6086b9ef3a077a385c9e3cbdd75301196c4c5576 | /src/main/java/com/griddynamics/SolrAtomicUpdaterBuilder.java | 748de9fe61aa9e62c1ed21065cc6e447b20fd78f | [] | no_license | fsolovyev/lucidworks-fusion-atomic-updates-test | 435d1a39107e83fc8dc2e5a5f58fb521da8bfd87 | db9c9a49bc66023b60a77e3310b9ee9b53c8cbed | refs/heads/master | 2021-01-10T11:47:03.079085 | 2015-10-27T11:54:28 | 2015-10-27T11:54:28 | 44,624,420 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,301 | java | package com.griddynamics;
import com.codahale.metrics.Counter;
import org.apache.solr.client.solrj.SolrClient;
public class SolrAtomicUpdaterBuilder {
private SolrClient solrClient;
private String documentIdPrefix;
private int documentsNumber;
private String fieldToSearchBy;
private com.codahale.metrics.Counter updatesCounter;
public SolrAtomicUpdaterBuilder setSolrClient(SolrClient solrClient) {
this.solrClient = solrClient;
return this;
}
public SolrAtomicUpdaterBuilder setDocumentIdPrefix(String documentIdPrefix) {
this.documentIdPrefix = documentIdPrefix;
return this;
}
public SolrAtomicUpdaterBuilder setDocumentsNumber(int documentsNumber) {
this.documentsNumber = documentsNumber;
return this;
}
public SolrAtomicUpdaterBuilder setFieldToSearchBy(String fieldToSearchBy) {
this.fieldToSearchBy = fieldToSearchBy;
return this;
}
public SolrAtomicUpdaterBuilder setUpdatesCounter(Counter updatesCounter) {
this.updatesCounter = updatesCounter;
return this;
}
public SolrAtomicUpdater createSolrAtomicUpdater() {
return new SolrAtomicUpdater(solrClient, documentIdPrefix, documentsNumber, fieldToSearchBy, updatesCounter);
}
} | [
"[email protected]"
] | |
dc33be43b8a7c2634fedbe812b1f4c3e1dbc6d16 | 5535ade706863138f0660eae073a90a4b535fb1b | /semantic-ide/src/main/java/ch/ethz/inf/vs/semantics/ide/AppModule.java | e724ecbac1ac8d23ece969e04d911f3640785c71 | [
"Apache-2.0"
] | permissive | mkovatsc/iot-semantics | 818ae0bf145e615f84e3f6104f77497e430464ae | c04483f086c65ddf55d63ab039575e863d3eaf17 | refs/heads/master | 2021-01-17T16:37:43.106926 | 2017-06-19T00:25:59 | 2017-06-19T00:25:59 | 34,433,441 | 9 | 0 | null | null | null | null | UTF-8 | Java | false | false | 748 | java | package ch.ethz.inf.vs.semantics.ide;
import com.google.common.collect.ImmutableMap;
import restx.ResourcesRoute;
import restx.factory.Module;
import restx.factory.Provides;
@Module
public class AppModule {
@Provides(priority = 2000)
// We set priority to 2000 to make sure static assets are matched only if no other route is matched.
public ResourcesRoute assetsRoute() {
return new ResourcesRoute(
"assets", // route name, for log and debug only
"/", // assets are served on / HTTP path
"assets", // assets are searched in /assets directory in classpath (src/main/resources/assets in sources)
ImmutableMap.of("", "index.html") // alias empty string to index.html, so asking for / will look for /index.html
);
}
}
| [
"[email protected]"
] | |
33a5541f2c92571b8b1c6440dc141854de6ad9b8 | 934f0d3060a095118926bbd210b1e40b9ee38e1e | /04_collections/src/examples/Worker.java | 142becf0250be1a965459530384bef2da775b392 | [] | no_license | fabiberlin/Tutorium-Programmierung-fuer-Fortgeschrittene | 30ab85d27c0d70f515b3154b2c1dc4c4b7897038 | afa23d0dd29a46474d1e5b879ccff5d815a0a9be | refs/heads/master | 2021-01-19T10:13:59.373455 | 2017-07-27T15:04:39 | 2017-07-27T15:04:39 | 87,840,560 | 0 | 1 | null | 2017-07-10T11:45:50 | 2017-04-10T17:52:03 | Java | UTF-8 | Java | false | false | 686 | java | package examples;
public class Worker implements Runnable, Comparable<Worker> {
private String name;
private int duration;
public Worker(String name, int duration) {
this.name = name;
this.duration = duration;
}
public void run() {
while(true){
System.out.println("I'm doing hard work ("+this.name+")");
try {
Thread.sleep(duration);
} catch (InterruptedException e) {
return;
}
}
}
public int compareTo(Worker o) {
if (this.duration < o.duration) {
return -1;
}
if (this.duration > o.duration) {
return 1;
}
return 0;
}
public String toString() {
return "I'm " + this.name + " (" + this.duration + ")";
}
}
| [
"[email protected]"
] | |
43486924d8184148c108d77143a627cd47aea776 | 5f960a9f2558a24219fbc0e722bba9c26fc441f4 | /app/src/test/java/com/example/ambienteconfinato/ExampleUnitTest.java | f489fd6208e8bc0b60526c240c72beefcba25b64 | [] | no_license | Duilio97/AmbienteConfinato | 10e37b33cfc6b7ee65ed2b9a50eca0adff45cb64 | 2b67f67d8dd15ae24f43d48b56ab5ef8c5696a5d | refs/heads/master | 2022-12-28T11:57:20.236427 | 2020-10-19T07:10:10 | 2020-10-19T07:10:10 | 295,461,531 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 390 | java | package com.example.ambienteconfinato;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
bb05ad61c978bdb6525c98789868aafad654abac | 9608ab2a7f7871e0d621b0e4166ec81fd3307763 | /src/systems/InputRecorderSystem.java | 7f4ad4d7c50f835d300994c4dd6b7387428caf34 | [] | no_license | blead/chrone | e30f3c709c89ab3fd762a6dc2697f940c54971ea | 937730155cfa21e6f091ae1808723b39e1bfd204 | refs/heads/master | 2020-06-11T02:09:49.354221 | 2016-12-20T05:48:31 | 2016-12-20T05:48:31 | 76,027,637 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 940 | java | /*
* @author Thad Benjaponpitak
*/
package systems;
import components.InputRecorderComponent;
import core.EntityManager;
import core.InputManager;
import entities.Entity;
import utils.ComponentNotFoundException;
public class InputRecorderSystem extends EntitySystem {
public InputRecorderSystem() {
super(12);
}
@Override
public void update(double deltaTime) {
for (Entity entity : EntityManager.getInstance().getEntities()) {
try {
InputRecorderComponent inputRecorderComponent = (InputRecorderComponent) entity
.getComponent(InputRecorderComponent.class);
if (inputRecorderComponent.getDuration() > 0) {
inputRecorderComponent.addPressedRecord(InputManager.getInstance().getPressed());
inputRecorderComponent.addTriggeredRecord(InputManager.getInstance().getTriggered());
inputRecorderComponent.decreaseDuration();
}
} catch (ComponentNotFoundException e) {
continue;
}
}
}
}
| [
"[email protected]"
] | |
fb76d32503e78c4074efdca5f2fd6064797d55a5 | 1f0b6e356e317cdf06e4c04de822af17418bd04f | /TrojanOffice/src/xinghanw_CSCI201_Assignment2/Server/ProgramServer.java | 17fe00d4a973d7717bf5a3d89e60e9b85b0b0d8b | [] | no_license | sean1996/TrojanOffice | d6c5672ce0ff84e4c708f40f46e7061aa93904e1 | 1692efae02b4995c330c143f1997e9bbf595986f | refs/heads/master | 2021-01-11T00:53:11.441965 | 2016-10-10T05:41:12 | 2016-10-10T05:41:12 | 70,455,379 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,156 | java | package xinghanw_CSCI201_Assignment2.Server;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.Buffer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.Vector;
import java.util.concurrent.ConcurrentHashMap;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
public class ProgramServer implements Runnable {
private int portNumber = 0;
private int udpateInterval = 3000;
private String hostName = "";
ServerSocket serverSocket = null;
ProgramServerGUI serverGUI;
boolean terminate = false;
public static Vector<ServerClientThread> clientThreads = new Vector<ServerClientThread>(0);
private updateThread updateThreadMain;
public static ConcurrentHashMap<userNamefileNamePair, Merger_Assignment5> updateHashmap = new ConcurrentHashMap<userNamefileNamePair, Merger_Assignment5>();
public ProgramServer(String configurationFilePath) {
serverGUI = new ProgramServerGUI(this);
parseConfigFile(configurationFilePath);
updateThreadMain = new updateThread(udpateInterval, this);
updateThreadMain.start();
new autoSavingThread(this).start();
}
private void parseConfigFile(String path){
FileReader freader = null;
BufferedReader bReader = null;
Scanner PortnumberScanner = null;
String nextLine;
try {
freader = new FileReader(path);
bReader = new BufferedReader(freader);
while((nextLine = bReader.readLine()) != null){
if(nextLine.startsWith("portnumber:")){
int index = nextLine.indexOf(':');
PortnumberScanner = new Scanner(nextLine.substring(index + 1));
StringBuilder sBuilder = new StringBuilder();
while(PortnumberScanner.hasNextInt()){
sBuilder.append(PortnumberScanner.nextInt());
}
portNumber = Integer.parseInt(sBuilder.toString());
}
if(nextLine.startsWith("updateInterval(ms):")){
int index = nextLine.indexOf(':');
PortnumberScanner = new Scanner(nextLine.substring(index + 1));
StringBuilder sBuilder = new StringBuilder();
while(PortnumberScanner.hasNextInt()){
sBuilder.append(PortnumberScanner.nextInt());
}
udpateInterval = Integer.parseInt(sBuilder.toString());
}
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}finally {
try {
if (freader != null) {freader.close();}
if (bReader != null) {bReader.close();}
if(PortnumberScanner!= null){PortnumberScanner.close();}
} catch (IOException ioe) {
System.out.println("IOException closing file: " + ioe.getMessage());
}
}
}
@Override
public void run() {
try{
serverSocket = new ServerSocket(portNumber);
serverGUI.textArea.setText(serverGUI.textArea.getText() + "Server started on port " + portNumber + "\n" );
while(true){
//start listening
Socket socket = serverSocket.accept();
ServerClientThread clientThread = new ServerClientThread(socket, this);
clientThreads.add(clientThread);
}
}catch(IOException ioe){
System.out.println("socket is closed. Stop listening.");
}finally {
}
}
protected void stopListening() {
if(serverSocket != null){
try{
serverSocket.close();
System.out.println("Closed the serverSocket");
}catch(IOException ioe){
System.out.println(ioe.getMessage());
}
}
for(ServerClientThread serverClientThread: clientThreads){
removeThread(serverClientThread);
}
clientThreads.clear();
}
public static void main(String[] args){
new ProgramServer("serverConfig.txt");
}
public void removeThread(ServerClientThread clientThread){
clientThread.interrupt();
clientThread.closeSocketInThisThread();
}
public void removeThread_concurrent(ServerClientThread clientThread){
clientThread.interrupt();
clientThread.closeSocketInThisThread();
clientThreads.remove(clientThread);
}
public void broadcastToAllClient(Assignment5RequestResponse response){
synchronized (clientThreads) {
for(ServerClientThread clientThread: clientThreads){
clientThread.sendResponseBack_File(response);
}
}
}
public updateThread getUpdateThreadMain() {
return updateThreadMain;
}
public void setUpdateThreadMain(updateThread updateThreadMain) {
this.updateThreadMain = updateThreadMain;
}
// public void updateTheNewHashmap(Assignment5RequestResponse request){
// synchronized (updateHashmap) {
// userNamefileNamePair pair = new userNamefileNamePair(request.getOwnerName(), request.getFileName());
// for(Map.Entry<userNamefileNamePair, Merger_Assignment5> entry: updateHashmap.entrySet()){
// if(entry.getKey().equals(pair)){
// System.out.println("hashmap does contain " + request.getOwnerName() + ", " + request.getFileName() + "updating");
// updateHashmap.get(entry.getKey()).addNewUpdateFromUsers(request.getFileContent());
// System.out.println("after update: " + updateHashmap.get(entry.getKey()).getNewUpdateFromUsers().toString());
// return;
// }
// }
//
// System.out.println("hashmap does not contain " + request.getOwnerName() + ", " + request.getFileName());
// Merger_Assignment5 merger_Assignment5 = new Merger_Assignment5();
// merger_Assignment5.addNewUpdateFromUsers(request.getFileContent());
// updateHashmap.put(pair, merger_Assignment5);
//
// }
// }
//
// public void mergeUpdates(){
// synchronized (updateHashmap) {
// for(Map.Entry<userNamefileNamePair, Merger_Assignment5> entry: updateHashmap.entrySet()){
// Assignment5RequestResponse response = updateHashmap.get(entry.getKey()).mergeUpdates(entry.getKey().getUserName(), entry.getKey().getFileName());
// broadcastToAllClient(response);
// }
// System.out.println("here");
// updateThreadMain.finishMerging.signalAll();
// }
// }
}
| [
"[email protected]"
] | |
d782eb5fa4723908387df4ea1a384c3929cd5643 | e0daa8f1cc1b590fd6d07d9aec16821d27a3b1ea | /jdk1.8/com/sun/corba/se/spi/activation/ORBPortInfoListHolder.java | 9bdbd4c0ee79534d90b4a93d35d592a258041510 | [] | no_license | gavin-one/jdk-study | 5d81a4296fc39a975b3b51de2bbba91a3686aa8e | 0bea803ef3ccac6cf2ec1ef93cb985c3c34c48d0 | refs/heads/master | 2021-04-15T10:11:34.631763 | 2018-03-23T06:23:54 | 2018-03-23T06:23:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,099 | java | package com.sun.corba.se.spi.activation;
/**
* com/sun/corba/se/spi/activation/ORBPortInfoListHolder.java .
* Generated by the IDL-to-Java compiler (portable), version "3.2"
* from d:/re/workspace/8-2-build-windows-amd64-cygwin/jdk8/2238/corba/src/share/classes/com/sun/corba/se/spi/activation/activation.idl
* Tuesday, March 4, 2014 3:47:38 AM PST
*/
public final class ORBPortInfoListHolder implements org.omg.CORBA.portable.Streamable
{
public com.sun.corba.se.spi.activation.ORBPortInfo value[] = null;
public ORBPortInfoListHolder ()
{
}
public ORBPortInfoListHolder (com.sun.corba.se.spi.activation.ORBPortInfo[] initialValue)
{
value = initialValue;
}
public void _read (org.omg.CORBA.portable.InputStream i)
{
value = com.sun.corba.se.spi.activation.ORBPortInfoListHelper.read (i);
}
public void _write (org.omg.CORBA.portable.OutputStream o)
{
com.sun.corba.se.spi.activation.ORBPortInfoListHelper.write (o, value);
}
public org.omg.CORBA.TypeCode _type ()
{
return com.sun.corba.se.spi.activation.ORBPortInfoListHelper.type ();
}
}
| [
"[email protected]"
] | |
c187540cb572b39586f0e221b88c870d6a9a6986 | 55c0eb8b78948aff5c55a4c22a6da56f15416c0b | /app/src/main/java/io/github/brettfx/chatviewdemo/recylcerchat/HolderDate.java | 473dda752054e105b703c34f69ff09a634b9f955 | [] | no_license | BrettFX/ChatViewDemo | e623413554768ce31f4c1730932a313bed299e97 | 674d731668d1104ee4ea45f942802edab889bc78 | refs/heads/master | 2021-01-07T18:55:24.041729 | 2020-02-21T02:40:20 | 2020-02-21T02:40:20 | 241,789,363 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 624 | java | package io.github.brettfx.chatviewdemo.recylcerchat;
//import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import io.github.brettfx.chatviewdemo.R;
/**
* Created by Dytstudio.
*/
public class HolderDate extends RecyclerView.ViewHolder {
private TextView date;
public HolderDate(View v) {
super(v);
date = (TextView) v.findViewById(R.id.tv_date);
}
public TextView getDate() {
return date;
}
public void setDate(TextView date) {
this.date = date;
}
}
| [
"[email protected]"
] | |
c4a10cb8e1a46e124c40241a4b52b8e34cf6607d | f49208814a9af2d309945ef094c141e9f40f1be5 | /src/main/java/com/example/SignInsystem/dao/TimeTableDAO.java | 68782cde5dc649dc614a36d77fa5337c518d05a7 | [] | no_license | lakomi/SignIn-system | 7e03568d800dd985023d04d01239ce84b06f26f9 | 156bec0d163e218987c47d68a00e9e148488bee1 | refs/heads/master | 2020-04-13T15:24:33.619385 | 2018-12-27T12:17:39 | 2018-12-27T12:17:39 | 163,290,558 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,610 | java | package com.example.SignInsystem.dao;
import com.example.SignInsystem.entity.TimeTable;
import com.example.SignInsystem.vo.SignListVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.sql.Date;
import java.sql.Time;
import java.util.List;
/**
* @author q
*/
@Repository
@Mapper
public interface TimeTableDAO {
/**
* 通过学号、日期查询日期内的签到签退情况
* 从本周表中得到数据
*
* @param startDate
* @param endDate
* @param userId
* @return
*/
List<TimeTable> getTablesByDate(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userId") String userId);
/**
* 获取新表中某人的某小日期
*
* @param userId
* @return
*/
String getNewTableMinTime(@Param("userId") String userId);
/**
* 获取旧表中某人的最大日期
*
* @param userId
* @return
*/
String getOldTableMaxTime(@Param("userId") String userId);
/**
* 通过学号、日期查询日期内的签到签退情况
* 从五周表中得到数据
*
* @param startDate
* @param endDate
* @param userId
* @return
*/
List<TimeTable> getAgoTableByDate(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("userId") String userId);
/**
* 添加签到信息
*
* @param timeId
* @param userId
* @param timeDate
* @param timeIn
* @param timeState
* @return
*/
int addTimeTable(@Param("timeId") String timeId, @Param("userId") String userId, @Param("timeDate") String timeDate, @Param("timeIn") String timeIn, @Param("timeState") int timeState);
/**
* 补充签退信息
*
* @param timeId
* @param timeOut
* @param timeState
* @param timeValid
* @return
*/
int updateTimeTable(@Param("timeId") String timeId, @Param("timeOut") String timeOut, @Param("timeState") int timeState, @Param("timeValid") String timeValid);
/**
* 批量插入数据
*
* @param timeTableList
* @return
*/
int insertListToAgoTable(@Param("timeTableList") List<TimeTable> timeTableList);
/**
* 某天 所有用户的签到签退状态列表
*
* @param tempDate
* @return
*/
List<SignListVo> getSignListByDate(@Param("tempDate") String tempDate);
/**
* 定时任务 将所有签退时间为空的记录的状态设为签到可用,并该条记录设为无效
*
* @return
*/
int timerUpdate();
/**
* 查找数据库中是否已有待签退的记录
*
* @param userId
* @param tempDate
* @return
*/
List<TimeTable> isRepeat(@Param("userId") String userId, @Param("tempDate") String tempDate);
/**
* 在某一时间内,查询所有
*
* @param startDate
* @param endDate
* @return
*/
List<TimeTable> selectAll(@Param("startDate") String startDate, @Param("endDate") String endDate);
/**
* 在某一时间内,删除所有
*
* @param startDate
* @param endDate
* @return
*/
int deleteAll(@Param("startDate") String startDate, @Param("endDate") String endDate);
/**
* 删除某一天之前的签到记录
*
* @return
*/
int deleteOneDayAgo();
/**
* 插入签到记录
*
* @param timeTable
* @return
*/
int insertOneTimeSup(TimeTable timeTable);
}
| [
"[email protected]"
] | |
b9dc010a0a3ecee86ac2f2141568c7a3de275951 | 9cf26edc13627afd07b5663e5ba78179f2d2bfec | /app/src/main/java/techkids/com/android9_tkmp3_onclass/databases/MusicTypeModel.java | d172f74c88d97ff21bb919ffce3a73b85c4624f5 | [] | no_license | phuongTP1998/ZingMp3_VuVuong | 5f18be36a10d7b016767871ec775511cfc567d00 | 67e86bb5eb362178b36e1e47f5eb829e2e1d45fc | refs/heads/master | 2021-07-09T16:23:23.769308 | 2017-10-02T04:00:30 | 2017-10-02T04:00:30 | 105,495,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 903 | java | package techkids.com.android9_tkmp3_onclass.databases;
/**
* Created by tungthanh.1497 on 07/19/2017.
*/
public class MusicTypeModel {
private String id;
private String translation_key;
private int imageID;
public MusicTypeModel() {
}
public MusicTypeModel(String id, String translation_key, int imageID) {
this.id = id;
this.translation_key = translation_key;
this.imageID = imageID;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTranslation_key() {
return translation_key;
}
public void setTranslation_key(String translation_key) {
this.translation_key = translation_key;
}
public int getImageID() {
return imageID;
}
public void setImageID(int imageID) {
this.imageID = imageID;
}
}
| [
"[email protected]"
] | |
8ebff8d6c41518e5ccc88587263bb3adae5c1475 | 3312db6327d8af690ca41a1b70a67ef13d7a7a94 | /recycleview/src/main/java/com/example/recycleview/InspectionRecord.java | 6a4ee73552b30a50fe3d10953f2e49631f565f60 | [] | no_license | Jeffery336699/EventBus2 | d3d7b66e66064ac710cb16ce975e1662a9dbafe5 | eca314cf90b67012338fa96d933a477819393190 | refs/heads/master | 2021-01-22T23:26:03.933286 | 2017-03-20T23:30:37 | 2017-03-20T23:30:37 | 85,637,671 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,118 | java | package com.example.recycleview;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.entity.MultiItemEntity;
import com.example.recycleview.adapter.ExpandableItemAdapter;
import com.example.recycleview.entity.Level0Item;
import com.example.recycleview.entity.Person;
import java.util.ArrayList;
import java.util.Random;
public class InspectionRecord extends BaseAcitivity {
private RecyclerView mRecyclerView;
private ArrayList<MultiItemEntity> list;
private ExpandableItemAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setBackBtn();
setTitle("ExpandableItem Activity");
setContentView(R.layout.activity_inspection_record);
mRecyclerView = (RecyclerView) findViewById(R.id.rv);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
list = generateData();
adapter = new ExpandableItemAdapter(list);
adapter.openLoadAnimation(BaseQuickAdapter.SLIDEIN_LEFT);
mRecyclerView.setAdapter(adapter);
expandAll();
}
private void expandAll() {
for (int i = 0; i <list.size() ; i++) {
adapter.expand(i + adapter.getHeaderLayoutCount(), false, false);
}
}
private ArrayList<MultiItemEntity> generateData() {
int lv0Count = 2;
int personCount = 5;
String[] nameList = {"Bob", "Andy", "Lily", "Brown", "Bruce"};
Random random = new Random();
ArrayList<MultiItemEntity> res = new ArrayList<>();
for (int i = 0; i < lv0Count; i++) {
Level0Item lv0 = new Level0Item("This is " + i + "th item in Level 0", "subtitle of " + i);
for (int k = 0; k < personCount; k++) {
lv0.addSubItem(new Person(nameList[k],nameList[k]+"--子类", random.nextInt(40)));
}
res.add(lv0);
}
return res;
}
}
| [
"[email protected]"
] | |
acc919be7f77b4b79af51637294f40467778358b | 41ecb4bffe35ae8a87ba07c8f5ad5ae08819847d | /src/com/hastable/INode.java | cca95e2392e5b0104af2004a04ea2915edd6271b | [] | no_license | shaileshdubeyr/HashTable | 61c67005c5f4d53d693681ce5dc8913d3a2c3f6d | e4c160b6d98e332fb2b0dc9367caa943328739e8 | refs/heads/master | 2023-08-29T10:05:01.447253 | 2021-10-23T18:19:32 | 2021-10-23T18:19:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 141 | java | package com.hastable;
public interface INode<K> {
K getKey();
void setKey(K key);
INode<K> getNext();
void setNext(INode<K> next);
}
| [
"[email protected]"
] | |
8a77479e9bd27e759873f0face4c5725312aef4c | 01d6839013d192946136b2cb1991fc4c6b7a1736 | /src/main/java/com/coocaa/remotectrlservice/dialog/TipsDialog.java | 1ad67c204aa8cd84a12e9e51ad7d81c7452c350a | [] | no_license | fanyanbo/SkyRemoteAssistant | 868e4c2f3409c3441dc7e967b4b5be0be7ee866b | d7389c1d01c4d9dca86642640f70fffe66176d3c | refs/heads/master | 2020-03-30T06:04:09.094220 | 2018-10-08T10:33:34 | 2018-10-08T10:33:34 | 150,837,266 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,131 | java | package com.coocaa.remotectrlservice.dialog;
import java.lang.ref.WeakReference;
import com.coocaa.remotectrlservice.R;
import com.skyworth.theme.SkyThemeEngine;
import com.skyworth.ui.blurbg.BlurBgLayout;
import com.skyworth.util.SkyScreenParams;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
import android.os.Message;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.FrameLayout;
import android.widget.TextView;
import android.widget.FrameLayout.LayoutParams;
public class TipsDialog extends Dialog {
private static TipsDialog instance = null;
private MyHandler mHandler;
private FrameLayout contentLayout;
private Context mContext;
private TextView toastTextView;
private FrameLayout shadowLayout;
private FrameLayout blurBgLayout;
private FrameLayout.LayoutParams shadowParams;
private BlurBgLayout mBgLayout = null;
public static TipsDialog getInstance(Context context)
{
if (instance == null) {
instance = new TipsDialog(context);
}
return instance;
}
private TipsDialog(Context context) {
super(context,R.style.dialog);
// TODO Auto-generated constructor stub
Window dialogWindow = getWindow();
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setType(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY);
SkyThemeEngine.getInstance().registerDialog(this);
if (mHandler == null)
mHandler = new MyHandler(this);
mContext = context;
// contentLayout 全屏透明使用
contentLayout = new FrameLayout(mContext);
contentLayout.setFocusable(false);
// shadowLayout 阴影布局使用
shadowLayout = new FrameLayout(mContext);
shadowParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
FrameLayout.LayoutParams.WRAP_CONTENT);
shadowParams.gravity = Gravity.CENTER_HORIZONTAL;
shadowParams.topMargin = SkyScreenParams.getInstence(mContext).getResolutionValue(780);
shadowLayout.setBackgroundResource(R.drawable.ui_sdk_toast_shadow_no_bg);
// blurBgLayout = new FrameLayout(mContext);
// blurBgLayout.setBackgroundResource(R.drawable.ui_sdk_other_page_bg_blur);
// blurBgLayout.setVisibility(View.GONE);
mBgLayout = new BlurBgLayout(context);
mBgLayout.setPageType(BlurBgLayout.PAGETYPE.OTHER_PAGE);
FrameLayout.LayoutParams bgParams = new FrameLayout.LayoutParams(
SkyScreenParams.getInstence(mContext).getResolutionValue(540),
SkyScreenParams.getInstence(mContext).getResolutionValue(70));
mBgLayout.setBgAlpha(1.0f);
shadowLayout.addView(mBgLayout, bgParams);
toastTextView = new TextView(mContext);
FrameLayout.LayoutParams toastTextViewParams = new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT);
toastTextView.setText(R.string.exit_control_tip);
toastTextView.setSingleLine(true);
toastTextView.setFocusable(false);
toastTextView.setGravity(Gravity.CENTER);
toastTextView.setPadding(SkyScreenParams.getInstence(mContext).getResolutionValue(70),
SkyScreenParams.getInstence(mContext).getResolutionValue(12), SkyScreenParams
.getInstence(mContext).getResolutionValue(70),
SkyScreenParams.getInstence(mContext).getResolutionValue(12));
toastTextView.setTextSize(SkyScreenParams.getInstence(mContext).getTextDpiValue(32));
toastTextView.setTextColor(mContext.getResources().getColor(R.color.c_3));
// toastTextView.setVisibility(View.INVISIBLE);
shadowLayout.addView(toastTextView, toastTextViewParams);
contentLayout.addView(shadowLayout, shadowParams);
this.setContentView(contentLayout, new FrameLayout.LayoutParams(
FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT));
this.setOnDismissListener(new OnDismissListener() {
@Override
public void onDismiss(DialogInterface arg0) {
// TODO Auto-generated method stub
}
});
this.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface arg0) {
// TODO Auto-generated method stub
refreshOnThemeChanged();
}
});
this.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface arg0) {
// TODO Auto-generated method stub
}
});
}
public boolean isShown(){
return this.isShowing();
}
public void showDialog(){
// toastTextView.setText(R.string.exit_control_tip);
// toastTextView.post(new Runnable()
// {
// @Override
// public void run()
// {
// FrameLayout.LayoutParams blue_p = (android.widget.FrameLayout.LayoutParams) blurBgLayout
// .getLayoutParams();
// blue_p.width = toastTextView.getWidth();
// blue_p.height = toastTextView.getHeight();
// blurBgLayout.setLayoutParams(blue_p);
// blurBgLayout.setVisibility(View.VISIBLE);
// }
// });
//
// shadowParams = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.WRAP_CONTENT,
// FrameLayout.LayoutParams.WRAP_CONTENT);
// shadowParams.gravity = Gravity.CENTER_HORIZONTAL;
// shadowParams.topMargin = SkyScreenParams.getInstence(mContext).getResolutionValue(780);
// shadowLayout.setLayoutParams(shadowParams);
// toastTextView.setVisibility(View.VISIBLE);
this.show();
if (mHandler.hasMessages(0))
mHandler.removeMessages(0);
mHandler.sendEmptyMessageDelayed(0, 3000);
}
public void hideDialog(){
this.hide();
}
public void cancelDialog(){
this.cancel();
}
@Override
public void dismiss()
{
if (mHandler.hasMessages(0))
mHandler.removeMessages(0);
super.dismiss();
}
private static class MyHandler extends Handler
{
private final WeakReference<TipsDialog> mView;
public MyHandler(TipsDialog view)
{
mView = new WeakReference<TipsDialog>(view);
}
@Override
public void handleMessage(Message msg)
{
TipsDialog view = mView.get();
if (view != null)
{
switch (msg.what)
{
case 0:
if (view.isShowing())
view.dismiss();
break;
default:
break;
}
}
}
}
private void refreshOnThemeChanged() {
// TODO Auto-generated method stub
toastTextView.setTextColor(mContext.getResources().getColor(R.color.c_3));
}
}
| [
"[email protected]"
] | |
5ad191926697e1df7b461c9003519a719c0e07a2 | 55d88331d83b44fcff586c16d89cf4561aafc639 | /todo/src/main/java/com/greenfoxacademy/todo/repositories/UserRepository.java | 47859df646acec1bdc69e94398caf95f31cb5a33 | [] | no_license | rekabuku/backend-workshop | 8eba5abf3e3ea5742e15f8e462408caf420fa459 | ebe8402c93c42b2c0f51159022093723e4f31bb6 | refs/heads/master | 2020-03-31T17:00:34.148845 | 2018-11-21T15:19:51 | 2018-11-21T15:19:51 | 152,400,910 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | package com.greenfoxacademy.todo.repositories;
import com.greenfoxacademy.todo.models.ApplicationUser;
import org.springframework.data.jpa.repository.JpaRepository;
public interface UserRepository extends JpaRepository<ApplicationUser, Long> {
ApplicationUser findByUsername(String username);
}
| [
"[email protected]"
] | |
7e219c3598d5f8b4f219c207bb8b0ee9d033119a | 6f11ae6a8c1f207dda5d503acd3cf0baf34bdd40 | /NextGreater.java | 5d7040c9d251be5f847b4fd8508be62188b35df3 | [] | no_license | jayathu/interviewprep-prework | 16ade19f2be57d2dae10c28dc8a6b8eae02f61f5 | 5162c0c6fe695941c2c400eedacfcbb87c74afa4 | refs/heads/master | 2020-03-16T17:19:00.971926 | 2018-05-10T00:50:19 | 2018-05-10T00:50:19 | 132,826,437 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 545 | java | import java.util.*;
public class NextGreater {
public ArrayList<Integer> nextGreater(ArrayList<Integer> A) {
ArrayList<Integer> results = new ArrayList<>();
int i = 0, j = 0;
for(i = 0; i < A.size(); i++){
for(j = i + 1; j < A.size(); j++){
if(A.get(j) > A.get(i)){
results.add(A.get(j));
break;
}
}
if(j == A.size()){
results.add(-1);
}
}
return results;
}
}
| [
"[email protected]"
] | |
27171efb9f2712fb2b37025337b75cdbf55ebcf3 | 93c76ddef5f8dbe78e060edb100d2091de87d934 | /desktop/geogebra/move/ggtapi/models/AuthenticationModelD.java | 4170cce0738508c35b5194640b368683dafbffe7 | [] | no_license | bigbluebutton86/geogebra | 5e9d0aaeb617b3ae2ec7fc6d24587d7fee1b916e | 764e0cf539d3bcbbc52dbcb93ea1b5ec1e3ad760 | refs/heads/master | 2021-01-18T02:49:02.961725 | 2013-12-06T22:01:32 | 2013-12-06T22:01:32 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 989 | java | package geogebra.move.ggtapi.models;
import geogebra.common.move.ggtapi.models.AuthenticationModel;
import geogebra.main.GeoGebraPreferencesD;
/**
* @author stefan
*
*/
public class AuthenticationModelD extends AuthenticationModel {
/**
* The token value that indicates that the token is not available (login was not performed yet)
*/
public static final String TOKEN_NOT_AVAILABLE = "<n/a>";
/**
* creates a new login model for Web
*/
public AuthenticationModelD() {
}
@Override
public void storeLoginToken(String token) {
GeoGebraPreferencesD.getPref().savePreference(GeoGebraPreferencesD.USER_LOGIN_TOKEN, token);
}
@Override
public String getLoginToken() {
String token = GeoGebraPreferencesD.getPref().loadPreference(GeoGebraPreferencesD.USER_LOGIN_TOKEN, TOKEN_NOT_AVAILABLE);
if (token.equals(TOKEN_NOT_AVAILABLE)) {
return null;
}
return token;
}
@Override
public void clearLoginToken() {
storeLoginToken(TOKEN_NOT_AVAILABLE);
}
}
| [
"[email protected]"
] | |
eb189261d7a4a0cb2d9af9025a2273f2ebf1bc4b | 1d05dd8edc0e775393609a47d7a1f3da55009656 | /app/src/main/java/android/room/play/com/nasadaily/vo/NasaDailyVO.java | ffac7185c55fd1ab1e6d0764dc3dc0505728b4e6 | [
"Apache-2.0"
] | permissive | chiragparmar17/nasa-daily | 026be3252f6ae1ca5b2af0c1c16651dffa4957c1 | 3e81fa38a26eb7056fd3cdcf43a7bcaf9433e9bb | refs/heads/master | 2021-05-29T13:05:23.575320 | 2015-11-15T14:37:56 | 2015-11-15T14:37:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,013 | java | package android.room.play.com.nasadaily.vo;
/**
* Created by Chirag Pc on 8/22/2015.
*/
public class NasaDailyVO {
private String uri;
private String mediaType;
private String explanation;
private String[] concepts;
private String title;
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getMediaType() {
return mediaType;
}
public void setMediaType(String mediaType) {
this.mediaType = mediaType;
}
public String getExplanation() {
return explanation;
}
public void setExplanation(String explanation) {
this.explanation = explanation;
}
public String[] getConcepts() {
return concepts;
}
public void setConcepts(String[] concepts) {
this.concepts = concepts;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
| [
"[email protected]"
] | |
2a77289c5abfacf4c06b21a854a00391be552e49 | 9489df7de60e62c53873f20c86ec47864b625d11 | /addressbook-web-tests/src/test/java/ru/stqa/pft/addressbook/tests/DbConnectionTest.java | 8951ba725df77c708f563f0167fbed71f2ec715b | [
"Apache-2.0"
] | permissive | Alexey1918/java_ptf | 432be4506bae6166084a62f7a279d2f6dbada26b | 03cd1f341d964f43c199a3576b65752e7d1facfe | refs/heads/main | 2023-04-29T23:06:01.985512 | 2021-05-21T15:51:59 | 2021-05-21T15:51:59 | 342,388,967 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,394 | java | package ru.stqa.pft.addressbook.tests;
import org.testng.annotations.Test;
import ru.stqa.pft.addressbook.model.Groups;
import ru.stqa.pft.addressbook.model.GroupData;
import java.sql.*;
public class DbConnectionTest {
@Test
public void testDbConnection(){
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost/addressbook?" + "user=root&password=");
Statement st = conn.createStatement();
ResultSet rs = st.executeQuery("SELECT group_id,group_name,group_header,group_footer FROM group_list");
Groups groups = new Groups();
while (rs.next()){
groups.add(new GroupData().withId(rs.getInt("group_id"))
.withName(rs.getString("group_name"))
.withHeader(rs.getString("group_header"))
.withFooter(rs.getString("group_footer")));
}
rs.close();
st.close();
conn.close();
System.out.println("Созданные группы " + groups);
} catch (SQLException ex) {
// handle any errors
System.out.println("SQLException: " + ex.getMessage());
System.out.println("SQLState: " + ex.getSQLState());
System.out.println("VendorError: " + ex.getErrorCode());
}
}
}
| [
"[email protected]"
] | |
763fe6da9b50f9d8547cc6906be13a2a405fe006 | b8e551fcef1c9d3aade40bf5218db01ca9b5ff75 | /Unidad20/src/main/java/JavaAngular/Unidad20/Ejerc01/AplicacionGrafica.java | 45d034c0cc96f9745f4fc63dc2fbf5bacdb4a5cf | [] | no_license | VyacheslavKhaydorov/JavaAngular_Unidad20 | 84b87c15571dcf8e37c29afa412709a67d38f656 | d171cd54781925f81f543c34e67b34684711403c | refs/heads/main | 2023-03-12T02:49:05.470986 | 2021-03-03T19:10:49 | 2021-03-03T19:10:49 | 343,792,513 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 738 | java | /**
*
*/
package JavaAngular.Unidad20.Ejerc01;
import javax.swing.*;
import java.awt.Color;
/**
* @author viach
*
*/
public class AplicacionGrafica extends JFrame {
private JPanel panelDeContenido;
public AplicacionGrafica() {
setTitle("Ejercicio 1");
setBounds(300,300,300,146);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
panelDeContenido = new JPanel();
panelDeContenido.setLayout(null);
setContentPane(panelDeContenido);
//Etiqueta
JLabel etiqueta = new JLabel("Este es el ejercicio 1 de la unidad 20");
etiqueta.setForeground(Color.BLACK);
etiqueta.setBounds(46,38,185,30);
panelDeContenido.add(etiqueta);
}
}
| [
"[email protected]"
] | |
a2e3711155c045e1cf25f0a22447df1aa224e91b | c3a1a0e83a707e78ec6dc1ad6d63adf6632c9fcb | /4.JavaCollections/src/com/codegym/task/task37/task3708/storage/RemoteStorage.java | e7c9dc9f9bec65b6ae2519f9c2ad97ed11dba05f | [] | no_license | Senned-001/CodegymTasks-Java- | a4b5c0f58c5c9ad782146d3bf4117a69e47c609c | cfd43cdee87edd225cacadacd14899eb80114428 | refs/heads/master | 2020-07-28T20:24:24.280873 | 2020-05-02T09:34:31 | 2020-05-02T09:34:31 | 209,524,464 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 586 | java | package com.codegym.task.task37.task3708.storage;
import java.util.HashMap;
public class RemoteStorage implements Storage {
private long id = 0;
private HashMap<Long, Object> storageMap = new HashMap<>();
@Override
public void add(Object o) {
storageMap.put(id++, o);
}
@Override
public Object get(long id) {
System.out.println("Getting a value for id #" + id + " from RemoteStorage...");
try {
Thread.sleep(2000);
} catch (InterruptedException ignored) {
}
return storageMap.get(id);
}
}
| [
"[email protected]"
] | |
813783e63c52174743dfef4d0631c1d4e543d38e | 347b62d108aaf199dce95a384c56a1fae6687e95 | /src/main/java/org/guili/ecshop/bean/credit/tmall/TmallSingleEvaluate.java | 905f77cb0ca6faad507c5d300ed2dbdf6f6c430a | [] | no_license | guiligege/womaime | 90da324501df2825db877bcf0992025b9e94f73b | fa50c56cfd776a7d4c4d99df2d9fbf919f4aa3a1 | refs/heads/master | 2016-09-09T23:59:34.011201 | 2014-01-05T15:28:26 | 2014-01-05T15:28:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,436 | java | package org.guili.ecshop.bean.credit.tmall;
import java.io.Serializable;
/**
* 天猫单个评论对象
* @author guili
*/
public class TmallSingleEvaluate implements Serializable{
private static final long serialVersionUID = 112342211122L;
private String annoy;
private String buyer;
private String credit;
private String date;
private String deal;
private String rateId;
private String reply;
private String text;
private String type;
public String getAnnoy() {
return annoy;
}
public void setAnnoy(String annoy) {
this.annoy = annoy;
}
public String getBuyer() {
return buyer;
}
public void setBuyer(String buyer) {
this.buyer = buyer;
}
public String getCredit() {
return credit;
}
public void setCredit(String credit) {
this.credit = credit;
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public String getDeal() {
return deal;
}
public void setDeal(String deal) {
this.deal = deal;
}
public String getRateId() {
return rateId;
}
public void setRateId(String rateId) {
this.rateId = rateId;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getReply() {
return reply;
}
public void setReply(String reply) {
this.reply = reply;
}
}
| [
"[email protected]"
] | |
411065af3842cde2d7c0ab13a20738a7f5aa68e5 | 9ff0c0f8a5a20dc321402151558e4f750cf8482b | /app/src/main/java/com/tmacbo/kotlinutils/fragment/DataListFragment.java | 7d6194c08e93ab60d890bccae30104e04be42e8a | [] | no_license | tmacbo/KotlinUtils | bf5556b0f8543952996b0476c9ce3b68873a7521 | d6eb5bea6367cda64d437e13cdd4f8f064c381c4 | refs/heads/master | 2021-01-17T04:28:35.538412 | 2017-07-28T02:37:23 | 2017-07-28T02:37:23 | 95,432,642 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,083 | java | package com.tmacbo.kotlinutils.fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.tmacbo.kotlinutils.R;
import retrofit2.Retrofit;
/**
* @Author tmacbo
* @Since on 2017/6/26 22:46
* @mail [email protected]
* @Description TODO
*/
public class DataListFragment extends Fragment {
private TextView textView;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_home, container, false);
textView = (TextView) rootView.findViewById(R.id.section_label);
textView.setText("DataListFragment");
return rootView;
}
private void netRequest(){
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("http://localhost:4567/")
.build();
}
}
| [
"[email protected]"
] | |
c90d967da3789fc31c3bf1503df191bc7f4fc5a7 | e86908640d2749a9ede93a056cb8ae696c2b8b22 | /src/main/java/com/yitianyike/calendar/appserver/bo/impl/GetSportsDataDBImpl.java | 249c273d4e0584225c9fc4178130aa10c906283b | [] | no_license | ndkhbwdddd/ndkhbwh | dd08c7a76346e56f34f49f1c0631c0b65f2a0526 | 01956bacf2afac0d42360ed9f8e50c3ab18f52d6 | refs/heads/master | 2021-07-05T23:55:45.856487 | 2017-09-04T11:23:07 | 2017-09-04T11:23:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,921 | java | /**
*
*/
package com.yitianyike.calendar.appserver.bo.impl;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yitianyike.calendar.appserver.bo.GetSportsDataDB;
import com.yitianyike.calendar.appserver.bo.IncrementDataBO;
import com.yitianyike.calendar.appserver.common.EnumConstants;
import com.yitianyike.calendar.appserver.dao.DataDAO;
import com.yitianyike.calendar.appserver.dao.RedisDAO;
import com.yitianyike.calendar.appserver.dao.UserDAO;
import com.yitianyike.calendar.appserver.model.DataInfo;
import com.yitianyike.calendar.appserver.model.response.AppResponse;
import com.yitianyike.calendar.appserver.service.DataAccessFactory;
import com.yitianyike.calendar.appserver.util.CalendarUtil;
import com.yitianyike.calendar.appserver.util.DateUtil;
import com.yitianyike.calendar.appserver.util.ParameterValidation;
/**
* @author xujinbo
*
*/
@Component("getSportsDataDB")
public class GetSportsDataDBImpl implements GetSportsDataDB {
private static Logger logger = Logger.getLogger(GetSportsDataDBImpl.class.getName());
private DataDAO dataDAO = (DataDAO) DataAccessFactory.dataHolder().get("dataDAO");
private RedisDAO redisDAO = (RedisDAO) DataAccessFactory.dataHolder().get("redisDAO");
@Override
public AppResponse process(Map<String, String> map, String content, long requestIndex) {
String token = map.get("token");
String aid = map.get("aid");
AppResponse appResponse = new AppResponse();
appResponse.setCode(EnumConstants.CALENDAR_SUCCESS_200);
Calendar cal = Calendar.getInstance();
SimpleDateFormat df = new SimpleDateFormat("yyyyMMdd");
cal.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); // 获取本周一的日期
String week = df.format(cal.getTime());
String currentDate = DateUtil.getCurrentDate();
Integer dateTime = Integer.parseInt(currentDate) - 2;
do {
if (token == null || aid == null || token.length() < 8 || aid.length() == 0) {
appResponse.setCode(EnumConstants.CALENDAR_ERROR_400);
logger.error(requestIndex + " : param error, return 400");
break;
}
int redisIndex = CalendarUtil.getRedisIndex(token);
String redisTemplate = "redisTemplate" + redisIndex;
redisDAO.setRedisTemplate(redisTemplate);
Map<String, String> tokenMap = redisDAO.hGetAll(token);
String uid = tokenMap.get("uid");
if (uid != null) {
Map<String, String> uidMap = redisDAO.hGetAll(uid);
// if (uidMap == null || uidMap.isEmpty() || !uidMap.get("token").equalsIgnoreCase(token)) {
// appResponse.setCode(EnumConstants.CALENDAR_ERROR_401);
// if (uidMap.get("token") == null) {
// logger.info(requestIndex + " : token exist, but current token : " + token
// + " is expired, return 401");
// } else {
// logger.info(requestIndex + " : token exist, but current token : " + token
// + " is invalid, new token : " + uidMap.get("token") + ", return 401");
// }
// redisDAO.delKey(token);
// redisDAO.clearRedisTemplate();
// break;
// }
String valueString = "";
String aidKey = uidMap.get("channel") + "-" + uidMap.get("version") + "-" + aid;
String detailsKey = uidMap.get("channel") + "-" + uidMap.get("version") + "-" + "details" + "-" + aid;
String hGetValue = redisDAO.hGetValue(detailsKey, detailsKey);
if (hGetValue == null) {
hGetValue = redisDAO.hGetValue(aidKey, week);
valueString = hGetValue;
appResponse.setRespContent(valueString);
break;
}
valueString = hGetValue;
String one = valueString.substring(0, 1);
if (one != "[" && !"[".equals(one)) {
valueString = "[" + valueString + "]";
}
/*
* List<String> fieldList =
* redisDAO.zRangeByScoreWithScores(aidKeySet, dateTime,
* Integer.parseInt(currentDate)); if(fieldList.size()<=1){
* hGetValue = redisDAO.hGetValue(aidKey,week); valueString =
* hGetValue; appResponse.setRespContent(valueString); break; }
*/
/*
* if(fieldList != null && fieldList.size() > 0){ List<String>
* valueList = redisDAO.hMgetValue(aidKey, fieldList);
* if(valueList != null && valueList.size() > 0){ for(String
* tempString: valueList){ if(tempString.charAt(0) == '[' &&
* tempString.charAt(tempString.length()-1) == ']'){ tempString
* = tempString.substring(1, tempString.length()-1); }
* valueString += tempString + ","; } } }else{
* if(redisDAO.keyExist(aidKeySet) == 0){
* logger.info(requestIndex + " zset key = " + aidKeySet +
* ", no exists!"); List<DataInfo> dataInfos =
* dataDAO.getDataInfos(aidKey); if(dataInfos != null &&
* dataInfos.size() > 0){ Map<String, String> dataMap = new
* HashMap<String, String>(); for(DataInfo info: dataInfos){
* dataMap.put(info.getField(), info.getCacheValue());
* if(dateTime.toString().compareToIgnoreCase(info.getField())
* <= 0 && currentDate.compareToIgnoreCase(info.getField()) >=
* 0){ String tempString = info.getCacheValue();
* if(tempString.charAt(0) == '[' &&
* tempString.charAt(tempString.length()-1) == ']'){ tempString
* = tempString.substring(1, tempString.length()-1); }
* valueString += tempString + ","; } }
* redisDAO.hMsetAndZadd(aidKey, dataMap); }else{
* logger.info(requestIndex + " : aid key = " + aidKey +
* " card data no exist in data cache"); } }else{
* logger.info(requestIndex + " : aid key set = " + aidKeySet +
* " redis key exist, but no data"); } }
*/
appResponse.setRespContent(valueString);
} else {
appResponse.setCode(EnumConstants.CALENDAR_ERROR_401);
logger.error(requestIndex + " : token no exist, return 401");
}
} while (false);
return appResponse;
}
}
| [
"[email protected]"
] | |
9435611c247ab982af69faf16881fcb3b3e99c22 | ad75c8d6a7ba9ea30b12bad159485ef72411953b | /src/main/java/com/jeanwolff/cursomc/domain/enums/EstadoPagamento.java | 79729bce3db7f1863e7628c5b51d2617b58b60e5 | [] | no_license | wolffjean/cursomc | 8eba83d50058606adbfd71b065a4c134a20439a8 | cd82bf1cb8a71b89f4ada6ba36c4e9c005509d9d | refs/heads/master | 2022-05-14T17:56:42.580253 | 2018-08-23T19:34:02 | 2018-08-23T19:34:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 714 | java | package com.jeanwolff.cursomc.domain.enums;
public enum EstadoPagamento {
PENDENTE(1, "Pendente"), QUITADO(2, "Quitado"), CANCELADO(3, "Cancelado");
private EstadoPagamento(Integer codigo, String descricao) {
this.codigo = codigo;
this.descricao = descricao;
}
private int codigo;
private String descricao;
public int getCodigo() {
return codigo;
}
public String getDescricao() {
return descricao;
}
public static EstadoPagamento toEnum(Integer codigo) {
if (codigo == null) {
return null;
}
for (EstadoPagamento x : EstadoPagamento.values()) {
if (codigo.equals(x.getCodigo())) {
return x;
}
}
throw new IllegalArgumentException("Id inválido: " + codigo);
}
}
| [
"[email protected]"
] | |
9b1404bf2d179d0aa95d8a3811e5eb23463fca81 | 7d0cc6f3c51ccf9b88d0bf7233bc2a908c886d74 | /src/LeetCode/Leetcode230.java | 8f19005f0bf61f59a8b58de32dcd4aa8e98ab4e9 | [] | no_license | JiangYueLi/LeetcodeHyh | 533c7b44951a250a639beffe7655b65051bb496f | 381b4ccdfa301119b5a8ea91388e4f5b72ee9289 | refs/heads/master | 2023-05-15T01:43:41.709614 | 2021-05-23T09:02:56 | 2021-05-23T09:02:56 | 370,004,926 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 829 | java | package LeetCode;
import java.util.Stack;
public class Leetcode230 {
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode() {}
TreeNode(int val) { this.val = val; }
TreeNode(int val, TreeNode left, TreeNode right) {
this.val = val;
this.left = left;
this.right = right;
}
}
public int kthSmallest(TreeNode root, int k) {
Stack<Integer> stack = new Stack<>();
helper(root,stack,k);
return stack.peek();
}
public void helper(TreeNode root,Stack<Integer> stack,int k)
{
if(root == null)
return;
helper(root.left,stack,k);
if(stack.size()==k)
{
return;
}
stack.push(root.val);
helper(root.right,stack,k);
}
}
| [
"[email protected]"
] | |
054515159c5b03f25507eef34a2011a34a894ba4 | 00632dda62a1d334e1272565e3f150f356a897d8 | /alunos/src/main/java/br/com/valhala/academia/alunos/infraestrutura/repositorios/jpa/AlunoRepository.java | 1a20514e7816057c1f2a164f6623221255c69684 | [] | no_license | BrunoLV/academia | 33fa8dc946d5d267f71baac0be2ae8eebfdbdecf | b5d361a70d790e2a7370682bbf3d6f184f575a55 | refs/heads/master | 2022-01-31T12:16:00.242699 | 2020-04-13T01:23:13 | 2020-04-13T01:23:13 | 250,876,337 | 0 | 1 | null | 2022-01-21T23:40:10 | 2020-03-28T19:26:22 | Java | UTF-8 | Java | false | false | 378 | java | package br.com.valhala.academia.alunos.infraestrutura.repositorios.jpa;
import br.com.valhala.academia.alunos.modelo.agregados.Aluno;
import br.com.valhala.academia.alunos.modelo.agregados.AlunoID;
import org.springframework.data.jpa.repository.JpaRepository;
public interface AlunoRepository extends JpaRepository<Aluno, Long> {
Aluno findByAlunoId(AlunoID alunoID);
}
| [
"[email protected]"
] | |
01365c85f8740ca4aa905539b1faf47c9548cb1c | bb0e94ec9ac2640ccce688c5cd10e2bbf14a49ce | /app/src/test/java/test/vcnc/co/kr/greendao/ExampleUnitTest.java | b3a61210bb2fe8bdb7dacb9dfd63999620da9d20 | [] | no_license | socar-alpaca/db-study | 637a9d142650c8c0286d7697f1a824c26c3c3be9 | 171099f58749c80ef1877732d05f887b36a92972 | refs/heads/master | 2023-01-07T23:51:13.541308 | 2017-02-15T09:13:46 | 2017-02-15T09:13:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 402 | java | package test.vcnc.co.kr.greendao;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
ba5a7a0f1f1a9feadd3d07e56f2633370b898fcc | ee70e60c732425d82b0a3fa21a426f08d59e9e03 | /src/test/java/com/cdsn/sell/LogbackDemo.java | 3b4a18d9698d414078f61bcfd38f320ce02e1a69 | [] | no_license | ChenHaoXFN/Sell | 5858d4326d176fad8f4810c5386c755a3be68204 | cdae0afaceaa52dd51dde2a1749e8651d913c5b6 | refs/heads/master | 2020-04-14T19:39:15.194307 | 2019-09-11T02:53:47 | 2019-09-11T02:53:47 | 164,066,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 416 | java | package com.cdsn.sell;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Logback
*
* @author chenhao
* @version 1.0.0
* @since 1.0.0
*
* Created at 2019-09-02 11:04
*/
//@Slf4j
public class LogbackDemo {
public static final Logger logger = LoggerFactory.getLogger(LogbackDemo.class);
public static void main(String[] args) {
logger.info("");
}
}
| [
"[email protected]"
] | |
23e88e45bfef57f3735bbbd15b2c3fc1b7e6b06b | d9d312a10429d65e54c46865f351a5a45a33cac9 | /Command.java | 3a51723087c073191767eb5ef8cf67fb6de375ae | [] | no_license | ArturoMacias/Actividad_0116 | 440533af90425bb410292c2b69122f17ed6bfb6b | c20f002eb60e441873180894438eb1ae731b06b6 | refs/heads/master | 2020-12-24T16:05:56.738560 | 2014-05-23T10:58:41 | 2014-05-23T10:58:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,028 | java | /**
* This class is part of the "World of Zuul" application.
* "World of Zuul" is a very simple, text based adventure game.
*
* This class holds information about a command that was issued by the user.
* A command currently consists of two strings: a command word and a second
* word (for example, if the command was "take map", then the two strings
* obviously are "take" and "map").
*
* The way this is used is: Commands are already checked for being valid
* command words. If the user entered an invalid command (a word that is not
* known) then the command word is <null>.
*
* If the command had only one word, then the second word is <null>.
*
* @author Michael Kölling and David J. Barnes
* @version 2011.07.31
*/
public class Command
{
private Option commandWord;
private String secondWord;
/**
* Create a command object. First and second word must be supplied, but
* either one (or both) can be null.
* @param firstWord
*
* @param secondWord The second word of the command.
*/
public Command(Option firstWord, String secondWord)
{
commandWord = firstWord;
this.secondWord = secondWord;
}
/**
* Return the command word (the first word) of this command. If the
* command was not understood, the result is null.
* @return The command word.
*/
public Option getCommandWord()
{
return commandWord;
}
/**
* @return The second word of this command. Returns null if there was no
* second word.
*/
public String getSecondWord()
{
return secondWord;
}
/**
* @return true if this command was not understood.
*/
public boolean isUnknown()
{
return (commandWord == Option.UNKNOWN);
}
/**
* @return true if the command has a second word.
*/
public boolean hasSecondWord()
{
return (secondWord != null);
}
}
| [
"[email protected]"
] | |
9f08fc80d1de703f9efc1f2260a1a9095afb5a2c | 79286a1bda4d4b0e4c852ecf2861241ed4ff998e | /app/src/main/java/com/xuye/androidlearning/handleLearning/HandlerLearingActivity.java | 253c74fb6cbe7b2c0effe353d658fb9fcc877150 | [] | no_license | x1876631/AndroidLearning | 8aaae325cd632a48e1d1744a04ed37fe8da33e76 | 5b344f98cf6d2fa108af3e0ee0a99a347b7c1e4d | refs/heads/master | 2021-08-16T10:12:23.661003 | 2020-08-26T13:17:50 | 2020-08-26T13:19:58 | 72,109,440 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,380 | java | package com.xuye.androidlearning.handleLearning;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;
import com.xuye.androidlearning.R;
import com.xuye.androidlearning.base.CommonTestActivity;
/**
* Created by xuye on 17/01/12
* handler学习
*/
public class HandlerLearingActivity extends CommonTestActivity {
private static final String tag = "HandlerLearing";
//线程内部的数据存储类,可以在指定的线程存取数据
private ThreadLocal<Boolean> mBooleanThreadLocal = new ThreadLocal<>();
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
showItemWithCount(new String[]{getString(R.string.send_handler_message)});
initHandler();
}
private void initHandler() {
mBooleanThreadLocal.set(true);
Log.e(tag, "[Thread#main]mBooleanThreadLocal=" + mBooleanThreadLocal.get());
new Thread("Thread#1") {
@Override
public void run() {
mBooleanThreadLocal.set(false);
Log.e(tag, "[Thread#1]mBooleanThreadLocal=" + mBooleanThreadLocal.get());
}
}.start();
}
@Override
protected void clickButton1() {
new Thread("Thread#2") {
@Override
public void run() {
Log.e(tag, "[Thread#2]mBooleanThreadLocal=" + mBooleanThreadLocal.get());
//在当前线程里存了个looper,此looper持有当前线程的引用,和一个新的消息队列
Looper.prepare();
/*
* 在子线程创建handler时,需要先创建looper,否则会报异常
* 创建handler时,这个handler会持有当前线程里的looper和消息队列
*/
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
// TODO: 17/1/13 api 21、22 为什么没弹出toast? 但api 23可以?
/*
* api 21、22 为什么没弹出toast? 但api 23可以?
* 看了toast的源码,正常在TN类的handleShow方法里,调用mWM.addView(mView, mParams)后,
* 就可以展示toast了,但是addView要展示view需要使用UI线程的handler,而现在是在子线程2里,所以无法展示。
* 那为什么23可以展示呢?
*/
Toast.makeText(
HandlerLearingActivity.this.getApplicationContext(), "[Thread#2 handle 0]",
Toast.LENGTH_SHORT).show();
Log.e(tag, "[Thread#2 handle 0]");
//如果Looper不用了,记得退出,否则当前线程会一直运行不会退出
// Looper.myLooper().quit();
break;
}
}
};
/*
* handler发送了个消息,其实是在消息队里里插入了一条消息,消息的target是此handler
* 而之前Looper.loop();已经开启了循环读取消息,就会读到这条消息
* 然后调用消息里绑定的handler去处理这个消息,执行此handler的handleMessage
*/
handler.sendEmptyMessage(1);
/*
* Looper.loop();拿到当前线程的消息队列,无限循环地读取消息队列里的消息,
* 如果读到消息,就给用消息绑定的handler去处理这个消息,
* 如果读不到消息,就一直阻塞
* 因此,该线程也就一直被hold住,不会销毁了
* ps:loop()方法要放到最后,否则之后的代码不会被执行到,因为loop开启了个死循环
*/
Looper.loop();
}
}.start();
}
}
| [
"[email protected]"
] | |
deafb4f0229deab6f18c560eea517b9b2044c473 | bb1c36eba1dd7684af02f532f97dec0facd145dc | /Javame/TMessageBox.java | b18c4551e8505e9238ac2cc96fcfcc9813e34cf7 | [] | no_license | shesheshe/linethrift | 220d34ca865f4adbd918117aa20daeb67210cac5 | 114b1ff1acde89b9018e05e645dd7098b4e0e900 | refs/heads/master | 2020-09-06T07:32:27.212969 | 2019-09-28T08:33:11 | 2019-09-28T08:33:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | true | 20,151 | java | /**
* Autogenerated by Thrift Compiler (0.13.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
import java.util.Hashtable;
import java.util.Vector;
import java.util.Enumeration;
import org.apache.thrift.*;
import org.apache.thrift.meta_data.*;
import org.apache.thrift.transport.*;
import org.apache.thrift.protocol.*;
public class TMessageBox implements TBase {
private static final TStruct STRUCT_DESC = new TStruct("TMessageBox");
private static final TField ID_FIELD_DESC = new TField("id", TType.STRING, (short)1);
private static final TField CHANNEL_ID_FIELD_DESC = new TField("channelId", TType.STRING, (short)2);
private static final TField LAST_SEQ_FIELD_DESC = new TField("lastSeq", TType.I64, (short)5);
private static final TField UNREAD_COUNT_FIELD_DESC = new TField("unreadCount", TType.I64, (short)6);
private static final TField LAST_MODIFIED_TIME_FIELD_DESC = new TField("lastModifiedTime", TType.I64, (short)7);
private static final TField STATUS_FIELD_DESC = new TField("status", TType.I32, (short)8);
private static final TField MID_TYPE_FIELD_DESC = new TField("midType", TType.I32, (short)9);
private static final TField LAST_MESSAGES_FIELD_DESC = new TField("lastMessages", TType.LIST, (short)10);
private String id;
private String channelId;
private long lastSeq;
private long unreadCount;
private long lastModifiedTime;
private int status;
private MIDType midType;
private Vector lastMessages;
// isset id assignments
private static final int __LASTSEQ_ISSET_ID = 0;
private static final int __UNREADCOUNT_ISSET_ID = 1;
private static final int __LASTMODIFIEDTIME_ISSET_ID = 2;
private static final int __STATUS_ISSET_ID = 3;
private boolean[] __isset_vector = new boolean[4];
public TMessageBox() {
}
public TMessageBox(
String id,
String channelId,
long lastSeq,
long unreadCount,
long lastModifiedTime,
int status,
MIDType midType,
Vector lastMessages)
{
this();
this.id = id;
this.channelId = channelId;
this.lastSeq = lastSeq;
setLastSeqIsSet(true);
this.unreadCount = unreadCount;
setUnreadCountIsSet(true);
this.lastModifiedTime = lastModifiedTime;
setLastModifiedTimeIsSet(true);
this.status = status;
setStatusIsSet(true);
this.midType = midType;
this.lastMessages = lastMessages;
}
/**
* Performs a deep copy on <i>other</i>.
*/
public TMessageBox(TMessageBox other) {
System.arraycopy(other.__isset_vector, 0, __isset_vector, 0, other.__isset_vector.length);
if (other.isSetId()) {
this.id = other.id;
}
if (other.isSetChannelId()) {
this.channelId = other.channelId;
}
this.lastSeq = other.lastSeq;
this.unreadCount = other.unreadCount;
this.lastModifiedTime = other.lastModifiedTime;
this.status = other.status;
if (other.isSetMidType()) {
this.midType = other.midType;
}
if (other.isSetLastMessages()) {
Vector __this__lastMessages = new Vector();
for (Enumeration other_enum = other.lastMessages.elements(); other_enum.hasMoreElements(); ) {
Message other_element = (Message)other_enum.nextElement();
__this__lastMessages.addElement(new Message(other_element));
}
this.lastMessages = __this__lastMessages;
}
}
public TMessageBox deepCopy() {
return new TMessageBox(this);
}
public void clear() {
this.id = null;
this.channelId = null;
setLastSeqIsSet(false);
this.lastSeq = 0;
setUnreadCountIsSet(false);
this.unreadCount = 0;
setLastModifiedTimeIsSet(false);
this.lastModifiedTime = 0;
setStatusIsSet(false);
this.status = 0;
this.midType = null;
this.lastMessages = null;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public void unsetId() {
this.id = null;
}
/** Returns true if field id is set (has been assigned a value) and false otherwise */
public boolean isSetId() {
return this.id != null;
}
public void setIdIsSet(boolean value) {
if (!value) {
this.id = null;
}
}
public String getChannelId() {
return this.channelId;
}
public void setChannelId(String channelId) {
this.channelId = channelId;
}
public void unsetChannelId() {
this.channelId = null;
}
/** Returns true if field channelId is set (has been assigned a value) and false otherwise */
public boolean isSetChannelId() {
return this.channelId != null;
}
public void setChannelIdIsSet(boolean value) {
if (!value) {
this.channelId = null;
}
}
public long getLastSeq() {
return this.lastSeq;
}
public void setLastSeq(long lastSeq) {
this.lastSeq = lastSeq;
setLastSeqIsSet(true);
}
public void unsetLastSeq() {
__isset_vector[__LASTSEQ_ISSET_ID] = false;
}
/** Returns true if field lastSeq is set (has been assigned a value) and false otherwise */
public boolean isSetLastSeq() {
return __isset_vector[__LASTSEQ_ISSET_ID];
}
public void setLastSeqIsSet(boolean value) {
__isset_vector[__LASTSEQ_ISSET_ID] = value;
}
public long getUnreadCount() {
return this.unreadCount;
}
public void setUnreadCount(long unreadCount) {
this.unreadCount = unreadCount;
setUnreadCountIsSet(true);
}
public void unsetUnreadCount() {
__isset_vector[__UNREADCOUNT_ISSET_ID] = false;
}
/** Returns true if field unreadCount is set (has been assigned a value) and false otherwise */
public boolean isSetUnreadCount() {
return __isset_vector[__UNREADCOUNT_ISSET_ID];
}
public void setUnreadCountIsSet(boolean value) {
__isset_vector[__UNREADCOUNT_ISSET_ID] = value;
}
public long getLastModifiedTime() {
return this.lastModifiedTime;
}
public void setLastModifiedTime(long lastModifiedTime) {
this.lastModifiedTime = lastModifiedTime;
setLastModifiedTimeIsSet(true);
}
public void unsetLastModifiedTime() {
__isset_vector[__LASTMODIFIEDTIME_ISSET_ID] = false;
}
/** Returns true if field lastModifiedTime is set (has been assigned a value) and false otherwise */
public boolean isSetLastModifiedTime() {
return __isset_vector[__LASTMODIFIEDTIME_ISSET_ID];
}
public void setLastModifiedTimeIsSet(boolean value) {
__isset_vector[__LASTMODIFIEDTIME_ISSET_ID] = value;
}
public int getStatus() {
return this.status;
}
public void setStatus(int status) {
this.status = status;
setStatusIsSet(true);
}
public void unsetStatus() {
__isset_vector[__STATUS_ISSET_ID] = false;
}
/** Returns true if field status is set (has been assigned a value) and false otherwise */
public boolean isSetStatus() {
return __isset_vector[__STATUS_ISSET_ID];
}
public void setStatusIsSet(boolean value) {
__isset_vector[__STATUS_ISSET_ID] = value;
}
/**
*
* @see MIDType
*/
public MIDType getMidType() {
return this.midType;
}
/**
*
* @see MIDType
*/
public void setMidType(MIDType midType) {
this.midType = midType;
}
public void unsetMidType() {
this.midType = null;
}
/** Returns true if field midType is set (has been assigned a value) and false otherwise */
public boolean isSetMidType() {
return this.midType != null;
}
public void setMidTypeIsSet(boolean value) {
if (!value) {
this.midType = null;
}
}
public int getLastMessagesSize() {
return (this.lastMessages == null) ? 0 : this.lastMessages.size();
}
public Enumeration getLastMessagesEnumeration() {
return (this.lastMessages == null) ? null : this.lastMessages.elements();
}
public void addToLastMessages(Message elem) {
if (this.lastMessages == null) {
this.lastMessages = new Vector();
}
this.lastMessages.addElement(elem);
}
public Vector getLastMessages() {
return this.lastMessages;
}
public void setLastMessages(Vector lastMessages) {
this.lastMessages = lastMessages;
}
public void unsetLastMessages() {
this.lastMessages = null;
}
/** Returns true if field lastMessages is set (has been assigned a value) and false otherwise */
public boolean isSetLastMessages() {
return this.lastMessages != null;
}
public void setLastMessagesIsSet(boolean value) {
if (!value) {
this.lastMessages = null;
}
}
public boolean equals(Object that) {
if (that == null)
return false;
if (that instanceof TMessageBox)
return this.equals((TMessageBox)that);
return false;
}
public boolean equals(TMessageBox that) {
if (that == null)
return false;
if (this == that)
return true;
boolean this_present_id = true && this.isSetId();
boolean that_present_id = true && that.isSetId();
if (this_present_id || that_present_id) {
if (!(this_present_id && that_present_id))
return false;
if (!this.id.equals(that.id))
return false;
}
boolean this_present_channelId = true && this.isSetChannelId();
boolean that_present_channelId = true && that.isSetChannelId();
if (this_present_channelId || that_present_channelId) {
if (!(this_present_channelId && that_present_channelId))
return false;
if (!this.channelId.equals(that.channelId))
return false;
}
boolean this_present_lastSeq = true;
boolean that_present_lastSeq = true;
if (this_present_lastSeq || that_present_lastSeq) {
if (!(this_present_lastSeq && that_present_lastSeq))
return false;
if (this.lastSeq != that.lastSeq)
return false;
}
boolean this_present_unreadCount = true;
boolean that_present_unreadCount = true;
if (this_present_unreadCount || that_present_unreadCount) {
if (!(this_present_unreadCount && that_present_unreadCount))
return false;
if (this.unreadCount != that.unreadCount)
return false;
}
boolean this_present_lastModifiedTime = true;
boolean that_present_lastModifiedTime = true;
if (this_present_lastModifiedTime || that_present_lastModifiedTime) {
if (!(this_present_lastModifiedTime && that_present_lastModifiedTime))
return false;
if (this.lastModifiedTime != that.lastModifiedTime)
return false;
}
boolean this_present_status = true;
boolean that_present_status = true;
if (this_present_status || that_present_status) {
if (!(this_present_status && that_present_status))
return false;
if (this.status != that.status)
return false;
}
boolean this_present_midType = true && this.isSetMidType();
boolean that_present_midType = true && that.isSetMidType();
if (this_present_midType || that_present_midType) {
if (!(this_present_midType && that_present_midType))
return false;
if (!this.midType.equals(that.midType))
return false;
}
boolean this_present_lastMessages = true && this.isSetLastMessages();
boolean that_present_lastMessages = true && that.isSetLastMessages();
if (this_present_lastMessages || that_present_lastMessages) {
if (!(this_present_lastMessages && that_present_lastMessages))
return false;
if (!this.lastMessages.equals(that.lastMessages))
return false;
}
return true;
}
public int hashCode() {
return 0;
}
public int compareTo(Object otherObject) {
if (!getClass().equals(otherObject.getClass())) {
return getClass().getName().compareTo(otherObject.getClass().getName());
}
TMessageBox other = (TMessageBox)otherObject; int lastComparison = 0;
lastComparison = TBaseHelper.compareTo(isSetId(), other.isSetId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetId()) {
lastComparison = TBaseHelper.compareTo(this.id, other.id);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetChannelId(), other.isSetChannelId());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetChannelId()) {
lastComparison = TBaseHelper.compareTo(this.channelId, other.channelId);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetLastSeq(), other.isSetLastSeq());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLastSeq()) {
lastComparison = TBaseHelper.compareTo(this.lastSeq, other.lastSeq);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetUnreadCount(), other.isSetUnreadCount());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetUnreadCount()) {
lastComparison = TBaseHelper.compareTo(this.unreadCount, other.unreadCount);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetLastModifiedTime(), other.isSetLastModifiedTime());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLastModifiedTime()) {
lastComparison = TBaseHelper.compareTo(this.lastModifiedTime, other.lastModifiedTime);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetStatus(), other.isSetStatus());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetStatus()) {
lastComparison = TBaseHelper.compareTo(this.status, other.status);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetMidType(), other.isSetMidType());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetMidType()) {
lastComparison = TBaseHelper.compareTo(this.midType, other.midType);
if (lastComparison != 0) {
return lastComparison;
}
}
lastComparison = TBaseHelper.compareTo(isSetLastMessages(), other.isSetLastMessages());
if (lastComparison != 0) {
return lastComparison;
}
if (isSetLastMessages()) {
lastComparison = TBaseHelper.compareTo(this.lastMessages, other.lastMessages);
if (lastComparison != 0) {
return lastComparison;
}
}
return 0;
}
public void read(TProtocol iprot) throws TException {
TField field;
iprot.readStructBegin();
while (true)
{
field = iprot.readFieldBegin();
if (field.type == TType.STOP) {
break;
}
switch (field.id) {
case 1: // ID
if (field.type == TType.STRING) {
this.id = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 2: // CHANNEL_ID
if (field.type == TType.STRING) {
this.channelId = iprot.readString();
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 5: // LAST_SEQ
if (field.type == TType.I64) {
this.lastSeq = iprot.readI64();
setLastSeqIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 6: // UNREAD_COUNT
if (field.type == TType.I64) {
this.unreadCount = iprot.readI64();
setUnreadCountIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 7: // LAST_MODIFIED_TIME
if (field.type == TType.I64) {
this.lastModifiedTime = iprot.readI64();
setLastModifiedTimeIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 8: // STATUS
if (field.type == TType.I32) {
this.status = iprot.readI32();
setStatusIsSet(true);
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 9: // MID_TYPE
if (field.type == TType.I32) {
this.midType = MIDType.findByValue(iprot.readI32());
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
case 10: // LAST_MESSAGES
if (field.type == TType.LIST) {
{
TList _list255 = iprot.readListBegin();
this.lastMessages = new Vector(_list255.size);
for (int _i256 = 0; _i256 < _list255.size; ++_i256)
{
Message _elem257;
_elem257 = new Message();
_elem257.read(iprot);
this.lastMessages.addElement(_elem257);
}
iprot.readListEnd();
}
} else {
TProtocolUtil.skip(iprot, field.type);
}
break;
default:
TProtocolUtil.skip(iprot, field.type);
}
iprot.readFieldEnd();
}
iprot.readStructEnd();
validate();
}
public void write(TProtocol oprot) throws TException {
validate();
oprot.writeStructBegin(STRUCT_DESC);
if (this.id != null) {
oprot.writeFieldBegin(ID_FIELD_DESC);
oprot.writeString(this.id);
oprot.writeFieldEnd();
}
if (this.channelId != null) {
oprot.writeFieldBegin(CHANNEL_ID_FIELD_DESC);
oprot.writeString(this.channelId);
oprot.writeFieldEnd();
}
oprot.writeFieldBegin(LAST_SEQ_FIELD_DESC);
oprot.writeI64(this.lastSeq);
oprot.writeFieldEnd();
oprot.writeFieldBegin(UNREAD_COUNT_FIELD_DESC);
oprot.writeI64(this.unreadCount);
oprot.writeFieldEnd();
oprot.writeFieldBegin(LAST_MODIFIED_TIME_FIELD_DESC);
oprot.writeI64(this.lastModifiedTime);
oprot.writeFieldEnd();
oprot.writeFieldBegin(STATUS_FIELD_DESC);
oprot.writeI32(this.status);
oprot.writeFieldEnd();
if (this.midType != null) {
oprot.writeFieldBegin(MID_TYPE_FIELD_DESC);
oprot.writeI32(this.midType.getValue());
oprot.writeFieldEnd();
}
if (this.lastMessages != null) {
oprot.writeFieldBegin(LAST_MESSAGES_FIELD_DESC);
{
oprot.writeListBegin(new TList(TType.STRUCT, this.lastMessages.size()));
for (Enumeration _iter258_enum = this.lastMessages.elements(); _iter258_enum.hasMoreElements(); ) {
Message _iter258 = (Message)_iter258_enum.nextElement();
_iter258.write(oprot);
}
oprot.writeListEnd();
}
oprot.writeFieldEnd();
}
oprot.writeFieldStop();
oprot.writeStructEnd();
}
public String toString() {
StringBuffer sb = new StringBuffer("TMessageBox(");
boolean first = true;
sb.append("id:");
if (this.id == null) {
sb.append("null");
} else {
sb.append(this.id);
}
first = false;
if (!first) sb.append(", ");
sb.append("channelId:");
if (this.channelId == null) {
sb.append("null");
} else {
sb.append(this.channelId);
}
first = false;
if (!first) sb.append(", ");
sb.append("lastSeq:");
sb.append(this.lastSeq);
first = false;
if (!first) sb.append(", ");
sb.append("unreadCount:");
sb.append(this.unreadCount);
first = false;
if (!first) sb.append(", ");
sb.append("lastModifiedTime:");
sb.append(this.lastModifiedTime);
first = false;
if (!first) sb.append(", ");
sb.append("status:");
sb.append(this.status);
first = false;
if (!first) sb.append(", ");
sb.append("midType:");
if (this.midType == null) {
sb.append("null");
} else {
sb.append(this.midType);
}
first = false;
if (!first) sb.append(", ");
sb.append("lastMessages:");
if (this.lastMessages == null) {
sb.append("null");
} else {
sb.append(this.lastMessages);
}
first = false;
sb.append(")");
return sb.toString();
}
public void validate() throws TException {
// check for required fields
}
}
| [
"[email protected]"
] | |
02d01215b39dea076aac0833bc1c5a26f0e0f91f | ab224d439746af74db556ab11f12bfad6a3c7071 | /Program2_PrintAnInteger.java | b7a9eb4cf89899930f0a073cb6e23766e2164f2d | [] | no_license | JamilathulRumana/HIT_Inspiron_Java | 211f5404ed9fa24381d7ed192aeb74a5b4148048 | cd50a134c339ad9c1c038faf218aad64c28a8d45 | refs/heads/main | 2023-06-25T09:12:47.365547 | 2021-07-17T17:05:22 | 2021-07-17T17:05:22 | 385,673,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 296 | java | import java.util.Scanner;
public class Program2_PrintAnInteger
{
public static void main(String[] args)
{
Scanner scan= new Scanner(System.in);
System.out.println("Enter a number: ");
int num1 = scan.nextInt();
System.out.println("Hey! You have entered "+num1+ ".");
}
}
| [
"[email protected]"
] | |
cefdf8a19fce1e1fd3066f0c5e75daa7d273dd47 | 928114757a9d6f36cd5ae14d3ba0173e7d068496 | /src/secp256k1/src/java/org/bitcoin/NativeSecp256k1.java | 23bf81a1f2275ddd666b592b11e4a097f3cb4de2 | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | ilafaf/kori | 65969ff2f9947f581f25f988a1180c731558312c | f77aeb4d19b66a3617d3a029c5c6ba2896ecf7b4 | refs/heads/master | 2021-05-06T13:32:59.180598 | 2017-12-05T20:48:28 | 2017-12-05T20:48:28 | 113,225,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,744 | java | /*
* Copyright 2013 Google Inc.
* Copyright 2014-2016 the libsecp256k1 contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.kori;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.math.BigInteger;
import com.google.common.base.Preconditions;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import static org.kori.NativeSecp256k1Util.*;
/**
* <p>This class holds native methods to handle ECDSA verification.</p>
*
* <p>You can find an example library that can be used for this at https://github.com/kori/secp256k1</p>
*
* <p>To build secp256k1 for use with korij, run
* `./configure --enable-jni --enable-experimental --enable-module-ecdh`
* and `make` then copy `.libs/libsecp256k1.so` to your system library path
* or point the JVM to the folder containing it with -Djava.library.path
* </p>
*/
public class NativeSecp256k1 {
private static final ReentrantReadWriteLock rwl = new ReentrantReadWriteLock();
private static final Lock r = rwl.readLock();
private static final Lock w = rwl.writeLock();
private static ThreadLocal<ByteBuffer> nativeECDSABuffer = new ThreadLocal<ByteBuffer>();
/**
* Verifies the given secp256k1 signature in native code.
* Calling when enabled == false is undefined (probably library not loaded)
*
* @param data The data which was signed, must be exactly 32 bytes
* @param signature The signature
* @param pub The public key which did the signing
*/
public static boolean verify(byte[] data, byte[] signature, byte[] pub) throws AssertFailException{
Preconditions.checkArgument(data.length == 32 && signature.length <= 520 && pub.length <= 520);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < 520) {
byteBuff = ByteBuffer.allocateDirect(520);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(data);
byteBuff.put(signature);
byteBuff.put(pub);
byte[][] retByteArray;
r.lock();
try {
return secp256k1_ecdsa_verify(byteBuff, Secp256k1Context.getContext(), signature.length, pub.length) == 1;
} finally {
r.unlock();
}
}
/**
* libsecp256k1 Create an ECDSA signature.
*
* @param data Message hash, 32 bytes
* @param key Secret key, 32 bytes
*
* Return values
* @param sig byte array of signature
*/
public static byte[] sign(byte[] data, byte[] sec) throws AssertFailException{
Preconditions.checkArgument(data.length == 32 && sec.length <= 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < 32 + 32) {
byteBuff = ByteBuffer.allocateDirect(32 + 32);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(data);
byteBuff.put(sec);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_ecdsa_sign(byteBuff, Secp256k1Context.getContext());
} finally {
r.unlock();
}
byte[] sigArr = retByteArray[0];
int sigLen = new BigInteger(new byte[] { retByteArray[1][0] }).intValue();
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(sigArr.length, sigLen, "Got bad signature length.");
return retVal == 0 ? new byte[0] : sigArr;
}
/**
* libsecp256k1 Seckey Verify - returns 1 if valid, 0 if invalid
*
* @param seckey ECDSA Secret key, 32 bytes
*/
public static boolean secKeyVerify(byte[] seckey) {
Preconditions.checkArgument(seckey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seckey.length) {
byteBuff = ByteBuffer.allocateDirect(seckey.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(seckey);
r.lock();
try {
return secp256k1_ec_seckey_verify(byteBuff,Secp256k1Context.getContext()) == 1;
} finally {
r.unlock();
}
}
/**
* libsecp256k1 Compute Pubkey - computes public key from secret key
*
* @param seckey ECDSA Secret key, 32 bytes
*
* Return values
* @param pubkey ECDSA Public key, 33 or 65 bytes
*/
//TODO add a 'compressed' arg
public static byte[] computePubkey(byte[] seckey) throws AssertFailException{
Preconditions.checkArgument(seckey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seckey.length) {
byteBuff = ByteBuffer.allocateDirect(seckey.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(seckey);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_ec_pubkey_create(byteBuff, Secp256k1Context.getContext());
} finally {
r.unlock();
}
byte[] pubArr = retByteArray[0];
int pubLen = new BigInteger(new byte[] { retByteArray[1][0] }).intValue();
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(pubArr.length, pubLen, "Got bad pubkey length.");
return retVal == 0 ? new byte[0]: pubArr;
}
/**
* libsecp256k1 Cleanup - This destroys the secp256k1 context object
* This should be called at the end of the program for proper cleanup of the context.
*/
public static synchronized void cleanup() {
w.lock();
try {
secp256k1_destroy_context(Secp256k1Context.getContext());
} finally {
w.unlock();
}
}
public static long cloneContext() {
r.lock();
try {
return secp256k1_ctx_clone(Secp256k1Context.getContext());
} finally { r.unlock(); }
}
/**
* libsecp256k1 PrivKey Tweak-Mul - Tweak privkey by multiplying to it
*
* @param tweak some bytes to tweak with
* @param seckey 32-byte seckey
*/
public static byte[] privKeyTweakMul(byte[] privkey, byte[] tweak) throws AssertFailException{
Preconditions.checkArgument(privkey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < privkey.length + tweak.length) {
byteBuff = ByteBuffer.allocateDirect(privkey.length + tweak.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(privkey);
byteBuff.put(tweak);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_privkey_tweak_mul(byteBuff,Secp256k1Context.getContext());
} finally {
r.unlock();
}
byte[] privArr = retByteArray[0];
int privLen = (byte) new BigInteger(new byte[] { retByteArray[1][0] }).intValue() & 0xFF;
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(privArr.length, privLen, "Got bad pubkey length.");
assertEquals(retVal, 1, "Failed return value check.");
return privArr;
}
/**
* libsecp256k1 PrivKey Tweak-Add - Tweak privkey by adding to it
*
* @param tweak some bytes to tweak with
* @param seckey 32-byte seckey
*/
public static byte[] privKeyTweakAdd(byte[] privkey, byte[] tweak) throws AssertFailException{
Preconditions.checkArgument(privkey.length == 32);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < privkey.length + tweak.length) {
byteBuff = ByteBuffer.allocateDirect(privkey.length + tweak.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(privkey);
byteBuff.put(tweak);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_privkey_tweak_add(byteBuff,Secp256k1Context.getContext());
} finally {
r.unlock();
}
byte[] privArr = retByteArray[0];
int privLen = (byte) new BigInteger(new byte[] { retByteArray[1][0] }).intValue() & 0xFF;
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(privArr.length, privLen, "Got bad pubkey length.");
assertEquals(retVal, 1, "Failed return value check.");
return privArr;
}
/**
* libsecp256k1 PubKey Tweak-Add - Tweak pubkey by adding to it
*
* @param tweak some bytes to tweak with
* @param pubkey 32-byte seckey
*/
public static byte[] pubKeyTweakAdd(byte[] pubkey, byte[] tweak) throws AssertFailException{
Preconditions.checkArgument(pubkey.length == 33 || pubkey.length == 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < pubkey.length + tweak.length) {
byteBuff = ByteBuffer.allocateDirect(pubkey.length + tweak.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(pubkey);
byteBuff.put(tweak);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_pubkey_tweak_add(byteBuff,Secp256k1Context.getContext(), pubkey.length);
} finally {
r.unlock();
}
byte[] pubArr = retByteArray[0];
int pubLen = (byte) new BigInteger(new byte[] { retByteArray[1][0] }).intValue() & 0xFF;
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(pubArr.length, pubLen, "Got bad pubkey length.");
assertEquals(retVal, 1, "Failed return value check.");
return pubArr;
}
/**
* libsecp256k1 PubKey Tweak-Mul - Tweak pubkey by multiplying to it
*
* @param tweak some bytes to tweak with
* @param pubkey 32-byte seckey
*/
public static byte[] pubKeyTweakMul(byte[] pubkey, byte[] tweak) throws AssertFailException{
Preconditions.checkArgument(pubkey.length == 33 || pubkey.length == 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < pubkey.length + tweak.length) {
byteBuff = ByteBuffer.allocateDirect(pubkey.length + tweak.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(pubkey);
byteBuff.put(tweak);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_pubkey_tweak_mul(byteBuff,Secp256k1Context.getContext(), pubkey.length);
} finally {
r.unlock();
}
byte[] pubArr = retByteArray[0];
int pubLen = (byte) new BigInteger(new byte[] { retByteArray[1][0] }).intValue() & 0xFF;
int retVal = new BigInteger(new byte[] { retByteArray[1][1] }).intValue();
assertEquals(pubArr.length, pubLen, "Got bad pubkey length.");
assertEquals(retVal, 1, "Failed return value check.");
return pubArr;
}
/**
* libsecp256k1 create ECDH secret - constant time ECDH calculation
*
* @param seckey byte array of secret key used in exponentiaion
* @param pubkey byte array of public key used in exponentiaion
*/
public static byte[] createECDHSecret(byte[] seckey, byte[] pubkey) throws AssertFailException{
Preconditions.checkArgument(seckey.length <= 32 && pubkey.length <= 65);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < 32 + pubkey.length) {
byteBuff = ByteBuffer.allocateDirect(32 + pubkey.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(seckey);
byteBuff.put(pubkey);
byte[][] retByteArray;
r.lock();
try {
retByteArray = secp256k1_ecdh(byteBuff, Secp256k1Context.getContext(), pubkey.length);
} finally {
r.unlock();
}
byte[] resArr = retByteArray[0];
int retVal = new BigInteger(new byte[] { retByteArray[1][0] }).intValue();
assertEquals(resArr.length, 32, "Got bad result length.");
assertEquals(retVal, 1, "Failed return value check.");
return resArr;
}
/**
* libsecp256k1 randomize - updates the context randomization
*
* @param seed 32-byte random seed
*/
public static synchronized boolean randomize(byte[] seed) throws AssertFailException{
Preconditions.checkArgument(seed.length == 32 || seed == null);
ByteBuffer byteBuff = nativeECDSABuffer.get();
if (byteBuff == null || byteBuff.capacity() < seed.length) {
byteBuff = ByteBuffer.allocateDirect(seed.length);
byteBuff.order(ByteOrder.nativeOrder());
nativeECDSABuffer.set(byteBuff);
}
byteBuff.rewind();
byteBuff.put(seed);
w.lock();
try {
return secp256k1_context_randomize(byteBuff, Secp256k1Context.getContext()) == 1;
} finally {
w.unlock();
}
}
private static native long secp256k1_ctx_clone(long context);
private static native int secp256k1_context_randomize(ByteBuffer byteBuff, long context);
private static native byte[][] secp256k1_privkey_tweak_add(ByteBuffer byteBuff, long context);
private static native byte[][] secp256k1_privkey_tweak_mul(ByteBuffer byteBuff, long context);
private static native byte[][] secp256k1_pubkey_tweak_add(ByteBuffer byteBuff, long context, int pubLen);
private static native byte[][] secp256k1_pubkey_tweak_mul(ByteBuffer byteBuff, long context, int pubLen);
private static native void secp256k1_destroy_context(long context);
private static native int secp256k1_ecdsa_verify(ByteBuffer byteBuff, long context, int sigLen, int pubLen);
private static native byte[][] secp256k1_ecdsa_sign(ByteBuffer byteBuff, long context);
private static native int secp256k1_ec_seckey_verify(ByteBuffer byteBuff, long context);
private static native byte[][] secp256k1_ec_pubkey_create(ByteBuffer byteBuff, long context);
private static native byte[][] secp256k1_ec_pubkey_parse(ByteBuffer byteBuff, long context, int inputLen);
private static native byte[][] secp256k1_ecdh(ByteBuffer byteBuff, long context, int inputLen);
}
| [
"[email protected]"
] | |
af712687f88533fa071cb3a10ed0daac922bd118 | d7d74e3f0610f3a26a33c7479a23b8bb6fdbbddc | /src/nhn코테연습/모의고사.java | be27dbffbee28dba4b2868e74e11a85e3706aca6 | [] | no_license | soohyeon13/algorithm | df06537082bb6d9fc4d84ab02d36b03f71be3d04 | d89465b2b9e11da9b57ca6e6824a265414dbe288 | refs/heads/master | 2021-07-01T23:50:40.589802 | 2020-10-28T09:07:42 | 2020-10-28T09:07:42 | 182,878,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 936 | java | package nhn코테연습;
import java.util.ArrayList;
public class 모의고사 {
private static final int[] first = {1, 2, 3, 4, 5};
private static final int[] second = {2, 1, 2, 3, 2, 4, 2, 5};
private static final int[] third = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5};
public int[] solution(int[] answers) {
int[] score = new int[3];
for (int i = 0; i < answers.length; i++) {
if (answers[i] == first[i % 5]) score[0]++;
if (answers[i] == second[i % 8]) score[1]++;
if (answers[i] == third[i % 10]) score[2]++;
}
int maxScore = Math.max(score[0],Math.max(score[1],score[2]));
ArrayList<Integer> answer = new ArrayList<>();
if (maxScore == score[0]) answer.add(1);
if (maxScore == score[1]) answer.add(2);
if (maxScore == score[2]) answer.add(3);
return answer.stream().mapToInt(i -> i.intValue()).toArray();
}
}
| [
"[email protected]"
] | |
fe2442ba74e4c58ebbf1ec381af4b13292c947ac | 0f1b74407b732116121940d80ac7499cc9f27554 | /user/src/main/java/com/whzm/pojo/vo/ResourcesListVo.java | 56d876fd30f6d9ee11079c79b197ce6765190286 | [] | no_license | sogaa556/rate-of-flow | c93f5298361e341fe2c5e93f51b08054580cfa75 | 05f563116b3fb9177d0fd6b199f1c471bf28c162 | refs/heads/master | 2022-12-20T18:47:46.450278 | 2020-08-26T02:38:21 | 2020-08-26T02:38:21 | 290,376,279 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,611 | java | package com.whzm.pojo.vo;
import com.whzm.pojo.Area;
import com.whzm.pojo.Cooperation;
import com.whzm.pojo.Implementation;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @BelongsProject: rate-of-flow
* @BelongsPackage: com.whzm.pojo
* @Author:
* @CreateTime: 2020-08-14 11:45
* @Description: 封装资源大厅列表往前端展示
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ResourcesListVo {
/**
* 资源id
*/
private String id;
/**
* 资源类型;资源的类型(1,流量;2,广告)
*/
private Integer type;
/**
* 资源名称
*/
private String name;
/**
* 资源发布人;关联用户表主键
*/
private String userId;
/**
* 资源状态
*/
private Integer status;
/**
* 资源发布人姓名
*/
private String userName;
/**
* 资源流量落地类型;关联流量落地类型主键
*/
private List<Implementation> implementations;
/**
* 资源流量所在区域;关联广告流量区域主键
*/
private List<Area> areas;
/**
* 资源流量合作方式;关联流量合作方式
*/
private List<Cooperation> cooperations;
/**
* 资源流量平台
*/
private String company;
/**
* 资源发布时间;首次自动创建
*/
private String createTime;
/**
* 购买指定服务时间
*/
private String vcreateTime;
/**
* 存活时间
*/
private String aliveTime;
}
| [
"[email protected]"
] | |
56f5778fd60a510785b77dd45e83161cf9000947 | ce44e9fec5f4ee3eff79c3e6fbb0064fbb94753d | /main/ip/generate/boofcv/alg/interpolate/impl/GenerateImplBilinearPixel.java | 77884c7eba5965b7a2486ddae844ffb30e5e8b12 | [
"Apache-2.0"
] | permissive | wsjhnsn/BoofCV | 74fc0687e29c45df1d2fc125b28d777cd91a8158 | bdae47003090c03386b6b23e2a884bceba242241 | refs/heads/master | 2020-12-24T12:34:02.996379 | 2014-06-27T21:15:21 | 2014-06-27T21:15:21 | 21,334,100 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,012 | java | /*
* Copyright (c) 2011-2014, Peter Abeles. All Rights Reserved.
*
* This file is part of BoofCV (http://boofcv.org).
*
* 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 boofcv.alg.interpolate.impl;
import boofcv.misc.AutoTypeImage;
import boofcv.misc.CodeGeneratorBase;
import java.io.FileNotFoundException;
/**
* @author Peter Abeles
*/
public class GenerateImplBilinearPixel extends CodeGeneratorBase {
AutoTypeImage image;
String floatType;
String f;
@Override
public void generate() throws FileNotFoundException {
createType(AutoTypeImage.F64);
createType(AutoTypeImage.F32);
createType(AutoTypeImage.U8);
createType(AutoTypeImage.S16);
createType(AutoTypeImage.S32);
}
private void createType( AutoTypeImage type ) throws FileNotFoundException {
className = "ImplBilinearPixel_"+type.name();
image = type;
createFile();
}
private void createFile() throws FileNotFoundException {
floatType = !image.isInteger() && image.getNumBits()==64 ? "double" : "float";
f = !image.isInteger() && image.getNumBits()==64 ? "" : "f";
printPreamble();
printTheRest();
out.println("}");
}
private void printPreamble() throws FileNotFoundException {
setOutputFile(className);
out.print("import boofcv.alg.interpolate.BilinearPixel;\n" +
"import boofcv.struct.image.ImageType;\n" +
"import boofcv.struct.image."+image.getSingleBandName()+";\n");
out.println();
out.println();
out.print("/**\n" +
" * <p>\n" +
" * Implementation of {@link BilinearPixel} for a specific image type.\n" +
" * </p>\n" +
" *\n" +
" * <p>\n" +
" * NOTE: This code was automatically generated using {@link GenerateImplBilinearPixel}.\n" +
" * </p>\n" +
" *\n" +
" * @author Peter Abeles\n" +
" */\n" +
"public class "+className+" extends BilinearPixel<"+image.getSingleBandName()+"> {\n" +
"\n" +
"\tpublic "+className+"() {\n" +
"\t}\n" +
"\n" +
"\tpublic "+className+"("+image.getSingleBandName()+" orig) {\n" +
"\t\tsetImage(orig);\n" +
"\t}\n");
}
private void printTheRest() {
String bitWise = image.getBitWise();
out.print("\t@Override\n" +
"\tpublic float get_fast(float x, float y) {\n" +
"\t\tint xt = (int) x;\n" +
"\t\tint yt = (int) y;\n" +
"\t\t"+floatType+" ax = x - xt;\n" +
"\t\t"+floatType+" ay = y - yt;\n" +
"\n" +
"\t\tint index = orig.startIndex + yt * stride + xt;\n" +
"\n" +
"\t\t"+image.getDataType()+"[] data = orig.data;\n" +
"\n" +
"\t\t"+floatType+" val = (1.0"+f+" - ax) * (1.0"+f+" - ay) * (data[index] "+bitWise+"); // (x,y)\n" +
"\t\tval += ax * (1.0"+f+" - ay) * (data[index + 1] "+bitWise+"); // (x+1,y)\n" +
"\t\tval += ax * ay * (data[index + 1 + stride] "+bitWise+"); // (x+1,y+1)\n" +
"\t\tval += (1.0"+f+" - ax) * ay * (data[index + stride] "+bitWise+"); // (x,y+1)\n" +
"\n" +
"\t\treturn val;\n" +
"\t}\n" +
"\n" +
"\t@Override\n" +
"\tpublic float get(float x, float y) {\n" +
"\t\tif (x < 0 || y < 0 || x > width-1 || y > height-1)\n" +
"\t\t\tthrow new IllegalArgumentException(\"Point is outside of the image \"+x+\" \"+y);\n" +
"\n" +
"\t\tint xt = (int) x;\n" +
"\t\tint yt = (int) y;\n" +
"\n" +
"\t\t"+floatType+" ax = x - xt;\n" +
"\t\t"+floatType+" ay = y - yt;\n" +
"\n" +
"\t\tint index = orig.startIndex + yt * stride + xt;\n" +
"\n" +
"\t\t// allows borders to be interpolated gracefully by double counting appropriate pixels\n" +
"\t\tint dx = xt == width - 1 ? 0 : 1;\n" +
"\t\tint dy = yt == height - 1 ? 0 : stride;\n" +
"\n" +
"\t\t"+image.getDataType()+"[] data = orig.data;\n" +
"\n" +
"\t\t"+floatType+" val = (1.0"+f+" - ax) * (1.0"+f+" - ay) * (data[index] "+bitWise+"); // (x,y)\n" +
"\t\tval += ax * (1.0"+f+" - ay) * (data[index + dx] "+bitWise+"); // (x+1,y)\n" +
"\t\tval += ax * ay * (data[index + dx + dy] "+bitWise+"); // (x+1,y+1)\n" +
"\t\tval += (1.0"+f+" - ax) * ay * (data[index + dy] "+bitWise+"); // (x,y+1)\n" +
"\n" +
"\t\treturn val;\n" +
"\t}\n"+
"\n" +
"\t@Override\n" +
"\tpublic ImageType<"+image.getSingleBandName()+"> getImageType() {\n" +
"\t\treturn ImageType.single("+image.getSingleBandName()+".class);\n" +
"\t}\n\n");
}
public static void main( String args[] ) throws FileNotFoundException {
GenerateImplBilinearPixel gen = new GenerateImplBilinearPixel();
gen.generate();
}
}
| [
"[email protected]"
] | |
a87e91a63409b97904e54b7e4911eadb37a51023 | 27621c86c0aa64dc15f9f69d29da0dd0f4f36cda | /mq-action02/src/test/java/com/mq/mqaction/MqActionApplicationTests.java | 76b72a94a7e2bc88a517bc7a0ec5068452c741a1 | [] | no_license | hongjieWang/SpringBootRabbitMq | 719bdddb83e9ca20425e7131dde1e761c3e3544b | 88bcca1cfc2dcbf75c439c4e373e6d8f70028955 | refs/heads/main | 2023-08-22T16:47:25.253145 | 2021-10-07T09:30:16 | 2021-10-07T09:30:16 | 414,455,989 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 209 | java | package com.mq.mqaction;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class MqActionApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
d148d9c958ee44dd82921afa708851f904682b1c | b1caa2d229f271726b44d95b5f9d5eda47c4b8c4 | /javaSenior/Java常用类/src/枚举类/enumSeason.java | bdc4a7c5165668a293aa0b6925942ce5846eea07 | [] | no_license | Lijinfu1332/JAVASeniors | 20be81f203bd0a8165055c363a854d5e56e6a0ff | a4ae7d6096f1a4a6d35ac46a91cda40213efbefd | refs/heads/master | 2023-02-19T09:48:13.614050 | 2021-01-21T10:42:01 | 2021-01-21T10:42:01 | 331,595,260 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,727 | java | package 枚举类;
import javax.swing.plaf.nimbus.State;
public class enumSeason {
public static void main(String[] args) {
Season1 summer=Season1.SUMMER;
System.out.println(summer);
//获取常量名
Season1[] season1=Season1.values();
for (int i = 0; i < season1.length; i++) {
System.out.println(season1[i]);
season1[i].show();
}
//enum自带的
//获取类中的ObjectName
//类名找不到时会抛出异常
Season1 season11=Season1.valueOf("SPRING1");
System.out.println(season11);
}
}
interface Info{
void show();
}
enum Season1 implements Info{
SPRING("春天","春暖花开"){
@Override
public void show() {
System.out.println("春天在哪里");
}
},
SUMMER("夏天","夏日凉凉"){
@Override
public void show() {
System.out.println("夏天夏天悄悄地过去");
}
},
AUTOMN("秋天","秋高气爽"){
@Override
public void show() {
System.out.println("秋天不回来");
}
},
WINTER("冬天","冰天雪地"){
@Override
public void show() {
System.out.println("大约在冬季");
}
}
;
private String name;
private String DCRB;
Season1(String name, String DCRB){
this.name=name;
this.DCRB=DCRB;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDCRB() {
return DCRB;
}
public void setDCRB(String DCRB) {
this.DCRB = DCRB;
}
}
| [
"[email protected]"
] |
Subsets and Splits