blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
listlengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
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
listlengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
fcceaaedb8990a6974246171c3f6aebf0ce0ae22 | 2057bb9aba2193468f57d67a13c1ebc091a9ca33 | /src/main/java/com/digicore/challenge/model/repository/TransactionDAO.java | 090dd3b2443cf3abd8cf804fda48fbcdea05b401 | []
| no_license | warl0ck1111/degicoreChallenge | 1a2c8d025d6717993c7b0f8b1ab416de272a6df9 | 0466e363d2f8416da1445380954f88d50b327bd8 | refs/heads/main | 2023-05-14T12:39:26.141586 | 2021-06-09T05:17:11 | 2021-06-09T05:17:11 | 374,947,099 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 901 | java | package com.digicore.challenge.model.repository;/*
* @author Okala III
*/
import com.digicore.challenge.model.entity.Account;
import com.digicore.challenge.model.entity.Transactions;
import lombok.extern.slf4j.Slf4j;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@Slf4j
public class TransactionDAO {
public static HashMap<Integer, Transactions> transactions = new HashMap<>();
public static boolean save(Transactions transaction){
transactions.put(transactions.size()+1,transaction);
return true;
}
public static List<Transactions> findAll(){
List<Transactions> allTransactions = new ArrayList<>();
for(Integer key : transactions.keySet()){
Transactions transaction = TransactionDAO.transactions.get(key);
allTransactions.add(transaction);
}
return allTransactions;
}
}
| [
"[email protected]"
]
| |
84c6fd8724ddddff856d51215f4445c045ef4160 | e8b1e6a15da9c1d5f8df50cfdc241ea7e97c48ff | /src/net/kismetwireless/android/pcapcapture/DialogListener.java | 0d49660b606e8ca0083522419028c81bd71ea83d | []
| no_license | Cosoute/WigKiz | 14b739a2959be66c74308397737ed02ed88d2e09 | 9b38fd1f1ad3542c0ed9be14dead5004a512c4d2 | refs/heads/master | 2021-07-22T07:20:16.342040 | 2019-01-30T17:14:27 | 2019-01-30T17:14:27 | 61,647,988 | 2 | 1 | null | null | null | null | UTF-8 | Java | false | false | 329 | java | package net.kismetwireless.android.pcapcapture;
import android.app.DialogFragment;
public interface DialogListener {
public void onDialogPositiveClick(DialogFragment dialog, int id);
public void onDialogNegativeClick(DialogFragment dialog, int id);
public void onDialogNeutralClick(DialogFragment dialog, int id);
} | [
"[email protected]"
]
| |
779fa6ed7de7ae2947566ba96c8ec73536543650 | 09c4f0c72b47653b855744c9d1e72c02598e2ac6 | /app/src/main/java/com/example/mockprojectcampuslink/listener/OnClickIcon.java | 82f15bef97a5ecb746c5ef1afd63bde114580eea | []
| no_license | datthanh3007/MediaPlayer1 | 666676af9e6b268bafadcdc8e7ef9fc142058788 | 670d2dce7b0cff8ccff40a64caf07e1a42f43836 | refs/heads/master | 2023-01-05T08:49:06.637689 | 2020-11-03T10:10:38 | 2020-11-03T10:10:38 | 309,633,038 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 154 | java | package com.example.mockprojectcampuslink.listener;
public interface OnClickIcon {
void clickIcon(int position);
void clickSong(int position);
}
| [
"[email protected]"
]
| |
da3b12c40ee7fbfc3c19e262c3cc6726002844fa | e8b99359b947c8d4a363300db1ca12e969d9a799 | /contacts-spring-mvc/src/main/java/se/fkarbing/spring/mvc/common/AppContextCommonConfig.java | 1cfaf0b89eeb816f03f01c5433697a1e44e81e69 | []
| no_license | fkarbing/contacts-mvc-proj | ae3e8776bcf6f5e4a97902da1685fe11cc255b0c | d839f89b19b3944c7b780184e755f9a9414e57be | refs/heads/master | 2016-09-06T15:10:54.858981 | 2012-12-08T20:39:55 | 2012-12-08T20:39:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,002 | java | package se.fkarbing.spring.mvc.common;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import se.fkarbing.spring.mvc.common.model.Company;
import se.fkarbing.spring.mvc.common.model.Consultant;
import se.fkarbing.spring.mvc.common.model.ConsultantSkill;
import se.fkarbing.spring.mvc.common.model.Location;
import se.fkarbing.spring.mvc.common.model.MyModel;
import se.fkarbing.spring.mvc.core.repository.GenericRepositoryInMemory;
import se.fkarbing.spring.mvc.core.repository.InMemoryModelIdManager;
import se.fkarbing.spring.mvc.core.repository.ModelIdManager;
@Configuration
public class AppContextCommonConfig {
protected Logger LOG = LoggerFactory.getLogger(this.getClass());
/*------------------ Repository - InMemory ------------------*/
/* GenericRepositoryInMemory<Company> */
@Bean
public GenericRepositoryInMemory<Company> companyRepository() {
GenericRepositoryInMemory<Company> companyRepository = new GenericRepositoryInMemory<Company>();
LOG.trace("### AppContextCommonConfig: companyRepository...");
return companyRepository;
}
/* GenericRepositoryInMemory<Location> */
@Bean
public GenericRepositoryInMemory<Location> locationRepository() {
GenericRepositoryInMemory<Location> locationRepository = new GenericRepositoryInMemory<Location>();
LOG.trace("### AppContextCommonConfig: locationRepository...");
return locationRepository;
}
/* GenericRepositoryInMemory<ConsultantSkill> */
@Bean
public GenericRepositoryInMemory<ConsultantSkill> consultantSkillRepository() {
GenericRepositoryInMemory<ConsultantSkill> consultantSkillRepository = new GenericRepositoryInMemory<ConsultantSkill>();
LOG.trace("### AppContextCommonConfig: consultantSkillRepository...");
return consultantSkillRepository;
}
/* GenericRepositoryInMemory<Consultant> */
@Bean
public GenericRepositoryInMemory<Consultant> consultantRepository() {
GenericRepositoryInMemory<Consultant> consultantRepository = new GenericRepositoryInMemory<Consultant>();
LOG.trace("### AppContextCommonConfig: consultantRepository...");
return consultantRepository;
}
/* GenericRepositoryInMemory<MyModel> */
@Bean
public GenericRepositoryInMemory<MyModel> modelRepository() {
GenericRepositoryInMemory<MyModel> modelRepository = new GenericRepositoryInMemory<MyModel>();
LOG.trace("### AppContextCommonConfig: modelRepository...");
return modelRepository;
}
/*------------------ RepositoryIdManager ------------------*/
@Bean
public ModelIdManager idManager() {
ModelIdManager idManager = new InMemoryModelIdManager();
LOG.info("### AppContextCommonConfig: idManager...");
return idManager;
}
/*------------------ CacheLoader ------------------*/
/*
* @Bean public MyModelCacheLoader myModelCacheLoader() { MyModelCacheLoader
* myModelCacheLoader = new MyModelCacheLoader(); return myModelCacheLoader;
* }
*/
}
| [
"[email protected]"
]
| |
d2b1b0556fff8cd8dcbc892f4764b8b4e6359d0c | 13dcc143b10c13bd88d061f63130b49e12903bf3 | /app/src/test/java/com/example/anshul/facebooklogin/ExampleUnitTest.java | 6e1a868e30412b6a36071f0971884605d202d2b6 | []
| no_license | MohiniBudhauliya/Facebook-GoogleLogin-Moovlee- | c3893c641c2087745619d8582d906042d42255b9 | f5652ec071c5fd121c4ff9d4c78db3f67c606814 | refs/heads/master | 2021-07-21T03:51:35.090123 | 2017-10-30T08:40:03 | 2017-10-30T08:40:03 | 108,651,850 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 410 | java | package com.example.anshul.facebooklogin;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
0c00a8cdcaf2444439a352f65a7eb4e5a81e5680 | 4cfd028278448364a9c11bf455f28613c06d00c2 | /server/src/main/java/edu/byu/cs/tweeter/server/service/LogoutServiceImpl.java | db4ed4f61c411b6b200a21b4b0c96f01a78ba870 | []
| no_license | hpurba/M3Tweeter-2021 | ce8166a1e585ed2f888a2bf31e0bad4fe8b12b05 | b0194ba23a940e84c61d86c9154078be41ba56b7 | refs/heads/main | 2023-03-31T16:37:00.102857 | 2021-04-09T07:05:20 | 2021-04-09T07:05:20 | 350,564,591 | 1 | 0 | null | 2021-03-24T22:38:10 | 2021-03-23T03:14:02 | Java | UTF-8 | Java | false | false | 751 | java | package edu.byu.cs.tweeter.server.service;
import edu.byu.cs.tweeter.model.service.ILogoutService;
import edu.byu.cs.tweeter.model.service.request.LogoutRequest;
import edu.byu.cs.tweeter.model.service.response.LogoutResponse;
import edu.byu.cs.tweeter.server.dao.LogoutDAO;
public class LogoutServiceImpl implements ILogoutService {
public LogoutResponse logout(LogoutRequest request) {
if (request == null) {
throw new RuntimeException("[BadRequest400] 400");
} else if (request.getUsername() != null && request.getClass() == null) {
throw new RuntimeException("[BadRequest500] 500");
}
return logoutDAO().logout(request);
}
LogoutDAO logoutDAO() { return new LogoutDAO(); }
}
| [
"[email protected]"
]
| |
7904143495f4c7de99df4841da3ab6fc8cf05566 | 4986799e27794bfbc76c3c76afb83ba700694dd6 | /demo3/src/main/java/com/example/demo/config/WebSecurityConfg.java | 05b9400fb50cc1c074ea75910d6acf5df2c6eff2 | []
| no_license | mayongqi/spring-boot-demo | e3882bda21cccf597b9c647da4fc10f8077e58ef | c8fae4f986bbd7227e3ee97b6437cf5f01dadb6f | refs/heads/master | 2023-06-16T02:26:22.070425 | 2021-07-12T02:05:57 | 2021-07-12T02:05:57 | 382,195,493 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,254 | java | package com.example.demo.config;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.WebSecurityConfigurer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
/**
* @program: demo3
* @description: security配置
* @author: ma
* @create: 2021-07-02 11:21
*/
@Configuration
public class WebSecurityConfg extends WebSecurityConfigurerAdapter {
private Logger logger = LoggerFactory.getLogger(WebSecurityConfg.class);
@Autowired
private MyLoginSuccessHandler myLoginSuccessHandler; //认证成功结果处理器
@Autowired
private MyLoginFailureHandler myLoginFailureHandler; //认证失败结果处理器
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests()
.antMatchers("/500").permitAll() //这里可设置一些公共都可访问的页面
.antMatchers("/403").permitAll()
.antMatchers("/404").permitAll()
.antMatchers("/user/login").permitAll() //登录页面
.antMatchers("/admin/index").hasRole("ADMIN")//指定权限为ADMIN才能访问
.antMatchers("/person").hasAnyRole("ADMIN","USER")//指定多个权限都能访问
.anyRequest() //任何其它请求
.authenticated() //都需要身份认证
.and()
.formLogin() //使用表单认证方式
.loginPage("/user/login") //默认登录页路径
.loginProcessingUrl("/user/login")//配置默认登录入口,是登录页面中form action 的地址
.successHandler(myLoginSuccessHandler)//使用自定义的成功结果处理器
.failureHandler(myLoginFailureHandler)//使用自定义失败的结果处理器
.and()
.csrf().disable();
}
/**
* 自定义认证策略
* @return
*/
@Autowired
public void configGlobal(AuthenticationManagerBuilder auth) throws Exception {
String password = passwordEncoder().encode("ma123");
logger.info("加密后的密码:" + password);
// auth.inMemoryAuthentication().withUser("admin").password(password)
// .roles("ADMIN").and();
auth.inMemoryAuthentication().withUser("ma").password(password)
.roles("USER").and();
}
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder();
}
}
| [
"[email protected]"
]
| |
d93b4f3e9e282ca255af6959cbf49ef927f6b461 | 1ab905161ef433fefe15f8d6341d4981e1e0784e | /src/main/java/com/jhoon/springboard/util/FileReaderSql.java | cba60b706a0a9d4d274d8b191aa9c76939e0b7a3 | []
| no_license | jhoon2002/board | 34b1901fa64f26f7d293515dabe436fbcee6d040 | b87b0ce3ec600f72f4d686dcc531fd670d4ed582 | refs/heads/master | 2020-12-02T10:03:13.967753 | 2017-07-09T13:26:03 | 2017-07-09T13:26:03 | 96,682,997 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 690 | java | package com.jhoon.springboard.util;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.text.ParseException;
public class FileReaderSql {
public String getQuery(String fileName) throws NumberFormatException, IOException, ParseException{
BufferedReader reader = new BufferedReader(new FileReader(fileName));
String s;
StringBuffer sb = new StringBuffer();
while((s=reader.readLine())!=null){
sb.append(s);
}
reader.close();
return sb.toString();
}
}
| [
"jhoon@DESKTOP-APQ5OF3"
]
| jhoon@DESKTOP-APQ5OF3 |
2e22b35187c732c02d9393994358b6fa795559d6 | 8157d199253a4fee1cf9142995e0c30e1398c9f7 | /src/Smile/src/com/heme/smile/NetHelperActivity.java | 537ea79e4ebf95b251a80e6072b9184abc89931b | []
| no_license | boboxu/smile | 4e3293a5b233de6459eea82ea860b1108adb613e | d4c2b66ae07441beb2a80d5c915b8f8ebb696649 | refs/heads/master | 2021-01-13T02:31:48.564821 | 2013-08-14T16:10:07 | 2013-08-14T16:10:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,521 | java | package com.heme.smile;
import java.util.ArrayList;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;
public class NetHelperActivity extends BaseActivity implements OnClickListener{
private static final String TAG = "NetHelperActivity";
private ListView mListView;
private ArrayList<NotifyData> datas = new ArrayList<NetHelperActivity.NotifyData>();
private MyAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
emulateDatas();
initUI();
}
private void initUI(){
setContentView(R.layout.nethelper);
findViewById(R.id.backImg).setOnClickListener(this);
((TextView)findViewById(R.id.titleTextView)).setText("告警信息");
mListView = (ListView)findViewById(R.id.listview);
mListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
Intent intent = new Intent(NetHelperActivity.this, SendPcCommondActivity.class);
intent.putExtra(SendPcCommondActivity.NOTIFY_ID, datas.get(arg2).id);
startActivity(intent);
}
});
adapter = new MyAdapter(this);
mListView.setAdapter(adapter);
}
private void emulateDatas(){
NotifyData data = new NotifyData();
data.id = 1;
data.time = "11:34";
data.content = "报警,你儿子正在撸管!!!";
datas.add(data);
NotifyData notifyData = new NotifyData();
notifyData.id = 2;
notifyData.time = "12:22";
notifyData.content = "报警,你儿子正在看快播";
datas.add(notifyData);
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.backImg:
finish();
break;
default:
break;
}
}
class NotifyData{
int id;
String time;
String content;
}
class MyAdapter extends BaseAdapter{
Context ctx;
public MyAdapter(Context ctx){
this.ctx = ctx;
}
@Override
public int getCount() {
if (datas==null) {
return 0;
}
return datas.size();
}
@Override
public Object getItem(int position) {
if (datas==null) {
return null;
}
return datas.get(position);
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
NotifyData data = (NotifyData)getItem(position);
if (convertView==null) {
convertView = LayoutInflater.from(ctx).inflate(R.layout.nethelper_item, null);
viewHolder = new ViewHolder();
convertView.setTag(viewHolder);
}else {
viewHolder = (ViewHolder)convertView.getTag();
}
viewHolder.time = (TextView)convertView.findViewById(R.id.time);
viewHolder.time.setText(data.time);
viewHolder.content = (TextView)convertView.findViewById(R.id.content);
viewHolder.content.setText(data.content);
return convertView;
}
}
class ViewHolder{
TextView time;
TextView content;
}
}
| [
"[email protected]"
]
| |
4db470232cabe843e1cb34aca101f4449c505738 | a7f96146a56ffcefd90b2934adf796f0c7bc28b0 | /app/src/main/java/com/routon/testsr/scan/BleScan.java | 57ed5483a3b6d5df88439d1641876f9c58bf0e6c | []
| no_license | ty819929470/TestSR | aafd3ff09c264602d64e6a9accf5974636ec44ed | e360913bf76c993e63f4eea4f74c66ca73a3e942 | refs/heads/master | 2021-09-09T12:40:55.876145 | 2018-03-16T06:10:28 | 2018-03-16T06:10:28 | 125,470,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,483 | java | package com.routon.testsr.scan;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import com.routon.testsr.utils.BleUtils;
import com.routon.testsr.utils.Const;
import com.routon.testsr.utils.Utils;
import com.routon.testsrUI.BleActivity;
import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.le.BluetoothLeScanner;
import android.bluetooth.le.ScanCallback;
import android.bluetooth.le.ScanFilter;
import android.bluetooth.le.ScanResult;
import android.bluetooth.le.ScanSettings;
import android.os.Bundle;
import android.os.Message;
import android.util.Log;
public class BleScan {
private static final String TAG = "BleScan";
private BluetoothLeScanner mLeScanner;
private List<ScanFilter> mScanFilter = new ArrayList<ScanFilter>();
private boolean mStarted = true;
public BleScan(BluetoothLeScanner scanner) {
// TODO Auto-generated constructor stub
this.mLeScanner = scanner;
}
public BleScan(BluetoothLeScanner scanner, List<ScanFilter> filters) {
// TODO Auto-generated constructor stub
this.mLeScanner = scanner;
this.mScanFilter = filters;
}
public void setWhiteName(String whiteName) {
mScanFilter.removeAll(mScanFilter);
ScanFilter filter = new ScanFilter.Builder()
.setDeviceAddress(whiteName).build();
mScanFilter.add(filter);
Log.i(TAG, "whiteName : " + whiteName);
}
public void startScan() {
Log.d(TAG, "start scan with utils.cmd ");
new Thread() {
@Override
public void run() {
ScanSettings scanSettings = new ScanSettings.Builder()
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
.build();
mLeScanner.startScan(mScanFilter, scanSettings, mScanCallback);
}
}.start();
}
public void stopScan() {
mLeScanner.stopScan(mScanCallback);
Log.d(TAG, "stop scan...");
mScanFilter.clear();
}
public void shutScan() {
Log.d(TAG, "shutup scan...");
mStarted = false;
}
public void continueScan() {
mStarted = true;
Log.d(TAG, "continue scan...");
}
public int getManuId(byte Bsn, byte iden) {
int manuid = 0;
manuid += (iden & 0xFF) << 8;
manuid += Bsn & 0xFF;
return manuid;
}
@SuppressLint("NewApi")
private ScanCallback mScanCallback = new ScanCallback() {
@Override
public void onScanResult(int callbackType, ScanResult result) {
BluetoothDevice device = result.getDevice();
String mac = device.getAddress();
String name = device.getName();
int rssi = result.getRssi();
// byte[] manufacturers =
// result.getScanRecord().getManufacturerSpecificData(BleAdv.manuId);
// byte[] manufacturers = result.getScanRecord()
// .getManufacturerSpecificData(
// getManuId((byte) Const.BSN_S1701,
// (byte) Const.S1701));
// 数据格式:Len ADType BSn Iden Cmd Data
byte[] manufacturers = result.getScanRecord().getBytes();
int length = 0;
if (manufacturers != null) {
length = manufacturers[0];
Log.i(TAG, "manufacturers = " + Arrays.toString(manufacturers));
//ADType == 0xff 说明是我们需要的的广播
// if ((manufacturers[1] & 0xFF) == Const.BLE_ADV_FACT) {
if (mac != null) {// 不发送重复包
Message msg = BtService.mRevHandler.obtainMessage(Utils.UploadData);
Bundle bundle = new Bundle();
bundle.putString("mac", mac);
bundle.putInt("rssi", rssi);
bundle.putByteArray("data", manufacturers);
bundle.putString("name", name);
msg.setData(bundle);
msg.sendToTarget();
}
}
}
// }
@Override
public void onScanFailed(int errorCode) {
Log.d(TAG, "scan failed !!! errorCode = " + errorCode);
super.onScanFailed(errorCode);
}
};
}
| [
"[email protected]"
]
| |
f8903cbd559108005dba285e940197935ff38ac7 | 6394cd6970e701b59e937a9754ea8b69609607b7 | /data-model/ubl-data-model/src/main/java/eu/nimble/service/model/ubl/commonaggregatecomponents/MultiTypeValueType.java | eb79208fa58c8f902aea65dec48b752c160a3bcb | [
"Apache-2.0"
]
| permissive | nimble-platform/common | d8eacbe065c5270873a7c16095f3e25f51c99832 | ff645dd88685a5b91b58f16f3099b78176c0262a | refs/heads/master | 2023-08-01T15:10:30.181827 | 2023-04-17T10:27:12 | 2023-04-17T10:27:12 | 106,780,293 | 2 | 3 | Apache-2.0 | 2023-07-07T21:29:36 | 2017-10-13T05:08:21 | Java | UTF-8 | Java | false | false | 15,855 | java | //
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.11
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2019.06.27 at 05:28:58 PM MSK
//
package eu.nimble.service.model.ubl.commonaggregatecomponents;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import eu.nimble.service.model.BigDecimalXmlAdapter;
import eu.nimble.service.model.ubl.commonbasiccomponents.CodeType;
import eu.nimble.service.model.ubl.commonbasiccomponents.QuantityType;
import eu.nimble.service.model.ubl.commonbasiccomponents.TextType;
import org.hibernate.annotations.Cascade;
import org.jvnet.hyperjaxb3.item.ItemUtils;
import org.jvnet.jaxb2_commons.lang.Equals;
import org.jvnet.jaxb2_commons.lang.EqualsStrategy;
import org.jvnet.jaxb2_commons.lang.JAXBEqualsStrategy;
import org.jvnet.jaxb2_commons.locator.ObjectLocator;
import org.jvnet.jaxb2_commons.locator.util.LocatorUtils;
/**
* <p>Java class for MultiTypeValueType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="MultiTypeValueType">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}Name"/>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}ValueQualifier"/>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}Value" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}ValueQuantity" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}ValueDecimal" maxOccurs="unbounded" minOccurs="0"/>
* <element ref="{urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2}ValueCode" maxOccurs="unbounded" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "MultiTypeValueType", propOrder = {
"name",
"valueQualifier",
"value",
"valueQuantity",
"valueDecimal",
"valueCode"
})
@Entity(name = "MultiTypeValueType")
@Table(name = "MULTI_TYPE_VALUE_TYPE")
@Inheritance(strategy = InheritanceType.JOINED)
public class MultiTypeValueType
implements Serializable, Equals
{
private final static long serialVersionUID = 1L;
@XmlElement(name = "Name", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2", required = true)
protected TextType name;
@XmlElement(name = "ValueQualifier", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2", required = true)
protected String valueQualifier;
@XmlElement(name = "Value", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")
protected List<TextType> value;
@XmlElement(name = "ValueQuantity", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")
protected List<QuantityType> valueQuantity;
@XmlElement(name = "ValueDecimal", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2", type = String.class)
@XmlJavaTypeAdapter(BigDecimalXmlAdapter.class)
protected List<BigDecimal> valueDecimal;
@XmlElement(name = "ValueCode", namespace = "urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2")
protected List<CodeType> valueCode;
@XmlAttribute(name = "Hjid")
protected Long hjid;
protected transient List<MultiTypeValueTypeValueDecimalItem> valueDecimalItems;
/**
* Gets the value of the name property.
*
* @return
* possible object is
* {@link TextType }
*
*/
@ManyToOne(targetEntity = TextType.class, cascade = {
javax.persistence.CascadeType.ALL
})
@JoinColumn(name = "NAME__MULTI_TYPE_VALUE_TYPE__0")
public TextType getName() {
return name;
}
/**
* Sets the value of the name property.
*
* @param value
* allowed object is
* {@link TextType }
*
*/
public void setName(TextType value) {
this.name = value;
}
/**
* Gets the value of the valueQualifier property.
*
* @return
* possible object is
* {@link String }
*
*/
@Basic
@Column(name = "VALUE_QUALIFIER", length = 255)
public String getValueQualifier() {
return valueQualifier;
}
/**
* Sets the value of the valueQualifier property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setValueQualifier(String value) {
this.valueQualifier = value;
}
/**
* Gets the value of the value property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the value property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getValue().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link TextType }
*
*
*/
@OneToMany(orphanRemoval = true,targetEntity = TextType.class, cascade = {
javax.persistence.CascadeType.ALL
})
@JoinColumn(name = "VALUE__MULTI_TYPE_VALUE_TYPE_0")
public List<TextType> getValue() {
if (value == null) {
value = new ArrayList<TextType>();
}
return this.value;
}
/**
*
*
*/
public void setValue(List<TextType> value) {
this.value = value;
}
/**
* Gets the value of the valueQuantity property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the valueQuantity property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getValueQuantity().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link QuantityType }
*
*
*/
@OneToMany(orphanRemoval = true,targetEntity = QuantityType.class, cascade = {
javax.persistence.CascadeType.ALL
})
@JoinColumn(name = "VALUE_QUANTITY_MULTI_TYPE_VA_0")
public List<QuantityType> getValueQuantity() {
if (valueQuantity == null) {
valueQuantity = new ArrayList<QuantityType>();
}
return this.valueQuantity;
}
/**
*
*
*/
public void setValueQuantity(List<QuantityType> valueQuantity) {
this.valueQuantity = valueQuantity;
}
/**
* Gets the value of the valueDecimal property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the valueDecimal property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getValueDecimal().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link String }
*
*
*/
@Transient
public List<BigDecimal> getValueDecimal() {
if (valueDecimal == null) {
valueDecimal = new ArrayList<BigDecimal>();
}
return this.valueDecimal;
}
/**
*
*
*/
public void setValueDecimal(List<BigDecimal> valueDecimal) {
this.valueDecimal = valueDecimal;
}
/**
* Gets the value of the valueCode property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the valueCode property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getValueCode().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link CodeType }
*
*
*/
@OneToMany(orphanRemoval = true,targetEntity = CodeType.class, cascade = {
javax.persistence.CascadeType.ALL
})
@JoinColumn(name = "VALUE_CODE_MULTI_TYPE_VALUE__0")
public List<CodeType> getValueCode() {
if (valueCode == null) {
valueCode = new ArrayList<CodeType>();
}
return this.valueCode;
}
/**
*
*
*/
public void setValueCode(List<CodeType> valueCode) {
this.valueCode = valueCode;
}
public boolean equals(ObjectLocator thisLocator, ObjectLocator thatLocator, Object object, EqualsStrategy strategy) {
if ((object == null)||(this.getClass()!= object.getClass())) {
return false;
}
if (this == object) {
return true;
}
final MultiTypeValueType that = ((MultiTypeValueType) object);
{
TextType lhsName;
lhsName = this.getName();
TextType rhsName;
rhsName = that.getName();
if (!strategy.equals(LocatorUtils.property(thisLocator, "name", lhsName), LocatorUtils.property(thatLocator, "name", rhsName), lhsName, rhsName)) {
return false;
}
}
{
String lhsValueQualifier;
lhsValueQualifier = this.getValueQualifier();
String rhsValueQualifier;
rhsValueQualifier = that.getValueQualifier();
if (!strategy.equals(LocatorUtils.property(thisLocator, "valueQualifier", lhsValueQualifier), LocatorUtils.property(thatLocator, "valueQualifier", rhsValueQualifier), lhsValueQualifier, rhsValueQualifier)) {
return false;
}
}
{
List<TextType> lhsValue;
lhsValue = (((this.value!= null)&&(!this.value.isEmpty()))?this.getValue():null);
List<TextType> rhsValue;
rhsValue = (((that.value!= null)&&(!that.value.isEmpty()))?that.getValue():null);
if (!strategy.equals(LocatorUtils.property(thisLocator, "value", lhsValue), LocatorUtils.property(thatLocator, "value", rhsValue), lhsValue, rhsValue)) {
return false;
}
}
{
List<QuantityType> lhsValueQuantity;
lhsValueQuantity = (((this.valueQuantity!= null)&&(!this.valueQuantity.isEmpty()))?this.getValueQuantity():null);
List<QuantityType> rhsValueQuantity;
rhsValueQuantity = (((that.valueQuantity!= null)&&(!that.valueQuantity.isEmpty()))?that.getValueQuantity():null);
if (!strategy.equals(LocatorUtils.property(thisLocator, "valueQuantity", lhsValueQuantity), LocatorUtils.property(thatLocator, "valueQuantity", rhsValueQuantity), lhsValueQuantity, rhsValueQuantity)) {
return false;
}
}
{
List<BigDecimal> lhsValueDecimal;
lhsValueDecimal = (((this.valueDecimal!= null)&&(!this.valueDecimal.isEmpty()))?this.getValueDecimal():null);
List<BigDecimal> rhsValueDecimal;
rhsValueDecimal = (((that.valueDecimal!= null)&&(!that.valueDecimal.isEmpty()))?that.getValueDecimal():null);
if (!strategy.equals(LocatorUtils.property(thisLocator, "valueDecimal", lhsValueDecimal), LocatorUtils.property(thatLocator, "valueDecimal", rhsValueDecimal), lhsValueDecimal, rhsValueDecimal)) {
return false;
}
}
{
List<CodeType> lhsValueCode;
lhsValueCode = (((this.valueCode!= null)&&(!this.valueCode.isEmpty()))?this.getValueCode():null);
List<CodeType> rhsValueCode;
rhsValueCode = (((that.valueCode!= null)&&(!that.valueCode.isEmpty()))?that.getValueCode():null);
if (!strategy.equals(LocatorUtils.property(thisLocator, "valueCode", lhsValueCode), LocatorUtils.property(thatLocator, "valueCode", rhsValueCode), lhsValueCode, rhsValueCode)) {
return false;
}
}
return true;
}
public boolean equals(Object object) {
final EqualsStrategy strategy = JAXBEqualsStrategy.INSTANCE;
return equals(null, null, object, strategy);
}
/**
* Gets the value of the hjid property.
*
* @return
* possible object is
* {@link Long }
*
*/
@Id
@Column(name = "HJID")
@GeneratedValue(strategy = GenerationType.AUTO)
public Long getHjid() {
return hjid;
}
/**
* Sets the value of the hjid property.
*
* @param value
* allowed object is
* {@link Long }
*
*/
public void setHjid(Long value) {
this.hjid = value;
}
@OneToMany(orphanRemoval = true, targetEntity = MultiTypeValueTypeValueDecimalItem.class, cascade = {
javax.persistence.CascadeType.ALL
})
@JoinColumn(name = "VALUE_DECIMAL_ITEMS_MULTI_TY_0")
public List<MultiTypeValueTypeValueDecimalItem> getValueDecimalItems() {
if (this.valueDecimalItems == null) {
this.valueDecimalItems = new ArrayList<MultiTypeValueTypeValueDecimalItem>();
}
if (ItemUtils.shouldBeWrapped(this.valueDecimal)) {
this.valueDecimal = ItemUtils.wrap(this.valueDecimal, this.valueDecimalItems, MultiTypeValueTypeValueDecimalItem.class);
}
return this.valueDecimalItems;
}
public void setValueDecimalItems(List<MultiTypeValueTypeValueDecimalItem> value) {
this.valueDecimal = null;
this.valueDecimalItems = null;
this.valueDecimalItems = value;
if (this.valueDecimalItems == null) {
this.valueDecimalItems = new ArrayList<MultiTypeValueTypeValueDecimalItem>();
}
if (ItemUtils.shouldBeWrapped(this.valueDecimal)) {
this.valueDecimal = ItemUtils.wrap(this.valueDecimal, this.valueDecimalItems, MultiTypeValueTypeValueDecimalItem.class);
}
}
}
| [
"[email protected]"
]
| |
3286e839ac9bff9afb1db7b4ba595c70ad72663a | aac03b4b65a894d35aa446e673528e149b96268f | /src/main/java/org/penguin/kayako/HttpRequestExecutorImpl.java | ada063fc6848cee8951cc2b7d78b7becc85a51f9 | [
"MIT"
]
| permissive | gssandhu/kayako-api | bf1544826331bd5491b0ed70ea64a1bec6359168 | 2fa3691a53f698058f0df117868763666fd474dc | refs/heads/master | 2020-03-24T02:00:20.968988 | 2013-05-08T07:19:26 | 2013-05-08T07:23:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,030 | java | package org.penguin.kayako;
import java.io.IOException;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.ParseException;
import org.apache.http.StatusLine;
import org.apache.http.client.methods.HttpRequestBase;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
import org.penguin.kayako.exception.ApiRequestException;
public class HttpRequestExecutorImpl implements HttpRequestExecutor {
@Override
public String execute(HttpRequestBase request) throws ParseException, IOException {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpResponse response = httpClient.execute(request);
StatusLine status = response.getStatusLine();
if (HttpStatus.SC_OK != status.getStatusCode()) {
throw new ApiRequestException(new IOException("Request failed with status code: " + status.getStatusCode()));
}
return EntityUtils.toString(response.getEntity());
}
}
| [
"[email protected]"
]
| |
122ceabf70b3e9440c7856328049f7ac3667cb2c | b2f07f3e27b2162b5ee6896814f96c59c2c17405 | /com/sun/media/sound/RIFFInvalidDataException.java | c4c6aade4e9def4a55a8bd807b7dd2955088b07f | []
| no_license | weiju-xi/RT-JAR-CODE | e33d4ccd9306d9e63029ddb0c145e620921d2dbd | d5b2590518ffb83596a3aa3849249cf871ab6d4e | refs/heads/master | 2021-09-08T02:36:06.675911 | 2018-03-06T05:27:49 | 2018-03-06T05:27:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 624 | java | /* */ package com.sun.media.sound;
/* */
/* */ public final class RIFFInvalidDataException extends InvalidDataException
/* */ {
/* */ private static final long serialVersionUID = 1L;
/* */
/* */ public RIFFInvalidDataException()
/* */ {
/* 37 */ super("Invalid Data!");
/* */ }
/* */
/* */ public RIFFInvalidDataException(String paramString) {
/* 41 */ super(paramString);
/* */ }
/* */ }
/* Location: C:\Program Files\Java\jdk1.7.0_79\jre\lib\rt.jar
* Qualified Name: com.sun.media.sound.RIFFInvalidDataException
* JD-Core Version: 0.6.2
*/ | [
"[email protected]"
]
| |
8597a2eb45eb8c7b05246a9530154569412a5898 | 555e82e9adc24bb8e23c3e128f83cd74a568bafd | /src/model/dao/MySQLComprarDAO.java | 4c56c53fab4bb7c9550f07dee5d0b0a53fc61ffe | []
| no_license | araujobarret/dps | d8608fdd880ef1301ae386cda8d6fd95b8de6b14 | 62fb292eba32eea6ba2783a1a4586d687132a8b2 | refs/heads/master | 2021-06-09T08:38:12.833668 | 2016-12-05T22:03:39 | 2016-12-05T22:03:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 825 | java | package model.dao;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;
import model.Carrinho;
import model.beans.Pedido;
import model.dao.interfaces.ComprarDAO;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
public class MySQLComprarDAO implements ComprarDAO
{
// Método que faz a inserção do pedido e também dos produtos na tabela pedido_produto
@Override
public boolean save(Carrinho carrinho)
{
Pedido pedido = new Pedido();
Locale locale = Locale.forLanguageTag("pt-br");
TimeZone timeZone = TimeZone.getTimeZone("GMT");
Calendar cal = Calendar.getInstance(timeZone, locale);
pedido.setData_pedido(cal.toString());
return false;
}
}
| [
"[email protected]"
]
| |
8981bf456aab3680a3ccfd51f1f924709db325d5 | a80ea6a715ffeaa1885c95153d6f2937e052b5f2 | /myapp/boolean1.java | 856c13d24ba159c751978a3ff0a5bfbfe007455a | []
| no_license | Nmazil-Dev/Mooc-Java | 250a17800479b61ad2878d376cd3822e789c1c9a | 2d23e9ba019875695f47cd94c50eef43d8800d63 | refs/heads/main | 2023-07-13T05:12:40.701316 | 2021-08-24T19:40:53 | 2021-08-24T19:40:53 | 397,585,070 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 422 | java | package myapp;
import java.util.Scanner;
public class boolean1 {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
System.out.print("Give speed: ");
int speed = Integer.valueOf(scanner.nextLine());
if (speed > 120){
System.out.println("Speeding Ticket!");
} else {
System.out.println("Good Speed.");
}
}
} | [
"[email protected]"
]
| |
744674c412a06eb7976e68b67ae3a7cbe8e75a44 | 51118f69799dc374d72fda4af15db14833095731 | /src/main/java/app/config/AppConfig.java | ee934c1946da280892b78a82d23c7d2524c6ae74 | []
| no_license | charl0tte/spring-boot-secure | 7f4e61799ec46f80c4f2e231770211bea78201e2 | c9ed4689b36f9c22c5b8a9392334cfc9da5a7253 | refs/heads/master | 2021-01-22T05:15:38.125076 | 2017-01-21T07:18:15 | 2017-01-21T07:18:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 570 | java | package app.config;
import app.web.CorsFilter;
import org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import javax.servlet.Filter;
import java.security.SecureRandom;
import java.util.Random;
@Configuration
public class AppConfig extends WebMvcAutoConfiguration {
@Bean
public Filter corsConfigurer() {
return new CorsFilter();
}
}
| [
"[email protected]"
]
| |
ff25a4ad94f6a0aa38ff85da17a5dd25c1c72484 | 46107a96af9a0f7a30b01836aec6bb2623f7a8cf | /src/com/shahi/dec/Node.java | 33e7531e5b1081d28eed234e960605b54b2230d7 | []
| no_license | anupkuma/Practice | 1f5b00151c9e97c5e24407c1e8b59b138324dd95 | 8461dc222fca4da84d2fc5bdc50aad160343f207 | refs/heads/master | 2020-05-20T08:07:50.181126 | 2012-12-22T07:54:18 | 2012-12-22T07:54:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 637 | java | package com.shahi.dec;
public class Node {
int value;
Node next = null;
public Node(int value) {
this.value = value;
}
public void setNextNode(int d) {
// TODO Auto-generated method stub
Node end = new Node(d);
Node n = this;
while(n.next!=null){
n=n.next;
}
n.next=end;
}
public int getValue(){
return this.value;
}
public Node deleteNode(int i, Node one){
Node head = one;
if(head.value==i){
return head.next;
}
while(head.next!=null){
if(head.next.value==i){
head.next=head.next.next;
return head;
}
head=head.next;
}
return head;
}
}
| [
"[email protected]"
]
| |
5c88d3b5b5d9414b3dc2141071cd4447861f7f73 | af1f7ef26000c1856ed62402b28904d0a98f5d15 | /数据结构/数据结构(java版)第4版-叶核亚[全套资料]/[数据结构(Java版)(第4版)][叶核亚][程序源代码]/10.3.4 回溯法【例10.6】八皇后/src/Queen.java | cf220a66c9269fde4418d79da7143deefc5a2179 | []
| no_license | 25April/doc | 2c449652ab7de50f9f875308f4622675d058ee63 | 5809ba2da9a21fc549fbb9f772239661e86d229e | refs/heads/master | 2023-02-12T02:31:11.602195 | 2021-01-02T00:19:42 | 2021-01-02T00:19:42 | 317,218,763 | 1 | 0 | null | null | null | null | GB18030 | Java | false | false | 5,776 | java | //《数据结构(Java版)(第4版)》,作者:叶核亚,2014年11月15日
//10.3 算法设计策略
//10.3.4 回溯法
//【例10.6】 八皇后。
public class Queen extends Backtrack //求解n皇后问题,默认八皇后;继承Backtrack类,回溯法求解
{
public Queen(int n) //构造方法,n指定棋盘大小即皇后个数
{
super(n,n);
if (n<=0 || n>8)
throw new java.lang.IllegalArgumentException("n="+n); //抛出无效参数异常
System.out.println("Queen("+n+"):");
}
public Queen() //构造方法,默认八皇后
{
this(8);
}
protected boolean restrict(int i) //隐约束条件,测试x[i]位置是否可放皇后。覆盖
{
// printX(i+1); //输出每个测试值,显示树的遍历路径
for (int j=0; j<i; j++)
if (x[j]==x[i] || Math.abs(i-j)==Math.abs(x[j]-x[i]))
return false;
return true;
}
public static void main(String args[])
{
new Queen(4).printAll(); //四皇后
// new Queen(8).printAll(); //八皇后
}
public void printAll() //输出所有解,遍历解空间k叉树。覆盖
{
this.count=0;
this.backtrack(); //迭代回溯,输出所有解
System.out.println(" "+count+"个解");
}
private void backtrack() //迭代回溯,输出所有解。重载
{
this.x[0]=-1;
int i=0;
while (i>=0)
{
do
this.x[i]++;
while (x[i]<x.length && !restrict(i)); //寻找第i个皇后位置
if (x[i]<x.length) //找到第i个皇后位置为x[i]
if (i!=x.length-1)
x[++i]=-1; //继续寻找第i+1个皇后位置
else //求得一个解
{
this.count++;
print(); //输出一个解
}
else i--; //没有找到第i个皇后位置,退回到第i-1个皇后位置,继续搜索其他路径
}
}
}
/*
程序运行结果如下:
Queen(1):
(1)
count=1
Queen(2):
count=0
Queen(3):
count=0
Queen(4):
(1,3,0,2),(2,0,3,1),2个解
Queen(5):
(0,2,4,1,3)
(0,3,1,4,2)
(1,3,0,2,4)
(1,4,2,0,3)
(2,0,3,1,4)
(2,4,1,3,0)
(3,0,2,4,1)
(3,1,4,2,0)
(4,1,3,0,2)
(4,2,0,3,1)
10个解
Queen(6):
(1,3,5,0,2,4)
(2,5,1,4,0,3)
(3,0,4,1,5,2)
(4,2,0,5,3,1)
4个解
Queen(7):
(0,2,4,6,1,3,5)
(0,3,6,2,5,1,4)
(0,4,1,5,2,6,3)
(0,5,3,1,6,4,2)
(1,3,0,6,4,2,5)
(1,3,5,0,2,4,6)
(1,4,0,3,6,2,5)
(1,4,2,0,6,3,5)
(1,4,6,3,0,2,5)
(1,5,2,6,3,0,4)
(1,6,4,2,0,5,3)
(2,0,5,1,4,6,3)
(2,0,5,3,1,6,4)
(2,4,6,1,3,5,0)
(2,5,1,4,0,3,6)
(2,6,1,3,5,0,4)
(2,6,3,0,4,1,5)
(3,0,2,5,1,6,4)
(3,0,4,1,5,2,6)
(3,1,6,4,2,0,5)
(3,5,0,2,4,6,1)
(3,6,2,5,1,4,0)
(3,6,4,1,5,0,2)
(4,0,3,6,2,5,1)
(4,0,5,3,1,6,2)
(4,1,5,2,6,3,0)
(4,2,0,5,3,1,6)
(4,6,1,3,5,0,2)
(4,6,1,5,2,0,3)
(5,0,2,4,6,1,3)
(5,1,4,0,3,6,2)
(5,2,0,3,6,4,1)
(5,2,4,6,0,3,1)
(5,2,6,3,0,4,1)
(5,3,1,6,4,2,0)
(5,3,6,0,2,4,1)
(6,1,3,5,0,2,4)
(6,2,5,1,4,0,3)
(6,3,0,4,1,5,2)
(6,4,2,0,5,3,1)
40个解
Queen(8):
(0,4,7,5,2,6,1,3)
(0,5,7,2,6,3,1,4)
(0,6,3,5,7,1,4,2)
(0,6,4,7,1,3,5,2)
(1,3,5,7,2,0,6,4)
(1,4,6,0,2,7,5,3)
(1,4,6,3,0,7,5,2)
(1,5,0,6,3,7,2,4)
(1,5,7,2,0,3,6,4)
(1,6,2,5,7,4,0,3)
(1,6,4,7,0,3,5,2)
(1,7,5,0,2,4,6,3)
(2,0,6,4,7,1,3,5)
(2,4,1,7,0,6,3,5)
(2,4,1,7,5,3,6,0)
(2,4,6,0,3,1,7,5)
(2,4,7,3,0,6,1,5)
(2,5,1,4,7,0,6,3)
(2,5,1,6,0,3,7,4)
(2,5,1,6,4,0,7,3)
(2,5,3,0,7,4,6,1)
(2,5,3,1,7,4,6,0)
(2,5,7,0,3,6,4,1)
(2,5,7,0,4,6,1,3)
(2,5,7,1,3,0,6,4)
(2,6,1,7,4,0,3,5)
(2,6,1,7,5,3,0,4)
(2,7,3,6,0,5,1,4)
(3,0,4,7,1,6,2,5)
(3,0,4,7,5,2,6,1)
(3,1,4,7,5,0,2,6)
(3,1,6,2,5,7,0,4)
(3,1,6,2,5,7,4,0)
(3,1,6,4,0,7,5,2)
(3,1,7,4,6,0,2,5)
(3,1,7,5,0,2,4,6)
(3,5,0,4,1,7,2,6)
(3,5,7,1,6,0,2,4)
(3,5,7,2,0,6,4,1)
(3,6,0,7,4,1,5,2)
(3,6,2,7,1,4,0,5)
(3,6,4,1,5,0,2,7)
(3,6,4,2,0,5,7,1)
(3,7,0,2,5,1,6,4)
(3,7,0,4,6,1,5,2)
(3,7,4,2,0,6,1,5)
(4,0,3,5,7,1,6,2)
(4,0,7,3,1,6,2,5)
(4,0,7,5,2,6,1,3)
(4,1,3,5,7,2,0,6)
(4,1,3,6,2,7,5,0)
(4,1,5,0,6,3,7,2)
(4,1,7,0,3,6,2,5)
(4,2,0,5,7,1,3,6)
(4,2,0,6,1,7,5,3)
(4,2,7,3,6,0,5,1)
(4,6,0,2,7,5,3,1)
(4,6,0,3,1,7,5,2)
(4,6,1,3,7,0,2,5)
(4,6,1,5,2,0,3,7)
(4,6,1,5,2,0,7,3)
(4,6,3,0,2,7,5,1)
(4,7,3,0,2,5,1,6)
(4,7,3,0,6,1,5,2)
(5,0,4,1,7,2,6,3)
(5,1,6,0,2,4,7,3)
(5,1,6,0,3,7,4,2)
(5,2,0,6,4,7,1,3)
(5,2,0,7,3,1,6,4)
(5,2,0,7,4,1,3,6)
(5,2,4,6,0,3,1,7)
(5,2,4,7,0,3,1,6)
(5,2,6,1,3,7,0,4)
(5,2,6,1,7,4,0,3)
(5,2,6,3,0,7,1,4)
(5,3,0,4,7,1,6,2)
(5,3,1,7,4,6,0,2)
(5,3,6,0,2,4,1,7)
(5,3,6,0,7,1,4,2)
(5,7,1,3,0,6,4,2)
(6,0,2,7,5,3,1,4)
(6,1,3,0,7,4,2,5)
(6,1,5,2,0,3,7,4)
(6,2,0,5,7,4,1,3)
(6,2,7,1,4,0,5,3)
(6,3,1,4,7,0,2,5)
(6,3,1,7,5,0,2,4)
(6,4,2,0,5,7,1,3)
(7,1,3,0,6,4,2,5)
(7,1,4,2,0,6,3,5)
(7,2,0,5,1,4,6,3)
(7,3,0,2,5,1,6,4)
92个解
Queen(4):
(0)
(0,0)
(0,1)
(0,2)
(0,2,0)
(0,2,1)
(0,2,2)
(0,2,3)
(0,3)
(0,3,0)
(0,3,1)
(0,3,1,0)
(0,3,1,1)
(0,3,1,2)
(0,3,1,3)
(0,3,2)
(0,3,3)
(1)
(1,0)
(1,1)
(1,2)
(1,3)
(1,3,0)
(1,3,0,0)
(1,3,0,1)
(1,3,0,2)
(1,3,0,2)
(1,3,0,3)
(1,3,1)
(1,3,2)
(1,3,3)
(2)
(2,0)
(2,0,0)
(2,0,1)
(2,0,2)
(2,0,3)
(2,0,3,0)
(2,0,3,1)
(2,0,3,1)
(2,0,3,2)
(2,0,3,3)
(2,1)
(2,2)
(2,3)
(3)
(3,0)
(3,0,0)
(3,0,1)
(3,0,2)
(3,0,2,0)
(3,0,2,1)
(3,0,2,2)
(3,0,2,3)
(3,0,3)
(3,1)
(3,1,0)
(3,1,1)
(3,1,2)
(3,1,3)
(3,2)
(3,3)
2个解
*/
| [
"[email protected]"
]
| |
8f3f33f9c6bc4cd10604d8919ccbe353320daca7 | 11f988e1cd82dd73580e50b04391abda2bf6176c | /jobs/pipeline-script-from-scm/cobertura/ken/kata/techtest/validator/Preconditions.java | 838febfec3a65170c521d52d4fa492afc76f6aaa | []
| no_license | superigno/myjenkins | 31f7b648af48157c3f4aa24b6dc29f66c0ff64a2 | 449d7a659c8f58837ba10c67beec90f09eedfe1d | refs/heads/master | 2020-12-06T10:19:23.914401 | 2020-01-20T06:12:06 | 2020-01-20T06:12:06 | 232,433,718 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,128 | java | <tr class="noCover">
<td class="line"><a name='1'/>1</td>
<td class="hits"/>
<td class="code">package ken.kata.techtest.validator;</td>
</tr>
<tr class="noCover">
<td class="line"><a name='2'/>2</td>
<td class="hits"/>
<td class="code"></td>
</tr>
<tr class="coverNone">
<td class="line"><a name='3'/>3</td>
<td class="hits">0</td>
<td class="code">public class Preconditions {</td>
</tr>
<tr class="noCover">
<td class="line"><a name='4'/>4</td>
<td class="hits"/>
<td class="code"> public static void validate(boolean condition, String message) {</td>
</tr>
<tr class="coverFull">
<td class="line"><a name='5'/>5</td>
<td class="hits">216</td>
<td class="code"> if (!condition) throw new IllegalArgumentException(message);</td>
</tr>
<tr class="coverFull">
<td class="line"><a name='6'/>6</td>
<td class="hits">214</td>
<td class="code"> }</td>
</tr>
<tr class="noCover">
<td class="line"><a name='7'/>7</td>
<td class="hits"/>
<td class="code">}</td>
</tr>
| [
"[email protected]"
]
| |
ee5a85d2b0e857757d96aa5ea27c91e5a447c03f | 48e835e6f176a8ac9ae3ca718e8922891f1e5a18 | /benchmark/training/org/apache/activemq/bugs/AMQ5035Test.java | 7a3466c039eb9761eb5fc3b4864b13ec2498fa18 | []
| no_license | STAMP-project/dspot-experiments | f2c7a639d6616ae0adfc491b4cb4eefcb83d04e5 | 121487e65cdce6988081b67f21bbc6731354a47f | refs/heads/master | 2023-02-07T14:40:12.919811 | 2019-11-06T07:17:09 | 2019-11-06T07:17:09 | 75,710,758 | 14 | 19 | null | 2023-01-26T23:57:41 | 2016-12-06T08:27:42 | null | UTF-8 | Java | false | false | 2,292 | 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.activemq.bugs;
import Session.AUTO_ACKNOWLEDGE;
import javax.jms.Connection;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.Topic;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.jmx.BrokerViewMBean;
import org.junit.Test;
public class AMQ5035Test {
private static final String CLIENT_ID = "amq-test-client-id";
private static final String DURABLE_SUB_NAME = "testDurable";
private final String xbean = "xbean:";
private final String confBase = "src/test/resources/org/apache/activemq/bugs/amq5035";
private static BrokerService brokerService;
private String connectionUri;
@Test
public void testFoo() throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(connectionUri);
Connection connection = factory.createConnection();
connection.setClientID(AMQ5035Test.CLIENT_ID);
connection.start();
Session session = connection.createSession(false, AUTO_ACKNOWLEDGE);
Topic topic = session.createTopic("Test.Topic");
MessageConsumer consumer = session.createDurableSubscriber(topic, AMQ5035Test.DURABLE_SUB_NAME);
consumer.close();
BrokerViewMBean brokerView = getBrokerView(AMQ5035Test.DURABLE_SUB_NAME);
brokerView.destroyDurableSubscriber(AMQ5035Test.CLIENT_ID, AMQ5035Test.DURABLE_SUB_NAME);
}
}
| [
"[email protected]"
]
| |
1307a702562128c7c1f0fc9b347f1257cce1ace7 | f1dc352c0ecc0f72f38bf80a4c864d2ba5d284ca | /src/main/java/test/RewriteKQWebClient.java | 56e995129ffe0979adcf6076978594fde1bf0f7b | []
| no_license | LegalCitizen/KuQ | 2de5404d51af96ebac354fa72db6c9c45a6f6934 | 83325794d2da5eb3bdf466c584e780fd905bd906 | refs/heads/master | 2022-06-20T20:56:26.333157 | 2020-03-03T06:50:52 | 2020-03-03T06:50:52 | 244,562,880 | 0 | 0 | null | 2022-06-17T02:57:29 | 2020-03-03T06:50:44 | Java | UTF-8 | Java | false | false | 1,169 | java | package test;
import com.alibaba.fastjson.JSONObject;
import com.mumu.webclient.KQWebClient;
import java.net.URI;
/**
* @ClassName KuQ
* @Author wxd
* @Date 2020/3/3
* @Version 1.0.0
**/
public class RewriteKQWebClient extends KQWebClient {
public RewriteKQWebClient(URI serverURI) {
super(serverURI);
}
@Override
public void sendPrivateMSG(String qq, String msg) {
try {
Thread.sleep(10L);
} catch (InterruptedException var4) {
var4.printStackTrace();
}
JSONObject sendMsg = new JSONObject();
sendMsg.put("act",106);
sendMsg.put("QQID",qq);
sendMsg.put("msg",msg);
super.send(sendMsg.toJSONString());
}
@Override
public void sendGroupMSG(String qq, String groupid, String msg, Boolean isAT) {
try {
Thread.sleep(10L);
} catch (InterruptedException var4) {
var4.printStackTrace();
}
JSONObject sendMsg = new JSONObject();
sendMsg.put("act",101);
sendMsg.put("groupid",groupid);
sendMsg.put("msg",msg);
super.send(sendMsg.toJSONString());
}
}
| [
"[email protected]"
]
| |
c7677f5e22801ed08ec30c7a46a24e63e1e97340 | d53b96e79b0ee10d37ae2b1f7f68a6d3543f87d4 | /MeiTu_all_baidu/src/com/duoduoapp/meitu/adapter/MainAdapter.java | 832308978430cec1fe63f9c14ac93c94e923467a | []
| no_license | ecenllen/meitu_bizhi | 52118ebcec79f8463bf32c1ebbbd95fc30fb161b | eb14121c6abefd9ece3992efef6bbc7a1dbe58b3 | refs/heads/master | 2021-08-19T19:36:09.060632 | 2017-11-27T08:17:01 | 2017-11-27T08:17:01 | 112,167,385 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,846 | java | package com.duoduoapp.meitu.adapter;
import android.content.Context;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.duoduoapp.meitu.bean.MainListBean;
import com.duoduoapp.meitu.utils.RecyclerViewOnItemClickListener;
import com.duoduoapp.meitu.utils.SelectUrlUtils;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.interfaces.DraweeController;
import com.facebook.drawee.view.SimpleDraweeView;
import com.facebook.imagepipeline.common.ResizeOptions;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.hlxwdsj.bj.vz.R;
import java.util.List;
/**
* Created by dkli on 2017/11/24.
*/
public class MainAdapter extends RecyclerView.Adapter<MainAdapter.ViewHolder> {
private Context context;
private List<MainListBean> beans;
private double scale;
private RecyclerViewOnItemClickListener listener;
public MainAdapter(Context context, List<MainListBean> beans) {
this.context = context;
this.beans = beans;
scale=context.getResources().getDisplayMetrics().density;
}
public void setOnItemClickListener(RecyclerViewOnItemClickListener listener){
this.listener=listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.show2_grid_item,null);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
final int p = position;
DraweeController controller;
ImageRequest request;
MainListBean listBean=beans.get(p);
if ("ad".equals(beans.get(p).getAd_platform())) {
request= ImageRequestBuilder.newBuilderWithSource(Uri.parse(beans.get(p).getAd_thumbnail())).setResizeOptions(new ResizeOptions((int)scale*100,(int)scale*178)).build();
controller= Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(holder.iv_image.getController()).setAutoPlayAnimations(true).build();
holder.ad_log.setVisibility(View.VISIBLE);
holder.tv_text.setText(beans.get(p).getAd_name());
}else {
request= ImageRequestBuilder.newBuilderWithSource(Uri.parse(SelectUrlUtils.selectUrl(beans.get(p)))).setResizeOptions(new ResizeOptions((int)scale*100,(int)scale*178)).build();
controller= Fresco.newDraweeControllerBuilder().setImageRequest(request).setOldController(holder.iv_image.getController()).setAutoPlayAnimations(true).build();
holder.ad_log.setVisibility(View.GONE);
holder.tv_text.setText("1");
}
holder.iv_image.setController(controller);
}
@Override
public int getItemCount() {
return beans!=null?beans.size():0;
}
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener{
private RelativeLayout rl_content;
private SimpleDraweeView iv_image;
private View ad_log;
private TextView tv_text;
public ViewHolder(View itemView) {
super(itemView);
rl_content= (RelativeLayout) itemView.findViewById(R.id.rl_content);
iv_image= (SimpleDraweeView) itemView.findViewById(R.id.iv_image);
ad_log=itemView.findViewById(R.id.ad_log);
tv_text= (TextView) itemView.findViewById(R.id.tv_text);
rl_content.setOnClickListener(this);
}
@Override
public void onClick(View v) {
listener.onItemClick(v,getLayoutPosition());
}
}
}
| [
"[email protected]"
]
| |
28da9844f1a77849c4cb1477cf3a913baa286cae | 86a182dc48660fcebc37df4a1848ef81071cd0e8 | /RecyclerView/app/src/main/java/yoghurt/recyclerview/MainActivity.java | 4806c947d2f0d9e56caa047d4461ae1f51835b19 | []
| no_license | YoGhurt111/AndroidStudy | dde38bf183dd533aab37747d833e7821b2849c71 | a8c3b512c5313eaa3dc09cf071f3e92deadc8c59 | refs/heads/master | 2021-01-12T08:34:07.660574 | 2017-02-22T15:05:03 | 2017-02-22T15:05:03 | 76,613,862 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,533 | java | package yoghurt.recyclerview;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.AppCompatDrawableManager;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Toast;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
private List<Fruit> fruitList = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initFruits();
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.recycler_view);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3,
StaggeredGridLayoutManager.VERTICAL);
//LinearLayoutManager layoutManager = new LinearLayoutManager(this);
//layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
recyclerView.setLayoutManager(layoutManager);
FruitAdapter adapter = new FruitAdapter(fruitList);
recyclerView.setAdapter(adapter);
}
private void initFruits(){
for(int i=0;i<2;i++){
Fruit apple = new Fruit("Apple", R.drawable.apple_pic);
fruitList.add(apple);
Fruit banana = new Fruit("Banana", R.drawable.banana_pic);
fruitList.add(banana);
Fruit orange = new Fruit("Orange", R.drawable.orange_pic);
fruitList.add(orange);
Fruit watermelon = new Fruit("Watermelon", R.drawable.watermelon_pic);
fruitList.add(watermelon);
Fruit pear = new Fruit("Pear", R.drawable.pear_pic);
fruitList.add(pear);
Fruit grape = new Fruit("Grape", R.drawable.grape_pic);
fruitList.add(grape);
Fruit pineapple = new Fruit("Pineapple", R.drawable.pineapple_pic);
fruitList.add(pineapple);
Fruit strawberry = new Fruit("Strawberry", R.drawable.strawberry_pic);
fruitList.add(strawberry);
Fruit cherry = new Fruit("Cherry", R.drawable.cherry_pic);
fruitList.add(cherry);
Fruit mango = new Fruit("Mango", R.drawable.mango_pic);
fruitList.add(mango);
}
}
}
| [
"[email protected]"
]
| |
44a7bab89c01c1b0c95cf6186642fa528f4783c3 | bb9ae26f5c140a7cbdc909d1848492d9d8fefaf2 | /Scooter_Admin/src/java/servlets/DeleteModelServlet.java | 1c56f1526c85c54d0f58369fec8bc24ebd58d966 | []
| no_license | Maisuki/ModernVespa | 9845ef6039ecadb8291256aafca92bdbfee7dd4a | cfa9944f9813b523b55efbb755673527aae3fad7 | refs/heads/master | 2021-07-06T22:26:59.851224 | 2019-09-12T07:42:08 | 2019-09-12T07:42:08 | 171,614,994 | 0 | 0 | null | 2020-08-20T15:33:29 | 2019-02-20T06:34:01 | JavaScript | UTF-8 | Java | false | false | 2,020 | java | package servlets;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import common.Global;
import controller.RefererCheckManager;
import controller.SNServer;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet(name = "DeleteModelServlet", urlPatterns = {"/deleteModel"})
public class DeleteModelServlet extends HttpServlet {
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String referer = request.getHeader("Referer");
if (referer == null) {
response.getWriter().println("Unauthorized access!");
return;
}
if (!RefererCheckManager.refererCheck(referer, "updateBM.jsp")) {
response.getWriter().println("Unauthorized access!");
return;
}
String bnmID = request.getParameter("bnmID");
String indexToRemove = request.getParameter("index");
if (bnmID == null || bnmID.trim().isEmpty() ||
indexToRemove == null || indexToRemove.trim().isEmpty()) {
JsonObject error = new JsonObject();
error.addProperty("status", false);
error.addProperty("message", "bnmID and index are required!");
response.getWriter().println(new Gson().toJson(error));
return;
}
String POST_URL = Global.BASE_URL + "/removeModel";
String POST_PARAMS = "bid=" + bnmID + "&indexToRemove=" + indexToRemove;
String result = SNServer.sendPOST(POST_URL, POST_PARAMS);
JsonObject obj = new JsonParser().parse(result).getAsJsonObject();
response.getWriter().println(new Gson().toJson(obj));
}
}
| [
"[email protected]"
]
| |
1f342f2b7173c9e39e0f735845aa9e38d4b59f56 | d1299b6eb4fd6f1054686ad323629aaa0baf3c7e | /app/src/main/java/com/example/wangzhibo/lovestudy/service/SendThread.java | 056de2e8710ba0ed2c8be4c6fc4fa34d2031f51d | []
| no_license | Shanshsn/LoveStudy | 669119b8ff73792ab1c40b5dfee552c8ad734df5 | 39c686f07f530de078a70796b9b0433f033f61ac | refs/heads/master | 2022-02-25T20:39:20.351133 | 2019-11-08T10:52:38 | 2019-11-08T10:52:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,184 | java | package com.example.wangzhibo.lovestudy.service;
/**
* AIDL 跨进程Activity、Service的观察者模式实现与源码解读(附github源码)
* https://blog.csdn.net/wangzhibo666/article/details/86667934
* Created by samwangzhibo on 2019/1/23.
*/
class SendThread extends Thread {
int num = 0;
boolean isEnd = false;
private final int DURATION_SLEEP = 1000;
ITaskCallback iTaskCallback;
/**
* 关闭线程
* @param end
*/
void setEnd(boolean end) {
isEnd = end;
}
public int getNum(){
return num;
}
@Override
public void run() {
super.run();
while (!isEnd) {
num++;
if (iTaskCallback != null){
iTaskCallback.onTasking(num);
}
try {
//不释放资源 休眠
Thread.sleep(DURATION_SLEEP);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
public void setITaskCallback(ITaskCallback iTaskCallback) {
this.iTaskCallback = iTaskCallback;
}
interface ITaskCallback{
void onTasking(int num);
}
} | [
"[email protected]"
]
| |
5ca8394248b2b514cb875e7e2a8fa66b266db5ac | 2b5219d338c75886ebcdb81f2293b43ceeea01ff | /src/main/java/com/wmte/service/impl/LocationServiceImpl.java | 05ea9ec99e3acb533d91a301aef3559caa3fb0e9 | []
| no_license | wtme/wtmt-monolithic | d76287d197b8b906ee021284f821a1337f7c0c2e | ce4419de1ee498d9b110f89306015606257eb8e3 | refs/heads/develop | 2022-12-21T11:29:48.212069 | 2019-10-25T16:02:36 | 2019-10-25T16:02:36 | 213,646,445 | 0 | 0 | null | 2022-12-16T05:06:17 | 2019-10-08T13:16:05 | Java | UTF-8 | Java | false | false | 2,552 | java | package com.wmte.service.impl;
import com.wmte.service.LocationService;
import com.wmte.domain.Location;
import com.wmte.repository.LocationRepository;
import com.wmte.service.dto.LocationDTO;
import com.wmte.service.mapper.LocationMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Optional;
/**
* Service Implementation for managing {@link Location}.
*/
@Service
@Transactional
public class LocationServiceImpl implements LocationService {
private final Logger log = LoggerFactory.getLogger(LocationServiceImpl.class);
private final LocationRepository locationRepository;
private final LocationMapper locationMapper;
public LocationServiceImpl(LocationRepository locationRepository, LocationMapper locationMapper) {
this.locationRepository = locationRepository;
this.locationMapper = locationMapper;
}
/**
* Save a location.
*
* @param locationDTO the entity to save.
* @return the persisted entity.
*/
@Override
public LocationDTO save(LocationDTO locationDTO) {
log.debug("Request to save Location : {}", locationDTO);
Location location = locationMapper.toEntity(locationDTO);
location = locationRepository.save(location);
return locationMapper.toDto(location);
}
/**
* Get all the locations.
*
* @param pageable the pagination information.
* @return the list of entities.
*/
@Override
@Transactional(readOnly = true)
public Page<LocationDTO> findAll(Pageable pageable) {
log.debug("Request to get all Locations");
return locationRepository.findAll(pageable)
.map(locationMapper::toDto);
}
/**
* Get one location by id.
*
* @param id the id of the entity.
* @return the entity.
*/
@Override
@Transactional(readOnly = true)
public Optional<LocationDTO> findOne(Long id) {
log.debug("Request to get Location : {}", id);
return locationRepository.findById(id)
.map(locationMapper::toDto);
}
/**
* Delete the location by id.
*
* @param id the id of the entity.
*/
@Override
public void delete(Long id) {
log.debug("Request to delete Location : {}", id);
locationRepository.deleteById(id);
}
}
| [
"[email protected]"
]
| |
d23dcba3a30bcd83b894b34aa6447a9a1a2a6abe | 0ac05e3da06d78292fdfb64141ead86ff6ca038f | /OSWE/oswe/openCRX/rtjar/rt.jar.src/sun/tools/jar/resources/jar_sv.java | 0996aa8ba9f96670fd27b23ee6b933883e091f54 | []
| no_license | qoo7972365/timmy | 31581cdcbb8858ac19a8bb7b773441a68b6c390a | 2fc8baba4f53d38dfe9c2b3afd89dcf87cbef578 | refs/heads/master | 2023-07-26T12:26:35.266587 | 2023-07-17T12:35:19 | 2023-07-17T12:35:19 | 353,889,195 | 7 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,161 | java | /* */ package sun.tools.jar.resources;
/* */
/* */ import java.util.ListResourceBundle;
/* */
/* */ public final class jar_sv extends ListResourceBundle {
/* */ protected final Object[][] getContents() {
/* 7 */ return new Object[][] { { "error.bad.cflag", "för c-flaggan måste manifest- eller indatafiler anges." }, { "error.bad.eflag", "e-flaggan och manifest med attributet Main-Class kan inte anges \ntillsammans." }, { "error.bad.option", "Ett av alternativen -{ctxu} måste anges." }, { "error.bad.uflag", "för u-flaggan måste manifest-, e-flagg- eller indatafiler anges." }, { "error.cant.open", "kan inte öppna: {0} " }, { "error.create.dir", "{0} : kunde inte skapa någon katalog" }, { "error.create.tempfile", "Kunde inte skapa en tillfällig fil" }, { "error.illegal.option", "Otillåtet alternativ: {0}" }, { "error.incorrect.length", "ogiltig längd vid bearbetning: {0}" }, { "error.nosuch.fileordir", "{0} : det finns ingen sådan fil eller katalog" }, { "error.write.file", "Ett fel inträffade vid skrivning till befintlig jar-fil." }, { "out.added.manifest", "tillagt manifestfil" }, { "out.adding", "lägger till: {0}" }, { "out.create", " skapad: {0}" }, { "out.deflated", "({0}% packat)" }, { "out.extracted", "extraherat: {0}" }, { "out.ignore.entry", "ignorerar posten {0}" }, { "out.inflated", " uppackat: {0}" }, { "out.size", "(in = {0}) (ut = {1})" }, { "out.stored", "(0% lagrat)" }, { "out.update.manifest", "uppdaterat manifest" }, { "usage", "Syntax: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...\nAlternativ:\n -c skapa nytt arkiv\n -t lista innehållsförteckning för arkiv\n -x extrahera namngivna (eller alla) filer från arkivet\n -u uppdatera befintligt arkiv\n -v generera utförliga utdata vid standardutmatning\n -f ange arkivfilens namn\n -m inkludera manifestinformation från angivet manifest\n -n utför Pack200-normalisering efter att ett nytt arkiv har skapats\n -e ange programstartpunkt för fristående applikation \n som medföljer i en jar-programfil\n -0 lagra endast; använd inte zip-komprimering\n -P behåll komponenter för inledande '/' (absolut sökväg) och \"..\" (överordnad katalog) från filnamn\n -M skapa inte någon manifestfil för posterna\n -i generera indexinformation för de angivna jar-filerna\n -C ändra till den angivna katalogen och inkludera följande fil\nOm en fil är en katalog bearbetas den rekursivt.\nNamnen på manifestfilen, arkivfilen och startpunkten anges i samma\nordning som flaggorna 'm', 'f' och 'e'.\n\nExempel 1: Så här arkiverar du två klassfiler i ett arkiv med namnet classes.jar: \n jar cvf classes.jar Foo.class Bar.class \nExempel 2: Använd en befintlig manifestfil (mymanifest) och arkivera alla\n filer från katalogen 'foo/' till 'classes.jar': \n jar cvfm classes.jar mymanifest -C foo/ .\n" } };
/* */ }
/* */ }
/* Location: /Users/timmy/timmy/OSWE/oswe/openCRX/rt.jar!/sun/tools/jar/resources/jar_sv.class
* Java compiler version: 8 (52.0)
* JD-Core Version: 1.1.3
*/ | [
"t0984456716"
]
| t0984456716 |
57d6fba11cb1e6f0d66065fd22fe0e2061b57c91 | 2426a1d820d712032191827572368a17cdee9bf9 | /NetBeansProjects/programacion-de-aplicaciones/JavaApplication2/src/prueba/ValorarVideo1.java | bb8084fa3a5f40d48ad73b673b702d7599b3b86a | []
| no_license | EnzoCorrales/LabPApps | a527bf04106091ee553228700a65af79f46685f5 | 6d46f9c0551bf746787b90db24b622e19ad001c4 | refs/heads/master | 2022-07-09T02:15:34.034977 | 2019-11-23T23:43:08 | 2019-11-23T23:43:08 | 215,820,872 | 0 | 0 | null | 2022-06-21T02:04:07 | 2019-10-17T15:03:59 | Java | UTF-8 | Java | false | false | 5,025 | 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 prueba;
import java.util.*;
import javax.swing.DefaultListModel;
import javax.swing.JList;
/**
*
* @author kangaru
*/
public class ValorarVideo1 extends javax.swing.JFrame {
/**
* Creates new form ValorarVideo1
*/
public ValorarVideo1() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList<String>(new DefaultListModel<String>());
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jList1.setModel(new DefaultListModel<String>());
String nick = prueba.ValorarVideo.jList2.getSelectedValue();
Sistema s = prueba.Inicio.sistema;
DtUsuario data = s.getDataUsuario(nick);
Collection<DtVideo> c = data.getDtVideos();
Iterator<DtVideo> it = c.iterator();
while(it.hasNext()){
DtVideo v = it.next();
((DefaultListModel)jList1.getModel()).addElement(v.getNomVideo());
}
jList1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
jList1MouseClicked(evt);
}
});
jScrollPane1.setViewportView(jList1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(139, 139, 139)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(138, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(35, 35, 35)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(86, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jList1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jList1MouseClicked
ValorarVideo2 valorar = new ValorarVideo2();
valorar.setVisible(true);
this.dispose();
}//GEN-LAST:event_jList1MouseClicked
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(ValorarVideo1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(ValorarVideo1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(ValorarVideo1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(ValorarVideo1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ValorarVideo1().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
public static javax.swing.JList<String> jList1;
private javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}
| [
"kangaru@AnaClaraPC"
]
| kangaru@AnaClaraPC |
fe72b435f77fd9fa6afd798ad2b1e80dc5b38401 | 63bc914fdb124a13186d885365501f405770421b | /src/it/finsiel/siged/mvc/presentation/action/protocollo/StampaEtichettaAction.java | a224e6c6e78f1ebcaa5b3b6ac83e327e4f808a65 | [
"Apache-2.0"
]
| permissive | grusso14/eprot | ebc014983f2d3ae49f00bc182bc05c688ebd56f7 | 691a281c9857a15a0244fbce9603ca69fbe8a6fa | refs/heads/master | 2021-01-10T10:58:46.811584 | 2016-01-30T10:47:22 | 2016-01-30T10:47:22 | 48,127,112 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,074 | java | package it.finsiel.siged.mvc.presentation.action.protocollo;
import it.finsiel.siged.constant.Constants;
import it.finsiel.siged.constant.ReturnValues;
import it.finsiel.siged.model.organizzazione.Utente;
import it.finsiel.siged.mvc.business.ConfigurazioneUtenteDelegate;
import it.finsiel.siged.mvc.presentation.actionform.protocollo.ProtocolloForm;
import it.finsiel.siged.mvc.presentation.actionform.protocollo.StampaEtichettaForm;
import it.finsiel.siged.mvc.vo.IdentityVO;
import it.finsiel.siged.mvc.vo.protocollo.ConfigurazioneUtenteVO;
import it.finsiel.siged.util.StringUtil;
import java.util.ArrayList;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.log4j.Logger;
import org.apache.struts.Globals;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import org.apache.struts.util.MessageResources;
public class StampaEtichettaAction extends Action {
static Logger logger = Logger.getLogger(StampaEtichettaAction.class
.getName());
final String IN_ALTO_DX = "In alto a destra";
final String IN_ALTO_SX = "In alto a sinistra";
final String IN_BASSO_DX = "In basso a destra";
final String IN_BASSO_SX = "In basso a sinistra";
final String STAMPA_FOGLIO_A4 = "S";
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
HttpSession session = request.getSession(true);
StampaEtichettaForm etichettaForm = (StampaEtichettaForm) form;
ActionMessages errors = new ActionMessages();
ProtocolloForm pForm = (ProtocolloForm) session
.getAttribute("protocolloForm");
IdentityVO identityVO;
Collection modalitaStampaA4 = new ArrayList();
identityVO = new IdentityVO("0", IN_ALTO_DX);
modalitaStampaA4.add(identityVO);
identityVO = new IdentityVO("1", IN_ALTO_SX);
modalitaStampaA4.add(identityVO);
identityVO = new IdentityVO("2", IN_BASSO_DX);
modalitaStampaA4.add(identityVO);
identityVO = new IdentityVO("3", IN_BASSO_SX);
modalitaStampaA4.add(identityVO);
etichettaForm.setModalitaStampaA4(modalitaStampaA4);
if (request.getParameter("btnImpostaParametriStampa") != null) {
errors = etichettaForm.validate(mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
impostaOffSet(request, etichettaForm);
}
// return mapping.getInputForward();
} else if (request.getParameter("btnSalvaConfigurazione") != null) {
ConfigurazioneUtenteDelegate cd = ConfigurazioneUtenteDelegate
.getInstance();
Utente utente = (Utente) session.getAttribute(Constants.UTENTE_KEY);
int utenteId = utente.getValueObject().getId().intValue();
errors = etichettaForm.validate(mapping, request);
if (!errors.isEmpty()) {
saveErrors(request, errors);
} else {
ConfigurazioneUtenteVO configurazioneUtenteVO = cd
.getConfigurazione(utenteId);
impostaOffSet(request, etichettaForm);
if (configurazioneUtenteVO != null
&& configurazioneUtenteVO.getReturnValue() == ReturnValues.FOUND) {
impostaParametriStampaVO(configurazioneUtenteVO,
etichettaForm);
configurazioneUtenteVO = cd
.aggiornaParametriStampante(configurazioneUtenteVO);
} else {
impostaConfigurazioneVO(configurazioneUtenteVO,
etichettaForm);
configurazioneUtenteVO = cd.salvaConfigurazione(
configurazioneUtenteVO, utenteId);
}
if (configurazioneUtenteVO.getReturnValue() == ReturnValues.FOUND) {
errors.add("CONFIGURAZIONE_UTENTE", new ActionMessage(
"operazione_ok", "", ""));
} else {
errors.add("CONFIGURAZIONE_UTENTE", new ActionMessage(
"errore_nel_salvataggio", "", ""));
}
session.setAttribute("CONFIGURAZIONE_UTENTE_PROTOCOLLO",
configurazioneUtenteVO);
}
} else if (request.getParameter("btnAnnullaStampa") != null) {
if ("I".equals(pForm.getFlagTipo())) {
return (mapping.findForward("visualizzaProtocolloIngresso"));
} else if ("U".equals(pForm.getFlagTipo())) {
return (mapping.findForward("visualizzaProtocolloUscita"));
}
}
impostaForm(etichettaForm, request, pForm.getProtocolloId());
if (!errors.isEmpty()) {
saveErrors(request, errors);
}
logger.info("Execute StampaEtichettaAction");
return (mapping.findForward("input"));
}
// public void stampaReport(HttpServletRequest request,
// HttpServletResponse response, ProtocolloForm pForm,
// StampaEtichettaForm etichettaForm) throws IOException,
// ServletException {
// ServletContext context = getServlet().getServletContext();
// OutputStream os = response.getOutputStream();
// try {
// File reportFile = new File(context.getRealPath("/")
// + FileConstants.STAMPA_ETICHETTA_PROTOCOLLO_REPORT_COMPILED);
//
// JasperReport jasperReport = (JasperReport) JRLoader
// .loadObject(reportFile.getPath());
// jasperReport.setProperty("leftMargin", String.valueOf(50));
// Map parameters = new HashMap();
// // impostazione dei margini sinistro e superiore
// parameters.put("ProtocolloId", StringUtil.formattaNumeroProtocollo(
// String.valueOf(pForm.getProtocolloId()), 12));
// parameters.put("AOO", Organizzazione.getInstance()
// .getAreaOrganizzativa(pForm.getAooId()).getValueObject()
// .getCodi_aoo());
//
// parameters.put("ImgBarcode", getImage(StringUtil
// .formattaNumeroProtocollo(String.valueOf(pForm
// .getProtocolloId()), 12)));
// if ("I".equals(pForm.getFlagTipo())) {
// parameters.put("DataProtocollo", "Ingresso del "
// + pForm.getDataRegistrazione());
// } else if ("U".equals(pForm.getFlagTipo())) {
// parameters.put("DataProtocollo", "Uscita del "
// + pForm.getDataRegistrazione());
// }
//
// parameters.put("NumeroProtocollo", StringUtil
// .formattaNumeroProtocollo(pForm.getNumeroProtocollo(), 7));
//
// if (pForm.getTitolario() != null) {
// parameters.put("Titolario", pForm.getTitolario().getCodice());
// }
//
// Collection c = new ArrayList();
// c.add("");
// CommonReportDS ds = new CommonReportDS(c);
//
// JasperPrint jasperPrint = JasperFillManager.fillReport(
// jasperReport, parameters, ds);
// response.setHeader("Content-Disposition",
// "attachment;filename=report");
//
// response.setContentType("application/pdf");
// JRPdfExporter exporter = new JRPdfExporter();
// exporter
// .setParameter(JRExporterParameter.JASPER_PRINT, jasperPrint);
// exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, os);
// MessageResources bundle = (MessageResources) request
// .getAttribute(Globals.MESSAGES_KEY);
//
// // in alto a dx
// if (etichettaForm.getModoStampaA4().equals("0")) {
// exporter
// .setParameter(JRExporterParameter.OFFSET_X,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET.X")
// .trim()));
// exporter.setParameter(JRExporterParameter.OFFSET_Y,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET").trim()));
// // in alto a sx
// } else if (etichettaForm.getModoStampaA4().equals("1")) {
// exporter.setParameter(JRExporterParameter.OFFSET_X,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET").trim()));
// exporter.setParameter(JRExporterParameter.OFFSET_Y,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET").trim()));
//
// // in basso a dx
// } else if (etichettaForm.getModoStampaA4().equals("2")) {
// exporter
// .setParameter(
// JRExporterParameter.OFFSET_X,
// new Integer(
// (String) bundle
// .getMessage("protocollo.stampa.etichette.OFFSET.X")));
// exporter
// .setParameter(
// JRExporterParameter.OFFSET_Y,
// new Integer(
// (String) bundle
// .getMessage("protocollo.stampa.etichette.OFFSET.Y")));
//
// // in basso a sx
// } else if (etichettaForm.getModoStampaA4().equals("3")) {
// exporter.setParameter(JRExporterParameter.OFFSET_X,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET").trim()));
// exporter
// .setParameter(JRExporterParameter.OFFSET_Y,
// new Integer((String) bundle.getMessage(
// "protocollo.stampa.etichette.OFFSET.Y")
// .trim()));
//
// }
// exporter.exportReport();
// } catch (Exception e) {
// logger.debug("Errore di compilazione", e);
// response.setContentType("text/plain");
// e.printStackTrace(new PrintStream(os));
// } finally {
// os.close();
// }
//
// }
//
// public void compile(ServletContext context) throws JRException {
// System.setProperty("jasper.reports.compile.class.path", context
// .getRealPath("/WEB-INF/lib/jasperreports-0.6.6.jar")
// + System.getProperty("path.separator")
// + context.getRealPath("/WEB-INF/classes/"));
//
// System.setProperty("jasper.reports.compile.temp", context
// .getRealPath("/")
// + "/WEB-INF/reports/");
// JasperCompileManager.compileReportToFile(context.getRealPath("/")
// + FileConstants.STAMPA_ETICHETTA_PROTOCOLLO_REPORT_TEMPLATE);
//
// }
//
// private Image getImage(String code) {
//
// Image image = null;
// logger.info(code);
// try {
// // Create the barcode bean
// EAN13Bean bean = new EAN13Bean();
// int dpi = FileConstants.BARCODE_DPI;
// double height = FileConstants.BARCODE_HEIGHT;
// // Configure the barcode generator
// bean.setModuleWidth(UnitConv.in2mm(1.5f / dpi)); // makes the
// // narrow
// // bar
// bean.setBarHeight(height);
// bean.setFontName("Courier");// request.getParameter("font"));
// bean.setFontSize(2.48);//
// Double.parseDouble(request.getParameter("size")));
// bean.doQuietZone(true);
// bean.setQuietZone(5);
// bean.setChecksumMode(ChecksumMode.CP_ADD);// aggiunge l'ultima
// // cifra
// try {
// // Set up the canvas provider for monochrome JPEG output
// BitmapCanvasProvider canvas = new BitmapCanvasProvider(dpi,
// BufferedImage.TYPE_BYTE_BINARY, false);
//
// // Generate the barcode
// bean.generateBarcode(canvas, code);
//
// image = canvas.getBufferedImage().getScaledInstance(-1, -1,
// Image.SCALE_DEFAULT);
//
// // Signal end of generation
// canvas.finish();
// } finally {
//
// }
// } catch (Exception e) {
// logger.error("", e);
// }
// return image;
// }
private void impostaForm(StampaEtichettaForm etichettaForm,
HttpServletRequest request, int protocolloId) {
HttpSession session = request.getSession(true);
Utente utente = (Utente) session.getAttribute(Constants.UTENTE_KEY);
String codiceDipartimento = utente.getAreaOrganizzativa()
.getDipartimento_codice();
String barCode = (codiceDipartimento == null ? "000" : StringUtil
.formattaNumeroProtocollo(codiceDipartimento, 3))
+ StringUtil.formattaNumeroProtocollo(String
.valueOf(protocolloId), 9);
etichettaForm.setBarCode(barCode);
ConfigurazioneUtenteVO configurazioneVO = null;
if (session.getAttribute("CONFIGURAZIONE_UTENTE_PROTOCOLLO") == null) {
configurazioneVO = ConfigurazioneUtenteDelegate.getInstance()
.getConfigurazione(
utente.getUfficioVOInUso().getId().intValue());
session.setAttribute("CONFIGURAZIONE_UTENTE_PROTOCOLLO",
configurazioneVO);
} else {
configurazioneVO = (ConfigurazioneUtenteVO) session
.getAttribute("CONFIGURAZIONE_UTENTE_PROTOCOLLO");
}
if (configurazioneVO != null) {
String parametriStampante = configurazioneVO
.getParametriStampante();
impostaParametriStampante(request, etichettaForm,
parametriStampante);
} else {
}
}
private void impostaFoglioA4() {
}
private void impostaParametriStampante(HttpServletRequest request,
StampaEtichettaForm etichettaForm, String parametri) {
if (parametri != null) {
String[] strings = parametri.split(";");
if (strings != null && strings.length == 9) {
etichettaForm.setMargineSinistro(strings[0]);
etichettaForm.setMargineSuperiore(strings[1]);
etichettaForm.setLarghezzaEtichetta(strings[2]);
etichettaForm.setAltezzaEtichetta(strings[3]);
etichettaForm.setTipoStampa(strings[4]);
etichettaForm.setModoStampaA4(strings[5]);
etichettaForm.setRotazione(strings[6]);
etichettaForm.setDeltaXMM(Integer.parseInt(strings[7]));
etichettaForm.setDeltaYMM(Integer.parseInt(strings[8]));
}
} else {
MessageResources bundle = (MessageResources) request
.getAttribute(Globals.MESSAGES_KEY);
etichettaForm.setModoStampaA4("1");
etichettaForm.setTipoStampa("N");
etichettaForm.setAltezzaEtichetta(bundle
.getMessage("protocollo.stampa.etichette.altezza"));
etichettaForm.setLarghezzaEtichetta(bundle
.getMessage("protocollo.stampa.etichette.larghezza"));
etichettaForm.setMargineSinistro(bundle
.getMessage("protocollo.stampa.etichette.margine.sx"));
etichettaForm
.setMargineSuperiore(bundle
.getMessage("protocollo.stampa.etichette.margine.superiore"));
impostaOffSet(request, etichettaForm);
}
}
public void impostaConfigurazioneVO(ConfigurazioneUtenteVO vo,
StampaEtichettaForm form) {
vo.setOggetto(null);
vo.setDataDocumento(null);
vo.setDestinatario(null);
vo.setMittente(null);
vo.setTipoDocumentoId(0);
vo.setTipoDocumentoId(0);
vo.setTipoMittente("F");
vo.setTitolario(0);
vo.setTitolarioId(0);
vo.setCheckAssegnatari(null);
vo.setCheckDataDocumento(null);
vo.setCheckDestinatari(null);
vo.setCheckMittente(null);
vo.setCheckOggetto(null);
vo.setCheckRicevutoIl(null);
vo.setCheckTipoDocumento(null);
vo.setCheckTipoMittente(null);
vo.setCheckTitolario(null);
impostaParametriStampaVO(vo, form);
}
private void impostaOffSet(HttpServletRequest request,
StampaEtichettaForm etichettaForm) {
MessageResources bundle = (MessageResources) request
.getAttribute(Globals.MESSAGES_KEY);
if (STAMPA_FOGLIO_A4.equals(etichettaForm.getTipoStampa())) {
if (etichettaForm.getModoStampaA4().equals("0")) {
etichettaForm.setDeltaXMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET.X")
.trim()));
etichettaForm.setDeltaYMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET")
.trim()));
// in alto a sx
} else if (etichettaForm.getModoStampaA4().equals("1")) {
etichettaForm.setDeltaXMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET")
.trim()));
etichettaForm.setDeltaYMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET")
.trim()));
// in basso a dx
} else if (etichettaForm.getModoStampaA4().equals("2")) {
etichettaForm.setDeltaXMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET.X")
.trim()));
etichettaForm.setDeltaYMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET.Y")
.trim()));
// in basso a sx
} else if (etichettaForm.getModoStampaA4().equals("3")) {
etichettaForm.setDeltaXMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET")
.trim()));
etichettaForm.setDeltaYMM(Integer.parseInt((String) bundle
.getMessage("protocollo.stampa.etichette.OFFSET.Y")
.trim()));
}
} else {
etichettaForm.setDeltaXMM(0);
etichettaForm.setDeltaYMM(0);
}
}
public void impostaParametriStampaVO(
ConfigurazioneUtenteVO configurazioneVO, StampaEtichettaForm form) {
StringBuffer parametriStampante = new StringBuffer("");
parametriStampante.append(form.getMargineSinistro()).append(";");
parametriStampante.append(form.getMargineSuperiore()).append(";");
parametriStampante.append(form.getLarghezzaEtichetta()).append(";");
parametriStampante.append(form.getAltezzaEtichetta()).append(";");
parametriStampante.append(form.getTipoStampa()).append(";");
parametriStampante.append(form.getModoStampaA4()).append(";");
parametriStampante.append(form.getRotazione()).append(";");
parametriStampante.append(form.getDeltaXMM()).append(";");
parametriStampante.append(form.getDeltaYMM());
configurazioneVO.setParametriStampante(parametriStampante.toString());
}
}
| [
"[email protected]"
]
| |
0d954efdf65975bc03840cb11a749e012965dca2 | 21d2cee9c448e466092559501900b32a96ce9748 | /edu.uci.isr.xarchlibs.apigen/src/edu/uci/isr/xarch/options/OptionsContext.java | 4a5c00e992c4cfb4f879132d271d7b93225b5c50 | []
| no_license | zheng3/AS | aa89acf9dc260442dee6b9816e2c5e9ecf001324 | 9549eb811fc0e1ff6bade062a933485edb919e4d | refs/heads/master | 2020-05-19T21:56:26.979488 | 2015-07-01T12:19:41 | 2015-07-01T12:19:41 | 38,369,692 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 24,492 | java | /*
* Copyright (c) 2000-2005 Regents of the University of California.
* All rights reserved.
*
* This software was developed at the University of California, Irvine.
*
* Redistribution and use in source and binary forms are permitted
* provided that the above copyright notice and this paragraph are
* duplicated in all such forms and that any documentation,
* advertising materials, and other materials related to such
* distribution and use acknowledge that the software was developed
* by the University of California, Irvine. The name of the
* University may not be used to endorse or promote products derived
* from this software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*/
package edu.uci.isr.xarch.options;
import java.util.*;
import edu.uci.isr.xarch.*;
import org.w3c.dom.*;
import edu.uci.isr.xarch.IXArch;
import edu.uci.isr.xarch.IXArchContext;
/**
* The context object for the options package.
* This object is used to create objects that are used
* in the options namespace.
*
* @author Automatically Generated by xArch apigen
*/
public class OptionsContext implements IOptionsContext {
protected static final String DEFAULT_ELT_NAME = "anonymousInstanceTag";
protected Document doc;
protected IXArch xArch;
/**
* Create a new OptionsContext for the given
* IXArch object.
* @param xArch XArch object to contextualize in this namespace.
*/
public OptionsContext(IXArch xArch){
if(!(xArch instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Node docRootNode = ((DOMBased)xArch).getDOMNode();
synchronized(DOMUtils.getDOMLock(docRootNode)){
this.doc = docRootNode.getOwnerDocument();
xArch.addSchemaLocation("http://www.ics.uci.edu/pub/arch/xArch/options.xsd", "http://www.isr.uci.edu/projects/xarchuci/ext/options.xsd");
this.xArch = xArch;
}
}
public IXArch getXArch(){
return xArch;
}
protected Element createElement(String name){
synchronized(DOMUtils.getDOMLock(doc)){
return doc.createElementNS(OptionsConstants.NS_URI, name);
}
}
public XArchTypeMetadata getTypeMetadata(){
return IOptionsContext.TYPE_METADATA;
}
/**
* Create an IGuard object in this namespace.
* @return New IGuard object.
*/
public IGuard createGuard(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, GuardImpl.XSD_TYPE_NSURI, GuardImpl.XSD_TYPE_NAME);
GuardImpl newElt = new GuardImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IGuard object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IGuard recontextualizeGuard(IGuard value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Create an IOptional object in this namespace.
* @return New IOptional object.
*/
public IOptional createOptional(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalImpl.XSD_TYPE_NSURI, OptionalImpl.XSD_TYPE_NAME);
OptionalImpl newElt = new OptionalImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptional object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptional recontextualizeOptional(IOptional value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Create an IOptionalComponent object in this namespace.
* @return New IOptionalComponent object.
*/
public IOptionalComponent createOptionalComponent(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalComponentImpl.XSD_TYPE_NSURI, OptionalComponentImpl.XSD_TYPE_NAME);
OptionalComponentImpl newElt = new OptionalComponentImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalComponent object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalComponent recontextualizeOptionalComponent(IOptionalComponent value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.IComponent</code>
* to one of type <code>IOptionalComponent</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.IComponent</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalComponent promoteToOptionalComponent(
edu.uci.isr.xarch.types.IComponent value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.ComponentImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.ComponentImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalComponentImpl.XSD_TYPE_NSURI,
OptionalComponentImpl.XSD_TYPE_NAME);
}
OptionalComponentImpl newElt = new OptionalComponentImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalComponent.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
/**
* Create an IOptionalConnector object in this namespace.
* @return New IOptionalConnector object.
*/
public IOptionalConnector createOptionalConnector(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalConnectorImpl.XSD_TYPE_NSURI, OptionalConnectorImpl.XSD_TYPE_NAME);
OptionalConnectorImpl newElt = new OptionalConnectorImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalConnector object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalConnector recontextualizeOptionalConnector(IOptionalConnector value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.IConnector</code>
* to one of type <code>IOptionalConnector</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.IConnector</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalConnector promoteToOptionalConnector(
edu.uci.isr.xarch.types.IConnector value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.ConnectorImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.ConnectorImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalConnectorImpl.XSD_TYPE_NSURI,
OptionalConnectorImpl.XSD_TYPE_NAME);
}
OptionalConnectorImpl newElt = new OptionalConnectorImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalConnector.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
/**
* Create an IOptionalLink object in this namespace.
* @return New IOptionalLink object.
*/
public IOptionalLink createOptionalLink(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalLinkImpl.XSD_TYPE_NSURI, OptionalLinkImpl.XSD_TYPE_NAME);
OptionalLinkImpl newElt = new OptionalLinkImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalLink object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalLink recontextualizeOptionalLink(IOptionalLink value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.ILink</code>
* to one of type <code>IOptionalLink</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.ILink</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalLink promoteToOptionalLink(
edu.uci.isr.xarch.types.ILink value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.LinkImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.LinkImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalLinkImpl.XSD_TYPE_NSURI,
OptionalLinkImpl.XSD_TYPE_NAME);
}
OptionalLinkImpl newElt = new OptionalLinkImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalLink.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
/**
* Create an IOptionalInterface object in this namespace.
* @return New IOptionalInterface object.
*/
public IOptionalInterface createOptionalInterface(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalInterfaceImpl.XSD_TYPE_NSURI, OptionalInterfaceImpl.XSD_TYPE_NAME);
OptionalInterfaceImpl newElt = new OptionalInterfaceImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalInterface object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalInterface recontextualizeOptionalInterface(IOptionalInterface value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.IInterface</code>
* to one of type <code>IOptionalInterface</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.IInterface</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalInterface promoteToOptionalInterface(
edu.uci.isr.xarch.types.IInterface value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.InterfaceImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.InterfaceImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalInterfaceImpl.XSD_TYPE_NSURI,
OptionalInterfaceImpl.XSD_TYPE_NAME);
}
OptionalInterfaceImpl newElt = new OptionalInterfaceImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalInterface.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
/**
* Create an IOptionalSignature object in this namespace.
* @return New IOptionalSignature object.
*/
public IOptionalSignature createOptionalSignature(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalSignatureImpl.XSD_TYPE_NSURI, OptionalSignatureImpl.XSD_TYPE_NAME);
OptionalSignatureImpl newElt = new OptionalSignatureImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalSignature object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalSignature recontextualizeOptionalSignature(IOptionalSignature value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.ISignature</code>
* to one of type <code>IOptionalSignature</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.ISignature</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalSignature promoteToOptionalSignature(
edu.uci.isr.xarch.types.ISignature value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.SignatureImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.SignatureImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalSignatureImpl.XSD_TYPE_NSURI,
OptionalSignatureImpl.XSD_TYPE_NAME);
}
OptionalSignatureImpl newElt = new OptionalSignatureImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalSignature.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
/**
* Create an IOptionalSignatureInterfaceMapping object in this namespace.
* @return New IOptionalSignatureInterfaceMapping object.
*/
public IOptionalSignatureInterfaceMapping createOptionalSignatureInterfaceMapping(){
Element elt = createElement(DEFAULT_ELT_NAME);
DOMUtils.addXSIType(elt, OptionalSignatureInterfaceMappingImpl.XSD_TYPE_NSURI, OptionalSignatureInterfaceMappingImpl.XSD_TYPE_NAME);
OptionalSignatureInterfaceMappingImpl newElt = new OptionalSignatureInterfaceMappingImpl(elt);
newElt.setXArch(this.getXArch());
return newElt;
}
/**
* Brings an IOptionalSignatureInterfaceMapping object created in another
* context into this context.
* @param value Object to recontextualize.
* @return <code>value</code> object in this namespace.
*/
public IOptionalSignatureInterfaceMapping recontextualizeOptionalSignatureInterfaceMapping(IOptionalSignatureInterfaceMapping value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
elt = DOMUtils.cloneAndRename(elt, doc, OptionsConstants.NS_URI, elt.getLocalName());
//elt = DOMUtils.cloneAndRename(elt, OptionsConstants.NS_URI, elt.getTagName());
//Removed next line because it causes an illegal character DOM exception
//elt.setPrefix(null);
((DOMBased)value).setDOMNode(elt);
((IXArchElement)value).setXArch(this.getXArch());
return value;
}
/**
* Promote an object of type <code>edu.uci.isr.xarch.types.ISignatureInterfaceMapping</code>
* to one of type <code>IOptionalSignatureInterfaceMapping</code>. xArch APIs
* are structured in such a way that a regular cast is not possible
* to change interface types, so casting must be done through these
* promotion functions. If the <code>edu.uci.isr.xarch.types.ISignatureInterfaceMapping</code>
* object wraps a DOM element that is the base type, then the
* <code>xsi:type</code> of the base element is promoted. Otherwise,
* it is left unchanged.
*
* This function also emits an <CODE>XArchEvent</CODE> with type
* PROMOTE_TYPE. The source for this events is the pre-promoted
* IXArchElement object (should no longer be used), and the
* target is the post-promotion object. The target name is
* the name of the interface class that was the target of the
* promotion.
*
* @param value Object to promote.
* @return Promoted object.
*/
public IOptionalSignatureInterfaceMapping promoteToOptionalSignatureInterfaceMapping(
edu.uci.isr.xarch.types.ISignatureInterfaceMapping value){
if(!(value instanceof DOMBased)){
throw new IllegalArgumentException("Cannot process non-DOM based xArch entities.");
}
Element elt = (Element)((DOMBased)value).getDOMNode();
if(DOMUtils.hasXSIType(elt,
edu.uci.isr.xarch.types.SignatureInterfaceMappingImpl.XSD_TYPE_NSURI,
edu.uci.isr.xarch.types.SignatureInterfaceMappingImpl.XSD_TYPE_NAME)){
DOMUtils.addXSIType(elt, OptionalSignatureInterfaceMappingImpl.XSD_TYPE_NSURI,
OptionalSignatureInterfaceMappingImpl.XSD_TYPE_NAME);
}
OptionalSignatureInterfaceMappingImpl newElt = new OptionalSignatureInterfaceMappingImpl(elt);
newElt.setXArch(this.getXArch());
xArch.fireXArchEvent(
new XArchEvent(value,
XArchEvent.PROMOTE_EVENT,
XArchEvent.ELEMENT_CHANGED,
IOptionalSignatureInterfaceMapping.class.getName(), newElt,
XArchUtils.getDefaultXArchImplementation().isContainedIn(xArch, newElt))
);
return newElt;
}
}
| [
"[email protected]"
]
| |
bdd630426ef570bbc320b82bf27b499b15195d45 | 4a706c5196964fa6cfbfc4fc191be1ef5d5a9e1b | /test/noble/NobleRuleTest.java | 6909dfd0eaac53b166f538f3c85d29108f9b12b6 | []
| no_license | s19009/java.2019 | b1afcdf9c5603b8fea1c69160be6aa4021e46d69 | 5c0c5bb6022e29de8d5a2a96d5a1baceb9903e3d | refs/heads/master | 2020-09-12T22:05:14.773245 | 2019-11-28T04:15:36 | 2019-11-28T04:15:36 | 222,573,355 | 0 | 0 | null | 2019-11-19T00:37:11 | 2019-11-19T00:37:11 | null | UTF-8 | Java | false | false | 3,618 | java | import static org.junit.Assert.*;
import static org.hamcrest.CoreMatchers.*;
import org.junit.runner.RunWith;
import org.junit.experimental.theories.Theory;
import org.junit.experimental.theories.DataPoints;
import org.junit.experimental.runners.Enclosed;
import org.junit.experimental.theories.Theories;
import org.junit.Test;
import org.junit.Before;
import trump.Card;
import trump.Master;
import trump.Hand;
import trump.Joker;
@RunWith(Enclosed.class)
public class NobleRuleTest {
public static class コンストラクタの動作確認 {
@Before
public void setUp() throws Exception {
}
@Test
public void コンストラクタ() throws Exception {
NobleRule instance = new NobleRule();
assertThat((instance instanceof NobleRule), is(true));
}
}
@RunWith(Theories.class)
public static class findCandidateの動作確認 {
private Hand _hand;
private NobleTable _table;
private NobleRule _rule;
@Before
public void setUp() throws Exception {
_hand = new Hand();
for (int i = 1; i <= Card.CARD_NUM; i+=2) {
_hand.addCard(new Card(Card.SUIT_CLUB, i));
}
_table = new NobleTable();
_rule = new NobleRule();
}
@DataPoints
public static Fixture[] PARAMs = {
new Fixture(new Card(Card.SUIT_SPADE, 1),
new Card[] {new Card(Card.SUIT_SPADE, 1), new Card(Card.SUIT_CLUB, 1)}),
new Fixture(new Card(Card.SUIT_SPADE, 2), null),
new Fixture(new Card(Card.SUIT_SPADE, 3),
new Card[] {new Card(Card.SUIT_SPADE, 3), new Card(Card.SUIT_CLUB, 3)}),
new Fixture(new Card(Card.SUIT_SPADE, 4), null),
new Fixture(new Card(Card.SUIT_SPADE, 5),
new Card[] {new Card(Card.SUIT_SPADE, 5), new Card(Card.SUIT_CLUB, 5)}),
new Fixture(new Card(Card.SUIT_SPADE, 6), null),
new Fixture(new Card(Card.SUIT_SPADE, 7),
new Card[] {new Card(Card.SUIT_SPADE, 7), new Card(Card.SUIT_SPADE, 7)}),
new Fixture(new Card(Card.SUIT_SPADE, 8), null),
new Fixture(new Card(Card.SUIT_SPADE, 9),
new Card[] {new Card(Card.SUIT_SPADE, 9), new Card(Card.SUIT_SPADE, 9)}),
new Fixture(new Card(Card.SUIT_SPADE, 10), null),
new Fixture(new Card(Card.SUIT_SPADE, 11),
new Card[] {new Card(Card.SUIT_SPADE, 11), new Card(Card.SUIT_SPADE, 11)}),
new Fixture(new Card(Card.SUIT_SPADE, 12), null),
new Fixture(new Card(Card.SUIT_SPADE, 13),
new Card[] {new Card(Card.SUIT_SPADE, 13), new Card(Card.SUIT_SPADE, 13)}),
};
@Theory
public void findCardidateの動作確認(Fixture p) throws Exception {
_hand.addCard(p.card);
Card [] actual = _rule.findCandidate(_hand, _table);
if (p.expected == null) {
assertThat(actual, is(nullValue()));
} else {
assertThat(actual, is(p.expected));
}
}
static class Fixture {
Card card;
Card [] ecpected;
Fixture(Card card, Card [] expected) {
this.card = card;
this.expected = expected;
}
}
}
// エントリーポイント
public static void main(String[] args) {
org.junit.runner.JUnitCore.main(NobleRuleTest.class.getName());
}
}
| [
"[email protected]"
]
| |
88d91c138b0fdc794a1214e8cf8ac5b3411259e1 | caa4f0ce10797c3b78680b958e2e9277d01c82ce | /src/com/shlg/chuang/annotation/Constraints.java | 94a828d9045e29fb7766887869f23effa71792d9 | []
| no_license | liushuiwushuang/codeThink | 00812e221713a7f2bb9e54722834190986fac7ae | 3285f374abfba339692c8e74dbcb87d0c5a70ef7 | refs/heads/master | 2021-01-19T04:15:17.251027 | 2017-05-05T10:13:31 | 2017-05-05T10:13:31 | 62,606,501 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 427 | java | package com.shlg.chuang.annotation;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
@Retention(RUNTIME)
@Target(FIELD)
public @interface Constraints {
boolean primaryKey() default false;
boolean allowNull() default true;
boolean unique() default false;
}
| [
"[email protected]"
]
| |
3e0efbdb9bf6f6006101765f6d83b4b4ced4d6b9 | e0636636f85ea1020caeca9ac818769e1e2c83ac | /src/jokenpo/Tesoura.java | 0a81c9707e1a71c278fe7d53efe9db45237e08ca | []
| no_license | alexolirib/jokenpo | 76b883354ff49bf96a928267693a74389f29341b | 67413e72f9b0e7ea04a2fbb1c5853fc818c6c5e1 | refs/heads/master | 2021-05-13T22:23:25.748769 | 2018-01-06T14:10:24 | 2018-01-06T14:10:24 | 116,487,828 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 722 | java | package jokenpo;
public class Tesoura {
private int resultado;
Tesoura(String jogador, String Computador) {
//Possiveis resultados 0 - Ganhou, 1 - empatou, 2 - perdeu
System.out.println("Seu oponente escolheu " + Computador);
if (Computador.equals("Papel")) {
System.out.println("Parabéns, você ganhou!");
this.resultado = 0;
} else {
if (Computador.equals("Pedra")) {
System.out.println("Você perdeu");
this.resultado = 2;
} else {
if (Computador.equals("Tesoura")) {
System.out.println("Empatou");
this.resultado = 1;
}
}
}
}
public int getResultado() {
return resultado;
}
public void setResultado(int resultado) {
this.resultado = resultado;
}
} | [
"[email protected]"
]
| |
23f3b23ee3f802f989b59e02b21943c2a81fb9d7 | 552da973f1febaa5b15f4a87597762c0eb88df23 | /src/test/java/chapter5_ifelse/IfElse2.java | 036db255121b617c841ade8e19795e0f61015dd9 | []
| no_license | gurpreetbamrah/qarobojavatraining | 1f9dc93a3716d1ca4bedcc04828524a0cbabdbae | 0a21dc089b6660322c2ea582163cbb84c5997997 | refs/heads/master | 2020-09-14T18:25:21.233755 | 2019-11-21T16:21:23 | 2019-11-21T16:21:23 | 223,213,933 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 296 | java | package chapter5_ifelse;
public class IfElse2 {
public static void main(String[] args) {
String string="gurpreet";
if(string.equals("gurpreet")){
System.out.println("Hey QArobo");
}
else {
System.out.println("test");
}
}
}
| [
"[email protected]"
]
| |
233ae51f3a64b8e039bfd8e2a1c8e91fb5ed74f6 | 647ec12ce50f06e7380fdbfb5b71e9e2d1ac03b4 | /com.tencent.mm/classes.jar/com/tencent/mm/plugin/webview/model/h.java | c040f98df3cbe4299e5aaf3189995d103617ae17 | []
| no_license | tsuzcx/qq_apk | 0d5e792c3c7351ab781957bac465c55c505caf61 | afe46ef5640d0ba6850cdefd3c11badbd725a3f6 | refs/heads/main | 2022-07-02T10:32:11.651957 | 2022-02-01T12:41:38 | 2022-02-01T12:41:38 | 453,860,108 | 36 | 9 | null | 2022-01-31T09:46:26 | 2022-01-31T02:43:22 | Java | UTF-8 | Java | false | false | 1,783 | java | package com.tencent.mm.plugin.webview.model;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.protocal.protobuf.dco;
import com.tencent.mm.protocal.protobuf.dfo;
import com.tencent.mm.sdk.platformtools.RWCache;
import com.tencent.mm.sdk.platformtools.Util;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
public final class h
{
public int WKG;
public int WKH;
public int WKI;
public final List<dfo> WKJ;
public int WKK;
public long WKL;
private h()
{
AppMethodBeat.i(78862);
this.WKG = 20480;
this.WKH = 30720;
this.WKI = 51200;
this.WKJ = new LinkedList();
this.WKK = 0;
this.WKL = 0L;
AppMethodBeat.o(78862);
}
public static void mh(List<dco> paramList)
{
AppMethodBeat.i(78863);
if (Util.isNullOrNil(paramList))
{
AppMethodBeat.o(78863);
return;
}
paramList = paramList.iterator();
while (paramList.hasNext())
{
dco localdco = (dco)paramList.next();
g localg = com.tencent.mm.plugin.webview.modeltools.g.iwb();
int i = localdco.ZsX;
long l1 = Util.nowSecond();
long l2 = localdco.aaIw;
localg.WKE.set(Integer.valueOf(i), Long.valueOf(l1 + l2));
}
com.tencent.mm.plugin.webview.modeltools.g.iwb().iuZ();
AppMethodBeat.o(78863);
}
public static final class a
{
private static final h WKM;
static
{
AppMethodBeat.i(78861);
WKM = new h((byte)0);
AppMethodBeat.o(78861);
}
}
}
/* Location: L:\local\mybackup\temp\qq_apk\com.tencent.mm\classes.jar
* Qualified Name: com.tencent.mm.plugin.webview.model.h
* JD-Core Version: 0.7.0.1
*/ | [
"[email protected]"
]
| |
2b3dcedb8b75c824bae7f2d64e7d9fa9b83ef732 | 4d134ede9b413f233756de6b2c8c520ab1cb13be | /app/src/main/java/com/example/cityparcel/track/ScheduledPackageActivity.java | 467314a058a5624a0fd4a7bcbac65a9f7abdfdb6 | []
| no_license | ror3665/CityParcelProject | d394ea2497a378a8eba9381f989c3115dd21993d | 8ecfbf250949faaff123d01bdeb4f59807edfbe4 | refs/heads/master | 2022-11-09T17:27:00.928072 | 2020-06-25T13:05:59 | 2020-06-25T13:05:59 | 268,427,662 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,672 | java | package com.example.cityparcel.track;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.android.volley.AuthFailureError;
import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.VolleyError;
import com.android.volley.toolbox.StringRequest;
import com.android.volley.toolbox.Volley;
import com.example.cityparcel.R;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
public class ScheduledPackageActivity extends AppCompatActivity {
private static String URL = "http://thecityparcel.com/ScheduledPackageList.php";
private ScheduledPackageAdapter scheuledPackageAdapter;
private RecyclerView recyclerView;
private String memEmail, getTitle, getDestination, getPrice;
private int getIndex;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_scheduled_package);
Intent intent = getIntent();
memEmail = intent.getStringExtra("memEmail");
init();
}
private void init() {
recyclerView = findViewById(R.id.scheduled_package_recyclerview);
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(linearLayoutManager);
scheuledPackageAdapter = new ScheduledPackageAdapter(ScheduledPackageActivity.this);
scheduledPackageListPHP();
}
private void scheduledPackageListPHP() {
StringRequest stringRequest = new StringRequest(Request.Method.POST, URL, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jsonobject = new JSONObject(response);
JSONArray jsonarray = jsonobject.getJSONArray("response");
for (int i = 0; i < jsonarray.length(); ++i) {
JSONObject jData = jsonarray.getJSONObject(i);
getTitle = jData.getString("parcel_title");
getDestination = jData.getString("parcel_destination");
getPrice = jData.getString("parcel_price");
getIndex = jData.getInt("parcel_idx");
scheuledPackageAdapter.addItem(new ScheduledPackageNode(getTitle, getDestination, getPrice, getIndex));
}
recyclerView.setAdapter(scheuledPackageAdapter); //show
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data [" + e.getMessage()+"]");
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(ScheduledPackageActivity.this, "DB CONNECTION FAIL", Toast.LENGTH_LONG).show();
error.printStackTrace();
}
}) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> parameters = new HashMap<>();
parameters.put("memEmail", memEmail);
return parameters;
}
};
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(stringRequest);
}
}
| [
"[email protected]"
]
| |
0ba048b049e05e041fadf8a99eb2f562f7b909f9 | a674cb30adf9f48be1d4c043d8d227ab3a60de5c | /src/com/churpi/games/grumpybusman/GrumpyBusmanGame.java | 67fbb35ee6b755b7cc0019a131ea496a395f10d4 | []
| no_license | agnimoloc/GrumpyBusman-core | b857637120031cf606834e6a791ddbda4a107b0d | 895a84d0ca568d6cd41b4f393aaedd128531f90b | refs/heads/master | 2021-01-20T00:24:28.235132 | 2014-11-25T04:07:23 | 2014-11-25T04:07:23 | 27,108,434 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 388 | java | package com.churpi.games.grumpybusman;
import com.churpi.games.grumpybusman.common.ChurpiGame;
import com.churpi.games.grumpybusman.screens.MainGame;
import com.churpi.games.grumpybusman.screens.Splash;
import com.churpi.games.grumpybusman.screens.TestScreen;
public class GrumpyBusmanGame extends ChurpiGame {
@Override
public void create () {
setScreen(new Splash(this));
}
}
| [
"[email protected]"
]
| |
711cfade9ff33cec3ea6d4674485974b306f4a33 | e9937eb3c6bc2d25fc28b1e76c91db7e60db8d9a | /app/src/main/java/com/example/babysitterfinder/DaftarPenyalurActivity.java | c32f4bfba96d842ce81b51b2cc08c353d179351a | []
| no_license | ericonnn/BabysitterFinder | d0e6e7f5066cad6fa0138025a1641b3216aa754a | 9c4be1bf759f55ae82269e55c0400deddcff91d5 | refs/heads/master | 2021-01-04T18:26:19.800003 | 2020-02-15T12:34:55 | 2020-02-15T12:34:55 | 240,702,867 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,689 | java | package com.example.babysitterfinder;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.AuthResult;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.firestore.DocumentReference;
import com.google.firebase.firestore.FirebaseFirestore;
import java.util.HashMap;
import java.util.Map;
public class DaftarPenyalurActivity extends AppCompatActivity {
private EditText namaPenyalur, emailPenyalur, pwdPenyalur, kPwdPenyalur, alamatPenyalur, kotaPenyalur, provinsiPenyalur, kodePosPenyalur, noTelpPenyalur, noWAPenyalur;
Button buttonDftrPenyalur;
FirebaseFirestore mFirestore;
FirebaseAuth mAuth;
String user_id;
String statusPenyalur = "penyalur";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_daftar_penyalur);
namaPenyalur = findViewById(R.id.daftarNamaPenyalur);
emailPenyalur = findViewById(R.id.daftarEmailPenyalur);
pwdPenyalur = findViewById(R.id.daftarPasswordPenyalur);
kPwdPenyalur = findViewById(R.id.daftarKPasswordPenyalur);
alamatPenyalur = findViewById(R.id.daftarAlamatPenyalur);
kotaPenyalur = findViewById(R.id.daftarKotaPenyalur);
provinsiPenyalur = findViewById(R.id.daftarProvinsiPenyalur);
kodePosPenyalur = findViewById(R.id.daftarKodePosPenyalur);
noTelpPenyalur = findViewById(R.id.daftarTeleponPenyalur);
noWAPenyalur = findViewById(R.id.daftarWAPenyalur);
buttonDftrPenyalur = findViewById(R.id.buttonSignUpPenyalur);
mFirestore = FirebaseFirestore.getInstance();
mAuth = FirebaseAuth.getInstance();
buttonDftrPenyalur.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String namaPylr = namaPenyalur.getText().toString();
final String emailIdPylr = emailPenyalur.getText().toString();
final String pwdPylr = pwdPenyalur.getText().toString();
final String kPwdPylr = kPwdPenyalur.getText().toString();
final String alamatPylr = alamatPenyalur.getText().toString();
final String kotaPylr = kotaPenyalur.getText().toString();
final String provinsiPylr = provinsiPenyalur.getText().toString();
final String kodePosPylr = kodePosPenyalur.getText().toString();
final String noTelpPylr = noTelpPenyalur.getText().toString();
final String WAPylr = noWAPenyalur.getText().toString();
if (namaPylr.isEmpty() || emailIdPylr.isEmpty() || pwdPylr.isEmpty() || pwdPylr.length() < 8 || kPwdPylr.isEmpty() || !kPwdPylr.equals(pwdPylr) || noTelpPylr.isEmpty() || alamatPylr.isEmpty() || kotaPylr.isEmpty() || provinsiPylr.isEmpty() || kodePosPylr.isEmpty() || WAPylr.isEmpty()) {
if (namaPylr.isEmpty()) {
namaPenyalur.setError("Mohon isi nama lengkap anda");
namaPenyalur.requestFocus();
}
if (emailIdPylr.isEmpty()) {
emailPenyalur.setError("Mohon isi email anda");
emailPenyalur.requestFocus();
}
if (pwdPylr.isEmpty()) {
pwdPenyalur.setError("Mohon isi password anda");
pwdPenyalur.requestFocus();
}
if (pwdPylr.length() < 8) {
pwdPenyalur.setError("Password minimal harus 8 karakter");
pwdPenyalur.requestFocus();
}
if (kPwdPylr.isEmpty()) {
kPwdPenyalur.setError("Mohon konfirmasi password anda");
kPwdPenyalur.requestFocus();
}
if (!kPwdPylr.equals(pwdPylr)) {
kPwdPenyalur.setError("Konfirmasi password anda tidak sama dengan password anda");
kPwdPenyalur.requestFocus();
}
if (noTelpPylr.isEmpty()) {
noTelpPenyalur.setError("Mohon isi nomor telepon anda");
noTelpPenyalur.requestFocus();
}
if (alamatPylr.isEmpty()) {
alamatPenyalur.setError("Mohon isi alamat anda");
alamatPenyalur.requestFocus();
}
if (kotaPylr.isEmpty()) {
kotaPenyalur.setError("Mohon isi kota anda");
kotaPenyalur.requestFocus();
}
if (provinsiPylr.isEmpty()) {
provinsiPenyalur.setError("Mohon isi provinsi anda");
provinsiPenyalur.requestFocus();
}
if (kodePosPylr.isEmpty()) {
kodePosPenyalur.setError("Mohon isi kode pos anda");
kodePosPenyalur.requestFocus();
}
if (WAPylr.isEmpty()) {
noWAPenyalur.setError("Mohon isi nomor WA anda");
noWAPenyalur.requestFocus();
}
} else {
final Map<String,String> userData = new HashMap<>();
userData.put("Nama Penyalur ", namaPylr);
userData.put("Email Penyalur ", emailIdPylr);
userData.put("Password Penyalur ", pwdPylr);
userData.put("Konfirmasi Password Penyalur ", kPwdPylr);
userData.put("Nomor Telepon Penyalur ", noTelpPylr);
userData.put("Alamat Penyalur ", alamatPylr);
userData.put("Kota Penyalur ", kotaPylr);
userData.put("Provinsi Penyalur ", provinsiPylr);
userData.put("Kode Pos Penyalur ", kodePosPylr);
userData.put("Nomor WA Penyalur ", WAPylr);
userData.put("Status ", statusPenyalur);
mAuth.createUserWithEmailAndPassword(emailIdPylr, pwdPylr).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
user_id = mAuth.getCurrentUser().getUid();
mFirestore.collection("Data Penyalur").document(user_id).set(userData).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
}
});
Toast.makeText(DaftarPenyalurActivity.this, "Halo Selamat Datang!", Toast.LENGTH_SHORT).show();
Intent i = new Intent(DaftarPenyalurActivity.this, HomePenyalurActivity.class);
startActivity(i);
}
}
});
}
}
});
}
}
| [
"[email protected]"
]
| |
b6c04151493b998bea084fefd6608831b7c7ef1d | 4672e3fdaae3fe95d3aac6347305f8abd6e64c55 | /backend/src/main/java/com/scit/xml/security/JwtAuthenticationEntryPoint.java | ea14446302b9ebbf981265d87d8cce048f5f7a1a | []
| no_license | rs-teamIO/scit | c25a71baf03b4722b7f6bfbae908fe3f9aa03665 | 2f6692a1dc2acec60041e0a2ae2033e9cf79f77a | refs/heads/master | 2022-05-07T14:15:28.264227 | 2020-02-06T22:48:10 | 2020-02-06T22:48:10 | 224,839,955 | 0 | 0 | null | 2022-04-29T03:06:42 | 2019-11-29T11:19:52 | Java | UTF-8 | Java | false | false | 848 | java | package com.scit.xml.security;
import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.stereotype.Component;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.Serializable;
@Component
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
private static final long serialVersionUID = 1L;
@Override
public void commence(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, AuthenticationException e) throws IOException, ServletException {
httpServletResponse.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized");
}
}
| [
"[email protected]"
]
| |
40b868c834716ec0a20974065f757aed53030d78 | f27cb821dd601554bc8f9c112d9a55f32421b71b | /examples/quarkus/testsuite/native/db2/src/main/java/com/blazebit/persistence/examples/quarkus/testsuite/nativedb2/Dummy.java | 241545b58683109a33bdde3501adf6c3d5752240 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
]
| permissive | Blazebit/blaze-persistence | 94f7e75154e80ce777a61eb3d436135ad6d7a497 | a9b1b6efdd7ae388e7624adc601a47d97609fdaa | refs/heads/main | 2023-08-31T22:41:17.134370 | 2023-07-14T15:31:39 | 2023-07-17T14:52:26 | 21,765,334 | 1,475 | 92 | Apache-2.0 | 2023-08-07T18:10:38 | 2014-07-12T11:08:47 | Java | UTF-8 | Java | false | false | 817 | java | /*
* Copyright 2014 - 2023 Blazebit.
*
* 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.blazebit.persistence.examples.quarkus.testsuite.nativedb2;
/**
* Newer Javadoc versions don't package empty javadocs anymore.
*
* @author Christian Beikov
* @since 1.6.0
*/
public class Dummy {
}
| [
"[email protected]"
]
| |
5a5c2812b1e4d1d4710ada02dc8eacc6191d16de | 347d1a1083145ddbbbcf5e5bd9d483be93e7086b | /xiao2/monthproject/src/main/java/com/bawei/monthproject/MainActivity.java | a9d36f4a23ecf76b38516bc3848acd8aeea047e1 | []
| no_license | 2318279444/1707A | 34f0fe8fe24e7b67e5733d2c556ab042edb8d3e5 | 46de73c27a1f392f059e1054b35ca9ded0037172 | refs/heads/master | 2020-11-30T07:24:00.423533 | 2019-12-28T02:21:34 | 2019-12-28T02:21:34 | 230,346,614 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 396 | java | package com.bawei.monthproject;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.bawei.base.BaseActivity;
public class MainActivity extends BaseActivity {
@Override
protected void inidata() {
}
@Override
protected void iniview() {
}
@Override
protected int inilayout() {
return R.layout.activity_main;
}
}
| [
"[email protected]"
]
| |
fedaa1df43a2a27a3fdac9e172b08269ecd036c6 | 9a7ab41fbd5a74fa9d5237f5b4b03f03bf9aa21c | /Java DataStructures Programming/Priority Queue/Main.java | 26fc6ab7d0a6b58e0654ad2b595d8f59de003028 | []
| no_license | garciaatech/Java-DataStructures | 1d35c20f00383a01f6a4163e219720af96c43efe | b9f8fe5215eb1505eb2e608589cf2a7003f644f1 | refs/heads/main | 2023-03-08T23:15:04.089493 | 2021-03-20T18:34:38 | 2021-03-20T18:34:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 882 | java | //5734454
//code based off what was taught in class and book. Anything copied
//directly off powerpoints or book will show slide number or page number.
public class Main {
public static void main(String[] args) {
PriorityQueue queue = new PriorityQueue();
queue.add(1);
queue.add(3);
queue.add(5);
queue.add(7);
queue.add(9);
queue.add(2);
queue.add(4);
queue.add(6);
queue.add(8);
queue.add(10);
System.out.println("Priority Queue: ");
while(!queue.isEmpty())
{
System.out.println(queue.max());
queue.removeMax();
}
}
} | [
"[email protected]"
]
| |
c6db96e29e57ee8be949a5483cf7cc65fa1eb0b2 | c34225cd3e71e39cfa2339b8e4a9316c4a83f428 | /ClientSurveyMs/src/test/java/com/surveybuilder/entity/SurveyTest.java | 5dcc19bf1ca1239812d078e5f131b0f5b763fb7d | []
| no_license | Bhavya0505/Sprint | 6cfe27416fd8bfe8308ba649f9cd7420d3f2c4a7 | 194c99193bfb8b64e9db9bcf4b62658d2b208d07 | refs/heads/master | 2023-04-05T15:55:16.563983 | 2021-04-26T15:23:21 | 2021-04-26T15:23:21 | 361,131,583 | 0 | 1 | null | 2021-04-26T15:23:22 | 2021-04-24T10:22:31 | Java | UTF-8 | Java | false | false | 1,300 | java | package com.surveybuilder.entity;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class SurveyTest {
private Survey survey= new Survey();
@BeforeEach
void setUp() throws Exception {
}
@AfterEach
void tearDown() throws Exception {
}
@Test
void testGetSid() {
long mockId = 101;
survey.setSid(mockId);
long id = survey.getSid();
assertThat(id).isEqualTo(mockId);
}
@Test
void testSetSid() {
long mockId = 101;
survey.setSid(mockId);
long id = survey.getSid();
assertThat(id).isEqualTo(mockId);
}
@Test
void testSetStatus() {
String mockStatus = "Passive";
survey.setStatus(mockStatus);
String status = survey.getStatus();
assertThat(status).isEqualTo(mockStatus);
}
@Test
void testGetTitle() {
String mockTitle = "title";
survey.setTitle(mockTitle);
String title = survey.getTitle();
assertThat(title).isEqualTo(mockTitle);
}
@Test
void testSetTitle() {
String mockTitle = "title";
survey.setTitle(mockTitle);
String title = survey.getTitle();
assertThat(title).isEqualTo(mockTitle);
}
}
| [
"[email protected]"
]
| |
272ba49c614bf2a50ccb3ce3caed4eabb47eca5d | 9921f0625385344fcf57582d3e8fbed02e4209b0 | /BigScreen/src/com/servlet/Servlet_Gao.java | dc1290b3702d8274a375ef840e319928b3b0b7f0 | []
| no_license | 351642983/FindWebRoot | 877a9b801515c89af30d3939eba48b368089b3cc | 6c3dfad3b0caf5485fa1705b34ae4485c978d7eb | refs/heads/master | 2023-03-07T07:26:16.092758 | 2021-02-22T02:27:42 | 2021-02-22T02:27:42 | 293,198,154 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,502 | java | package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.JSONArray;
import com.python.Ppyrun;
import com.python.Ppyrun_pre;
import com.web.tuopu.Config;
import com.web.tuopu.DataServlet;
/**
* Servlet implementation class Servlet_Gao
*/
@WebServlet("/Servlet_Gao")
public class Servlet_Gao extends HttpServlet {
protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
req.setCharacterEncoding("utf-8");
String method = req.getParameter("method");
// System.out.println("PPPPPPPPPPPPPPP");
if ("Time_qunee".equals(method)) {
try {
Time_qunee(req, resp);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if ("Time_qunee_pre".equals(method)) {
try {
Time_qunee_pre(req, resp);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if ("Time_qunee_fold".equals(method)) {
try {
Time_qunee_fold(req, resp);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else if("Create_root_json".equals(method)) {
resp.setCharacterEncoding("utf-8");
resp.getWriter().write(DataServlet.createRootInfoJson());
}
else if("Create_montior_json".equals(method)) {
resp.setCharacterEncoding("utf-8");
resp.getWriter().write(DataServlet.createMontiorInfoJson());
}
}
public Servlet_Gao() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
private void Time_qunee(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
HttpSession session=req.getSession();
PrintWriter out=resp.getWriter();
String Filename = req.getParameter("Filename");
JSONArray array_data=Ppyrun.GET_file_json(Filename);
resp.setCharacterEncoding("UTF-8");
System.out.println(array_data.toString());
//resp.sendRedirect(req.getContextPath() + "/admin/child/Child_11/1_Rcai.jsp");
resp.getWriter().write(array_data.toString());
}
private void Time_qunee_pre(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
HttpSession session=req.getSession();
PrintWriter out=resp.getWriter();
String Filename = req.getParameter("Filename");
String Nodename = Ppyrun.GET_NAME(Filename) ;
JSONArray array_data=Ppyrun.GET_file_json(Filename);
JSONArray array_data_pre=Ppyrun_pre.GET_Value_json(Filename,Nodename);
JSONArray array1=new JSONArray();
array1.put(array_data);
array1.put(array_data_pre);
resp.setCharacterEncoding("UTF-8");
System.out.println(array1.toString());
//resp.sendRedirect(req.getContextPath() + "/admin/child/Child_11/1_Rcai.jsp");
resp.getWriter().write(array1.toString());
}
private void Time_qunee_fold(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException, SQLException {
// TODO Auto-generated method stub
//response.getWriter().append("Served at: ").append(request.getContextPath());
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=utf-8");
HttpSession session=req.getSession();
PrintWriter out=resp.getWriter();
String Foldname = req.getParameter("Foldname");
JSONArray array_data=Ppyrun.GET_waring_json(Foldname);
resp.setCharacterEncoding("UTF-8");
System.out.println(array_data.toString());
//resp.sendRedirect(req.getContextPath() + "/admin/child/Child_11/1_Rcai.jsp");
resp.getWriter().write(array_data.toString());
}
}
| [
"[email protected]"
]
| |
52f5fdc91f797af89a78ee66a78a5329f27750b7 | 1a8d489cfb0998167692376117364d053bee7130 | /codeBaekJoon/No10675_cowJog.java | dcddecccf6494d325b3b04575649f482fbd328cb | []
| no_license | JakyungYoon/BaekjoonAnswer | 9ae139c0e71a28f3688c842feb055dde1cd97f35 | e0ec993416d49543ba71d98fb43cd4019022a794 | refs/heads/master | 2020-05-09T12:47:39.924203 | 2019-04-01T14:55:58 | 2019-04-01T14:55:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,471 | java | package codeBaekJoon;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class No10675_cowJog {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());
int p[] = new int [T];
int count = 0;
int v[] = new int [T];
for(int i=0; i<T; i++){
String s = br.readLine();
StringTokenizer st = new StringTokenizer(s, " ");
p[i] = Integer.parseInt(st.nextToken());
v[i] = Integer.parseInt(st.nextToken());
}
int vm = v[T-1];
for(int i=T-1; i>=0; i--){
if(vm>=v[i]){
count++;
vm = v[i];
}
}
/* 어경우는 되게 신기한 방식으로 진행되었는데 간단히 이야기하면,
* 빠른녀석이 앞에 있는 놈을 지나치려는 순간 속도를 앞에 앞서 있는 소의 속도로 맞춰서 달리는 방식.
* 근데 이걸 빠른소 기준으로 잡아서 잡아 먹는 방식이면, 시간복잡도가 넘치는 데
* 역으로 앞에 있는 느린소 기준으로 잡아서 따라잡히는 방식으로 해버리면
* 이 소보다 빠른 소는 무조건 이 소를 넘을 수는 없고 이 소보다 느린 속도로 달리거나, 같은속도로
달리면, 결국에는 절대 못따라 잡는 그룹이 생기니. 그런 방식으로 계산해서 찾는것.
*/
System.out.println(count);
}
}
| [
"[email protected]"
]
| |
925f4c4f632fd22b6ede07d9bc4be4119bb76277 | 8ec192c2bb2b9d5e80a114e18760850fa793e9de | /src/main/java/com/epam/library/command/impl/BookTypeCommand.java | 71ff69299b113263063c1463a1b92851247ba3c7 | []
| no_license | balsimran-epam/appLibrary | dec841ac0a121e2f26c38c3f9513ce5f477c7ca3 | 61ae31a1642f45f71383ab753abb566fb9c2e3f1 | refs/heads/master | 2021-01-21T07:08:15.905110 | 2017-05-30T10:06:12 | 2017-05-30T10:06:12 | 91,598,461 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 794 | java | package com.epam.library.command.impl;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.epam.library.command.Command;
public class BookTypeCommand implements Command {
private static final String ADMIN_FORM_COMMAND = "ControllerServlet?action=bookType";
private static final String TYPE_TO_BE_ADDED = "bookTypeToBeAdded";
@Override
public String execute(HttpServletRequest request, HttpServletResponse response) {
HttpSession session = request.getSession();
String role = (String) request.getParameter(TYPE_TO_BE_ADDED);
if (role != null && !role.isEmpty()) {
session.setAttribute(TYPE_TO_BE_ADDED, request.getParameter(TYPE_TO_BE_ADDED));
}
return ADMIN_FORM_COMMAND;
}
}
| [
"[email protected]"
]
| |
90224526dd6f43b6bb5710bbe4dd1afa456ab8a9 | 8ccd1c071b19388f1f2e92c5e5dbedc78fead327 | /src/main/java/ohos/agp/render/render3d/impl/CoreResource.java | b846380654a28290b69066cee0937fad37ca5e37 | []
| no_license | yearsyan/Harmony-OS-Java-class-library | d6c135b6a672c4c9eebf9d3857016995edeb38c9 | 902adac4d7dca6fd82bb133c75c64f331b58b390 | refs/heads/main | 2023-06-11T21:41:32.097483 | 2021-06-24T05:35:32 | 2021-06-24T05:35:32 | 379,816,304 | 6 | 3 | null | null | null | null | UTF-8 | Java | false | false | 2,248 | java | package ohos.agp.render.render3d.impl;
import java.math.BigInteger;
class CoreResource {
private transient long agpCptrCoreResource;
private final Object delLock = new Object();
transient boolean isAgpCmemOwn;
CoreResource(long j, boolean z) {
this.isAgpCmemOwn = z;
this.agpCptrCoreResource = j;
}
static long getCptr(CoreResource coreResource) {
if (coreResource == null) {
return 0;
}
return coreResource.agpCptrCoreResource;
}
/* access modifiers changed from: package-private */
public void delete() {
synchronized (this.delLock) {
if (this.agpCptrCoreResource != 0) {
if (!this.isAgpCmemOwn) {
this.agpCptrCoreResource = 0;
} else {
this.isAgpCmemOwn = false;
throw new UnsupportedOperationException("C++ destructor does not have public access");
}
}
}
}
static long getCptrAndSetMemOwn(CoreResource coreResource, boolean z) {
if (coreResource != null) {
coreResource.isAgpCmemOwn = z;
}
return getCptr(coreResource);
}
/* access modifiers changed from: package-private */
public CorePropertyHandle getProperties() {
long propertiesInCoreResource = CoreJni.getPropertiesInCoreResource(this.agpCptrCoreResource, this);
if (propertiesInCoreResource == 0) {
return null;
}
return new CorePropertyHandle(propertiesInCoreResource, false);
}
/* access modifiers changed from: package-private */
public void setProperties(CorePropertyHandle corePropertyHandle) {
CoreJni.setPropertiesInCoreResource(this.agpCptrCoreResource, this, CorePropertyHandle.getCptr(corePropertyHandle), corePropertyHandle);
}
/* access modifiers changed from: package-private */
public BigInteger getType() {
return CoreJni.getTypeInCoreResource(this.agpCptrCoreResource, this);
}
static void destroy(CoreResource coreResource) {
CoreJni.destroyInCoreResource(getCptr(coreResource), coreResource);
}
}
| [
"[email protected]"
]
| |
ec38379a0b6703a011082882988dcfa45e4de06e | 3c0a799ccd177bb4cec3060262f2fc699a94dc18 | /src/java知识/Java基础/二进制/Convert.java | a4290fee60b9987337f2b188677f215e7e8d53c0 | []
| no_license | gaohanghang/technology | 6c855a0b17c85940affdd67df807dd2106f5087c | f7de7153e1b9805a0cae5fea894bd9ba54627b97 | refs/heads/master | 2022-10-04T10:13:11.942340 | 2022-09-27T17:45:01 | 2022-09-27T17:45:01 | 125,711,791 | 1 | 2 | null | 2022-05-22T15:08:41 | 2018-03-18T09:58:35 | Java | UTF-8 | Java | false | false | 2,341 | java | package java知识.Java基础.二进制;
/**
* @Description:
* @author: Gao Hang Hang
* @date 2019/02/18 11:09
*/
public class Convert {
/**
* int转换为byte[]
* @param id
* @return
*/
public static byte[] int2Bytes(int id) {
byte[] arr = new byte[4];
// arr[0] = (byte) ((id >> 0*8) & 0xff);
// arr[1] = (byte) ((id >> 1*8) & 0xff);
// arr[2] = (byte) ((id >> 2*8) & 0xff);
// arr[3] = (byte) ((id >> 3*8) & 0xff);
for (int i = 0; i < arr.length; i++) {
arr[i] = (byte) ((id >> i*8) & 0xff);
}
return arr;
}
public static int bytes2Int(byte[] arr) {
// int rs0 = (arr[0] & 0xff) << 0*8;
// int rs1 = (arr[1] & 0xff) << 1*8;
// int rs2 = (arr[2] & 0xff) << 2*8;
// int rs3 = (arr[3] & 0xff) << 3*8;
int result = 0;
for (int i = 0; i < arr.length; i++) {
result += (arr[i] & 0xff) << i*8;
}
return result;
}
/**
* int转换为byte[]
* @param id
* @return
*/
public static byte[] long2Bytes(int id) {
byte[] arr = new byte[8];
// arr[0] = (byte) ((id >> 0*8) & 0xff);
// arr[1] = (byte) ((id >> 1*8) & 0xff);
// arr[2] = (byte) ((id >> 2*8) & 0xff);
// arr[3] = (byte) ((id >> 3*8) & 0xff);
for (int i = 0; i < arr.length; i++) {
arr[i] = (byte) ((id >> i*8) & 0xff);
}
return arr;
}
public static int bytes2Long(byte[] arr) {
// int rs0 = (arr[0] & 0xff) << 0*8;
// int rs1 = (arr[1] & 0xff) << 1*8;
// int rs2 = (arr[2] & 0xff) << 2*8;
// int rs3 = (arr[3] & 0xff) << 3*8;
int result = 0;
for (int i = 0; i < arr.length; i++) {
result += (long)((arr[i] & 0xff) << i*8);
}
return result;
}
public static void main(String[] args) {
byte[] arr = Convert.int2Bytes(8143);
System.out.println(arr[0] + "," + arr[1] + "," + arr[2] + "," + arr[3]);
System.out.println(Convert.bytes2Int(arr));
//字符串与字节数组
String describe = "我每天都练功,我天下无敌...";
byte[] barr = describe.getBytes();
String des = new String(barr);
System.out.println(des);
}
}
| [
"[email protected]"
]
| |
cd2fec4b358e8e90065c52f6f0a427c0ca51c4b9 | a38dc66d6940082ae06fe77c942b5d2661a6b5b6 | /src/main/java/Fisher.java | f2b5404d2202fd760592522f6ad02083124c63ae | []
| no_license | kubiakdamian/SMPD | 256c40d32064d10e0dece84fa003834ea7eb78d0 | 149965dd06318db4e7a001e4e924f1c811f48b8e | refs/heads/master | 2020-06-09T21:31:56.814257 | 2019-06-24T23:02:52 | 2019-06-24T23:02:52 | 193,509,746 | 0 | 0 | null | 2019-06-24T15:26:21 | 2019-06-24T13:21:31 | Java | UTF-8 | Java | false | false | 1,799 | java | public class Fisher {
public static double fisherMulti(int firstIndex, int secondIndex, double[][] vectorA, double[][] vectorB) {
double[][] uA = Matrix.getVectorWithAverages(firstIndex, secondIndex, vectorA);
double[][] uB = Matrix.getVectorWithAverages(firstIndex, secondIndex, vectorB);
double[][] aMatrixTmp = createMatrixFromRows(firstIndex, secondIndex, vectorA);
double[][] bMatrixTmp = createMatrixFromRows(firstIndex, secondIndex, vectorB);
double[][] aMatrix = Matrix.subtraction(aMatrixTmp, uA);
double[][] bMatrix = Matrix.subtraction(bMatrixTmp, uB);
aMatrix = multiplyMatrixes(aMatrix, Matrix.transposeMatrix(aMatrix));
bMatrix = multiplyMatrixes(bMatrix, Matrix.transposeMatrix(bMatrix));
double detA = Matrix.calculateMatrixDet(aMatrix);
double detB = Matrix.calculateMatrixDet(bMatrix);
double fisherMultiValue = Matrix.euclidesDistance(uA, uB) / (detA + detB);
return fisherMultiValue;
}
private static double[][] createMatrixFromRows(int row1, int row2, double[][] matrix) {
double[][] matrixTmp = new double[2][2];
matrixTmp[0] = matrix[row1];
matrixTmp[1] = matrix[row2];
return matrixTmp;
}
private static double[][] multiplyMatrixes(double[][] matrix1, double[][] matrix2) {
double[][] result = new double[matrix1.length][matrix1.length];
for (int i = 0; i < matrix1.length; i++) {
for (int j = 0; j < matrix2[0].length; j++) {
double temp = 0;
for (int w = 0; w < matrix2.length; w++) {
temp += matrix1[i][w] * matrix2[w][j];
}
result[i][j] = temp;
}
}
return result;
}
}
| [
"[email protected]"
]
| |
917b9339f5848fa4aa271df639772849ed9a41ed | 7a257eb5a5a4f420409eb3bcfc254b1831579a11 | /app/src/main/java/com/url/msi/uixy/ItemTouchHelper.java | 37f1999737db0df5de901d5494349f3248b311d3 | []
| no_license | qjijk/uixy | c6df1c774601af6f1e4fb8ee92a23658802415ce | 06c0f53279cd6db8945839fa5a2cda2e6ffbd28d | refs/heads/master | 2020-06-14T08:09:28.838250 | 2019-07-03T01:16:51 | 2019-07-03T01:16:51 | 194,956,402 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 179 | java | package com.url.msi.uixy;
public interface ItemTouchHelper {
//移动
void onItemMove(int startPostion,int endPosttion);
//删除
void onItemDele(int postion);
}
| [
"[email protected]"
]
| |
995a9108d6ab48b2609377995bb2a908bc93bc2b | a64477e77efc3636141a6d5b8764430f85421e5d | /mappers/PlayerMapper.java | ff7ec959cd80be071f7313f9d028d41373afd850 | []
| no_license | Sp4rk3r/LotteryManagement | 0115cc2bc2045de5ddd4b47d5ffeb5313bd856bd | 46f73631afdbd17b86f716e8b02c09d670ce0fbf | refs/heads/master | 2021-04-30T08:36:19.018070 | 2018-02-13T12:31:18 | 2018-02-13T12:31:18 | 121,379,768 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 794 | java | package be.thibaulthelsmoortel.lotterymanagement.mappers;
import be.thibaulthelsmoortel.lotterymanagement.model.Player;
import java.util.List;
import lombok.Data;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.StatementType;
import org.springframework.stereotype.Component;
/**
* Mapper for {@link be.thibaulthelsmoortel.lotterymanagement.model.Player}.
*
* @author Koen Rombout
* @since 5/10/2017
*/
@Component
@Mapper
public interface PlayerMapper {
@Select(" {CALL `p_get_all_players`()}")
@Options(statementType = StatementType.CALLABLE)
List<Player> getAllPlayers();
@Data
class GetPlayerRequest{
private Long playerId;
}
}
| [
"[email protected]"
]
| |
c4803a1d825e2eb900220c802746cb50695aa5e8 | 9b75d8540ff2e55f9ff66918cc5676ae19c3bbe3 | /bazaar8.apk-decompiled/sources/com/farsitel/bazaar/ui/splash/SplashActivity.java | 5215d2363133b8a9f9c3109cf4ad9994dc7c7438 | []
| no_license | BaseMax/PopularAndroidSource | a395ccac5c0a7334d90c2594db8273aca39550ed | bcae15340907797a91d39f89b9d7266e0292a184 | refs/heads/master | 2020-08-05T08:19:34.146858 | 2019-10-06T20:06:31 | 2019-10-06T20:06:31 | 212,433,298 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,799 | java | package com.farsitel.bazaar.ui.splash;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.widget.ProgressBar;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.constraintlayout.widget.Group;
import androidx.databinding.ViewDataBinding;
import b.l.g;
import b.r.E;
import c.c.a.c.c.a;
import c.c.a.d.b.d;
import c.c.a.d.b.l;
import c.c.a.d.f.b;
import c.c.a.f.C0407c;
import c.c.a.n.y.e;
import com.farsitel.bazaar.R;
import com.farsitel.bazaar.core.model.Resource;
import com.farsitel.bazaar.core.model.ResourceState;
import com.farsitel.bazaar.data.entity.ErrorModel;
import com.farsitel.bazaar.data.entity.None;
import com.farsitel.bazaar.ui.home.MainActivity;
import h.f.b.j;
import h.f.b.k;
/* compiled from: SplashActivity.kt */
public final class SplashActivity extends b {
public e w;
public C0407c x;
public boolean y = true;
public static final /* synthetic */ e a(SplashActivity splashActivity) {
e eVar = splashActivity.w;
if (eVar != null) {
return eVar;
}
j.c("splashViewModel");
throw null;
}
public final void C() {
C0407c cVar = this.x;
if (cVar != null) {
ProgressBar progressBar = cVar.E;
j.a((Object) progressBar, "binding.progressBar");
l.c(progressBar);
C0407c cVar2 = this.x;
if (cVar2 != null) {
Group group = cVar2.B;
j.a((Object) group, "binding.errorGroup");
l.a(group);
return;
}
j.c("binding");
throw null;
}
j.c("binding");
throw null;
}
public final void D() {
if (this.y) {
F();
}
}
public final void E() {
E a2 = A().a(e.class);
e eVar = (e) a2;
eVar.e().a(this, new d(this));
j.a((Object) a2, "viewModelFactory.create(…\n })\n }");
this.w = eVar;
e eVar2 = this.w;
if (eVar2 != null) {
eVar2.k();
} else {
j.c("splashViewModel");
throw null;
}
}
public final void F() {
Intent intent = new Intent(this, MainActivity.class);
getIntent().addFlags(32768);
startActivity(intent);
finish();
}
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
ViewDataBinding a2 = g.a(this, R.layout.activity_splash);
j.a((Object) a2, "DataBindingUtil.setConte…R.layout.activity_splash)");
this.x = (C0407c) a2;
if (!isTaskRoot()) {
Intent intent = getIntent();
j.a((Object) intent, "intent");
String action = intent.getAction();
if (intent.hasCategory("android.intent.category.LAUNCHER") && action != null && j.a((Object) action, (Object) "android.intent.action.MAIN")) {
finish();
return;
}
}
E();
}
public void onPause() {
super.onPause();
this.y = false;
}
public void onResume() {
super.onResume();
this.y = true;
e eVar = this.w;
ResourceState resourceState = null;
if (eVar != null) {
Resource a2 = eVar.e().a();
if (a2 != null) {
resourceState = a2.d();
}
if (j.a((Object) resourceState, (Object) ResourceState.Success.f12179a)) {
D();
return;
}
return;
}
j.c("splashViewModel");
throw null;
}
public final void a(Resource<None> resource) {
if (resource != null) {
ResourceState d2 = resource.d();
if (j.a((Object) d2, (Object) ResourceState.Loading.f12178a)) {
C();
} else if (j.a((Object) d2, (Object) ResourceState.Success.f12179a)) {
D();
} else if (j.a((Object) d2, (Object) ResourceState.Error.f12177a)) {
a(resource.c());
} else {
a aVar = a.f4699b;
aVar.a(new Throwable("Illegal State in handleResourceState in " + k.a(SplashActivity.class)));
}
}
}
public final void a(ErrorModel errorModel) {
if (errorModel != null) {
C0407c cVar = this.x;
if (cVar != null) {
ProgressBar progressBar = cVar.E;
j.a((Object) progressBar, "binding.progressBar");
l.a(progressBar);
C0407c cVar2 = this.x;
if (cVar2 != null) {
Group group = cVar2.B;
j.a((Object) group, "binding.errorGroup");
l.c(group);
C0407c cVar3 = this.x;
if (cVar3 != null) {
AppCompatTextView appCompatTextView = cVar3.C;
j.a((Object) appCompatTextView, "binding.errorText");
appCompatTextView.setText(d.b((Context) this, errorModel));
C0407c cVar4 = this.x;
if (cVar4 != null) {
cVar4.A.setOnClickListener(new c(this));
} else {
j.c("binding");
throw null;
}
} else {
j.c("binding");
throw null;
}
} else {
j.c("binding");
throw null;
}
} else {
j.c("binding");
throw null;
}
}
}
}
| [
"[email protected]"
]
| |
eff23a8ac6fb4dd6b141c7bca129b1a6d9087e29 | 4b5351f597b8e0a817b0ba70bebc98451dce6e8a | /Chapter2/src/ch04/Student.java | 9a80f920cd07ec2eb538f58aff1cfbbefae2e7e2 | []
| no_license | xjvmdutl/chapter02 | 414a6fcf12c573686bbf6f4e7a2d3ab796e4418e | 22a0129831093d0a6f3c522bd2cdcfa0ef5be98e | refs/heads/master | 2023-05-07T10:14:09.486236 | 2021-05-30T10:28:55 | 2021-05-30T10:28:55 | 367,574,123 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 508 | java | package ch04;
public class Student {
public int studentID;
public String studentName;
public String address;
public void showStudentInfo() {//학생 정보를 보여준다.
System.out.println(studentID + "학번 학생의 이름은 "+studentName+" 이고, 주소는 "+address+"입니다.");
}
public String getStudentName(){//studentName을 가져가는 함수
return studentName;
}
public void setStudentName(String name) {//studentName을 지정하는 함수
studentName = name;
}
}
| [
"[email protected]"
]
| |
320e7e3a14fcabb1361d24095a43a42d68569703 | 10b3bbd0bd63d4a7a64c5aa0295e9be4c2e9e230 | /app/src/main/java/com/flashPurchase/app/adapter/RecommendDownAdapter.java | cc1c6255c298df422b172f531c916d1e7e6184f5 | []
| no_license | JinliWang/FlashPurchase | e17800b451d8acb9f0b99689141ae728a3615eef | de3922e5ca32d913630ed4358e82b52b63fdd5e8 | refs/heads/master | 2020-03-08T13:02:29.016870 | 2018-07-23T07:30:14 | 2018-07-23T07:30:14 | 128,147,171 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,573 | java | package com.flashPurchase.app.adapter;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.app.library.base.BaseAdapter;
import com.app.library.base.BaseHolder;
import com.app.library.util.ImageLoadManager;
import com.app.library.util.UIUtil;
import com.flashPurchase.app.R;
import com.flashPurchase.app.model.bean.RecommendMoreResponse;
import java.util.List;
import butterknife.BindView;
/**
* Created by 10951 on 2018/7/8.
*/
public class RecommendDownAdapter extends BaseAdapter<RecommendMoreResponse.ResponseBean.GoodsBean> {
public RecommendDownAdapter(List<RecommendMoreResponse.ResponseBean.GoodsBean> mDatas) {
super(mDatas);
}
@Override
protected BaseHolder getHolder() {
return new Holder();
}
class Holder extends BaseHolder<RecommendMoreResponse.ResponseBean.GoodsBean> {
@BindView(R.id.img_goods)
ImageView mImgGoods;
@BindView(R.id.img_saled)
ImageView mImgSaled;
@BindView(R.id.tv_goods_name)
TextView mTvGoodsName;
@BindView(R.id.tv_goods_price)
TextView mTvGoodsPrice;
@Override
protected View initView() {
return UIUtil.inflate(R.layout.item_home_list);
}
@Override
protected void refreshView() {
ImageLoadManager.getInstance().setImage(getContext(), getData().getPics(), mImgGoods);
mTvGoodsName.setText(getData().getName());
mTvGoodsPrice.setText(getData().getCurrentPrice());
}
}
}
| [
"[email protected]"
]
| |
1983f1ae91ad3a2823f0fa467b88f084f5df9888 | df7d0488f2b006ed1b9715351298e2f394e28ebe | /src/EBOXES.java | 1cef0e1b16b0bfbcd40a43d4be9c6ceed97df008 | []
| no_license | saurabh321gupta/SPOJ | 8c9bae99e78e7cfb8be7c7402f325e3e821ae8c6 | 6c37723bcc6cb13ff958af19a9793141b1a42256 | refs/heads/master | 2021-08-19T23:26:15.090800 | 2017-11-27T16:58:02 | 2017-11-27T16:58:02 | 270,078,257 | 0 | 0 | null | 2020-06-06T19:10:56 | 2020-06-06T19:10:55 | null | UTF-8 | Java | false | false | 723 | java | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* Created by sreedish.ps on 10/11/15.
*/
public class EBOXES {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Integer T = Integer.parseInt(br.readLine());
while (T-- > 0) {
String temp[] = br.readLine().split(" ");
Integer N = Integer.parseInt(temp[0]);
Integer K = Integer.parseInt(temp[1]);
Integer T1 = Integer.parseInt(temp[2]);
Integer F = Integer.parseInt(temp[3]);
System.out.println(N + ((F - N) * K)/(K-1));
}
}
}
| [
"[email protected]"
]
| |
167a78bf6f6fb89b99489a65a55cb7a85b226ca0 | fd22e0ebe1276b95ca3bac9a10410912994bfb45 | /src/Handler/Md5Encoder.java | 9d6f8f9822190c92fd4ca288c6b10cef56c45d74 | [
"MIT"
]
| permissive | qiu1518977696/OnlineExamSystem | f132284520c133599738b399fe2ea7a8e22ff499 | 77a9beeba1e55ad1d767136a8096b402890502a9 | refs/heads/master | 2020-07-31T19:54:44.158877 | 2018-08-31T08:02:39 | 2018-08-31T08:02:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,522 | java | package Handler;
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
/**
* 与前端js保持一致的加密编码
* @author taominqi
*
*/
public class Md5Encoder {
/**利用MD5进行加密
* @param str 待加密的字符串
* @return 加密后的字符串
* @throws NoSuchAlgorithmException 没有这种产生消息摘要的算法
* @throws UnsupportedEncodingException
*/
public static String EncoderByMd5(String str) throws NoSuchAlgorithmException, UnsupportedEncodingException{
byte[] salt = str.getBytes("UTF-8");
//确定计算方法
MessageDigest md5=MessageDigest.getInstance("MD5");
//将数组放入计算
md5.update(salt);
//执行计算
byte[] temp=md5.digest();
StringBuffer sb = new StringBuffer();
//转化16进制 ?与前端js一致?
for(int i=0;i<temp.length;i++){
int val = ((int)temp[i])&0xff;
if(val<16){
sb.append("0");
}
sb.append(Integer.toHexString(val));
}
return sb.toString();
}
/*//密码前端先加密一次,然后后端再加盐 (username+加密过的密码)再加密
public static void main(String args[]) throws NoSuchAlgorithmException, UnsupportedEncodingException{
String str ="root"+"63a9f0ea7bb98050796b649e85481845";
System.out.println(EncoderByMd5(str));
}*/
}
| [
"tmq77"
]
| tmq77 |
31b819db67329af360f567662c992c6ab0b2d985 | 826c2ed5532895751461e7bcce67fd67ef62c4b7 | /agent/plugins/elasticsearch-plugin/src/test/common/java/org/glowroot/agent/plugin/elasticsearch/ElasticsearchSyncIT.java | fa1acd281471ff92395c6db1eb63be4200698ead | [
"Apache-2.0"
]
| permissive | Varshini5811/Glowrooot | 4a42dad1b9f2fefc443bb58218775c7e60b82936 | 385d4e6c38e5d507da966e84d19ddc46c6e11c5f | refs/heads/master | 2022-12-20T16:02:38.831582 | 2019-10-01T04:56:12 | 2019-10-01T04:56:12 | 212,013,890 | 0 | 0 | Apache-2.0 | 2022-12-12T21:42:09 | 2019-10-01T04:41:33 | Java | UTF-8 | Java | false | false | 19,454 | java | /**
* Copyright 2017 the original author or 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 org.glowroot.agent.plugin.elasticsearch;
import java.net.InetSocketAddress;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import com.google.common.collect.Lists;
import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.transport.InetSocketTransportAddress;
import org.elasticsearch.index.query.QueryBuilders;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.glowroot.agent.it.harness.AppUnderTest;
import org.glowroot.agent.it.harness.Container;
import org.glowroot.agent.it.harness.TransactionMarker;
import org.glowroot.wire.api.model.TraceOuterClass.Trace;
import static org.assertj.core.api.Assertions.assertThat;
public class ElasticsearchSyncIT {
private static Container container;
@BeforeClass
public static void setUp() throws Exception {
container = SharedSetupRunListener.getContainer();
}
@AfterClass
public static void tearDown() throws Exception {
SharedSetupRunListener.close(container);
}
@After
public void afterEachTest() throws Exception {
container.checkAndReset();
}
@Test
public void shouldCaptureDocumentPut() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentPut.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("PUT testindex/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentGet() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentGet.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("GET testindex/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).startsWith(" [");
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentUpdate() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentUpdate.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("PUT testindex/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).startsWith(" [");
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentDelete() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentDelete.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("DELETE testindex/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).startsWith(" [");
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentSearchWithoutSource() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentSearchWithoutSource.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("SEARCH testindex/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentSearchWithoutIndexesWithoutSource() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentSearchWithoutIndexesWithoutSource.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("SEARCH _any/testtype");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentSearchWithoutIndexesWithoutTypesWithoutSource()
throws Exception {
// when
Trace trace = container
.execute(ExecuteDocumentSearchWithoutIndexesWithoutTypesWithoutSource.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("SEARCH /");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentSearchWithMultipleIndexesWithMultipleTypesWithoutSource()
throws Exception {
// when
Trace trace = container.execute(
ExecuteDocumentSearchWithMultipleIndexesWithMultipleTypesWithoutSource.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).isEqualTo("SEARCH testindex,testindex2/testtype,testtype2");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
@Test
public void shouldCaptureDocumentSearchWithSource() throws Exception {
// when
Trace trace = container.execute(ExecuteDocumentSearchWithSource.class);
// then
checkTimers(trace);
Iterator<Trace.Entry> i = trace.getEntryList().iterator();
List<Trace.SharedQueryText> sharedQueryTexts = trace.getSharedQueryTextList();
Trace.Entry entry = i.next();
assertThat(entry.getDepth()).isEqualTo(0);
assertThat(entry.getMessage()).isEmpty();
assertThat(sharedQueryTexts.get(entry.getQueryEntryMessage().getSharedQueryTextIndex())
.getFullText()).startsWith("SEARCH testindex/testtype {");
assertThat(entry.getQueryEntryMessage().getPrefix()).isEqualTo("elasticsearch execution: ");
assertThat(entry.getQueryEntryMessage().getSuffix()).isEmpty();
assertThat(i.hasNext()).isFalse();
}
private static void checkTimers(Trace trace) {
Trace.Timer rootTimer = trace.getHeader().getMainThreadRootTimer();
List<String> timerNames = Lists.newArrayList();
for (Trace.Timer timer : rootTimer.getChildTimerList()) {
timerNames.add(timer.getName());
}
Collections.sort(timerNames);
assertThat(timerNames).containsExactly("elasticsearch execute");
for (Trace.Timer timer : rootTimer.getChildTimerList()) {
assertThat(timer.getChildTimerList()).isEmpty();
}
assertThat(trace.getHeader().getAsyncTimerCount()).isZero();
}
public static class ExecuteDocumentPut implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
}
}
public static class ExecuteDocumentGet implements AppUnderTest, TransactionMarker {
private TransportClient client;
private String documentId;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
IndexResponse response = client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
documentId = response.getId();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareGet("testindex", "testtype", documentId)
.get();
}
}
public static class ExecuteDocumentUpdate implements AppUnderTest, TransactionMarker {
private TransportClient client;
private String documentId;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
IndexResponse response = client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
documentId = response.getId();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareUpdate("testindex", "testtype", documentId)
.setDoc("xyz", "some updated text")
.get();
}
}
public static class ExecuteDocumentDelete implements AppUnderTest, TransactionMarker {
private TransportClient client;
private String documentId;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
IndexResponse response = client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
documentId = response.getId();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareDelete("testindex", "testtype", documentId)
.get();
}
}
public static class ExecuteDocumentSearchWithoutSource
implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch("testindex")
.setTypes("testtype")
.get();
}
}
public static class ExecuteDocumentSearchWithoutIndexesWithoutSource
implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch()
.setTypes("testtype")
.get();
}
}
public static class ExecuteDocumentSearchWithoutTypesWithoutSource
implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch("testindex")
.get();
}
}
public static class ExecuteDocumentSearchWithoutIndexesWithoutTypesWithoutSource
implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch()
.get();
}
}
public static class ExecuteDocumentSearchWithMultipleIndexesWithMultipleTypesWithoutSource
implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
client.prepareIndex("testindex2", "testtype2")
.setSource("abc2", 11, "xyz2", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch("testindex", "testindex2")
.setTypes("testtype", "testtype2")
.get();
}
}
public static class ExecuteDocumentSearchWithSource implements AppUnderTest, TransactionMarker {
private TransportClient client;
@Override
public void executeApp() throws Exception {
client = Util.client();
client.addTransportAddress(
new InetSocketTransportAddress(new InetSocketAddress("127.0.0.1", 9300)));
client.prepareIndex("testindex", "testtype")
.setSource("abc", 11, "xyz", "some text")
.get();
transactionMarker();
client.close();
}
@Override
public void transactionMarker() throws Exception {
client.prepareSearch("testindex")
.setTypes("testtype")
.setQuery(QueryBuilders.termQuery("xyz", "text"))
.get();
}
}
}
| [
"[email protected]"
]
| |
9d0969079140730969c6e2b1cd11a5c8f90be226 | e7befe058496daae36c6bbb59696decdca2b2d86 | /src/Solver.java | 978aad16f7cf9be4ecda256a48afff73e718f61a | []
| no_license | GarryWah/15Puzzle | 902b9921c66188ba71ee83900e64be3d7b869022 | 543178c3f3d96ddf4dafbb14788a7f00d4f474ea | refs/heads/master | 2021-01-20T02:42:35.104908 | 2017-04-26T06:17:26 | 2017-04-26T06:17:26 | 89,444,236 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,346 | java | import edu.princeton.cs.algs4.MinPQ;
import edu.princeton.cs.algs4.Stack;
/**
* Created by Admin on 4/13/2017.
*/
public class Solver {
private final Board initial;
private int minMoves;
private Iterable<Board> graph;
public Solver(Board initial) {
if (initial == null) throw new NullPointerException();
this.initial = initial;
graph = solution();
}
// find a solution to the initial board (using the A* algorithm)
public boolean isSolvable() {
return solution() != null;
} // is the initial board solvable?
public int moves() {
return minMoves;
} // min number of moves to solve initial board; -1 if unsolvable
public Iterable<Board> solution() {
MinPQ<Node> pq = new MinPQ<>();
MinPQ<Node> pqTwin = new MinPQ<>();
Board twin = initial.twin();
Stack<Board> result = new Stack<>();
Node root = new Node(initial, 0, initial.manhattan(), null);
Node rootTwin = new Node(twin, 0, twin.manhattan(), null);
// System.out.println(initial.toString());
pq.insert(root);
pqTwin.insert(rootTwin);
Node node;
Node nodeTwin;
while (true) {
node = pq.delMin();
nodeTwin = pqTwin.delMin();
// result.enqueue(node.board);
// System.out.println("Moves: " + node.moves + " priority: " + node.priority);
// System.out.println(node.board.toString());
if (node.board.isGoal()) {
minMoves = node.moves;
while (node.prev != null) {
result.push(node.board);
node = node.prev;
}
result.push(node.board);
return result;
}
if (nodeTwin.board.isGoal()) {
// System.out.println("Twin success!");
minMoves = -1;
result = null;
return result;
}
for (Board b : node.board.neighbors()) {
if (node.prev == null) {
pq.insert(new Node(b, node.moves + 1, b.manhattan() + node.moves + 1, node));
} else {
if (!b.equals(node.prev.board)) {
pq.insert(new Node(b, node.moves + 1, b.manhattan() + node.moves + 1, node));
}
}
}
for (Board bTwin : nodeTwin.board.neighbors()) {
if (nodeTwin.prev == null) {
pqTwin.insert(new Node(bTwin, nodeTwin.moves + 1, bTwin.manhattan() + nodeTwin.moves + 1, nodeTwin));
} else {
if (!bTwin.equals(nodeTwin.prev.board)) {
pqTwin.insert(new Node(bTwin, nodeTwin.moves + 1, bTwin.manhattan() + nodeTwin.moves + 1, nodeTwin));
}
}
}
}
} // sequence of boards in a shortest solution; null if unsolvable
private class Node implements Comparable<Node> {
Board board;
int moves;
int priority;
Node prev;
public Node(Board board, int moves, int priority, Node prev) {
this.board = board;
this.moves = moves;
this.priority = priority;
this.prev = prev;
}
@Override
public int compareTo(Node o) {
if (priority < o.priority) return -1;
if (priority > o.priority) return 1;
return 0;
}
}
public static void main(String[] args) {
// int[][] test = new int[3][3];
// test[0][0] = 1;
// test[0][1] = 2;
// test[0][2] = 3;
// test[1][0] = 4;
// test[1][1] = 5;
// test[1][2] = 6;
// test[2][0] = 8;
// test[2][1] = 7;
// test[2][2] = 0;
// Board board = new Board(test);
// System.out.println(board.manhattan());
// Solver solver = new Solver(board);
// Iterable<Board> solution = solver.solution();
//
// if (solution != null) {
// for (Board b : solution) {
// System.out.println(b.toString());
// }
// } else
// System.out.println("unsolvable");
} // solve a slider puzzle (given below)
}
| [
"[email protected]"
]
| |
52b7c0558169840c6e47faa82bb8513d7f8dff35 | ffaa0a7f468f37893a8c292574b9f0affb0730bb | /mvc/src/main/java/com/example/mvcdeom/modle/User.java | 6d3bfe05122fa5505e57be65e854c8c53a2736cf | []
| no_license | xiaoyuZhou93/frameDemo | 1ab491ee9da40ab9aabf4146a44c5f38ce396f98 | f923e5b4fe2ce947a3b152cd14528dc7397fa2fb | refs/heads/master | 2020-06-21T21:00:20.093930 | 2019-09-26T03:36:27 | 2019-09-26T03:36:27 | 197,551,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 557 | java | package com.example.mvcdeom.modle;
/***
* 登陆成功的 bean
* @Author: Zhou xiaoyu
* @CreateDate: 2019/7/18 0018
*
*/
public class User {
private String name;
private String pwd;
public User(String name, String pwd) {
this.name = name;
this.pwd = pwd;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
}
| [
"!@#$%^&*"
]
| !@#$%^&* |
7230da621e9caec9b642eb7d4878979e7e961090 | 674613e6c7159525e6d54a3ff7d222bd133fd4df | /src/main/java/SlackApp.java | 45f4cc11e5e6d8a57bc024d2c06095e648d53291 | []
| no_license | d2bajaj/SlackApp-HCPatientGuide | 7f4ed702925bf69600cb836a159fb2eaffd49c58 | f17d2834b2d74eb5147f23c206c8fce1af59231c | refs/heads/master | 2023-03-05T14:29:48.858686 | 2021-02-16T02:06:00 | 2021-02-16T02:06:00 | 338,406,722 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,222 | java | import Config.SlackConfiguration;
import EventHandlers.SlackActionCommandUserSelectedMedicinesHandler;
import EventHandlers.SlackCommandMedicinesHandler;
import com.slack.api.bolt.App;
import com.slack.api.bolt.AppConfig;
import com.slack.api.bolt.socket_mode.SocketModeApp;
public class SlackApp {
static {
System.setProperty("org.slf4j.simpleLogger.defaultLogLevel", "trace");
}
private static SlackConfiguration configuration = new SlackConfiguration();
private static String medicineSlashCommand = "/medicines";
private static String actionIdMedicinesUserSelected = "user_select_medicines_action";
public static void main(String[] args) throws Exception {
String botToken = configuration.getBotToken();
String appToken = configuration.getAppToken();
App app = new App(AppConfig.builder().singleTeamBotToken(botToken).build());
app.command(medicineSlashCommand, new SlackCommandMedicinesHandler(actionIdMedicinesUserSelected));
app.blockAction(actionIdMedicinesUserSelected, new SlackActionCommandUserSelectedMedicinesHandler());
SocketModeApp socketModeApp = new SocketModeApp(appToken, app);
socketModeApp.start();
}
} | [
""
]
| |
84e460aee44ed201ec164f183087883f3e10d4ce | f786b239d5e3cf60cc84f6df708d6b33831e3ef8 | /app/src/main/java/com/dalmirdasilva/androidmessagingprotocol/device/message/DataMessage.java | 8c1dbad7f29758d7ab4b50064962ab82cb4446bf | []
| no_license | dalmirdasilva/AndroidMessagingProtocol | 7753a4466de8c36bbe9b6b2cbd043efbd21fe949 | fafffac117f058dc08322e993fd30e2042520d18 | refs/heads/master | 2021-01-22T00:04:04.029370 | 2018-09-27T06:50:17 | 2018-09-27T06:53:00 | 102,184,819 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 309 | java | package com.dalmirdasilva.androidmessagingprotocol.device.message;
import java.util.ArrayList;
import java.util.List;
public class DataMessage extends Message {
public DataMessage() {
super(Message.TYPE_DATA);
}
public DataMessage(Byte[] payload) {
this();
this.payload = payload;
}
}
| [
"[email protected]"
]
| |
014360cf94b55af45af1bf0e877670083865b78a | 33113ce79972c67c8a82105d65f3b1c751f8cc05 | /app/src/main/java/com/dnamedical/Models/VideoModel.java | f8f2dd432dbb66e44792e1d8d07006e51cd838a3 | []
| no_license | rajpatel123/DNA | e7823cd8a53bbf5a891de91389c7efef490dc0ae | 9c269128c20176de5dacd7123376d4154ea88f18 | refs/heads/master | 2021-08-20T01:48:22.504104 | 2020-04-20T10:35:23 | 2020-04-20T10:35:23 | 162,786,524 | 0 | 1 | null | 2020-03-26T09:33:28 | 2018-12-22T06:10:35 | Java | UTF-8 | Java | false | false | 637 | java | package com.dnamedical.Models;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
import java.util.List;
public class VideoModel {
@SerializedName("id")
@Expose
private String id;
@SerializedName("v_name")
@Expose
private String vName;
@SerializedName("title")
@Expose
private String title;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getVName() {
return vName;
}
public void setVName(String vName) {
this.vName = vName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
}
| [
"[email protected]"
]
| |
235758188efa8a7af222e31f2163968033d24c78 | 389d09b229ccc4aa8e0c0f2b09b501bcbffc42b9 | /curso_spring_modulo_2/spring_di_anotaciones/di_anotacion_autowire_SpringQualifier2/src/main/java/com/bolsadeideas/ejemplos/Persona.java | 4a68d32f7e2c1b275d7b73b5fdc42756ae02711f | []
| no_license | jordysp92/CursoSpringFramework-4.3 | 46bdc3b8ad0374ed3eba59e106d5882746602ab3 | 142fa66db38313fafb63abc25f3280227337ce3a | refs/heads/master | 2020-05-21T21:21:15.524007 | 2019-05-11T16:05:14 | 2019-05-11T16:05:14 | 186,151,280 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,058 | java | package com.bolsadeideas.ejemplos;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
public class Persona {
private String nombre = "Andres Guzman";
private int edad = 34;
private float peso = 1.99f;
private boolean programador = true;
// Usando anotacion @Autowired con atributo
@Autowired
@Qualifier("campo")
private IDireccion direccion;
public IDireccion getDireccion() {
return direccion;
}
// public void setDireccion(IDireccion direccion) {
// this.direccion = direccion;
// }
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public int getEdad() {
return edad;
}
public void setEdad(int edad) {
this.edad = edad;
}
public float getPeso() {
return peso;
}
public void setPeso(float peso) {
this.peso = peso;
}
public boolean isProgramador() {
return programador;
}
public void setProgramador(boolean esProgramador) {
this.programador = esProgramador;
}
}
| [
"[email protected]"
]
| |
249773a2036f82b56def40eaea857f2e83ad01f9 | 086cd7f835fd58f57175ace30c501af1d8707635 | /src/main/java/com/hlq/wxshop/service/impl/ProductInfoServiceImpl.java | 09a90a341a574b53c7a07bcef7eb4dd6ba9b3480 | []
| no_license | hlqhlq/wechat_shop | 9347720c0e864bde6219962defabcc2aa4bf154c | 55285ad3ce9ef2bfda31830d70b233313ec1688a | refs/heads/master | 2020-04-26T17:57:14.198728 | 2019-05-05T09:22:39 | 2019-05-05T09:22:39 | 173,729,709 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,389 | java | package com.hlq.wxshop.service.impl;
import com.hlq.wxshop.config.LimitGlobalData;
import com.hlq.wxshop.dao.ProductInfoDao;
import com.hlq.wxshop.dto.CartDTO;
import com.hlq.wxshop.enums.ProductStatusEnum;
import com.hlq.wxshop.enums.ResultEnum;
import com.hlq.wxshop.exception.SellException;
import com.hlq.wxshop.model.ProductInfo;
import com.hlq.wxshop.service.ProductInfoService;
import com.hlq.wxshop.utils.DateFormatUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/**
* @Author:HLQ
* @Date:2019/3/6 11:36
*/
@Service
public class ProductInfoServiceImpl implements ProductInfoService {
/**
* 自定义属性值
*/
@Autowired
private LimitGlobalData limitGlobalData;
@Autowired
private ProductInfoDao dao;
@Override
public ProductInfo findOne(String productId) {
return dao.findOne(productId);
}
@Override
public List<ProductInfo> findByCategoryTypeIn(Integer categoryType) {
return dao.findByCategoryTypeIn(categoryType);
}
@Override
public List<ProductInfo> findOnAll() {
return dao.findByProductStatus(ProductStatusEnum.On.getCode());
}
@Override
public Page<ProductInfo> findAll(Pageable pageable) {
return dao.findAll(pageable);
}
@Override
@Transactional(rollbackFor =Exception.class)
public ProductInfo save(ProductInfo productInfo) {
return dao.save(productInfo);
}
@Override
@Transactional(rollbackFor =Exception.class )
public void addStock(List<CartDTO> cartDTOList) {
for (CartDTO cartDTO: cartDTOList) {
ProductInfo productInfo = dao.findOne(cartDTO.getProductId());
if (productInfo == null) {
throw new SellException(ResultEnum.PRODUCT_NOT_EXIST);
}
Integer result = productInfo.getProductStock() + cartDTO.getProductQuantity();
productInfo.setProductStock(result);
dao.save(productInfo);
}
}
@Override
@Transactional(rollbackFor =Exception.class )
public void addVolume(List<CartDTO> cartDTOList) {
for (CartDTO cartDTO: cartDTOList) {
ProductInfo productInfo = dao.findOne(cartDTO.getProductId());
if (productInfo == null) {
throw new SellException(ResultEnum.PRODUCT_NOT_EXIST);
}
Integer result = productInfo.getProductVolume() + cartDTO.getProductQuantity();
productInfo.setProductVolume(result);
dao.save(productInfo);
}
}
@Override
@Transactional(rollbackFor =Exception.class)
public void decVolume(List<CartDTO> cartDTOList) {
for (CartDTO cartDTO: cartDTOList) {
ProductInfo productInfo = dao.findOne(cartDTO.getProductId());
if (productInfo == null) {
throw new SellException(ResultEnum.PRODUCT_NOT_EXIST);
}
Integer result = productInfo.getProductVolume()-cartDTO.getProductQuantity();
productInfo.setProductVolume(result);
dao.save(productInfo);
}
}
@Override
@Transactional(rollbackFor =Exception.class )
public void decStock(List<CartDTO> cartDTOList) {
for(CartDTO cartDTO:cartDTOList){
ProductInfo info = dao.findOne(cartDTO.getProductId());
if(info == null){
throw new SellException(ResultEnum.PRODUCT_NOT_EXIST);
}
Integer result = info.getProductStock() - cartDTO.getProductQuantity();
if(result<0){
throw new SellException(ResultEnum.PRODUCT_STOCK_ERROR);
}
info.setProductStock(result);
dao.save(info);
}
}
@Override
public List<ProductInfo> findGoodsByVolume() {
List<ProductInfo> list = dao.findGoodsByVolume(limitGlobalData.getProductNum());
return list;
}
@Override
@Transactional(rollbackFor =Exception.class)
public ProductInfo updateHits(String productId) {
ProductInfo product = dao.findOne(productId);
AtomicInteger hits=new AtomicInteger(product.getProductHits());
//保证多线程安全
product.setProductHits(hits.incrementAndGet());
ProductInfo result = dao.save(product);
return result;
}
@Override
public List<ProductInfo> findMostHotsGoodsByHits() {
List<ProductInfo> info = dao.findMostHotsGoodsByHits(limitGlobalData.getHitsNum());
return info;
}
@Override
@Transactional(rollbackFor =Exception.class)
public ProductInfo update(ProductInfo productInfo) {
ProductInfo info = dao.findOne(productInfo.getProductId());
productInfo.setProductVolume(info.getProductVolume());
productInfo.setProductHits(info.getProductHits());
productInfo.setCreateTime(info.getCreateTime());
productInfo.setUpdateTime(new Date());
ProductInfo product = dao.save(productInfo);
return product;
}
@Override
@Transactional(rollbackFor =Exception.class)
public ProductInfo takeOff(String productId) {
ProductInfo productInfo = dao.findOne(productId);
productInfo.setProductStatus(ProductStatusEnum.Down.getCode());
productInfo.setUpdateTime(new Date());
ProductInfo result = dao.save(productInfo);
return result;
}
@Override
@Transactional(rollbackFor =Exception.class)
public ProductInfo putOn(String productId) {
ProductInfo productInfo = dao.findOne(productId);
productInfo.setProductStatus(ProductStatusEnum.On.getCode());
productInfo.setUpdateTime(new Date());
ProductInfo result = dao.save(productInfo);
return result;
}
@Override
public Page<ProductInfo> searchByKey(String productId, String productName, Integer categoryType, Pageable pageable) {
return dao.searchByKey(productId,productName,categoryType,pageable);
}
@Override
public void deleteById(String productId) {
dao.delete(productId);
}
}
| [
"[email protected]"
]
| |
a8537169d1df5d2bfedf331e49423b2c66d7d27b | e2960a3872cecd096e62ca83aa8a16644b6fad68 | /app/src/main/java/com/birina/bsecure/SplashActivity.java | 57e446f91766d8c68903166911f6748d92bb0b44 | []
| no_license | SanjaySharma/Birina | ffd09c1025702302744b6c434fb494eb7108ba15 | 779795c9b7c722aa7ffa2a72e654a636d03c058c | refs/heads/master | 2021-01-24T01:51:21.875255 | 2019-03-31T12:31:26 | 2019-03-31T12:31:26 | 122,822,711 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,000 | java | package com.birina.bsecure;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import com.birina.bsecure.Base.BaseActivity;
import com.birina.bsecure.login.LoginActivity;
import com.birina.bsecure.registration.RegistrationActivity;
public class SplashActivity extends BaseActivity {
private final int SPLASH_DISPLAY_LENGTH = 1500;
@Override
public void onBackPressed() {
System.exit(0);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash);
android.support.v7.app.ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null)
supportActionBar.hide();
// New handler to start the splash activity
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
startActivity(new Intent(SplashActivity.this,
RegistrationActivity.class));
finish();
}
}, SPLASH_DISPLAY_LENGTH);
}
}
| [
"[email protected]"
]
| |
85651e78c0428a888bbda49ba2cad88a83fa0b59 | 1bf5d0a43df5401409cff7792a23d6cc6e0ee3df | /gmall-sms/src/main/java/com/atguigu/gmall/sms/controller/SeckillSkuNoticeController.java | 8fe7c450ea286061e28013557078f6d4a7164f99 | [
"Apache-2.0"
]
| permissive | yuanman-666/gmall | f39ed80a089b5032ddad0131476e904df4643795 | 31d9005fb5ce32ede5b97f4f5ec11082162e7ad7 | refs/heads/master | 2022-07-31T17:28:45.826797 | 2020-02-02T13:06:16 | 2020-02-02T13:06:16 | 234,684,854 | 0 | 0 | Apache-2.0 | 2022-07-06T20:46:53 | 2020-01-18T05:08:49 | JavaScript | UTF-8 | Java | false | false | 2,587 | java | package com.atguigu.gmall.sms.controller;
import java.util.Arrays;
import java.util.Map;
import com.atguigu.core.bean.PageVo;
import com.atguigu.core.bean.QueryCondition;
import com.atguigu.core.bean.Resp;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.atguigu.gmall.sms.entity.SeckillSkuNoticeEntity;
import com.atguigu.gmall.sms.service.SeckillSkuNoticeService;
/**
* 秒杀商品通知订阅
*
* @author liuzhiyuan
* @email [email protected]
* @date 2020-02-02 20:50:53
*/
@Api(tags = "秒杀商品通知订阅 管理")
@RestController
@RequestMapping("sms/seckillskunotice")
public class SeckillSkuNoticeController {
@Autowired
private SeckillSkuNoticeService seckillSkuNoticeService;
/**
* 列表
*/
@ApiOperation("分页查询(排序)")
@GetMapping("/list")
@PreAuthorize("hasAuthority('sms:seckillskunotice:list')")
public Resp<PageVo> list(QueryCondition queryCondition) {
PageVo page = seckillSkuNoticeService.queryPage(queryCondition);
return Resp.ok(page);
}
/**
* 信息
*/
@ApiOperation("详情查询")
@GetMapping("/info/{id}")
@PreAuthorize("hasAuthority('sms:seckillskunotice:info')")
public Resp<SeckillSkuNoticeEntity> info(@PathVariable("id") Long id){
SeckillSkuNoticeEntity seckillSkuNotice = seckillSkuNoticeService.getById(id);
return Resp.ok(seckillSkuNotice);
}
/**
* 保存
*/
@ApiOperation("保存")
@PostMapping("/save")
@PreAuthorize("hasAuthority('sms:seckillskunotice:save')")
public Resp<Object> save(@RequestBody SeckillSkuNoticeEntity seckillSkuNotice){
seckillSkuNoticeService.save(seckillSkuNotice);
return Resp.ok(null);
}
/**
* 修改
*/
@ApiOperation("修改")
@PostMapping("/update")
@PreAuthorize("hasAuthority('sms:seckillskunotice:update')")
public Resp<Object> update(@RequestBody SeckillSkuNoticeEntity seckillSkuNotice){
seckillSkuNoticeService.updateById(seckillSkuNotice);
return Resp.ok(null);
}
/**
* 删除
*/
@ApiOperation("删除")
@PostMapping("/delete")
@PreAuthorize("hasAuthority('sms:seckillskunotice:delete')")
public Resp<Object> delete(@RequestBody Long[] ids){
seckillSkuNoticeService.removeByIds(Arrays.asList(ids));
return Resp.ok(null);
}
}
| [
"[email protected]"
]
| |
ac71f7a6bbe090c3aebd5031c94e81d2feb7de52 | 4b12e00acec8096fad1e0a8adbcf8835ba254cec | /JavaBasics2020/src/com/syntax/class10/ArrayLength.java | a01aec973e770f21e6caf88c13c3cd41c47de311 | []
| no_license | Djandrew10/JavaBasics2020 | cb4f92ffbc6b8c39992f73e1b899851b19b6184b | 6732f5e725400ba43a8479d4ec74508ac06fe905 | refs/heads/master | 2022-12-24T10:12:08.636431 | 2020-09-25T08:53:28 | 2020-09-25T08:53:28 | 274,979,584 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 622 | java | package com.syntax.class10;
public class ArrayLength {
public static void main(String[] args) {
String[] group1 = new String[5];
group1[3] = "Kamila";
group1[1] = "Elshan";
group1[4] = "Yuriy";
System.out.println(group1[0]);
System.out.println(group1[1]);
int arrLength = group1.length;
System.out.println("The length of the array is: " + arrLength);
System.out.println("=====================");
String[] group2 = { "Ali", "Ksenia", "Olga", "Castro" };
System.out.println("The size of group 2 is: " + group2.length);
// HW create an array of 4 integers and see the default values.
}
}
| [
"[email protected]"
]
| |
42d05ae2b01c511d3df8023cae9bbe3e972f741c | 6cbf05870c22b97e961d5fe04743855dca71a4bc | /app/src/main/java/com/example/liangwanandroid/presenter/knowledge/impl/KnowledgePresenterImpl.java | 16c8d3b3c83df8b4b1fb83d3373ccb918b028307 | [
"MIT"
]
| permissive | Mryanze/aLiangWanAndroid | 4c6ba3a9e44cda5069f13c4e21998e231d63d94c | fe16d3e6eadec622790958ed502ada323edf4470 | refs/heads/master | 2020-05-24T00:44:15.646154 | 2019-04-25T02:07:41 | 2019-04-25T02:07:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 663 | java | package com.example.liangwanandroid.presenter.knowledge.impl;
import android.annotation.SuppressLint;
import android.content.Context;
import com.example.liangwanandroid.presenter.knowledge.interfaces.KnowledgeContract;
import com.example.liangwanandroid.utils.ALogger;
public class KnowledgePresenterImpl extends KnowledgeContract.Presenter {
@SuppressLint("CheckResult")
@Override
public void initData(Context context) {
model.getKnowledgeData(context).subscribe(listBaseBean -> view.showKnowLedge(listBaseBean.getData()), throwable -> {
ALogger.e("knowledge get data error is" + throwable.getMessage());
});
}
}
| [
"[email protected]"
]
| |
cf9b37c155ce012e3cd06ca492d0e6996ece8c26 | b1a7149172a52a7ee7c67affab9da92492b0ec6a | /src/java/main/org/dbunit/datasets/dataset/tokens/TokenReplacingReader.java | 73f8dfdada2eb472305ec88cf2570269b29c702e | []
| no_license | ryaneberly/dbunit-datasets | 119071d8b69c180c4ba32febf79243f5a4297094 | 9fcceb254a5933206d3520f59e66211ce1f1d09e | refs/heads/master | 2021-01-10T21:16:31.713485 | 2015-06-01T14:24:17 | 2015-06-01T14:24:17 | 26,150,060 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,054 | java | package org.dbunit.datasets.dataset.tokens;
import java.io.IOException;
import java.io.PushbackReader;
import java.io.Reader;
import java.nio.CharBuffer;
public class TokenReplacingReader extends Reader {
protected PushbackReader pushbackReader = null;
protected ITokenResolver tokenResolver = null;
protected StringBuilder tokenNameBuffer = new StringBuilder();
protected String tokenValue = null;
protected int tokenValueIndex = 0;
public TokenReplacingReader(Reader source, ITokenResolver resolver) {
this.pushbackReader = new PushbackReader(source, 2);
this.tokenResolver = resolver;
}
public int read(CharBuffer target) throws IOException {
throw new RuntimeException("Operation Not Supported");
}
public int read() throws IOException {
if(this.tokenValue != null){
if(this.tokenValueIndex < this.tokenValue.length()){
return this.tokenValue.charAt(this.tokenValueIndex++);
}
if(this.tokenValueIndex == this.tokenValue.length()){
this.tokenValue = null;
this.tokenValueIndex = 0;
}
}
int data = this.pushbackReader.read();
if(data != '$') return data;
data = this.pushbackReader.read();
if(data != '{'){
this.pushbackReader.unread(data);
return '$';
}
this.tokenNameBuffer.delete(0, this.tokenNameBuffer.length());
data = this.pushbackReader.read();
while(data != '}'){
this.tokenNameBuffer.append((char) data);
data = this.pushbackReader.read();
}
this.tokenValue = this.tokenResolver
.resolveToken(this.tokenNameBuffer.toString());
if(this.tokenValue == null){
this.tokenValue = "${"+ this.tokenNameBuffer.toString() + "}";
}
if(this.tokenValue.length() == 0){
return read();
}
return this.tokenValue.charAt(this.tokenValueIndex++);
}
public int read(char cbuf[]) throws IOException {
return read(cbuf, 0, cbuf.length);
}
public int read(char cbuf[], int off, int len) throws IOException {
int charsRead = 0;
for(int i=0; i<len; i++){
int nextChar = read();
if(nextChar == -1) {
if(charsRead == 0){
charsRead = -1;
}
break;
}
charsRead = i + 1;
cbuf[off + i] = (char) nextChar;
}
return charsRead;
}
public void close() throws IOException {
this.pushbackReader.close();
}
public long skip(long n) throws IOException {
throw new RuntimeException("Operation Not Supported");
}
public boolean ready() throws IOException {
return this.pushbackReader.ready();
}
public boolean markSupported() {
return false;
}
public void mark(int readAheadLimit) throws IOException {
throw new RuntimeException("Operation Not Supported");
}
public void reset() throws IOException {
throw new RuntimeException("Operation Not Supported");
}
} | [
"[email protected]"
]
| |
d7299ffa613e73d414f38b88b91be9c9aa3eaf9c | d71fc6f733e494f35f1ea855f25c5e830efea632 | /kernel/impl/fabric3-contribution/src/main/java/org/fabric3/contribution/processor/SymLinkContributionProcessor.java | aaacd7b17cc1c5a4b304fc2c0719e5b2d15ccc68 | [
"Apache-2.0"
]
| permissive | carecon/fabric3-core | d92ba6aa847386ee491d16f7802619ee1f65f493 | 14a6c6cd5d7d3cabf92e670ac89432a5f522c518 | refs/heads/master | 2020-04-02T19:54:51.148466 | 2018-12-06T19:56:50 | 2018-12-06T19:56:50 | 154,750,871 | 0 | 0 | null | 2018-10-25T23:39:54 | 2018-10-25T23:39:54 | null | UTF-8 | Java | false | false | 6,861 | java | /*
* Fabric3
* Copyright (c) 2009-2015 Metaform Systems
*
* 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.
* Portions originally based on Apache Tuscany 2007
* licensed under the Apache 2.0 license.
*/
package org.fabric3.contribution.processor;
import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.List;
import org.fabric3.api.host.Fabric3Exception;
import org.fabric3.api.host.stream.Source;
import org.fabric3.api.host.stream.UrlSource;
import org.fabric3.spi.contribution.Contribution;
import org.fabric3.spi.contribution.ContributionProcessor;
import org.fabric3.spi.contribution.ProcessorRegistry;
import org.fabric3.spi.contribution.Resource;
import org.fabric3.spi.introspection.IntrospectionContext;
import org.fabric3.spi.util.RegexHelper;
import org.oasisopen.sca.annotation.Destroy;
import org.oasisopen.sca.annotation.EagerInit;
import org.oasisopen.sca.annotation.Init;
import org.oasisopen.sca.annotation.Reference;
import static org.fabric3.spi.contribution.Constants.EXPLODED_CONTENT_TYPE;
/**
* Processes a symbolic link contribution (*.contribution file). This is done by de-referencing the target directory specified in the .contribution file and
* introspecting it. The introspection results are then copied to the <code>Contribution</code> representing the symbolic link.
*/
@EagerInit
public class SymLinkContributionProcessor implements ContributionProcessor {
public static final String F3_SYMLINK = "f3.symlink";
private ProcessorRegistry processorRegistry;
public SymLinkContributionProcessor(@Reference ProcessorRegistry processorRegistry) {
this.processorRegistry = processorRegistry;
}
@Init
public void init() {
processorRegistry.register(this);
}
@Destroy
public void destroy() {
processorRegistry.unregister(this);
}
public boolean canProcess(Contribution contribution) {
String sourceUrl = contribution.getLocation().toString();
return sourceUrl.endsWith(".contribution") || contribution.getMetaData(Boolean.class, F3_SYMLINK) != null; // source url will change
}
public void processManifest(Contribution contribution, IntrospectionContext context) {
try {
Contribution syntheticContribution = createSyntheticContribution(contribution);
processorRegistry.processManifest(syntheticContribution, context);
// override the locations
contribution.overrideLocation(syntheticContribution.getLocation());
contribution.getAdditionalLocations().addAll(syntheticContribution.getAdditionalLocations());
contribution.setManifest(syntheticContribution.getManifest());
contribution.addMetaData(F3_SYMLINK, Boolean.TRUE);
contribution.addMetaData(contribution.getUri(), syntheticContribution);
} catch (IOException e) {
throw new Fabric3Exception(e);
}
}
public void index(Contribution contribution, IntrospectionContext context) {
Contribution syntheticContribution = contribution.getMetaData(Contribution.class, contribution.getUri());
processorRegistry.indexContribution(syntheticContribution, context);
for (Resource resource : syntheticContribution.getResources()) {
resource.setContribution(contribution);
contribution.addResource(resource);
}
}
public void process(Contribution contribution, IntrospectionContext context) {
Contribution syntheticContribution = contribution.getMetaData(Contribution.class, contribution.getUri());
processorRegistry.processContribution(syntheticContribution, context);
contribution.removeMetaData(contribution.getUri());
}
private Contribution createSyntheticContribution(Contribution contribution) throws IOException, Fabric3Exception {
try {
URL location = contribution.getLocation();
Path symFile = Paths.get(location.toURI());
List<String> paths = Files.readAllLines(symFile, Charset.defaultCharset());
if (paths.isEmpty()) {
throw new Fabric3Exception("Invalid contribution file: " + location);
}
// take the first entry in the file as the main contribution location
String pathname = paths.get(0);
// expand variables of the form ${..}
pathname = RegexHelper.expandExpression(pathname, (s) -> {
String var = s.substring(2, s.length() - 1);
String path = System.getenv().get(var);
if (path == null) {
throw new Fabric3Exception("Contribution location environment variable not set: " + var);
}
return path;
});
File file = new File(pathname);
URL dereferencedLocation = file.toURI().toURL();
URI contributionUri = URI.create(file.getName());
Source source = new UrlSource(dereferencedLocation);
long timestamp = System.currentTimeMillis();
Contribution syntheticContribution = new Contribution(contributionUri, source, dereferencedLocation, timestamp, EXPLODED_CONTENT_TYPE);
if (paths.size() > 1) {
for (int i = 1; i < paths.size(); i++) {
String subPath = paths.get(i);
// expand variables of the form ${..}
subPath = RegexHelper.expandExpression(subPath, (s) -> {
String var = s.substring(2, s.length() - 1);
String path = System.getenv().get(var);
if (path == null) {
throw new Fabric3Exception("Contribution location environment variable not set: " + var);
}
return path;
});
syntheticContribution.addAdditionalLocation(new File(subPath).toURI().toURL());
}
}
return syntheticContribution;
} catch (URISyntaxException e) {
throw new IOException(e);
}
}
}
| [
"[email protected]"
]
| |
d873dc83cf2f858c10e86956c07339221d609f8c | 9d907c807eab126224099122323d3ed8fa8e99a4 | /app/src/main/java/br/usjt/ads/desmob/ciclodevida/util/Utils.java | c6167651801ff322ff17585d232042115b50312a | []
| no_license | Erick12031995/CicloDeVida | e844d8dc2364e48c6906277183dd6d00bc765d1b | 163d53251ae682539ae7f6267328fdd921212a9e | refs/heads/master | 2020-04-09T04:11:38.499208 | 2018-12-02T04:34:53 | 2018-12-02T04:34:53 | 160,013,658 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,595 | java | /*
* Copyright (C) 2012 The Android Open Source Project
*
* 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 br.usjt.ads.desmob.ciclodevida.util;
import android.os.Handler;
import android.widget.TextView;
import java.util.List;
public class Utils {
private static br.usjt.ads.desmob.ciclodevida.util.StatusTracker mStatusTracker = br.usjt.ads.desmob.ciclodevida.util.StatusTracker.getInstance();
/**
* Helper method to print out the lifecycle state of each Activity. Note this has
* been wrapped in a Handler to delay the output due to overlaps in lifecycle state
* changes as one Activity launches another.
* @link http://developer.android.com/guide/topics/fundamentals/activities.html#CoordinatingActivities
* @param viewMethods TextView to list out the lifecycle methods called
* @param viewStatus TextView to list out the status of all Activity classes
*/
public static void printStatus(final TextView viewMethods, final TextView viewStatus) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
// Get the stack of Activity lifecycle methods called and print to TextView
StringBuilder sbMethods = new StringBuilder();
List<String> listMethods = mStatusTracker.getMethodList();
for (String method : listMethods) {
sbMethods.insert(0, method + "\r\n");
}
if(viewMethods != null) {
viewMethods.setText(sbMethods.toString());
}
// Get the status of all Activity classes and print to TextView
StringBuilder sbStatus = new StringBuilder();
for (String key : mStatusTracker.keySet()) {
sbStatus.insert(0,key + ": " + mStatusTracker.getStatus(key) + "\n");
}
if(viewStatus != null) {
viewStatus.setText(sbStatus.toString());
}
}
}, 750);
}
}
| [
"[email protected]"
]
| |
56274258f24e6fec75ba4f56708b15e2ca77cd88 | 6a20e0e9f217dc9a561ccccda0ab9adb6fd46600 | /src/main/java/org/apache/chemistry/opencmis/inmemory/storedobj/api/StoredObject.java | 14629d9414b291c8dbedf1347bc9d8dcbcaaa86d | []
| no_license | exo-docker/lightweightCMISserver | ea07659736525b59a5b67c28650f0c16301bb2ca | f52e5c86ced4b1c3a22fe11ed64654e5f4f05f07 | refs/heads/master | 2020-04-08T09:09:01.928045 | 2018-12-05T11:19:51 | 2018-12-05T11:19:51 | 159,210,451 | 0 | 1 | null | 2020-10-15T15:40:07 | 2018-11-26T17:54:18 | Java | UTF-8 | Java | false | false | 9,417 | 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.chemistry.opencmis.inmemory.storedobj.api;
import java.util.GregorianCalendar;
import java.util.List;
import java.util.Map;
import org.apache.chemistry.opencmis.commons.data.AllowableActions;
// suppress unused import
import org.apache.chemistry.opencmis.commons.data.PropertyData;
// suppress unused import
import org.apache.chemistry.opencmis.commons.spi.BindingsObjectFactory;
/**
* Stored Object interface is common part that all objects handled by CMIS
* (Documents, Folders, Relations, Policies, ACLs) share. Objects that implement
* this interface are always concrete and can live in the object store. A stored
* object always has an id, a name and properties.
*
*/
public interface StoredObject {
/**
* Retrieve the id of this object.
*
* @return id of this object
*/
String getId();
/**
* Set the id of this object.
*
* @param id
* id of this object
*/
void setId(String id);
/**
* Retrieve the name of this object.
*
* @return name of this object
*/
String getName();
/**
* Set the name of this document. This method does not persist the object.
*
* @param name
* name that is assigned to this object
*/
void setName(String name);
/**
* Retrieve the type of this document.
*
* @return Id of the type identifying the type of this object
*/
String getTypeId();
/**
* Set the type of this document. This method does not persist the object.
*
* @param type
* id of the type this object gets assigned.
*/
void setTypeId(String type);
/**
* CMIS 1.1 get ids of all secondary types.
*
* @return list of type ids
*/
List<String> getSecondaryTypeIds();
/**
* CMIS 1.1: set description of an object.
*
* @param description
* description of this object
*/
void setDescription(String description);
/**
* CMIS 1.1: get description of an object.
*
* @return description of this object
*/
String getDescription();
/**
* Retrieve the user who created the document.
*
* @return user who created the document.
*/
String getCreatedBy();
/**
* Set the user who last modified the object. This method does not persist.
* the object.
*
* @param createdBy
* user who last modified the document
*/
void setCreatedBy(String createdBy);
/**
* Retrieve the user who last modified the document.
*
* @return user who last modified the document.
*/
String getModifiedBy();
/**
* Set the user who last modified the object. This method does not persist.
* the object.
*
* @param modifiedBy
* user who last modified the document
*/
void setModifiedBy(String modifiedBy);
/**
* Get the creation date.
*
* @return date the object was created at
*/
GregorianCalendar getCreatedAt();
/**
* Assign date and time when the object was created. Usually you should not
* call this method externally. This method does not persist the object.
*
* @param createdAt
* date the object was created at
*/
void setCreatedAt(GregorianCalendar createdAt);
/**
* Retrieve date and time when the object was last modified.
*
* @return date the object was last modified
*/
GregorianCalendar getModifiedAt();
/**
* Assign current date and time when the object was last modified. Usually
* you should not call this method externally. This method does not persist
* the object.
*/
void setModifiedAtNow();
/**
* Set the date and time of the last modification of this object.
*
* @param calendar
* timestamp of last modification
*/
void setModifiedAt(GregorianCalendar calendar);
/**
* Get the repository id of this object where the object is stored.
*
* @return
* repository id of this object
*/
String getRepositoryId();
/**
* Assign a repository where this object will be stored. This method does
* not persist the object.
*
* @param repositoryId
* id of the repository
*/
void setRepositoryId(String repositoryId);
/**
* Retrieve the list of properties.
*
* @return map of properties
*/
Map<String, PropertyData<?>> getProperties();
/**
* Assign the properties to an object. This method does not persist the
* object.
*
* @param props
* properties to be assigned
*/
void setProperties(Map<String, PropertyData<?>> props);
/**
* Retrieve a change token uniquely identifying the state of the object when
* it was persisted (used for optimistic locking).
*
* @return String identifying the change token
*/
String getChangeToken();
/**
* Create all system base properties that need to be stored with every
* object in the repository This method is called when a new object is
* created to record all of the capturing data like the creation time,
* creator etc.
*
* @param properties
* The properties passed by the client, containing, name, type,
* etc
* @param user
* The user creating the document
*/
void createSystemBasePropertiesWhenCreated(Map<String, PropertyData<?>> properties, String user);
/**
* Update all system base properties that need to be stored with every
* object in the repository This method is called when an object is is
* updated to record all of the capturing data like the modification time,
* updating user etc.
*
* @param properties
* The properties passed by the client, containing, name, type,
* etc
* @param user
* The user creating the document
*/
void updateSystemBasePropertiesWhenModified(Map<String, PropertyData<?>> properties, String user);
/**
* fill a passed map object with properties of this object.
*
* @param properties
* map to fill
* @param objFactory
* object factory to create objects
* @param requestedIds
* list of property ids being requested
*/
void fillProperties(Map<String, PropertyData<?>> properties, BindingsObjectFactory objFactory,
List<String> requestedIds);
/**
* Set all properties which are not system properties. These are the
* properties as defined in Type system definition. This method is called
* when an object is created or updated. The implementation must ignore the
* system properties.
*
* @param properties
* Set of properties as set by the client, including system
* parameters
*/
void setCustomProperties(Map<String, PropertyData<?>> properties);
/**
* get the Acl id of the stored object.
*
* @return acl id of the ACl of this object
*/
int getAclId();
/**
* get the allowable actions of the object.
*
* @param user
* user requesting allowable actions
* @return allowable actions of this object for the use
*/
AllowableActions getAllowableActions(String user);
/**
* check if the document can generate a renditions and rendition is visible
* for user.
*
* @param user
* user requesting allowable actions
* @return true if rendition exists, false if not.
*/
boolean hasRendition(String user);
/**
* get applied policies of this object.
*
* @return list of ids of policies applied to this object
*/
List<String> getAppliedPolicies();
/**
* add an id of a policy to an object.
*
* @param policyId
* id of policy to add
*/
void addAppliedPolicy(String policyId);
/**
* remove an id of a policy from an object.
*
* @param policyId
* id of policy to remove
*/
void removePolicy(String policyId);
/**
* set object store to allow each object to find its parent
* @param store
*/
void setStore(ObjectStore store);
/**
* Return the store of objects
* @return
*/
ObjectStore getStore();
} | [
"[email protected]"
]
| |
51b575c001cae7379c809955c2bec20020d91c4a | 59d69bdbc62d15807d41895f644b7938871346ac | /src/revision/Switch1.java | fdbfc856fcca3144a1709c0c115eb37a42724818 | []
| no_license | jaswanth-jash/assginments | daed61eb185d474edaf57c2e4ad97b1f18089ddb | 57fad749ae993e4642ceea07fa78602230ffb913 | refs/heads/master | 2023-04-08T13:15:59.726290 | 2021-04-15T15:03:02 | 2021-04-15T15:03:02 | 287,041,808 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 780 | java | package revision;
public class Switch1 {
public static void main(String[] args) {
int day = 4;
switch (day) {
case 1:
System.out.println("Monday");
break;
case 2:
System.out.println("Tuesday");
break;
case 3:
System.out.println("Wednesday");
break;
case 4:
System.out.println("Thursday");
break;
case 5:
System.out.println("Friday");
break;
case 6:
System.out.println("Saturday");
break;
case 7:
System.out.println("Sunday");
break;
}
}
}
| [
"[email protected]"
]
| |
9a1ff9c57f984dd8d2fc0f863f992fa23c7393b1 | 022d9e139e25a005098a33dc7f6a4778493ce9ac | /src/main/java/com/example/ReadingText/AccountGenerate.java | f5d6a2d7a9fb3a05d0abd33ae1083b4878e44762 | []
| no_license | butolapradip/Atm-application-in-springboot-using-mongo-client | cc190542210fffff51cd79bc854ef737e2125431 | 15a526589ce317f64085570894279c6a405541ca | refs/heads/master | 2020-04-10T13:41:27.760597 | 2018-12-10T03:10:16 | 2018-12-10T03:10:16 | 161,057,041 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,531 | java | package com.example.ReadingText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.core.mapping.event.ValidatingMongoEventListener;
import org.springframework.stereotype.Component;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
@Component
public class AccountGenerate {
@Autowired
AtmDao dao;
private long accountNo;
private int pin;
private long addNo = 0;
public long getAccountNo() {
return accountNo;
}
public void setAccountNo(long accountNo) {
this.accountNo = accountNo;
}
public AccountGenerate(long accountNo, int pin) {
super();
this.accountNo = accountNo;
this.pin = pin;
}
public int getPin() {
return pin;
}
public void setPin(int pin) {
this.pin = pin;
}
public AccountGenerate() {
}
public int pinGenerate() {
pin = (int) (Math.random() * 9000) + 1000;
return pin;
}
public long accountGenerate() {
// get last value from database
// accountNo =lastAccountNo + 1;
addNo = dao.getCountNo();
long accountNo = 10000000000000l + addNo;
System.out.println(accountNo);
this.accountNo = accountNo;
// addNo++;
// get last value from database
return accountNo;
}
/* @Bean
public ValidatingMongoEventListener validatingMongoEventListener() {
return new ValidatingMongoEventListener(validator());
}
@Bean
public LocalValidatorFactoryBean validator() {
return new LocalValidatorFactoryBean();
}*/
}
| [
"[email protected]"
]
| |
375987b09fded0bf155d80734c42b318c54f1066 | c45d7ddfcdc75f96a379225d2df0d0be5af1cf5e | /src/main/java/io/magentys/utils/Sugars.java | 806b46453570663a1a33d45bfad6899275778899 | []
| no_license | gitter-badger/cherry | 730ff758bf042d3152732cdfe7687942d9380b9c | c955707dc00df048c2955f727c4328aac516b11e | refs/heads/master | 2021-01-22T13:03:20.016111 | 2016-04-08T15:24:49 | 2016-04-08T15:24:49 | 55,789,668 | 0 | 0 | null | 2016-04-08T15:31:48 | 2016-04-08T15:31:48 | null | UTF-8 | Java | false | false | 200 | java | package io.magentys.utils;
public class Sugars {
public static <ITEM> ITEM and(ITEM item){
return item;
}
public static <ITEM> ITEM but(ITEM item){
return item;
}
}
| [
"[email protected]"
]
| |
06cf451e50262ac6100ae26ffa1025d6c29c971a | dbab952a4527a87cda154a66669d683311a76ca4 | /datasharing/src/main/java/com/example/dm/enumT/E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行.java | 6edb224857e9fbee3368003635990dd9e02667d2 | []
| no_license | zhoudy-github/demok8s | 6b957cd1e6aaee663fd069e4cd78d2da449a088e | 38f00f7f59b4f55e2c250050608a8131f036c740 | refs/heads/master | 2023-02-17T13:45:15.586325 | 2021-01-18T13:17:11 | 2021-01-18T13:17:11 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,435 | java | package com.example.dm.enumT;
//import com.coalvalue.domain.pojo.ListItem;
/**
* Created by silence on 2016/1/18.
*/
public enum E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 {
国家机关 ("000001", "国家机关",1,""),
民办非企业单位_社会团体 ("000006", "民办非企业单位_社会团体",1,""),
国有企业 ("000002", "国有企业",2,""),
外资企业 ("000004", "外资企业",2,""),
城镇集体企业 ("000003", "城镇集体企业",2,""),
城镇私营企业及其他城镇企业 ("000005", "城镇私营企业及其他城镇企业",2,""),
其他 ("000007", "其他",1,""),
;
public static E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 from(E_待_DP0102_PaymentUnitTypeEnum_单位性质_定 typeEnum) {
switch (typeEnum){
default:
return E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行.其他;
}
}
private final String statusText;
private final String displayText;
private final Integer id;
private String helpMessage;
public String getHelpMessage() {
return helpMessage;
}
public void setHelpMessage(String helpMessage) {
this.helpMessage = helpMessage;
}
public String getDisplayText() {
return displayText;
}
E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行(String statusText, String displayText, Integer id, String helpMessage) {
this.statusText = statusText;
this.displayText = displayText;
this.id = id;
this.helpMessage = helpMessage;
}
public String getText() {
return this.statusText;
}
public Integer getId() {
return this.id;
}
/*
public static List<ListItem> retriveTypese() {
List<ListItem> list = new ArrayList<ListItem>();
for (AccountingVoucherStatusEnum status : AccountingVoucherStatusEnum.values()) {
ListItem element = new ListItem(status.getId(), status.getDisplayText(), status.getHelpMessage());
list.add(element);
}
return list;
}
public static List<ListItem> retriveTypese(String statusText) {
List<ListItem> list = new ArrayList<ListItem>();
for(PersonalAccountStatusEnum status : PersonalAccountStatusEnum.values()) {
ListItem element = new ListItem(status.getText(), status.getDisplayText());
if (status.getText().equals(statusText)){
element.setSelected(true);
}
list.add(element);
}
return list;
}*/
public static E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 fromString(String text) {
for (E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 status : E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行.values()) {
if (status.getText().equals(text) ) {
return status;
}
}
throw new RuntimeException("no customer status " + text);
}
public static E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 fromInt(Integer text) {
for (E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行 status : E_待_DP0102_PaymentUnitTypeEnum_单位性质_工行.values()) {
if (status.getId().equals(text) ) {
return status;
}
}
throw new RuntimeException("no customer status " + text);
}
}
| [
"[email protected]"
]
| |
a9411e0cb5b425fa7ac76fe6844bf0a25eba5bcb | 4fc99bee5733e873e4b7088099c7c2e8e16aa2b5 | /Omertex/domain/src/test/java/com/pgmail/martsulg/domain/ExampleUnitTest.java | ac424603dfd1399a27e58a83f1f49bb92bd69fe6 | []
| no_license | G-Washingt0n/OmertexTestApp | 1e3e0ea7ae68f4788b905efd2491d97548506662 | 6dbc3fdb2d1246c4bc0582a86b4e9aaf2b0afb76 | refs/heads/master | 2021-07-18T01:43:57.262490 | 2017-10-25T22:05:40 | 2017-10-25T22:05:40 | 108,110,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 404 | java | package com.pgmail.martsulg.domain;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
]
| |
8de86452cee0f5daae4ac25553706a96bbb3b699 | 0bfa4b8dd31b12af9192c84d2701a5bb9618b1ce | /materialy_do_kursu/4/4_7/Początek/OpakowywanieTypowProstych.java | f3634f3ab39f5b2f10cbb7a5a7b21a1875a8a04f | [
"MIT"
]
| permissive | janiszewskibartlomiej/Java_beginner_strefakursow | ec92db7d4da6a8a34c286f7efc0f9d0566ea14c6 | c6a514e7dac74e866266f6dce4a7285b64ac250f | refs/heads/master | 2022-12-23T20:18:15.745605 | 2020-10-03T16:10:33 | 2020-10-03T16:10:33 | 294,024,371 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 44 | java | public class OpakowywanieTypowProstych {
} | [
"[email protected]"
]
| |
5705c88d86b4f9bc220d249ba5096419d2d26425 | 6543809d31ffb3f135e73cf1de8ee184fc6e85a3 | /src/jcodecc/javase/src/main/java/org/jcodec/api/awt/AWTFrameGrab.java | eaa45b8aa1ea416b2949a635235b56bc83458eee | []
| no_license | DanisAvko/Mandelbrot | 72d48a53177b8482909896b648d203863ff6b06f | 86b5f92a328c4c4a4be937840af6e5eaf31cbd20 | refs/heads/master | 2020-09-30T03:07:24.332271 | 2019-12-23T09:56:58 | 2019-12-23T09:56:58 | 227,186,662 | 0 | 7 | null | 2019-12-22T20:00:04 | 2019-12-10T18:13:41 | Kotlin | UTF-8 | Java | false | false | 6,191 | java | package jcodecc.javase.src.main.java.org.jcodec.api.awt;
import jcodecc.javase.src.main.java.org.jcodec.scale.AWTUtil;
import org.jcodec.api.FrameGrab;
import org.jcodec.api.JCodecException;
import org.jcodec.api.PictureWithMetadata;
import org.jcodec.api.UnsupportedFormatException;
import org.jcodec.api.specific.ContainerAdaptor;
import org.jcodec.common.SeekableDemuxerTrack;
import org.jcodec.common.io.FileChannelWrapper;
import org.jcodec.common.io.NIOUtils;
import org.jcodec.common.io.SeekableByteChannel;
import org.jcodec.common.model.Picture;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
/**
* This class is part of JCodec ( www.jcodec.org ) This software is distributed
* under FreeBSD License
*
* Extracts frames from a movie into uncompressed images suitable for
* processing.
*
* Supports going to random points inside of a movie ( seeking ) by frame number
* of by second.
*
* NOTE: Supports only AVC ( H.264 ) in MP4 ( ISO BMF, QuickTime ) at this
* point.
*
* NOTE: AWT specific routines
*
* @author The JCodec project
*
*/
public class AWTFrameGrab extends FrameGrab {
public static AWTFrameGrab createAWTFrameGrab(SeekableByteChannel _in) throws IOException, JCodecException {
FrameGrab fg = FrameGrab.createFrameGrab(_in);
return new AWTFrameGrab(fg.getVideoTrack(), fg.getDecoder());
}
public AWTFrameGrab(SeekableDemuxerTrack videoTrack, ContainerAdaptor decoder) {
super(videoTrack, decoder);
}
/**
* Get frame at a specified second as AWT image
*
* @param file
* @param second
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrame(File file, double second) throws IOException, JCodecException {
FileChannelWrapper ch = null;
try {
ch = NIOUtils.readableChannel(file);
return ((AWTFrameGrab) createAWTFrameGrab(ch).seekToSecondPrecise(second)).getFrameWithOrientation();
} finally {
NIOUtils.closeQuietly(ch);
}
}
/**
* Get frame at a specified second as AWT image
*
* @param file
* @param second
* @return
* @throws UnsupportedFormatException
* @throws IOException
*/
public static BufferedImage getFrame(SeekableByteChannel file, double second) throws JCodecException, IOException {
return ((AWTFrameGrab) createAWTFrameGrab(file).seekToSecondPrecise(second)).getFrame();
}
/**
* Get frame at current position in AWT image
*
* @return
* @throws IOException
*/
public BufferedImage getFrame() throws IOException {
Picture nativeFrame = getNativeFrame();
return nativeFrame == null ? null : AWTUtil.toBufferedImage(nativeFrame);
}
public BufferedImage getFrameWithOrientation() throws IOException {
PictureWithMetadata nativeFrame = getNativeFrameWithMetadata();
return nativeFrame == null ? null : AWTUtil.toBufferedImage(nativeFrame.getPicture(), nativeFrame.getOrientation());
}
/**
* Get frame at a specified frame number as AWT image
*
* @param file
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrame(File file, int frameNumber) throws IOException, JCodecException {
FileChannelWrapper ch = null;
try {
ch = NIOUtils.readableChannel(file);
return ((AWTFrameGrab) createAWTFrameGrab(ch).seekToFramePrecise(frameNumber)).getFrame();
} finally {
NIOUtils.closeQuietly(ch);
}
}
/**
* Get frame at a specified frame number as AWT image
*
* @param file
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrame(SeekableByteChannel file, int frameNumber) throws JCodecException, IOException {
return ((AWTFrameGrab) createAWTFrameGrab(file).seekToFramePrecise(frameNumber)).getFrame();
}
/**
* Get a specified frame by number from an already open demuxer track
*
* @param vt
* @param decoder
* @param frameNumber
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrame(SeekableDemuxerTrack vt, ContainerAdaptor decoder, int frameNumber)
throws IOException, JCodecException {
return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToFramePrecise(frameNumber)).getFrame();
}
/**
* Get a specified frame by second from an already open demuxer track
*
* @param vt
* @param decoder
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrame(SeekableDemuxerTrack vt, ContainerAdaptor decoder, double second)
throws IOException, JCodecException {
return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToSecondPrecise(second)).getFrame();
}
/**
* Get a specified frame by number from an already open demuxer track (
* sloppy mode, i.e. nearest keyframe )
*
* @param vt
* @param decoder
* @param frameNumber
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrameSloppy(SeekableDemuxerTrack vt, ContainerAdaptor decoder, int frameNumber)
throws IOException, JCodecException {
return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToFrameSloppy(frameNumber)).getFrame();
}
/**
* Get a specified frame by second from an already open demuxer track (
* sloppy mode, i.e. nearest keyframe )
*
* @param vt
* @param decoder
* @param frameNumber
* @return
* @throws IOException
* @throws JCodecException
*/
public static BufferedImage getFrameSloppy(SeekableDemuxerTrack vt, ContainerAdaptor decoder, double second)
throws IOException, JCodecException {
return ((AWTFrameGrab) new AWTFrameGrab(vt, decoder).seekToSecondSloppy(second)).getFrame();
}
}
| [
"[email protected]"
]
| |
a72bb14d4011a7625774ec974a0901c53781f263 | d98ed4986ecdd7df4c04e4ad09f38fdb7a7043e8 | /Hero_Specialties/src/main/java/net/sf/anathema/hero/specialties/display/presenter/SpecialtiesInitializer.java | db995b64922cc74952694d3a96136069001f5624 | []
| no_license | bjblack/anathema_3e | 3d1d42ea3d9a874ac5fbeed506a1a5800e2a99ac | 963f37b64d7cf929f086487950d4870fd40ac67f | refs/heads/master | 2021-01-19T07:12:42.133946 | 2018-12-18T23:57:41 | 2018-12-18T23:57:41 | 67,353,965 | 0 | 0 | null | 2016-09-04T15:47:48 | 2016-09-04T15:47:48 | null | UTF-8 | Java | false | false | 1,725 | java | package net.sf.anathema.hero.specialties.display.presenter;
import net.sf.anathema.hero.environment.HeroEnvironment;
import net.sf.anathema.hero.individual.model.Hero;
import net.sf.anathema.hero.individual.model.HeroModelInitializer;
import net.sf.anathema.hero.individual.model.RegisteredInitializer;
import net.sf.anathema.hero.individual.overview.HeroModelGroup;
import net.sf.anathema.hero.individual.view.SectionView;
import net.sf.anathema.hero.specialties.model.SpecialtiesModel;
import net.sf.anathema.hero.specialties.model.SpecialtiesModelFetcher;
import net.sf.anathema.library.initialization.Weight;
import net.sf.anathema.library.presenter.CategorizedOptionalPropertyPresenter;
import net.sf.anathema.library.view.property.OptionalPropertiesView;
@RegisteredInitializer (HeroModelGroup.Mundane)
@Weight (weight = 300)
public class SpecialtiesInitializer implements HeroModelInitializer
{
private HeroEnvironment environment;
@SuppressWarnings ("UnusedParameters")
public SpecialtiesInitializer (HeroEnvironment environment)
{
this.environment = environment;
}
@Override
public void initialize (SectionView sectionView, Hero hero)
{
String viewName = environment.getResources ().getString ("AdditionalTemplateView.TabName.Specialties");
OptionalPropertiesView view = sectionView.addView (viewName, OptionalPropertiesView.class);
SpecialtiesModel specialtiesModel = SpecialtiesModelFetcher.fetch (hero);
new CategorizedOptionalPropertyPresenter (hero, specialtiesModel, view, environment.getResources ()).initPresentation ();
}
@Override
public boolean canWorkForHero (Hero hero)
{
return SpecialtiesModelFetcher.fetch (hero) != null;
}
}
| [
"BJ@BJ-PC"
]
| BJ@BJ-PC |
93e81a0ad804dbff4045bb4a23760f8048a41844 | ec8325beae79acd95a60fe95e0576e3b65ed15a0 | /game365-core/src/main/java/com/wz/cashloan/core/common/context/Constant.java | d51a0d652237dbc308d721b05c9f3ab7f6f1d375 | []
| no_license | wangwei615566/game365 | 688f595d69d067e318f7c0a61551631efa158af9 | 477e63974af86c31f3fbbf99316a23b95c3b6800 | refs/heads/master | 2021-07-13T17:35:45.573754 | 2019-01-18T06:38:08 | 2019-01-18T06:38:08 | 145,642,720 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,964 | java |
package com.wz.cashloan.core.common.context;
/**
* 公用常量类定义
*
* @version 1.0
* @author 吴国成f
* @created 2014年9月23日 下午2:17:20
*/
public class Constant {
/** session用户 **/
public static final String SESSION_OPERATOR = "session_operator";
/** 角色session 暂用*/
public static final String ROLEID = "roleId";
public static final String INSERT = "create";
public static final String UPDATE = "update";
public static final String ACCESSCODE = "accessCode";
public static final String RESPONSE_CODE = "code";
public static final String RESPONSE_CODE_MSG = "msg";
public static final String RESPONSE_DATA = "data";
public static final String RESPONSE_DATA_TOTAL = "total";
public static final String RESPONSE_DATA_TOTALCOUNT = "totalCount";
public static final String RESPONSE_DATA_CURRENTPAGE = "currentPage";
public static final String RESPONSE_DATA_PAGE = "page";
public static final String OPERATION_SUCCESS = "操作成功";
public static final String OPERATION_FAIL = "操作失败";
public static final int SIGN_FAIL = 99; // 验签失败
public static final int SUCCEED_CODE_VALUE = 200; // 成功
public static final int FAIL_CODE_PARAM_INSUFFICIENT = 300; //业务异常
public static final int FAIL_CODE_VALUE = 400; // 缺少参数
public static final int OTHER_CODE_VALUE = 500; // 系统异常
public static final int FAIL_CODE_PWD = 401; // 交易密码错误
public static final int PERM_CODE_VALUE = 403; // 无权限访问
public static final int NOSESSION_CODE_VALUE = 800; // session失效
public static final int CLIENT_EXCEPTION_CODE_VALUE = 998; // 连接异常(除请求超时)
public static final int TIMEOUT_CODE_VALUE = 999; // 请求超时
/**武汉成长无限网络科技有限公司相关参数 START*/
public static final String CZWX_LENDER = "武汉成长无限网络科技有限公司";
public static final String RESPONSE_RETCODE = "retCode";//返回状态码
public static final String RESPONSE_RETMSG = "retMsg";//返回消息
public static final String RESPONSE_INFO = "info";//返回数据
public static final String SUCCEED_KNCODE_VALUE = "00000"; // 成功
public static final String FAIL_KNCODE_PARAM = "20001"; // 参数错误
public static final String FAIL_KNCODE_EXP = "10001"; // 服务器异常
public static final String FAIL_BSCODE_EXP = "10002"; // 业务异常
public static final String FAIL_KNCODE_SIGN = "99999"; //验签错误
public static final String FAIL_KNCODE_USER = "30013"; //用户信息不存在
public static final String FAIL_KNCODE_IDNO = "30002"; //身份证号码已经存在
public static final String FAIL_KNCODE_PHONE = "30003"; //手机号码已经存在
public static final String FAIL_KNCODE_BANKCARD = "30004"; //银行卡号已经存在
public static final String FAIL_KNCODE_VERIFYCODE= "20008"; //验证码错误
}
| [
"[email protected]"
]
| |
3a265ee0d9c15b2213c554e38b52a7cdf69c4147 | 73267be654cd1fd76cf2cb9ea3a75630d9f58a41 | /services/aom/src/main/java/com/huaweicloud/sdk/aom/v2/model/DeleteAlarmRuleResponse.java | 255f98208e5f6d396ee93a5a27b7022a4fd3420d | [
"Apache-2.0"
]
| permissive | huaweicloud/huaweicloud-sdk-java-v3 | 51b32a451fac321a0affe2176663fed8a9cd8042 | 2f8543d0d037b35c2664298ba39a89cc9d8ed9a3 | refs/heads/master | 2023-08-29T06:50:15.642693 | 2023-08-24T08:34:48 | 2023-08-24T08:34:48 | 262,207,545 | 91 | 57 | NOASSERTION | 2023-09-08T12:24:55 | 2020-05-08T02:27:00 | Java | UTF-8 | Java | false | false | 1,743 | java | package com.huaweicloud.sdk.aom.v2.model;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.huaweicloud.sdk.core.SdkResponse;
import java.util.Objects;
/**
* Response Object
*/
public class DeleteAlarmRuleResponse extends SdkResponse {
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonProperty(value = "body")
private String body;
public DeleteAlarmRuleResponse withBody(String body) {
this.body = body;
return this;
}
/**
* Get body
* @return body
*/
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
@Override
public boolean equals(java.lang.Object obj) {
if (this == obj) {
return true;
}
if (obj == null || getClass() != obj.getClass()) {
return false;
}
DeleteAlarmRuleResponse that = (DeleteAlarmRuleResponse) obj;
return Objects.equals(this.body, that.body);
}
@Override
public int hashCode() {
return Objects.hash(body);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DeleteAlarmRuleResponse {\n");
sb.append(" body: ").append(toIndentedString(body)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| [
"[email protected]"
]
| |
768602f4738d788efa40365a414867fc901fcff9 | cd6b91d95bd6b322879610471b2243fa10c91d30 | /platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/activity/BaseMapboxMapTest.java | 1b1211b94c675cc9216d3eb19e624652fa6c6369 | [
"BSD-3-Clause",
"IJG",
"LicenseRef-scancode-warranty-disclaimer",
"Zlib",
"curl",
"NCSA",
"LicenseRef-scancode-openssl",
"OpenSSL",
"LicenseRef-scancode-ssleay-windows",
"JSON",
"ISC",
"MIT",
"BSL-1.0",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-unknown-license-reference",
"blessing",
"Libpng"
]
| permissive | wuqiuhao/mapbox-gl-native | dd64cbf294c20ba8cf83bad3b6bd1c210000fd62 | 91fd87f2a05ae310537f50d49e78c1da9b1285d6 | refs/heads/master | 2020-04-28T06:22:11.256890 | 2016-08-02T16:42:58 | 2016-08-06T23:03:46 | 65,172,227 | 1 | 0 | null | 2016-08-08T04:21:35 | 2016-08-08T04:21:35 | null | UTF-8 | Java | false | false | 1,106 | java | package com.mapbox.mapboxsdk.activity;
import android.app.Activity;
import android.support.test.espresso.Espresso;
import android.util.Log;
import com.mapbox.mapboxsdk.activity.utils.OnMapReadyIdlingResource;
import com.mapbox.mapboxsdk.constants.MapboxConstants;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.testapp.R;
import org.junit.After;
import org.junit.Before;
public abstract class BaseMapboxMapTest extends BaseTest {
private OnMapReadyIdlingResource idlingResource;
protected MapboxMap mapboxMap;
@Before
public void registerIdlingResource() {
Log.e(MapboxConstants.TAG, "@Before test");
idlingResource = new OnMapReadyIdlingResource(getActivity());
Espresso.registerIdlingResources(idlingResource);
checkViewIsDisplayed(R.id.mapView);
mapboxMap = idlingResource.getMapboxMap();
}
public abstract Activity getActivity();
@After
public void unregisterIdlingResource() {
Log.e(MapboxConstants.TAG, "@After test");
Espresso.unregisterIdlingResources(idlingResource);
}
}
| [
"[email protected]"
]
| |
06feafcb4c871eb04771db3f998b53761d95ba54 | cfa646154d8b3c0163b7d5b7f74ef446026aa2ca | /java/Oct23-19/src/OnePlus.java | f2767380d155e8a0bba739232b9e45927a0e275c | []
| no_license | Manasa-Acharya/USTGlobal-16Sep19-Manasa | 46f17a348cd7446dee7a40ae9140a71a5fda6c40 | 360b804a3a654c0b9510e37ce8c37ecad643801a | refs/heads/master | 2023-01-14T11:07:50.234076 | 2019-12-22T02:29:08 | 2019-12-22T02:29:08 | 215,539,906 | 0 | 0 | null | 2023-01-07T13:04:49 | 2019-10-16T12:13:42 | Java | UTF-8 | Java | false | false | 157 | java |
public class OnePlus extends Android {
@Override
public void homeScreen() {
System.out.println("HomeDoubleDoubleScreen () method");
}
}
| [
"[email protected]"
]
| |
5027c886098baaf93ad3fa9ea3ba6f86dde6dfdb | a13965972105a61de68a058bfb9638a1e3080dfa | /src/main/java/com/mackittipat/designpattern/behavioural/observer/SubscriberA.java | 261da8a8d9c1d126e00dedd9f40f894cfcefec37 | []
| no_license | MacKittipat/mac-design-pattern | ff988b8c7a554e2d44b90c2d4192068bee828774 | 97c25a13463fa39e16336488548bbb76f92e2d8d | refs/heads/master | 2021-01-18T17:25:41.022301 | 2018-01-21T07:46:34 | 2018-01-21T07:46:34 | 86,797,779 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package com.mackittipat.designpattern.behavioural.observer;
public class SubscriberA implements Observer {
@Override
public void update() {
System.out.println("A get updated");
}
}
| [
"[email protected]"
]
| |
0f845c2e661b157e8a43a74fe7a089115a178265 | 1c4546ef3e9b6cc3883a4ab2c42f87c16337f4df | /src/main/java/com/example/demo/services/ResultService.java | 94e40684110a7f0bc1f3a40146afc8d2da608a51 | []
| no_license | kungfupandahug/spring-backend | 1d42b99a533f1c23832acc226bf3a571e08f78a8 | 867f7a6343a75fc58a42f19d7353e5fe6108c67e | refs/heads/master | 2020-09-04T09:28:56.666546 | 2019-10-30T16:50:55 | 2019-10-30T16:50:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,244 | java | package com.example.demo.services;
import com.example.demo.dtos.ResultDTO;
import com.example.demo.exceptions.ElementNotFoundException;
import com.example.demo.models.MatchModel;
import com.example.demo.models.ResultModel;
import com.example.demo.models.TeamModel;
import com.example.demo.repositories.ResultRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class ResultService {
@Autowired
ResultRepository resultRepository;
@Autowired MatchService matchService;
@Autowired TeamService teamService;
public ResultModel save(ResultModel resultModel) {
return resultRepository.save(resultModel);
}
private ResultModel convert(ResultDTO input) {
Optional<MatchModel> match = matchService.findById(input.getMatchId());
Optional<TeamModel> team = teamService.findById(input.getTeamId());
if ( !match.isPresent() || !team.isPresent() )
throw new ElementNotFoundException("Could not locate one or several IDs in database");
return new ResultModel(match.get(), team.get(), input.getScore(), input.getResult());
}
public ResultModel create(ResultDTO input) throws ElementNotFoundException {
ResultModel converted = convert(input);
return save(converted);
}
public ResultModel update(Integer id, ResultDTO input) throws ElementNotFoundException {
findById(id).orElseThrow(() -> new ElementNotFoundException("Could not find result with ID=" + id));
ResultModel updatedResult = convert(input);
updatedResult.setMatchId(id);
return save(updatedResult);
}
public Optional<ResultModel> findById(Integer id) {
return resultRepository.findById(id);
}
public List<ResultModel> findAll() {
return resultRepository.findAll();
}
public ResultModel deleteById(Integer id) throws ElementNotFoundException {
ResultModel result = findById(id)
.orElseThrow(() -> new ElementNotFoundException("Could not find result with ID=" + id));
resultRepository.deleteById(id);
return result;
}
}
| [
"[email protected]"
]
| |
bb1bd1e61225d3e67a1684f27a6fab02445a0bdf | bdb5c9daee0a8ec4b7ff2b94f96aa6bf9b3fe413 | /backEnd/src/main/java/com/desafio/backEnd/controller/form/ProdutoForm.java | 9b8d7d9bb5be842b96f8d1ccbae24fa4cf835068 | []
| no_license | ThiagoEllera/notas | 2416d710c7d70b5e1f549de37a9503d8e7c141c5 | 29bc9901a7f8de0b02fd28649a057e8839a96a80 | refs/heads/main | 2023-07-28T11:26:41.634776 | 2021-09-03T13:18:24 | 2021-09-03T13:18:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,178 | java | package com.desafio.backEnd.controller.form;
import com.desafio.backEnd.modelo.Produto;
import com.desafio.backEnd.repository.ProdutoRepository;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
public class ProdutoForm {
@NotNull
@NotEmpty
private String codigo;
@NotNull
@NotEmpty
private String descricao;
@NotNull
private BigDecimal valor;
public String getCodigo() {
return codigo;
}
public String getDescricao() {
return descricao;
}
public BigDecimal getValor() {
return valor;
}
public Produto converter() {
return new Produto(codigo, descricao, valor);
}
public Produto atualizar(Integer id, ProdutoRepository produtoRepository) {
Produto produto = produtoRepository.getById(id);
produto.setCodigo((this.codigo != null) ? this.codigo : produto.getCodigo());
produto.setDescricao((this.descricao != null) ? this.descricao : produto.getDescricao());
produto.setValor((this.valor != null) ? this.valor : produto.getValor());
return produto;
}
}
| [
"[email protected]"
]
| |
ce3f6d4abfbd558bc3924299ae112f4b36f1556c | 1ffce8c0ab5c342d241badb2b188351b92739ab5 | /rest-client-demo/src/com/dg/examples/restclientdemo/communication/requests/CustomHandlersRequest.java | d73024cbf733ae14879b36004a3e2fc8326f2451 | []
| no_license | sondt87/android-rest-client | 438806a6c4cb3a58e2bce929569b043640d721df | 009ab6022cbde9446c9ea4f1ac29bbcd2fd6d835 | refs/heads/master | 2020-04-06T06:36:55.374445 | 2014-03-25T12:58:28 | 2014-03-25T12:58:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,639 | java | package com.dg.examples.restclientdemo.communication.requests;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import com.araneaapps.android.libs.asyncrunners.enums.DownloadPriority;
import com.araneaapps.android.libs.asyncrunners.models.RequestOptions;
import com.dg.libs.rest.callbacks.HttpCallback;
import com.dg.libs.rest.client.BaseRestClient;
import com.dg.libs.rest.domain.ResponseStatus;
import com.dg.libs.rest.handlers.UIThreadResponseHandler;
import com.dg.libs.rest.parsers.HttpResponseParser;
import com.dg.libs.rest.requests.ParameterHttpRequestImpl;
import java.io.InputStream;
public class CustomHandlersRequest extends ParameterHttpRequestImpl<Void> {
private final CustomHandlersRequest.CustomUIHandler handler;
private VoidHttpCallback callback;
public static CustomHandlersRequest createInstance(Context c) {
CustomHandlersRequest customHandlersRequest = new CustomHandlersRequest(c,
new VoidHttpResponseParser(),
new VoidHttpCallback());
return customHandlersRequest;
}
public CustomHandlersRequest(Context context, VoidHttpResponseParser parser,
VoidHttpCallback callback) {
super(context, BaseRestClient.RequestMethod.GET, parser, callback);
this.callback = callback;
handler = new CustomUIHandler(callback);
setResponseHandler(handler);
// You can add custom request options for specific request. there is a queue running the requests so new requests coming in
// will be sorted and executed according to priority if needed.
// ex. you queue 50 downloads but you want the app to still run API get requests without waiting for everything else to finish first.
RequestOptions requestOptions = new RequestOptions.RequestOptionsBuilder()
.setPriority(DownloadPriority.HIGH)
.setRunInSingleThread(true).build();
setRequestOptions(requestOptions);
}
@Override
protected boolean handleResponseStatus(final ResponseStatus status) {
// This method will also run in the background thread. Returning true means you have handled the request and this will be
// the last piece of code which will be executed.
// False means the execution will continue with the parser and then success if the request is parsed successfully.
if (status.getStatusCode() == 204) {
callback.onCustomResult(status);// careful this runs in Background thread.
// Or to run in UI thread:
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
@Override
public void run() {
callback.onCustomResult(status); // This will run in UI thread.
}
});
// Alternatively:
CustomHandlersRequest.this.handler.handleCustom(status);
// will also run in UI thread but needs extra logic to implement as opposed to the code above. Cleaner but a bit more complex.
return true;
} else {
return super.handleResponseStatus(status);
}
}
private class CustomUIHandler extends UIThreadResponseHandler<Void> {
private VoidHttpCallback callback;
public CustomUIHandler(VoidHttpCallback callback) {
super(callback);
this.callback = callback;
}
public void handleCustom(final ResponseStatus status) {
handler.post(new Runnable() {
@Override
public void run() {
callback.onCustomResult(status); // This will run in UI thread.
}
});
}
}
@Override
protected void doAfterRunRequestInBackgroundThread() {
// this will run in after the request completes in background.
super.doAfterRunRequestInBackgroundThread();
}
@Override
protected void doBeforeRunRequestInBackgroundThread() {
// this will run before the request runs. here you can query databases, add parameters or headers in the request background thread.
// So there is no need to do async tasks or similar stuff to fetch parameters before executing a request if needed.
super.doBeforeRunRequestInBackgroundThread();
}
@Override
protected String getUrl() {
return "http://some-dummy-url.com";
}
private static class VoidHttpResponseParser implements HttpResponseParser<Void> {
@Override
public Void parse(InputStream instream) throws Exception {
return null;
}
}
private static class VoidHttpCallback implements HttpCallback<Void> {
@Override
public void onSuccess(Void responseData) {
}
@Override
public void onHttpError(ResponseStatus responseCode) {
}
public void onCustomResult(ResponseStatus status) {
}
}
}
| [
"[email protected]"
]
| |
23b08b00efaf50b2254252fe5eb78a248b8522cc | 6dbe38fa197104d0e8e1164fa05921f823aa8fd3 | /portal/src/main/java/com/springinpractice/ch13/portal/formatter/LinkFormatter.java | a143f3103251c971708bfa4fd71cff1b2c8ee173 | []
| no_license | bbaron/sip13-new | e273d64af876a93800f39809a9db9a9ec6c27a9f | 0219e6b8b1c143fe34f17e4638c5e3b005d0c2b7 | refs/heads/master | 2020-12-25T07:58:36.751370 | 2012-12-28T20:44:52 | 2012-12-28T20:44:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 801 | java | package com.springinpractice.ch13.portal.formatter;
import java.text.ParseException;
import java.util.Locale;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.format.Formatter;
import org.springframework.hateoas.Link;
import org.springframework.stereotype.Component;
/**
* @author Willie Wheeler ([email protected])
*/
@Component
public class LinkFormatter implements Formatter<Link> {
private static final Logger log = LoggerFactory.getLogger(LinkFormatter.class);
@Override
public String print(Link link, Locale locale) {
log.debug("Printing Link: {}", link);
return link.getHref();
}
@Override
public Link parse(String href, Locale locale) throws ParseException {
log.debug("Parsing Link: href={}", href);
return new Link(href);
}
}
| [
"[email protected]"
]
| |
2e2826747ad2b777801062ce3c72822837e084ae | fc0f74a8eee91319f51ab29d9a72d2082cf7d599 | /src/java/Activos/Controllers/Controller_Funcionario.java | d8caa0727501c877cbf29ef6a04930d4eac980b7 | []
| no_license | Dhanw/Gestor_Activos | 145c2d512e7dad14e064550b58f5df9d601b892e | 4e9915cf6f1295d8f8206855fab6a560d052c104 | refs/heads/master | 2020-05-01T14:23:42.773404 | 2019-05-28T19:20:50 | 2019-05-28T19:20:50 | 177,518,906 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,075 | 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 Activos.Controllers;
import Activos.Logic.Dependencia;
import Activos.Logic.Funcionario;
import Activos.Logic.Model;
import Activos.Logic.Puesto;
import Activos.Logic.Usuario;
import Activos.Models.Model_Funcionario;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author jorac
*/
@WebServlet(name = "Controller_Funcionario", urlPatterns = {"/Funcionario/Funcionario_listar", "/Funcionario/Funcionario_Crear", "/Funcionario/Agregar_Funcionario",
"/Funcionario/Funcionario_eliminar", "/Funcionario/Filtro_Funcionario_Nombre", "/Funcionario/Funcionario_editar", "/Funcionario/Editar_Funcionario"})
public class Controller_Funcionario extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
switch (request.getServletPath()) {
case "/Funcionario/Funcionario_listar": {
try {
this.prepareListado(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case "/Funcionario/Funcionario_Crear": {
try {
this.prepareCrear(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case "/Funcionario/Agregar_Funcionario": {
try {
this.agregar(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case "/Funcionario/Funcionario_eliminar": {
try {
this.eliminar(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
case "/Funcionario/Filtro_Funcionario_Nombre": {
try {
this.filtroNombre(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case "/Funcionario/Funcionario_editar": {
try {
this.prepare_editar(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
case "/Funcionario/Editar_Funcionario": {
try {
this.editar(request, response);
} catch (Exception ex) {
Logger.getLogger(Controller_Funcionario.class.getName()).log(Level.SEVERE, null, ex);
}
}
break;
default:
break;
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
private void prepareListado(HttpServletRequest request, HttpServletResponse response) throws Exception {
List<Model_Funcionario> funcionarios = new ArrayList<>();
Usuario use = (Usuario) request.getSession().getAttribute("user");
Dependencia dep = Model.instance().getDependencia_fromFuncionarioV2(use.getFuncionario().getID());
List<Funcionario> todos = Model.instance().getFuncionarios();
Model_Funcionario tmp = null;
for (Funcionario f : todos) {
Puesto puesto = Model.instance().getPuestoFromFuncionario(f.getID());
if (puesto != null) {
tmp = new Model_Funcionario(f.getID(), f.getNombre(), f.getIdentificacion(), puesto);
} else {
tmp = new Model_Funcionario(f.getID(), f.getNombre(), f.getIdentificacion(), null);
}
funcionarios.add(tmp);
}
request.setAttribute("funcionarios", funcionarios);
request.setAttribute("dependencia", dep);
request.getRequestDispatcher("/Funcionario/Funcionario_Listado.jsp").forward(request, response);
}
private void prepareCrear(HttpServletRequest request, HttpServletResponse response) throws Exception {
Usuario use = (Usuario) request.getSession().getAttribute("user");
Dependencia dep = Model.instance().getDependencia_fromFuncionarioV2(use.getFuncionario().getID());
List<Puesto> puestos = Model.instance().getPuestosDisponibles();
request.setAttribute("puestos", puestos);
request.setAttribute("dependencia", dep);
request.getRequestDispatcher("/Funcionario/Funcionario_Edicion.jsp").forward(request, response);
}
private void agregar(HttpServletRequest request, HttpServletResponse response) throws Exception {
Usuario use = (Usuario) request.getSession().getAttribute("user");
Dependencia dep = Model.instance().getDependencia_fromFuncionarioV2(use.getFuncionario().getID());
String cedula = request.getParameter("cedula");
String nombre = request.getParameter("nombre");
int p = Integer.parseInt(request.getParameter("puesto"));
Funcionario fun = new Funcionario(cedula, nombre);
//Agregamos el funcionario
Model.instance().addFuncionario(fun);
Puesto puesto = null;
//Lo contratamos en caso de que el puesto no sea 0
if (p != 0) {
puesto = Model.instance().getPuesto(p);
Model.instance().contratar(fun, puesto);
}
request.getRequestDispatcher("/Funcionario/Funcionario_listar").forward(request, response);
}
private void eliminar(HttpServletRequest request, HttpServletResponse response) throws Exception {
int id = Integer.parseInt(request.getParameter("ID"));
Funcionario fun = Model.instance().getFuncionario(id);
Puesto p = Model.instance().getPuestoFromFuncionario(fun.getID());
boolean b;
if (p == null) {
b = false;
} else {
b = true;
}
Model.instance().descontratar(fun, b);
request.getRequestDispatcher("/Funcionario/Funcionario_listar").forward(request, response);
}
private void filtroNombre(HttpServletRequest request, HttpServletResponse response) throws Exception {
String filtro = request.getParameter("nombre");
List<Model_Funcionario> funcionarios = new ArrayList<>();
Usuario use = (Usuario) request.getSession().getAttribute("user");
Dependencia dep = Model.instance().getDependencia_fromFuncionarioV2(use.getFuncionario().getID());
List<Funcionario> todos = Model.instance().getFuncionarios();
Model_Funcionario tmp = null;
for (Funcionario f : todos) {
Puesto puesto = Model.instance().getPuestoFromFuncionario(f.getID());
String a = f.getNombre().toUpperCase();
String b = filtro.toUpperCase();
if (a.matches(".*" + b + ".*")) {
if (puesto != null) {
tmp = new Model_Funcionario(f.getID(), f.getNombre(), f.getIdentificacion(), puesto);
} else {
tmp = new Model_Funcionario(f.getID(), f.getNombre(), f.getIdentificacion(), null);
}
funcionarios.add(tmp);
}
}
request.setAttribute("funcionarios", funcionarios);
request.setAttribute("dependencia", dep);
request.getRequestDispatcher("/Funcionario/Funcionario_Listado.jsp").forward(request, response);
}
private void prepare_editar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception {
String ID = (request.getParameter("ID"));
String cedula = request.getParameter("cedula");
String nombre = request.getParameter("nombre");
Puesto puesto = Model.instance().getPuesto(Integer.parseInt(request.getParameter("PID")));
request.setAttribute("cedula", cedula);
request.setAttribute("ID", ID);
request.setAttribute("nombre", nombre);
request.setAttribute("puesto", puesto);
List<Puesto> puestos = Model.instance().getPuestosDisponibles();
request.setAttribute("puestos", puestos);
request.getRequestDispatcher("/Funcionario/Funcionario_Mostrar.jsp").forward(request, response);
}
private void editar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException, Exception {
int IDf = Integer.parseInt(request.getParameter("ID"));
Funcionario fun = Model.instance().getFuncionario(IDf);
String nombre = request.getParameter("nombre");
Puesto p = Model.instance().getPuestoFromFuncionario(IDf);
Puesto puesto = Model.instance().getPuesto(Integer.parseInt(request.getParameter("puesto")));
Model.instance().updateFuncionarioNombre(fun, nombre);
if(p!=null && puesto!= null){
if(!(p.getID() == puesto.getID())){
Model.instance().updateFuncionarioPuesto(fun, puesto, p);
}
}
else{
Model.instance().updateFuncionarioPuesto(fun, puesto, p);
}
request.getRequestDispatcher("/Funcionario/Funcionario_listar").forward(request, response);
}
}
| [
"[email protected]"
]
| |
1e1b6a1693e8fc475acf57a983fcc006773303f8 | 1242e105b7c8d8ad9e4de3d6c1821bf8025aa949 | /src/com/fedex/ship/stub/OperationalInstruction.java | c8b99131fca7ed933be116071bb5f70ea99f903e | []
| no_license | 578608614/quiship | 550815f7b681b36c6ff50173ee1c3c01f97547ed | 7442ef28a9058865c6fb3e0c5ab6845f09b4aa2c | refs/heads/master | 2021-01-13T00:38:29.515687 | 2015-10-30T03:10:30 | 2015-10-30T03:10:30 | 45,223,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,282 | java | /**
* OperationalInstruction.java
*
* This file was auto-generated from WSDL
* by the Apache Axis 1.4 Apr 22, 2006 (06:55:48 PDT) WSDL2Java emitter.
*/
package com.fedex.ship.stub;
public class OperationalInstruction implements java.io.Serializable {
/* Position of operational instruction element. */
private java.lang.Integer number;
/* Content corresponding to the operational instruction. */
private java.lang.String content;
public OperationalInstruction() {
}
public OperationalInstruction(
java.lang.Integer number,
java.lang.String content) {
this.number = number;
this.content = content;
}
/**
* Gets the number value for this OperationalInstruction.
*
* @return number * Position of operational instruction element.
*/
public java.lang.Integer getNumber() {
return number;
}
/**
* Sets the number value for this OperationalInstruction.
*
* @param number * Position of operational instruction element.
*/
public void setNumber(java.lang.Integer number) {
this.number = number;
}
/**
* Gets the content value for this OperationalInstruction.
*
* @return content * Content corresponding to the operational instruction.
*/
public java.lang.String getContent() {
return content;
}
/**
* Sets the content value for this OperationalInstruction.
*
* @param content * Content corresponding to the operational instruction.
*/
public void setContent(java.lang.String content) {
this.content = content;
}
private java.lang.Object __equalsCalc = null;
public synchronized boolean equals(java.lang.Object obj) {
if (!(obj instanceof OperationalInstruction)) return false;
OperationalInstruction other = (OperationalInstruction) obj;
if (obj == null) return false;
if (this == obj) return true;
if (__equalsCalc != null) {
return (__equalsCalc == obj);
}
__equalsCalc = obj;
boolean _equals;
_equals = true &&
((this.number==null && other.getNumber()==null) ||
(this.number!=null &&
this.number.equals(other.getNumber()))) &&
((this.content==null && other.getContent()==null) ||
(this.content!=null &&
this.content.equals(other.getContent())));
__equalsCalc = null;
return _equals;
}
private boolean __hashCodeCalc = false;
public synchronized int hashCode() {
if (__hashCodeCalc) {
return 0;
}
__hashCodeCalc = true;
int _hashCode = 1;
if (getNumber() != null) {
_hashCode += getNumber().hashCode();
}
if (getContent() != null) {
_hashCode += getContent().hashCode();
}
__hashCodeCalc = false;
return _hashCode;
}
// Type metadata
private static org.apache.axis.description.TypeDesc typeDesc =
new org.apache.axis.description.TypeDesc(OperationalInstruction.class, true);
static {
typeDesc.setXmlType(new javax.xml.namespace.QName("http://fedex.com/ws/ship/v15", "OperationalInstruction"));
org.apache.axis.description.ElementDesc elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("number");
elemField.setXmlName(new javax.xml.namespace.QName("http://fedex.com/ws/ship/v15", "Number"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "int"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
elemField = new org.apache.axis.description.ElementDesc();
elemField.setFieldName("content");
elemField.setXmlName(new javax.xml.namespace.QName("http://fedex.com/ws/ship/v15", "Content"));
elemField.setXmlType(new javax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema", "string"));
elemField.setMinOccurs(0);
elemField.setNillable(false);
typeDesc.addFieldDesc(elemField);
}
/**
* Return type metadata object
*/
public static org.apache.axis.description.TypeDesc getTypeDesc() {
return typeDesc;
}
/**
* Get Custom Serializer
*/
public static org.apache.axis.encoding.Serializer getSerializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanSerializer(
_javaType, _xmlType, typeDesc);
}
/**
* Get Custom Deserializer
*/
public static org.apache.axis.encoding.Deserializer getDeserializer(
java.lang.String mechType,
java.lang.Class _javaType,
javax.xml.namespace.QName _xmlType) {
return
new org.apache.axis.encoding.ser.BeanDeserializer(
_javaType, _xmlType, typeDesc);
}
}
| [
"qq123456"
]
| qq123456 |
36952119fd4c68c698bf0dad1856180980671315 | fbb451429d7c4bace20f1d1c6ae4123526784491 | /D2D/Server/WebService/src/com/ca/arcflash/ha/utils/VMwareUploadManager.java | 2e49c31d0ae3868b488c01af7b40d62538d29015 | []
| no_license | cliicy/autoupdate | 93ffb71feb958ff08915327b2ea8eec356918286 | 8da1c549847b64a9ea00452bbc97c16621005b4f | refs/heads/master | 2021-01-24T08:11:26.676542 | 2018-02-26T13:33:29 | 2018-02-26T13:33:29 | 122,970,736 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,503 | java | package com.ca.arcflash.ha.utils;
import java.io.InputStream;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.log4j.Logger;
import com.ca.arcflash.ha.vmwaremanagerIntf.CAVMDetails;
import com.ca.arcflash.ha.vmwaremanagerIntf.CAVirtualInfrastructureManager;
import com.ca.arcflash.jobscript.replication.RepJobMonitor;
import com.ca.arcflash.webservice.service.CommonService;
public class VMwareUploadManager {
private static Logger logger = Logger.getLogger(VMwareUploadManager.class);
public static boolean uploadToStorage(HARetryStrategy strategy,
CAVirtualInfrastructureManager vmwareManager,
CAVMDetails vmDetails, Map<String, String> fileUris, String afguid) {
RepJobMonitor jobMonitor = CommonService.getInstance().getRepJobMonitorInternal(afguid);
Iterator<String> iter = fileUris.keySet().iterator();
while (iter.hasNext()) {
String key = iter.next();
String value = fileUris.get(key);
for (int i = 0; i < strategy.getTimes(); ++i) {
try {
if (vmwareManager.putVMConfig(vmDetails.getVmName(),
vmDetails.getUuid(), value, key)) {
iter.remove();
break;
}
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
synchronized (jobMonitor) {
if (jobMonitor.isCurrentJobCancelled())
return false;
}
try {
Thread.sleep(strategy.getInterval() * 1000);
} catch (InterruptedException e) {
logger.error(e.getMessage(), e);
}
}
}
return fileUris.size() == 0;
}
public static boolean deleteFromStorage(HARetryStrategy strategy,
CAVirtualInfrastructureManager vmwareManager,
CAVMDetails vmDetails,List<String> fileNames){
boolean isDeleted =false;
InputStream in = null;
for (String name : fileNames) {
for (int i = 0; i < strategy.getTimes(); i++) {
try {
in = vmwareManager.getVMConfig(vmDetails.getVmName(), vmDetails.getUuid(), name);
if(in != null){
try {
in.close();
}catch(Exception e) {}
isDeleted = vmwareManager.deleteVMConfig(vmDetails.getVmName(), vmDetails.getUuid(), name);
if(isDeleted)
break;
}else { // A null 'in' means the file doesn't exist, to retry more times is meaningless.
break;
}
} catch (Exception e) {
}
try {
Thread.sleep(strategy.getInterval() * 1000);
} catch (InterruptedException e) {
}
}
}
return isDeleted;
}
}
| [
"[email protected]"
]
| |
a094c2286e7091cd5b1508f291d126f1fb65b05f | c4a09a6615a94cb8ee80972351aa6560d2e7ba05 | /KeepNote7/NoteService/src/main/java/com/stackroute/keepnote/model/NoteUser.java | b4620dedc9c53828bb31af22f9b1d16caefd6a18 | []
| no_license | ArChAnAs123/springkeepnote | 9937ddff578b024034276a55270b0864ba186d83 | d4d2a61324ee98a17c109b755b665d119116fa78 | refs/heads/master | 2023-08-05T23:50:26.492146 | 2021-09-24T09:14:49 | 2021-09-24T09:14:49 | 409,239,475 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,045 | java | package com.stackroute.keepnote.model;
import java.util.List;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.mongodb.core.mapping.Document;
/*
* Please note that this class is annotated with @Document annotation
* @Document identifies a domain object to be persisted to MongoDB.
* */
@Document
public class NoteUser {
/*
* This class should have two fields (userId, notes).Out of these two fields,
* the field userId should be annotated with @Id. This class should also contain
* the getters and setters for the fields.
*/
@Transient
public final static String SEQ_NAME = "user_seq";
@Id
private String userId;
private List<Note> notes;
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public List<Note> getNotes() {
return notes;
}
public void setNotes(List<Note> notes) {
this.notes = notes;
}
} | [
"[email protected]"
]
| |
0412f93057d9201193b3ddc5c293f4c57c3578c4 | ebce863e8ce04a4be8fa10be80235d291588aae7 | /app/src/main/java/com/codencode/chitchat/StatusActivity.java | 7e8f5511f9fd033ddadff40fb4d1e3d151a4398e | []
| no_license | Code-N-Code/ChitChat | 767e647d497778f7ad58569c0205db8824200094 | 8a268ba103cabfc3bbf485f0c7caf38c8e9d7818 | refs/heads/master | 2020-06-18T21:18:39.255226 | 2019-07-11T19:15:07 | 2019-07-11T19:15:07 | 196,452,063 | 6 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,009 | java | package com.codencode.chitchat;
import android.app.ProgressDialog;
import android.support.annotation.NonNull;
import android.support.design.widget.TextInputLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class StatusActivity extends AppCompatActivity {
Toolbar mToolbar;
Button statusUpdateButton;
TextInputLayout inputLayout;
DatabaseReference mRef;
ProgressDialog mProgressDialog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_status);
//Firebse
String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
mRef = FirebaseDatabase.getInstance().getReference().child("Users").child(uid);
//Toolbar section
mToolbar = findViewById(R.id.status_appbar);
setSupportActionBar(mToolbar);
getSupportActionBar().setTitle("Set Status");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
//TextInputLayout and Status fetch area
inputLayout = findViewById(R.id.status_input_text);
inputLayout.getEditText().setText(getIntent().getStringExtra("status_value"));
//Status update button and update function
statusUpdateButton = findViewById(R.id.status_update_btn);
statusUpdateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mProgressDialog = new ProgressDialog(StatusActivity.this);
mProgressDialog.setTitle("Updating Status...");
mProgressDialog.setCanceledOnTouchOutside(false);
mProgressDialog.show();
final String status = inputLayout.getEditText().getText().toString();
mRef.child("status").setValue(status).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if(task.isSuccessful())
{
mProgressDialog.dismiss();
Toast.makeText(StatusActivity.this, "Status Changed Successfully", Toast.LENGTH_SHORT).show();
}
else
{
Toast.makeText(StatusActivity.this, "Something went wrong , try again!", Toast.LENGTH_SHORT).show();
}
}
});
}
});
}
}
| [
"[email protected]"
]
| |
ea3c57815b835f7bde6539e6111fafaad6d59829 | 2bb3f50095442292fd5c26e04cb36bd65edeb9a1 | /src/test/java/com/infotech/isg/it/MTNIT.java | bf6e6825fa71dbab4de382f27ceaa7aa37cb4a0d | []
| no_license | sevak-gh/isgws | 1810343bacc1f931c4f146c498d2dcbf45449af0 | 9f52383b4afbd634d46bcdf78b76265a03a2f25e | refs/heads/master | 2021-04-12T04:43:52.376532 | 2018-02-19T07:51:47 | 2018-02-19T07:51:47 | 27,213,696 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 132,227 | java | package com.infotech.com.it;
import com.infotech.isg.domain.BankCodes;
import com.infotech.isg.domain.Transaction;
import com.infotech.isg.repository.TransactionRepository;
import com.infotech.isg.validation.ErrorCodes;
import com.infotech.isg.service.ISGServiceResponse;
import com.infotech.isg.proxy.mtn.MTNProxy;
import com.infotech.isg.proxy.mtn.MTNProxyResponse;
import com.infotech.isg.it.fake.mtn.MTNWSFake;
import com.infotech.isg.it.wsclient.ISGClient;
import javax.sql.DataSource;
import java.util.List;
import java.util.ArrayList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.jdbc.JdbcTestUtils;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.AfterMethod;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.anything;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.greaterThan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* integration test for MTN service
*
* @author Sevak Gahribian
*/
@ContextConfiguration(locations = { "classpath:spring/applicationContext.xml" })
public class MTNIT extends AbstractTestNGSpringContextTests {
private static final Logger LOG = LoggerFactory.getLogger(MTNIT.class);
private JdbcTemplate jdbcTemplate;
@Autowired
private DataSource dataSource;
@Autowired
private TransactionRepository transactionRepo;
// fake mci web service
// defined as spring managed bean so that app properties can be used
@Autowired
MTNWSFake mtnws;
// isg web service client
// defined as spring managed bean so that app properties can be used
@Autowired
ISGClient wsclient;
@BeforeMethod
public void initDB() {
jdbcTemplate = new JdbcTemplate(dataSource);
JdbcTestUtils.deleteFromTables(jdbcTemplate, "info_topup_transactions",
"info_topup_operators",
"info_topup_payment_channel",
"info_topup_clients",
"info_topup_client_ips");
jdbcTemplate.update("insert into info_topup_operators values(1,'MTN','active'), (2,'MCI','active'), (3,'Jiring','active')");
jdbcTemplate.update("insert into info_topup_payment_channel values(59,'Y'), (14,'Y'), (5,'Y')");
// add client: username=root, password=123456, active='Y', ips: 127.0.0.1, 172.16.14.15
jdbcTemplate.update("insert into info_topup_clients(id,client,pin,name,contact,tel,vendor,created,active) values(1, 'root', "
+ "'ba3253876aed6bc22d4a6ff53d8406c6ad864195ed144ab5c87621b6c233b548baeae6956df346"
+ "ec8c17f5ea10f35ee3cbc514797ed7ddd3145464e2a0bab413'"
+ ", 'name', 'contact', 'tel', 'vendor', '2014-01-01 13:05:23','Y')");
jdbcTemplate.update("insert into info_topup_client_ips values(1,'127.0.0.1'), (1, '172.16.14.15')");
}
@AfterMethod
public void tearDown() {
mtnws.stop();
}
@Test
public void HappyPathShouldSucceedForTOPUP() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileID, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForTOPUPWithInfotechVendor() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileID, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
String customerName = "INFOTECH";
String vendor = "infotech";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp, customerName, vendor);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
assertThat(transaction.getVendor(), is(vendor));
}
@Test
public void HappyPathShouldSucceedForTOPUPWithThirdPartyVendor() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileID, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
String customerName = "INFOTECH";
String vendor = "mtn";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp, customerName, vendor);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
assertThat(transaction.getVendor(), is(vendor));
}
@Test
public void HappyPathShouldSucceedForWOW() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "wow";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForPayBill() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "pay-bill";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForBulk() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "bulk";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForPreWimax() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "pre-wimax";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForPostWimax() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "post-wimax";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForGPRS() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "gprs";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void HappyPathShouldSucceedForGPRSCombo() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "gprs-47";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is(mtnTransactionId));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void shouldReturnInvalidUsernamePassword() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "root"; // invalid password
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.INVALID_USERNAME_OR_PASSWORD));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(0));
}
@Test
public void shouldReturnInvalidCellNumber() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "077856698"; // invalid cell number
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.INVALID_CELL_NUMBER));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(0));
}
@Test
public void shouldReturnInvalidPaymentChannel() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 54; // invalid channel
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.INVALID_PAYMENT_CHANNEL));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(0));
}
@Test
public void shouldReturnNOKWhenOperationNotSucceed() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge not done";
String mtnCommandStatus = "NOK";
String mtnResultCode = "2"; // any non-zero positive number means NOK
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_RESPONSE_NOK));
assertThat(response.getOPRDoc(), is(mtnResultCode));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_RESPONSE_NOK));
assertThat(transaction.getToken(), is(nullValue()));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void shouldReturnNotReverseAndSetSTFWhenEndpointNotAvailable() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
throw new RuntimeException("something unpredictable happened!!!");
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(response.getOPRDoc(), is(anything()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getStf(), is(1));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnNotReverseAndSetSTFWhenResultUnknown() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(response.getOPRDoc(), is(anything()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getStf(), is(1));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnNotReverseWhenAlreadySetSTFButNotResolvedYet() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(response.getOPRDoc(), is(anything()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getStf(), is(1));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnNOKWhenAlreadySetSTFAndResolvedToFailed() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assuming STF resolved to failed
jdbcTemplate.update("update info_topup_transactions set stf=3");
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_RESPONSE_NOK));
assertThat(response.getOPRDoc(), is(anything()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getStf(), is(3));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnNOKWhenAlreadySetSTFAndResolvedToSuccessful() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assuming STF resolved to failed
jdbcTemplate.update("update info_topup_transactions set stf=2, oprresponse='done', oprtid=123654");
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("OK"));
assertThat(response.getISGDoc(), is(greaterThan(0L))); // TR ID, any positive number
assertThat(response.getOPRDoc(), is("123654")); // operator response detail
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE)); // this is because first attempt that failed
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getOperatorResponse(), is("done"));
assertThat(transaction.getOperatorTId(), is("123654"));
assertThat(transaction.getStf(), is(2));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnNOtReverseWhenAlreadySetSTFAndResolvedValueInvalid() {
// arrange
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
return null;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
return null;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assuming STF resolved to failed
jdbcTemplate.update("update info_topup_transactions set stf=-1");
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(response.getOPRDoc(), is(anything()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_ERROR_DONOT_REVERSE));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode(), is(not(0)));
assertThat(transaction.getStf(), is(1));
assertThat(transaction.getStfResult(), is(0));
}
@Test
public void shouldReturnRepetitiveTransactionWhenTheSameTransactionAlreadySuccesseeded() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.REPETITIVE_TRANSACTION));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getToken(), is(nullValue()));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void shouldReturnRepetitiveTransactionWhenTheSameTransactionAlreadyFailed() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge not done";
String mtnCommandStatus = "NOK";
String mtnResultCode = "2";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "mtnrcpt";
String orderId = "orderid";
String consumer = "09385067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.REPETITIVE_TRANSACTION));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(ErrorCodes.OPERATOR_SERVICE_RESPONSE_NOK));
assertThat(transaction.getToken(), is(nullValue()));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
@Test
public void shouldReturnDoubleSpendingTransactionWhenATransactionWithSameRrnAndBankCodeAndClientAlreadyRegistered() {
// arrange
String mtnTransactionId = "1111";
String mtnOrigResponseMessage = "recharge done";
String mtnCommandStatus = "OK";
String mtnResultCode = "0";
MTNProxy mtnService = new MTNProxy() {
@Override
public MTNProxyResponse recharge(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse billPayment(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse bulkTransfer(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse wow(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse postPaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse prePaidWimax(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprs(String consumer, int amount, long trId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse gprsCombo(String consumer, int amount, long trId, int profileId, String channel) {
MTNProxyResponse response = new MTNProxyResponse();
response.setTransactionId(mtnTransactionId);
response.setOrigResponseMessage(mtnOrigResponseMessage);
response.setCommandStatus(mtnCommandStatus);
response.setResultCode(mtnResultCode);
return response;
}
@Override
public MTNProxyResponse verify(long trId) {
throw new UnsupportedOperationException("verify not supported");
}
@Override
public MTNProxyResponse getBalance() {
throw new UnsupportedOperationException("balance not supported");
}
};
mtnws.setServiceImpl(mtnService);
mtnws.publish();
String username = "root";
String password = "123456";
String action = "top-up";
int clientId = 1;
String bankCode = BankCodes.SAMAN;
int amount = 10000;
int channel = 59;
String state = "state";
String bankReceipt = "jirrcpt";
String orderId = "orderid";
String consumer = "09365067064";
String customerIp = "10.20.120.30";
String remoteIp = "1.1.1.1";
// act
// first attempt
ISGServiceResponse response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// changing one or more params excluding bankreceipt,bankcode,client(username,password)
orderId += "123";
// second attempt
response = wsclient.mtn(username, password, action,
bankCode, amount,
channel, state, bankReceipt, orderId,
consumer, customerIp);
// assert
assertThat(response, is(notNullValue()));
assertThat(response.getStatus(), is("ERROR"));
assertThat(response.getISGDoc(), is((long)ErrorCodes.DOUBLE_SPENDING_TRANSACTION));
assertThat(response.getOPRDoc(), is(nullValue()));
List<Transaction> transactions = transactionRepo.findByRefNumBankCodeClientId(bankReceipt, BankCodes.SAMAN, clientId);
assertThat(transactions, is(notNullValue()));
assertThat(transactions.size(), is(1));
Transaction transaction = transactions.get(0);
assertThat(transaction.getRefNum(), is(bankReceipt));
assertThat(transaction.getStatus(), is(1));
assertThat(transaction.getToken(), is(nullValue()));
assertThat(transaction.getAmount(), is((long)amount));
assertThat(transaction.getConsumer(), is(consumer));
assertThat(transaction.getOperatorResponseCode().toString(), is(mtnResultCode));
assertThat(transaction.getOperatorResponse(), is(mtnOrigResponseMessage));
assertThat(transaction.getOperatorTId(), is(mtnTransactionId));
assertThat(transaction.getOperatorCommand(), is(mtnCommandStatus));
assertThat(transaction.getStf(), is(nullValue()));
}
}
| [
"[email protected]"
]
| |
eb81b89b097f9b0b56c011f3aa2104959b455f12 | ec0448c27754bed7bf616245ab44c7be2bc686dd | /JavaBrain/src/chap6/MusicCDInfo.java | 255b171ff70448066d1d1f53f5168ffe594cbcd7 | []
| no_license | rechido/kmove30 | 1d95116af70b0739081c65ee17b27cc8abbc874d | f4fdaa8acb9171509fec081c5315875c8f8b1964 | refs/heads/master | 2020-03-22T02:32:07.662708 | 2018-09-09T10:04:48 | 2018-09-09T10:04:48 | 139,376,108 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 333 | java | /**
* 2018. 5. 23. Dev. by D. A. Lee
*/
package chap6;
public class MusicCDInfo extends CDInfo {
String artist;
String musicname[];
public MusicCDInfo(String registerNo, String title, String artist, String[] musicname) {
super(registerNo, title);
this.artist = artist;
this.musicname = musicname;
}
}
| [
"[email protected]"
]
| |
b50347acffefe954294006f5a40facaddbb286a0 | 4de94326744b26b076ed5454418b3a04f56d9434 | /src/com/syntax/class15/Hw.java | ff3ec5cdea538dec5356acf640a70331857efc0f | []
| no_license | madeehaRana/javaBasics | 95542ec1c09b7bfdc780297c56ea97b55742a8b3 | 24308aba09accb73c0104d78dfc1b7e623b6e04f | refs/heads/master | 2022-12-07T02:53:00.610240 | 2020-08-29T15:50:50 | 2020-08-29T15:50:50 | 275,492,692 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,253 | java | package com.syntax.class15;
public class Hw {
public static void main(String[] args) {
//How would you reverse a String character by character?
String str="Reverse";
System.out.println("String character :"+str);
for(int i=str.length()-1; i>=0; i--) {
System.out.print(str.charAt(i));
}
System.out.println();
//How would you reverse a String word by word?
String wBw ="This Java class is driving me crazy";
String []arr= wBw.split(" ");
for(int i=arr.length-1; i>=0; i--) {
System.out.print(arr[i]+ " ");
}
System.out.println();
//How would you swap 2 strings without a temporary variable?
String str1="Good";
String str2="Day";
str1=str1.concat(str2);
str2=str1.concat(str2).replace(str2, "");
str1=str1.concat(str2).replace(str2, "");
System.out.println(str1);
System.out.println(str2);
System.out.println("How would you check if String is palindrome or not?");
String orWord="mom";
String rev="";
for(int i=orWord.length()-1; i>=0; i--) {
rev=rev+orWord.charAt(i);
}
if(orWord.equals(rev)) {
System.out.println(orWord+" The word is palindrome.");
}else {
System.out.println(orWord+" The word is not palindrome");
}
}
}
| [
"[email protected]"
]
| |
cbb497b8d7eacc9b878fe6cfd3f60171ec662ff9 | d4a466f3a171294bee36cfa24108ea47ae36b834 | /where-to-refuel-server/src/main/java/where/to/refuel/server/model/Brand.java | 6fe4d07bba1308f4786cfa9326bb0c791765573e | [
"MIT"
]
| permissive | webdude21/where-to-refuel | 8650713a2431d88aedf7cfba32eca33b80fc3576 | 205b018cd149947f54370120e68d05a44e7d07c2 | refs/heads/master | 2023-01-11T07:00:33.716685 | 2022-12-29T11:42:41 | 2022-12-29T11:48:54 | 181,197,289 | 2 | 0 | MIT | 2020-05-06T15:20:32 | 2019-04-13T16:15:37 | Java | UTF-8 | Java | false | false | 143 | java | package where.to.refuel.server.model;
import lombok.Value;
@Value(staticConstructor = "of")
public class Brand {
long id;
String name;
}
| [
"[email protected]"
]
| |
d06840c938ff121618f2f8353425938d62700eff | 1c20a99b60e0e1b501b6a7f54691dce123d5a11c | /innlevering_1/src/no/hvl/dat100/trinnSkatt.java | 3930f5582d7495c451362b769f6d5cb51deec365 | []
| no_license | JaranVasstveit/innlevering1 | ba01f5003a45bffc136d955bc31ec8e3308b8dcd | 7698fa55ec3772eea9646ccd56b5efc755782102 | refs/heads/master | 2022-12-13T21:37:57.779210 | 2020-09-08T10:35:47 | 2020-09-08T10:35:47 | 293,575,715 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 772 | java | package no.hvl.dat100;
import static javax.swing.JOptionPane.*;
public class trinnSkatt {
public static void main(String[] args) {
String skatt = showInputDialog("skriv inn din lonn");
double lonn = Integer.parseInt(skatt);
double t1 = lonn * 0.93;
double t2 = lonn * 2.41;
double t3 = lonn * 11.52;
double t4 = lonn * 14.52;
if (lonn < 164100) {
System.out.println("ingen skatt");
} else if (lonn > 164101 && lonn < 230950) {
System.out.println("0.93 i skatt: " + t1);
} else if (lonn > 230951 && lonn < 580650) {
System.out.println("2.41 i skatt: " + t2);
} else if (lonn > 580651 && lonn < 934050) {
System.out.println("11.52 i skatt: " + t3);
} else if (lonn > 934051) {
System.out.println("14.52 i skatt: " + t4);
}
}
} | [
"[email protected]"
]
| |
0566fdcaaa6af30f58a833750c46d33abf7a323c | 167c6226bc77c5daaedab007dfdad4377f588ef4 | /java/ql/test/stubs/jinjava-2.6.0/com/fasterxml/jackson/databind/node/NumericNode.java | dda8f9438433799ab89c794c89cd102cde2e8396 | [
"MIT"
]
| permissive | github/codeql | 1eebb449a34f774db9e881b52cb8f7a1b1a53612 | d109637e2d7ab3b819812eb960c05cb31d9d2168 | refs/heads/main | 2023-08-20T11:32:39.162059 | 2023-08-18T14:33:32 | 2023-08-18T14:33:32 | 143,040,428 | 5,987 | 1,363 | MIT | 2023-09-14T19:36:50 | 2018-07-31T16:35:51 | CodeQL | UTF-8 | Java | false | false | 1,243 | java | // Generated automatically from com.fasterxml.jackson.databind.node.NumericNode for testing purposes
package com.fasterxml.jackson.databind.node;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.node.JsonNodeType;
import com.fasterxml.jackson.databind.node.ValueNode;
import java.math.BigDecimal;
import java.math.BigInteger;
abstract public class NumericNode extends ValueNode
{
protected NumericNode(){}
public abstract BigDecimal decimalValue();
public abstract BigInteger bigIntegerValue();
public abstract JsonParser.NumberType numberType();
public abstract Number numberValue();
public abstract String asText();
public abstract boolean canConvertToInt();
public abstract boolean canConvertToLong();
public abstract double doubleValue();
public abstract int intValue();
public abstract long longValue();
public final JsonNodeType getNodeType(){ return null; }
public final double asDouble(){ return 0; }
public final double asDouble(double p0){ return 0; }
public final int asInt(){ return 0; }
public final int asInt(int p0){ return 0; }
public final long asLong(){ return 0; }
public final long asLong(long p0){ return 0; }
}
| [
"[email protected]"
]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.