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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c2e8f31e69b29f67e2bfd46c2411f978f61b7df2 | 573b9c497f644aeefd5c05def17315f497bd9536 | /src/main/java/com/alipay/api/response/AlipayOfflineProviderEquipmentAuthRemoveResponse.java | 48fd1e612838099fe361c093ecc4f233e3151490 | [
"Apache-2.0"
] | permissive | zzzyw-work/alipay-sdk-java-all | 44d72874f95cd70ca42083b927a31a277694b672 | 294cc314cd40f5446a0f7f10acbb5e9740c9cce4 | refs/heads/master | 2022-04-15T21:17:33.204840 | 2020-04-14T12:17:20 | 2020-04-14T12:17:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 933 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.offline.provider.equipment.auth.remove response.
*
* @author auto create
* @since 1.0, 2019-01-07 20:51:15
*/
public class AlipayOfflineProviderEquipmentAuthRemoveResponse extends AlipayResponse {
private static final long serialVersionUID = 4253334365277128614L;
/**
* 被解绑的机具编号
*/
@ApiField("device_id")
private String deviceId;
/**
* 机具厂商PID
*/
@ApiField("merchant_pid")
private String merchantPid;
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getDeviceId( ) {
return this.deviceId;
}
public void setMerchantPid(String merchantPid) {
this.merchantPid = merchantPid;
}
public String getMerchantPid( ) {
return this.merchantPid;
}
}
| [
"[email protected]"
] | |
fdade604b12e4d8982a19e9dd7167a2d21ffe820 | 369270a14e669687b5b506b35895ef385dad11ab | /jdk.internal.vm.compiler/org.graalvm.compiler.jtt/src/org/graalvm/compiler/jtt/optimize/SignExtendShort.java | 8a3a4fc87a49c6bdf55c54e19b2df9e1fc9825ff | [] | no_license | zcc888/Java9Source | 39254262bd6751203c2002d9fc020da533f78731 | 7776908d8053678b0b987101a50d68995c65b431 | refs/heads/master | 2021-09-10T05:49:56.469417 | 2018-03-20T06:26:03 | 2018-03-20T06:26:03 | 125,970,208 | 3 | 3 | null | null | null | null | UTF-8 | Java | false | false | 1,078 | java | /*
* Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package org.graalvm.compiler.jtt.optimize;
import org.junit.Test;
import org.graalvm.compiler.jtt.JTTTest;
/*
*/
public class SignExtendShort extends JTTTest {
public static int val;
public static boolean test(short[] b) {
val = b[2];
int x = 0;
return val >= x;
}
@Test
public void run0() throws Throwable {
runTest("test", new short[]{0, 0, 0});
}
@Test
public void run1() throws Throwable {
runTest("test", new short[]{0, 0, 1});
}
@Test
public void run2() throws Throwable {
runTest("test", new short[]{0, 0, -1});
}
@Test
public void run3() throws Throwable {
runTest("test", new short[]{0, 0, Short.MAX_VALUE});
}
@Test
public void run4() throws Throwable {
runTest("test", new short[]{0, 0, Short.MIN_VALUE});
}
}
| [
"[email protected]"
] | |
cd1feb4cab7f02e401a2a84299316f7768917e8f | 320b7e4ab10a1f7cf58147a6e8a0951ba4b3dcd0 | /comehome-socket/src/main/java/com/ac/comehome/config/WebSocketConfig.java | aab6439b6422508d1511f69696af01ae91251b51 | [] | no_license | ErfengV/comehome | f769c8a895d6218c523e8dbfc0885e6ae9c67a09 | dc3e6e6488b0d13d5ceac7cd2b1cc9c5fdb7f564 | refs/heads/main | 2023-08-27T18:17:29.096164 | 2021-10-26T05:24:26 | 2021-10-26T05:24:26 | 367,632,032 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 461 | java | package com.ak.chess.dao;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* 配置类
* 功能:开启WebSocket支持
* */
@Configuration
public class WebSocketConfig {
@Bean
public ServerEndpointExporter serverEndpointExporter() {
return new ServerEndpointExporter();
}
} | [
"[email protected]"
] | |
7b92f7ffaf54a87e0f7ed68bcc2e668ba9c04884 | dd76d0b680549acb07278b2ecd387cb05ec84d64 | /divestory-Fernflower/com/google/android/gms/internal/drive/zzbf.java | dbef5c4988df4406e5e02a12d846db461b19af01 | [] | no_license | ryangardner/excursion-decompiling | 43c99a799ce75a417e636da85bddd5d1d9a9109c | 4b6d11d6f118cdab31328c877c268f3d56b95c58 | refs/heads/master | 2023-07-02T13:32:30.872241 | 2021-08-09T19:33:37 | 2021-08-09T19:33:37 | 299,657,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 840 | java | package com.google.android.gms.internal.drive;
import android.content.IntentSender;
import android.os.RemoteException;
import com.google.android.gms.common.api.Api;
import com.google.android.gms.common.api.internal.TaskApiCall;
import com.google.android.gms.drive.OpenFileActivityOptions;
import com.google.android.gms.tasks.TaskCompletionSource;
final class zzbf extends TaskApiCall<zzaw, IntentSender> {
// $FF: synthetic field
private final OpenFileActivityOptions zzeq;
zzbf(zzbb var1, OpenFileActivityOptions var2) {
this.zzeq = var2;
}
// $FF: synthetic method
protected final void doExecute(Api.AnyClient var1, TaskCompletionSource var2) throws RemoteException {
var2.setResult(((zzeo)((zzaw)var1).getService()).zza(new zzgm(this.zzeq.zzba, this.zzeq.zzbb, this.zzeq.zzbd, this.zzeq.zzbe)));
}
}
| [
"[email protected]"
] | |
2b26749f0c075ffc7eb49c60574d6eead2040fab | 6b8b39cb613f1382ddfcba13965614cdbad2ba66 | /src/test/java/com/example/aruna/MovieRatingsServiceNewApplicationTests.java | 210c4e28ce50806a976c6e4aa5eda28b4e57c5db | [] | no_license | arunasilva86/movie-ratings-service-new | 8862e568fd93220fffc1b6e731c682d695b9d342 | e7677b32f5fca87342f4d1067b29dac9cc45a524 | refs/heads/master | 2020-08-01T02:02:51.730734 | 2019-09-25T10:52:52 | 2019-09-25T10:53:04 | 210,821,632 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 350 | java | package com.example.aruna;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MovieRatingsServiceNewApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
a8f191f20d3271cea236bb0228e26f84bd11532a | 9a8a1303f0bd99080097c637b8e6ca5e3eb9c70f | /src/main/java/com/hq/secondhand_book/entity/PlaceTransaction.java | 8c1c29a62892ba0b24cbfd851fbb863e4053e33f | [] | no_license | zifan612301/study | 65f1cee6237fe22a1db88e653558a1699d2a82e0 | 36a82c3e547bd376d6283468e4220d4997a5ab95 | refs/heads/master | 2023-05-22T08:56:41.968348 | 2021-06-05T09:54:24 | 2021-06-05T09:54:24 | 308,547,712 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 911 | java | package com.hq.secondhand_book.entity;
import lombok.Data;
import javax.persistence.*;
import java.util.Date;
/**
* @auther 黄琦
* @create 2019 04 02
*/
@Entity
@Data
@Table( name = "place_transaction")
public class PlaceTransaction {
@Id
@GeneratedValue( strategy = GenerationType.IDENTITY)
private Integer id; //交易地点编号
@Column(name = "place_name")
private String placeName; //交易地点名称
@Column(name = "place_father_id")
private Integer placeFatherId; //交易地点父类编号
@Column(name = "place_level")
private Integer placeLevel; //地点级别
@Column(name = "is_usable")
private Integer usable; //是否可用:0-否 1-是
@Column(name = "cst_create")
private Date cstCreate; //数据的创建时间
@Column(name = "cst_modify")
private Date cstModify; //数据的修改时间
}
| [
"[email protected]"
] | |
961cd8fa355a62ef1ae328cb0cdb3b34d6fceab5 | bbffb2bdacdf1de236ffb4c799a49ab97beda31e | /src/main/java/br/com/service/exception/ErroAutenticacaoException.java | 4f10c6ca37e9a62e86986e9846cf4957ed300eef | [] | no_license | JhonisAnjos/minhas-financas-backend | 9d8bb37ee7ed26a8101497624a6817ff9951100b | 7e7f0c0a649f570b841c50f4e96445e1daa3f5d1 | refs/heads/main | 2023-01-24T21:12:21.551948 | 2020-11-26T13:44:31 | 2020-11-26T13:44:31 | 315,403,484 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 180 | java | package br.com.service.exception;
public class ErroAutenticacaoException extends RuntimeException {
public ErroAutenticacaoException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
a954f352653e105e00afb8bc71a3b21c34124442 | 9739485a54700d5efb38b38af9db010ae49617ed | /C_Arrays/src/eindimensional/Niederschlagsmengen.java | 2e75c56edfd2bffb56119bda24ba6d097840dfee | [] | no_license | sly1018/Java-Aufbau | c52fe61fb6262682b9014f71e556f18a7abcec3b | 971355d6750f2e812f36e121b1016fa7cf26848e | refs/heads/master | 2023-04-30T07:55:31.652668 | 2021-05-28T14:31:19 | 2021-05-28T14:31:19 | 354,025,782 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,407 | java | package eindimensional;
import java.util.Arrays;
import java.util.Random;
public class Niederschlagsmengen {
public static void main(String[] args) {
// Niederschlagswerte in ein Array pro Monat
double[] werte = new double[12];
Random random = new Random();
// int tmp = random.nextInt(45); // liefer Werte zwischen 0 und 45
// an jedem Index einen Wert setzen
for (int i = 0; i < werte.length; i++) {
// Zufallswert holen
double wert = random.nextDouble() * 100;
// und im Array eintragen
werte[i] = wert;
}
// alle Werte anzeigen
for (double wert : werte) {
System.out.printf("%.1f", wert);
}
System.out.println();
// Monat mit dem wenigsten Niederschlag suchen
int iMin = 0;
// Wenn der neue aktuelle Wert kleiner ist -> neues Minumun merken
for (int i = 0; i < werte.length; i++) {
if (werte[i] < werte[iMin]) {
iMin = i;
if (werte[i] == 0) {
break;
}
}
}
System.out.printf("Das Minimum war im Monat %d mit %.1f mm\n", iMin + 1, werte[iMin]);
String[] monatsNamen = { "Jänner", "Februar", "März", "April", "Juni", "Juli", "August", "September", "Oktober",
"November", "Dezember" };
System.out.printf("Das Minimum war im %s mit %.1f mm\n", monatsNamen[iMin], werte[iMin]);
// Hilfsklasse für Arrays
// das Array sortieren
Arrays.sort(werte);
System.out.println(Arrays.toString(werte));
}
}
| [
"[email protected]"
] | |
524d982d58778c1eb18e0cd6b524f25410d0be8c | d148a22ba57c797ef78b4ae72ae7ae6ef1c8e1f4 | /EcoMottoHouse-Web/src/main/java/org/apache/EcoMotto/web/component/IPersonService.java | a8b45ba7b85feba9f78d3866d3af6e75714c339c | [] | no_license | mrchenjunjie/EcoMottoHouse-Web | 8b6c2ea61591ae938f467cd59d41f7b7db28e529 | 8d083c1eaa432472857da7c45ec1f267075e5172 | refs/heads/master | 2021-01-23T12:33:37.856060 | 2015-06-01T05:16:31 | 2015-06-01T05:16:31 | 34,977,336 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 114 | java | package org.apache.EcoMotto.web.component;
public interface IPersonService {
public String getPersonName();
}
| [
"[email protected]"
] | |
978b4f885a0942a3cee3871d947db6918cf9fc30 | 78a5af6d7778847e93385d1e00ad8f773f1d0fba | /SystemsForDesignAndImplementation/SDIProjectModular/web/src/main/java/web/controller/ClientWebController.java | 053295e17bf48960ab3485f5f594b989c472d2e4 | [] | no_license | vladvlad23/UBBComputerScienceBachelor | 099596a139c8aa5460c705b6d51fb86608015687 | d99a26dbcd9b629f5b3f38ff814cab42837365ed | refs/heads/master | 2023-05-08T23:49:32.737144 | 2021-05-27T19:06:56 | 2021-05-27T19:06:56 | 280,646,572 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,476 | java | package web.controller;
import core.controller.interfaces.ClientServiceInterface;
import core.exceptions.ControllerException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import web.converter.ClientConverter;
import web.dto.ClientDto;
import java.util.ArrayList;
import java.util.List;
@RestController
public class ClientWebController {
public static final Logger log= LoggerFactory.getLogger(ClientWebController.class);
@Autowired
private ClientServiceInterface clientService;
@Autowired
private ClientConverter clientConverter;
@RequestMapping(value = "/clients", method = RequestMethod.GET)
List<ClientDto> getClients() {
log.trace("getClients: method entered");
log.trace("getClients: method exit");
return new ArrayList<>(clientConverter
.convertModelsToDtos(clientService.getAll()));
}
@RequestMapping(value = "/clients", method = RequestMethod.POST)
ClientDto saveClient(@RequestBody ClientDto clientDto) throws ControllerException {
log.trace("saveClient: method entered: clientDto = {}",clientDto);
ClientDto returnValue = clientConverter.convertModelToDto(
clientService.add(clientConverter.convertDtoToModel(clientDto)));
log.trace("saveClient: method exit: returnValue={}",returnValue);
return returnValue;
}
@RequestMapping(value = "/clients/{id}", method = RequestMethod.PUT)
ClientDto updateClient(@PathVariable Long id,
@RequestBody ClientDto clientDto) {
log.trace("updateClient: method entered: clientDto={}",clientDto);
ClientDto returnValue = clientConverter.convertModelToDto(
clientService.update(clientConverter.convertDtoToModel(clientDto)));
log.trace("updateClient: method exit: returnValue={}",returnValue);
return returnValue;
}
@RequestMapping(value = "/clients/{id}", method = RequestMethod.DELETE)
ResponseEntity<?> deleteClient(@PathVariable Long id) throws ControllerException {
log.trace("deleteClient: entered method: id={}",id);
clientService.remove(id);
log.trace("deleteClient: exit method");
return new ResponseEntity<>(HttpStatus.OK);
}
}
| [
"[email protected]"
] | |
938e0df47fe6bc2cee28e165be57269642f34f23 | 0454f1ca2465b7c87595478f91b573480aa79736 | /AdvanceJava/21 JSP Basics/JSP Action Elements/javabean/Test.java | a076e12847c1b476e9f40a6f2c84b02507176928 | [] | no_license | maheshp1987/JAVA-Programming | 273dabeb51454be8ebf0c17e99efc3c71952a1c4 | 41349b28882ddc79dbc6ef544b016659bd1082f7 | refs/heads/master | 2021-01-17T17:51:05.529257 | 2018-03-26T04:42:29 | 2018-03-26T04:42:29 | 60,851,554 | 4 | 4 | null | null | null | null | UTF-8 | Java | false | false | 236 | java | package com.javabean;
public class Test{
public static void main(String args[]){
Employee e=new Employee();//object is created
e.setName("OM");//setting value to the object
System.out.println(e.getName());
}} | [
"[email protected]"
] | |
de5c1f139cd08fb50332dbbbc8ed3413da8aac51 | 042fc648173712141566349ccd9be2cfdff3d628 | /app/src/main/java/com/ky/kyandroid/adapter/EventEntityListAdapter.java | 84458d173fda30f20751285592e0828889b75e60 | [] | no_license | kyAndroid/KyAndroid-1 | 00a6f4dd8603528b2d507b51c9e3e744f8a8b1b6 | 19a5178e0558112c4b1fea8a26e02b555358057b | refs/heads/master | 2021-01-21T14:53:20.741496 | 2017-06-25T09:49:23 | 2017-06-25T09:49:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,513 | java | package com.ky.kyandroid.adapter;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.ky.kyandroid.R;
import com.ky.kyandroid.entity.TFtSjEntity;
import java.util.ArrayList;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
public class EventEntityListAdapter extends BaseAdapter {
public List<TFtSjEntity> list;
public Context context;
public EventEntityListAdapter(Context context) {
super();
list = new ArrayList<TFtSjEntity>();
this.context = context;
}
public EventEntityListAdapter(List<TFtSjEntity> list, Context context) {
super();
this.list = list;
this.context = context;
}
@Override
public int getCount() {
return list.size();
}
@Override
public Object getItem(int position) {
return list.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
if (convertView == null) {
convertView = View.inflate(context, R.layout.activity_evententry_item, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);// 绑定ViewHolder对象
} else {
holder = (ViewHolder) convertView.getTag();// 取出ViewHolder对象
}
holder.thingName.setText(list.get(position).getSjmc());
holder.thingAddress.setText(list.get(position).getFsdd());
holder.thingTime.setText(list.get(position).getFssj());
if("1".equals(list.get(position).getZt())){
holder.thingStatus.setText("未上报");
}else{
holder.thingStatus.setText(list.get(position).getZtname());
}
return convertView;
}
/**
* 存放控件
*/
class ViewHolder {
@BindView(R.id.thing_name)
TextView thingName;
@BindView(R.id.thing_status)
TextView thingStatus;
@BindView(R.id.thing_address)
TextView thingAddress;
@BindView(R.id.thing_time)
TextView thingTime;
ViewHolder(View view) {
ButterKnife.bind(this, view);
}
}
public void notifyDataSetChanged(List<TFtSjEntity> list) {
this.list = list;
super.notifyDataSetChanged();
}
}
| [
"[email protected]"
] | |
1436eeec5505bc74d6667eb9adef558cd8366f5f | 8d0cd47ed68bee4f5de3819e4404dcd85866b174 | /app/src/main/java/com/example/jatin/AddressLocator/MainActivity.java | 426764fe5a58074ee3d77601f812d891f4426b5a | [] | no_license | jatingupta896/Addresslocator | 40643cbf702635469b95685ef992aa9812cbfc40 | 862bdf3bac076e0acf2258c6092b79d68f3541a1 | refs/heads/master | 2020-07-23T18:47:58.562234 | 2017-06-14T17:37:15 | 2017-06-14T17:37:15 | 94,357,047 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,346 | java | package com.example.jatin.AddressLocator;
import android.app.ProgressDialog;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class MainActivity extends AppCompatActivity {
private EditText room;
private EditText locality;
private EditText zipCode;
private EditText city;
private EditText state;
private EditText country;
private ProgressDialog progressDialog;
private DatabaseReference databaseReference;
private Button submitButton;
private String location;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
progressDialog = new ProgressDialog(this);
databaseReference = FirebaseDatabase.getInstance().getReference().child("Address");
submitButton = (Button) findViewById(R.id.submit);
room = (EditText) findViewById(R.id.room_no);
locality = (EditText) findViewById(R.id.locality);
city = (EditText) findViewById(R.id.city);
state = (EditText) findViewById(R.id.state);
country = (EditText) findViewById(R.id.country);
zipCode = (EditText) findViewById(R.id.pincode);
SharedPreferences sharedPreferences=getSharedPreferences("DemoFile",0);
String sr=sharedPreferences.getString("STATUS1",null);
room.setText(sr);
String sl=sharedPreferences.getString("STATUS2",null);
locality.setText(sl);
String sc=sharedPreferences.getString("STATUS3",null);
city.setText(sc);
String ss=sharedPreferences.getString("STATUS4",null);
state.setText(ss);
String sco=sharedPreferences.getString("STATUS5",null);
country.setText(sco);
String sz=sharedPreferences.getString("STATUS6",null);
zipCode.setText(sz);
submitButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
progressDialog.setMessage("Loading...");
progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
if(room.length()>6 || locality.length()>20 || zipCode.length()!=6 )
{
Toast.makeText(MainActivity.this,"Room No field is having more than 6 character or Locality field is having more than 20 character or Zipcode is not correct ", Toast.LENGTH_SHORT).show();
}
else
{
String Room = room.getText().toString().trim();
String Locality=locality.getText().toString().trim();
String City = city.getText().toString().trim();
String State = state.getText().toString().trim();
String Country = country.getText().toString().trim();
String Zipcode = zipCode.getText().toString().trim();
if(!TextUtils.isEmpty(Room)&&!TextUtils.isEmpty(Locality)&&!TextUtils.isEmpty(City)&&!TextUtils.isEmpty(State)&&!TextUtils.isEmpty(Country)&&!TextUtils.isEmpty(Zipcode))
{
progressDialog.show();
DatabaseReference post=databaseReference.push();
post.child("RoomNo").setValue(Room);
post.child("Locality").setValue(Locality);
post.child("City").setValue(City);
post.child("State").setValue(State);
post.child("Country").setValue(Country);
post.child("Zipcode").setValue(Zipcode);
progressDialog.dismiss();
// room.setText(null);
// locality.setText(null);
// country.setText(null);
// city.setText(null);
// state.setText(null);
// zipCode.setText(null);
location= Room+", "+Locality+", "+City+", "+State+", "+Country+", "+ Zipcode;
Intent intent= new Intent(MainActivity.this,MapsActivity.class);
intent.putExtra("Location", location);
startActivityForResult(intent,7777);
}
}
}
});
}
@Override
protected void onStop()
{
super.onStop();
SharedPreferences sharedPreferences=getSharedPreferences("DemoFile",0);
SharedPreferences.Editor editor=sharedPreferences.edit();
editor.putString("STATUS1",room.getText().toString());
editor.putString("STATUS2",locality.getText().toString());
editor.putString("STATUS3",city.getText().toString());
editor.putString("STATUS4",state.getText().toString());
editor.putString("STATUS5",country.getText().toString());
editor.putString("STATUS6",zipCode.getText().toString());
editor.commit();
}
}
| [
"[email protected]"
] | |
79a8d2ffa5e53a69e2e510b287fac2851f49e865 | cd686241381e0babae7b440b9564d191c80c1c39 | /app/src/main/java/com/example/wellington/lolguide/model/spell/SummonerSpellDto.java | eb4f3a6ca50e7abbc4d290affa6917bfc4f040ea | [] | no_license | wellyogui/LolGuide | 39e0667ae8d1e68a5c0ef8d3a9e7ef0b4ba02e22 | a0238011d7e6e19c58b353f63653ec87ba45c052 | refs/heads/master | 2021-01-13T02:48:31.890627 | 2017-05-17T14:15:10 | 2017-05-17T14:15:10 | 77,160,039 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,863 | java |
package com.example.wellington.lolguide.model.spell;
import java.util.List;
import com.example.wellington.lolguide.model.Image;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class SummonerSpellDto {
@SerializedName("name")
@Expose
public String name;
@SerializedName("description")
@Expose
public String description;
@SerializedName("sanitizedDescription")
@Expose
public String sanitizedDescription;
@SerializedName("tooltip")
@Expose
public String tooltip;
@SerializedName("sanitizedTooltip")
@Expose
public String sanitizedTooltip;
@SerializedName("image")
@Expose
public Image image;
@SerializedName("resource")
@Expose
public String resource;
@SerializedName("maxrank")
@Expose
public Integer maxrank;
@SerializedName("cost")
@Expose
public List<Integer> cost = null;
@SerializedName("costType")
@Expose
public String costType;
@SerializedName("costBurn")
@Expose
public String costBurn;
@SerializedName("cooldown")
@Expose
public List<Integer> cooldown = null;
@SerializedName("cooldownBurn")
@Expose
public String cooldownBurn;
@SerializedName("effect")
@Expose
public List<Object> effect = null;
@SerializedName("effectBurn")
@Expose
public List<String> effectBurn = null;
@SerializedName("range")
@Expose
public List<Integer> range = null;
@SerializedName("rangeBurn")
@Expose
public String rangeBurn;
@SerializedName("summonerLevel")
@Expose
public Integer summonerLevel;
@SerializedName("id")
@Expose
public Integer id;
@SerializedName("key")
@Expose
public String key;
@SerializedName("modes")
@Expose
public List<String> modes = null;
}
| [
"[email protected]"
] | |
e5143c587ffbda9ccaaf51bdcaf3056ce9fbc6f8 | 5648d74f6243e63e45a8888043b0d017bf49dd50 | /02NQueens/QueenBoard.java | 537b46b77770ea557d12a571624e7e9af51b5674 | [] | no_license | AntonDanylenko/MKS22X | a1eb7a36d2ef79e43dd378a84c1b675f8a1d083d | bfae3c84a343079dcfd1e39b23d55159b8252b50 | refs/heads/master | 2018-09-02T16:10:47.834472 | 2018-06-17T21:17:47 | 2018-06-17T21:17:47 | 120,021,393 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,744 | java | public class QueenBoard{
private int[][] board;
public QueenBoard(int size){
board = new int[size][size];
}
private boolean addQueen(int r, int c){
if (board[r][c]!=0){
return false;
}
for (int n=0; n<board.length; n++){
board[r][n]+=1;
}
for (int p=0; p<board.length; p++){
board[p][c]+=1;
}
for (int q=0; q<board.length; q++){
try{
board[r+q][c+q]+=1;
}
catch(ArrayIndexOutOfBoundsException e){
}
}
for (int s=0; s<board.length; s++){
try{
board[r-s][c+s]+=1;
}
catch(ArrayIndexOutOfBoundsException e){
}
}
board[r][c] = -1;
return true;
}
private boolean removeQueen(int r, int c){
if (board[r][c]!=-1){
return false;
}
for (int n=0; n<board.length; n++){
board[r][n]-=1;
}
for (int p=0; p<board.length; p++){
board[p][c]-=1;
}
for (int q=0; q<board.length; q++){
try{
board[r+q][c+q]-=1;
}
catch(ArrayIndexOutOfBoundsException e){
}
}
for (int s=0; s<board.length; s++){
try{
board[r-s][c+s]-=1;
}
catch(ArrayIndexOutOfBoundsException e){
}
}
board[r][c] = 0;
return true;
}
public String toString(){
String result = "";
for (int n=0; n<board.length; n++){
for (int r=0; r<board.length; r++){
if (board[r][n]!=-1){
result = result + "_ ";
}
else{
result = result + "Q ";
}
}
result += "\n";
}
return result;
}
public boolean solve(){
for (int n=0; n<board.length; n++){
for (int r=0; r<board.length; r++){
if(board[n][r]!=0){
throw new IllegalStateException();
}
}
}
return solveHelp(0);
}
private boolean solveHelp(int col){
if (col == board.length){
return true;
}
for (int n=0; n<board.length; n++){
if(addQueen(n, col)){
if (solveHelp(col+1)){
return true;
}
removeQueen(n, col);
}
}
return false;
}
public int countSolutions(){
for (int n=0; n<board.length; n++){
for (int r=0; r<board.length; r++){
if(board[n][r]!=0){
throw new IllegalStateException();
}
}
}
return countHelp(0, 0);
}
private int countHelp(int col, int sum){
if (col == board.length){
return 1;
}
for (int n=0; n<board.length; n++){
if(addQueen(n, col)){
int num = countHelp(col+1, 0);
if (num>0){
sum+=num;
}
removeQueen(n, col);
}
}
return sum;
}
/*public static void main(String[]args){
QueenBoard newBoard = new QueenBoard(4);
System.out.println(newBoard.solve());
System.out.println(newBoard);
}*/
}
| [
"[email protected]"
] | |
db052c1b8aa9e64f989bda1492ae41146553f5d1 | 15b260ccada93e20bb696ae19b14ec62e78ed023 | /v2/src/main/java/com/alipay/api/response/AlipayDigitalmgmtAppAppreportQueryResponse.java | ac4f17d1913a16c384bd73a37fddff6112779a5f | [
"Apache-2.0"
] | permissive | alipay/alipay-sdk-java-all | df461d00ead2be06d834c37ab1befa110736b5ab | 8cd1750da98ce62dbc931ed437f6101684fbb66a | refs/heads/master | 2023-08-27T03:59:06.566567 | 2023-08-22T14:54:57 | 2023-08-22T14:54:57 | 132,569,986 | 470 | 207 | Apache-2.0 | 2022-12-25T07:37:40 | 2018-05-08T07:19:22 | Java | UTF-8 | Java | false | false | 888 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.domain.ApmobileAppDetectResultDTO;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: alipay.digitalmgmt.app.appreport.query response.
*
* @author auto create
* @since 1.0, 2023-08-11 17:51:40
*/
public class AlipayDigitalmgmtAppAppreportQueryResponse extends AlipayResponse {
private static final long serialVersionUID = 3311649585663478897L;
/**
* 检测结果
*/
@ApiField("apmobile_app_detect_result_dto")
private ApmobileAppDetectResultDTO apmobileAppDetectResultDto;
public void setApmobileAppDetectResultDto(ApmobileAppDetectResultDTO apmobileAppDetectResultDto) {
this.apmobileAppDetectResultDto = apmobileAppDetectResultDto;
}
public ApmobileAppDetectResultDTO getApmobileAppDetectResultDto( ) {
return this.apmobileAppDetectResultDto;
}
}
| [
"auto-publish"
] | auto-publish |
4d91409262c2f45a66cf991eb2dabf36db188510 | 1f19aec2ecfd756934898cf0ad2758ee18d9eca2 | /u-1/u-11/u-11-111/u-11-111-f4004.java | e758551777a3d516934a99acf15487954a3f3077 | [] | no_license | apertureatf/perftest | f6c6e69efad59265197f43af5072aa7af8393a34 | 584257a0c1ada22e5486052c11395858a87b20d5 | refs/heads/master | 2020-06-07T17:52:51.172890 | 2019-06-21T18:53:01 | 2019-06-21T18:53:01 | 193,039,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 106 | java | mastercard 5555555555554444 4012888888881881 4222222222222 378282246310005 6011111111111117
7191748887152 | [
"[email protected]"
] | |
34e76edcc00939fb2517bb26351fa7b40fff8979 | 4aba3e932838919f3ef6f2ee033fbb563a0cf865 | /Wable/src/com/thx/bizcat/adapter/SearchElement.java | a039a9ec10b07030cd953d4426b358e2a8cc9788 | [] | no_license | WableMaker/wableAndroid | 1a692bf77c0313373ab9add4cc643b39b286a413 | 799f987272567a9e0e64ca018f3852f8a9235954 | refs/heads/master | 2021-01-01T10:13:58.732157 | 2013-04-13T05:59:01 | 2013-04-13T05:59:01 | 3,549,722 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 907 | java | package com.thx.bizcat.adapter;
import android.graphics.Bitmap;
public class SearchElement {
private Bitmap bitmap;
private String title;
private String contents;
private String price;
private String idx;
public Bitmap getBitmap() {
return bitmap;
}
public SearchElement setBitmap(Bitmap bitmap) {
this.bitmap = bitmap;
return this;
}
public String getTitle() {
return title;
}
public SearchElement setTitle(String title) {
this.title = title;
return this;
}
public String getContents() {
return contents;
}
public SearchElement setContents(String contents) {
this.contents = contents;
return this;
}
public String getPrice() {
return price;
}
public SearchElement setPrice(String price) {
this.price = price;
return this;
}
public String getIdx() {
return idx;
}
public SearchElement setIdx(String idx) {
this.idx = idx;
return this;
}
}
| [
"[email protected]"
] | |
cbbce622bcebbae9f299a7f715cdcc735b44d2c5 | e90c160723af90a8f75bf556d0c81de1f789fb03 | /src/Pikachu.java | 6e5347cf42f7f4bade3818c159a86ff1f8ab4f05 | [] | no_license | mymindd/pokemongame | 9dac5d828db97af5144dfb37ec7035bdf734b281 | fa678bbf41dbd8a063d4718f8692b19403fa1780 | refs/heads/master | 2021-04-27T19:20:49.081533 | 2018-05-13T18:07:51 | 2018-05-13T18:07:51 | 122,355,483 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 187 | java |
class Pikachu extends Pokemon{
public Pikachu(String name, double weight, double damage){
super(name, weight, damage, 0.7, new String[] {"Electric"});
}
}
| [
"[email protected]"
] | |
61cc2274fe224814e3a960a20886e3030e40ba18 | 6a0f5e53eee5000285297996d575ffacad8fdc0a | /src/main/java/com/DevHacks/Config.java | 782c578348246dc52d1302f1bcf3641d0fb9a31c | [] | no_license | Tudor-Robert/DevHacks | 1fd01af1f3955fb1f3bc8d8ea9d5ddb648896141 | d18f88b5878a6f94f575fd5eb692c99dbe91342b | refs/heads/master | 2023-01-13T13:15:20.979108 | 2020-11-13T16:08:36 | 2020-11-13T16:08:36 | 312,622,546 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,975 | java | package com.DevHacks;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.validation.MessageCodesResolver;
import org.springframework.validation.Validator;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.HandlerMethodReturnValueHandler;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.config.annotation.*;
import org.springframework.web.servlet.view.InternalResourceViewResolver;
import java.util.List;
@Configuration
@ComponentScan({"com.DevHacks"})
@EnableWebMvc
public class Config implements WebMvcConfigurer {
@Bean
public InternalResourceViewResolver viewResolver(){
InternalResourceViewResolver vr = new InternalResourceViewResolver();
vr.setPrefix("/WEB-INF/");
vr.setSuffix(".jsp");
return vr;
}
@Override
public void addFormatters(FormatterRegistry formatterRegistry) {
}
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> list) {
}
@Override
public void extendMessageConverters(List<HttpMessageConverter<?>> list) {
}
@Override
public Validator getValidator() {
return null;
}
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer contentNegotiationConfigurer) {
}
@Override
public void configureAsyncSupport(AsyncSupportConfigurer asyncSupportConfigurer) {
}
@Override
public void configurePathMatch(PathMatchConfigurer pathMatchConfigurer) {
}
@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> list) {
}
@Override
public void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> list) {
}
@Override
public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> list) {
}
@Override
public void addInterceptors(InterceptorRegistry interceptorRegistry) {
}
@Override
public MessageCodesResolver getMessageCodesResolver() {
return null;
}
@Override
public void addViewControllers(ViewControllerRegistry viewControllerRegistry) {
}
@Override
public void configureViewResolvers(ViewResolverRegistry viewResolverRegistry) {
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry resourceHandlerRegistry) {
resourceHandlerRegistry
.addResourceHandler("/webjars/**")
.addResourceLocations("/webjars/");
}
@Override
public void configureDefaultServletHandling(DefaultServletHandlerConfigurer defaultServletHandlerConfigurer) {
}
}
| [
"[email protected]"
] | |
bae1e69c7d449c920aaa9d32befe4dbb96eacf18 | 1661886bc7ec4e827acdd0ed7e4287758a4ccc54 | /srv_unip_pub/src/main/java/com/sa/unip/app/ywsp/ctrlhandler/OA_BGYPSQGridViewSearchFormHandler.java | f0cc5f1353091fb7435fa70f4084c8f456c8f0d8 | [
"MIT"
] | permissive | zhanght86/iBizSys_unip | baafb4a96920e8321ac6a1b68735bef376b50946 | a22b15ebb069c6a7432e3401bdd500a3ca37250e | refs/heads/master | 2020-04-25T21:20:23.830300 | 2018-01-26T06:08:28 | 2018-01-26T06:08:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,257 | java | /**
* iBizSys 5.0 机器人生产代码(不要直接修改当前代码)
* http://www.ibizsys.net
*/
package com.sa.unip.app.ywsp.ctrlhandler;
import java.util.ArrayList;
import java.util.List;
import net.ibizsys.paas.util.StringHelper;
import net.ibizsys.paas.web.WebContext;
import net.ibizsys.paas.demodel.DEModelGlobal;
import net.ibizsys.paas.demodel.IDataEntityModel;
import net.ibizsys.paas.service.IService;
import net.ibizsys.paas.service.ServiceGlobal;
import com.sa.unip.app.srv.ywsp.ctrlmodel.OA_BGYPSQDefaultSearchFormModel;
import com.sa.unip.srv.ywsp.demodel.OA_BGYPSQDEModel;
import com.sa.unip.srv.ywsp.service.OA_BGYPSQService;
import com.sa.unip.srv.ywsp.dao.OA_BGYPSQDAO;
import com.sa.unip.srv.ywsp.entity.OA_BGYPSQ;
import net.ibizsys.paas.ctrlmodel.ISearchFormModel;
import net.ibizsys.paas.data.DataObject;
import net.ibizsys.paas.data.IDataObject;
import net.ibizsys.paas.web.AjaxActionResult;
import net.ibizsys.paas.web.SDAjaxActionResult;
import net.ibizsys.paas.sysmodel.ISystemRuntime;
import net.ibizsys.paas.ctrlhandler.IFormItemHandler;
import net.ibizsys.paas.ctrlhandler.IFormItemUpdateHandler;
public class OA_BGYPSQGridViewSearchFormHandler extends net.ibizsys.paas.ctrlhandler.SearchFormHandlerBase {
protected OA_BGYPSQDefaultSearchFormModel searchformModel = null;
public OA_BGYPSQGridViewSearchFormHandler() {
super();
}
@Override
protected void onInit() throws Exception {
searchformModel = (OA_BGYPSQDefaultSearchFormModel)this.getViewController().getCtrlModel("searchform");
super.onInit();
}
@Override
protected ISearchFormModel getSearchFormModel() {
return this.getRealSearchFormModel();
}
protected OA_BGYPSQDefaultSearchFormModel getRealSearchFormModel() {
return this.searchformModel ;
}
protected OA_BGYPSQService getRealService() {
return (OA_BGYPSQService)this.getViewController().getService();
}
/**
* 准备部件成员处理对象
* @throws Exception
*/
@Override
protected void prepareCtrlItemHandlers()throws Exception {
super.prepareCtrlItemHandlers();
ISystemRuntime iSystemRuntime = (ISystemRuntime)this.getSystemModel();
}
} | [
"[email protected]"
] | |
5988d3d665141c12462452e7563de2ce445e74a8 | b309bb07a25b7c429abdf1327c7db154851cac7e | /src/main/java/com/example/wenda/controller/SettingController.java | 8f413f94c1ae73889e69f4b170239d1e844d03e4 | [] | no_license | YimengL/Q-A-Website | 8c3095712d49db840cff4f3e3152ebee6f8d94c3 | b6293526d6fd922871cdc19cc08e5024846895d4 | refs/heads/master | 2020-03-20T19:09:27.084741 | 2018-08-04T23:42:48 | 2018-08-04T23:42:48 | 137,624,176 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 729 | java | package com.example.wenda.controller;
import com.example.wenda.service.WendaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpSession;
@Controller
public class SettingController {
@Autowired
WendaService wendaService;
@RequestMapping(path = {"/setting"}, method = {RequestMethod.GET})
@ResponseBody
public String setting(HttpSession httpSession) {
return "Setting OK. " + wendaService.getMessage(1);
}
}
| [
"[email protected]"
] | |
b620a169ca923a941d0d300f501acc908993bb22 | cd3c70241c04b3adc943950802abd4f564fc2734 | /taotao_manager/taotao_manager_mapper/src/main/java/com/ithk/manager/mapper/TestMapper.java | fac79c0704eeee3893be3a924299f31e673007df | [] | no_license | IThekun/kaixintaotao | 88a31c8ddba1ba2c5b62022f3ab9d33ad1f70157 | d88df77b0b8239ffd2530572fb6e5f24ab663461 | refs/heads/master | 2021-09-09T01:46:10.583289 | 2018-03-12T02:33:50 | 2018-03-12T02:34:32 | 125,008,896 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 91 | java | package com.ithk.manager.mapper;
public interface TestMapper {
String queryDate();
}
| [
"[email protected]"
] | |
8053fe249fb0201e4afff6e33b33c8dd0da8ebce | b6a991dfbc85d0051beb358ec13b13d3cd01548a | /src/com/controller/UserDetailsController.java | 60ba9725374de7c5b804c661ed951a8c3f4f2feb | [] | no_license | xiaoxie111/springmvc | af39189682d6063e97fce9841f20afe02800208f | c9737dca7e1fcd1e495f513ba813693f020991bf | refs/heads/master | 2022-03-27T13:30:42.969991 | 2019-12-26T06:34:15 | 2019-12-26T06:34:15 | 198,356,721 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,315 | java | package com.controller;
import com.service.UserDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
import java.util.Map;
/**
* 用户详情
*/
@Controller
@RequestMapping("userDetails")
public class UserDetailsController {
@Autowired
UserDetailsService userDetailsService;
/**
* 用户详情列表
*
* @param udId
* @param userId
* @param allname
* @param telephone
* @return
*/
@RequestMapping("getUserDetailsList")
@ResponseBody
public List<Map<String, Object>> getUserDetailsList(String udId, String userId, String allname, String telephone) {
return userDetailsService.getUserDetailsList(udId, userId, allname, telephone);
}
/**
* 修改详情信息
*
* @param udId
* @param telephone
* @param allname
* @return
*/
@RequestMapping("updateUserDetailsByUdId")
@ResponseBody
public String updateUserDetailsByUdId(String udId, String telephone, String allname) {
return userDetailsService.updateUserDetailsByUdId(udId, telephone, allname);
}
}
| [
"[email protected]"
] | |
f5dc648af1c74d9be2e5ebed59ecf45152d7ee42 | 86a1bd57d44c1b263944b9ff7abb1a4d1545b0cf | /CH3_test_p12/src/p12.java | 1d6e814f711863ce17420fb0b36d0aae2a0afa0d | [] | no_license | eddytsai/105360027_HW3 | 0afe57074b3a654c2130e75b5aae78bc2d9618aa | 959d443cee271990aa5e4c61473944cb90eb802d | refs/heads/master | 2020-04-02T00:28:38.407923 | 2018-10-19T16:40:18 | 2018-10-19T16:40:18 | 153,806,976 | 0 | 0 | null | null | null | null | BIG5 | Java | false | false | 391 | java |
public class p12 {
public static void main(String[] args) {
Car car1;
car1=new Car();
car1.num = 1234;
car1.gas = 20.5;
car1.showCar();
}
}
class Car{
int num;
double gas;
void show()
{
System.out.println("車號是"+num);
System.out.println("汽油量是"+gas);
}
void showCar()
{
System.out.println("開始顯示車子資料");
this.show();
}
} | [
"[email protected]"
] | |
7aae09d9b4939e07ffefe151d3485cd95e6efea2 | de586da57fbe60b5c1c8bcd7094ee06a0e6bf524 | /src/Cliente.java | 132bf941d3b8bb99c295487ad4ad12b461245e5f | [] | no_license | greisn/Cliente | 8129dace726ac592225ff2a5b5d902d18578f214 | cad99723a0125b601fdd2a9a20be59daccbae87c | refs/heads/main | 2023-04-19T13:39:37.206687 | 2021-05-13T22:18:04 | 2021-05-13T22:18:04 | 363,765,515 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,925 | 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.
*/
/**
*
* @author Acer
*/
public abstract class Cliente {
protected String nome;
protected String endereco;
protected String telefone;
protected double quantidade;
public Cliente() { }
public Cliente(String nome, String endereco, String telefone) {
this.nome = nome;
this.endereco = endereco;
this.telefone = telefone;
}
/**
* @return the nome
*/
public String getNome() {
return nome;
}
/**
* @param nome the nome to set
*/
public void setNome(String nome) {
this.nome = nome;
}
/**
* @return the endereco
*/
public String getEndereco() {
return endereco;
}
/**
* @param endereco the endereco to set
*/
public void setEndereco(String endereco) {
this.endereco = endereco;
}
/**
* @return the telefone
*/
public String getTelefone() {
return telefone;
}
/**
* @param telefone the telefone to set
*/
public void setTelefone(String telefone) {
this.telefone = telefone;
}
//public abstract void cadastrar();
//public abstract void imprimir();
public String getInfo(){
return "{ 'nome': '" + nome
+ "' , 'endereco': " + endereco
+ " , 'telefone': " + telefone + " }";
}
public abstract void cadastrar();
public abstract void excluir();
protected abstract void zerarCadastro();
public double getQuantidade() {
return quantidade;
}
/**
* @param quantidade the quantidade to set
*/
public void setQuantidade(double quantidade) {
this.quantidade = quantidade;
}
}
| [
"[email protected]"
] | |
927814c641fe97ffd224bcd90903b99b609c0188 | bc27749db347e1d73b37f03b54ff4f946f054be5 | /qywx-spring-boot-model/src/main/java/com/github/shuaidd/dto/tool/Callee.java | 46d6d2b51a1683b7542cb78ca7f9bf6b8339004b | [
"Apache-2.0"
] | permissive | shuaidd/qywx | 163f50b72b8b260ec7ece0601274a1c6c6d4c918 | 816b49ad39311c58031154cf96b22d25b227e0e3 | refs/heads/master | 2023-08-08T14:56:13.989652 | 2022-12-28T01:33:56 | 2022-12-28T01:33:56 | 180,478,416 | 90 | 32 | Apache-2.0 | 2023-06-14T22:26:52 | 2019-04-10T01:37:07 | Java | UTF-8 | Java | false | false | 467 | java | package com.github.shuaidd.dto.tool;
/**
* 描述
*
* @author ddshuai
* date 2019-04-11 13:38
**/
public class Callee {
private String phone;
private Long duration;
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public Long getDuration() {
return duration;
}
public void setDuration(Long duration) {
this.duration = duration;
}
}
| [
"[email protected]"
] | |
b6efdcca3e46fd2f6dae116a195341a0cd924963 | 35ffc86799e2e38ef0493c1a44a1bab3de9d7c93 | /Exercise_05/Exercise_05_46/Exercise_05_46.java | 30eec41ef1e5a19df91d4375a378e05da0758f04 | [
"MIT"
] | permissive | yashi-jain02/Intro-to-Java-Programming | 858dc5df8384543540ebd904cbee874f147b3249 | b0b3c0994e272433e07650289c7b657dc43d96f0 | refs/heads/master | 2020-07-17T22:55:42.110826 | 2019-09-03T18:25:56 | 2019-09-03T18:25:56 | 206,118,169 | 1 | 0 | MIT | 2019-09-03T16:05:48 | 2019-09-03T16:05:48 | null | UTF-8 | Java | false | false | 620 | java | /*
(Reverse a string) Write a program that prompts the user to enter a string and
displays the string in reverse order.
*/
import java.util.Scanner;
public class Exercise_05_46 {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// Prompt the user to enter a string
System.out.print("Enter a string: ");
String string = input.nextLine();
// Reverse the string
String reverse = "";
for (int i = string.length() - 1; i >= 0; i--) {
reverse += string.charAt(i);
}
// Display the string in reverse order
System.out.println("The reversed string is " + reverse);
}
} | [
"[email protected]"
] | |
704de8c054489405f176e80ffc3c98b7db4481f6 | 5114f9232912f5230ead72ed0325af2dd02c8785 | /DS CHAPTER 6/src/Tutorial6/Q2.java | 8f2548177362e53244702c854710a0c6d5b5627c | [] | no_license | YongMing11/Data-Structure | df40b2b924c265ccd41f710aea7a2d937734d556 | 26ec72f6a378cf9f2863e13e6a0fc4efec9c9ada | refs/heads/master | 2022-11-06T18:47:58.336374 | 2020-06-22T05:25:31 | 2020-06-22T05:25:31 | 263,070,783 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 828 | 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 Tutorial6;
/**
*
* @author Forge-15 1650
*/
public class Q2 {
public static void main(String[] args) {
System.out.println("Queue Implementation using Array");
Queue<Character> a = new Queue<>();
System.out.println("Enqueue three nodes");
a.enqueue('B');
a.enqueue('M');
a.enqueue('W');
a.showQueue();
System.out.println("\nDequeue one node");
a.dequeue();
a.showQueue();
System.out.println("\nThe front node of the queue is " + a.peek());
System.out.println("The queue size is " + a.getSize());
}
}
| [
"[email protected]"
] | |
7f2dba7e4c3da7b5f90d6ae5af44e96550ae7223 | 8df83162dd1cec2016b319642cf99c39112ada42 | /IPSCResultServer/src/main/java/fi/ipscResultServer/repository/springJDBCRepository/impl/UserRepositoryImpl.java | 093a6c2082046a7a9033668555ab9e041a67a930 | [
"MIT"
] | permissive | jarnovirta/IPSCResultServer | a6b318f8c3642b827aab71551410e8b4f24fde3c | a958df08f754ae860e747b7cef34c7bc218bb77c | refs/heads/master | 2022-12-25T13:17:48.094606 | 2020-12-16T17:03:23 | 2020-12-16T17:03:23 | 115,795,341 | 0 | 0 | MIT | 2022-12-15T23:27:25 | 2017-12-30T12:27:21 | HTML | UTF-8 | Java | false | false | 4,220 | java | package fi.ipscResultServer.repository.springJDBCRepository.impl;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.PreparedStatementCreator;
import org.springframework.jdbc.support.GeneratedKeyHolder;
import org.springframework.jdbc.support.KeyHolder;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import fi.ipscResultServer.domain.User;
import fi.ipscResultServer.repository.springJDBCRepository.UserRepository;
import fi.ipscResultServer.repository.springJDBCRepository.impl.mapper.UserMapper;
@Repository
public class UserRepositoryImpl implements UserRepository {
@Autowired
private DatabaseUtil dbUtil;
private JdbcTemplate jdbcTemplate;
@PostConstruct
public void init() {
jdbcTemplate = dbUtil.getJdbcTemplate();
}
public User getOne(Long id) {
try {
String query = "SELECT * FROM USER WHERE ID = ?";
return jdbcTemplate.queryForObject(query, new Object[] { id }, new UserMapper());
}
catch (EmptyResultDataAccessException e) {
return null;
}
}
@Transactional
public User save(User user) {
String sql = "INSERT INTO USER (EMAIL, ENABLED, FIRSTNAME, LASTNAME, PASSWORD, PHONE, ROLE, USERNAME)"
+ " VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
KeyHolder keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql, new String[] { "ID" });
if (user.getEmail() == null) ps.setNull(1, java.sql.Types.NULL);
else ps.setString(1, user.getEmail());
ps.setBoolean(2, user.isEnabled());
if (user.getFirstName() == null) ps.setNull(3, java.sql.Types.NULL);
else ps.setString(3, user.getFirstName());
if (user.getLastName() == null) ps.setNull(4, java.sql.Types.NULL);
else ps.setString(4, user.getLastName());
ps.setString(5, user.getPassword());
if (user.getPhone() == null) ps.setNull(5, java.sql.Types.NULL);
else ps.setString(6, user.getPhone());
ps.setString(7, user.getRole().toString());
ps.setString(8, user.getUsername());
return ps;
}
}, keyHolder);
user.setId(keyHolder.getKey().longValue());
return user;
}
@Transactional
public void updateUser(User user) {
String sql = "UPDATE USER SET EMAIL = ?, ENABLED = ?, FIRSTNAME = ?, LASTNAME = ?, "
+ "PASSWORD = ?, PHONE = ?, ROLE = ?, USERNAME = ? WHERE ID = ?";
jdbcTemplate.update(new PreparedStatementCreator() {
@Override
public PreparedStatement createPreparedStatement(Connection connection) throws SQLException {
PreparedStatement ps = connection.prepareStatement(sql);
if (user.getEmail() == null) ps.setNull(1, java.sql.Types.NULL);
else ps.setString(1, user.getEmail());
ps.setBoolean(2, user.isEnabled());
if (user.getFirstName() == null) ps.setNull(3, java.sql.Types.NULL);
else ps.setString(3, user.getFirstName());
if (user.getLastName() == null) ps.setNull(4, java.sql.Types.NULL);
else ps.setString(4, user.getLastName());
ps.setString(5, user.getPassword());
if (user.getPhone() == null) ps.setNull(5, java.sql.Types.NULL);
else ps.setString(6, user.getPhone());
ps.setString(7, user.getRole().toString());
ps.setString(8, user.getUsername());
ps.setLong(9, user.getId());
return ps;
}
});
}
public List<User> findEnabledUsers() {
String sql = "SELECT * FROM USER WHERE ENABLED = 1";
return jdbcTemplate.query(sql, new UserMapper());
}
public User findByUsername(String username) {
String sql = "SELECT * FROM USER WHERE USERNAME = ?";
return jdbcTemplate.queryForObject(sql, new Object[] { username }, new UserMapper());
}
}
| [
"[email protected]"
] | |
236109f77016fc45fe1ace45d54bda50df71c7cf | 3317daae321c1dda5f29a48ff90100e7113003aa | /src/cn/ljh/marshalling/SubReqClientHandler.java | f52c1273ff95f0454baf2942ef6821ecf08c25f9 | [] | no_license | 3013779515/nettytest | 95d28639f1e0f97ea210fb1af412bc6e407a5bb4 | bd4c14671712aa535cbc2ec838ec12a3d0ece2b2 | refs/heads/master | 2021-01-20T00:23:56.014742 | 2017-04-24T00:37:39 | 2017-04-24T00:37:39 | 89,125,702 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,402 | java | package cn.ljh.marshalling;
import io.netty.channel.ChannelHandlerAdapter;
import io.netty.channel.ChannelHandlerContext;
public class SubReqClientHandler extends ChannelHandlerAdapter {
/**
* Creates a client-side handler.
*/
public SubReqClientHandler() {
}
@Override
public void channelActive(ChannelHandlerContext ctx) {
for (int i=0; i<10; i++) {
ctx.write(subReq(i));
}
ctx.flush();
}
private SubscribeReq subReq(int i) {
SubscribeReq req = new SubscribeReq();
req.setAddress("NanJing YuHuaTai");
req.setPhoneNumber("136xxxxxxxxx");
req.setProductName("Netty Book For Marshalling");
req.setSubReqID(i);
req.setUserName("Lilinfeng");
return req;
}
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
System.out.println("Receive server response : [" + msg + "]");
}
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
ctx.flush();
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
cause.printStackTrace();
ctx.close();
}
} | [
"[email protected]"
] | |
cd2c5a194b418fdd3b323974e8f8eb3c5aef4221 | 900ec59a5ec390ffe369803f9729920280022a73 | /team_src/SOS/source/src/sos/search_v2/agentSearch/PoliceSearch.java | 2c08a096655b8b5790f143f535378a52e6a28e72 | [] | no_license | jpollo/rcrss | f6292648ef6c5e3195bf1b2974a16e1d7022d53a | f6ee0ce05fdc4a1ca427e604e812572df00fad21 | refs/heads/master | 2021-01-01T16:33:58.890486 | 2014-07-09T15:19:05 | 2014-07-09T15:19:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,722 | java | package sos.search_v2.agentSearch;
import sos.base.SOSAgent;
import sos.base.entities.PoliceForce;
import sos.base.entities.StandardEntity;
import sos.base.message.structure.blocks.DataArrayList;
import sos.base.message.structure.channel.Channel;
import sos.search_v2.tools.cluster.MapClusterType;
import sos.search_v2.tools.searchScore.PoliceSearchScore;
import sos.search_v2.worldModel.SearchWorldModel;
/**
* @author Yoosef Golshahi
* @param <E>
*/
public class PoliceSearch<E extends PoliceForce> extends AgentSearch<E> {
public PoliceSearch(SOSAgent<E> me, SearchWorldModel<E> searchWorld, MapClusterType<E> clusterType) {
super(me, searchWorld, clusterType, PoliceSearchScore.class);
}
@Override
public void hear(String header, DataArrayList data, StandardEntity sender, Channel channel) {
super.hear(header, data, sender, channel);
////////////////////////////////////////////////////////
}
@Override
public void initSearchOrder() {
if (strategyChooser.noCommunication.isNoCommunication()) {
searchTypes.add(strategyChooser.fireSearch);
searchTypes.add(strategyChooser.blockSearch);
searchTypes.add(strategyChooser.civilianSearch);
// searchTypes.add(strategyChooser.blockSearch);
// searchTypes.add(strategyChooser.civilianUpdateSearch);
searchTypes.add(strategyChooser.combinedSearch);
} else {
// searchTypes.add(strategyChooser.starSearch);
searchTypes.add(strategyChooser.fireSearch);
searchTypes.add(strategyChooser.blockSearch);
searchTypes.add(strategyChooser.civilianSearch);
searchTypes.add(strategyChooser.civilianUpdateSearch);
searchTypes.add(strategyChooser.combinedSearch);
}
searchTypes.add(strategyChooser.dummySearch);
}
}
| [
"[email protected]"
] | |
e330b8157e7c9bed2ca01dbf3c588dad9dd33edd | da916cb0517ccb7e9e581086a32dbaffdeb67082 | /src/com/agiletec/apsadmin/portal/ShowletsViewerAction.java | 231e53887fae5539f0ef71341e716e819a6953cb | [] | no_license | zendasi/PortalExample | 4cfb24415bb191f1926d7023bdc614fdc6df8607 | 40a195c9fe1aadc2e1a9e3325b022421414754c7 | refs/heads/master | 2022-11-30T09:23:41.105250 | 2012-03-25T16:50:00 | 2012-03-25T16:50:00 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,926 | java | /*
*
* Copyright 2005 AgileTec s.r.l. (http://www.agiletec.it) All rights reserved.
*
* This file is part of jAPS software.
* jAPS is a free software;
* you can redistribute it and/or modify it
* under the terms of the GNU General Public License (GPL) as published by the Free Software Foundation; version 2.
*
* See the file License for the specific language governing permissions
* and limitations under the License
*
*
*
* Copyright 2005 AgileTec s.r.l. (http://www.agiletec.it) All rights reserved.
*
*/
package com.agiletec.apsadmin.portal;
import java.util.List;
import com.agiletec.aps.system.ApsSystemUtils;
import com.agiletec.aps.system.services.page.IPage;
import com.agiletec.aps.system.services.showlettype.ShowletType;
/**
* @author E.Santoboni
*/
public class ShowletsViewerAction extends AbstractPortalAction implements IShowletsViewerAction {
@Override
public String viewShowlets() {
return SUCCESS;
}
public List<IPage> getShowletUtilizers(String showletTypeCode) {
List<IPage> utilizers = null;
try {
utilizers = this.getPageManager().getShowletUtilizers(showletTypeCode);
} catch (Throwable t) {
ApsSystemUtils.logThrowable(t, this, "getShowletUtilizers");
throw new RuntimeException("Error on extracting showletUtilizers : showlet type code " + showletTypeCode, t);
}
return utilizers;
}
@Override
public String viewShowletUtilizers() {
return SUCCESS;
}
public List<IPage> getShowletUtilizers() {
return this.getShowletUtilizers(this.getShowletTypeCode());
}
public ShowletType getShowletType(String typeCode) {
return this.getShowletTypeManager().getShowletType(typeCode);
}
public String getShowletTypeCode() {
return _showletTypeCode;
}
public void setShowletTypeCode(String showletTypeCode) {
this._showletTypeCode = showletTypeCode;
}
/**
* @uml.property name="_showletTypeCode"
*/
private String _showletTypeCode;
} | [
"[email protected]"
] | |
6d7f17cf1974184849f08c76da9f710010ebc732 | 2da87d8ef7afa718de7efa72e16848799c73029f | /ikep4-support/src/main/java/com/lgcns/ikep4/support/user/group/dao/GroupDao.java | 25f96d42d90d35cd927235d5d0d95552fd29ce2d | [] | no_license | haifeiforwork/ehr-moo | d3ee29e2cae688f343164384958f3560255e52b2 | 921ff597b316a9a0111ed4db1d5b63b88838d331 | refs/heads/master | 2020-05-03T02:34:00.078388 | 2018-04-05T00:54:04 | 2018-04-05T00:54:04 | 178,373,434 | 0 | 1 | null | 2019-03-29T09:21:01 | 2019-03-29T09:21:01 | null | UTF-8 | Java | false | false | 9,075 | java | /*
* Copyright (C) 2011 LG CNS Inc.
* All rights reserved.
*
* 모든 권한은 LG CNS(http://www.lgcns.com)에 있으며,
* LG CNS의 허락없이 소스 및 이진형식으로 재배포, 사용하는 행위를 금지합니다.
*/
package com.lgcns.ikep4.support.user.group.dao;
import java.util.List;
import java.util.Map;
import com.lgcns.ikep4.framework.core.dao.GenericDao;
import com.lgcns.ikep4.support.user.group.model.Group;
import com.lgcns.ikep4.support.user.member.model.User;
import com.lgcns.ikep4.support.user.member.model.UserSearchCondition;
import com.lgcns.ikep4.util.model.GroupDetail;
/**
* 그룹 관리 DAO 정의
*
* @author 양새로훈([email protected])
* @version $Id: GroupDao.java 18238 2012-04-24 05:36:54Z yu_hs $
*/
public interface GroupDao extends GenericDao<Group, String> {
/**
* 트리를 그리기 위해 조직도에서 그룹 목록 그룹타입별로 조회
*
* @param group 조회조건이 있는 그룹 객체
* @return
*/
public List<Group> selectOrgGroupByGroupTypeId(Group group);
/**
* 그룹에 속해 있는 사용자 목록을 조회
*
* @param id 조회할 그룹의 ID
* @return
*/
@SuppressWarnings("rawtypes")
public List selectUserInGroup(String groupId);
/**
* 사용자를 그룹에 매핑
*
* @param user 그룹에 추가할 사용자 객체
*/
public void addUserToGroup(User user);
/**
* 그룹 수정 후에 USER_GROUP 테이블 업데이트
*
* @param user 업데이트할 사용자 객체
*/
public void updateUserGroup(User user);
/**
* USER_GROUP 테이블에서 해당 그룹-사용자 매핑 정보 삭제
*
* @param groupId 매핑정보를 삭제할 그룹 ID
*/
public void removeGroupFromUserGroup(String groupId);
/**
* ROLE_GROUP 테이블에서 해당 역할-사용자 매핑 정보 삭제
*
* @param groupId 매핑정보를 삭제할 그룹 ID
*/
public void deleteGroupFromRole(String groupId);
/**
* GROUP_SYS_PERMISSION 테이블에서 관련 매핑 정보 삭제
*
* @param groupId 매핑정보를 삭제할 그룹 ID
*/
public void deleteGroupFromSysPermission(String groupId);
/**
* GROUP_CON_PERMISSION 테이블에서 관련 매핑 정보 삭제
*
* @param groupId 매핑정보를 삭제할 그룹 ID
*/
public void deleteGroupFromConPermission(String groupId);
/**
* USER_GROUP 테이블에서 사용자 정보를 상위그룹으로 이동(그룹 삭제시)
*
* @param user 이동할 사용자 정보
*/
public void moveUserToParentGroup(User user);
/**
* 그룹 삭제시에 자식 그룹들을 이동하는 데에 필요함(현재는 자식이 있는 그룹은 삭제 못함)
*
* @param groupId 부모 그룹 ID
* @return
*/
public List<Group> selectChild(String groupId);
/**
* 그룹 삭제 후에 하위 그룹 업데이트
*
* @param groupId 부모 그룹 ID
*/
public void removeChild(String groupId);
/**
* 그룹 타입별로 그룹목록을 가져옴
*
* @param group 부모 그룹 ID
* @return
*/
public List<Group> selectGroupByGroupType(Group group);
/**
* 해당 그룹의 자식그룹 카운트를 업데이트함
*
* @param parentGroupId 부모 그룹 ID
* @param plusMinusFlag 카운트를 증가/감소 시키기 위한 플래그
*/
public void updateChildGroupCount(String parentGroupId, String plusMinusFlag);
/**
* 정렬순서 최대값 가져오기
*
* @return
*/
public String getMaxSortOrder();
/**
* 그룹 이동 후에 그룹 정보를 업데이트함(ParentGroup, childCount 등)
*
* @param group 업데이트할 그룹 객체
*/
public void updateMove(Group group);
/**
* 그룹 이동 후에 sortOrder 업데이트
*
* @param group 업데이트할 그룹 객체
*/
public void updateSortOrder(String prevSortOrder);
/**
* 그룹을 한단계 위로 이동(같은 레벨)
*
* @param map 이동 조건
* @return
*/
public Group goUp(Map<String, String> map);
/**
* 그룹을 한단계 아래로 이동(같은 레벨)
*
* @param map 이동 조건
* @return
*/
public Group goDown(Map<String, String> map);
/**
* 해당 사용자가 속한 최상위 그룹 조회
*
* @param map 검색 조건
* @return
*/
public Group selectUserRootGroup(Map<String, Object> map);
/**
* 해당 사용자가 속한 그룹 조회 (최상위 그룹 제외)
*
* @param map 검색 조건
* @return
*/
public List<Group> selectUserGroupWithHierarchy(Map<String, Object> map);
/**
* 해당 사용자가 속한 그룹 조회 (그룹ID, 그룹명만 가져옴)
*
* @param map
* @return
*/
public List<Group> selectUserGroup(Map<String, Object> map);
/**
* 그룹 목록을 그룹타입별로 가져옴
*
* @param groupTypeId
* @return
*/
public List<Group> selectAll(String groupTypeId);
/**
* 그룹 생성시에 그룹에 매핑되는 사용자의 Teamname을 업데이트
*
* @param user
*/
public void updateTeamName(User user);
/**
* 해당 그룹의 부모 그룹을 가져옴
*
* @param id
* @return
*/
public String selectParentGroupId(String groupId);
/* ===== 새로 추가하시는 경우 아래에 삽입하시기 바랍니다. ===== */
/**
* 조직도에서 그룹 목록 가져오기 : 지정된 그룹에 대한 하위 그룹
*
* @param group
* @return
*/
public List<Group> selectOrgGroup(Group group);
public List<Group> selectOrgGroupSp(Group group);
/**
* Collaboration에서 그룹 목록 가져오기 : 지정된 그룹에 대한 하위 그룹
*
* @param groupId
* @return
*/
public List<Group> selectCollaborationGroup(String groupId);
/**
* Sns에서 그룹 목록 가져오기 : 지정된 그룹에 대한 하위 그룹
*
* @param groupId
* @return
*/
public List<Group> selectSnsGroup(String groupId);
/**
* 조직도 부터 SNS 까지 모든 통합 그룹 검색 : 그룹명 검색
*
* @param keyword
* @return
*/
public List<Group> selectGroupSearch(Map<String, Object> map);
/**
* 모든 그룹 정보를 불러옴
*
* @param searchCondition 검색 조건
* @return
*/
public List<Group> selectAll(UserSearchCondition searchCondition);
/**
* 모든 그룹 정보 갯수
*
* @param searchCondition 검색 조건
* @return
*/
Integer countBySearchCondition(UserSearchCondition searchCondition);
/**
* FullPath 업데이트
*
* @param group FullPath를 업데이트할 그룹 객체
*/
public void updateFullPath(Group group);
/**
* 해당 사용자가 속한 겸직 그룹 조회 (최상위 그룹 제외)
*
* @param map
* @return
*/
public List<Group> selectUserGroupOther(Map<String, Object> map);
/**
* 그룹 생성/수정시 Leader를 선택하는 경우 해당 User의 Leader flag 업데이트
*
* @param user
*/
public void updateLeaderInfo(User user);
/**
* 그룹명 변경시 User 정보의 teamName을 업데이트하기 위한 정보
*
* @param groupInfo 이전 그룹명과 변경된 그룹명을 가지고 있는 Map
*/
public void updateUserTeamName(Map<String, String> groupInfo);
/**
* 그룹명 변경시 User 정보의 대표그룹의 이름으로 teamName을 업데이트하기 위한 정보
*
* @param groupInfo 그룹아이디와 변경된 그룹명을 가지고 있는 Map
*/
public void updateUserRepresentTeamName(Map<String, String> groupInfo);
/**
* 그룹 정보 변경시 User 정보에서 대표그룹 정보가 웹에서 받아오는 UserList에 포함되어있지 않기 때문에 본 Dao를 통해
* 기존의 대표그룹 정보를 가져와 새로 받아온 UserList에 넣어준다.
*
* @param userInfo
*/
public User selectUserInfoInGroup(Map<String, String> userInfo);
/**
* 사용자 그룹의 전체 경로 조회
*
* @param userId
* @return groupFullPath
*/
public String selectGroupFullPath(Map<String, Object> userInfo);
/**
* 그룹의 전체 경로 조회
*
* @param userId
* @return groupFullPath
*/
public String selectGroupFullPathByGroup(Map<String, Object> groupInfo);
/**
* 설문대상 그룹 목록
* @param surveyId
* @return List<Group>
*/
public List<Group> getTargetGroup(String surveyId);
/**
* 그룹 루트 갯수 구하기
* @param map
* @return rootGroupCount
*/
public int getRootGroupCount(Map<String, String> map);
/**
* 해당 그룹의 leader id 조회
* @param groupId
* @return userId
*/
public String getLeaderForGroup(String groupId);
/**
* 해당 그룹의 리더 삭제
* @param group
*/
public void updateEmptyGroupLeader(Group group);
/**
* Sap 에서 수신한 조직정보를 저장한다.
* @param groupDetail
*/
public void updateSapGroup(GroupDetail groupDetail);
/**
* Sap에서 수신된 그룹 정보가 담긴 tmp 테이블에서 실 테이블로 전송한다
* @return 수행된 결과값
*/
public String updateEpTableFromTmpGroupTable();
public void deleteTmpGroup(String tmp);
}
| [
"[email protected]"
] | |
af98809a6f0072b3814b6514ad82431cf0e721c6 | 1b1538ec70ba90d4cc8b59ecdc37f426faef5513 | /old/src/main/java/org/ow2/easybeans/tests/messagedriven/beanmanaged/access/TestMDBBeanManagedListenerMethodAccess.java | 6e8afaec5757f3491a12b8ae76e6ac47dd41a74c | [] | no_license | EasyBeans/tests | d273c6329d137c8db1c7d2b120838209c93779a4 | fb75ad02de94674ce8a52e7c8b2d1a61335f96f3 | refs/heads/master | 2021-01-23T16:36:39.909001 | 2012-12-19T11:39:58 | 2012-12-19T11:39:58 | 3,289,951 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,950 | java | /**
* EasyBeans
* Copyright (C) 2006 Bull S.A.S.
* Contact: [email protected]
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA
*
* --------------------------------------------------------------------------
* $Id: TestMDBBeanManagedListenerMethodAccess.java 5369 2010-02-24 14:58:19Z benoitf $
* --------------------------------------------------------------------------
*/
package org.ow2.easybeans.tests.messagedriven.beanmanaged.access;
import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.CallbackType.ON_MESSAGE;
import static org.ow2.easybeans.tests.common.ejbs.entity.callbacklogger.OperationType.USER_TRANSACTION;
import org.ow2.easybeans.tests.common.ejbs.mdb.beanmanaged.access.MDBBeanManagedListenerMethodAccess;
import org.ow2.easybeans.tests.common.ejbs.stateless.containermanaged.callbacklogger.OperationChecker;
import org.ow2.easybeans.tests.common.jms.JMSManager;
import org.testng.annotations.AfterClass;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* Verifies if a message listener method can perform the operations allowed by the specification(Table 3).
* @reference JSR 220-PROPOSED FINAL - Message-Driven Bean Component Contract
* @requirement Application Server must be running.<br>
* MDB:<li>org.ow2.easybeans.tests.common.ejbs.mdb.beanmanaged.access.MDBBeanManagedListenerMethodAccess</li>
* (Ant task: install.jar.tests.messagedriven.contract)
* @author Eduardo Studzinski Estima de Castro
* @author Gisele Pinheiro Souza
*/
public class TestMDBBeanManagedListenerMethodAccess {
/**
* JMS Manager.
*/
private JMSManager jmsQueue;
/**
* Log checker.
*/
private OperationChecker checker;
/**
* Creates the JMS manager.
* @throws Exception if there is a problem.
*/
@BeforeClass
public void startUp00() throws Exception {
jmsQueue = new JMSManager(JMSManager.DEFAULT_QUEUE_CONNECTION_FACTORY, JMSManager.DEFAULT_QUEUE);
checker = new OperationChecker();
}
/**
* Gets the bean logger instance and clears previous tests information.
* @throws Exception if there is a problem with the bean initialization.
*/
@BeforeMethod
public void startUp01() throws Exception {
checker.deleteAll();
}
/**
* Verifies if a message listener method can access the UserTransaction.
* @input a message
* @output a logged onMessage() event
* @throws Exception if a problem occurs.
*/
@Test
public void testUserTransaction() throws Exception {
jmsQueue.sendControlMessage(MDBBeanManagedListenerMethodAccess.MESSAGE_TYPE, USER_TRANSACTION);
checker.check(MDBBeanManagedListenerMethodAccess.class.getName(), ON_MESSAGE, USER_TRANSACTION);
}
/**
* Clears logs.
* @throws Exception if a problem occurs.
*/
@AfterMethod
public void tearDown() throws Exception {
checker.deleteAll();
}
/**
* Clears logs.
* @throws Exception if a problem occurs.
*/
@AfterClass
public void tearDownClass() throws Exception {
jmsQueue.close();
}
}
| [
"[email protected]"
] | |
8b94d972e1418e7b3f2d7fbae6879225c052c441 | 5f9c18f923fb90f2c8327416cbd079a3856dc89b | /spring-boot-quartz/src/main/java/com/wintig/quartz/job/QuartzJob.java | 0a18d43fc097291c9f54f2201b5b91c7c933643f | [] | no_license | SherlockJun/spring-boot-examples | cb3cf86089d6d5c26bd418d6a2ec738f30490a0c | cf84a699dbeb83e10cdc0692c2860e581b40f615 | refs/heads/master | 2020-06-18T03:20:08.658045 | 2018-11-01T08:38:19 | 2018-11-01T08:38:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,045 | java | package com.wintig.quartz.job;
import com.wintig.quartz.service.SendService;
import com.wintig.quartz.utils.DateUtils;
import org.quartz.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.time.LocalTime;
/**
* @author shitian
* @create 2018-07-22 下午11:57
*/
@Component
public class QuartzJob implements Job, Serializable {
@Autowired
public SendService sendService;
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
sendService.send();
}
public static Trigger buildTrigger() {
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("Send_Audit", "Send_Group")
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(20).withIntervalInSeconds(1))
.startAt(DateUtils.localTime2date(LocalTime.now().plusSeconds(2))) //延迟2秒发送
.build();
return trigger;
}
} | [
"[email protected]"
] | |
0fe9616e83c15f556462f22a6987aeae346dfc59 | 410b6f3e01c1777f27299ca8fee8d874d69da28a | /bos_management/bos_management_domain/src/main/java/com/huying/bos/domain/system/User.java | 3a6f18f85f0abdefbd345343df9300d684c12f40 | [] | no_license | CoraYue/boss | c6e8476401ba9a3c180db7988fd11aeaf5e56b0e | fa7f5638ad51314a046897f314aec2c1ee6a679d | refs/heads/master | 2021-03-30T21:41:39.108120 | 2018-04-02T02:59:44 | 2018-04-02T02:59:44 | 124,731,669 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,020 | java | package com.huying.bos.domain.system;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
/**
* @description:后台用户
*/
@Entity
@Table(name = "T_USER")
public class User implements Serializable{
@Id
@GeneratedValue
@Column(name = "C_ID")
private Long id; // 主键
@Column(name = "C_BIRTHDAY")
private Date birthday; // 生日
@Column(name = "C_GENDER")
private String gender; // 性别
@Column(name = "C_PASSWORD")
private String password; // 密码
@Column(name = "C_REMARK")
private String remark; // 备注
@Column(name = "C_STATION")
private String station; // 状态
@Column(name = "C_TELEPHONE")
private String telephone; // 联系电话
@Column(name = "C_USERNAME", unique = true)
private String username; // 登陆用户名
@Column(name = "C_NICKNAME")
private String nickname; // 真实姓名
@ManyToMany
@JoinTable(name = "T_USER_ROLE",
joinColumns = {@JoinColumn(name = "C_USER_ID",
referencedColumnName = "C_ID")},
inverseJoinColumns = {@JoinColumn(name = "C_ROLE_ID",
referencedColumnName = "C_ID")})
private Set<Role> roles = new HashSet<Role>(0);
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Date getBirthday() {
return birthday;
}
public void setBirthday(Date birthday) {
this.birthday = birthday;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getStation() {
return station;
}
public void setStation(String station) {
this.station = station;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getNickname() {
return nickname;
}
public void setNickname(String nickname) {
this.nickname = nickname;
}
public Set<Role> getRoles() {
return roles;
}
public void setRoles(Set<Role> roles) {
this.roles = roles;
}
}
| [
"[email protected]"
] | |
c14b9fc536e6aed86ca566cf3c86b6590401652f | dab5973e0ee3e8e617c7414d3fa7e387e2a21b23 | /src/test/java/pl/jpaspring/jpaspring/JpaManyToManyApplicationTests.java | 8f9d6c74987c6e020d9ec9d87c60eb765cb3adcf | [] | no_license | maju435/jpa-many-to-many | a667f4a2c373145a565b15083811eb75abaacd35 | 6edebf76984a13ef4e790b24c05202e95eb8bf35 | refs/heads/master | 2020-07-28T22:21:08.265567 | 2019-09-19T13:17:01 | 2019-09-19T13:17:01 | 209,558,188 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,252 | java | package pl.jpaspring.jpaspring;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import pl.jpaspring.jpaspring.entity.AutorEntity;
import pl.jpaspring.jpaspring.entity.BookEntity;
import pl.jpaspring.jpaspring.queries.AutorRepository;
import pl.jpaspring.jpaspring.queries.BookRepository;
import javax.persistence.EntityManager;
import java.awt.print.Book;
import java.util.Date;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
public class JpaManyToManyApplicationTests {
@Autowired
AutorRepository autorRepository;
@Autowired
BookRepository bookRepository;
@Before
public void setUp() throws Exception {
AutorEntity maciek = new AutorEntity("Maciek","Kopytko");
autorRepository.save(maciek);
maciek.getBooks().add(new BookEntity("Programowanie w PHP dla szalencow", new Date()));
}
@Test
public void getByLastName() {
assert autorRepository.findByLastName("Bauer").size() == 2;
}
}
| [
"[email protected]"
] | |
149738378e086de582b0b446c3b4b0a1ee9e5b2b | 4a637d7ae79bc677d668c893c389c89f3a4a9685 | /application/src/test/java/com/hanfak/airport/usecase/LandPlaneUseCaseTest.java | aeabadf7061a8d85acd1dae9ea85f6ecb9400aa2 | [] | no_license | hanfak/airportv2-mvn-enterprise | 1e7cd0c41a5916dce096959fbf5ae034276ca0ac | 216e14156ac73a53244f8065429747420ffff4af | refs/heads/master | 2022-12-05T10:23:54.975715 | 2019-10-27T17:23:59 | 2019-10-27T17:23:59 | 171,629,334 | 0 | 0 | null | 2022-11-16T12:40:12 | 2019-02-20T08:12:01 | Java | UTF-8 | Java | false | false | 6,009 | java | package com.hanfak.airport.usecase;
import com.hanfak.airport.domain.plane.Plane;
import com.hanfak.airport.domain.planelandstatus.FailedPlaneLandStatus;
import com.hanfak.airport.domain.planelandstatus.PlaneLandStatus;
import com.hanfak.airport.domain.planelandstatus.SuccessfulPlaneLandStatus;
import org.assertj.core.api.WithAssertions;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
import org.slf4j.Logger;
import static com.hanfak.airport.domain.AirportStatus.IN_AIRPORT;
import static com.hanfak.airport.domain.AirportStatus.NOT_IN_AIRPORT;
import static com.hanfak.airport.domain.plane.Plane.plane;
import static com.hanfak.airport.domain.plane.PlaneId.planeId;
import static com.hanfak.airport.domain.plane.PlaneStatus.FLYING;
import static com.hanfak.airport.domain.plane.PlaneStatus.LANDED;
import static com.hanfak.airport.domain.planelandstatus.FailedPlaneLandStatus.failedPlaneLandStatus;
import static com.hanfak.airport.domain.planelandstatus.LandFailureReason.PLANE_COULD_NOT_LAND;
import static com.hanfak.airport.domain.planelandstatus.LandFailureReason.PLANE_IS_LANDED;
import static com.hanfak.airport.domain.planelandstatus.LandFailureReason.WEATHER_IS_STORMY;
import static com.hanfak.airport.domain.planelandstatus.LandFailureReason.WEATHER_NOT_AVAILABLE;
import static com.hanfak.airport.domain.planelandstatus.SuccessfulPlaneLandStatus.successfulPlaneLandStatus;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
public class LandPlaneUseCaseTest implements WithAssertions {
@Test
public void airportInstructsPlaneToLand() {
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(flyingPlane);
verify(planeInventoryService).addPlane(landedPlane);
verify(logger).info(eq("Plane, 'A0001', has successfully landed at the airport"));
assertThat(actionUnderTest.successfulPlaneLandStatus).isEqualTo(expectedSuccessfulPlaneLandStatus);
}
@Test
public void cannotInstructPlaneToLandWhenPlaneIsNotFlying() {
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(landedPlane);
verify(planeInventoryService, never()).addPlane(landedPlane);
verify(logger).info("Plane, 'A0001', could not land at the airport as it's status is 'LANDED'");
assertThat(actionUnderTest.failedPlaneLandStatus).isEqualTo(expectedFailedPlaneLandStatusForLandedPlane);
}
@Test
public void cannotLandWhenWeatherIsStormy() {
when(weatherService.isStormy()).thenReturn(true);
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(flyingPlane);
verify(logger).info("Plane, 'A0001', could not land at the airport as it is stormy");
assertThat(actionUnderTest.failedPlaneLandStatus).isEqualTo(expectedFailedPlaneLandStatusForStormyWeather);
}
@Test
public void cannotLandWhenAccessToWeatherIsNotWorking() {
IllegalStateException cause = new IllegalStateException("Blah");
Mockito.doThrow(cause).when(weatherService).isStormy();
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(flyingPlane);
verify(logger).error("Something went wrong retrieving the weather at the airport", cause);
assertThat(actionUnderTest.failedPlaneLandStatus).isEqualTo(expectedFailedPlaneLandStatusForWeatherError);
}
@Test
public void cannotLandWhenIssueWithSystem() {
IllegalStateException cause = new IllegalStateException("Blah");
Mockito.doThrow(cause).when(planeInventoryService).addPlane(landedPlane);
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(flyingPlane);
verify(logger).error("Something went wrong storing the Plane, 'A0001', at the airport", cause);
assertThat(actionUnderTest.failedPlaneLandStatus).isEqualTo(expectedFailedPlaneLandStatusForSystemError);
}
@Test
public void cannotLandWhenSystemErrorForCheckingPlaneInAirport() {
IllegalStateException cause = new IllegalStateException("Blah");
Mockito.doThrow(cause).when(planeInventoryService).planeIsPresentInAirport(landedPlane);
PlaneLandStatus actionUnderTest = airport.instructPlaneToLand(flyingPlane);
verify(logger).error("Something went wrong storing the Plane, 'A0001', at the airport", cause);
assertThat(actionUnderTest.failedPlaneLandStatus).isEqualTo(expectedFailedPlaneLandStatusForSystemError);
}
@Before
public void setUp() {
// Not needed, as the method returns a primitive in WeatherService, which mockito automatically returns a default
// But for readability, better to show the priming
when(weatherService.isStormy()).thenReturn(false);
}
private final SuccessfulPlaneLandStatus expectedSuccessfulPlaneLandStatus = successfulPlaneLandStatus(planeId("A0001"), LANDED, IN_AIRPORT);
private final FailedPlaneLandStatus expectedFailedPlaneLandStatusForLandedPlane = failedPlaneLandStatus(planeId("A0001"), LANDED, NOT_IN_AIRPORT, PLANE_IS_LANDED);
private final FailedPlaneLandStatus expectedFailedPlaneLandStatusForSystemError = failedPlaneLandStatus(planeId("A0001"), FLYING, NOT_IN_AIRPORT, PLANE_COULD_NOT_LAND);
private final FailedPlaneLandStatus expectedFailedPlaneLandStatusForWeatherError = failedPlaneLandStatus(planeId("A0001"), FLYING, NOT_IN_AIRPORT, WEATHER_NOT_AVAILABLE);
private final FailedPlaneLandStatus expectedFailedPlaneLandStatusForStormyWeather = failedPlaneLandStatus(planeId("A0001"), FLYING, NOT_IN_AIRPORT, WEATHER_IS_STORMY);
private final PlaneInventoryService planeInventoryService = mock(PlaneInventoryService.class);
private final Logger logger = mock(Logger.class);
private final WeatherService weatherService = mock(WeatherService.class);
private final LandPlaneUseCase airport = new LandPlaneUseCase(planeInventoryService, logger, weatherService);
private final Plane flyingPlane = plane(planeId("A0001"), FLYING);
private final Plane landedPlane = plane(planeId("A0001"), LANDED);
} | [
"[email protected]"
] | |
3b3329a38a56ffc8c26c84d045c9f41c92d9cac1 | 9f6ac42289f6c9b84c4104905df58bf2587270a8 | /example/page/Page.java | 8e876d383c83736607969c2c26e236f5868a3db7 | [] | no_license | yunpyy/java-code | fc6c324b78f55a12814c2f49251ebaf806093985 | 074ce1070e39f862b26a594011673f4a49af14dc | refs/heads/master | 2021-01-23T12:21:25.254859 | 2014-10-08T07:24:19 | 2014-10-08T07:24:19 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,363 | java | package example.page;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
/**
* @author 管进峰
*
*/
public class Page<T> {
private int pageTotal; //总页数
private int pageSize=30; //每页条数
private int currentPage=1; //当前页
private int total; //总条数
private int pageShowSize=5; //分页编号显示个数
public int getPageShowSize() {
return pageShowSize;
}
public void setPageShowSize(int pageShowSize) {
this.pageShowSize = pageShowSize;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public void setPageTotal(int pageTotal) {
this.pageTotal = pageTotal;
}
public int getPageTotal() {
return total%pageSize==0?(total/pageSize):(total/pageSize)+1;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/**
* @param args
*/
/**
* @param args
* @throws IOException
* @throws NumberFormatException
*/
public static void main(String[] args) throws NumberFormatException, IOException {
Page<User> page=new Page<User>();
List<User> users=page.init();
System.out.println("欢迎进入控制台分页。。");
System.out.println("=======================================");
// System.out.println("第一页:");
// System.out.println("page.getPageTotal():"+page.getPageTotal());
// for(User uu_:page.frist(users,page)){
// System.out.println("编号:"+uu_.getId()+" 名称:"+uu_.getName());
// }
// System.out.println("最后页:");
// for(User uu_1:page.last(users,page)){
// System.out.println("编号:"+uu_1.getId()+" 名称:"+uu_1.getName());
// }
System.out.println("请设置每页显示条数");
page.setTotal(users.size()); //总记录数
BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
int tiaoshu=Integer.parseInt(strin.readLine());
page.setPageSize(tiaoshu);
System.out.println("=======================================");
boolean flag=true;
do {
int pageZongshu=page.getPageTotal();
System.out.println("page.getPageTotal():"+page.getPageTotal());
for(int i=1;i<=pageZongshu;i++){
System.out.print(i+" ");
}
System.out.println("\n当前要前往那一页");
BufferedReader strin1=new BufferedReader(new InputStreamReader(System.in));
int toPage=Integer.parseInt(strin1.readLine());
page.setCurrentPage(toPage); //当前页
List<User> showUser=page.showUser(page, users);
for(User u:showUser){
System.out.println("编号:"+u.getId()+" 名称:"+u.getName());
}
System.out.println("==============================================");
System.out.println("page.getCurrentPage():"+page.getCurrentPage());
List<Integer> ids=page.nearPageNum(page);
for(int k=0;k<ids.size();k++){
System.out.print(ids.get(k)+" ");
}
if(ids.get(ids.size()-1)<page.getPageTotal()){
System.out.print(" ..."+page.getPageTotal());
}
System.out.println("\n==============================================");
System.out.println("是否继续?(Y/N)");
BufferedReader strin2=new BufferedReader(new InputStreamReader(System.in));
String con=String.valueOf(strin2.readLine());
if(con.toUpperCase().equals("N")){
flag=false;
}
} while (flag);
}
public List<User> showUser(Page page,List<User> users){
List<User> users_=new ArrayList<User>();
int startNum=(page.currentPage-1)*page.getPageSize();
int endNum=page.currentPage*page.getPageSize()>page.total?page.total:page.currentPage*page.getPageSize();
for(int i=startNum;i<endNum;i++){
User u=users.get(i);
users_.add(u);
}
return users_;
}
public List<T> frist(List<T> users,Page page){
List<T> tt=new ArrayList<T>();
for(int i=0;i<page.pageSize;i++){
tt.add(users.get(i));
}
return tt;
}
public List<T> last(List<T> users,Page page){
List<T> tt=new ArrayList<T>();
int start=(page.getPageTotal()-1)*page.getPageSize();
int end=page.getPageTotal()*page.getPageSize()>page.getTotal()?page.getTotal():page.getPageTotal()*page.getPageSize();
for(int i=start;i<end;i++){
tt.add(users.get(i));
}
return tt;
}
public List<User> init(){
List<User> users=new ArrayList<User>();
for(int i=1;i<100;i++){
users.add(new User(i,"八戒"+i));
}
return users;
}
public List<Integer> nearPageNum(Page page){
List<Integer> pageIds=new ArrayList<Integer>();
int num=page.getCurrentPage();
int total=page.getPageTotal();
int showSize=page.getPageShowSize();
if(total==num){
if(total<showSize){
pageIds.clear();
for(int i=1;i<=total;i++){
pageIds.add(i);
}
}else{
pageIds.clear();
for(int i=total-showSize+1;i<=total;i++){
pageIds.add(i);
}
}
}else if(total>num){
pageIds.clear();
if(num<showSize){
for(int i=1;i<=showSize;i++){
pageIds.add(i);
}
}else{
for(int i=num-2;i<=num+2;i++){
pageIds.add(i);
}
}
}
return pageIds;
}
} | [
"[email protected]"
] | |
80523a27092372319f52bb3de65644bc0555ca9c | 5e309ec1551901e0da258163b5ebb9defbe79e0f | /IDNP-CHAT-master/app/src/main/java/com/practica02/myapplication/Model/Persistencia/RestauranteDAO.java | 21d21c0d21fd7aef7a0c6e6ac66f4e0a423583ad | [] | no_license | rmanchego/IDNP-RESTOMATE | 30ecdc19b604f42aad7891b6af49f4b889caa609 | aea9aebb730491370e5c28a8f371431cbffacdab | refs/heads/master | 2022-12-01T07:07:08.047273 | 2020-08-11T07:47:31 | 2020-08-11T07:47:31 | 283,541,919 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,280 | java | package com.practica02.myapplication.Model.Persistencia;
import android.net.Uri;
import androidx.annotation.NonNull;
import com.google.android.gms.tasks.Continuation;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.auth.FirebaseUser;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import com.google.firebase.storage.FirebaseStorage;
import com.google.firebase.storage.StorageReference;
import com.google.firebase.storage.UploadTask;
import com.practica02.myapplication.Model.Entidades.Firebase.Restaurante;
import com.practica02.myapplication.Model.Entidades.Logica.LRestaurante;
import com.practica02.myapplication.Model.Utilidades.Constantes;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Locale;
public class RestauranteDAO {
public interface IDevolverRestaurante{
public void devolverRestaurante(LRestaurante lRestaurante);
public void devolverError(String error);
}
public interface IDevolverURLFoto{
public void devolverUrlString(String url);
}
private static RestauranteDAO restauranteDAO;
private FirebaseDatabase database;
private FirebaseStorage storage;
private DatabaseReference referenceRestaurantes;
private StorageReference referenceFotoDePerfil;
public static RestauranteDAO getInstancia(){
if(restauranteDAO==null) restauranteDAO = new RestauranteDAO();
return restauranteDAO;
}
private RestauranteDAO(){
database = FirebaseDatabase.getInstance();
storage = FirebaseStorage.getInstance();
referenceRestaurantes = database.getReference(Constantes.NODO_DE_RESTAURANTES);
referenceFotoDePerfil = storage.getReference("Fotos/FotoPerfil/Restaurantes/" + getKeyRestaurante());
}
public String getKeyRestaurante(){
return FirebaseAuth.getInstance().getUid();
}
public boolean isRestauranteLogeado(){
FirebaseUser firebaseUser = FirebaseAuth.getInstance().getCurrentUser();
return firebaseUser!=null;
}
public long fechaDeCreacionLong(){
return FirebaseAuth.getInstance().getCurrentUser().getMetadata().getCreationTimestamp();
}
public long fechaDeUltimaVezQueSeLogeoLong(){
return FirebaseAuth.getInstance().getCurrentUser().getMetadata().getLastSignInTimestamp();
}
public void obtenerInformacionDeRestaurantePorLlave(final String key, final RestauranteDAO.IDevolverRestaurante iDevolverRestaurante){
referenceRestaurantes.child(key).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
Restaurante restaurante = dataSnapshot.getValue(Restaurante.class);
LRestaurante lRestaurante = new LRestaurante(key,restaurante);
iDevolverRestaurante.devolverRestaurante(lRestaurante);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError){
iDevolverRestaurante.devolverError(databaseError.getMessage());
}
}); //ejecuta una sola vez, no tiene listener por si ocurre cambio
}
public void añadirFotoDePerfilALosRestaurantesQueNoTienenFoto() {
referenceRestaurantes.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
List<LRestaurante> lRestaurantesLista = new ArrayList<>();
for(DataSnapshot childDataSnapshot : dataSnapshot.getChildren()){
Restaurante restaurante = childDataSnapshot.getValue(Restaurante.class);
LRestaurante lRestaurante = new LRestaurante(childDataSnapshot.getKey(),restaurante);
lRestaurantesLista.add(lRestaurante);
}
for(LRestaurante lRestaurante : lRestaurantesLista){
if(lRestaurante.getRestaurante().getFotoPerfilURL()==null){
referenceRestaurantes.child(lRestaurante.getKey()).child("fotoPerfilURL").setValue(Constantes.URL_FOTO_POR_DEFECTO_USUARIOS);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
}); //Trae a todos los restaurantes solo una vez.
}
public void subirFotoUri(Uri uri, final RestauranteDAO.IDevolverURLFoto iDevolverURLFoto){ //Uri -> foto que se elige con el celular
String nombreFoto = "";
Date date = new Date();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("SSS.ss-mm-hh-dd-MM-yyyy", Locale.getDefault()); //Guardar en Firebase por fecha
nombreFoto = simpleDateFormat.format(date);
final StorageReference fotoReferencia = referenceFotoDePerfil.child(nombreFoto);
//Uri u = taskSnapshot.getDownloadUrl();
fotoReferencia.putFile(uri).continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if(!task.isSuccessful()){
throw task.getException(); //throw -> llama a la excepcion
}
return fotoReferencia.getDownloadUrl(); //Si se eligio una foto y se subio a la BD, agarra la url del archivo
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() { //este metodo captura la url de la foto
@Override
public void onComplete(@NonNull Task<Uri> task) {
if(task.isSuccessful()){
Uri uri = task.getResult(); //url de la foto que se sube a la BS
iDevolverURLFoto.devolverUrlString(uri.toString());
}
}
});
}
}
| [
"[email protected]"
] | |
809ab3967fc2095c17533682ee38814024ad1ffd | c104f6c85c7dd2e67967ac9a27ac199c7dd32c5d | /SpringInDepth/udemy-Step18/src/main/java/com/in28minutes/spring/basics/step18/Step18CdiApplication.java | dd925334122daa53e35027d69326848ad6daeeaf | [] | no_license | dario-boberek/udemyspring | 0cb5f03dd6b2a076bdd27c89f42b1f71f0ec3914 | 621c992f685b6474f5b67e4af1fe2def83dee8a6 | refs/heads/master | 2022-08-13T10:45:57.123339 | 2018-11-27T17:01:39 | 2018-11-27T17:01:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,208 | java | package com.in28minutes.spring.basics.step18;
import com.in28minutes.spring.basics.step18.cdi.PaymentProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import com.in28minutes.spring.basics.step18.cdi.SomeCdiBusiness;
@SpringBootApplication
public class Step18CdiApplication {
private static Logger LOGGER = LoggerFactory.getLogger(Step18CdiApplication.class);
public static void main(String[] args) {
new Step18CdiApplication().doIt(args);
}
public void doIt(String[] args) {
ApplicationContext applicationContext = SpringApplication.run(Step18CdiApplication.class, args);
//i21c: testujemy czy uzywajac ustandaryzowanych adnotacji z java zadziała DEPENDANCY INJECTION.
SomeCdiBusiness business = applicationContext.getBean(SomeCdiBusiness.class);
LOGGER.info("{} dao-{}", business, business.getSomeCDIDAO());
//i21c: moje takie tam..
PaymentProcessor paymentProcessor = applicationContext.getBean(PaymentProcessor.class);
paymentProcessor.addMoney("1000000", "GBP");
}
} | [
"[email protected]"
] | |
83531f123145865ba60dd0208421df1206fb646a | 0643fc1d290445abfeabd2db4c20a2a3ba4c5550 | /google-cloud-clients/google-cloud-compute/src/main/java/com/google/cloud/compute/v1/stub/InterconnectLocationStubSettings.java | 2d8929b980ded5ac4aabc0d468a1aedf8fbe151e | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | SanowerTamjit/google-cloud-java | 98d507530e2e0cf6f5b277d1b8d93e05ebb8eec2 | 28fab80ed42dcdf56bac22f67b6e262e3ad54cd2 | refs/heads/master | 2020-04-05T04:08:53.424185 | 2018-11-07T00:38:35 | 2018-11-07T00:38:35 | 156,539,437 | 1 | 0 | Apache-2.0 | 2018-11-07T11:55:22 | 2018-11-07T11:55:22 | null | UTF-8 | Java | false | false | 16,840 | java | /*
* Copyright 2018 Google LLC
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.compute.v1.stub;
import static com.google.cloud.compute.v1.InterconnectLocationClient.ListInterconnectLocationsPagedResponse;
import com.google.api.core.ApiFunction;
import com.google.api.core.ApiFuture;
import com.google.api.core.BetaApi;
import com.google.api.gax.core.GaxProperties;
import com.google.api.gax.core.GoogleCredentialsProvider;
import com.google.api.gax.core.InstantiatingExecutorProvider;
import com.google.api.gax.httpjson.GaxHttpJsonProperties;
import com.google.api.gax.httpjson.HttpJsonTransportChannel;
import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider;
import com.google.api.gax.retrying.RetrySettings;
import com.google.api.gax.rpc.ApiCallContext;
import com.google.api.gax.rpc.ApiClientHeaderProvider;
import com.google.api.gax.rpc.ClientContext;
import com.google.api.gax.rpc.PageContext;
import com.google.api.gax.rpc.PagedCallSettings;
import com.google.api.gax.rpc.PagedListDescriptor;
import com.google.api.gax.rpc.PagedListResponseFactory;
import com.google.api.gax.rpc.StatusCode;
import com.google.api.gax.rpc.StubSettings;
import com.google.api.gax.rpc.TransportChannelProvider;
import com.google.api.gax.rpc.UnaryCallSettings;
import com.google.api.gax.rpc.UnaryCallable;
import com.google.cloud.compute.v1.GetInterconnectLocationHttpRequest;
import com.google.cloud.compute.v1.InterconnectLocation;
import com.google.cloud.compute.v1.InterconnectLocationList;
import com.google.cloud.compute.v1.ListInterconnectLocationsHttpRequest;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import java.io.IOException;
import java.util.List;
import javax.annotation.Generated;
import org.threeten.bp.Duration;
// AUTO-GENERATED DOCUMENTATION AND CLASS
/**
* Settings class to configure an instance of {@link InterconnectLocationStub}.
*
* <p>The default instance has everything set to sensible defaults:
*
* <ul>
* <li>The default service address (https://www.googleapis.com/compute/v1/projects/) and default
* port (443) are used.
* <li>Credentials are acquired automatically through Application Default Credentials.
* <li>Retries are configured for idempotent methods but not for non-idempotent methods.
* </ul>
*
* <p>The builder of this class is recursive, so contained classes are themselves builders. When
* build() is called, the tree of builders is called to create the complete settings object. For
* example, to set the total timeout of getInterconnectLocation to 30 seconds:
*
* <pre>
* <code>
* InterconnectLocationStubSettings.Builder interconnectLocationSettingsBuilder =
* InterconnectLocationStubSettings.newBuilder();
* interconnectLocationSettingsBuilder.getInterconnectLocationSettings().getRetrySettings().toBuilder()
* .setTotalTimeout(Duration.ofSeconds(30));
* InterconnectLocationStubSettings interconnectLocationSettings = interconnectLocationSettingsBuilder.build();
* </code>
* </pre>
*/
@Generated("by gapic-generator")
@BetaApi
public class InterconnectLocationStubSettings
extends StubSettings<InterconnectLocationStubSettings> {
/** The default scopes of the service. */
private static final ImmutableList<String> DEFAULT_SERVICE_SCOPES =
ImmutableList.<String>builder()
.add("https://www.googleapis.com/auth/cloud-platform")
.add("https://www.googleapis.com/auth/compute")
.add("https://www.googleapis.com/auth/compute.readonly")
.add("https://www.googleapis.com/auth/devstorage.full_control")
.add("https://www.googleapis.com/auth/devstorage.read_only")
.add("https://www.googleapis.com/auth/devstorage.read_write")
.build();
private final UnaryCallSettings<GetInterconnectLocationHttpRequest, InterconnectLocation>
getInterconnectLocationSettings;
private final PagedCallSettings<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>
listInterconnectLocationsSettings;
/** Returns the object with the settings used for calls to getInterconnectLocation. */
public UnaryCallSettings<GetInterconnectLocationHttpRequest, InterconnectLocation>
getInterconnectLocationSettings() {
return getInterconnectLocationSettings;
}
/** Returns the object with the settings used for calls to listInterconnectLocations. */
public PagedCallSettings<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>
listInterconnectLocationsSettings() {
return listInterconnectLocationsSettings;
}
@BetaApi("A restructuring of stub classes is planned, so this may break in the future")
public InterconnectLocationStub createStub() throws IOException {
if (getTransportChannelProvider()
.getTransportName()
.equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
return HttpJsonInterconnectLocationStub.create(this);
} else {
throw new UnsupportedOperationException(
"Transport not supported: " + getTransportChannelProvider().getTransportName());
}
}
/** Returns a builder for the default ExecutorProvider for this service. */
public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() {
return InstantiatingExecutorProvider.newBuilder();
}
/** Returns the default service endpoint. */
public static String getDefaultEndpoint() {
return "https://www.googleapis.com/compute/v1/projects/";
}
/** Returns the default service port. */
public static int getDefaultServicePort() {
return 443;
}
/** Returns the default service scopes. */
public static List<String> getDefaultServiceScopes() {
return DEFAULT_SERVICE_SCOPES;
}
/** Returns a builder for the default credentials for this service. */
public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() {
return GoogleCredentialsProvider.newBuilder().setScopesToApply(DEFAULT_SERVICE_SCOPES);
}
/** Returns a builder for the default ChannelProvider for this service. */
public static InstantiatingHttpJsonChannelProvider.Builder
defaultHttpJsonTransportProviderBuilder() {
return InstantiatingHttpJsonChannelProvider.newBuilder();
}
public static TransportChannelProvider defaultTransportChannelProvider() {
return defaultHttpJsonTransportProviderBuilder().build();
}
@BetaApi("The surface for customizing headers is not stable yet and may change in the future.")
public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
return ApiClientHeaderProvider.newBuilder()
.setGeneratedLibToken(
"gapic", GaxProperties.getLibraryVersion(InterconnectLocationStubSettings.class))
.setTransportToken(
GaxHttpJsonProperties.getHttpJsonTokenName(),
GaxHttpJsonProperties.getHttpJsonVersion());
}
/** Returns a new builder for this class. */
public static Builder newBuilder() {
return Builder.createDefault();
}
/** Returns a new builder for this class. */
public static Builder newBuilder(ClientContext clientContext) {
return new Builder(clientContext);
}
/** Returns a builder containing all the values of this settings class. */
public Builder toBuilder() {
return new Builder(this);
}
protected InterconnectLocationStubSettings(Builder settingsBuilder) throws IOException {
super(settingsBuilder);
getInterconnectLocationSettings = settingsBuilder.getInterconnectLocationSettings().build();
listInterconnectLocationsSettings = settingsBuilder.listInterconnectLocationsSettings().build();
}
private static final PagedListDescriptor<
ListInterconnectLocationsHttpRequest, InterconnectLocationList, InterconnectLocation>
LIST_INTERCONNECT_LOCATIONS_PAGE_STR_DESC =
new PagedListDescriptor<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
InterconnectLocation>() {
@Override
public String emptyToken() {
return "";
}
@Override
public ListInterconnectLocationsHttpRequest injectToken(
ListInterconnectLocationsHttpRequest payload, String token) {
return ListInterconnectLocationsHttpRequest.newBuilder(payload)
.setPageToken(token)
.build();
}
@Override
public ListInterconnectLocationsHttpRequest injectPageSize(
ListInterconnectLocationsHttpRequest payload, int pageSize) {
return ListInterconnectLocationsHttpRequest.newBuilder(payload)
.setMaxResults(pageSize)
.build();
}
@Override
public Integer extractPageSize(ListInterconnectLocationsHttpRequest payload) {
return payload.getMaxResults();
}
@Override
public String extractNextToken(InterconnectLocationList payload) {
return payload.getNextPageToken();
}
@Override
public Iterable<InterconnectLocation> extractResources(
InterconnectLocationList payload) {
return payload.getItemsList();
}
};
private static final PagedListResponseFactory<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>
LIST_INTERCONNECT_LOCATIONS_PAGE_STR_FACT =
new PagedListResponseFactory<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>() {
@Override
public ApiFuture<ListInterconnectLocationsPagedResponse> getFuturePagedResponse(
UnaryCallable<ListInterconnectLocationsHttpRequest, InterconnectLocationList>
callable,
ListInterconnectLocationsHttpRequest request,
ApiCallContext context,
ApiFuture<InterconnectLocationList> futureResponse) {
PageContext<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
InterconnectLocation>
pageContext =
PageContext.create(
callable, LIST_INTERCONNECT_LOCATIONS_PAGE_STR_DESC, request, context);
return ListInterconnectLocationsPagedResponse.createAsync(
pageContext, futureResponse);
}
};
/** Builder for InterconnectLocationStubSettings. */
public static class Builder
extends StubSettings.Builder<InterconnectLocationStubSettings, Builder> {
private final ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders;
private final UnaryCallSettings.Builder<
GetInterconnectLocationHttpRequest, InterconnectLocation>
getInterconnectLocationSettings;
private final PagedCallSettings.Builder<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>
listInterconnectLocationsSettings;
private static final ImmutableMap<String, ImmutableSet<StatusCode.Code>>
RETRYABLE_CODE_DEFINITIONS;
static {
ImmutableMap.Builder<String, ImmutableSet<StatusCode.Code>> definitions =
ImmutableMap.builder();
definitions.put(
"idempotent",
ImmutableSet.copyOf(
Lists.<StatusCode.Code>newArrayList(
StatusCode.Code.DEADLINE_EXCEEDED, StatusCode.Code.UNAVAILABLE)));
definitions.put("non_idempotent", ImmutableSet.copyOf(Lists.<StatusCode.Code>newArrayList()));
RETRYABLE_CODE_DEFINITIONS = definitions.build();
}
private static final ImmutableMap<String, RetrySettings> RETRY_PARAM_DEFINITIONS;
static {
ImmutableMap.Builder<String, RetrySettings> definitions = ImmutableMap.builder();
RetrySettings settings = null;
settings =
RetrySettings.newBuilder()
.setInitialRetryDelay(Duration.ofMillis(100L))
.setRetryDelayMultiplier(1.3)
.setMaxRetryDelay(Duration.ofMillis(60000L))
.setInitialRpcTimeout(Duration.ofMillis(20000L))
.setRpcTimeoutMultiplier(1.0)
.setMaxRpcTimeout(Duration.ofMillis(20000L))
.setTotalTimeout(Duration.ofMillis(600000L))
.build();
definitions.put("default", settings);
RETRY_PARAM_DEFINITIONS = definitions.build();
}
protected Builder() {
this((ClientContext) null);
}
protected Builder(ClientContext clientContext) {
super(clientContext);
getInterconnectLocationSettings = UnaryCallSettings.newUnaryCallSettingsBuilder();
listInterconnectLocationsSettings =
PagedCallSettings.newBuilder(LIST_INTERCONNECT_LOCATIONS_PAGE_STR_FACT);
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
getInterconnectLocationSettings, listInterconnectLocationsSettings);
initDefaults(this);
}
private static Builder createDefault() {
Builder builder = new Builder((ClientContext) null);
builder.setTransportChannelProvider(defaultTransportChannelProvider());
builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build());
builder.setInternalHeaderProvider(defaultApiClientHeaderProviderBuilder().build());
builder.setEndpoint(getDefaultEndpoint());
return initDefaults(builder);
}
private static Builder initDefaults(Builder builder) {
builder
.getInterconnectLocationSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
builder
.listInterconnectLocationsSettings()
.setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("idempotent"))
.setRetrySettings(RETRY_PARAM_DEFINITIONS.get("default"));
return builder;
}
protected Builder(InterconnectLocationStubSettings settings) {
super(settings);
getInterconnectLocationSettings = settings.getInterconnectLocationSettings.toBuilder();
listInterconnectLocationsSettings = settings.listInterconnectLocationsSettings.toBuilder();
unaryMethodSettingsBuilders =
ImmutableList.<UnaryCallSettings.Builder<?, ?>>of(
getInterconnectLocationSettings, listInterconnectLocationsSettings);
}
// NEXT_MAJOR_VER: remove 'throws Exception'
/**
* Applies the given settings updater function to all of the unary API methods in this service.
*
* <p>Note: This method does not support applying settings to streaming methods.
*/
public Builder applyToAllUnaryMethods(
ApiFunction<UnaryCallSettings.Builder<?, ?>, Void> settingsUpdater) throws Exception {
super.applyToAllUnaryMethods(unaryMethodSettingsBuilders, settingsUpdater);
return this;
}
public ImmutableList<UnaryCallSettings.Builder<?, ?>> unaryMethodSettingsBuilders() {
return unaryMethodSettingsBuilders;
}
/** Returns the builder for the settings used for calls to getInterconnectLocation. */
public UnaryCallSettings.Builder<GetInterconnectLocationHttpRequest, InterconnectLocation>
getInterconnectLocationSettings() {
return getInterconnectLocationSettings;
}
/** Returns the builder for the settings used for calls to listInterconnectLocations. */
public PagedCallSettings.Builder<
ListInterconnectLocationsHttpRequest, InterconnectLocationList,
ListInterconnectLocationsPagedResponse>
listInterconnectLocationsSettings() {
return listInterconnectLocationsSettings;
}
@Override
public InterconnectLocationStubSettings build() throws IOException {
return new InterconnectLocationStubSettings(this);
}
}
}
| [
"[email protected]"
] | |
48d8ecc3ade6d231ca6172f94d8f30145615fce2 | f161bd84ec87c843da54c604efcadeb49bb91c79 | /Section16/src/com/samuelvazquez/optional/preview/FirstExample.java | 19e91f1d8b54e3b4ef6740b5f36de211bb975d78 | [] | no_license | samuelvazcal/Java-RelearningSessions-Exercises | dc86d58f21c0d3dbdc04f32c9aa29589dcd0fbf5 | 07190c1b1b9df86e3d7eaf19c654534db2f70960 | refs/heads/main | 2023-07-07T06:00:55.950805 | 2021-08-04T20:15:42 | 2021-08-04T20:15:42 | 358,030,679 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 483 | java | package src.com.samuelvazquez.optional.preview;
//String comparison with literals
public class FirstExample {
public static void main(String[] args) {
try {
String str1 = null;
if(str1.equals("sunday")) {
System.out.println("Same!");
} else {
System.out.println("Not same");
}
} catch (NullPointerException e) {
System.out.println("Caught: " + e);
}
}
}
| [
"[email protected]"
] | |
2cb4a2791c924721446cdab87d3538c59fbd284a | f1123bdb1e29def659a671cffd92c3d86da39722 | /core/src/test/java/org/elasticsearch/search/query/MultiMatchQueryIT.java | 36aa8d7b941b75306759f2dcd8d18437e9ed6e03 | [
"Apache-2.0"
] | permissive | q474818917/elasticsearch-2.3.5 | 075dfcd6dc175ce6a1f477b5f581a4e1ff2176fa | 15210e447f84d77c1fd6a5fb2df8cec2d56e2dda | refs/heads/master | 2022-08-12T12:02:48.663691 | 2019-07-23T06:10:05 | 2019-07-23T06:10:05 | 103,924,125 | 0 | 0 | Apache-2.0 | 2022-07-15T21:06:14 | 2017-09-18T10:15:22 | Java | UTF-8 | Java | false | false | 40,512 | java | /*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch 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.elasticsearch.search.query;
import com.carrotsearch.randomizedtesting.generators.RandomPicks;
import com.google.common.collect.Sets;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequestBuilder;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.elasticsearch.index.query.MatchQueryBuilder;
import org.elasticsearch.index.query.MultiMatchQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.SearchHits;
import org.elasticsearch.search.sort.SortBuilders;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
import org.junit.Before;
import org.junit.Test;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;
import static org.elasticsearch.common.settings.Settings.settingsBuilder;
import static org.elasticsearch.index.query.QueryBuilders.*;
import static org.elasticsearch.test.hamcrest.ElasticsearchAssertions.*;
import static org.hamcrest.Matchers.*;
public class MultiMatchQueryIT extends ESIntegTestCase {
@Before
public void init() throws Exception {
CreateIndexRequestBuilder builder = prepareCreate("test").setSettings(settingsBuilder()
.put(indexSettings())
.put(SETTING_NUMBER_OF_SHARDS, 1)
.put(SETTING_NUMBER_OF_REPLICAS, 0)
.put("index.analysis.analyzer.perfect_match.type", "custom")
.put("index.analysis.analyzer.perfect_match.tokenizer", "keyword")
.put("index.analysis.analyzer.perfect_match.filter", "lowercase")
.put("index.analysis.analyzer.category.type", "custom")
.put("index.analysis.analyzer.category.tokenizer", "whitespace")
.put("index.analysis.analyzer.category.filter", "lowercase")
);
assertAcked(builder.addMapping("test", createMapping()));
ensureGreen();
int numDocs = scaledRandomIntBetween(50, 100);
List<IndexRequestBuilder> builders = new ArrayList<>();
builders.add(client().prepareIndex("test", "test", "theone").setSource(
"full_name", "Captain America",
"first_name", "Captain",
"last_name", "America",
"category", "marvel hero",
"skill", 15,
"int-field", 25));
builders.add(client().prepareIndex("test", "test", "theother").setSource(
"full_name", "marvel hero",
"first_name", "marvel",
"last_name", "hero",
"category", "bogus",
"skill", 5));
builders.add(client().prepareIndex("test", "test", "ultimate1").setSource(
"full_name", "Alpha the Ultimate Mutant",
"first_name", "Alpha the",
"last_name", "Ultimate Mutant",
"category", "marvel hero",
"skill", 1));
builders.add(client().prepareIndex("test", "test", "ultimate2").setSource(
"full_name", "Man the Ultimate Ninja",
"first_name", "Man the Ultimate",
"last_name", "Ninja",
"category", "marvel hero",
"skill", 3));
builders.add(client().prepareIndex("test", "test", "anotherhero").setSource(
"full_name", "ultimate",
"first_name", "wolferine",
"last_name", "",
"category", "marvel hero",
"skill", 1));
List<String> firstNames = new ArrayList<>();
fill(firstNames, "Captain", between(15, 25));
fill(firstNames, "Ultimate", between(5, 10));
fillRandom(firstNames, between(3, 7));
List<String> lastNames = new ArrayList<>();
fill(lastNames, "Captain", between(3, 7));
fillRandom(lastNames, between(30, 40));
for (int i = 0; i < numDocs; i++) {
String first = RandomPicks.randomFrom(getRandom(), firstNames);
String last = randomPickExcept(lastNames, first);
builders.add(client().prepareIndex("test", "test", "" + i).setSource(
"full_name", first + " " + last,
"first_name", first,
"last_name", last,
"category", randomBoolean() ? "marvel hero" : "bogus",
"skill", between(1, 3)));
}
indexRandom(true, false, builders);
}
private XContentBuilder createMapping() throws IOException {
return XContentFactory.jsonBuilder().startObject().startObject("test")
.startObject("properties")
.startObject("full_name")
.field("type", "string")
.field("copy_to", "full_name_phrase")
.field("analyzer", "perfect_match")
.endObject()
.startObject("category")
.field("type", "string")
.field("analyzer", "category")
.endObject()
.startObject("first_name")
.field("type", "string")
.field("omit_norms", "true")
.field("copy_to", "first_name_phrase")
.endObject()
.startObject("last_name")
.field("type", "string")
.field("omit_norms", "true")
.field("copy_to", "last_name_phrase")
.endObject()
.endObject()
.endObject().endObject();
}
@Test
public void testDefaults() throws ExecutionException, InterruptedException {
MatchQueryBuilder.Type type = randomBoolean() ? null : MatchQueryBuilder.Type.BOOLEAN;
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR))).get();
Set<String> topNIds = Sets.newHashSet("theone", "theother");
for (int i = 0; i < searchResponse.getHits().hits().length; i++) {
topNIds.remove(searchResponse.getHits().getAt(i).getId());
// very likely that we hit a random doc that has the same score so orders are random since
// the doc id is the tie-breaker
}
assertThat(topNIds, empty());
assertThat(searchResponse.getHits().hits()[0].getScore(), equalTo(searchResponse.getHits().hits()[1].getScore()));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).useDisMax(false).type(type))).get();
assertFirstHit(searchResponse, anyOf(hasId("theone"), hasId("theother")));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).type(type))).get();
assertFirstHit(searchResponse, hasId("theother"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.AND).type(type))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.AND).type(type))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
}
@Test
public void testPhraseType() {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("Man the Ultimate", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase")
.operator(MatchQueryBuilder.Operator.OR).type(MatchQueryBuilder.Type.PHRASE))).get();
assertFirstHit(searchResponse, hasId("ultimate2"));
assertHitCount(searchResponse, 1l);
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("Captain", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase")
.operator(MatchQueryBuilder.Operator.OR).type(MatchQueryBuilder.Type.PHRASE))).get();
assertThat(searchResponse.getHits().getTotalHits(), greaterThan(1l));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("the Ul", "full_name_phrase", "first_name_phrase", "last_name_phrase", "category_phrase")
.operator(MatchQueryBuilder.Operator.OR).type(MatchQueryBuilder.Type.PHRASE_PREFIX))).get();
assertSearchHits(searchResponse, "ultimate2", "ultimate1");
assertHitCount(searchResponse, 2l);
}
@Test
public void testSingleField() throws NoSuchFieldException, IllegalAccessException {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill"))).get();
assertNoFailures(searchResponse);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill", "int-field")).analyzer("category")).get();
assertNoFailures(searchResponse);
assertFirstHit(searchResponse, hasId("theone"));
String[] fields = {"full_name", "first_name", "last_name", "last_name_phrase", "first_name_phrase", "category_phrase", "category"};
String[] query = {"marvel","hero", "captain", "america", "15", "17", "1", "5", "ultimate", "Man",
"marvel", "wolferine", "ninja"};
// check if it's equivalent to a match query.
int numIters = scaledRandomIntBetween(10, 100);
for (int i = 0; i < numIters; i++) {
String field = RandomPicks.randomFrom(getRandom(), fields);
int numTerms = randomIntBetween(1, query.length);
StringBuilder builder = new StringBuilder();
for (int j = 0; j < numTerms; j++) {
builder.append(RandomPicks.randomFrom(getRandom(), query)).append(" ");
}
MultiMatchQueryBuilder multiMatchQueryBuilder = randomizeType(multiMatchQuery(builder.toString(), field));
SearchResponse multiMatchResp = client().prepareSearch("test")
// _uid sort field is a tie, in case hits have the same score,
// the hits will be sorted the same consistently
.addSort("_score", SortOrder.DESC)
.addSort("_uid", SortOrder.ASC)
.setQuery(multiMatchQueryBuilder).get();
MatchQueryBuilder matchQueryBuilder = QueryBuilders.matchQuery(field, builder.toString());
if (getType(multiMatchQueryBuilder) != null) {
matchQueryBuilder.type(MatchQueryBuilder.Type.valueOf(getType(multiMatchQueryBuilder).matchQueryType().toString()));
}
SearchResponse matchResp = client().prepareSearch("test")
// _uid tie sort
.addSort("_score", SortOrder.DESC)
.addSort("_uid", SortOrder.ASC)
.setQuery(matchQueryBuilder).get();
assertThat("field: " + field + " query: " + builder.toString(), multiMatchResp.getHits().getTotalHits(), equalTo(matchResp.getHits().getTotalHits()));
SearchHits hits = multiMatchResp.getHits();
for (int j = 0; j < hits.hits().length; j++) {
assertThat(hits.getHits()[j].score(), equalTo(matchResp.getHits().getHits()[j].score()));
assertThat(hits.getHits()[j].getId(), equalTo(matchResp.getHits().getHits()[j].getId()));
}
}
}
@Test
public void testCutoffFreq() throws ExecutionException, InterruptedException {
final long numDocs = client().prepareCount("test")
.setQuery(matchAllQuery()).get().getCount();
MatchQueryBuilder.Type type = randomBoolean() ? null : MatchQueryBuilder.Type.BOOLEAN;
Float cutoffFrequency = randomBoolean() ? Math.min(1, numDocs * 1.f / between(10, 20)) : 1.f / between(10, 20);
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).cutoffFrequency(cutoffFrequency))).get();
Set<String> topNIds = Sets.newHashSet("theone", "theother");
for (int i = 0; i < searchResponse.getHits().hits().length; i++) {
topNIds.remove(searchResponse.getHits().getAt(i).getId());
// very likely that we hit a random doc that has the same score so orders are random since
// the doc id is the tie-breaker
}
assertThat(topNIds, empty());
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThanOrEqualTo(searchResponse.getHits().hits()[1].getScore()));
cutoffFrequency = randomBoolean() ? Math.min(1, numDocs * 1.f / between(10, 20)) : 1.f / between(10, 20);
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).useDisMax(false).cutoffFrequency(cutoffFrequency).type(type))).get();
assertFirstHit(searchResponse, anyOf(hasId("theone"), hasId("theother")));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
long size = searchResponse.getHits().getTotalHits();
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).useDisMax(false).type(type))).get();
assertFirstHit(searchResponse, anyOf(hasId("theone"), hasId("theother")));
assertThat("common terms expected to be a way smaller result set", size, lessThan(searchResponse.getHits().getTotalHits()));
cutoffFrequency = randomBoolean() ? Math.min(1, numDocs * 1.f / between(10, 20)) : 1.f / between(10, 20);
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.OR).cutoffFrequency(cutoffFrequency).type(type))).get();
assertFirstHit(searchResponse, hasId("theother"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.AND).cutoffFrequency(cutoffFrequency).type(type))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.AND).cutoffFrequency(cutoffFrequency).type(type))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero", "first_name", "last_name", "category")
.operator(MatchQueryBuilder.Operator.AND).cutoffFrequency(cutoffFrequency)
.analyzer("category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theother"));
}
@Test
public void testEquivalence() {
final int numDocs = (int) client().prepareCount("test")
.setQuery(matchAllQuery()).get().getCount();
int numIters = scaledRandomIntBetween(5, 10);
for (int i = 0; i < numIters; i++) {
{
MatchQueryBuilder.Type type = randomBoolean() ? null : MatchQueryBuilder.Type.BOOLEAN;
MultiMatchQueryBuilder multiMatchQueryBuilder = randomBoolean() ? multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category") :
multiMatchQuery("marvel hero captain america", "*_name", randomBoolean() ? "category" : "categ*");
SearchResponse left = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(randomizeType(multiMatchQueryBuilder
.operator(MatchQueryBuilder.Operator.OR).type(type))).get();
SearchResponse right = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(disMaxQuery().
add(matchQuery("full_name", "marvel hero captain america"))
.add(matchQuery("first_name", "marvel hero captain america"))
.add(matchQuery("last_name", "marvel hero captain america"))
.add(matchQuery("category", "marvel hero captain america"))
).get();
assertEquivalent("marvel hero captain america", left, right);
}
{
MatchQueryBuilder.Type type = randomBoolean() ? null : MatchQueryBuilder.Type.BOOLEAN;
String minShouldMatch = randomBoolean() ? null : "" + between(0, 1);
MatchQueryBuilder.Operator op = randomBoolean() ? MatchQueryBuilder.Operator.AND : MatchQueryBuilder.Operator.OR;
MultiMatchQueryBuilder multiMatchQueryBuilder = randomBoolean() ? multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category") :
multiMatchQuery("captain america", "*_name", randomBoolean() ? "category" : "categ*");
SearchResponse left = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(randomizeType(multiMatchQueryBuilder
.operator(op).useDisMax(false).minimumShouldMatch(minShouldMatch).type(type))).get();
SearchResponse right = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(boolQuery().minimumShouldMatch(minShouldMatch)
.should(randomBoolean() ? termQuery("full_name", "captain america") : matchQuery("full_name", "captain america").operator(op))
.should(matchQuery("first_name", "captain america").operator(op))
.should(matchQuery("last_name", "captain america").operator(op))
.should(matchQuery("category", "captain america").operator(op))
).get();
assertEquivalent("captain america", left, right);
}
{
String minShouldMatch = randomBoolean() ? null : "" + between(0, 1);
MatchQueryBuilder.Operator op = randomBoolean() ? MatchQueryBuilder.Operator.AND : MatchQueryBuilder.Operator.OR;
SearchResponse left = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(randomizeType(multiMatchQuery("capta", "full_name", "first_name", "last_name", "category")
.type(MatchQueryBuilder.Type.PHRASE_PREFIX).useDisMax(false).minimumShouldMatch(minShouldMatch))).get();
SearchResponse right = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(boolQuery().minimumShouldMatch(minShouldMatch)
.should(matchPhrasePrefixQuery("full_name", "capta"))
.should(matchPhrasePrefixQuery("first_name", "capta").operator(op))
.should(matchPhrasePrefixQuery("last_name", "capta").operator(op))
.should(matchPhrasePrefixQuery("category", "capta").operator(op))
).get();
assertEquivalent("capta", left, right);
}
{
String minShouldMatch = randomBoolean() ? null : "" + between(0, 1);
MatchQueryBuilder.Operator op = randomBoolean() ? MatchQueryBuilder.Operator.AND : MatchQueryBuilder.Operator.OR;
SearchResponse left;
if (randomBoolean()) {
left = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.type(MatchQueryBuilder.Type.PHRASE).useDisMax(false).minimumShouldMatch(minShouldMatch))).get();
} else {
left = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.type(MatchQueryBuilder.Type.PHRASE).tieBreaker(1.0f).minimumShouldMatch(minShouldMatch))).get();
}
SearchResponse right = client().prepareSearch("test").setSize(numDocs)
.addSort(SortBuilders.scoreSort()).addSort(SortBuilders.fieldSort("_uid"))
.setQuery(boolQuery().minimumShouldMatch(minShouldMatch)
.should(matchPhraseQuery("full_name", "captain america"))
.should(matchPhraseQuery("first_name", "captain america").operator(op))
.should(matchPhraseQuery("last_name", "captain america").operator(op))
.should(matchPhraseQuery("category", "captain america").operator(op))
).get();
assertEquivalent("captain america", left, right);
}
}
}
@Test
public void testCrossFieldMode() throws ExecutionException, InterruptedException {
SearchResponse searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.OR))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero captain america", "full_name", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.OR))).get();
assertFirstHit(searchResponse, hasId("theone"));
assertSecondHit(searchResponse, hasId("theother"));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("marvel hero", "full_name", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.OR))).get();
assertFirstHit(searchResponse, hasId("theother"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america", "full_name", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america 15", "full_name", "first_name", "last_name", "category", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america 15", "full_name", "first_name", "last_name", "category", "skill", "int-field")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america 15", "skill", "full_name", "first_name", "last_name", "category", "int-field")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america 15", "first_name", "last_name", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("25 15", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("25 15", "int-field", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("25 15", "first_name", "int-field", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("25 15", "int-field", "skill", "first_name")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("25 15", "int-field", "first_name", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category"))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.cutoffFrequency(0.1f)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.OR))).get();
assertFirstHit(searchResponse, anyOf(hasId("theother"), hasId("theone")));
long numResults = searchResponse.getHits().totalHits();
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.OR))).get();
assertThat(numResults, lessThan(searchResponse.getHits().getTotalHits()));
assertFirstHit(searchResponse, hasId("theone"));
// test group based on analyzer -- all fields are grouped into a cross field search
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.analyzer("category")
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 1l);
assertFirstHit(searchResponse, hasId("theone"));
// counter example
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category")
.type(randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : null)
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 0l);
// counter example
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("captain america marvel hero", "first_name", "last_name", "category")
.type(randomBoolean() ? MultiMatchQueryBuilder.Type.CROSS_FIELDS : null)
.operator(MatchQueryBuilder.Operator.AND))).get();
assertHitCount(searchResponse, 0l);
// test if boosts work
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("the ultimate", "full_name", "first_name", "last_name^2", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.AND))).get();
assertFirstHit(searchResponse, hasId("ultimate1")); // has ultimate in the last_name and that is boosted
assertSecondHit(searchResponse, hasId("ultimate2"));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
// since we try to treat the matching fields as one field scores are very similar but we have a small bias towards the
// more frequent field that acts as a tie-breaker internally
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("the ultimate", "full_name", "first_name", "last_name", "category")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.operator(MatchQueryBuilder.Operator.AND))).get();
assertFirstHit(searchResponse, hasId("ultimate2"));
assertSecondHit(searchResponse, hasId("ultimate1"));
assertThat(searchResponse.getHits().hits()[0].getScore(), greaterThan(searchResponse.getHits().hits()[1].getScore()));
// Test group based on numeric fields
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "skill", "first_name")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get();
assertFirstHit(searchResponse, hasId("theone"));
// Two numeric fields together caused trouble at one point!
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "int-field", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("15", "int-field", "first_name", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS))).get();
assertFirstHit(searchResponse, hasId("theone"));
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("alpha 15", "first_name", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.lenient(true))).get();
assertFirstHit(searchResponse, hasId("ultimate1"));
/*
* Doesn't find theone because "alpha 15" isn't a number and we don't
* break on spaces.
*/
assertHitCount(searchResponse, 1);
// Lenient wasn't always properly lenient with two numeric fields
searchResponse = client().prepareSearch("test")
.setQuery(randomizeType(multiMatchQuery("alpha 15", "int-field", "first_name", "skill")
.type(MultiMatchQueryBuilder.Type.CROSS_FIELDS)
.lenient(true))).get();
assertFirstHit(searchResponse, hasId("ultimate1"));
}
private static final void assertEquivalent(String query, SearchResponse left, SearchResponse right) {
assertNoFailures(left);
assertNoFailures(right);
SearchHits leftHits = left.getHits();
SearchHits rightHits = right.getHits();
assertThat(leftHits.getTotalHits(), equalTo(rightHits.getTotalHits()));
assertThat(leftHits.getHits().length, equalTo(rightHits.getHits().length));
SearchHit[] hits = leftHits.getHits();
SearchHit[] rHits = rightHits.getHits();
for (int i = 0; i < hits.length; i++) {
assertThat("query: " + query + " hit: " + i, (double) hits[i].getScore(), closeTo(rHits[i].getScore(), 0.00001d));
}
for (int i = 0; i < hits.length; i++) {
if (hits[i].getScore() == hits[hits.length - 1].getScore()) {
return; // we need to cut off here since this is the tail of the queue and we might not have fetched enough docs
}
assertThat("query: " + query, hits[i].getId(), equalTo(rHits[i].getId()));
}
}
public static List<String> fill(List<String> list, String value, int times) {
for (int i = 0; i < times; i++) {
list.add(value);
}
return list;
}
public List<String> fillRandom(List<String> list, int times) {
for (int i = 0; i < times; i++) {
list.add(randomRealisticUnicodeOfCodepointLengthBetween(1, 5));
}
return list;
}
public <T> T randomPickExcept(List<T> fromList, T butNot) {
while (true) {
T t = RandomPicks.randomFrom(getRandom(), fromList);
if (t.equals(butNot)) {
continue;
}
return t;
}
}
public MultiMatchQueryBuilder randomizeType(MultiMatchQueryBuilder builder) {
try {
MultiMatchQueryBuilder.Type type = getType(builder);
if (type == null && randomBoolean()) {
return builder;
}
if (type == null) {
type = MultiMatchQueryBuilder.Type.BEST_FIELDS;
}
if (randomBoolean()) {
builder.type(type);
} else {
Object oType = type;
switch (type) {
case BEST_FIELDS:
if (randomBoolean()) {
oType = MatchQueryBuilder.Type.BOOLEAN;
}
break;
case MOST_FIELDS:
if (randomBoolean()) {
oType = MatchQueryBuilder.Type.BOOLEAN;
}
break;
case CROSS_FIELDS:
break;
case PHRASE:
if (randomBoolean()) {
oType = MatchQueryBuilder.Type.PHRASE;
}
break;
case PHRASE_PREFIX:
if (randomBoolean()) {
oType = MatchQueryBuilder.Type.PHRASE_PREFIX;
}
break;
}
builder.type(oType);
}
return builder;
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
private MultiMatchQueryBuilder.Type getType(MultiMatchQueryBuilder builder) throws NoSuchFieldException, IllegalAccessException {
return builder.getType();
}
}
| [
"[email protected]"
] | |
cf55de698590fdfc4a2269fb858ebe147cd98125 | 551306c208dbfc6f3fc51cabde4ab74478cc9834 | /question1/TrimClient.java | 1348cc2218d846ecfcbbf093f225229e2979d4fe | [] | no_license | liorshahverdi/java-client-server-demo | 088a2b6abe752899dbb14e7b430401dc1ccab463 | db5f27be3fe8a27fc0f09ea5a1608a4a285e2988 | refs/heads/master | 2016-09-10T22:25:08.558996 | 2014-12-03T22:37:59 | 2014-12-03T22:37:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,804 | java | /**
* TrimClient
* Reads strings and returns similar string with whitespace omitted.
*
* Invoke as: java TrimClient [-port=<number>] [server]
* Default port is 1200, if not specified
* Default host is localhost, if not specified
*
* @author (Lior Shahverdi)
* @version (Version 1.1 12/02/2014)
*/
import java.io.*;
import java.net.*;
public class TrimClient
{
public static void main (String [] args)
{
Socket s; //Client socket for connecting to the server
String server = "localhost"; //Use localhost by default
int serverPort = 1200; //Use port 1200 by default
InetAddress local, remote; //Local and remote addresses
int localPort, remotePort; //Local and remote ports
//For input and output
BufferedReader socketIn; //Socket input
PrintWriter socketOut; //Socket output
BufferedReader keyboardIn; //Keyboard input
String userInput, serverResult;
//Process command line arguments
//Error if more than two command line arguments
if (args.length > 2)
{
System.out.println("Usage: java TrimClient "
+ "[-port=<number>] [server]");
System.exit(-1);
}
//If two arguments, only one should start with '-'
if (args.length == 2)
{
if ((args[0].charAt(0) == '-' &&
args[1].charAt(0) == '-' ) ||
(args[0].charAt(0) != '-' &&
args[1].charAt(0) != '-' ))
{
System.out.println("Usage: "
+ "java TrimClient "
+ "[-port=<number>] [server]");
System.exit(-1);
}
}
//Set the server and server port suitably
for (int i = 0; i < args.length; i++)
{
if (args[i].charAt(0) != '-')
server = args[i];
if (args[i].startsWith("-port="))
serverPort = Integer.parseInt(args[i].substring(6));
}
//Set up keyboard input and print greeting
keyboardIn = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Hello, you have invoked a Trim Client");
System.out.println("You have requested a connection to " +
server + " at port " + serverPort);
System.out.println(); //Blank line
//Establish socket connection and communicate
try
{
//Establish connection
s = new Socket(server, serverPort);
//Report connection status
local = s.getLocalAddress(); remote = s.getInetAddress();
localPort = s.getLocalPort(); remotePort = s.getPort();
System.out.println ("Client side");
System.out.println (" " + local.getHostName()
+ "[" + local.getHostAddress() + "]"
+ " at port " + localPort);
System.out.println ("Server side");
System.out.println (" " + remote.getHostName()
+ "[" + remote.getHostAddress() + "]"
+ " at port " + remotePort);
System.out.println(); //Blank line
//TCP provides a full-duplex byte stream service
//For UNICODE and line support, we need BufferedReader
//and PrintWriter objects
socketIn = new BufferedReader(new InputStreamReader(s.getInputStream()));
socketOut = new PrintWriter(s.getOutputStream(), true);
//Interact with user
System.out.print("Enter a string (or bye to quit): ");
userInput = keyboardIn.readLine();
//Loop until user indicates termination
while (!userInput.equalsIgnoreCase("bye"))
{
//Send user input to server
socketOut.println(userInput);
//Get server response
serverResult = socketIn.readLine();
//Report server response
System.out.println(serverResult);
System.out.println(); //Blank line
//Get new string
System.out.print("Enter a string (or bye to quit): ");
userInput = keyboardIn.readLine();
}
//Signal the server to quit
socketOut.println(userInput);
//Close all streams and socket
keyboardIn.close();
socketIn.close();
socketOut.close();
s.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
826255f560a14f3e684a53685c990427760035b3 | 6a9b474b2de2d11aebb2e1e64c297fdc72c14675 | /src/dao/QuestionDao.java | d6a35083e3717545079487caf40dac8ea6afa153 | [] | no_license | khushalishah/CampusTalk | b5c2548b1542d056aa53d65d08a78b097e837ab0 | cbfbd8f42623b0f2c66ba46852126cb88a12ad07 | refs/heads/master | 2021-08-31T08:12:24.827836 | 2017-12-20T18:37:52 | 2017-12-20T18:37:52 | 114,815,416 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,127 | java | package dao;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import vo.NoticeVo;
import vo.QuestionVo;
import db.Database;
public class QuestionDao extends CTDao {
@Override
public List<Object> view(long id) {
// TODO Auto-generated method stub
Database db = new Database();
Session session = db.getSession();
Transaction tx = null;
List<Object> que_ans = new ArrayList<>();
try {
tx = session.beginTransaction();
que_ans = session.createQuery("from QuestionVo order by question_date asc").list();
tx.commit();
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
System.out.println(e);
} finally {
db.closeSession(session);
}
return que_ans;
}
@Override
public void delete(Object id) {
// TODO Auto-generated method stub
// type-casting
int ID = (int) id;
Database db = new Database();
Session session = db.getSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
QuestionVo question = (QuestionVo) session.get(QuestionVo.class, ID);
session.delete(question);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
}
@Override
public void edit(Object o) {
// TODO Auto-generated method stub
QuestionVo qv = (QuestionVo) o;
Database db = new Database();
Session session = db.getSession();
Transaction tx = null;
try {
tx = session.beginTransaction();
QuestionVo question = (QuestionVo) session.get(QuestionVo.class, qv.getQuestion_id());
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String qDate = sdf.format(date);
question.setQuestion_date(qDate);
question.setQuestion_department(qv.getQuestion_department());
question.setQuestion_semester(qv.getQuestion_semester());
question.setQuestion_name(qv.getQuestion_name());
question.setQuestion_title(qv.getQuestion_title());
session.update(question);
tx.commit();
} catch (HibernateException e) {
if (tx != null)
tx.rollback();
e.printStackTrace();
} finally {
session.close();
}
}
public List<Object[]> viewAll(String search){
Database db = new Database();
Session session = db.getSession();
Transaction tx = null;
List<Object[]> que_ans = new ArrayList<>();
try {
tx = session.beginTransaction();
que_ans = session
.createQuery(
"SELECT q.question_id,q.question_title,q.question_date,c.ansID,c.answer,c.date,c.department,c.semester,c.name FROM QuestionVo AS q LEFT JOIN q.children c WHERE q.question_title LIKE '%"+search+"%' order by q.question_date desc")
.list();
// questions = session.createQuery("FROM QuestionVo where
// question_enrollment="+id).list();
tx.commit();
} catch (Exception e) {
if (tx != null) {
tx.rollback();
}
System.out.println(e);
} finally {
db.closeSession(session);
}
return que_ans;
}
}
| [
"[email protected]"
] | |
eeb4dc02d3775a360ab737d37c301c3107b697e4 | cfbf8fc182dc2ca0c2fb7a3805f7095042ab256c | /tesla-java-client/src/main/java/org/oxbow/tesla/BaseService.java | f0b06c0fc0b4db5866a85b043e758ce9124ae2b3 | [] | no_license | eugener/tesla-java-api | 8487dc36e606de230805595419edc509c2ce4033 | afb45b34b83448eb2b1e97126d44051a487c168b | refs/heads/master | 2023-04-27T00:54:23.605449 | 2020-02-26T22:14:40 | 2020-02-26T22:14:40 | 152,005,539 | 0 | 1 | null | 2023-04-23T13:16:02 | 2018-10-08T02:09:33 | Java | UTF-8 | Java | false | false | 1,880 | java | package org.oxbow.tesla;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import retrofit2.Call;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.function.Function;
class BaseService {
private static final Gson GSON = new Gson();
<T> T asResponse(Call<Response<T>> call ) {
return executeCall(call).content;
}
<T> T asResult(Call<Response<Result<T>>> call ) {
return asResponse(call).result;
}
<T> T executeCall(Call<T> call ) {
return executeCall(call, RuntimeException::new, RuntimeException::new );
}
<T> T executeCall(Call<T> call,
Function<Throwable,RuntimeException> fromCause,
Function<String,RuntimeException> fromText) {
try {
retrofit2.Response<T> response = Objects.requireNonNull( call ).execute();
if ( response.isSuccessful() ) {
return response.body();
} else {
String errorJson = new String( Objects.requireNonNull(response.errorBody()).bytes(), StandardCharsets.UTF_8);
Error error = GSON.fromJson(errorJson, Error.class );
throw produceException( fromText, error.message);
}
} catch (IOException e) {
throw produceException( fromCause, e);
}
}
private <T> RuntimeException produceException(Function<T,RuntimeException> producer, T value ) {
return producer != null ? producer.apply(value) : new RuntimeException("Exception producer is null");
}
}
class Response<T> {
@SerializedName("response")
final T content = null;
}
class Result<T> {
@SerializedName("result")
final T result = null;
}
class Error {
@SerializedName("error")
final String message = null;
}
| [
"[email protected]"
] | |
c7343bdc9deaa700f0b3394b4044ddf89647cf3c | 7a4d5fad2cca674f66c3f6d22bf8abda75b8b67c | /src/main/java/org/teststompwebsocket/util/AuthenticationMsg.java | 77a8883073cd86665c3d484bba8845e1563df26a | [] | no_license | desertfoxzhou/teststompwebsocket | ae8f7508c4b5fce481bd9d81c8b7af7d845c2ae5 | 1fe208f421baa135accc15693140d77cfb9de9ef | refs/heads/master | 2021-01-11T02:03:02.320556 | 2016-06-13T21:05:06 | 2016-06-13T21:05:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 975 | java | package org.teststompwebsocket.util;
import java.io.Serializable;
import java.util.Map;
/**
* Authentication Message.
*
* @author Sergey Stotskiy
*
*/
@SuppressWarnings("serial")
public class AuthenticationMsg implements Serializable {
private String type;
private String sequence_id;
private Map<String, String> data;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getSequence_id() {
return sequence_id;
}
public void setSequence_id(String sequence_id) {
this.sequence_id = sequence_id;
}
public Map<String, String> getData() {
return data;
}
public void setData(Map<String, String> data) {
this.data = data;
}
@Override
public String toString() {
return "AuthenticationMsg [type=" + type + ", sequence_id=" + sequence_id
+ ", data=" + data + "]";
}
}
| [
"[email protected]"
] | |
75be71fe9dc9894296d7cd8a2d83bad6149cf1d5 | d959dda05e794a7382572ffe4cda83fc824088b5 | /app/src/androidTest/java/com/example/rizwansyed/menudemo/ExampleInstrumentedTest.java | 61ba1e462a6490b18536115c9f4d013a6e5b083b | [] | no_license | Rizwansyed9/MenuDemo | 47e37d39b31c4817d1c1576aa14be7f8ba68180d | 4bdc26b37640c0ea1a53097073a4533645358af7 | refs/heads/master | 2021-01-11T00:36:08.601909 | 2016-10-10T16:57:54 | 2016-10-10T16:57:54 | 70,509,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 766 | java | package com.example.rizwansyed.menudemo;
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.rizwansyed.menudemo", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
31a9f898d8d885fb861c9a07c5e57228c4362019 | d2d6189b2ffb66ab70c68b51fa5a67d5991a4718 | /src/main/java/br/execute/ecommerce/web/rest/PedidoResource.java | c2a75789c562c9c9197443cebda02d155713cd3a | [] | no_license | ingridfr/ecommerce-simples | 67a254a14c1fb3c826e1aecba38c02ffbcbde363 | 40d492e074787015286407abbb7e779eec32818e | refs/heads/main | 2023-07-08T02:31:57.472362 | 2021-08-10T19:38:35 | 2021-08-10T19:38:35 | 394,738,110 | 0 | 0 | null | 2021-08-10T19:38:36 | 2021-08-10T17:59:11 | Java | UTF-8 | Java | false | false | 8,863 | java | package br.execute.ecommerce.web.rest;
import br.execute.ecommerce.repository.PedidoRepository;
import br.execute.ecommerce.service.PedidoQueryService;
import br.execute.ecommerce.service.PedidoService;
import br.execute.ecommerce.service.criteria.PedidoCriteria;
import br.execute.ecommerce.service.dto.PedidoDTO;
import br.execute.ecommerce.web.rest.errors.BadRequestAlertException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import tech.jhipster.web.util.HeaderUtil;
import tech.jhipster.web.util.PaginationUtil;
import tech.jhipster.web.util.ResponseUtil;
/**
* REST controller for managing {@link br.execute.ecommerce.domain.Pedido}.
*/
@RestController
@RequestMapping("/api")
public class PedidoResource {
private final Logger log = LoggerFactory.getLogger(PedidoResource.class);
private static final String ENTITY_NAME = "pedido";
@Value("${jhipster.clientApp.name}")
private String applicationName;
private final PedidoService pedidoService;
private final PedidoRepository pedidoRepository;
private final PedidoQueryService pedidoQueryService;
public PedidoResource(PedidoService pedidoService, PedidoRepository pedidoRepository, PedidoQueryService pedidoQueryService) {
this.pedidoService = pedidoService;
this.pedidoRepository = pedidoRepository;
this.pedidoQueryService = pedidoQueryService;
}
/**
* {@code POST /pedidos} : Create a new pedido.
*
* @param pedidoDTO the pedidoDTO to create.
* @return the {@link ResponseEntity} with status {@code 201 (Created)} and with body the new pedidoDTO, or with status {@code 400 (Bad Request)} if the pedido has already an ID.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@PostMapping("/pedidos")
public ResponseEntity<PedidoDTO> createPedido(@RequestBody PedidoDTO pedidoDTO) throws URISyntaxException {
log.debug("REST request to save Pedido : {}", pedidoDTO);
if (pedidoDTO.getId() != null) {
throw new BadRequestAlertException("A new pedido cannot already have an ID", ENTITY_NAME, "idexists");
}
PedidoDTO result = pedidoService.save(pedidoDTO);
return ResponseEntity
.created(new URI("/api/pedidos/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(applicationName, true, ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* {@code PUT /pedidos/:id} : Updates an existing pedido.
*
* @param id the id of the pedidoDTO to save.
* @param pedidoDTO the pedidoDTO to update.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated pedidoDTO,
* or with status {@code 400 (Bad Request)} if the pedidoDTO is not valid,
* or with status {@code 500 (Internal Server Error)} if the pedidoDTO couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@PutMapping("/pedidos/{id}")
public ResponseEntity<PedidoDTO> updatePedido(
@PathVariable(value = "id", required = false) final Long id,
@RequestBody PedidoDTO pedidoDTO
) throws URISyntaxException {
log.debug("REST request to update Pedido : {}, {}", id, pedidoDTO);
if (pedidoDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
if (!Objects.equals(id, pedidoDTO.getId())) {
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
}
if (!pedidoRepository.existsById(id)) {
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
}
PedidoDTO result = pedidoService.save(pedidoDTO);
return ResponseEntity
.ok()
.headers(HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, pedidoDTO.getId().toString()))
.body(result);
}
/**
* {@code PATCH /pedidos/:id} : Partial updates given fields of an existing pedido, field will ignore if it is null
*
* @param id the id of the pedidoDTO to save.
* @param pedidoDTO the pedidoDTO to update.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the updated pedidoDTO,
* or with status {@code 400 (Bad Request)} if the pedidoDTO is not valid,
* or with status {@code 404 (Not Found)} if the pedidoDTO is not found,
* or with status {@code 500 (Internal Server Error)} if the pedidoDTO couldn't be updated.
* @throws URISyntaxException if the Location URI syntax is incorrect.
*/
@PatchMapping(value = "/pedidos/{id}", consumes = "application/merge-patch+json")
public ResponseEntity<PedidoDTO> partialUpdatePedido(
@PathVariable(value = "id", required = false) final Long id,
@RequestBody PedidoDTO pedidoDTO
) throws URISyntaxException {
log.debug("REST request to partial update Pedido partially : {}, {}", id, pedidoDTO);
if (pedidoDTO.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
if (!Objects.equals(id, pedidoDTO.getId())) {
throw new BadRequestAlertException("Invalid ID", ENTITY_NAME, "idinvalid");
}
if (!pedidoRepository.existsById(id)) {
throw new BadRequestAlertException("Entity not found", ENTITY_NAME, "idnotfound");
}
Optional<PedidoDTO> result = pedidoService.partialUpdate(pedidoDTO);
return ResponseUtil.wrapOrNotFound(
result,
HeaderUtil.createEntityUpdateAlert(applicationName, true, ENTITY_NAME, pedidoDTO.getId().toString())
);
}
/**
* {@code GET /pedidos} : get all the pedidos.
*
* @param pageable the pagination information.
* @param criteria the criteria which the requested entities should match.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the list of pedidos in body.
*/
@GetMapping("/pedidos")
public ResponseEntity<List<PedidoDTO>> getAllPedidos(PedidoCriteria criteria, Pageable pageable) {
log.debug("REST request to get Pedidos by criteria: {}", criteria);
Page<PedidoDTO> page = pedidoQueryService.findByCriteria(criteria, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(ServletUriComponentsBuilder.fromCurrentRequest(), page);
return ResponseEntity.ok().headers(headers).body(page.getContent());
}
/**
* {@code GET /pedidos/count} : count all the pedidos.
*
* @param criteria the criteria which the requested entities should match.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and the count in body.
*/
@GetMapping("/pedidos/count")
public ResponseEntity<Long> countPedidos(PedidoCriteria criteria) {
log.debug("REST request to count Pedidos by criteria: {}", criteria);
return ResponseEntity.ok().body(pedidoQueryService.countByCriteria(criteria));
}
/**
* {@code GET /pedidos/:id} : get the "id" pedido.
*
* @param id the id of the pedidoDTO to retrieve.
* @return the {@link ResponseEntity} with status {@code 200 (OK)} and with body the pedidoDTO, or with status {@code 404 (Not Found)}.
*/
@GetMapping("/pedidos/{id}")
public ResponseEntity<PedidoDTO> getPedido(@PathVariable Long id) {
log.debug("REST request to get Pedido : {}", id);
Optional<PedidoDTO> pedidoDTO = pedidoService.findOne(id);
return ResponseUtil.wrapOrNotFound(pedidoDTO);
}
/**
* {@code DELETE /pedidos/:id} : delete the "id" pedido.
*
* @param id the id of the pedidoDTO to delete.
* @return the {@link ResponseEntity} with status {@code 204 (NO_CONTENT)}.
*/
@DeleteMapping("/pedidos/{id}")
public ResponseEntity<Void> deletePedido(@PathVariable Long id) {
log.debug("REST request to delete Pedido : {}", id);
pedidoService.delete(id);
return ResponseEntity
.noContent()
.headers(HeaderUtil.createEntityDeletionAlert(applicationName, true, ENTITY_NAME, id.toString()))
.build();
}
}
| [
"[email protected]"
] | |
0cb35409e0775f5603f3728609d41dac4e6af774 | 632c52b66bcddf212c3ea18903b5d0a2accf25d2 | /src/academy/belhard/entity/Planes.java | 8b32224119bf81e274d0f799a087e9d6af066724 | [] | no_license | Dzmitry20/Airport_project | 6a477d3e4260656a2ab258b4b7582f059db48585 | e97b9145d673ce182f5d566c2bd1838916464ad9 | refs/heads/main | 2023-02-04T01:03:59.049301 | 2020-12-22T08:34:24 | 2020-12-22T08:34:24 | 320,518,022 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,461 | java | package academy.belhard.entity;
public class Planes {
private int id;
private String mark;
private String model;
private int capacity;
private String board_number;
public Planes(int id, String mark, String model, int capacity, String board_number) {
this.id = id;
this.mark = mark;
this.model = model;
this.capacity = capacity;
this.board_number = board_number;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getMark() {
return mark;
}
public void setMark(String mark) {
this.mark = mark;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getCapacity() {
return capacity;
}
public void setCapacity(int capacity) {
this.capacity = capacity;
}
public String getBoard_number() {
return board_number;
}
public void setBoard_number(String board_number) {
this.board_number = board_number;
}
@Override
public String toString() {
return "Planes{" +
"id=" + id +
", marka='" + mark + '\'' +
", model='" + model + '\'' +
", capacity=" + capacity +
", board_number='" + board_number + '\'' +
'}';
}
}
| [
"[email protected]"
] | |
46c2a9f2f015c28246b174639a68dd691564c819 | 26d9db01850c2566ed26172850c6877fd1612af1 | /day-6/src/main/java/com/duckelekuuk/aoc/DaySixPartOne.java | 1452738b64859d4974ec4332d497595adfc2041a | [] | no_license | Duckelekuuk/AdventOfCode2020 | fdeffcfbc4c3e0a3726bab4f889848529004c3b6 | cf1dd73080f189866c78cae52b812d00a9b645a9 | refs/heads/master | 2023-01-28T16:18:19.251552 | 2020-12-12T15:50:18 | 2020-12-12T15:50:18 | 317,651,488 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,269 | java | package com.duckelekuuk.aoc;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class DaySixPartOne {
public static void main(String[] args) {
int count = 0;
Set<String> characterGroup = new HashSet<>();
for (String line : getInput("input.txt").collect(Collectors.toList())) {
if (line.isEmpty()) {
count += characterGroup.size();
characterGroup.clear();
continue;
}
characterGroup.addAll(Arrays.asList(line.split("")));
}
count += characterGroup.size();
System.out.println("Count: " + count);
}
public static Stream<String> getInput(String resourceName) {
InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(resourceName);
if (inputStream == null) {
throw new IllegalArgumentException("Resource not found");
}
BufferedReader reader = new BufferedReader(new BufferedReader(new InputStreamReader(inputStream)));
return reader.lines();
}
}
| [
"[email protected]"
] | |
1d34044f9f42a4c60dafbfb45459d319f348cc9f | a322d862e170704b4008a8f70bd358d900ae6fa0 | /huaweicloud-dis-flink-connector_2.11/src/main/java/org/apache/flink/streaming/connectors/dis/internals/DisPartitionDiscoverer.java | 684e30571c25ade4d7ef4b781b85361fcff87fc6 | [
"Apache-2.0"
] | permissive | huaweicloud/flink-dis-plugin | 134b09b3f693edc4a43c753ef7f8e3683f105399 | 63325802db7d076d0778b17dc1218b512c28b5f0 | refs/heads/master | 2023-08-28T20:56:52.374235 | 2022-07-08T08:39:23 | 2022-07-08T08:39:23 | 199,606,177 | 3 | 7 | Apache-2.0 | 2022-07-08T08:39:24 | 2019-07-30T08:11:02 | Java | UTF-8 | Java | false | false | 4,509 | 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.flink.streaming.connectors.dis.internals;
import com.huaweicloud.dis.adapter.kafka.clients.consumer.Consumer;
import com.huaweicloud.dis.adapter.kafka.clients.consumer.ConsumerRebalanceListener;
import com.huaweicloud.dis.adapter.kafka.clients.consumer.DISKafkaConsumer;
import com.huaweicloud.dis.adapter.kafka.common.PartitionInfo;
import com.huaweicloud.dis.adapter.kafka.common.TopicPartition;
import org.apache.flink.annotation.Internal;
import java.util.*;
import static org.apache.flink.util.Preconditions.checkNotNull;
/**
* A partition discoverer that can be used to discover topics and partitions metadata
* from DIS using DIS Kafka Adapter.
*/
@Internal
public class DisPartitionDiscoverer extends AbstractPartitionDiscoverer {
private final Properties kafkaProperties;
private final DisStreamsDescriptor topicsDescriptor;
private Consumer<?, ?> kafkaConsumer;
public DisPartitionDiscoverer(
DisStreamsDescriptor topicsDescriptor,
int indexOfThisSubtask,
int numParallelSubtasks,
Properties kafkaProperties) {
super(topicsDescriptor, indexOfThisSubtask, numParallelSubtasks);
this.topicsDescriptor = topicsDescriptor;
this.kafkaProperties = checkNotNull(kafkaProperties);
}
@Override
protected void initializeConnections() {
this.kafkaConsumer = new DISKafkaConsumer<>(kafkaProperties);
ConsumerRebalanceListener consumerRebalanceListener = new ConsumerRebalanceListener() {
@Override
public void onPartitionsRevoked(Collection<TopicPartition> collection) {
}
@Override
public void onPartitionsAssigned(Collection<TopicPartition> collection) {
kafkaConsumer.pause(collection);
}
};
if (this.topicsDescriptor.isFixedTopics()) {
this.kafkaConsumer.subscribe(topicsDescriptor.getFixedTopics(), consumerRebalanceListener);
} else if (this.topicsDescriptor.isTopicPattern()) {
this.kafkaConsumer.subscribe(this.topicsDescriptor.getTopicPattern(), consumerRebalanceListener);
} else {
throw new IllegalArgumentException("Illegal " + topicsDescriptor.toString());
}
}
@Override
protected List<String> getAllTopics() throws WakeupException {
return new ArrayList<>(kafkaConsumer.listTopics().keySet());
}
@Override
protected List<DisStreamPartition> getAllPartitionsForTopics(List<String> topics) throws WakeupException {
List<DisStreamPartition> partitions = new LinkedList<>();
for (String topic : topics) {
final List<PartitionInfo> kafkaPartitions = kafkaConsumer.partitionsFor(topic);
if (kafkaPartitions == null) {
throw new RuntimeException(
String.format(
"Could not fetch partitions for %s. Make sure that the stream exists.",
topic));
}
for (PartitionInfo partitionInfo : kafkaPartitions) {
partitions.add(new DisStreamPartition(partitionInfo.topic(), partitionInfo.partition()));
}
}
return partitions;
}
@Override
protected void wakeupConnections() {
if (this.kafkaConsumer != null) {
this.kafkaConsumer.wakeup();
}
}
@Override
protected void closeConnections() throws Exception {
if (this.kafkaConsumer != null) {
this.kafkaConsumer.close();
// de-reference the consumer to avoid closing multiple times
this.kafkaConsumer = null;
}
}
}
| [
"[email protected]"
] | |
f6ca3f150462be12c126591bf34bef55e820f1e5 | 5e6eac37384fb8928b53b457ae359fd89b84d3da | /Euges-1.0/ihm/PageAccueilIHM.java | 0bc3a4498a1c9d41b5a1a8309f3853edc772cefd | [] | no_license | BackupTheBerlios/eugesproject | c1e572b1313077d67360489ace848118671c7ae9 | be6992a22174a5f053d5ee98782c3d8b4d9e6134 | refs/heads/master | 2020-06-03T05:59:38.118461 | 2005-03-25T08:28:09 | 2005-03-25T08:28:09 | 40,045,087 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,304 | java | /*
* Created on 27 nov. 2003
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package ihm;
import java.util.ResourceBundle;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import configuration.Config;
/**
* @author will
*
* To change the template for this generated type comment go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
public class PageAccueilIHM extends PageAssistantIHM{
private ResourceBundle message = ResourceBundle.getBundle(Config.config.getProperty("cheminTraduction") + "." + Config.locale.getLanguage() + getClass().getName().substring(getClass().getName().lastIndexOf('.')), Config.locale);
//definition des boutons activés pour l'assistant
final boolean[] tab={false,false,true,false,true};
public PageAccueilIHM(final Shell shell) {
//appel du constructeur de la classe composite
super(shell);
//mise en place du layout
GridLayout gridLayout = new GridLayout();
gridLayout.numColumns=1;
this.setLayout(gridLayout);
//titre
Font font = new Font(getDisplay(), "Arial", 15, 15);
Label titre = new Label(this, SWT.NONE);
titre.setFont(font);
titre.setText(message.getString("pageAccueilIHM.titre"));
titre.pack();
//champ texte
Text presentation = new Text(this, SWT.BORDER | SWT.WRAP | SWT.MULTI);
presentation.setText(message.getString("pageAccueilIHM.texte"));
presentation.setEnabled(false);
//titre
GridData gridData1 = new GridData();
titre.setLayoutData(gridData1);
//champ texte
gridData1 = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
presentation.setLayoutData(gridData1);
//activation des boutons
set_activeBoutons(tab);
}
/* (non-Javadoc)
* @see ihm.PageAssistantIHM#verifDonnees()
*/
public boolean verifDonnees() {
return true;
}
/* (non-Javadoc)
* @see ihm.PageAssistantIHM#loadData()
*/
public void loadData() {
// TODO Auto-generated method stub
}
}
| [
"euges8"
] | euges8 |
86210d71f6347dae1be5c7abbf47a8ece5dbb7bb | 783ed06f346658907d93712893f045bdf3dc3a39 | /AnyclipHW/src/test/java/tests/repository/Repository.java | 1a6246933860e94f414908017235b18f37a32b65 | [] | no_license | VIxela/AnyclipHW | 8deb41abff58966097b691a31eda6d354d15ea37 | a24daeb068cd1fd180947fa39268affe0f30ee84 | refs/heads/main | 2023-06-28T19:31:29.149672 | 2021-08-01T18:33:41 | 2021-08-01T18:33:41 | 391,707,719 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 756 | java | package tests.repository;
public interface Repository {
String START_URL = "https://bootsnipp.com/login";
String LOGIN_BUTTON = "//*[@class='btn btn-lg btn-success btn-block']";
String EMAIL_INPUT = "//*[@class='form-control email-title']";
String EMAIL = "[email protected]";
String EMAIL1 = "[email protected]";
String PASSWORD_INPUT = " //*[@class='form-control']";
String PASSWORD = "cospp02b";
String PASSWORD1 = "cospp02b";
String REMEMBER_ME_CHECKBOX = "//*[@name='remember']";
String PROFILE = "(//a[contains(text(),'Profile')])[1]";
String LOGIN = "(//a[contains(text(),'Login')])[1]";
String LOGOUT = "//a[contains(text(),'Logout')]";
Boolean REMEMBER_ME =true;
}
| [
"[email protected]"
] | |
7167a306e67c959c08629fdeedbcd742d88eb977 | e4ef2c13308bb89888cab43097b02a3299a63e7f | /app/src/main/java/com/ngliaxl/encrypt/util/FileComparator.java | eeb5ebc2d1016af7a79b8a02f50e7cbc1bac26b8 | [] | no_license | ngLiaXL/FileEncryptor | 14a478237d8d7d81fe76e31b3c6bc744719fb737 | 8e8d8a5a492c27fbf220f5a3d3b7dbf7c0518cc4 | refs/heads/master | 2021-01-23T01:52:31.438861 | 2017-06-02T05:46:07 | 2017-06-02T05:46:07 | 92,899,050 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 667 | java | package com.ngliaxl.encrypt.util;
import java.io.File;
import java.util.Comparator;
/**
* Created by Dimorinny on 24.10.15.
*/
public class FileComparator implements Comparator<File> {
@Override
public int compare(File f1, File f2) {
if (f1 == f2) {
return 0;
}
if (f1.isDirectory() && f2.isFile()) {
// Show directories above files
return -1;
}
if (f1.isFile() && f2.isDirectory()) {
// Show files below directories
return 1;
}
// Sort the directories alphabetically
return f1.getName().compareToIgnoreCase(f2.getName());
}
}
| [
"[email protected]"
] | |
454bfd1aa3f6c4d7e4de9753cf5c6c54d518d5da | 1968a8cbb561158105ab17a82212fbad7c774863 | /nabook/src/main/java/com/nabook/constants/Constant.java | 57d20aee84166b525a8df5841cac32ef19aeac3e | [] | no_license | phantoan/liferay7 | e2dddb4586edb40c2eeb8d9418ccb400a2bff66f | 8b01586297cd70100134145bfb4e5f3915296fea | refs/heads/master | 2021-06-13T03:38:31.141804 | 2017-02-20T00:28:46 | 2017-02-20T00:28:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 156 | java | /**
*
*/
package com.nabook.constants;
/**
* @author Phan Toan
*
*/
public class Constant {
public static final String abc= "asdads";
}
| [
"[email protected]"
] | |
2639ef22e5a6fad96a6b9767d7429dbd660698f3 | 476c7d76eae6b69a836b1e3d13aa1b6116e50359 | /gmall-mbg/src/main/java/com/mars/gmall/oms/mapper/CartItemMapper.java | 19c77783b941e6763b31596212ed308d4ad4cf28 | [] | no_license | lwx666666/mars-gmall | 603559c79b69ce096327102a9492583d60148930 | 115db6d5d9da4065f0f98a8d1d815fc0be0105ef | refs/heads/master | 2022-06-22T03:26:05.725191 | 2020-01-19T15:41:12 | 2020-01-19T15:41:12 | 234,536,643 | 0 | 0 | null | 2022-06-21T02:40:04 | 2020-01-17T11:40:20 | Java | UTF-8 | Java | false | false | 295 | java | package com.mars.gmall.oms.mapper;
import com.mars.gmall.oms.entity.CartItem;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 购物车表 Mapper 接口
* </p>
*
* @author Mars
* @since 2020-01-17
*/
public interface CartItemMapper extends BaseMapper<CartItem> {
}
| [
"[email protected]"
] | |
e8cc58214d07572b65ceab0262af255d01f9c7a1 | 0b4761f05abd931823a3dfc32f855b533e8e0411 | /src/tasks/interceptors/AutenticadorInterceptor.java | 18c1e3fc9b560232ff47d9e272075b7660347388 | [] | no_license | Joneswc/javaspring | 40f93bc8c5a3655807b4aa27f42c9c5b0256ecc2 | 6acb24b86bf1b1d94d9cb3ee04b5eedc3bbd7d66 | refs/heads/master | 2020-05-30T13:33:09.188523 | 2019-06-20T22:06:33 | 2019-06-20T22:06:33 | 189,764,045 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 876 | java | package tasks.interceptors;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
public class AutenticadorInterceptor extends HandlerInterceptorAdapter {
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object controller) throws Exception {
String uri = request.getRequestURI(); // endereço da requisição daquele recurso
if (uri.endsWith("formlogin") || uri.endsWith("getlogin") || uri.contains("resources")) {
return true;
}
// se a lógica de login verificou que aquele login e senha, existem no banco, foi adicionado um 'usuário logado na sessão'
if (request.getSession().getAttribute("usuariologado") != null ) {
return true;
}
response.sendRedirect("formlogin");
return false;
}
}
| [
"[email protected]"
] | |
f9964991db9b667501adee920e09275e71dad37e | 99c02e8c0429ffbae9bce95decbf8f3befb09d12 | /myResource/src/main/java/com/longe/myresource/view/AndroidBug5497Workaround.java | 6624107dc51dabc80c2a7645ef46324c200a0c34 | [] | no_license | zuoguiqing/BottomNavDemo | d281c4e9a37a9d20db9e4fef126e34c5d59dd2ca | 0028eeb699b60de854aaf56d7dfebd2fa6f2837e | refs/heads/master | 2020-03-10T05:11:37.146018 | 2018-04-13T02:52:48 | 2018-04-13T02:52:48 | 129,211,641 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,231 | java | package com.longe.myresource.view;
import android.app.Activity;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
/**
* Created by si on 05/07/2017.
*/
public class AndroidBug5497Workaround {
// For more information, see https://code.google.com/p/android/issues/detail?id=5497
// To use this class, simply invoke assistActivity() on an Activity that already has its content view set.
public static void assistActivity (Activity activity) {
new AndroidBug5497Workaround(activity);
}
private View mChildOfContent;
private int usableHeightPrevious;
private FrameLayout.LayoutParams frameLayoutParams;
private AndroidBug5497Workaround(Activity activity) {
FrameLayout content = (FrameLayout) activity.findViewById(android.R.id.content);
mChildOfContent = content.getChildAt(0);
mChildOfContent.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
public void onGlobalLayout() {
possiblyResizeChildOfContent();
}
});
frameLayoutParams = (FrameLayout.LayoutParams) mChildOfContent.getLayoutParams();
}
private void possiblyResizeChildOfContent() {
int usableHeightNow = computeUsableHeight();
if (usableHeightNow != usableHeightPrevious) {
int usableHeightSansKeyboard = mChildOfContent.getRootView().getHeight();
int heightDifference = usableHeightSansKeyboard - usableHeightNow;
if (heightDifference > (usableHeightSansKeyboard/4)) {
// keyboard probably just became visible
frameLayoutParams.height = usableHeightSansKeyboard - heightDifference;
} else {
// keyboard probably just became hidden
frameLayoutParams.height = usableHeightSansKeyboard;
}
mChildOfContent.requestLayout();
usableHeightPrevious = usableHeightNow;
}
}
private int computeUsableHeight() {
Rect r = new Rect();
mChildOfContent.getWindowVisibleDisplayFrame(r);
return (r.bottom - r.top);
}
}
| [
"[email protected]"
] | |
4fe9a0077a27359fbdb7f9cb348c2414d48aae8b | 865193e72ce3f81293e5006814b465f607b44416 | /core/folioxml/src/folioxml/export/ExportingNodeListProcessor.java | 27491becc6d3d28df72faae5853ebf9c8d40eb43 | [
"Apache-2.0"
] | permissive | imazen/folioxml | f2a0ce3498134d843527fd6f8220b980723db487 | de441f7bf464db5575c8e571c17639a257092b27 | refs/heads/master | 2022-12-17T05:48:25.059236 | 2022-10-18T05:17:20 | 2022-10-18T05:17:20 | 25,088,312 | 11 | 7 | Apache-2.0 | 2018-05-16T19:33:27 | 2014-10-11T17:31:49 | Java | UTF-8 | Java | false | false | 325 | java | package folioxml.export;
import folioxml.config.ExportLocations;
/**
* Created by nathanael on 6/25/15.
*/
public interface ExportingNodeListProcessor extends NodeListProcessor {
void setFileNode(FileNode fn);
void setLogProvider(LogStreamProvider provider);
void setExportLocations(ExportLocations el);
}
| [
"[email protected]"
] | |
27a9694e60bceb5efbc49498fe27293497cd3d4b | c1d5603c524da1ced7a6f479ec8098c4fc7e57c5 | /src/main/java/ro/uvt/mrbs/models/Detail.java | 7db98fe5e3b4c1267a742e2ccac791ab3c0d5f31 | [
"Apache-2.0"
] | permissive | ZbRoby/Meeting-Room-Booking-System | c1f8dbf70f1f8763c1c8ee501e22baae471f3470 | 5395ec160943dfda2443c3734ace1925ab5fb4a3 | refs/heads/master | 2021-09-04T09:01:14.225186 | 2018-01-17T14:30:52 | 2018-01-17T14:30:52 | 115,860,843 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 407 | java | package ro.uvt.mrbs.models;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
*
* @author Zbiera Alexandru-Robert
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Detail {
private String lastname;
private String firstname;
private String email;
private String phone;
private List<OutBoundBook> books;
}
| [
"[email protected]"
] | |
c2a2e4e5f80f328d31d9e12a9913dfbf36282d66 | de4090699ca1c5bce1c6660ac20d89c7a76d7b21 | /Hello_World.java | 57782cefe9db93dd948575d7b7c28f0cf8685e10 | [] | no_license | anne871101/test_git | b9a913760b620b06bb023245a2e57d5183c0ebbf | c41d17fc62784c6f5639342ac41305753f3bd459 | refs/heads/master | 2021-01-18T16:22:36.880157 | 2014-09-07T23:54:02 | 2014-09-07T23:54:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 111 | java | public class Hello_World {
public static main(String[] args) {
System.out.println("HELLO WORLD");
}
}
| [
"[email protected]"
] | |
f9d28edc2657605d4a906ef42b2e9882ca5dfcd2 | 9ec3045b736ce00789db5c5d8fc6a0cd9edaa197 | /src/Java8Test/scratch.java | f3fad9e14b58077f536ae7328cfe0f7e18355956 | [] | no_license | anujachockalingam/fun-coding | f72003deffd8aafc180a30ff59a3d4dc79a5e183 | b15363e98b39150af62c0f7c7888278c4864f583 | refs/heads/master | 2022-12-24T16:24:13.700888 | 2020-10-01T20:56:30 | 2020-10-01T20:56:30 | 296,708,815 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,240 | java | package Java8Test;
import java.util.*;
class Java8Tester {
public static void main(String[] args) {
List<String> names1 = new ArrayList<String>();
names1.add("Mahesh ");
names1.add("Suresh ");
names1.add("Ramesh ");
names1.add("Naresh ");
names1.add("Kalpesh ");
List<String> names2 = new ArrayList<String>();
names2.add("Mahesh ");
names2.add("Suresh ");
names2.add("Ramesh ");
names2.add("Naresh ");
names2.add("Kalpesh ");
Java8Tester tester = new Java8Tester();
System.out.println("Sort using Java 7 syntax: ");
tester.sortUsingJava7(names1);
System.out.println(names1);
System.out.println("Sort using Java 8 syntax: ");
tester.sortUsingJava8(names2);
System.out.println(names2);
}
private void sortUsingJava8(List<String> names) {
Collections.sort(names, (s1,s2) -> s1.compareTo(s2));
}
private void sortUsingJava7(List<String> names) {
Collections.sort(names, new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o1.compareTo(o2);
}
});
}
} | [
"[email protected]"
] | |
e7e42e24e7f8fd52301f7a72b0f52e4110b35476 | ba7ea425a956d6ed74d7d52549c6c660071e312d | /stub-idp/src/main/java/uk/gov/ida/stub/idp/resources/singleidp/SingleIdpPreRegistrationResource.java | e8a19775c3bdeb6caf84af38729dce8ecaf9054e | [
"MIT",
"LicenseRef-scancode-proprietary-license"
] | permissive | willp-bl/verify-stub-idp | a7860f1854f414ee0ba0c5d2620bf0cd77f8a11a | bfbf554b4d73c45e434cc9c1c2117d0388145069 | refs/heads/monorepo | 2023-07-06T01:46:02.867893 | 2019-02-19T16:15:04 | 2019-02-19T16:15:04 | 128,985,826 | 0 | 1 | MIT | 2019-09-25T20:43:39 | 2018-04-10T19:37:08 | Java | UTF-8 | Java | false | false | 3,026 | java | package uk.gov.ida.stub.idp.resources.singleidp;
import uk.gov.ida.common.SessionId;
import uk.gov.ida.stub.idp.Urls;
import uk.gov.ida.stub.idp.cookies.CookieFactory;
import uk.gov.ida.stub.idp.repositories.Idp;
import uk.gov.ida.stub.idp.repositories.IdpSession;
import uk.gov.ida.stub.idp.repositories.IdpSessionRepository;
import uk.gov.ida.stub.idp.repositories.IdpStubsRepository;
import uk.gov.ida.stub.idp.views.CancelPreRegistrationPageView;
import uk.gov.ida.stub.idp.views.ErrorMessageType;
import uk.gov.ida.stub.idp.views.RegistrationPageView;
import javax.inject.Inject;
import javax.validation.constraints.NotNull;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.Optional;
import java.util.UUID;
import static uk.gov.ida.stub.idp.views.ErrorMessageType.NO_ERROR;
@Path(Urls.SINGLE_IDP_PRE_REGISTER_RESOURCE)
@Produces(MediaType.TEXT_HTML)
public class SingleIdpPreRegistrationResource {
private final IdpStubsRepository idpStubsRepository;
private final CookieFactory cookieFactory;
private final IdpSessionRepository idpSessionRepository;
@Inject
public SingleIdpPreRegistrationResource(
IdpStubsRepository idpStubsRepository, CookieFactory cookieFactory, IdpSessionRepository idpSessionRepository) {
this.idpStubsRepository = idpStubsRepository;
this.cookieFactory = cookieFactory;
this.idpSessionRepository = idpSessionRepository;
}
@GET
@Path(Urls.SINGLE_IDP_PRE_REGISTER_CANCEL_PATH)
@Produces(MediaType.TEXT_HTML)
public Response getPreRegisterCancel(
@PathParam(Urls.IDP_ID_PARAM) @NotNull String idpName,
@QueryParam(Urls.ERROR_MESSAGE_PARAM) Optional<ErrorMessageType> errorMessage) {
Idp idp = idpStubsRepository.getIdpWithFriendlyId(idpName);
return Response.ok(new CancelPreRegistrationPageView(idp.getDisplayName(), idp.getFriendlyId(), errorMessage.orElse(NO_ERROR).getMessage(), idp.getAssetId())).build();
}
@GET
public Response getPreRegister(
@PathParam(Urls.IDP_ID_PARAM) @NotNull String idpName,
@QueryParam(Urls.ERROR_MESSAGE_PARAM) Optional<ErrorMessageType> errorMessage) {
Idp idp = idpStubsRepository.getIdpWithFriendlyId(idpName);
IdpSession session = new IdpSession(
new SessionId(UUID.randomUUID().toString()));
final SessionId sessionId = idpSessionRepository.createSession(session);
idpSessionRepository.updateSession(session.getSessionId(), session.setNewCsrfToken());
return Response.ok(new RegistrationPageView(idp.getDisplayName(), idp.getFriendlyId(), errorMessage.orElse(NO_ERROR).getMessage(), idp.getAssetId(), Urls.SINGLE_IDP_PRE_REGISTER_PATH, session.getCsrfToken()))
.cookie(cookieFactory.createSessionIdCookie(sessionId))
.build();
}
}
| [
"[email protected]"
] | |
49fdcdd12b6b2ab000357c61cdd033f3b6861708 | 009851d339fcf6ecec8e725cf2c47a71ae747639 | /src/main/java/org/notification/module/InitializeUsers.java | a563a1062c0d385cb21a61690407e998734414fb | [] | no_license | nupur-singhal1992/Notificationn_Module | 6c9dddbc4bc71663d7927800cb990a9241fc9103 | bf889dd6bd79fbee4c1826033389a40295420b5b | refs/heads/master | 2022-12-27T02:05:14.696601 | 2020-05-21T16:13:41 | 2020-05-21T16:13:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,056 | java | package org.notification.module;
import org.notification.module.entities.LogBean;
import org.notification.module.entities.User;
import org.notification.module.entities.UserForLog;
import org.notification.module.enums.CommunicationMode;
import org.notification.module.enums.LogType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.notification.module.repository.LogBeanRepository;
import org.notification.module.repository.UserForLogRepository;
import org.notification.module.repository.UserRepository;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
@Service
public class InitializeUsers {
@Autowired
private UserRepository userRepository;
@Autowired
private LogBeanRepository logBeanRepository;
@Autowired
private UserForLogRepository userForLogRepository;
public void initializeUsers() {
User user1 = new User();
user1.setName("nupur");
user1.setEmail("[email protected]");
// user1.setPassword("thisIsMe6#");
user1.setMobileNo(new BigInteger("7829840398"));
user1.setAlertSubscriptionTaken(true);
user1 = userRepository.save(user1);
List<CommunicationMode> communicationModes = new ArrayList<>();
// communicationModes.add(CommunicationMode.SMS);
communicationModes.add(CommunicationMode.EMAIL);
LogBean logBeanForUser1 = new LogBean();
logBeanForUser1.setLogType(LogType.Warning);
logBeanForUser1.setDuration(10);
logBeanForUser1.setFrequency(30);
logBeanForUser1.setWaitTime(100);
logBeanForUser1.setCommunicationModes(communicationModes);
logBeanForUser1 = logBeanRepository.save(logBeanForUser1);
UserForLog userForLog = new UserForLog();
userForLog.setLogType(logBeanForUser1.getLogType());
userForLog.setLogId(logBeanForUser1.getId());
userForLog.setUserId(user1.getId());
userForLogRepository.save(userForLog);
}
}
| [
"[email protected]"
] | |
09a2334db1039116ced4e999de901be4aabec836 | 1aef4669e891333de303db570c7a690c122eb7dd | /src/main/java/com/alipay/api/response/KoubeiTradeOrderEnterpriseSettleResponse.java | 858073c88a654ce6f29d389f0b0d624265cbb06b | [
"Apache-2.0"
] | permissive | fossabot/alipay-sdk-java-all | b5d9698b846fa23665929d23a8c98baf9eb3a3c2 | 3972bc64e041eeef98e95d6fcd62cd7e6bf56964 | refs/heads/master | 2020-09-20T22:08:01.292795 | 2019-11-28T08:12:26 | 2019-11-28T08:12:26 | 224,602,331 | 0 | 0 | Apache-2.0 | 2019-11-28T08:12:26 | 2019-11-28T08:12:25 | null | UTF-8 | Java | false | false | 1,250 | java | package com.alipay.api.response;
import com.alipay.api.internal.mapping.ApiField;
import com.alipay.api.AlipayResponse;
/**
* ALIPAY API: koubei.trade.order.enterprise.settle response.
*
* @author auto create
* @since 1.0, 2019-03-29 18:50:02
*/
public class KoubeiTradeOrderEnterpriseSettleResponse extends AlipayResponse {
private static final long serialVersionUID = 5748128488453659294L;
/**
* 描述本次返回中的业务属性,该字段用于描述本次返回中的业务属性,现有:BIZ_ALREADY_SUCCESS(幂等业务码)
*/
@ApiField("biz_code")
private String bizCode;
/**
* 口碑订单号
*/
@ApiField("order_no")
private String orderNo;
/**
* 传入的商户订单号
*/
@ApiField("out_order_no")
private String outOrderNo;
public void setBizCode(String bizCode) {
this.bizCode = bizCode;
}
public String getBizCode( ) {
return this.bizCode;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getOrderNo( ) {
return this.orderNo;
}
public void setOutOrderNo(String outOrderNo) {
this.outOrderNo = outOrderNo;
}
public String getOutOrderNo( ) {
return this.outOrderNo;
}
}
| [
"[email protected]"
] | |
b73d7ab7ccd267e54ecd4afb7a4276ba6c56b5a9 | e85ffdc21ce39468fd3a3e4a1eafa6aaf5cc855a | /src/attack/special/Hurricane.java | cd1907f2e357cd9288ccf7858675b79a0ea55549 | [] | no_license | Nanachi07/SumerIntenseLabWork2 | 9c02381b5d12f73b91a93be3645922afa056761b | 4898c6f0c0121ad1f6c5b245937601ad7da94912 | refs/heads/master | 2022-12-03T09:15:34.717376 | 2020-07-29T15:41:35 | 2020-07-29T15:41:35 | 282,186,306 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 442 | java | package attack.special;
import ru.ifmo.se.pokemon.*;
public class Hurricane extends PhysicalMove {
public Hurricane() {
super(Type.FLYING, 110, 70);
}
public static void confuse(Pokemon p) {
Effect effect = new Effect().chance(0.3);
if (effect.success())
System.out.println(true);
confuse(p);
}
protected String describe() {
return "CONFUSE WITH HURRICANE!";
}
} | [
"[email protected]"
] | |
e43d977452b9fe1fa421692ab189aab8604abe60 | 9daed01d61bb9dea18d3cc6fa97ded5a13b28d53 | /app/src/main/java/pratice/asia/nextop/tabsmaterial/MyApplication.java | 6a8bac8f2d0272d7b77915f12605e4b1d3d77f65 | [] | no_license | RohidanTiger/TabsMaterial | 38d5c7c5fe1ebb0624a5fcfca67c5f65b79624c2 | 3565361a012c00fecca4e3d50731b42eba7a60f6 | refs/heads/master | 2021-01-19T12:04:46.843869 | 2017-06-30T08:52:03 | 2017-06-30T08:52:03 | 88,017,145 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,732 | java | package pratice.asia.nextop.tabsmaterial;
import android.app.Application;
import android.text.TextUtils;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.Volley;
import nextop.asia.pratise.util.LruBitmapCache;
/**
* Created by billymobile on 11/18/15.
*/
public class MyApplication extends Application{
public static final String TAG = MyApplication.class
.getSimpleName();
private RequestQueue mRequestQueue;
private ImageLoader mImageLoader;
private static MyApplication mInstance;
@Override
public void onCreate() {
super.onCreate();
mInstance = this;
}
public static synchronized MyApplication getInstance() {
return mInstance;
}
public RequestQueue getRequestQueue() {
if (mRequestQueue == null) {
mRequestQueue = Volley.newRequestQueue(getApplicationContext());
}
return mRequestQueue;
}
public ImageLoader getImageLoader() {
getRequestQueue();
if (mImageLoader == null) {
mImageLoader = new ImageLoader(this.mRequestQueue,
new LruBitmapCache());
}
return this.mImageLoader;
}
public <T> void addToRequestQueue(Request<T> req, String tag) {
req.setTag(TextUtils.isEmpty(tag) ? TAG : tag);
getRequestQueue().add(req);
}
public <T> void addToRequestQueue(Request<T> req) {
req.setTag(TAG);
getRequestQueue().add(req);
}
public void cancelPendingRequests(Object tag) {
if (mRequestQueue != null) {
mRequestQueue.cancelAll(tag);
}
}
}
| [
"[email protected]"
] | |
6d771598538d646cb0a4de3600983e45e43f2dad | 88c76d0ed062c7cc4217a59e5d11566dd5ed9daf | /app/src/main/java/agoption/projetos/com/agoption/helper/ConfiguracaoBanco.java | 264d6caae90af77869edbfa3f6424b56e0aec362 | [] | no_license | FabioSousaFBS/AGOption | 5efe8f783388203340d748cb09d9b555d41c21a4 | 47ccb8d2d13fa770bb9c6f363a8fc3d064ab1acb | refs/heads/master | 2021-01-24T03:57:59.183645 | 2018-04-18T02:47:07 | 2018-04-18T02:47:07 | 122,913,188 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,184 | java | package agoption.projetos.com.agoption.helper;
import android.database.sqlite.SQLiteDatabase;
public final class ConfiguracaoBanco {
private static SQLiteDatabase banco;
public static SQLiteDatabase getBanco(){
if(banco == null){
banco = SQLiteDatabase.openOrCreateDatabase("DbAGOption", null);
//banco = SQLiteDatabase.op
}
return banco;
}
//CRIAR TABELAS
public static void criarTabelas(){
banco.execSQL("CREATE TABLE IF NOT EXISTS Carros(" +
" idCarro INTEGER PRIMARY KEY AUTOINCREMENT," +
" descricao VARCHAR(30)," +
" fator NUMERIC(10,2));");
banco.execSQL("CREATE TABLE IF NOT EXISTS Historico(" +
" idHistorico INTEGER PRIMARY KEY AUTOINCREMENT," +
" data DATETIME," +
" vlAlcool NUMERIC(10,2)," +
" vlGasolina NUMERIC(10,2)," +
" idCarro_fk INTEGER," +
" melhorOP VARCHAR(10)," +
" fator NUMERIC(10,2)," +
" FOREIGN KEY (idCarro_fk) REFERENCES Carros(idCarro));");
}
}
| [
"[email protected]"
] | |
8b8cb1a31c73a53858486ee4612e05c4beaf7c3c | ae140feae43cf56cc2faf99a355530e20108d4b9 | /programmers/programmers_basic/dfs2.java | 765fb5034423c207facfece40d0e8886b2dbedee | [] | no_license | Wonji1/coding-test | 6ac7e6a014c6f9d400b0d4b3fc19bf4b102a9980 | 11ff1be18957c65a1bdd571f168a46caa86000a4 | refs/heads/master | 2023-04-12T19:54:32.144543 | 2021-05-04T08:43:58 | 2021-05-04T08:43:58 | 312,788,713 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 797 | java | public class dfs2 {
public static int solution(int n, int[][] computers) {
int answer = 0;
boolean[] check = new boolean[n];
for(int i=0;i<n;i++){
if(!check[i]){
answer++;
dfs(i,computers,check);
}
}
return answer;
}
private static void dfs(int i, int[][] computers, boolean[] check) {
check[i] = true;
for(int j=0;j<computers[i].length;j++){
if(!check[j] && computers[i][j] == 1){
dfs(j,computers,check);
}
}
}
public static void main(String[] args) {
int n = 3;
int[][] computers = {{1,1,0},{1,1,0},{0,0,1}};
int answer = solution(n, computers);
System.out.println(answer);
}
}
| [
"[email protected]"
] | |
e8fc00ef999ab5873d31446177c43b7975e274a8 | 38ea3b73feec749b4716adee20cb602b3ec57600 | /Dog.java | e8af698b14c78893891f4efa399256bb477f0b4a | [] | no_license | chaixiaobao/factory | 54a11a5a4176368bada18344c2846b3467d82de7 | 79ca462bc44cfe7b063a7d5c9fd0f984351b66ca | refs/heads/master | 2020-04-27T16:57:31.001510 | 2019-03-09T11:06:03 | 2019-03-09T11:06:03 | 174,498,992 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 198 | java | package stu.mavendemo.factory;
public class Dog implements Animal {
@Override
public void eat() {
// TODO Auto-generated method stub
System.out.println("Dog is eating...");
}
}
| [
"[email protected]"
] | |
68e463a59aaa0b2c324bb6490c1ad8b738d66ff1 | ea52e1ee2d8e390b77fdef93882513cfe61c74a2 | /app/src/test/java/com/akb/ANGGI/myapplication/ExampleUnitTest.java | de865cc657e22b941f325cc87874d9521919a5fa | [] | no_license | anggi03/Tugas-UAS-AKB-AKB1-10116042 | a6d6ec84347806843fbd50d928ccdff80b54f359 | 518129d06452058ac08509f94917202e339c680a | refs/heads/master | 2020-07-04T06:43:00.314352 | 2019-08-13T17:21:11 | 2019-08-13T17:21:11 | 202,181,574 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 388 | java | package com.akb.ANGGI.myapplication;
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]"
] | |
f136d1653a772c6e63fd402959e99893268d6774 | 2123444b620c719eec9f2166c56a1240f0eaa80d | /mergesort.java | 8a21e172a94e29ea19f3d65a17294defcffc528b | [] | no_license | riturajdatta1997/mergesort | 9e05f017ee880dff083bb04dcdfbf7644e9f2372 | a0419ccace86e41175f7092b2bd8317a74248f17 | refs/heads/master | 2020-06-02T11:40:08.351635 | 2019-06-10T09:46:27 | 2019-06-10T09:46:27 | 191,142,744 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,658 | java | import java.util.*;
class Mergesort
{
void merge(int a[],int l,int m,int r)
{
//Finding the sizes of two sub arrays to be merged
int n1=m-l+1;
int n2=r-m;
int b[]=new int[100];
int c[]=new int [100];
for(int j=0;j<n1;j++)
{
b[j]=a[l+j];
}
for(int j=0;j<n1;j++)
{
c[j]=a[m+1+j];
}
//Condition checking to merge the 2 sub arrays
int i=0,j=0,k=l;
while(i<n1 && j<n2)
{
if(b[i]<=c[j])
{
a[k]=b[i];
i++;
}
else
{
a[k]=c[j];
j++;
}
k++;
}
//storing the left over elements
while(i<n1)
{
a[k]=b[i];
i++;
k++;
}
while(j<n1)
{
a[k]=c[j];
j++;
k++;
}
}
//Function to sort the elements using merge sort techniques using a function
void sort(int a[],int l,int r)
{
if(l<r)
{
//calculating the mid point
int m=(l+r)/2;
//recursive calls
sort(a,l,m);
sort(a,m+1,r);
//Function calling to merge the two sorted arrays
merge(a,l,m,r);
}
}
//Function to print the merged and sorted array
void printarray(int a[])
{
int n=a.length;
for(int i=0;i<n;i++)
System.out.print(a[i]+" ");
System.out.println();
}
//Main function
public static void main(String args[])
{
/*Scanner input=new Scanner(System.in);
int a[]=new int[100];
int n;
System.out.println(" Enter the number of array elements");
n=input.nextInt();
System.out.println("Enter the elements of the array");
for(int i=0;i<n;i++)
{
a[i]=input.nextInt();
}*/
int a[]= {10, 3, 24, 4,11,18, 89};
Mergesort obj=new Mergesort();
obj.sort(a,0,a.length-1);
System.out.println(" Sorted array:- ");
printarray(a);
}
}
| [
"[email protected]"
] | |
98e7f8a59929b577fcc63fb746e7286e40fdb99f | c9a6b445eb78b303df154d67f1fa68f0afd389d6 | /backend/src/test/java/br/com/digitalhouse/ComunidadeOrganicaApplicationTests.java | d5ca5f5f8bc60e936922a79beaa33121ebe97fc7 | [] | no_license | vyrs/comunidade-organica | 57bf3fb660d3a5f76142a21f01c4c75489233de7 | b9693d5329389aeff33f296b04ebba849aea1b7a | refs/heads/master | 2023-02-13T16:13:56.702851 | 2021-01-12T12:47:31 | 2021-01-12T12:47:31 | 320,680,445 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 223 | java | package br.com.digitalhouse;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ComunidadeOrganicaApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
a83451bce0f1a3c50c8af0f25094f70f49b82d33 | 9c1466a41541cae6413c8d546407bab74b118f72 | /app/src/main/java/com/example/higooo/tarhil/WalkingFragment.java | 23a62d6fdfb268ba0352210f503f5d3832e60711 | [] | no_license | NazarAmin/Tarhil | 7c4396b340db1d4ada8cad129d22eb94b18c5814 | 26a3e31a793ef64551cd379315857b5cad994248 | refs/heads/master | 2020-05-05T02:12:24.183186 | 2019-04-05T06:19:29 | 2019-04-05T06:19:29 | 179,629,315 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,829 | java | package com.example.higooo.tarhil;
import android.Manifest;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.gms.location.FusedLocationProviderClient;
import com.google.android.gms.location.LocationRequest;
import com.google.android.gms.location.LocationServices;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Timer;
import java.util.zip.Inflater;
import static java.lang.Math.round;
public class WalkingFragment extends Fragment implements OnMapReadyCallback, LocationListener {
private static final String TAG = "WalkingFragment";
private GoogleMap mMap;
private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
private static final String COARSE_LOCATION = Manifest.permission.ACCESS_COARSE_LOCATION;
private static final int LOCATIONPERMISSIONCODE = 1234;
LatLng latLng;
private boolean track = false;
private boolean locationpermissionsgranted = false;
private FusedLocationProviderClient mFusedLocationClient;
Button btn;
public String dd;
Button start;
Button end;
boolean online = false;
TextView Average;
TextView Distance;
TextView Maximum;
TextView Blank, OnRide, paused;
TextView Dur;
TextView Durend;
Button History;
ArrayList<Float> arrayList = new ArrayList <Float>();
ArrayList <Location> distances = new ArrayList<Location>();
ArrayList <Float> meters = new ArrayList<>();
int index = 0;
Timer timer =new Timer();
Date currentTime;
FirebaseDatabase database;
private DatabaseReference reference;
static final int GPS_REQUEST = 100;
// ..
Bitmap bitmap;
@SuppressLint("MissingPermission")
@Nullable
// @Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.walking,container,false);
getlocationpermission();
database = FirebaseDatabase.getInstance();
reference = database.getReference("Data_Work");
//Animation animfadein = AnimationUtils.loadAnimation(getApplicationContext(),R.anim.blink);
//animfadein.start();
/** reference.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
for Receiving Configuration
UserLocation user = new UserLocation();
double lo = dataSnapshot.child("Nazar").getValue(UserLocation.class).getLongi();
double la = dataSnapshot.child("Nazar").getValue(UserLocation.class).getLatti();
latLng = new LatLng(la,lo);
mMap.clear();
MarkerOptions marker = new MarkerOptions().position(latLng);
mMap.addMarker(new MarkerOptions().position(latLng).title("Member Location"));
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.dot));
mMap.addMarker(marker);
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
*/
History = (Button) view.findViewById(R.id.listH);
Average = (TextView) view.findViewById(R.id.avg);
Distance = (TextView) view.findViewById(R.id.dis);
Maximum = (TextView) view.findViewById(R.id.msp);
Dur = (TextView) view.findViewById(R.id.dur);
Durend = (TextView) view.findViewById(R.id.ende);
Blank = (TextView) view.findViewById(R.id.blank);
OnRide = (TextView) view.findViewById(R.id.onride);
paused = (TextView) view.findViewById(R.id.Paused);
btn = (Button) view.findViewById(R.id.full);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent i = new Intent(getContext(),Main2Activity.class);
startActivity(i);
}
});
LocationManager lm = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE);
lm.requestLocationUpdates(LocationManager.GPS_PROVIDER,0,0, (LocationListener) this);
this.onLocationChanged(null);
// SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager()
// .findFragmentById(R.id.mapw);
// mapFragment.getMapAsync( this);
start = (Button) view.findViewById(R.id.trip);
start.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
track = true;
arrayList.clear();
distances.clear();
boolean online = true;
currentTime = Calendar.getInstance().getTime();
OnRide.setVisibility(View.VISIBLE);
Toast.makeText(getContext(),"Trip Started",Toast.LENGTH_LONG).show();
}
});
end = (Button) view.findViewById(R.id.reset);
end.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
online = false;
track = false;
OnRide.setVisibility(View.INVISIBLE);
paused.setVisibility(View.VISIBLE);
float num = 0;
// float de = 0;
float max = 0;
float tot;
for(float s: arrayList){
num = num + s;
if (max < s){
max = s;
}
}
tot = num/arrayList.size();
int ig = round(tot);
float totDis = 0;
for(int po = 0; po< distances.size()-1; po++){
meters.add(distances.get(po).distanceTo(distances.get(po+1)));
}
for (Float q: meters){
totDis = totDis + q;
}
Average.setText(String.valueOf(ig));
Maximum.setText(String.valueOf(round(max)));
Distance.setText(String.valueOf(round(totDis)));
Dur.setText((CharSequence) currentTime.toString());
Durend.setText((CharSequence) Calendar.getInstance().getTime().toString());
arrayList.clear();
distances.clear();
totDis = 0;
int id = 1;
int avg2 = Integer.parseInt(Average.getText().toString());
int max2 = Integer.parseInt(Maximum.getText().toString());
int dis2 = Integer.parseInt(Distance.getText().toString());
String Start = Dur.getText().toString();
String end = Durend.getText().toString();
Trip employee = new Trip(id,avg2,max2,dis2,Start,end);
SQLHelperClass db = new SQLHelperClass(getContext());
db.addEmployee(employee);
Toast.makeText(getContext(),"Trip added succesfully",Toast.LENGTH_LONG).show();
}
});
History.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent IR = new Intent(getContext(),All_Trips.class);
startActivity(IR);
}
});
return view;
}
private void getDeviceLocation() {
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(getContext());
try {
if (locationpermissionsgranted) {
final Task location = mFusedLocationClient.getLastLocation();
location.addOnCompleteListener(new OnCompleteListener() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
Location currentLocation = (Location) task.getResult();
MoveCamera(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude()), 5f);
Toast.makeText(getContext(), "Location Found OK", Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getContext(), "Location Not Found", Toast.LENGTH_LONG).show();
}
}
});
}
} catch (SecurityException e) {
}
}
private void MoveCamera(LatLng latLng, float zoom) {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoom));
}
private void getlocationpermission() {
String[] permissions = {android.Manifest.permission.ACCESS_COARSE_LOCATION, android.Manifest.permission.ACCESS_COARSE_LOCATION};
if (ContextCompat.checkSelfPermission(this.getContext(), FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (ContextCompat.checkSelfPermission(this.getContext(), COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
locationpermissionsgranted = true;
} else {
ActivityCompat.requestPermissions((Activity) getContext(), permissions, LOCATIONPERMISSIONCODE);
}
} else {
ActivityCompat.requestPermissions((Activity) getContext(), permissions, LOCATIONPERMISSIONCODE);
}
;
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
locationpermissionsgranted = false;
getlocationpermission();
switch (requestCode) {
case LOCATIONPERMISSIONCODE: {
if (grantResults.length > 0) {
for (int i = 0; i < grantResults.length; i++) {
if (grantResults[i] != PackageManager.PERMISSION_GRANTED) {
locationpermissionsgranted = false;
return;
}
locationpermissionsgranted = true;
// database = FirebaseDatabase.getInstance();
//reference = database.getReference("Locations");
initMap();
}
}
}
}
}
protected void createLocationRequest() {
LocationRequest mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(10000);
mLocationRequest.setFastestInterval(5000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
}
/**
* Manipulates the map once available.
* This callback is triggered when the map is ready to be used.
* This is where we can add markers or lines, add listeners or move the camera. In this case,
* we just add a marker near Sydney, Australia.
* If Google Play services is not installed on the device, the user will be prompted to install
* it inside the SupportMapFragment. This method will only be triggered once the user has
* installed Google Play services and returned to the app.
*/
private void initMap() {
SupportMapFragment mapFragment = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync((OnMapReadyCallback) getContext());
}
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
if (locationpermissionsgranted) {
getDeviceLocation();
if (ActivityCompat.checkSelfPermission(getContext(), android.Manifest.permission.ACCESS_FINE_LOCATION)
!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission
(getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
return;
}
mMap.setMyLocationEnabled(true);
mMap.setTrafficEnabled(true);
mMap.getUiSettings().setCompassEnabled(true);
}
}
@Override
public void onLocationChanged(Location location) {
// String id = reference.push().getKey();
// UserLocation userLocation = new UserLocation(id,"Nazar", location.getLongitude(), location.getLatitude());
// UserLocation userLocation = new UserLocation(id,"Nazar", 10.6, 30.335);
//double lattiude = location.getLatitude();
//String rtu = "Nazar";
// UserLocation userLocation = new UserLocation(15.3, 30.55);
// reference.child(rtu);
// reference.setValue("try this");
// Toast.makeText(WalkingFragment.this,String.valueOf(longit),Toast.LENGTH_SHORT).show();
// TextView txt = (TextView) getView().findViewById(R.id.speed);
if(location == null)
{
// txt.setText("0");
// dis.setText("0 m");
}
else
{
Location locationA = new Location("PointA");
locationA.setLatitude(location.getLatitude());
locationA.setLongitude(location.getLongitude());
distances.add(locationA);
if (track) {
latLng = new LatLng(location.getLatitude(),location.getLongitude());
MarkerOptions marker = new MarkerOptions().position(latLng);
marker.icon(BitmapDescriptorFactory.fromResource(R.drawable.dot));
mMap.addMarker(marker);
UserLocation userlocation = new UserLocation(location.getLongitude(), location.getLatitude());
reference.child("Nazar").setValue(userlocation);
}
// index = index + 1;
float cs = location.getSpeed();
float csd = (float) (cs * 3.6);
int speed2 = Math.round(csd);
dd = String.valueOf(speed2);
// txt.setText(dd);
arrayList.add(csd);
String id = reference.push().getKey();
UserLocation userLocation = new UserLocation(id,"Nazar", locationA.getLongitude(), locationA.getLatitude());
reference.child(id).setValue(userLocation);
// dis.setText(String.valueOf(Math.round(location.getAltitude())) + " m");
}
}
@Override
public void onStatusChanged(String s, int i, Bundle bundle) {
}
@Override
public void onProviderEnabled(String s) {
}
@Override
public void onProviderDisabled(String s) {
}
}
| [
"[email protected]"
] | |
1fb7429070b6897b1ac6ddd84c7015be4dcc894e | a54d6cb5ead7dcd721ff9c3985ed140b809f1823 | /app/src/main/java/com/acadgild/fujitsu/assignment51/MainActivity.java | bbe336485ad4aef741577aaf968d30a2aa3bb50d | [] | no_license | Ritesh786/Assignment5.1 | a412f2601647ac935bf9f70e40606a86011fbda2 | a9228d9f85576c5124b79b55175ca06b0822f3a0 | refs/heads/master | 2021-01-19T18:17:16.391650 | 2017-04-15T14:45:15 | 2017-04-15T14:45:15 | 88,353,096 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,560 | java |
package com.acadgild.fujitsu.assignment51;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.text);
}
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.firstmmenu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
//noinspection SimplifiableIfStatement
if (id == R.id.action_red) {
textView.setTextColor(Color.RED);
return true;
}
if (id == R.id.action_blue) {
textView.setTextColor(Color.BLUE);
return true;
}
if (id == R.id.action_yeloow) {
textView.setTextColor(Color.YELLOW);
return true;
}
return super.onOptionsItemSelected(item);
}
}
| [
"[email protected]"
] | |
1166873dff97898c47df11911ee3efe29e1c358e | 4d3ea698dcbac7798258e7ff93e41a0f54dcc00a | /src/BinaryTrees/SpiralPrint.java | f7a70aaf293e1e7f629601dac519d79fac7ac82d | [] | no_license | amanmahajan2190/Algorithms-and-Data-Structure | 94f5b28bd449ac7eff4af8be5fc6b4951ac650ea | 6957cb2e03b33b0376befeee4480dade5739ad57 | refs/heads/master | 2020-12-29T00:55:10.635850 | 2016-08-23T13:12:41 | 2016-08-23T13:12:41 | 45,441,028 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,582 | java | package BinaryTrees;
import java.util.Stack;
/**
* Created by AMAN on 5/23/2016.
*/
public class SpiralPrint {
Stack<Node> stack1;
Stack<Node> stack2;
SpiralPrint(){
stack1 = new Stack<Node>();
stack2 = new Stack<Node>();
}
public void createTree(Node root){
root.left = new Node(2);
root.right = new Node(3);
root.left.left = new Node(5);
root.left.right = new Node(4);
root.right.left = new Node(7);
root.right.right = new Node(6);
}
public void makeSpiralTree(Node root){
if(root == null){
return;
}
stack1.push(root);
while (!stack1.isEmpty() || !stack2.isEmpty()){
while (!stack1.isEmpty()){
Node t = stack1.pop();
System.out.print(t.data);
if(t.left!= null){
stack2.push(t.left);
}
if(t.left!=null){
stack2.push(t.right);
}
}
while (!stack2.isEmpty()){
Node t = stack2.pop();
System.out.print(t.data);
if(t.left!= null){
stack1.push(t.left);
}
if(t.left!=null){
stack1.push(t.right);
}
}
}
}
public static void main(String[] args){
SpiralPrint print = new SpiralPrint();
Node root = new Node(1);
print.createTree(root);
print.makeSpiralTree(root);
}
}
| [
"[email protected]"
] | |
58f006f6a2ba9251180efac1ac2cd782c72f2899 | 2ba4aa725e17d29c4482c5699ea8210136339b1e | /app/src/main/java/com/borntonight/loftcoin/data/DataModule.java | b685c85951c48970881eea344e50d5af463e61e8 | [] | no_license | BornToNight/LoftCoin | d44154b6bb17e9551cf3ba8a236baef2ee01ff70 | f422406d43d15f02438c656298166130c0d2dec8 | refs/heads/master | 2023-01-07T02:13:55.466612 | 2020-11-06T05:18:30 | 2020-11-06T05:18:30 | 290,524,570 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,208 | java | package com.borntonight.loftcoin.data;
import android.content.Context;
import androidx.room.Room;
import com.borntonight.loftcoin.BuildConfig;
import com.squareup.moshi.Moshi;
import javax.inject.Singleton;
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.moshi.MoshiConverterFactory;
@Module
public abstract class DataModule {
@Provides
static Moshi moshi() {
final Moshi moshi = new Moshi.Builder().build();
return moshi.newBuilder()
.add(Coin.class, moshi.adapter(AutoValue_CmcCoin.class))
.add(Listings.class, moshi.adapter(AutoValue_Listings.class))
.build();
}
@Provides
static Retrofit retrofit(OkHttpClient httpClient, Moshi moshi) {
final Retrofit.Builder builder = new Retrofit.Builder();
builder.client(httpClient.newBuilder()
.addInterceptor(chain -> {
final Request request = chain.request();
return chain.proceed(request.newBuilder()
.addHeader(CmcApi.API_KEY, BuildConfig.API_KEY)
.build());
})
.build());
builder.baseUrl(BuildConfig.API_ENDPOINT);
builder.addConverterFactory(MoshiConverterFactory.create(moshi));
builder.addCallAdapterFactory(RxJava2CallAdapterFactory.createAsync());
return builder.build();
}
@Provides
static CmcApi cmcApi(Retrofit retrofit) {
return retrofit.create(CmcApi.class);
}
@Provides
@Singleton
static LoftDatabase loftDatabase(Context context) {
if (BuildConfig.DEBUG) {
return Room.inMemoryDatabaseBuilder(context, LoftDatabase.class).build();
} else {
return Room.databaseBuilder(context, LoftDatabase.class, "loft.db").build();
}
}
@Binds
abstract CoinsRepo coinsRepo(CmcCoinsRepo impl);
@Binds
abstract CurrencyRepo currencyRepo(CurrencyRepoImpl impl);
@Binds
abstract WalletsRepo walletsRepo(WalletsRepoImpl impl);
}
| [
"[email protected]"
] | |
64da47021e3286231471c1190f1817bf6e9ef107 | 8e53bc40ba86cd4d0f7d01a06147bdedc8c56cd1 | /epoxy-adapter/src/main/java/com/airbnb/epoxy/EpoxyVisibilityTracker.java | 79cd33d2f35f726c51bb69e66a142d88d673cd01 | [
"Apache-2.0"
] | permissive | viclee888/epoxy | 6ab53edb2d6039c0c1e5d7b77bf493e5cc741c55 | 6e717cfb55a0e4704394ed791b6843eec4a6d083 | refs/heads/master | 2020-04-04T09:38:00.456507 | 2018-10-22T18:07:09 | 2018-10-22T18:07:09 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 13,451 | java | package com.airbnb.epoxy;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.AdapterDataObserver;
import android.support.v7.widget.RecyclerView.OnChildAttachStateChangeListener;
import android.support.v7.widget.RecyclerView.OnScrollListener;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.util.Log;
import android.util.SparseArray;
import android.view.View;
import android.view.View.OnLayoutChangeListener;
import java.util.ArrayList;
import java.util.List;
/**
* A simple way to track visibility events on {@link com.airbnb.epoxy.EpoxyModel} within a {@link
* android.support.v7.widget.RecyclerView}.
* <p>
* {@link EpoxyVisibilityTracker} works with any {@link android.support.v7.widget.RecyclerView}
* backed by an Epoxy controller. Once attached the events will be forwarded to the Epoxy model (or
* to the Epoxy view when using annotations).
* <p>
* Note regarding nested lists: The visibility event tracking is not properly handled yet. This is
* on the todo.
* <p>
*
* @see OnVisibilityChanged
* @see OnVisibilityStateChanged
* @see OnModelVisibilityChangedListener
* @see OnModelVisibilityStateChangedListener
*/
public class EpoxyVisibilityTracker {
private static final String TAG = "EpoxyVisibilityTracker";
// Not actionable at runtime. It is only useful for internal test-troubleshooting.
static final boolean DEBUG_LOG = false;
/** Maintain visibility item indexed by view id (identity hashcode) */
private final SparseArray<EpoxyVisibilityItem> visibilityIdToItemMap = new SparseArray<>();
private final List<EpoxyVisibilityItem> visibilityIdToItems = new ArrayList<>();
/** listener used to process scroll, layout and attach events */
private final Listener listener = new Listener();
/** listener used to process data events */
private final DataObserver observer = new DataObserver();
@Nullable
private RecyclerView attachedRecyclerView = null;
@Nullable
private Adapter lastAdapterSeen = null;
private boolean onChangedEnabled = true;
/** This flag is for optimizing the process on detach. If detach is from data changed then it
* need to re-process all views, else no need (ex: scroll). */
private boolean visibleDataChanged = false;
/**
* Enable or disable visibility changed event. Default is `true`, disable it if you don't need
* (triggered by every pixel scrolled).
*
* @see OnVisibilityChanged
* @see OnModelVisibilityChangedListener
*/
public void setOnChangedEnabled(boolean enabled) {
onChangedEnabled = enabled;
}
/**
* Attach the tracker.
*
* @param recyclerView The recyclerview that the EpoxyController has its adapter added to.
*/
public void attach(@NonNull RecyclerView recyclerView) {
attachedRecyclerView = recyclerView;
recyclerView.addOnScrollListener(this.listener);
recyclerView.addOnLayoutChangeListener(this.listener);
recyclerView.addOnChildAttachStateChangeListener(this.listener);
}
/**
* Detach the tracker
*
* @param recyclerView The recycler view that the EpoxyController has its adapter added to.
*/
public void detach(@NonNull RecyclerView recyclerView) {
recyclerView.removeOnScrollListener(this.listener);
recyclerView.removeOnLayoutChangeListener(this.listener);
recyclerView.removeOnChildAttachStateChangeListener(this.listener);
attachedRecyclerView = null;
}
/**
* The tracker is storing visibility states internally and is using if to send events, only the
* difference is sent. Use this method to clear the states and thus regenerate the visibility
* events. This may be useful when you change the adapter on the {@link
* android.support.v7.widget.RecyclerView}
*/
public void clearVisibilityStates() {
// Clear our visibility items
visibilityIdToItemMap.clear();
visibilityIdToItems.clear();
}
private void processChangeEvent(String debug) {
processChangeEventWithDetachedView(null, debug);
}
private void processChangeEventWithDetachedView(@Nullable View detachedView, String debug) {
final RecyclerView recyclerView = attachedRecyclerView;
if (recyclerView != null) {
// On every every events lookup for a new adapter
processNewAdapterIfNecessary();
// Process the detached child if any
if (detachedView != null) {
processChild(detachedView, true, debug);
}
// Process all attached children
for (int i = 0; i < recyclerView.getChildCount(); i++) {
final View child = recyclerView.getChildAt(i);
if (child != null && child != detachedView) {
// Is some case the detached child is still in the recycler view. Don't process it as it
// was already processed.
processChild(child, false, debug);
}
}
}
}
/**
* If there is a new adapter on the attached RecyclerView it will resister the data observer and
* clear the current visibility states
*/
private void processNewAdapterIfNecessary() {
if (attachedRecyclerView != null && attachedRecyclerView.getAdapter() != null) {
if (lastAdapterSeen != attachedRecyclerView.getAdapter()) {
if (lastAdapterSeen != null) {
// Unregister the old adapter
lastAdapterSeen.unregisterAdapterDataObserver(this.observer);
}
// Register the new adapter
attachedRecyclerView.getAdapter().registerAdapterDataObserver(this.observer);
lastAdapterSeen = attachedRecyclerView.getAdapter();
}
}
}
/**
* Don't call this method directly, it is called from
* {@link EpoxyVisibilityTracker#processVisibilityEvents}
*
* @param child the view to process for visibility event
* @param detachEvent true if the child was just detached
* @param eventOriginForDebug a debug strings used for logs
*/
private void processChild(@NonNull View child, boolean detachEvent, String eventOriginForDebug) {
final RecyclerView recyclerView = attachedRecyclerView;
if (recyclerView != null) {
final ViewHolder holder = recyclerView.getChildViewHolder(child);
if (holder instanceof EpoxyViewHolder) {
processVisibilityEvents(
recyclerView,
(EpoxyViewHolder) holder,
recyclerView.getLayoutManager().canScrollVertically(),
detachEvent,
eventOriginForDebug
);
} else {
throw new IllegalEpoxyUsage(
"`EpoxyVisibilityTracker` cannot be used with non-epoxy view holders."
);
}
}
}
/**
* Call this methods every time something related to ui (scroll, layout, ...) or something related
* to data changed.
*
* @param recyclerView the recycler view
* @param epoxyHolder the {@link RecyclerView}
* @param vertical true if the scrolling is vertical
* @param detachEvent true if the event originated from a view detached from the
* recycler view
* @param eventOriginForDebug a debug strings used for logs
*/
private void processVisibilityEvents(
@NonNull RecyclerView recyclerView,
@NonNull EpoxyViewHolder epoxyHolder,
boolean vertical, boolean detachEvent,
String eventOriginForDebug
) {
if (DEBUG_LOG) {
Log.d(TAG, String.format("%s.processVisibilityEvents %s, %s, %s",
eventOriginForDebug,
System.identityHashCode(epoxyHolder),
detachEvent,
epoxyHolder.getAdapterPosition()
));
}
final View itemView = epoxyHolder.itemView;
final int id = System.identityHashCode(itemView);
EpoxyVisibilityItem vi = visibilityIdToItemMap.get(id);
if (vi == null) {
// New view discovered, assign an EpoxyVisibilityItem
vi = new EpoxyVisibilityItem(epoxyHolder.getAdapterPosition());
visibilityIdToItemMap.put(id, vi);
visibilityIdToItems.add(vi);
} else if (epoxyHolder.getAdapterPosition() != RecyclerView.NO_POSITION
&& vi.getAdapterPosition() != epoxyHolder.getAdapterPosition()) {
// EpoxyVisibilityItem being re-used for a different adapter position
vi.reset(epoxyHolder.getAdapterPosition());
}
if (vi.update(itemView, recyclerView, vertical, detachEvent)) {
// View is measured, process events
vi.handleVisible(epoxyHolder, detachEvent);
vi.handleFocus(epoxyHolder, detachEvent);
vi.handleFullImpressionVisible(epoxyHolder, detachEvent);
if (onChangedEnabled) {
vi.handleChanged(epoxyHolder);
}
}
}
/**
* Helper class that host the {@link android.support.v7.widget.RecyclerView} listener
* implementations
*/
private class Listener extends OnScrollListener
implements OnLayoutChangeListener, OnChildAttachStateChangeListener {
@Override
public void onLayoutChange(
@NonNull View recyclerView,
int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom
) {
processChangeEvent("onLayoutChange");
}
@Override
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
processChangeEvent("onScrolled");
}
@Override
public void onChildViewAttachedToWindow(View child) {
processChild(child, false, "onChildViewAttachedToWindow");
}
@Override
public void onChildViewDetachedFromWindow(View child) {
if (visibleDataChanged) {
// On detach event caused by data set changed we need to re-process all children because
// the removal caused the others views to changes.
processChangeEventWithDetachedView(child, "onChildViewDetachedFromWindow");
visibleDataChanged = false;
} else {
processChild(child, true, "onChildViewDetachedFromWindow");
}
}
}
/**
* The layout/scroll events are not enough to detect all sort of visibility changes. We also
* need to look at the data events from the adapter.
*/
class DataObserver extends AdapterDataObserver {
/**
* Clear the current visibility statues
*/
@Override
public void onChanged() {
if (DEBUG_LOG) {
Log.d(TAG, "onChanged()");
}
visibilityIdToItemMap.clear();
visibilityIdToItems.clear();
visibleDataChanged = true;
}
/**
* For all items after the inserted range shift each {@link EpoxyVisibilityTracker} adapter
* position by inserted item count.
*/
@Override
public void onItemRangeInserted(int positionStart, int itemCount) {
if (DEBUG_LOG) {
Log.d(TAG, String.format("onItemRangeInserted(%d, %d)", positionStart, itemCount));
}
for (EpoxyVisibilityItem item : visibilityIdToItems) {
if (item.getAdapterPosition() >= positionStart) {
visibleDataChanged = true;
item.shiftBy(itemCount);
}
}
}
/**
* For all items after the removed range reverse-shift each {@link EpoxyVisibilityTracker}
* adapter position by removed item count
*/
@Override
public void onItemRangeRemoved(int positionStart, int itemCount) {
if (DEBUG_LOG) {
Log.d(TAG, String.format("onItemRangeRemoved(%d, %d)", positionStart, itemCount));
}
for (EpoxyVisibilityItem item : visibilityIdToItems) {
if (item.getAdapterPosition() >= positionStart) {
visibleDataChanged = true;
item.shiftBy(-itemCount);
}
}
}
/**
* This is a bit more complex, for move we need to first swap the moved position then shift the
* items between the swap. To simplify we split any range passed to individual item moved.
*
* ps: anyway {@link android.support.v7.util.AdapterListUpdateCallback} does not seem to use
* range for moved items.
*/
@Override
public void onItemRangeMoved(int fromPosition, int toPosition, int itemCount) {
for (int i = 0; i < itemCount; i++) {
onItemMoved(fromPosition + i, toPosition + i);
}
}
private void onItemMoved(int fromPosition, int toPosition) {
if (DEBUG_LOG) {
Log.d(TAG,
String.format("onItemRangeMoved(%d, %d, %d)", fromPosition, toPosition, 1));
}
for (EpoxyVisibilityItem item : visibilityIdToItems) {
int position = item.getAdapterPosition();
if (position == fromPosition) {
// We found the item to be moved, just swap the position.
item.shiftBy(toPosition - fromPosition);
visibleDataChanged = true;
} else if (fromPosition < toPosition) {
// Item will be moved down in the list
if (position > fromPosition && position <= toPosition) {
// Item is between the moved from and to indexes, it should move up
item.shiftBy(-1);
visibleDataChanged = true;
}
} else if (fromPosition > toPosition) {
// Item will be moved up in the list
if (position >= toPosition && position < fromPosition) {
// Item is between the moved to and from indexes, it should move down
item.shiftBy(1);
visibleDataChanged = true;
}
}
}
}
}
}
| [
"[email protected]"
] | |
b0416e3ecf54e7a8899f8b91f320bf54f19b4aa9 | 07bb26f2cf6b83f94499f097bd8932286744bae1 | /src/Collections/PrettyName.java | 55de3ef44d0a3f083a5f81052c644cb8b9983fa9 | [] | no_license | yangsch/BasicAlgorithm | 7237c80f9c43b068125269ab76e19dd555eebc64 | 0c9c385f7a6249e9f24b2709863f4fb89f8ce349 | refs/heads/master | 2020-04-05T15:53:25.423810 | 2018-11-10T14:27:56 | 2018-11-10T14:27:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,685 | java | package Collections;
import java.util.*;
public class PrettyName {
private static int prettyname(String name){
char[] letters = name.toCharArray();
HashMap<Character,Integer> hm = new HashMap<>();
for(int i =0;i<letters.length;i++){
int value = 0;
if(!hm.containsKey(letters[i])){
hm.put(letters[i],1);
}else{
value = hm.get(letters[i])+1;
hm.put(letters[i],value);
}
}
List<Map.Entry<Character,Integer>> list = new ArrayList<>(hm.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Character, Integer>>() {
@Override
public int compare(Map.Entry<Character, Integer> o1, Map.Entry<Character, Integer> o2) {
if(o1.getValue()>o2.getValue())
return 1;
else if(o1.getValue()==o2.getValue())
return 0;
else
return -1;
}
});
int sum = 0;
for (int i=list.size()-1;i>=0;i--){
int pretty = list.get(i).getValue();
sum = pretty*(26+i-list.size()+1)+sum;
}
return sum;
}
public static void main(String[] args){
Scanner s = new Scanner(System.in);
while(s.hasNext()){
int n = s.nextInt();
String[] strs = new String[n];
int[] pretty = new int[n];
for(int i =0;i<n;i++){
strs[i] = s.next();
pretty[i] = prettyname(strs[i]);
}
for(int ss:pretty)
System.out.println(ss);
}
}
}
| [
"[email protected]"
] | |
6c29c571d5ce969da25828a99be7f34840d566ab | 05c2a972a383de999e871b0e1d2b7ee91634c7bf | /zxinglib/src/main/java/com/scan/zxinglib/zxorg/ViewfinderResultPointCallback.java | 77e9ab7a6bd4468ef49beac7d6d95b4d26314f5d | [] | no_license | jackyflame/ZxingTester | 344b126cd09448138669b6bcdd1949ba1ae9471b | e41a5238096b62124dfb81e180979e4c0aa2bc04 | refs/heads/master | 2021-06-25T22:16:11.665016 | 2017-09-14T09:24:07 | 2017-09-14T09:24:07 | 103,254,121 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,085 | java | /*
* Copyright (C) 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.scan.zxinglib.zxorg;
import com.google.zxing.ResultPoint;
import com.google.zxing.ResultPointCallback;
final class ViewfinderResultPointCallback implements ResultPointCallback {
private final ViewfinderView viewfinderView;
ViewfinderResultPointCallback(ViewfinderView viewfinderView) {
this.viewfinderView = viewfinderView;
}
@Override
public void foundPossibleResultPoint(ResultPoint point) {
viewfinderView.addPossibleResultPoint(point);
}
}
| [
"[email protected]"
] | |
9c7e73c40d44ac213ef5715cc3e87399c0456e93 | e75e3a7f0d4a501acf8d43d12b7102d4e2315ba8 | /src/main/java/com/thc/code/services/UserService.java | aaddb884640210782950bdee3840b867f0060b85 | [] | no_license | facuc28/esportTournament | 74fa6125def54c2545cb31055ef7bd90cc1acef0 | 3e6c1b2a99ac5214c86c00eabd645a15de77266d | refs/heads/master | 2021-08-28T11:19:14.433750 | 2017-12-12T03:37:05 | 2017-12-12T03:37:05 | 113,933,827 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 540 | java | package com.thc.code.services;
import com.thc.code.domain.User;
import com.thc.code.repositories.UserRespository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class UserService {
@Autowired
UserRespository userRespository;
public User getUserbyUserName(String userName) {
return userRespository.getUserByUserName(userName);
}
public boolean createUser(User user) {
return userRespository.createUser(user);
}
}
| [
"[email protected]"
] | |
90fe4a7602ba5707a1c330483e3df1c5c4e80638 | 7878907644870f3dc938c090702d3f976f8888ae | /gemini-spring-boot-interview-demo/src/main/java/com/gemini/core/LockSupportDemo.java | df4cf34bdef6655488ddd042ffa051f754ea5576 | [] | no_license | xiaocuizi/demo | defdad53954e3c88d9af82ade114ece2ccea3c7f | 697709e1b890bc9e9dcf66cca62e6c8924a923c0 | refs/heads/master | 2022-12-23T08:17:48.536774 | 2020-04-10T11:33:30 | 2020-04-10T11:33:30 | 194,759,727 | 0 | 0 | null | 2022-12-15T23:54:17 | 2019-07-02T00:22:58 | Java | UTF-8 | Java | false | false | 2,125 | java | package com.gemini.core;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
import java.util.HashMap;
import java.util.Map;
/**
* @author xiaocuzi
* @version v1.0.0
* @Package com.gemini.test.core
* @classname: LockSupportDemo
* @Description: todo (用一句话描述该文件做什么)
* @date 2019/3/14 12:09
*/
public class LockSupportDemo {
static Object u = new Object();
@org.openjdk.jmh.annotations.Benchmark
public void measureName() {
// System.out.println("hello,world!");
Map<String, String> map = new HashMap<>();
map.put("a", "b");
}
/** main method */
public static void main(String[] args) {
Options opt = new OptionsBuilder()
////benchmark 所在的类的名字,注意这里是使用正则表达式对所有类进行匹配的
.include(LockSupportDemo.class.getSimpleName())
.forks(1)////进行 fork 的次数。如果 fork 数是2的话,则 JMH 会 fork 出两个进程来进行测试
.warmupIterations(5) //预热的迭代次数
.measurementIterations(5) //实际测量的迭代次数
.build();
try {
new Runner(opt).run();
} catch (RunnerException e) {
e.printStackTrace();
}
}
/*public static class ChangeObject extends Thread{
public ChangeObject(String name) {
super(name);
}
public void run(){
//synchronized (u){
System.out.println("in "+getName());
LockSupport.park();
//}
}
}
static ChangeObject t1 = new ChangeObject("T1");
static ChangeObject t2 = new ChangeObject("T2");
public static void main(String[] args) throws InterruptedException {
t1.start();
Thread.sleep(100);
t2.start();
LockSupport.unpark(t1);
*//* LockSupport.unpark(t2);
t1.join();
t2.join();*//*
}*/
}
| [
"[email protected]"
] | |
6708795d65a36e6cc97708f20ba1166101cf23f5 | 18606c6b3f164a935e571932b3356260b493e543 | /benchmarks/xalan/src/org/apache/xpath/operations/Plus.java | 490e88c7b35d07f2fbae21a77eaf82fdf47dbdec | [
"Apache-2.0",
"BSD-2-Clause",
"Apache-1.1"
] | permissive | jackyhaoli/abc | d9a3bd2d4140dd92b9f9d0814eeafa16ea7163c4 | 42071b0dcb91db28d7b7fdcffd062f567a5a1e6c | refs/heads/master | 2020-04-03T09:34:47.612136 | 2019-01-11T07:16:04 | 2019-01-11T07:16:04 | 155,169,244 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,987 | java | /*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [email protected].
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, Lotus
* Development Corporation., http://www.lotus.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.xpath.operations;
import org.apache.xpath.objects.XObject;
import org.apache.xpath.objects.XNumber;
import org.apache.xpath.XPathContext;
/**
* The '+' operation expression executer.
*/
public class Plus extends Operation
{
/**
* Apply the operation to two operands, and return the result.
*
*
* @param left non-null reference to the evaluated left operand.
* @param right non-null reference to the evaluated right operand.
*
* @return non-null reference to the XObject that represents the result of the operation.
*
* @throws javax.xml.transform.TransformerException
*/
public XObject operate(XObject left, XObject right)
throws javax.xml.transform.TransformerException
{
return new XNumber(left.num() + right.num());
}
/**
* Evaluate this operation directly to a double.
*
* @param xctxt The runtime execution context.
*
* @return The result of the operation as a double.
*
* @throws javax.xml.transform.TransformerException
*/
public double num(XPathContext xctxt)
throws javax.xml.transform.TransformerException
{
return (m_right.num(xctxt) + m_left.num(xctxt));
}
}
| [
"xiemaisi@40514614-586c-40e6-bf05-bf7e477dc3e6"
] | xiemaisi@40514614-586c-40e6-bf05-bf7e477dc3e6 |
a87dce5bb1d97d953e3d1b7c9b0ce5fda91f6b4c | e70c84f9e528cde3b87a01a8517293456b6a160a | /app/src/main/java/com/example/bamproject/EditCardActivity.java | bee629370dc02b6760932750f620a4bf8b815710 | [] | no_license | zwrg/bam-project | 4752ce86bc826b7f56aa8255fdf5bb699cdf5554 | b9d3570085db54c75f069eaa477f4bfeee4c10d7 | refs/heads/master | 2023-05-30T19:34:51.904687 | 2021-05-22T11:56:54 | 2021-05-22T11:56:54 | 368,243,509 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,572 | java | package com.example.bamproject;
import androidx.annotation.RequiresApi;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.WindowManager;
import android.widget.EditText;
import android.widget.TextView;
public class EditCardActivity extends AppCompatActivity {
final String TAG = "Edit Card Activity";
private Card currentCard;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
setContentView(R.layout.activity_edit_card);
int cardId = getIntent().getIntExtra("cardUid", 0);
if (cardId == 0) {
// Log.d(TAG, "card id = 0, sth wrong");
throw new Error(TAG + "card id = 0, sth wrong");
}
AppDatabase database = AppDatabase.getInstance(getApplicationContext());
CardDao cardDao = database.cardDao();
new Thread(() -> {
currentCard = cardDao.getCard(cardId);
// Log.d(TAG, currentCard.toString());
runOnUiThread(this::updateView);
}).start();
}
private void updateView() {
EditText cardNameView = findViewById(R.id.card_edit_text_name);
EditText cardNumberView = findViewById(R.id.card_edit_text_number);
EditText cardValidityView = findViewById(R.id.card_edit_text_validity);
EditText cardCvvView = findViewById(R.id.card_edit_text_cvv);
cardNameView.setText(currentCard.cardName);
cardNumberView.setText(currentCard.cardNumber);
cardValidityView.setText(currentCard.cardValidity);
cardCvvView.setText(currentCard.cvv);
}
@RequiresApi(api = Build.VERSION_CODES.M)
public void onSaveHandler(View view) {
clearErrorsView();
EditText cardNameView = findViewById(R.id.card_edit_text_name);
String cardName = cardNameView.getText().toString();
EditText cardNumberView = findViewById(R.id.card_edit_text_number);
String cardNumber = cardNumberView.getText().toString();
EditText cardValidityView = findViewById(R.id.card_edit_text_validity);
String cardValidity = cardValidityView.getText().toString();
EditText cardCvvView = findViewById(R.id.card_edit_text_cvv);
String cardCvv = cardCvvView.getText().toString();
CardValidityEnum addCardError = CardValidator.checkDataValidity(cardName, cardNumber, cardValidity, cardCvv);
if (addCardError == CardValidityEnum.GOOD) {
currentCard.cardName = cardName;
currentCard.cardNumber = cardNumber;
currentCard.cardValidity = cardValidity;
currentCard.cvv = cardCvv;
AppDatabase database = AppDatabase.getInstance(getApplicationContext());
CardDao cardDao = database.cardDao();
// todo add other user ID check
int currentUserId = Preferences.getUserId(getApplicationContext());
if (currentUserId == 0) {
throw new Error("User ID = 0");
}
new Thread(() -> {
cardDao.updateCard(currentCard);
leaveActivity();
}).start();
} else {
showErrorsView(addCardError);
}
}
private void clearErrorsView() {
TextView errorView = findViewById(R.id.card_edit_error);
errorView.setText("");
}
private void showErrorsView(CardValidityEnum registerError) {
String error = "";
switch (registerError) {
case EMPTY_FIELDS:
error = "There are some empty fields";
break;
case WRONG_NUMBER:
error = "Bad Card Number";
break;
case WRONG_VALIDITY:
error = "Bad Validity Format";
break;
case WRONG_CVV:
error = "Bad CVV Number";
break;
default:
error = "";
break;
}
TextView errorView = findViewById(R.id.card_edit_error);
errorView.setText(error);
}
private void leaveActivity() {
Intent intent = new Intent(EditCardActivity.this, HomeActivity.class);
startActivity(intent);
}
public void onCancelHandler(View view) {
finish();
}
} | [
"[email protected]"
] | |
94615b9ac111a8b149c4944c012e569d51b220a2 | d7be4442074b22ec3b091888ac57f523e026d182 | /src/evosim/buildingblocks/AminoAcid.java | ca7a2c6fe8b6a1b97f2546ae0f9c888db7b6e3fc | [] | no_license | drwat/EvoSim | 52cc001f33af9c96729905bba98c5d3472a97dd8 | 04ae6f2758b9f816c8a9a20eb5bf1d52460503ba | refs/heads/master | 2021-01-25T10:17:08.493625 | 2012-04-04T02:25:51 | 2012-04-04T02:25:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 109 | java | package evosim.buildingblocks;
/**
* @author WooLooWoo
*/
public class AminoAcid extends Molecule {
}
| [
"[email protected]"
] | |
14daee7899f8a0fa133c63dbb2663a5e599f59af | 72661191e9d2eeb2d5a5d35d361afaab7dc7aa8c | /src/main/java/com/fds/repositories/CustomerInfoRepo.java | e9292423401c95e21037c4b63bcb6022c76ecc60 | [] | no_license | vht1092/FraudDetectionSystems_v2_Rpt | a84cb71209082b977863b65fcd97c2248557a148 | dd29ca58caa6a4aa8cd5e93013e36098b874c2ce | refs/heads/master | 2023-04-21T07:28:28.803573 | 2021-05-10T06:27:38 | 2021-05-10T06:27:38 | 365,917,532 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,774 | java | package com.fds.repositories;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import com.fds.entities.CustomerInfo;
@Repository
public interface CustomerInfoRepo extends JpaRepository<CustomerInfo, String> {
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, fx_ir056_off_tel_1 as cust_off_tel_1, fx_ir056_off_tel_2 as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, fx_ir056_cif_no as cust_cif from [email protected] join FDS_SYS_TASK s on trim(fx_ir056_cif_no) = s.objecttask where s.typetask =:typetask ", nativeQuery = true)
List<CustomerInfo> findAllTypetask(@Param("typetask") String typetask);
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, fx_ir056_off_tel_1 as cust_off_tel_1, fx_ir056_off_tel_2 as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, fx_ir056_cif_no as cust_cif from [email protected] where rownum = 1 and fx_ir056_cif_no = :cifno ", nativeQuery = true)
CustomerInfo findAll(@Param("cifno") String cifno);
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, fx_ir056_off_tel_1 as cust_off_tel_1, fx_ir056_off_tel_2 as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, fx_ir056_cif_no as cust_cif from [email protected] where rownum = 1 and trim(fx_ir056_cif_no) =?1", nativeQuery = true)
CustomerInfo findOneAll(String cifno);
/**
* Lay ten khach hang (chinh/phu) theo so the
*/
@Query(value = "select decode((select trim(fx_ir025_emb_lst_nm) || ' ' || trim(fx_ir025_emb_mid_nm) || ' ' || trim(fx_ir025_emb_name) from [email protected] where px_ir025_pan = :enccardno union select trim(fx_ir275_emb_lst_nm) || ' ' || trim(fx_ir275_emb_mid_nm) || ' ' || trim(fx_ir275_emb_name) from [email protected] where px_ir275_own_pan = :enccardno), null, (select trim(fx_ir025_emb_lst_nm) || ' ' || trim(fx_ir025_emb_mid_nm) || ' ' || trim(fx_ir025_emb_name) from [email protected] where FX_IR025_REF_PAN = :enccardno union select trim(fx_ir275_emb_lst_nm) || ' ' || trim(fx_ir275_emb_mid_nm) || ' ' || trim(fx_ir275_emb_name) from [email protected] where FX_IR275_REF_PAN = :enccardno ), (select trim(fx_ir025_emb_lst_nm) || ' ' || trim(fx_ir025_emb_mid_nm) || ' ' || trim(fx_ir025_emb_name) from [email protected] where px_ir025_pan = :enccardno union select trim(fx_ir275_emb_lst_nm) || ' ' || trim(fx_ir275_emb_mid_nm) || ' ' || trim(fx_ir275_emb_name) from [email protected] where px_ir275_own_pan = :enccardno)) custname from dual", nativeQuery = true)
String getCustNameByEncCrdNo(String enccardno);
/**
* Lay Loc (chinh/phu) theo so the
*/
@Query(value = "select decode((select f9_ir025_loc_acct from [email protected] where px_ir025_pan = :enccardno union select f9_ir275_loc_acct from [email protected] where px_ir275_own_pan = :enccardno), null, (select f9_ir025_loc_acct from [email protected] where fx_ir025_ref_pan = :enccardno union select f9_ir275_loc_acct from [email protected] where fx_ir275_ref_pan = :enccardno), (select f9_ir025_loc_acct from [email protected] where px_ir025_pan = :enccardno union select f9_ir275_loc_acct from [email protected] where px_ir275_own_pan = :enccardno)) loc from dual", nativeQuery = true)
String getLocByEncCrdNo(String enccardno);
/*
* select trim(fx_ir056_name) as cust_name,
* decode(fx_ir056_gendr, 'F', 'Bà', 'Ông') as cust_gendr,
* fx_ir056_hp as cust_hp,
* fx_ir056_hme_tel as cust_off_tel_1,
* fx_ir056_off_tel_1 as cust_off_tel_2,
* fx_ir056_email_addr as cust_email_addr,
* fx_ir056_cif_no as cust_cif
* from [email protected]
* where p9_ir056_crn = (select f9_ir275_crn
* from [email protected]
* where px_ir275_own_pan = :crdno)
* union
* select trim(fx_ir056_name) as cust_name,
* decode(fx_ir056_gendr, 'F', 'Bà', 'Ông') as cust_gendr,
* fx_ir056_hp as cust_hp,
* fx_ir056_hme_tel as cust_off_tel_1,
* fx_ir056_off_tel_1 as cust_off_tel_2,
* fx_ir056_email_addr as cust_email_addr,
* fx_ir056_cif_no as cust_cif
* from [email protected]
* where p9_ir056_crn =
* (select f9_ir025_crn from [email protected] where px_ir025_pan = :crdno)
*/
/*khoa khong check so dien thoai fcc
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, '0' as cust_off_tel_1, fx_ir056_off_tel_1 as cust_off_tel_2, trim(fx_ir056_email_addr) as cust_email_addr, trim(fx_ir056_cif_no) as cust_cif from [email protected] where p9_ir056_crn = (select nvl((select f9_ir025_crn from [email protected] where px_ir025_pan = :crdno),(select f9_ir275_crn from [email protected] where px_ir275_own_pan = :crdno)) from dual)", nativeQuery = true)
CustomerInfo findByCrdNo(@Param("crdno") String crdno);
*/
/*huyennt add them ngay 14Oct2017*/
/*@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, '0' as cust_off_tel_1, fx_ir056_off_tel_1 as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, trim(fx_ir056_cif_no) as cust_cif from [email protected] where trim(fx_ir056_cif_no) = :cifno and rownum <= 1", nativeQuery = true)
CustomerInfo findByCif(@Param("cifno") String cifno);
*/
//tam khoa check so dt fcc
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, nvl((SELECT trim(MOBILE_NUMBER) FROM fcusr01.STTM_CUST_PERSONAL@exadata where CUSTOMER_NO = trim(fx_ir056_cif_no)),' ') as cust_off_tel_1, nvl((SELECT trim(telephone) FROM fcusr01.STTM_CUST_PERSONAL@exadata where CUSTOMER_NO = trim(fx_ir056_cif_no)),' ') as cust_off_tel_2, trim(fx_ir056_email_addr) as cust_email_addr, trim(fx_ir056_cif_no) as cust_cif from [email protected] where p9_ir056_crn = (select nvl((select f9_ir025_crn from [email protected] where px_ir025_pan = :crdno),(select f9_ir275_crn from [email protected] where px_ir275_own_pan = :crdno)) from dual)", nativeQuery = true)
CustomerInfo findByCrdNo(@Param("crdno") String crdno);
//huyennt add them ngay 14Oct2017
//tanvh1
// @Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, '0963137131' as cust_off_tel_1, '0935569842' as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, trim(fx_ir056_cif_no) as cust_cif from [email protected] where trim(fx_ir056_cif_no) = :cifno and rownum <= 1", nativeQuery = true)
@Query(value = "select trim(fx_ir056_name) as cust_name, case trim(fx_ir056_ttl) when 'MISS' then 'Bà' when 'MR' then 'Ông' when 'MRS' then 'Bà' else '' end cust_gendr, fx_ir056_hp as cust_hp, nvl((SELECT trim(MOBILE_NUMBER) FROM fcusr01.STTM_CUST_PERSONAL@exadata where CUSTOMER_NO = trim(fx_ir056_cif_no)),' ') as cust_off_tel_1, nvl((SELECT trim(telephone) FROM fcusr01.STTM_CUST_PERSONAL@exadata where CUSTOMER_NO = trim(fx_ir056_cif_no)),' ') as cust_off_tel_2, fx_ir056_email_addr as cust_email_addr, trim(fx_ir056_cif_no) as cust_cif from [email protected] where trim(fx_ir056_cif_no) = :cifno and rownum <= 1", nativeQuery = true)
CustomerInfo findByCif(@Param("cifno") String cifno);
}
/*
* select trim(fx_ir056_name) as cust_name,
* decode(fx_ir056_gendr, 'F', 'Bà', 'Ông') as cust_gendr,
* trim(fx_ir056_hp) as cust_hp,
* trim(fx_ir056_off_tel_1) as cust_off_tel_1,
* trim(fx_ir056_off_tel_2) as cust_off_tel_2,
* trim(fx_ir056_email_addr) as cust_email_addr,
* trim(fx_ir056_cif_no) as cust_cif
* from [email protected]
* where p9_ir056_crn =
* (select F9_IR275_CRN
* from [email protected]
* where PX_IR275_OWN_PAN = '48E219A099958F1CXXX')
* union
* select trim(fx_ir056_name) as cust_name,
* decode(fx_ir056_gendr, 'F', 'Bà', 'Ông') as cust_gendr,
* trim(fx_ir056_hp) as cust_hp,
* trim(fx_ir056_off_tel_1) as cust_off_tel_1,
* trim(fx_ir056_off_tel_2) as cust_off_tel_2,
* trim(fx_ir056_email_addr) as cust_email_addr,
* trim(fx_ir056_cif_no) as cust_cif
* from [email protected]
* where p9_ir056_crn =
* (select F9_IR025_CRN
* from [email protected]
* where PX_IR025_PAN = '48E219A099958F1CXXX');
*/
| [
"[email protected]"
] | |
0309a9bac39711d79ccaa2f68e9f6ef5cb45e60e | 07d3d970419e7d78c072508c9dc8dafc05f7c1ac | /java/grasp/Player.java | 7b8cb9a47155949f4e057d98d2bad8812cda0381 | [] | no_license | arthurTemporim/design_patterns | 4a8308e85f00faa91ed36d58220ba7d4494acb31 | 63099a1827aaff44c790370a059468eccd7a6aa0 | refs/heads/master | 2020-11-29T15:07:00.829402 | 2017-04-07T18:13:40 | 2017-04-07T18:13:40 | 87,491,465 | 0 | 1 | null | 2019-04-14T21:12:31 | 2017-04-07T01:31:19 | Java | UTF-8 | Java | false | false | 202 | java | public class Player {
private String name;
public Player(String name) {
setName(name);
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
| [
"[email protected]"
] | |
bab18b1ba0cbc8f4e033a9c2b40883ddf64fdcd3 | 8cf7dc95101060cf7a28f2582915db8ebb81b1c0 | /Hospital - Jovany T/hospital/hospital/src/main/java/br/edu/uniacademia/hospital/dao/ProntuariosDAO.java | cf67b40f74e55535024fa646af897d775dfd972e | [] | no_license | JovanyTvares/TrabalhoHospital | 74d12a205ec566e8e3729a19d17be8c72df39ba7 | 92dcc56863dd77caa7f424f2a5de511e9e39a1b6 | refs/heads/master | 2023-01-04T05:14:56.418214 | 2020-10-29T23:57:55 | 2020-10-29T23:57:55 | 308,478,385 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,998 | java | package br.edu.uniacademia.hospital.dao;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.Query;
import br.edu.uniacademia.hospital.model.Prontuarios;
import br.edu.uniacademia.hospital.util.PersistenceUtil;
public class ProntuariosDAO {
public static ProntuariosDAO prontuariosDAO;
public static ProntuariosDAO getInstance() {
if (prontuariosDAO == null) {
prontuariosDAO = new ProntuariosDAO();
}
return prontuariosDAO;
}
public Prontuarios buscar(String descricao) {
EntityManager em = PersistenceUtil.getEntityManager();
Query query = em.createQuery("select a from Prontuarios a where a.descricao =:descricao ");
query.setParameter("descricao", descricao);
List<Prontuarios> prontuariosList = query.getResultList();
if (prontuariosList != null && prontuariosList.size() > 0) {
return prontuariosList.get(0);
}
return null;
}
public List<Prontuarios> buscarTodas() {
EntityManager em = PersistenceUtil.getEntityManager();
Query query = em.createQuery("from Prontuarios As a");
return query.getResultList();
}
public void remover(Prontuarios prontuarios) {
EntityManager em = PersistenceUtil.getEntityManager();
em.getTransaction().begin();
if (!em.contains(prontuarios)) {
prontuarios = em.merge(prontuarios);
}
em.remove(prontuarios);
em.getTransaction().commit();
}
public Prontuarios persistir(Prontuarios prontuarios) {
EntityManager em = PersistenceUtil.getEntityManager();
em.getTransaction().begin();
try {
prontuarios = em.merge(prontuarios);
em.getTransaction().commit();
System.out.println("Registro Prontuarios gravado com sucesso");
} catch (Exception e) {
e.printStackTrace();
}
return prontuarios;
}
public void removeAll() {
EntityManager em = PersistenceUtil.getEntityManager();
em.getTransaction().begin();
Query query = em.createQuery(" delete from Prontuarios ");
query.executeUpdate();
em.getTransaction().commit();
}
}
| [
"[email protected]"
] | |
d60a3acc25061be64343e4e1bd296fc4b4076787 | e5488dea88f1036ac9fbb61816bae69d70a9d763 | /core/cdi-injection-point/src/main/java/org/agoncal/fascicle/quarkus/core/cdi/injectionpoint/IsbnGenerator.java | be0455ccf051edc4167c08bff2068d8d5a7f6e34 | [
"MIT"
] | permissive | fg78nc/agoncal-fascicle-quarkus | 1572eb5aeaddda11708c3ea3d2f4fd1474295323 | 5a62b42d4e246a279eb188f6f1c09c02e0e85b8b | refs/heads/master | 2023-01-12T18:28:19.834971 | 2020-11-09T13:46:37 | 2020-11-09T13:46:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 439 | java | package org.agoncal.fascicle.quarkus.core.cdi.injectionpoint;
import javax.enterprise.context.ApplicationScoped;
import java.util.Random;
/**
* @author Antonio Goncalves
* http://www.antoniogoncalves.org
* --
*/
// tag::adocSnippet[]
@ApplicationScoped
public class IsbnGenerator implements NumberGenerator {
public String generateNumber() {
return "13-84356-" + Math.abs(new Random().nextInt());
}
}
// end::adocSnippet[]
| [
"[email protected]"
] | |
efac82d16f5eafd4e6c34049177ccb210c84166d | dac1cef4f7c86d3797138dc34953d5b7652dfcc8 | /app/src/main/java/com/chrisahn/popularmovies/FavoriteAdapter.java | 0488f039bd06674e2a55f07df0ab363946f8df0c | [] | no_license | AhnChris/PopularMovies_old | 13ad694c532c2cd2bf533f48e7810492e8d6e645 | 916c7cd2ac722a52ab492f7d92f3acb1544916fd | refs/heads/master | 2021-01-18T19:03:30.006335 | 2016-03-21T06:39:54 | 2016-03-21T06:39:54 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,415 | java | package com.chrisahn.popularmovies;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CursorAdapter;
import android.widget.ImageView;
import com.chrisahn.popularmovies.data.FavoriteColumns;
import com.squareup.picasso.Picasso;
public class FavoriteAdapter extends CursorAdapter {
private final String LOG_TAG = FavoriteAdapter.class.getSimpleName();
public FavoriteAdapter(Context context, Cursor c, int flags) {
super(context, c, flags);
}
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
ImageView imageView = new ImageView(context);
imageView.setAdjustViewBounds(true);
imageView.setPadding(0, 0, 0, 0);
return imageView;
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
String BASE_IMG_URL = "http://image.tmdb.org/t/p/w185/";
Uri uri = Uri.parse(BASE_IMG_URL).buildUpon()
.appendEncodedPath(cursor.getString(cursor.getColumnIndex(FavoriteColumns.POSTER_PATH)))
.build();
String url = uri.toString();
Log.v(LOG_TAG, "Favorite URL with Picasso: " + url);
Picasso.with(context).load(url).error(R.drawable.error_image2).into((ImageView) view);
}
}
| [
"[email protected]"
] | |
a324be50e7273a4e1ef894bf15055b2b2c73af7f | a85d2dccd5eab048b22b2d66a0c9b8a3fba4d6c2 | /rebellion_h5_realm/java/l2r/gameserver/listener/actor/OnReviveListener.java | 513abc4e747bc70ec0186f84cb0bb7e577187ea9 | [] | no_license | netvirus/reb_h5_storm | 96d29bf16c9068f4d65311f3d93c8794737d4f4e | 861f7845e1851eb3c22d2a48135ee88f3dd36f5c | refs/heads/master | 2023-04-11T18:23:59.957180 | 2021-04-18T02:53:10 | 2021-04-18T02:53:10 | 252,070,605 | 0 | 0 | null | 2021-04-18T02:53:11 | 2020-04-01T04:19:39 | HTML | UTF-8 | Java | false | false | 261 | java | package l2r.gameserver.listener.actor;
import l2r.gameserver.listener.CharListener;
import l2r.gameserver.model.Creature;
/**
* @author VISTALL
*/
public interface OnReviveListener extends CharListener
{
public void onRevive(Creature actor);
}
| [
"[email protected]"
] | |
8894fb5d794b2b03c06dbbaf614415eaca11db1e | b0449f253ddac1228a8e64f26ceded5347d6d1af | /1-algorithm/13-leetcode/java/src/buildingblock/table/alphabet/lc383_ransomnote/Solution.java | 597b861d4d49289186951b52f09efbb97c5a55c2 | [
"MIT"
] | permissive | cdai/interview | c03f64442b48cb8af0658642633d0118295a788d | d2dfffb707eb32ee83ed9caecce5a4dce976ccb7 | refs/heads/master | 2020-05-21T16:46:04.313493 | 2017-05-13T20:13:06 | 2017-05-13T20:13:06 | 60,381,799 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,288 | java | package buildingblock.table.alphabet.lc383_ransomnote;
/**
* Given
an
arbitrary
ransom
note
string
and
another
string
containing
letters from
all
the
magazines,
* write
a
function
that
will
return
true
if
the
ransom
note
can
be
constructed
from
the
magazines ;
* otherwise,
it
will
return
false.
Each
letter
in
the
magazine
string
can
only
be
used
once
in
your
ransom
note.
* Note: You may assume that both strings contain only lowercase letters.
* canConstruct("a", "b") -> false
* canConstruct("aa", "ab") -> false
* canConstruct("aa", "aab") -> true
*/
public class Solution {
// Test case: [],[] [a],[] [],[a] [abc],[a] [ab],[abc] [abb],[bacb]
public boolean canConstruct(String ransom, String magazine) {
if (ransom.isEmpty() || magazine.isEmpty()) return ransom.isEmpty();
if (ransom.length() > magazine.length()) return false;
int[] diff = new int[26];
for (int i = 0; i < magazine.length(); i++) {
diff[magazine.charAt(i) - 'a']++;
}
for (int i = 0; i < ransom.length(); i++) {
if (--diff[ransom.charAt(i) - 'a'] < 0) return false;
}
return true;
}
// Simplify: remove last one loop
public boolean canConstruct1(String ransomNote, String magazine) {
int[] letters = new int[26];
for (char c : magazine.toCharArray()) {
letters[c - 'a']++;
}
for (char c : ransomNote.toCharArray()) {
if (--letters[c - 'a'] < 0) {
return false;
}
}
return true;
}
// My 1AC
public boolean canConstruct12(String ransomNote, String magazine) {
if (ransomNote.length() > magazine.length()) {
return false;
}
int[] letters = new int[26];
for (char c : magazine.toCharArray()) {
letters[c - 'a']++;
}
for (char c : ransomNote.toCharArray()) {
letters[c - 'a']--;
}
for (int letter : letters) {
if (letter < 0) {
return false;
}
}
return true;
}
}
| [
"[email protected]"
] | |
bc0c0b51db63c7a5c22b6b1d3310df83a5342387 | 4688d19282b2b3b46fc7911d5d67eac0e87bbe24 | /aws-java-sdk-ssm/src/main/java/com/amazonaws/services/simplesystemsmanagement/model/transform/DescribePatchBaselinesResultJsonUnmarshaller.java | 25ce250e4cd7d2a1a4578586325cd211b91e84e7 | [
"Apache-2.0"
] | permissive | emilva/aws-sdk-java | c123009b816963a8dc86469405b7e687602579ba | 8fdbdbacdb289fdc0ede057015722b8f7a0d89dc | refs/heads/master | 2021-05-13T17:39:35.101322 | 2018-12-12T13:11:42 | 2018-12-12T13:11:42 | 116,821,450 | 1 | 0 | Apache-2.0 | 2018-09-19T04:17:41 | 2018-01-09T13:45:39 | Java | UTF-8 | Java | false | false | 3,309 | java | /*
* Copyright 2013-2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.simplesystemsmanagement.model.transform;
import java.math.*;
import javax.annotation.Generated;
import com.amazonaws.services.simplesystemsmanagement.model.*;
import com.amazonaws.transform.SimpleTypeJsonUnmarshallers.*;
import com.amazonaws.transform.*;
import com.fasterxml.jackson.core.JsonToken;
import static com.fasterxml.jackson.core.JsonToken.*;
/**
* DescribePatchBaselinesResult JSON Unmarshaller
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class DescribePatchBaselinesResultJsonUnmarshaller implements Unmarshaller<DescribePatchBaselinesResult, JsonUnmarshallerContext> {
public DescribePatchBaselinesResult unmarshall(JsonUnmarshallerContext context) throws Exception {
DescribePatchBaselinesResult describePatchBaselinesResult = new DescribePatchBaselinesResult();
int originalDepth = context.getCurrentDepth();
String currentParentElement = context.getCurrentParentElement();
int targetDepth = originalDepth + 1;
JsonToken token = context.getCurrentToken();
if (token == null)
token = context.nextToken();
if (token == VALUE_NULL) {
return describePatchBaselinesResult;
}
while (true) {
if (token == null)
break;
if (token == FIELD_NAME || token == START_OBJECT) {
if (context.testExpression("BaselineIdentities", targetDepth)) {
context.nextToken();
describePatchBaselinesResult.setBaselineIdentities(new ListUnmarshaller<PatchBaselineIdentity>(PatchBaselineIdentityJsonUnmarshaller
.getInstance()).unmarshall(context));
}
if (context.testExpression("NextToken", targetDepth)) {
context.nextToken();
describePatchBaselinesResult.setNextToken(context.getUnmarshaller(String.class).unmarshall(context));
}
} else if (token == END_ARRAY || token == END_OBJECT) {
if (context.getLastParsedParentElement() == null || context.getLastParsedParentElement().equals(currentParentElement)) {
if (context.getCurrentDepth() <= originalDepth)
break;
}
}
token = context.nextToken();
}
return describePatchBaselinesResult;
}
private static DescribePatchBaselinesResultJsonUnmarshaller instance;
public static DescribePatchBaselinesResultJsonUnmarshaller getInstance() {
if (instance == null)
instance = new DescribePatchBaselinesResultJsonUnmarshaller();
return instance;
}
}
| [
""
] | |
0819742d4fceeda497894758ff66cf1d59adc592 | 9c3562103721cb438fed5ba7696eeb372d027a3f | /src/fr/vincentteam/vtgl/fonts/VTGLFont.java | 6b3b9741841f2e64e9b825c34dcab24653d43d99 | [] | no_license | gaston147/VTGL | d5a9a8cd69273507601577f1682c4b0cf297641d | 46c2cad146d60ad6033062b3766a756a4d3fcee4 | refs/heads/master | 2021-01-25T05:28:10.557020 | 2014-07-06T18:09:29 | 2014-07-06T18:09:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 282 | java | package fr.vincentteam.vtgl.fonts;
import fr.vincentteam.vtgl.bitmaps.Bitmap;
public interface VTGLFont {
public Bitmap getCharacter(char c);
public int getLineHeight();
public int getWidth(String str);
public void drawString(Bitmap bitmap, int x, int y, String str);
}
| [
"[email protected]"
] | |
9daae451ad74d0f5353600a058b536042c8bc8a0 | d8ad177ec206a562da10a6249e2a677c604a79b0 | /src/factory/method/e2/TVFactory.java | 675bc722c8dbedbe10533d1149d7ed00b9e3f6b1 | [] | no_license | xxxknight/DesignPattern | 503d28750f6f0c857fdf3fac7282311a84742bc5 | 25bac2b0729c85af53fa1d24bfb81e24b5642cce | refs/heads/master | 2021-06-02T18:10:53.583495 | 2017-10-14T08:32:10 | 2017-10-14T08:32:10 | 32,872,999 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 87 | java | package factory.method.e2;
public interface TVFactory {
abstract TV produce();
} | [
"[email protected]"
] | |
79999bc52d7b26b5aa57f678a3e145aed63d3e4f | d8d3f3982c522440a6de8ad475ff50b86c4840e7 | /src/main/java/io/vertx/guides/wiki/database/SqlQuery.java | 7892b02bced7fb1b78c6fc6857b992b8a2d63844 | [] | no_license | ryanthames/vertx-wiki-tutorial | 2ff68933e7cec1755e1d35e7870ba4fc4d118d1f | f2ff0707e851b648fd93312ff7ab3f2e671ed76c | refs/heads/master | 2021-07-08T11:30:48.846693 | 2017-10-05T01:16:38 | 2017-10-05T01:16:38 | 105,482,308 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 183 | java | package io.vertx.guides.wiki.database;
enum SqlQuery {
CREATE_PAGES_TABLE,
ALL_PAGES,
ALL_PAGES_DATA,
GET_PAGE,
GET_PAGE_BY_ID,
CREATE_PAGE,
SAVE_PAGE,
DELETE_PAGE
}
| [
"[email protected]"
] | |
d4e7b7aecd43cd1a8179d568f7c4469e0b66caaf | a6cc78e2c4be520291a31a0a8126c99972830074 | /Demo/src/main/java/sdk/moon/com/moonsdk/adapter/MLoopAdapter.java | 0f0afa413e4caca2886d35156e5e0a4f729ff43f | [] | no_license | jxxfzgy/MoonSDK | cc101aed252d445213fd8acfbc8e84255c117cec | 8ac926e1cd62dc0aecea9d9087c33e71867934f4 | refs/heads/master | 2021-01-23T18:10:40.393903 | 2015-01-11T11:30:18 | 2015-01-11T11:30:18 | 25,164,588 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 917 | java | package sdk.moon.com.moonsdk.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import java.util.List;
import sdk.moon.com.moonsdk.R;
import sdk.moon.com.moonsdk.abst.MBaseViewAdapter;
import sdk.moon.com.moonsdk.entity.MLoopViewBean;
/**
* Created by Administrator on 2014/10/14 0014.
*/
public class MLoopAdapter extends MBaseViewAdapter<MLoopViewBean> {
public MLoopAdapter(Context context, List list) {
super(context, list);
}
@Override
public View createView(LayoutInflater inflater) {
View view = inflater.inflate(R.layout.viewpager_loop_item, null) ;
return view;
}
@Override
public void showData(View view ,int position) {
ImageView imageView = findView(view,R.id.item_loop_img) ;
imageView.setImageResource(getItem(position).drawableId);
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.