blob_id
stringlengths 40
40
| __id__
int64 225
39,780B
| directory_id
stringlengths 40
40
| path
stringlengths 6
313
| content_id
stringlengths 40
40
| detected_licenses
sequence | license_type
stringclasses 2
values | repo_name
stringlengths 6
132
| repo_url
stringlengths 25
151
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
70
| visit_date
timestamp[ns] | revision_date
timestamp[ns] | committer_date
timestamp[ns] | github_id
int64 7.28k
689M
⌀ | star_events_count
int64 0
131k
| fork_events_count
int64 0
48k
| gha_license_id
stringclasses 23
values | gha_fork
bool 2
classes | gha_event_created_at
timestamp[ns] | gha_created_at
timestamp[ns] | gha_updated_at
timestamp[ns] | gha_pushed_at
timestamp[ns] | gha_size
int64 0
40.4M
⌀ | gha_stargazers_count
int32 0
112k
⌀ | gha_forks_count
int32 0
39.4k
⌀ | gha_open_issues_count
int32 0
11k
⌀ | gha_language
stringlengths 1
21
⌀ | gha_archived
bool 2
classes | gha_disabled
bool 1
class | content
stringlengths 7
4.37M
| src_encoding
stringlengths 3
16
| language
stringclasses 1
value | length_bytes
int64 7
4.37M
| extension
stringclasses 24
values | filename
stringlengths 4
174
| language_id
stringclasses 1
value | entities
list | contaminating_dataset
stringclasses 0
values | malware_signatures
sequence | redacted_content
stringlengths 7
4.37M
| redacted_length_bytes
int64 7
4.37M
| alphanum_fraction
float32 0.25
0.94
| alpha_fraction
float32 0.25
0.94
| num_lines
int32 1
84k
| avg_line_length
float32 0.76
99.9
| std_line_length
float32 0
220
| max_line_length
int32 5
998
| is_vendor
bool 2
classes | is_generated
bool 1
class | max_hex_length
int32 0
319
| hex_fraction
float32 0
0.38
| max_unicode_length
int32 0
408
| unicode_fraction
float32 0
0.36
| max_base64_length
int32 0
506
| base64_fraction
float32 0
0.5
| avg_csv_sep_count
float32 0
4
| is_autogen_header
bool 1
class | is_empty_html
bool 1
class | shard
stringclasses 16
values |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9a946a688cf4d69b1d343a7f21913d34145bf27b | 28,845,000,419,305 | 125fda05bf47422fbf62836041c81950951399da | /Spring-cloud-alibaba-nacos-consumer-feign/src/main/java/com/qq/nacos/consumer/feign/service/NacosPrviderService.java | f3c54d50e5a31a96df80f2b5dc5843a79e494571 | [
"Apache-2.0"
] | permissive | kotowaru/springCloudAlibaba | https://github.com/kotowaru/springCloudAlibaba | 1bed272d73d0b6f2c4c45dd23405449a7cdf6781 | 8f7ff0d9a2a023db00b6c8cd2390eb8ed9f14813 | refs/heads/main | 2023-01-29T12:54:00.596000 | 2020-12-10T06:12:56 | 2020-12-10T06:12:56 | 320,175,359 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.qq.nacos.consumer.feign.service;
import com.qq.nacos.consumer.feign.fallback.NacosProviderFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value = "nacos-provider",fallback = NacosProviderFeignFallback.class)
public interface NacosPrviderService {
@RequestMapping(value = "/message/{message}",method = RequestMethod.GET)
public String message(@PathVariable String message);
}
| UTF-8 | Java | 619 | java | NacosPrviderService.java | Java | [] | null | [] | package com.qq.nacos.consumer.feign.service;
import com.qq.nacos.consumer.feign.fallback.NacosProviderFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@FeignClient(value = "nacos-provider",fallback = NacosProviderFeignFallback.class)
public interface NacosPrviderService {
@RequestMapping(value = "/message/{message}",method = RequestMethod.GET)
public String message(@PathVariable String message);
}
| 619 | 0.827141 | 0.827141 | 13 | 46.615383 | 27.73373 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.692308 | false | false | 14 |
f9f95ded4d1c9cb6b476f261ef4c8aac49a9bd8b | 21,002,390,148,270 | 7d1e7a9c9fa0704766f974570ddb78b060a7e64f | /Android/SDKSample/app/src/main/java/com/parrot/sdksample/activity/UsbAccessoryActivityImpl.java | b9821c1e92669bfa75043d96913fa617164c1f5a | [
"BSD-3-Clause"
] | permissive | khizar-anjum/bebopController | https://github.com/khizar-anjum/bebopController | 6776892a8a81c53c3ff32312de4c3d20a7871aa4 | ec38d7f6e466cc907d63a28fcc8878f186403617 | refs/heads/master | 2021-03-20T03:24:42.905000 | 2020-03-14T03:29:03 | 2020-03-14T03:29:03 | 247,171,185 | 0 | 0 | BSD-3-Clause | true | 2020-08-05T17:04:58 | 2020-03-13T22:22:22 | 2020-03-14T03:30:04 | 2020-03-15T01:30:45 | 999 | 0 | 0 | 1 | Objective-C | false | false | package com.parrot.sdksample.activity;
import com.parrot.arsdk.ardiscovery.UsbAccessoryActivity;
public class UsbAccessoryActivityImpl extends UsbAccessoryActivity
{
@Override
protected Class getBaseActivity() {
return DeviceListActivity.class;
}
}
| UTF-8 | Java | 271 | java | UsbAccessoryActivityImpl.java | Java | [] | null | [] | package com.parrot.sdksample.activity;
import com.parrot.arsdk.ardiscovery.UsbAccessoryActivity;
public class UsbAccessoryActivityImpl extends UsbAccessoryActivity
{
@Override
protected Class getBaseActivity() {
return DeviceListActivity.class;
}
}
| 271 | 0.782288 | 0.782288 | 11 | 23.636364 | 23.780331 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.272727 | false | false | 14 |
c59d352ca180ca286187ba8af80032f86e89bfdb | 26,749,056,385,045 | bd7dd7a97b5cffb6cac2423cb4cdf024957f2a3f | /src/com/faesp/protesteinterface/contaCorrente.java | 7437f0f8cfc686feed804ceffb5f9f3134f9cbb2 | [] | no_license | Willian-Levandoski/Facul | https://github.com/Willian-Levandoski/Facul | 1f9c5b92d06a1dbb548c1b63a34568f66c3ddebc | d7343f57de92a013732c6052bf0962bca28291bd | refs/heads/master | 2021-01-25T04:09:06.677000 | 2015-04-11T03:47:05 | 2015-04-11T03:47:05 | 33,761,760 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.faesp.protesteinterface;
public class contaCorrente extends servicosBanco{
public double saldo;
public double getSaldo() {
return saldo;
}
public void setSaldo(double saldo) {
this.saldo = saldo;
}
@Override
public double calculaImposto() { //Falta o Overide
return saldo * 0.1;
}
public contaCorrente(double saldo) {
super();
this.saldo = saldo;
}
}
| UTF-8 | Java | 421 | java | contaCorrente.java | Java | [] | null | [] | package com.faesp.protesteinterface;
public class contaCorrente extends servicosBanco{
public double saldo;
public double getSaldo() {
return saldo;
}
public void setSaldo(double saldo) {
this.saldo = saldo;
}
@Override
public double calculaImposto() { //Falta o Overide
return saldo * 0.1;
}
public contaCorrente(double saldo) {
super();
this.saldo = saldo;
}
}
| 421 | 0.655582 | 0.650831 | 26 | 14.192307 | 16.222063 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.153846 | false | false | 14 |
ccce778f21abded5663abe7dc83d99ec77668e69 | 9,534,827,461,976 | 4a0469efe25f88b0e16278a52ef931630e1bea70 | /Mobikul App/src/main/java/com/webkul/mobikul/adapter/HotDealsRvAdapter.java | d170f4e8b042ede3cdbdfc0551c5e125eb723f90 | [] | no_license | paddypatil90/AJP_NEW | https://github.com/paddypatil90/AJP_NEW | 8e39cbd20f47f6d1b75e0c9df81119363021f916 | 43b5239f62c6413739b03ffe20f8719848bb1627 | refs/heads/master | 2018-02-06T20:04:18.670000 | 2017-06-28T13:16:21 | 2017-06-28T13:16:21 | 95,640,067 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.webkul.mobikul.adapter;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.webkul.mobikul.R;
import com.webkul.mobikul.databinding.ItemHotDealsBinding;
import com.webkul.mobikul.handler.ProductHandler;
import com.webkul.mobikul.model.catalog.ProductData;
import java.util.ArrayList;
/**
* Created by vedesh.kumar on 23/1/17. @Webkul Software Pvt. Ltd
*/
public class HotDealsRvAdapter extends RecyclerView.Adapter<HotDealsRvAdapter.ViewHolder> {
private final Context mContext;
private final ArrayList<ProductData> mHotDealsDatas;
public HotDealsRvAdapter(Context context, ArrayList<ProductData> featuredProductsDatas) {
mContext = context;
mHotDealsDatas = featuredProductsDatas;
}
@Override
public HotDealsRvAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.item_hot_deals, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final HotDealsRvAdapter.ViewHolder holder, int position) {
final ProductData hotDealsData = mHotDealsDatas.get(position);
hotDealsData.setProductPosition(position);
holder.mBinding.setData(hotDealsData);
holder.mBinding.setHandler(new ProductHandler(mContext,mHotDealsDatas));
holder.mBinding.executePendingBindings();
}
@Override
public int getItemCount() {
if (mHotDealsDatas.size() <= 4)
return mHotDealsDatas.size();
else
return 4;
}
static class ViewHolder extends RecyclerView.ViewHolder {
private ItemHotDealsBinding mBinding;
private ViewHolder(View itemView) {
super(itemView);
mBinding = DataBindingUtil.bind(itemView);
}
}
}
| UTF-8 | Java | 2,045 | java | HotDealsRvAdapter.java | Java | [
{
"context": "a;\n\nimport java.util.ArrayList;\n\n/**\n * Created by vedesh.kumar on 23/1/17. @Webkul Software Pvt. Ltd\n ",
"end": 495,
"score": 0.9328253865242004,
"start": 493,
"tag": "NAME",
"value": "ve"
},
{
"context": "\nimport java.util.ArrayList;\n\n/**\n * Created by vedesh.kumar on 23/1/17. @Webkul Software Pvt. Ltd\n */",
"end": 497,
"score": 0.5067582130432129,
"start": 495,
"tag": "USERNAME",
"value": "de"
},
{
"context": "mport java.util.ArrayList;\n\n/**\n * Created by vedesh.kumar on 23/1/17. @Webkul Software Pvt. Ltd\n */\n\npublic",
"end": 505,
"score": 0.6521430015563965,
"start": 497,
"tag": "NAME",
"value": "sh.kumar"
}
] | null | [] | package com.webkul.mobikul.adapter;
import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.webkul.mobikul.R;
import com.webkul.mobikul.databinding.ItemHotDealsBinding;
import com.webkul.mobikul.handler.ProductHandler;
import com.webkul.mobikul.model.catalog.ProductData;
import java.util.ArrayList;
/**
* Created by vedesh.kumar on 23/1/17. @Webkul Software Pvt. Ltd
*/
public class HotDealsRvAdapter extends RecyclerView.Adapter<HotDealsRvAdapter.ViewHolder> {
private final Context mContext;
private final ArrayList<ProductData> mHotDealsDatas;
public HotDealsRvAdapter(Context context, ArrayList<ProductData> featuredProductsDatas) {
mContext = context;
mHotDealsDatas = featuredProductsDatas;
}
@Override
public HotDealsRvAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
LayoutInflater inflater = LayoutInflater.from(mContext);
View view = inflater.inflate(R.layout.item_hot_deals, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(final HotDealsRvAdapter.ViewHolder holder, int position) {
final ProductData hotDealsData = mHotDealsDatas.get(position);
hotDealsData.setProductPosition(position);
holder.mBinding.setData(hotDealsData);
holder.mBinding.setHandler(new ProductHandler(mContext,mHotDealsDatas));
holder.mBinding.executePendingBindings();
}
@Override
public int getItemCount() {
if (mHotDealsDatas.size() <= 4)
return mHotDealsDatas.size();
else
return 4;
}
static class ViewHolder extends RecyclerView.ViewHolder {
private ItemHotDealsBinding mBinding;
private ViewHolder(View itemView) {
super(itemView);
mBinding = DataBindingUtil.bind(itemView);
}
}
}
| 2,045 | 0.728606 | 0.724694 | 63 | 31.460318 | 27.605972 | 93 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.555556 | false | false | 14 |
0f403b918062201161d76f420212fd579c81f274 | 22,780,506,541,798 | 2eaf6004b7719bf1b483749d2181aca7fc4c9867 | /film-online/src/com/bo/listener/ContextLoaderListener.java | 847b7e83b97b0ac11cc8b0b057e84cc292915184 | [] | no_license | ycshang123/java-web-dev | https://github.com/ycshang123/java-web-dev | a8e16114c34d97838a2eda9a83b8291d99e9069e | bb16ef711a5d4cdd0653c9b2fce92a93dabddfec | refs/heads/master | 2020-08-02T12:32:49.378000 | 2019-10-06T07:47:32 | 2019-10-06T07:47:32 | 211,354,344 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bo.listener;/*@ClassName ContextLoaderListener
*@Description:监听器,初始化一组数据供Servlet享用
*@author yc_shang
*@Date2019/10/4
*@Version 1.0
**/
import com.bo.entity.Film;
import com.bo.entity.User;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//监视TomCat的启动
@WebListener
public class ContextLoaderListener implements ServletContextListener {
@Override
//容器初始化方法
public void contextInitialized(ServletContextEvent sce) {
System.out.println("容器启动");
//创建并生成用户数据列表
List<User> userList = new ArrayList<>(6);
User[] user = {
new User(1,"aaa@qq.com","698d51a19d8a121ce581499d7b701668","盏茶作酒","江苏徐州", LocalDate.of(2018,9,12),"看过所有新海诚知名的电影,《秒速五厘米》、《云之彼端,约定的地方》、《追逐繁星的孩子》、《言叶之庭》,甚至早期的《星之声》我也看过。这次的《你的名字》我个人认为是这几部中最好的一部,不得不说,新海诚有点让我刮目相看。","1.jpg"),
new User(2,"bbb@qq.com","bcbe3365e6ac95ea2c0343a2395834dd","@TTT","江苏泰州", LocalDate.of(2018,9,12),"教育一定要因材施教,良好的教育方法是迈向成功的开始。熊猫虽说身体肥胖,没有尖牙利爪,不是学习武术的好材料,但是经过浣熊师傅的开创性的教育,最终也可以一跃而起,凭自己的实力从师傅手里夺得了包子。","2.jpg"),
new User(3,"ccc@qq.com","310dcbbf4cce62f762a2aaa148d556bd","图图酱酱","江苏无锡", LocalDate.of(2018,9,12),"《烈火英雄》是中国电影史上第一次大规模聚焦消防员群体的影片,观看完《烈火英雄》让我对消防员充满了深深的敬意,下面是电影《烈火英雄》观后感,《烈火英雄》用震撼的场面、感人的情节,向我们展示了消防救援队伍的英勇形象,在此希望我们的英雄们,每次执行任务,都能平安归来。","3.jpg"),
new User(4,"ddd@qq.com","550a141f12de6341fba65b0ad0433500","义","新疆伊犁", LocalDate.of(2018,9,12),"看过所有新海诚知名的电影,《秒速五厘米》、《云之彼端,约定的地方》、《追逐繁星的孩子》、《言叶之庭》,甚至早期的《星之声》我也看过。这次的《你的名字》我个人认为是这几部中最好的一部,不得不说,新海诚有点让我刮目相看。","4.jpg"),
new User(5,"eee@qq.com","15de21c670ae7c3f6f3f1f37029303c9","O.","安徽宿迁", LocalDate.of(2018,9,12),"教育一定要因材施教,良好的教育方法是迈向成功的开始。熊猫虽说身体肥胖,没有尖牙利爪,不是学习武术的好材料,但是经过浣熊师傅的开创性的教育,最终也可以一跃而起,凭自己的实力从师傅手里夺得了包子。","5.jpg"),
new User(6,"fff@qq.com","fae0b27c451c728867a567e8c1bb4e53","骄纵","江苏南通", LocalDate.of(2018,9,12),"《烈火英雄》是中国电影史上第一次大规模聚焦消防员群体的影片,观看完《烈火英雄》让我对消防员充满了深深的敬意,下面是电影《烈火英雄》观后感,《烈火英雄》用震撼的场面、感人的情节,向我们展示了消防救援队伍的英勇形象,在此希望我们的英雄们,每次执行任务,都能平安归来。","6.jpg"),
};
userList = Arrays.asList(user);
List<Film> filmList = new ArrayList<>(20);
Film[] film = {
new Film(1,"我和我的祖国",9.4,"陈凯歌, 张一白……","杜江,葛优,欧豪,张译……","国语",155,"剧情","film1.jpg","该电影是2019年中国大陆多段式剧情片,是中国电影界庆祝中华人民共和国成立70周年的献礼片,“庆祝中华人民共和国成立70周年优秀国产新片展映”7部重点影片之一。影片以“历史瞬间,全民记忆,迎头相撞”的串联手法,讲述了70年间不同职业、背景及身份下的普通人在时代背景下发生的不平凡故事。"),
new Film(2,"中国机长",9.3,"刘伟强","张涵予,欧豪,杜江,袁泉,张天爱,李沁","国语",111,"剧情","film2.jpg","电影《中国机长》根据2018年5月14日四川航空3U8633航班机组成功处置特情真实事件改编:机组执行航班任务时,在万米高空突遇驾驶舱风挡玻璃爆裂脱落、座舱释压的极端罕见险情,生死关头,他们临危不乱、果断应对、正确处置,确保了机上全部人员的生命安全,创造了世界民航史上的奇迹。"),
new Film(3,"攀登者",9.2,"李仁港","吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰","国语",125,"剧情","film3.jpg","1960年,中国登山队向珠峰发起冲刺,完成了世界首次北坡登顶这一不可能的任务。15 年后,方五洲和曲松林在气象学家徐缨的帮助下,带领李国梁、杨光等年轻队员再次挑战世界之巅。迎接他们的将是更加 严酷的现实,也是生与死的挑战......"),
new Film(4,"飞驰人生",9.2,"韩寒","沈腾、黄景瑜、尹正、尹昉","国语",90,"剧情","film4.jpg","曾经叱咤风云的拉力赛车手张驰(沈腾 饰),五年前因私自赛车而被禁赛。从天堂跌落谷底,张驰饱尝生活的艰辛。他忍辱负重,洗心革面,终于争取到了解禁的判决。在此之后,他重新找到亲如兄弟的领航员孙宇强(尹正 饰),决心共同冲击本年度的巴音布鲁克拉力赛。然而在此之前,张驰必须重考驾照,改装赛车,拉到赞助。每一步都充满艰难,他忍受着旁人的奚落嘲讽,忍受着现实的冰冷残酷,无论如何都不改变前进的目标。当他好不容易走到了赛场,还将面对禁赛这几年崛起的新秀林臻东(黄景瑜 饰)的挑战。"),
new Film(5,"烈火英雄",9.2,"陈国辉","黄晓明、杜江、谭卓","国语",120,"剧情","film5.jpg","滨海市海港码头发生管道爆炸,整个罐区的原油都顺着A01油罐往外流,化成火海和阵阵爆炸,威胁全市、全省,甚至邻国的安全。慌乱的市民们四处奔逃,一辆辆消防车却逆向冲进火海……"),
new Film(6,"哪吒之魔童降世",9.2,"饺子","吕艳婷,囧森瑟夫,瀚墨,陈浩,绿绮,张珈铭,杨卫","国语",110,"动画","film6.jpg","天地灵气孕育出一颗能量巨大的混元珠,元始天尊将混元珠提炼成灵珠和魔丸,灵珠投胎为人,助周伐纣时可堪大用;而魔丸则会诞出魔王,为祸人间。元始天尊启动了天劫咒语,3年后天雷将会降临,摧毁魔丸。太乙受命将灵珠托生于陈塘关李靖家的儿子哪吒身上。然而阴差阳错,灵珠和魔丸竟然被掉包。本应是灵珠英雄的哪吒却成了混世大魔王。调皮捣蛋顽劣不堪的哪吒却徒有一颗做英雄的心。然而面对众人对魔丸的误解和即将来临的天雷的降临,哪吒是否命中注定会立地成魔?他将何去何从?"),
new Film(7,"你的名字",9.0,"新海诚","神木隆之介,上白石萌音,长泽雅美,市原悦子 ","日语",106,"动画","film10.jpg","在远离大都会的小山村,住着巫女世家出身的高中女孩宫水三叶(上白石萌音 配音)。校园和家庭的原因本就让她充满烦恼,而近一段时间发生的奇怪事件,又让三叶摸不清头脑。不知从何时起,三叶在梦中就会变成一个住在东京的高中男孩。那里有陌生的同学和朋友,有亲切的前辈和繁华的街道,一切都是如此诱人而真实。"),
new Film(8,"烟花",7.5,"李仁港"," 广濑铃,菅田将晖, 宫野真守,松隆子,花泽","国语",125,"动画","film8.jpg","炎炎夏日,茂下町的烟花大会即将举行。就读于当地高中的及川奈砂(广濑铃 配音)并未沉浸在愉快祥和的气氛之中,她即将随母亲(松隆子 配音)搬家到另一个城市,心中满是失落。在某次即兴的游泳比赛时,奈砂击败同班同学岛田典道(菅田将晖 配音)和安昙祐介(宫野真守 配音)。随后她坦白喜欢祐介,希望烟花大会时能与对方一同游玩。"),
};
filmList = Arrays.asList(film);
//获得全局变量
ServletContext servletContext = sce.getServletContext();
//设置全局变量属性,将用户和电影列表数据记入,整个应用可以共享
servletContext.setAttribute("userList",userList);
servletContext.setAttribute("filmList",filmList);
}
@Override
//容器销毁方法
public void contextDestroyed(ServletContextEvent sce)
{
System.out.println("容器销毁");
}
}
| UTF-8 | Java | 9,239 | java | ContextLoaderListener.java | Java | [
{
"context": "ner\n *@Description:监听器,初始化一组数据供Servlet享用\n *@author yc_shang\n *@Date2019/10/4\n *@Version 1.0\n **/\n\nimport com.",
"end": 114,
"score": 0.9997145533561707,
"start": 106,
"tag": "USERNAME",
"value": "yc_shang"
},
{
"context": " User[] user = {\n new User(1,\"aaa@qq.com\",\"698d51a19d8a121ce581499d7b701668\",\"盏茶作酒\",\"江苏徐州\"",
"end": 839,
"score": 0.9998584985733032,
"start": 829,
"tag": "EMAIL",
"value": "aaa@qq.com"
},
{
"context": "ser = {\n new User(1,\"aaa@qq.com\",\"698d51a19d8a121ce581499d7b701668\",\"盏茶作酒\",\"江苏徐州\", Loca",
"end": 845,
"score": 0.5807245969772339,
"start": 843,
"tag": "PASSWORD",
"value": "98"
},
{
"context": " = {\n new User(1,\"aaa@qq.com\",\"698d51a19d8a121ce581499d7b701668\",\"盏茶作酒\",\"江苏徐州\", LocalDate.of(2018,9,12),\"看过所有新海诚知",
"end": 874,
"score": 0.6462271809577942,
"start": 846,
"tag": "PASSWORD",
"value": "51a19d8a121ce581499d7b701668"
},
{
"context": "诚有点让我刮目相看。\",\"1.jpg\"),\n new User(2,\"bbb@qq.com\",\"bcbe3365e6ac95ea2c0343a2395834dd\",\"@TTT\",\"江苏泰州\"",
"end": 1074,
"score": 0.9998997449874878,
"start": 1064,
"tag": "EMAIL",
"value": "bbb@qq.com"
},
{
"context": "1.jpg\"),\n new User(2,\"bbb@qq.com\",\"bcbe3365e6ac95ea2c0343a2395834dd\",\"@TTT\",\"江苏泰州\", LocalDate.of(2018,9,12),\"教育一定要因材施",
"end": 1109,
"score": 0.8962693214416504,
"start": 1077,
"tag": "PASSWORD",
"value": "bcbe3365e6ac95ea2c0343a2395834dd"
},
{
"context": "师傅手里夺得了包子。\",\"2.jpg\"),\n new User(3,\"ccc@qq.com\",\"310dcbbf4cce62f762a2aaa148d556bd\",\"图图酱酱\",\"江苏无锡\"",
"end": 1297,
"score": 0.999921977519989,
"start": 1287,
"tag": "EMAIL",
"value": "ccc@qq.com"
},
{
"context": "2.jpg\"),\n new User(3,\"ccc@qq.com\",\"310dcbbf4cce62f762a2aaa148d556bd\",\"图图酱酱\",\"江苏无锡\", LocalDate.of(2018,9,12),\"《烈火英雄》是中",
"end": 1332,
"score": 0.9033455848693848,
"start": 1300,
"tag": "PASSWORD",
"value": "310dcbbf4cce62f762a2aaa148d556bd"
},
{
"context": "任务,都能平安归来。\",\"3.jpg\"),\n new User(4,\"ddd@qq.com\",\"550a141f12de6341fba65b0ad0433500\",\"义\",\"新疆伊犁\", L",
"end": 1555,
"score": 0.9999235272407532,
"start": 1545,
"tag": "EMAIL",
"value": "ddd@qq.com"
},
{
"context": "诚有点让我刮目相看。\",\"4.jpg\"),\n new User(5,\"eee@qq.com\",\"15de21c670ae7c3f6f3f1f37029303c9\",\"O.\",\"安徽宿迁\", ",
"end": 1787,
"score": 0.9999234080314636,
"start": 1777,
"tag": "EMAIL",
"value": "eee@qq.com"
},
{
"context": "4.jpg\"),\n new User(5,\"eee@qq.com\",\"15de21c670ae7c3f6f3f1f37029303c9\",\"O.\",\"安徽宿迁\", LocalDate.of(2018,9,12),\"教育一定要因材施教,",
"end": 1822,
"score": 0.8996843695640564,
"start": 1790,
"tag": "PASSWORD",
"value": "15de21c670ae7c3f6f3f1f37029303c9"
},
{
"context": "师傅手里夺得了包子。\",\"5.jpg\"),\n new User(6,\"fff@qq.com\",\"fae0b27c451c728867a567e8c1bb4e53\",\"骄纵\",\"江苏南通\", ",
"end": 2008,
"score": 0.9999133944511414,
"start": 1998,
"tag": "EMAIL",
"value": "fff@qq.com"
},
{
"context": "5.jpg\"),\n new User(6,\"fff@qq.com\",\"fae0b27c451c728867a567e8c1bb4e53\",\"骄纵\",\"江苏南通\", LocalDate.of(2018,9,12),\"《烈火英雄》是中国电",
"end": 2043,
"score": 0.6558922529220581,
"start": 2011,
"tag": "KEY",
"value": "fae0b27c451c728867a567e8c1bb4e53"
},
{
"context": "film = {\n new Film(1,\"我和我的祖国\",9.4,\"陈凯歌, 张一白……\",\"杜江,葛优,欧豪,张译……\",\"国语\",155,\"剧情\",\"film1.jpg\"",
"end": 2396,
"score": 0.9940738677978516,
"start": 2393,
"tag": "NAME",
"value": "陈凯歌"
},
{
"context": "的不平凡故事。\"),\n new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",",
"end": 2636,
"score": 0.9998217821121216,
"start": 2633,
"tag": "NAME",
"value": "刘伟强"
},
{
"context": "。\"),\n new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国",
"end": 2642,
"score": 0.9996343851089478,
"start": 2639,
"tag": "NAME",
"value": "张涵予"
},
{
"context": "\n new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国机长》",
"end": 2645,
"score": 0.9993249177932739,
"start": 2643,
"tag": "NAME",
"value": "欧豪"
},
{
"context": " new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国机长》根据2",
"end": 2648,
"score": 0.9889399409294128,
"start": 2646,
"tag": "NAME",
"value": "杜江"
},
{
"context": " new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国机长》根据2018",
"end": 2651,
"score": 0.9991714954376221,
"start": 2649,
"tag": "NAME",
"value": "袁泉"
},
{
"context": " new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国机长》根据2018年5月1",
"end": 2655,
"score": 0.9994097352027893,
"start": 2652,
"tag": "NAME",
"value": "张天爱"
},
{
"context": " new Film(2,\"中国机长\",9.3,\"刘伟强\",\"张涵予,欧豪,杜江,袁泉,张天爱,李沁\",\"国语\",111,\"剧情\",\"film2.jpg\",\"电影《中国机长》根据2018年5月14日四",
"end": 2658,
"score": 0.9994812607765198,
"start": 2656,
"tag": "NAME",
"value": "李沁"
},
{
"context": "民航史上的奇迹。\"),\n new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"",
"end": 2870,
"score": 0.999591588973999,
"start": 2867,
"tag": "NAME",
"value": "李仁港"
},
{
"context": "迹。\"),\n new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",12",
"end": 2875,
"score": 0.9842981100082397,
"start": 2873,
"tag": "NAME",
"value": "吴京"
},
{
"context": "),\n new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧",
"end": 2879,
"score": 0.9416396021842957,
"start": 2876,
"tag": "NAME",
"value": "章子怡"
},
{
"context": " new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",",
"end": 2882,
"score": 0.9595858454704285,
"start": 2880,
"tag": "NAME",
"value": "张译"
},
{
"context": " new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"fil",
"end": 2886,
"score": 0.9465866684913635,
"start": 2883,
"tag": "NAME",
"value": "井柏然"
},
{
"context": " new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3",
"end": 2889,
"score": 0.9989006519317627,
"start": 2887,
"tag": "NAME",
"value": "胡歌"
},
{
"context": " new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg",
"end": 2893,
"score": 0.999394953250885,
"start": 2890,
"tag": "NAME",
"value": "王景春"
},
{
"context": " new Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"",
"end": 2896,
"score": 0.9987974762916565,
"start": 2894,
"tag": "NAME",
"value": "何琳"
},
{
"context": "w Film(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"196",
"end": 2899,
"score": 0.9990471601486206,
"start": 2897,
"tag": "NAME",
"value": "陈龙"
},
{
"context": "ilm(3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"1960年,中",
"end": 2903,
"score": 0.9994168281555176,
"start": 2900,
"tag": "NAME",
"value": "刘小锋"
},
{
"context": "3,\"攀登者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"1960年,中国登山队向",
"end": 2908,
"score": 0.996825098991394,
"start": 2904,
"tag": "NAME",
"value": "曲尼次仁"
},
{
"context": "者\",9.2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"1960年,中国登山队向珠峰发起冲",
"end": 2913,
"score": 0.9967080950737,
"start": 2909,
"tag": "NAME",
"value": "拉旺罗布"
},
{
"context": "2,\"李仁港\",\"吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰\",\"国语\",125,\"剧情\",\"film3.jpg\",\"1960年,中国登山队向珠峰发起冲刺,完成",
"end": 2917,
"score": 0.9927810430526733,
"start": 2914,
"tag": "NAME",
"value": "多布杰"
},
{
"context": " 饰)的挑战。\"),\n new Film(5,\"烈火英雄\",9.2,\"陈国辉\",\"黄晓明、杜江、谭卓\",\"国语\",120,\"剧情\",\"film5.jpg\",\"滨海市海港码头发生",
"end": 3430,
"score": 0.9914601445198059,
"start": 3427,
"tag": "NAME",
"value": "陈国辉"
}
] | null | [] | package com.bo.listener;/*@ClassName ContextLoaderListener
*@Description:监听器,初始化一组数据供Servlet享用
*@author yc_shang
*@Date2019/10/4
*@Version 1.0
**/
import com.bo.entity.Film;
import com.bo.entity.User;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
//监视TomCat的启动
@WebListener
public class ContextLoaderListener implements ServletContextListener {
@Override
//容器初始化方法
public void contextInitialized(ServletContextEvent sce) {
System.out.println("容器启动");
//创建并生成用户数据列表
List<User> userList = new ArrayList<>(6);
User[] user = {
new User(1,"<EMAIL>","698d<PASSWORD>","盏茶作酒","江苏徐州", LocalDate.of(2018,9,12),"看过所有新海诚知名的电影,《秒速五厘米》、《云之彼端,约定的地方》、《追逐繁星的孩子》、《言叶之庭》,甚至早期的《星之声》我也看过。这次的《你的名字》我个人认为是这几部中最好的一部,不得不说,新海诚有点让我刮目相看。","1.jpg"),
new User(2,"<EMAIL>","<PASSWORD>","@TTT","江苏泰州", LocalDate.of(2018,9,12),"教育一定要因材施教,良好的教育方法是迈向成功的开始。熊猫虽说身体肥胖,没有尖牙利爪,不是学习武术的好材料,但是经过浣熊师傅的开创性的教育,最终也可以一跃而起,凭自己的实力从师傅手里夺得了包子。","2.jpg"),
new User(3,"<EMAIL>","<PASSWORD>","图图酱酱","江苏无锡", LocalDate.of(2018,9,12),"《烈火英雄》是中国电影史上第一次大规模聚焦消防员群体的影片,观看完《烈火英雄》让我对消防员充满了深深的敬意,下面是电影《烈火英雄》观后感,《烈火英雄》用震撼的场面、感人的情节,向我们展示了消防救援队伍的英勇形象,在此希望我们的英雄们,每次执行任务,都能平安归来。","3.jpg"),
new User(4,"<EMAIL>","550a141f12de6341fba65b0ad0433500","义","新疆伊犁", LocalDate.of(2018,9,12),"看过所有新海诚知名的电影,《秒速五厘米》、《云之彼端,约定的地方》、《追逐繁星的孩子》、《言叶之庭》,甚至早期的《星之声》我也看过。这次的《你的名字》我个人认为是这几部中最好的一部,不得不说,新海诚有点让我刮目相看。","4.jpg"),
new User(5,"<EMAIL>","<PASSWORD>","O.","安徽宿迁", LocalDate.of(2018,9,12),"教育一定要因材施教,良好的教育方法是迈向成功的开始。熊猫虽说身体肥胖,没有尖牙利爪,不是学习武术的好材料,但是经过浣熊师傅的开创性的教育,最终也可以一跃而起,凭自己的实力从师傅手里夺得了包子。","5.jpg"),
new User(6,"<EMAIL>","<KEY>","骄纵","江苏南通", LocalDate.of(2018,9,12),"《烈火英雄》是中国电影史上第一次大规模聚焦消防员群体的影片,观看完《烈火英雄》让我对消防员充满了深深的敬意,下面是电影《烈火英雄》观后感,《烈火英雄》用震撼的场面、感人的情节,向我们展示了消防救援队伍的英勇形象,在此希望我们的英雄们,每次执行任务,都能平安归来。","6.jpg"),
};
userList = Arrays.asList(user);
List<Film> filmList = new ArrayList<>(20);
Film[] film = {
new Film(1,"我和我的祖国",9.4,"陈凯歌, 张一白……","杜江,葛优,欧豪,张译……","国语",155,"剧情","film1.jpg","该电影是2019年中国大陆多段式剧情片,是中国电影界庆祝中华人民共和国成立70周年的献礼片,“庆祝中华人民共和国成立70周年优秀国产新片展映”7部重点影片之一。影片以“历史瞬间,全民记忆,迎头相撞”的串联手法,讲述了70年间不同职业、背景及身份下的普通人在时代背景下发生的不平凡故事。"),
new Film(2,"中国机长",9.3,"刘伟强","张涵予,欧豪,杜江,袁泉,张天爱,李沁","国语",111,"剧情","film2.jpg","电影《中国机长》根据2018年5月14日四川航空3U8633航班机组成功处置特情真实事件改编:机组执行航班任务时,在万米高空突遇驾驶舱风挡玻璃爆裂脱落、座舱释压的极端罕见险情,生死关头,他们临危不乱、果断应对、正确处置,确保了机上全部人员的生命安全,创造了世界民航史上的奇迹。"),
new Film(3,"攀登者",9.2,"李仁港","吴京,章子怡,张译,井柏然,胡歌,王景春,何琳,陈龙,刘小锋,曲尼次仁,拉旺罗布,多布杰","国语",125,"剧情","film3.jpg","1960年,中国登山队向珠峰发起冲刺,完成了世界首次北坡登顶这一不可能的任务。15 年后,方五洲和曲松林在气象学家徐缨的帮助下,带领李国梁、杨光等年轻队员再次挑战世界之巅。迎接他们的将是更加 严酷的现实,也是生与死的挑战......"),
new Film(4,"飞驰人生",9.2,"韩寒","沈腾、黄景瑜、尹正、尹昉","国语",90,"剧情","film4.jpg","曾经叱咤风云的拉力赛车手张驰(沈腾 饰),五年前因私自赛车而被禁赛。从天堂跌落谷底,张驰饱尝生活的艰辛。他忍辱负重,洗心革面,终于争取到了解禁的判决。在此之后,他重新找到亲如兄弟的领航员孙宇强(尹正 饰),决心共同冲击本年度的巴音布鲁克拉力赛。然而在此之前,张驰必须重考驾照,改装赛车,拉到赞助。每一步都充满艰难,他忍受着旁人的奚落嘲讽,忍受着现实的冰冷残酷,无论如何都不改变前进的目标。当他好不容易走到了赛场,还将面对禁赛这几年崛起的新秀林臻东(黄景瑜 饰)的挑战。"),
new Film(5,"烈火英雄",9.2,"陈国辉","黄晓明、杜江、谭卓","国语",120,"剧情","film5.jpg","滨海市海港码头发生管道爆炸,整个罐区的原油都顺着A01油罐往外流,化成火海和阵阵爆炸,威胁全市、全省,甚至邻国的安全。慌乱的市民们四处奔逃,一辆辆消防车却逆向冲进火海……"),
new Film(6,"哪吒之魔童降世",9.2,"饺子","吕艳婷,囧森瑟夫,瀚墨,陈浩,绿绮,张珈铭,杨卫","国语",110,"动画","film6.jpg","天地灵气孕育出一颗能量巨大的混元珠,元始天尊将混元珠提炼成灵珠和魔丸,灵珠投胎为人,助周伐纣时可堪大用;而魔丸则会诞出魔王,为祸人间。元始天尊启动了天劫咒语,3年后天雷将会降临,摧毁魔丸。太乙受命将灵珠托生于陈塘关李靖家的儿子哪吒身上。然而阴差阳错,灵珠和魔丸竟然被掉包。本应是灵珠英雄的哪吒却成了混世大魔王。调皮捣蛋顽劣不堪的哪吒却徒有一颗做英雄的心。然而面对众人对魔丸的误解和即将来临的天雷的降临,哪吒是否命中注定会立地成魔?他将何去何从?"),
new Film(7,"你的名字",9.0,"新海诚","神木隆之介,上白石萌音,长泽雅美,市原悦子 ","日语",106,"动画","film10.jpg","在远离大都会的小山村,住着巫女世家出身的高中女孩宫水三叶(上白石萌音 配音)。校园和家庭的原因本就让她充满烦恼,而近一段时间发生的奇怪事件,又让三叶摸不清头脑。不知从何时起,三叶在梦中就会变成一个住在东京的高中男孩。那里有陌生的同学和朋友,有亲切的前辈和繁华的街道,一切都是如此诱人而真实。"),
new Film(8,"烟花",7.5,"李仁港"," 广濑铃,菅田将晖, 宫野真守,松隆子,花泽","国语",125,"动画","film8.jpg","炎炎夏日,茂下町的烟花大会即将举行。就读于当地高中的及川奈砂(广濑铃 配音)并未沉浸在愉快祥和的气氛之中,她即将随母亲(松隆子 配音)搬家到另一个城市,心中满是失落。在某次即兴的游泳比赛时,奈砂击败同班同学岛田典道(菅田将晖 配音)和安昙祐介(宫野真守 配音)。随后她坦白喜欢祐介,希望烟花大会时能与对方一同游玩。"),
};
filmList = Arrays.asList(film);
//获得全局变量
ServletContext servletContext = sce.getServletContext();
//设置全局变量属性,将用户和电影列表数据记入,整个应用可以共享
servletContext.setAttribute("userList",userList);
servletContext.setAttribute("filmList",filmList);
}
@Override
//容器销毁方法
public void contextDestroyed(ServletContextEvent sce)
{
System.out.println("容器销毁");
}
}
| 9,110 | 0.719651 | 0.662378 | 63 | 75.492065 | 94.475807 | 325 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.031746 | false | false | 14 |
b3b27886d486cc67a8c5680cff234427b5cb6764 | 6,837,587,999,884 | a770e95028afb71f3b161d43648c347642819740 | /sources/org/telegram/messenger/BuildVars.java | c11d04da53578e37074e570eeebf72c7ec141780 | [] | no_license | Edicksonjga/TGDecompiledBeta | https://github.com/Edicksonjga/TGDecompiledBeta | d7aa48a2b39bbaefd4752299620ff7b72b515c83 | d1db6a445d5bed43c1dc8213fb8dbefd96f6c51b | refs/heads/master | 2023-08-25T04:12:15.592000 | 2021-10-28T20:24:07 | 2021-10-28T20:24:07 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package org.telegram.messenger;
import android.content.SharedPreferences;
public class BuildVars {
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
public static String APPCENTER_HASH_DEBUG = "var_-67c9-48d2-b5d0-4761f1c1a8f3";
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static int APP_ID = 4;
public static int BUILD_VERSION = 2446;
public static String BUILD_VERSION_STRING = "8.2.3";
public static boolean CHECK_UPDATES = true;
public static boolean DEBUG_PRIVATE_VERSION = false;
public static boolean DEBUG_VERSION = true;
public static boolean LOGS_ENABLED = true;
public static boolean NO_SCOPED_STORAGE = true;
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";
public static String SMS_HASH = (isStandaloneApp() ? "w0lkcmTZkKh" : DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static boolean USE_CLOUD_STRINGS = true;
private static Boolean betaApp;
private static Boolean standaloneApp;
static {
if (ApplicationLoader.applicationContext != null) {
boolean z = false;
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", 0);
boolean z2 = DEBUG_VERSION;
if (z2 || sharedPreferences.getBoolean("logsEnabled", z2)) {
z = true;
}
LOGS_ENABLED = z;
}
}
public static boolean isStandaloneApp() {
if (standaloneApp == null) {
standaloneApp = Boolean.valueOf(ApplicationLoader.applicationContext != null && "org.telegram.messenger.web".equals(ApplicationLoader.applicationContext.getPackageName()));
}
return standaloneApp.booleanValue();
}
public static boolean isBetaApp() {
if (betaApp == null) {
betaApp = Boolean.valueOf(ApplicationLoader.applicationContext != null && "org.telegram.messenger.beta".equals(ApplicationLoader.applicationContext.getPackageName()));
}
return betaApp.booleanValue();
}
}
| UTF-8 | Java | 2,165 | java | BuildVars.java | Java | [] | null | [] | package org.telegram.messenger;
import android.content.SharedPreferences;
public class BuildVars {
public static String APPCENTER_HASH = "a5b5c4f5-51da-dedc-9918-d9766a22ca7c";
public static String APPCENTER_HASH_DEBUG = "var_-67c9-48d2-b5d0-4761f1c1a8f3";
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
public static int APP_ID = 4;
public static int BUILD_VERSION = 2446;
public static String BUILD_VERSION_STRING = "8.2.3";
public static boolean CHECK_UPDATES = true;
public static boolean DEBUG_PRIVATE_VERSION = false;
public static boolean DEBUG_VERSION = true;
public static boolean LOGS_ENABLED = true;
public static boolean NO_SCOPED_STORAGE = true;
public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger";
public static String SMS_HASH = (isStandaloneApp() ? "w0lkcmTZkKh" : DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT");
public static boolean USE_CLOUD_STRINGS = true;
private static Boolean betaApp;
private static Boolean standaloneApp;
static {
if (ApplicationLoader.applicationContext != null) {
boolean z = false;
SharedPreferences sharedPreferences = ApplicationLoader.applicationContext.getSharedPreferences("systemConfig", 0);
boolean z2 = DEBUG_VERSION;
if (z2 || sharedPreferences.getBoolean("logsEnabled", z2)) {
z = true;
}
LOGS_ENABLED = z;
}
}
public static boolean isStandaloneApp() {
if (standaloneApp == null) {
standaloneApp = Boolean.valueOf(ApplicationLoader.applicationContext != null && "org.telegram.messenger.web".equals(ApplicationLoader.applicationContext.getPackageName()));
}
return standaloneApp.booleanValue();
}
public static boolean isBetaApp() {
if (betaApp == null) {
betaApp = Boolean.valueOf(ApplicationLoader.applicationContext != null && "org.telegram.messenger.beta".equals(ApplicationLoader.applicationContext.getPackageName()));
}
return betaApp.booleanValue();
}
}
| 2,165 | 0.688222 | 0.654042 | 48 | 44.104168 | 41.927635 | 184 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.645833 | false | false | 14 |
f4a3858bcec06e9e7c0491ae8a98f999ac8031b0 | 14,783,277,503,224 | 44ea354a2ef926d1058655b9c264d126529c7619 | /app/src/main/java/com/coremobile/coreyhealth/native_epro/CMN_Epro_number_of_options.java | 4bc27ef7f95b0f90ec5ebeb2c7edaca69ff0523c | [] | no_license | Nitijkatiyar/coreyclient_android_studio | https://github.com/Nitijkatiyar/coreyclient_android_studio | 6ce8ef169e7cd0116763b7a3166e9a0ed24d5597 | 17b36523f6e60333c240a03322f0cb517a101368 | refs/heads/master | 2021-08-24T08:30:18.361000 | 2017-12-08T21:33:57 | 2017-12-08T21:34:51 | 113,618,836 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.coremobile.coreyhealth.native_epro;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.NumberPicker;
import com.coremobile.coreyhealth.R;
import com.coremobile.coreyhealth.base.CMN_AppBaseActivity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by nitij on 09-01-2017.
*/
public class CMN_Epro_number_of_options extends CMN_AppBaseActivity {
NumberPicker numberPicker;
EditText editText1, editText2, editText3, editText4, editText5;
List<EditText> editTexts;
Intent intent;
int numberoptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.epro_number_of_option);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setTitle(
"" + getResources().getString(R.string.options));
getActionBar().setDisplayHomeAsUpEnabled(true);
editTexts = new ArrayList<>();
intent = getIntent();
numberPicker = (NumberPicker) findViewById(R.id.epro_add_numberofoptions_picker);
numberPicker.setMinValue(2);
numberPicker.setMaxValue(5);
editText1 = (EditText) findViewById(R.id.add_epro_option1);
editText2 = (EditText) findViewById(R.id.add_epro_option2);
editText3 = (EditText) findViewById(R.id.add_epro_option3);
editText4 = (EditText) findViewById(R.id.add_epro_option4);
editText5 = (EditText) findViewById(R.id.add_epro_option5);
editText1.clearFocus();
editText2.clearFocus();
editText3.clearFocus();
editText4.clearFocus();
editText5.clearFocus();
editTexts.add(editText1);
editTexts.add(editText2);
editTexts.add(editText3);
editTexts.add(editText4);
editTexts.add(editText5);
editText3.setVisibility(View.GONE);
editText4.setVisibility(View.GONE);
editText5.setVisibility(View.GONE);
if (intent != null && intent.hasExtra("numberofoptions")) {
numberoptions = intent.getIntExtra("numberofoptions", 0);
showhideedittexts(numberoptions);
numberPicker.setValue(numberoptions);
}
List<String> items = Arrays.asList(intent.getStringExtra("data").toString().split("\\s*,\\s*"));
for (int i = 0; i < items.size(); i++) {
editTexts.get(i).setText(items.get(i));
}
numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
editText1.setVisibility(View.GONE);
editText2.setVisibility(View.GONE);
editText3.setVisibility(View.GONE);
editText4.setVisibility(View.GONE);
editText5.setVisibility(View.GONE);
showhideedittexts(newVal);
}
});
}
private void showhideedittexts(int value) {
for (int i = 0; i < value; i++) {
editTexts.get(i).setVisibility(View.VISIBLE);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.savesurveydata, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
case R.id.action_save:
String options = "";
for (int i = 0; i < numberPicker.getValue(); i++) {
if (i == numberPicker.getValue() - 1) {
options = options + editTexts.get(i).getText().toString();
} else {
options = options + editTexts.get(i).getText().toString() + ",";
}
}
Intent intent = new Intent();
intent.putExtra("optionsCount", numberPicker.getValue());
intent.putExtra("optionsValue", "" + options);
setResult(RESULT_OK, intent);
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
| UTF-8 | Java | 4,486 | java | CMN_Epro_number_of_options.java | Java | [
{
"context": ".Arrays;\nimport java.util.List;\n\n/**\n * Created by nitij on 09-01-2017.\n */\npublic class CMN_Epro_number_o",
"end": 455,
"score": 0.9996318221092224,
"start": 450,
"tag": "USERNAME",
"value": "nitij"
}
] | null | [] | package com.coremobile.coreyhealth.native_epro;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.NumberPicker;
import com.coremobile.coreyhealth.R;
import com.coremobile.coreyhealth.base.CMN_AppBaseActivity;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* Created by nitij on 09-01-2017.
*/
public class CMN_Epro_number_of_options extends CMN_AppBaseActivity {
NumberPicker numberPicker;
EditText editText1, editText2, editText3, editText4, editText5;
List<EditText> editTexts;
Intent intent;
int numberoptions;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.epro_number_of_option);
getActionBar().setHomeButtonEnabled(true);
getActionBar().setTitle(
"" + getResources().getString(R.string.options));
getActionBar().setDisplayHomeAsUpEnabled(true);
editTexts = new ArrayList<>();
intent = getIntent();
numberPicker = (NumberPicker) findViewById(R.id.epro_add_numberofoptions_picker);
numberPicker.setMinValue(2);
numberPicker.setMaxValue(5);
editText1 = (EditText) findViewById(R.id.add_epro_option1);
editText2 = (EditText) findViewById(R.id.add_epro_option2);
editText3 = (EditText) findViewById(R.id.add_epro_option3);
editText4 = (EditText) findViewById(R.id.add_epro_option4);
editText5 = (EditText) findViewById(R.id.add_epro_option5);
editText1.clearFocus();
editText2.clearFocus();
editText3.clearFocus();
editText4.clearFocus();
editText5.clearFocus();
editTexts.add(editText1);
editTexts.add(editText2);
editTexts.add(editText3);
editTexts.add(editText4);
editTexts.add(editText5);
editText3.setVisibility(View.GONE);
editText4.setVisibility(View.GONE);
editText5.setVisibility(View.GONE);
if (intent != null && intent.hasExtra("numberofoptions")) {
numberoptions = intent.getIntExtra("numberofoptions", 0);
showhideedittexts(numberoptions);
numberPicker.setValue(numberoptions);
}
List<String> items = Arrays.asList(intent.getStringExtra("data").toString().split("\\s*,\\s*"));
for (int i = 0; i < items.size(); i++) {
editTexts.get(i).setText(items.get(i));
}
numberPicker.setOnValueChangedListener(new NumberPicker.OnValueChangeListener() {
@Override
public void onValueChange(NumberPicker picker, int oldVal, int newVal) {
editText1.setVisibility(View.GONE);
editText2.setVisibility(View.GONE);
editText3.setVisibility(View.GONE);
editText4.setVisibility(View.GONE);
editText5.setVisibility(View.GONE);
showhideedittexts(newVal);
}
});
}
private void showhideedittexts(int value) {
for (int i = 0; i < value; i++) {
editTexts.get(i).setVisibility(View.VISIBLE);
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.savesurveydata, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
this.finish();
return true;
case R.id.action_save:
String options = "";
for (int i = 0; i < numberPicker.getValue(); i++) {
if (i == numberPicker.getValue() - 1) {
options = options + editTexts.get(i).getText().toString();
} else {
options = options + editTexts.get(i).getText().toString() + ",";
}
}
Intent intent = new Intent();
intent.putExtra("optionsCount", numberPicker.getValue());
intent.putExtra("optionsValue", "" + options);
setResult(RESULT_OK, intent);
finish();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}
| 4,486 | 0.607222 | 0.596523 | 133 | 32.729324 | 24.813023 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.691729 | false | false | 14 |
955a6741fa0cf0c4086f1893496fd8cca910e06b | 5,626,407,171,978 | 219fb009217f3a77a21bbea89aac8ff5bbffce81 | /src/com/lh/super_market/web/CategoryController.java | d5500b005f09a04d7e43b81f65d95e2972ff9ce8 | [] | no_license | LHCAMPUS/super_market | https://github.com/LHCAMPUS/super_market | 1b3e65fa970a8a7697433ef6cbfd34ae52cfeb78 | e648cd56f19d7aaa06e68217c679dbe5bca1f901 | refs/heads/master | 2021-01-17T20:20:08.865000 | 2017-04-24T09:33:47 | 2017-04-24T09:33:47 | 84,142,593 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lh.super_market.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.github.pagehelper.PageInfo;
import com.lh.super_market.entity.Category;
import com.lh.super_market.service.impl.CategoryServiceImpl;
@Controller
@RequestMapping("/category")
public class CategoryController {
@Autowired
private CategoryServiceImpl categoryServiceImpl;
@RequestMapping("/categoryList.do")
public String query(String pageIndex, String pageSize, String strWhere, Model model){
PageInfo<Category> list = categoryServiceImpl.queryByPage(Integer.parseInt(pageIndex), 5, strWhere);
model.addAttribute("list", list.getList());
model.addAttribute("pageCount", list.getPages());
model.addAttribute("currentPage", list.getPageNum());
model.addAttribute("count", list.getSize());
return "category/list";
}
@RequestMapping(value = "/addCategory.do", method = RequestMethod.GET)
public String addStaff(){
return "category/add";
}
@RequestMapping(value = "/addCategory.do", method = RequestMethod.POST)
public String addCategoryInfo(Category category, HttpServletResponse response){
int id = categoryServiceImpl.add(category);
boolean b = id > 0? true : false;
outStr(b, response);
return null;
}
@RequestMapping(value = "/updateCategory.do", method = RequestMethod.GET)
public String upCategory(String id, Model model){
Map<String,String> map = new HashMap<String,String>();
map.put("strWhere", "Category_id="+id);
List<Category> list = categoryServiceImpl.queryByStr(map);
model.addAttribute("category", list.get(0));
return "category/update";
}
@RequestMapping(value = "/updateCategory.do", method = RequestMethod.POST)
public String upCategoryInfo(Category category, HttpServletResponse response){
boolean b = categoryServiceImpl.update(category);
outStr(b, response);
return null;
}
@RequestMapping(value = "/deleteCategory.do", method = RequestMethod.GET)
public String deleteCategory(String id, HttpServletResponse response){
boolean b = categoryServiceImpl.delete(Integer.parseInt(id));
outStr(b, response);
return null;
}
public void outStr(boolean b, HttpServletResponse response){
try {
response.setContentType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
if(b){
out.println("<script>alert('操作成功');window.location.href='categoryList.do?pageIndex=1'</script>");
}else{
out.println("<script>alert('操作失败');window.location.href='categoryList.do?pageIndex=1'</script>");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
| UTF-8 | Java | 3,071 | java | CategoryController.java | Java | [] | null | [] | package com.lh.super_market.web;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import com.github.pagehelper.PageInfo;
import com.lh.super_market.entity.Category;
import com.lh.super_market.service.impl.CategoryServiceImpl;
@Controller
@RequestMapping("/category")
public class CategoryController {
@Autowired
private CategoryServiceImpl categoryServiceImpl;
@RequestMapping("/categoryList.do")
public String query(String pageIndex, String pageSize, String strWhere, Model model){
PageInfo<Category> list = categoryServiceImpl.queryByPage(Integer.parseInt(pageIndex), 5, strWhere);
model.addAttribute("list", list.getList());
model.addAttribute("pageCount", list.getPages());
model.addAttribute("currentPage", list.getPageNum());
model.addAttribute("count", list.getSize());
return "category/list";
}
@RequestMapping(value = "/addCategory.do", method = RequestMethod.GET)
public String addStaff(){
return "category/add";
}
@RequestMapping(value = "/addCategory.do", method = RequestMethod.POST)
public String addCategoryInfo(Category category, HttpServletResponse response){
int id = categoryServiceImpl.add(category);
boolean b = id > 0? true : false;
outStr(b, response);
return null;
}
@RequestMapping(value = "/updateCategory.do", method = RequestMethod.GET)
public String upCategory(String id, Model model){
Map<String,String> map = new HashMap<String,String>();
map.put("strWhere", "Category_id="+id);
List<Category> list = categoryServiceImpl.queryByStr(map);
model.addAttribute("category", list.get(0));
return "category/update";
}
@RequestMapping(value = "/updateCategory.do", method = RequestMethod.POST)
public String upCategoryInfo(Category category, HttpServletResponse response){
boolean b = categoryServiceImpl.update(category);
outStr(b, response);
return null;
}
@RequestMapping(value = "/deleteCategory.do", method = RequestMethod.GET)
public String deleteCategory(String id, HttpServletResponse response){
boolean b = categoryServiceImpl.delete(Integer.parseInt(id));
outStr(b, response);
return null;
}
public void outStr(boolean b, HttpServletResponse response){
try {
response.setContentType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
if(b){
out.println("<script>alert('操作成功');window.location.href='categoryList.do?pageIndex=1'</script>");
}else{
out.println("<script>alert('操作失败');window.location.href='categoryList.do?pageIndex=1'</script>");
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
| 3,071 | 0.735188 | 0.733224 | 88 | 32.715908 | 28.100853 | 102 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.022727 | false | false | 14 |
5db327e6b335daf987a0ef4da30a40daa863345f | 7,894,149,956,416 | d244ba116183d9a9052770b4ab1467e336fe1881 | /skysail.server.portal/src/main/java/de/twenty11/skysail/portal/internal/Portal.java | 7ad35ce98803ea379a0410440d48d1def217bdeb | [] | no_license | evandor/skysail-server-old | https://github.com/evandor/skysail-server-old | 310f7e19d5fcee4eeede8f756d4c5e8f9d5853d4 | 54342cbf519d45cd6b9bb01262e0364faa133d10 | refs/heads/master | 2021-03-27T12:48:08.205000 | 2013-10-22T05:51:49 | 2013-10-22T05:51:49 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package de.twenty11.skysail.portal.internal;
import de.twenty11.skysail.server.listener.UrlMappingServiceListener;
import de.twenty11.skysail.server.restlet.RestletOsgiApplication;
public class Portal extends RestletOsgiApplication {
public Portal(String staticPathTemplate) {
super(staticPathTemplate);
}
@Override
protected void attach() {
new UrlMappingServiceListener(this);
}
}
| UTF-8 | Java | 403 | java | Portal.java | Java | [] | null | [] | package de.twenty11.skysail.portal.internal;
import de.twenty11.skysail.server.listener.UrlMappingServiceListener;
import de.twenty11.skysail.server.restlet.RestletOsgiApplication;
public class Portal extends RestletOsgiApplication {
public Portal(String staticPathTemplate) {
super(staticPathTemplate);
}
@Override
protected void attach() {
new UrlMappingServiceListener(this);
}
}
| 403 | 0.799007 | 0.784119 | 17 | 22.705883 | 24.513536 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.705882 | false | false | 14 |
8a32cea7bd4939c7fd187d7b690fb111802bf4cd | 1,846,835,941,692 | 0ed9d43a9087a6601654fd4d4ab98a723a48ded3 | /app/src/main/java/com/acchain/community/presenter/IndexPresenter.java | b61a33752bcd99b8679827f072349f5fe732a98e | [] | no_license | xuxiaowei007/DigitalMall | https://github.com/xuxiaowei007/DigitalMall | 6fbf7021aae35d5231333d56b73e4e974061aac5 | a4d34d1e91dfa8d96e687f417a79402e00eb9eb7 | refs/heads/master | 2020-04-14T10:22:21.108000 | 2018-05-08T08:00:17 | 2018-05-08T08:00:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.acchain.community.presenter;
import com.acchain.community.base.BaseHttpBean;
import com.acchain.community.base.BasePresenter;
import com.acchain.community.bean.IndexDataBean;
import com.acchain.community.contract.IndexContract;
import com.acchain.community.fragment.IndexFragment;
import com.acchain.community.util.HttpListener;
import com.acchain.community.util.HTTPException;
import javax.inject.Inject;
/**
* function---- IndexPresenter
* <p>
* Created(Gradle default create) by ACChain on 2017/12/20 10:48:47 (+0000).
*/
public class IndexPresenter extends BasePresenter<IndexFragment> implements IndexContract.Presenter {
@Inject
public IndexPresenter() {
}
@Override
public void getIndexData() {
requestHttp(httpInterface.getIndexData("mall_app_index"), new HttpListener<BaseHttpBean<IndexDataBean>>() {
@Override
public void onSuccess(BaseHttpBean<IndexDataBean> response) {
IndexDataBean dataSet = response.dataSet;
dataSet.setCurrentTime(response.systemTime);
mView.onIndexDataFinish(dataSet);
}
@Override
public void onFailed(Throwable e) {
super.onFailed(e);
e.printStackTrace();
mView.onIndexDataFinish(null);
}
@Override
public void onFailed(HTTPException e) {
super.onFailed(e);
mView.onIndexDataFinish(null);
}
});
}
} | UTF-8 | Java | 1,533 | java | IndexPresenter.java | Java | [] | null | [] | package com.acchain.community.presenter;
import com.acchain.community.base.BaseHttpBean;
import com.acchain.community.base.BasePresenter;
import com.acchain.community.bean.IndexDataBean;
import com.acchain.community.contract.IndexContract;
import com.acchain.community.fragment.IndexFragment;
import com.acchain.community.util.HttpListener;
import com.acchain.community.util.HTTPException;
import javax.inject.Inject;
/**
* function---- IndexPresenter
* <p>
* Created(Gradle default create) by ACChain on 2017/12/20 10:48:47 (+0000).
*/
public class IndexPresenter extends BasePresenter<IndexFragment> implements IndexContract.Presenter {
@Inject
public IndexPresenter() {
}
@Override
public void getIndexData() {
requestHttp(httpInterface.getIndexData("mall_app_index"), new HttpListener<BaseHttpBean<IndexDataBean>>() {
@Override
public void onSuccess(BaseHttpBean<IndexDataBean> response) {
IndexDataBean dataSet = response.dataSet;
dataSet.setCurrentTime(response.systemTime);
mView.onIndexDataFinish(dataSet);
}
@Override
public void onFailed(Throwable e) {
super.onFailed(e);
e.printStackTrace();
mView.onIndexDataFinish(null);
}
@Override
public void onFailed(HTTPException e) {
super.onFailed(e);
mView.onIndexDataFinish(null);
}
});
}
} | 1,533 | 0.655577 | 0.643836 | 49 | 30.306122 | 26.9559 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.387755 | false | false | 14 |
5e20f9bfb0aba721e9c21a054b2515b7f6510330 | 16,647,293,289,458 | d75490203dcbe5ba2a7b7e56191a4b91c954ee84 | /src/application/application__list.java | c735cafee6d5676610d33a692134c5560d2a1ba9 | [] | no_license | Nouhack/Doc-Shot | https://github.com/Nouhack/Doc-Shot | 8c795249f77c38112bc377b3b28f1ed2c609ddff | 9f8952929f3818dbc9cdcc1bf59398ea89a0d88c | refs/heads/master | 2022-11-28T05:26:09.148000 | 2020-07-30T10:38:53 | 2020-07-30T10:38:53 | 283,739,186 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package application;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXTreeTableColumn;
import com.jfoenix.controls.JFXTreeTableView;
import com.jfoenix.controls.RecursiveTreeItem;
import com.jfoenix.controls.cells.editors.TextFieldEditorBuilder;
import com.jfoenix.controls.cells.editors.base.GenericEditableTreeTableCell;
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableColumn.CellEditEvent;
import javafx.util.Callback;
public class application__list {
void application_tree_table_vview(JFXTreeTableView<application_documenter> aa,boolean editable,String statem) {
JFXTreeTableColumn<application_documenter, String> nom_application = new JFXTreeTableColumn<>("Nom de l'application");
nom_application.setPrefWidth(280);
nom_application.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(nom_application.validateValue(param)) return param.getValue().getValue().nom_app;
else return nom_application.getComputedValue(param);
});
JFXTreeTableColumn<application_documenter, String> descrip_application = new JFXTreeTableColumn<>("La description de l'application");
descrip_application.setPrefWidth(280);
descrip_application.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(descrip_application.validateValue(param)) return param.getValue().getValue().app_descrip;
else return descrip_application.getComputedValue(param);
});
JFXTreeTableColumn<application_documenter, String> nom_du_projet = new JFXTreeTableColumn<>("Nom du projet");
nom_du_projet.setPrefWidth(280);
nom_du_projet.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(nom_du_projet.validateValue(param)) return param.getValue().getValue().project_name;
else return nom_du_projet.getComputedValue(param);
});
//-------------------------------------------------
// data FXCollections.observableArrayList();
ObservableList<application_documenter> apps = FXCollections.observableArrayList();
get_application_list_to_tree_table(statem, apps);
final TreeItem<application_documenter> root2 = new RecursiveTreeItem<application_documenter>(apps, RecursiveTreeObject::getChildren);
aa.getColumns().setAll(nom_application,descrip_application,nom_du_projet);
aa.setRoot(root2);
aa.setShowRoot(false);
aa.setEditable(editable);
aa.getColumns().setAll(nom_application,descrip_application,nom_du_projet);
}
private void get_application_list_to_tree_table(String userlog, ObservableList<application_documenter> apps) {
// TODO Auto-generated method stub
try {
jdbc.setConnection();
Statement stm=jdbc.setConnection().createStatement();
String strcheck="select nom_app,app_descrip,nom_projet from application,projet where (application.id_projet=projet.id) and application.id in (select Id_app from collab_app where Id_collab_samp=(select id from utilisateur where username="+'"'+userlog+'"'+"))";
ResultSet res = stm.executeQuery(strcheck);
while (res.next()) {
apps.add(new application_documenter(res.getString("nom_app"),res.getString("app_descrip"),res.getString("nom_projet")));
}
jdbc.setConnection().close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void application_filter(JFXTextField zz,JFXTreeTableView<application_documenter> deltree) {
zz.textProperty().addListener((o,oldVal,newVal)->{
deltree.setPredicate(pro -> pro.getValue().nom_app.get().contains(newVal)
|| pro.getValue().app_descrip.get().contains(newVal)
|| pro.getValue().project_name.get().contains(newVal)
);
});
}
}
| UTF-8 | Java | 4,410 | java | application__list.java | Java | [] | null | [] | package application;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.jfoenix.controls.JFXTextField;
import com.jfoenix.controls.JFXTreeTableColumn;
import com.jfoenix.controls.JFXTreeTableView;
import com.jfoenix.controls.RecursiveTreeItem;
import com.jfoenix.controls.cells.editors.TextFieldEditorBuilder;
import com.jfoenix.controls.cells.editors.base.GenericEditableTreeTableCell;
import com.jfoenix.controls.datamodels.treetable.RecursiveTreeObject;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableColumn.CellEditEvent;
import javafx.util.Callback;
public class application__list {
void application_tree_table_vview(JFXTreeTableView<application_documenter> aa,boolean editable,String statem) {
JFXTreeTableColumn<application_documenter, String> nom_application = new JFXTreeTableColumn<>("Nom de l'application");
nom_application.setPrefWidth(280);
nom_application.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(nom_application.validateValue(param)) return param.getValue().getValue().nom_app;
else return nom_application.getComputedValue(param);
});
JFXTreeTableColumn<application_documenter, String> descrip_application = new JFXTreeTableColumn<>("La description de l'application");
descrip_application.setPrefWidth(280);
descrip_application.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(descrip_application.validateValue(param)) return param.getValue().getValue().app_descrip;
else return descrip_application.getComputedValue(param);
});
JFXTreeTableColumn<application_documenter, String> nom_du_projet = new JFXTreeTableColumn<>("Nom du projet");
nom_du_projet.setPrefWidth(280);
nom_du_projet.setCellValueFactory((TreeTableColumn.CellDataFeatures<application_documenter, String> param) ->{
if(nom_du_projet.validateValue(param)) return param.getValue().getValue().project_name;
else return nom_du_projet.getComputedValue(param);
});
//-------------------------------------------------
// data FXCollections.observableArrayList();
ObservableList<application_documenter> apps = FXCollections.observableArrayList();
get_application_list_to_tree_table(statem, apps);
final TreeItem<application_documenter> root2 = new RecursiveTreeItem<application_documenter>(apps, RecursiveTreeObject::getChildren);
aa.getColumns().setAll(nom_application,descrip_application,nom_du_projet);
aa.setRoot(root2);
aa.setShowRoot(false);
aa.setEditable(editable);
aa.getColumns().setAll(nom_application,descrip_application,nom_du_projet);
}
private void get_application_list_to_tree_table(String userlog, ObservableList<application_documenter> apps) {
// TODO Auto-generated method stub
try {
jdbc.setConnection();
Statement stm=jdbc.setConnection().createStatement();
String strcheck="select nom_app,app_descrip,nom_projet from application,projet where (application.id_projet=projet.id) and application.id in (select Id_app from collab_app where Id_collab_samp=(select id from utilisateur where username="+'"'+userlog+'"'+"))";
ResultSet res = stm.executeQuery(strcheck);
while (res.next()) {
apps.add(new application_documenter(res.getString("nom_app"),res.getString("app_descrip"),res.getString("nom_projet")));
}
jdbc.setConnection().close();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
void application_filter(JFXTextField zz,JFXTreeTableView<application_documenter> deltree) {
zz.textProperty().addListener((o,oldVal,newVal)->{
deltree.setPredicate(pro -> pro.getValue().nom_app.get().contains(newVal)
|| pro.getValue().app_descrip.get().contains(newVal)
|| pro.getValue().project_name.get().contains(newVal)
);
});
}
}
| 4,410 | 0.714512 | 0.712018 | 116 | 37.017242 | 42.927158 | 262 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.422414 | false | false | 14 |
5dfd0c3431f33f0e630034c73acf57c76e27e7b0 | 31,559,419,729,156 | 3a7e07fc8d6ca3c35c2a2891cdd0aa3130f57a7a | /src/main/java/tp1/iterator/GraphIterator.java | 6fdeddd7c93f9f5d3fd7c34ddf375f1c988f06e0 | [] | no_license | YannickMontes/4a-isi3-tp1-2016-2017-groupe-1-lathuiliere_montes | https://github.com/YannickMontes/4a-isi3-tp1-2016-2017-groupe-1-lathuiliere_montes | d824d8d48fe6899ae973aee6f7eb1ccc793fc384 | 16e1c49ee2dcaf62a1556f72b5c110a8aeadcb64 | refs/heads/master | 2021-01-23T08:34:34.030000 | 2017-03-24T07:36:17 | 2017-03-24T07:36:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tp1.iterator;
import tp1.graph.IGraph;
import tp1.graph.node.Node;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* @author yoannlathuiliere
*/
public abstract class GraphIterator implements Iterator<Node> {
protected IGraph graph; // Graph reference to an intefarce (in order to support both Graph and UndirectedGraph)
protected Node sourceNode; // Node where to start traitments
protected List<Node> markedNodes;
public GraphIterator(IGraph graph, Node sourceNode) {
super();
// Init attributes
this.graph = graph;
this.sourceNode = sourceNode;
this.markedNodes = new ArrayList<Node>();
}
@Override
public Node next() {
Node next = deleteFromQueue(); // Take a node from the list
List<Node> adjacentNodes = graph.getAdjNodes(next);
adjacentNodes.stream()
.filter(node -> !markedNodes.contains(node))
.forEach(node -> {
markedNodes.add(node);
addToQueue(node);
});
return next;
}
public abstract void addToQueue(Node node);
public abstract Node deleteFromQueue();
}
| UTF-8 | Java | 1,453 | java | GraphIterator.java | Java | [
{
"context": "rt java.util.stream.Collectors;\n\n/**\n *\n * @author yoannlathuiliere\n */\npublic abstract class GraphIterator implement",
"end": 410,
"score": 0.9988147020339966,
"start": 394,
"tag": "USERNAME",
"value": "yoannlathuiliere"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tp1.iterator;
import tp1.graph.IGraph;
import tp1.graph.node.Node;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
/**
*
* @author yoannlathuiliere
*/
public abstract class GraphIterator implements Iterator<Node> {
protected IGraph graph; // Graph reference to an intefarce (in order to support both Graph and UndirectedGraph)
protected Node sourceNode; // Node where to start traitments
protected List<Node> markedNodes;
public GraphIterator(IGraph graph, Node sourceNode) {
super();
// Init attributes
this.graph = graph;
this.sourceNode = sourceNode;
this.markedNodes = new ArrayList<Node>();
}
@Override
public Node next() {
Node next = deleteFromQueue(); // Take a node from the list
List<Node> adjacentNodes = graph.getAdjNodes(next);
adjacentNodes.stream()
.filter(node -> !markedNodes.contains(node))
.forEach(node -> {
markedNodes.add(node);
addToQueue(node);
});
return next;
}
public abstract void addToQueue(Node node);
public abstract Node deleteFromQueue();
}
| 1,453 | 0.650379 | 0.648314 | 52 | 26.942308 | 25.055641 | 115 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 14 |
ec1d5984a65a9e0d4ffe2a7971e8701e90258529 | 26,061,861,617,969 | e7f5346998bc1ff7382a2f185db66439809868b2 | /geotk-xml-ebrim/src/main/java/org/geotoolkit/ebrim/xml/v300/NotificationType.java | 664cb81ba189ea3082aaa463e5490f7af0393749 | [] | no_license | Geomatys/geotoolkit | https://github.com/Geomatys/geotoolkit | 02f9c8fe238353150ed38619d4861ba0af075917 | b9fd93908d0350b3fad0d59f74c5c9670b83db94 | refs/heads/main | 2023-08-16T19:43:42.347000 | 2023-08-14T16:15:17 | 2023-08-14T16:15:17 | 21,858,951 | 48 | 32 | null | false | 2023-09-14T19:36:37 | 2014-07-15T12:37:35 | 2023-09-02T22:55:53 | 2023-09-14T19:36:36 | 90,761 | 47 | 26 | 11 | Java | false | false | /*
* Geotoolkit - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2008 - 2009, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotoolkit.ebrim.xml.v300;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
/**
* Notification of registry events.
*
* <p>Java class for NotificationType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="NotificationType">
* <complexContent>
* <extension base="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}RegistryObjectType">
* <sequence>
* <element ref="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}RegistryObjectList"/>
* </sequence>
* <attribute name="subscription" use="required" type="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}referenceURI" />
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
* @module
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NotificationType", propOrder = {
"registryObjectList"
})
@XmlRootElement(name = "Notification")
public class NotificationType extends RegistryObjectType {
@XmlElement(name = "RegistryObjectList", required = true)
private RegistryObjectListType registryObjectList;
@XmlAttribute(required = true)
private String subscription;
/**
* Gets the value of the registryObjectList property.
*/
public RegistryObjectListType getRegistryObjectList() {
return registryObjectList;
}
/**
* Sets the value of the registryObjectList property.
*
*/
public void setRegistryObjectList(final RegistryObjectListType value) {
this.registryObjectList = value;
}
/**
* Gets the value of the subscription property.
*/
public String getSubscription() {
return subscription;
}
/**
* Sets the value of the subscription property.
*/
public void setSubscription(final String value) {
this.subscription = value;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(super.toString());
if (registryObjectList != null) {
sb.append("registryObjectList:").append(registryObjectList).append('\n');
}
if (subscription != null) {
sb.append("subscription:").append(subscription).append('\n');
}
return sb.toString();
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof NotificationType && super.equals(obj)) {
final NotificationType that = (NotificationType) obj;
return Objects.equals(this.registryObjectList, that.registryObjectList) &&
Objects.equals(this.subscription, that.subscription);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + super.hashCode();
hash = 31 * hash + (this.registryObjectList != null ? this.registryObjectList.hashCode() : 0);
hash = 31 * hash + (this.subscription != null ? this.subscription.hashCode() : 0);
return hash;
}
}
| UTF-8 | Java | 4,058 | java | NotificationType.java | Java | [
{
"context": "ttp://www.geotoolkit.org\n *\n * (C) 2008 - 2009, Geomatys\n *\n * This library is free software; you can r",
"end": 120,
"score": 0.9950355887413025,
"start": 112,
"tag": "NAME",
"value": "Geomatys"
}
] | null | [] | /*
* Geotoolkit - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2008 - 2009, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotoolkit.ebrim.xml.v300;
import java.util.Objects;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlElement;
import jakarta.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlType;
/**
* Notification of registry events.
*
* <p>Java class for NotificationType complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="NotificationType">
* <complexContent>
* <extension base="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}RegistryObjectType">
* <sequence>
* <element ref="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}RegistryObjectList"/>
* </sequence>
* <attribute name="subscription" use="required" type="{urn:oasis:names:tc:ebxml-regrep:xsd:rim:3.0}referenceURI" />
* </extension>
* </complexContent>
* </complexType>
* </pre>
*
*
* @module
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "NotificationType", propOrder = {
"registryObjectList"
})
@XmlRootElement(name = "Notification")
public class NotificationType extends RegistryObjectType {
@XmlElement(name = "RegistryObjectList", required = true)
private RegistryObjectListType registryObjectList;
@XmlAttribute(required = true)
private String subscription;
/**
* Gets the value of the registryObjectList property.
*/
public RegistryObjectListType getRegistryObjectList() {
return registryObjectList;
}
/**
* Sets the value of the registryObjectList property.
*
*/
public void setRegistryObjectList(final RegistryObjectListType value) {
this.registryObjectList = value;
}
/**
* Gets the value of the subscription property.
*/
public String getSubscription() {
return subscription;
}
/**
* Sets the value of the subscription property.
*/
public void setSubscription(final String value) {
this.subscription = value;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder(super.toString());
if (registryObjectList != null) {
sb.append("registryObjectList:").append(registryObjectList).append('\n');
}
if (subscription != null) {
sb.append("subscription:").append(subscription).append('\n');
}
return sb.toString();
}
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof NotificationType && super.equals(obj)) {
final NotificationType that = (NotificationType) obj;
return Objects.equals(this.registryObjectList, that.registryObjectList) &&
Objects.equals(this.subscription, that.subscription);
}
return false;
}
@Override
public int hashCode() {
int hash = 7;
hash = 31 * hash + super.hashCode();
hash = 31 * hash + (this.registryObjectList != null ? this.registryObjectList.hashCode() : 0);
hash = 31 * hash + (this.subscription != null ? this.subscription.hashCode() : 0);
return hash;
}
}
| 4,058 | 0.663135 | 0.656235 | 125 | 31.464001 | 28.548779 | 125 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.376 | false | false | 14 |
6a0978a7bce131142e31d3c4fe7c13dcf0daf019 | 20,366,734,933,880 | 866a235448d7b925a45deb8f4a4d0babdc8c6386 | /src/test/SimpleQueue.java | f9ef0dd78c3c792251ea5035560fa8a011bfe01e | [] | no_license | kevinleary/Motionpoint-Code-Sample | https://github.com/kevinleary/Motionpoint-Code-Sample | 810ffacdd89ed700b5844d68f1fbd0253a6cc7d5 | 47be35b08a63a831d6d2c91e7e9f2b33f127389b | refs/heads/master | 2020-05-03T10:05:53.827000 | 2019-04-22T18:45:25 | 2019-04-22T18:45:25 | 178,571,346 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package main;
public class SimpleQueue implements SimpleDataStructures{
//SimpleDataStructures queue = new SimpleQueue();
private int back = -1; //trails behind
private int front = 0;
private int count = 0;
int arr[] = new int[MAX];
public boolean isEmpty() {
if (count <= 0)
return true;
else
return false;
}
public void add(int x) {
if (front == (MAX)) {
System.out.println("Queue Overflow!");
}
else {
//back = (back+1);
arr[++back] = x;
count++;
System.out.println(x + " was pushed on to the queue");
}
}
public int remove() {
if (isEmpty()) {
System.out.println("Queue underflow!");
return -1;
}
else {
//front = (front+1);
//front++;
--count;
return arr[front++];
}
}
}
| UTF-8 | Java | 814 | java | SimpleQueue.java | Java | [] | null | [] | package main;
public class SimpleQueue implements SimpleDataStructures{
//SimpleDataStructures queue = new SimpleQueue();
private int back = -1; //trails behind
private int front = 0;
private int count = 0;
int arr[] = new int[MAX];
public boolean isEmpty() {
if (count <= 0)
return true;
else
return false;
}
public void add(int x) {
if (front == (MAX)) {
System.out.println("Queue Overflow!");
}
else {
//back = (back+1);
arr[++back] = x;
count++;
System.out.println(x + " was pushed on to the queue");
}
}
public int remove() {
if (isEmpty()) {
System.out.println("Queue underflow!");
return -1;
}
else {
//front = (front+1);
//front++;
--count;
return arr[front++];
}
}
}
| 814 | 0.551597 | 0.542998 | 48 | 14.958333 | 15.3785 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.041667 | false | false | 14 |
50c47762b55dd0b1dc3d16c22b4b1631a43d7127 | 34,248,069,218,397 | 9c9acc5a95ffd811bedb9620be2ee1ffb69f05bd | /TestDemo96.java | 73b8b0f490888e0e65321da210d61e02ca72d4ff | [] | no_license | Ezaki-Yuko/LearnJava | https://github.com/Ezaki-Yuko/LearnJava | 70c92376f4963dac7aa005223c2a1e4261f2f47c | 280e3880312c756f6407b1e9ac76960c7883f49f | refs/heads/master | 2021-01-16T05:34:20.980000 | 2020-07-20T00:46:42 | 2020-07-20T00:46:42 | 242,992,508 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* @PackgeName: PACKAGE_NAME
* @ClassName: TestDemo96
* @Author: LENOVO
* Date: 2020/5/31 11:41
* project name: 20200529
* @Version:
* @Description:
*/
public class TestDemo96 {
public static void main(String[] args) throws SQLException {
DataSource dataSource =new MysqlDataSource();
((MysqlDataSource)dataSource).setURL("jdbc:mysql://127.0.0.1:3306/java16_0531?characterEncoding=utf-8&useSSL=true");
((MysqlDataSource)dataSource).setUser("root");
((MysqlDataSource)dataSource).setPassword("root");
Connection connection=dataSource.getConnection();
String sql="select * from student";
PreparedStatement statement=connection.prepareStatement(sql);
ResultSet resultSet=statement.executeQuery();
//遍历过程类似于迭代器
//结果集相当于一张表 这个表里有很多行每一行是一条记录(又包含很多列)
//next() 一方面是判定当前是否存在下一行,另一方面,如果存在下一行就直接获取到这一行)
//可以直观的把resultSet想象成一个光标
while(resultSet.next()){
//resultSet的光标指向当前行,就可以把当前行的列数据都获取到
//当前表中的每一行包含三个列 根据列名获取列数据
int id=resultSet.getInt("id");
String name=resultSet.getString("name");
int classId=resultSet.getInt("classId");
System.out.println(" id : "+id+" name : "+name+" classId : "+classId);
}
resultSet.close();
statement.close();
connection.close();
//1.创建DataSource对象
//2.创建Connection对象和数据库建立连接
//3.借助PrePareStatement拼装SQL语句
//4.执行SQL语句
//5.遍历结果
//6.关闭释放资源
}
}
| UTF-8 | Java | 2,082 | java | TestDemo96.java | Java | [
{
"context": "PACKAGE_NAME\n * @ClassName: TestDemo96\n * @Author: LENOVO\n * Date: 2020/5/31 11:41\n * project name: 2020052",
"end": 282,
"score": 0.9977073669433594,
"start": 276,
"tag": "USERNAME",
"value": "LENOVO"
},
{
"context": "(MysqlDataSource)dataSource).setURL(\"jdbc:mysql://127.0.0.1:3306/java16_0531?characterEncoding=utf-8&useSSL=t",
"end": 581,
"score": 0.9936990737915039,
"start": 572,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
},
{
"context": " ((MysqlDataSource)dataSource).setPassword(\"root\");\n Connection connection=dataSource.getCo",
"end": 749,
"score": 0.9349219799041748,
"start": 745,
"tag": "PASSWORD",
"value": "root"
}
] | null | [] | import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
/**
* @PackgeName: PACKAGE_NAME
* @ClassName: TestDemo96
* @Author: LENOVO
* Date: 2020/5/31 11:41
* project name: 20200529
* @Version:
* @Description:
*/
public class TestDemo96 {
public static void main(String[] args) throws SQLException {
DataSource dataSource =new MysqlDataSource();
((MysqlDataSource)dataSource).setURL("jdbc:mysql://127.0.0.1:3306/java16_0531?characterEncoding=utf-8&useSSL=true");
((MysqlDataSource)dataSource).setUser("root");
((MysqlDataSource)dataSource).setPassword("<PASSWORD>");
Connection connection=dataSource.getConnection();
String sql="select * from student";
PreparedStatement statement=connection.prepareStatement(sql);
ResultSet resultSet=statement.executeQuery();
//遍历过程类似于迭代器
//结果集相当于一张表 这个表里有很多行每一行是一条记录(又包含很多列)
//next() 一方面是判定当前是否存在下一行,另一方面,如果存在下一行就直接获取到这一行)
//可以直观的把resultSet想象成一个光标
while(resultSet.next()){
//resultSet的光标指向当前行,就可以把当前行的列数据都获取到
//当前表中的每一行包含三个列 根据列名获取列数据
int id=resultSet.getInt("id");
String name=resultSet.getString("name");
int classId=resultSet.getInt("classId");
System.out.println(" id : "+id+" name : "+name+" classId : "+classId);
}
resultSet.close();
statement.close();
connection.close();
//1.创建DataSource对象
//2.创建Connection对象和数据库建立连接
//3.借助PrePareStatement拼装SQL语句
//4.执行SQL语句
//5.遍历结果
//6.关闭释放资源
}
}
| 2,088 | 0.65442 | 0.62744 | 52 | 32.5 | 23.406525 | 124 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.461538 | false | false | 14 |
3897bd7d2dca0745ea1f8e96ea72a7238c8b932e | 30,846,455,165,351 | a98228368a22785fd4d2920067d1fe4ae95aeb3c | /FileIOExample/src/FileIOExampleRead.java | 747cb3af837933d5dcaffc2cb6739a06f29a5a99 | [] | no_license | david-amos/Java1 | https://github.com/david-amos/Java1 | 8d484f2d11e5f09d0dfdeba20f9f06a7862ea8ce | 3b48c229576107345c2751f33baf2fc9535b6dd6 | refs/heads/master | 2020-09-19T08:23:07.310000 | 2020-02-11T14:07:19 | 2020-02-11T14:07:19 | 224,212,125 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
public class FileIOExampleRead {
static String iString;
static String iFirstName, iLastName;
static int iHours;
static double iRate;
static double cPay;
static String oPay;
static Scanner payrollScanner;
static PrintWriter pw;
static boolean eof = false;
static int cEmpCtr = 0;
static double cEmpPayTot = 0;
public static void main(String[] args){
init();
while(!eof){
calcs();
output();
input();
}
totals();
pw.close();
}
public static void init(){
try{
payrollScanner = new Scanner(new File("payroll.dat"));
}
catch (FileNotFoundException e1){
System.out.println("File error");
System.exit(1); // end the program
}
try{
pw = new PrintWriter(new File("payroll_report.prt"));
}
catch(FileNotFoundException e){
System.out.println("Output file error");
System.exit(1);
}
pw.format("%-25s%5s%-25s%5s%5s%5s%5s%5s%10s%n%n", "First Name", " ", "Last Name", " ", "Hours", " ", "Rate", " ",
"Pay Amount");
input();
}
public static void input(){
String record;
if (payrollScanner.hasNext()){
record = payrollScanner.nextLine();
iFirstName = record.substring(0,25);
iLastName = record.substring(25,50);
iString = record.substring(50,53);
iHours = Integer.parseInt(iString);
iString = record.substring(53,58);
iRate = Double.parseDouble(iString);
}
else{
eof = true;
}
}
public static void calcs(){
cPay = iHours * iRate;
cEmpCtr ++;
cEmpPayTot += cPay;
}
public static void output(){
pw.format("%-25s%5s%-25s%5s%5d%5s%5.2f%5s%10.2f%n%n", iFirstName, " ", iLastName, " ",
iHours, " ", iRate, " ", cPay);
}
public static void totals(){
DecimalFormat dfEmpCtr = new DecimalFormat("#,##0");
DecimalFormat dfEmpPayTot = new DecimalFormat("$##,###.00");
String oEmpCtr = dfEmpCtr.format(cEmpCtr);
String oEmpPayTot = dfEmpPayTot.format(cEmpPayTot);
pw.format("%n%21s%5s%54s%10s%n", "Number of Employees: ", oEmpCtr, " ", oEmpPayTot);
}
}
| UTF-8 | Java | 2,545 | java | FileIOExampleRead.java | Java | [] | null | [] | import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
public class FileIOExampleRead {
static String iString;
static String iFirstName, iLastName;
static int iHours;
static double iRate;
static double cPay;
static String oPay;
static Scanner payrollScanner;
static PrintWriter pw;
static boolean eof = false;
static int cEmpCtr = 0;
static double cEmpPayTot = 0;
public static void main(String[] args){
init();
while(!eof){
calcs();
output();
input();
}
totals();
pw.close();
}
public static void init(){
try{
payrollScanner = new Scanner(new File("payroll.dat"));
}
catch (FileNotFoundException e1){
System.out.println("File error");
System.exit(1); // end the program
}
try{
pw = new PrintWriter(new File("payroll_report.prt"));
}
catch(FileNotFoundException e){
System.out.println("Output file error");
System.exit(1);
}
pw.format("%-25s%5s%-25s%5s%5s%5s%5s%5s%10s%n%n", "First Name", " ", "Last Name", " ", "Hours", " ", "Rate", " ",
"Pay Amount");
input();
}
public static void input(){
String record;
if (payrollScanner.hasNext()){
record = payrollScanner.nextLine();
iFirstName = record.substring(0,25);
iLastName = record.substring(25,50);
iString = record.substring(50,53);
iHours = Integer.parseInt(iString);
iString = record.substring(53,58);
iRate = Double.parseDouble(iString);
}
else{
eof = true;
}
}
public static void calcs(){
cPay = iHours * iRate;
cEmpCtr ++;
cEmpPayTot += cPay;
}
public static void output(){
pw.format("%-25s%5s%-25s%5s%5d%5s%5.2f%5s%10.2f%n%n", iFirstName, " ", iLastName, " ",
iHours, " ", iRate, " ", cPay);
}
public static void totals(){
DecimalFormat dfEmpCtr = new DecimalFormat("#,##0");
DecimalFormat dfEmpPayTot = new DecimalFormat("$##,###.00");
String oEmpCtr = dfEmpCtr.format(cEmpCtr);
String oEmpPayTot = dfEmpPayTot.format(cEmpPayTot);
pw.format("%n%21s%5s%54s%10s%n", "Number of Employees: ", oEmpCtr, " ", oEmpPayTot);
}
}
| 2,545 | 0.551277 | 0.529273 | 91 | 26.967033 | 22.841764 | 121 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.846154 | false | false | 14 |
ea7dd1fcde071da70a899c99ca7434c4d3be8193 | 22,076,131,934,718 | 29f9c39eaef92f74b25c4c78fddc0e329a7d7bb0 | /EchoService/src/clientes/Cliente.java | b6da8903bbc8601d29aa55950e3b5c36f50ea3ce | [] | no_license | manoelnetom/inf012 | https://github.com/manoelnetom/inf012 | ea004317fbcc2826b60600db147495c145c68b3a | 0224a63f189b60673d2f6f535bd56fa6e871fc17 | refs/heads/master | 2021-06-04T10:55:25.483000 | 2021-05-24T23:25:06 | 2021-05-24T23:25:06 | 32,333,668 | 8 | 12 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package clientes;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
/**
*
* @author ManoelNeto
*/
public class Cliente {
public static void main(String[] args) throws Exception{
Socket cli=new Socket("127.0.0.1",1234);
Scanner ler=new Scanner(cli.getInputStream());
PrintWriter esc=new PrintWriter(cli.getOutputStream(),true);
esc.println("teste de msg em minusculo");
String msgMaisculo= ler.nextLine();
System.out.println(msgMaisculo);
}
}
| UTF-8 | Java | 774 | java | Cliente.java | Java | [
{
"context": "cket;\nimport java.util.Scanner;\n\n/**\n *\n * @author ManoelNeto\n */\npublic class Cliente {\n public static void",
"end": 312,
"score": 0.9988864064216614,
"start": 302,
"tag": "NAME",
"value": "ManoelNeto"
},
{
"context": "xception{\n \n Socket cli=new Socket(\"127.0.0.1\",1234);\n Scanner ler=new Scanner(cli.getI",
"end": 450,
"score": 0.9988706111907959,
"start": 441,
"tag": "IP_ADDRESS",
"value": "127.0.0.1"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package clientes;
import java.io.PrintWriter;
import java.net.Socket;
import java.util.Scanner;
/**
*
* @author ManoelNeto
*/
public class Cliente {
public static void main(String[] args) throws Exception{
Socket cli=new Socket("127.0.0.1",1234);
Scanner ler=new Scanner(cli.getInputStream());
PrintWriter esc=new PrintWriter(cli.getOutputStream(),true);
esc.println("teste de msg em minusculo");
String msgMaisculo= ler.nextLine();
System.out.println(msgMaisculo);
}
}
| 774 | 0.639535 | 0.626615 | 32 | 23.1875 | 23.165758 | 79 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.46875 | false | false | 14 |
0af1caebf4a97d1492ed35181d53f8dd084899ce | 14,594,298,933,241 | 026c0bbc8f4a41b19b7ff65d5e3dab8ffea18b88 | /Gralliton/src/client/servlet/DetailledRecipeServlet.java | 09fc15a62c730a84133a92f87e805ba236f96120 | [] | no_license | fmillerwork/MM_Project | https://github.com/fmillerwork/MM_Project | 4b287a99db2e25720fbabc6742746c80eeb8cf98 | 279f688ef60b70064fdc6e43449a23c5d7e779f5 | refs/heads/master | 2023-02-17T11:11:38.914000 | 2021-01-20T16:25:46 | 2021-01-20T16:25:46 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package client.servlet;
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;
import javax.servlet.http.HttpSession;
import webservice.WS;
import webservice.WebServiceSOAPService;
@WebServlet("/DetailledRecipeServlet")
public class DetailledRecipeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public DetailledRecipeServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if(request.getParameter("recipeId") != null) {
WS stub = new WebServiceSOAPService().getWSPort();
int recipeId = Integer.parseInt(request.getParameter("recipeId"));
request.setAttribute("recipe",stub.getRecipeById(recipeId));
request.setAttribute("steps",stub.getStepsById(recipeId));
request.setAttribute("difficulty",stub.getDifficultyById(recipeId));
request.setAttribute("tags",stub.getTagsById(recipeId));
request.setAttribute("type",stub.getTypeById(recipeId));
request.setAttribute("ingredients",stub.getIngredientsById(recipeId));
request.setAttribute("ustensils",stub.getUstensilsById(recipeId));
request.setAttribute("account",stub.getAccountById(recipeId));
HttpSession session = request.getSession();
String userLogin = (String) session.getAttribute("userLogin");
if(userLogin != null) { // est connectÚ
if(stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId)) { // est dÚjÓ dans les favoris
request.setAttribute("isFavorite",true);
}
else request.setAttribute("isFavorite",false);
}
}
this.getServletContext().getRequestDispatcher("/WEB-INF/detailledRecipe.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
String userLogin = (String) session.getAttribute("userLogin");
WS stub = new WebServiceSOAPService().getWSPort();
int userId = stub.getCurrentAccountId(userLogin);
if(userLogin != null && request.getParameter("recipeIdAdd") != null) { // Utilisateur est connect´┐Ż et ajout´┐Ż favoris et selectionn´┐Ż
int recipeId = Integer.parseInt(request.getParameter("recipeIdAdd"));
if(!stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId))
stub.addFavorite(userId,recipeId);
}
else if(userLogin != null && request.getParameter("recipeIdDel") != null) { // Utilisateur est connect´┐Ż et suppression favoris et selectionn´┐Ż
int recipeId = Integer.parseInt(request.getParameter("recipeIdDel"));
if(stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId))
stub.removeFavorite(userId,recipeId);
}
doGet(request, response);
}
}
| IBM852 | Java | 3,025 | java | DetailledRecipeServlet.java | Java | [] | null | [] | package client.servlet;
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;
import javax.servlet.http.HttpSession;
import webservice.WS;
import webservice.WebServiceSOAPService;
@WebServlet("/DetailledRecipeServlet")
public class DetailledRecipeServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
public DetailledRecipeServlet() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if(request.getParameter("recipeId") != null) {
WS stub = new WebServiceSOAPService().getWSPort();
int recipeId = Integer.parseInt(request.getParameter("recipeId"));
request.setAttribute("recipe",stub.getRecipeById(recipeId));
request.setAttribute("steps",stub.getStepsById(recipeId));
request.setAttribute("difficulty",stub.getDifficultyById(recipeId));
request.setAttribute("tags",stub.getTagsById(recipeId));
request.setAttribute("type",stub.getTypeById(recipeId));
request.setAttribute("ingredients",stub.getIngredientsById(recipeId));
request.setAttribute("ustensils",stub.getUstensilsById(recipeId));
request.setAttribute("account",stub.getAccountById(recipeId));
HttpSession session = request.getSession();
String userLogin = (String) session.getAttribute("userLogin");
if(userLogin != null) { // est connectÚ
if(stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId)) { // est dÚjÓ dans les favoris
request.setAttribute("isFavorite",true);
}
else request.setAttribute("isFavorite",false);
}
}
this.getServletContext().getRequestDispatcher("/WEB-INF/detailledRecipe.jsp").forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
HttpSession session = request.getSession();
String userLogin = (String) session.getAttribute("userLogin");
WS stub = new WebServiceSOAPService().getWSPort();
int userId = stub.getCurrentAccountId(userLogin);
if(userLogin != null && request.getParameter("recipeIdAdd") != null) { // Utilisateur est connect´┐Ż et ajout´┐Ż favoris et selectionn´┐Ż
int recipeId = Integer.parseInt(request.getParameter("recipeIdAdd"));
if(!stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId))
stub.addFavorite(userId,recipeId);
}
else if(userLogin != null && request.getParameter("recipeIdDel") != null) { // Utilisateur est connect´┐Ż et suppression favoris et selectionn´┐Ż
int recipeId = Integer.parseInt(request.getParameter("recipeIdDel"));
if(stub.isFavorite(stub.getCurrentAccountId(userLogin), recipeId))
stub.removeFavorite(userId,recipeId);
}
doGet(request, response);
}
}
| 3,025 | 0.755829 | 0.755496 | 78 | 37.487179 | 35.268475 | 147 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.474359 | false | false | 14 |
5b7fec215848e07a80d5da470bd009e30af42e99 | 15,960,098,534,859 | a4967dd4236b69f084dffda7efc1f18237c5c48a | /elasticsearch-client/src/main/java/com/deleidos/analytics/elasticsearch/client/ElasticsearchQueryResult.java | bb7207134a86c17129498e5618417b03819cef4d | [
"Apache-2.0"
] | permissive | deleidos/de-pipeline-tool | https://github.com/deleidos/de-pipeline-tool | 924f939632fa743bd17f8bd384a967f65f3e17bd | cbe7dd101b6c75f94256de48a6285b341c84dfde | refs/heads/master | 2020-04-12T08:16:44.447000 | 2017-08-30T21:19:23 | 2017-08-30T21:19:23 | 63,269,862 | 1 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.deleidos.analytics.elasticsearch.client;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* A single query result hit.
*
* Includes convenience methods for getting typed data.
*
* @author vernona
*/
@Deprecated
public class ElasticsearchQueryResult {
private String id;
private Map<String, List<Object>> fieldValues;
/**
* Constructor.
*
* @param id
* @param fieldValues
*/
public ElasticsearchQueryResult(String id, Map<String, List<Object>> fieldValues) {
this.id = id;
this.fieldValues = fieldValues;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single string value.
*
* @param fieldName
* @return
*/
public String getStringValue(String fieldName) {
String value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = list.get(0).toString(); // Calling toString on a String returns the String itself.
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single integer value.
*
* @param fieldName
* @return
*/
public Integer getIntegerValue(String fieldName) {
Integer value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = (Integer) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single long value.
*
* @param fieldName
* @return
*/
public Long getLongValue(String fieldName) {
Long value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
System.out.println(list.get(0).getClass().getName());
value = (Long) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single double value.
*
* @param fieldName
* @return
*/
public Double getDoubleValue(String fieldName) {
Double value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = (Double) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of strings.
*
* @param fieldName
* @return
*/
public List<String> getStringList(String fieldName) {
List<String> stringList = new ArrayList<String>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
stringList.add(o.toString());
}
}
return stringList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of integers.
*
* @param fieldName
* @return
*/
public List<Integer> getIntegerList(String fieldName) {
List<Integer> intList = new ArrayList<Integer>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
intList.add(Integer.parseInt(o.toString()));
}
}
return intList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of longs.
*
* @param fieldName
* @return
*/
public List<Long> getLongList(String fieldName) {
List<Long> longList = new ArrayList<Long>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
longList.add((Long.parseLong(o.toString())));
}
}
return longList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of doubles.
*
* @param fieldName
* @return
*/
public List<Double> getDoubleList(String fieldName) {
List<Double> doubleList = new ArrayList<Double>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
doubleList.add(Double.parseDouble(o.toString()));
}
}
return doubleList;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Map<String, List<Object>> getFieldValues() {
return fieldValues;
}
public void setFieldValues(Map<String, List<Object>> fieldValues) {
this.fieldValues = fieldValues;
}
@SuppressWarnings("unchecked")
public Map<String, Object> getPartialFieldObject() {
List<Object> values = getFieldValues().get("partial1");
return (Map<String, Object>) values.get(0);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
| UTF-8 | Java | 4,671 | java | ElasticsearchQueryResult.java | Java | [
{
"context": "nce methods for getting typed data.\n * \n * @author vernona\n */\n@Deprecated\npublic class ElasticsearchQueryRe",
"end": 302,
"score": 0.9964594841003418,
"start": 295,
"tag": "USERNAME",
"value": "vernona"
}
] | null | [] | package com.deleidos.analytics.elasticsearch.client;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
/**
* A single query result hit.
*
* Includes convenience methods for getting typed data.
*
* @author vernona
*/
@Deprecated
public class ElasticsearchQueryResult {
private String id;
private Map<String, List<Object>> fieldValues;
/**
* Constructor.
*
* @param id
* @param fieldValues
*/
public ElasticsearchQueryResult(String id, Map<String, List<Object>> fieldValues) {
this.id = id;
this.fieldValues = fieldValues;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single string value.
*
* @param fieldName
* @return
*/
public String getStringValue(String fieldName) {
String value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = list.get(0).toString(); // Calling toString on a String returns the String itself.
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single integer value.
*
* @param fieldName
* @return
*/
public Integer getIntegerValue(String fieldName) {
Integer value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = (Integer) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single long value.
*
* @param fieldName
* @return
*/
public Long getLongValue(String fieldName) {
Long value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
System.out.println(list.get(0).getClass().getName());
value = (Long) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a single double value.
*
* @param fieldName
* @return
*/
public Double getDoubleValue(String fieldName) {
Double value = null;
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
value = (Double) list.get(0);
}
return value;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of strings.
*
* @param fieldName
* @return
*/
public List<String> getStringList(String fieldName) {
List<String> stringList = new ArrayList<String>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
stringList.add(o.toString());
}
}
return stringList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of integers.
*
* @param fieldName
* @return
*/
public List<Integer> getIntegerList(String fieldName) {
List<Integer> intList = new ArrayList<Integer>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
intList.add(Integer.parseInt(o.toString()));
}
}
return intList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of longs.
*
* @param fieldName
* @return
*/
public List<Long> getLongList(String fieldName) {
List<Long> longList = new ArrayList<Long>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
longList.add((Long.parseLong(o.toString())));
}
}
return longList;
}
/**
* Convenience method for when the caller is expecting the results for the field to be a list of doubles.
*
* @param fieldName
* @return
*/
public List<Double> getDoubleList(String fieldName) {
List<Double> doubleList = new ArrayList<Double>();
List<Object> list = fieldValues.get(fieldName);
if (list != null && !list.isEmpty()) {
for (Object o : list) {
doubleList.add(Double.parseDouble(o.toString()));
}
}
return doubleList;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Map<String, List<Object>> getFieldValues() {
return fieldValues;
}
public void setFieldValues(Map<String, List<Object>> fieldValues) {
this.fieldValues = fieldValues;
}
@SuppressWarnings("unchecked")
public Map<String, Object> getPartialFieldObject() {
List<Object> values = getFieldValues().get("partial1");
return (Map<String, Object>) values.get(0);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this);
}
}
| 4,671 | 0.676086 | 0.674374 | 188 | 23.845745 | 26.548883 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.579787 | false | false | 14 |
865d16f0524f455b9e42b5744965d4f958767a75 | 29,008,209,171,685 | f8c8a1077c71eeb5e2e13e5a18e08e8fce3a72c0 | /forbes/src/com/forbes/mail/ForbesMailSender.java | d00d9cdba792f4e4d388bd76a581ac815d2430d8 | [] | no_license | snowriver/chijiao | https://github.com/snowriver/chijiao | ef39b46d7ff968cc56c3f037be44ff8b04132f3c | 1c3ff8b90e078c0e9f26b174a90282126c3e9e74 | refs/heads/master | 2020-05-19T16:06:44.658000 | 2009-10-18T13:58:28 | 2009-10-18T13:58:28 | 34,316,826 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.forbes.mail;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
public class ForbesMailSender {
private MimeMessage mimeMsg; // MIME邮件對象
private Session session; // 邮件會话對象
private Properties props = System.getProperties() ; // 系统属性
private boolean needAuth = true; // smtp是否需要認证
private String user ;
private String password;
public ForbesMailSender(String smtpHost, String userName, String password) {
props.put("mail.host", smtpHost);
props.put("mail.localhost", smtpHost);
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.localhost", smtpHost);
props.put("mail.smtp.auth", "true");
this.user = userName;
this.password = password;
}
public boolean doSend( ForbesMail mail ){
try {
session = Session.getDefaultInstance(props, null); // 获得邮件會话對象
mimeMsg = new MimeMessage(session);
mimeMsg.setFrom( new InternetAddress( mail.getFrom() ) );
List <String> toList = mail.getToList();
for( String to : toList ){
mimeMsg.setRecipient(Message.RecipientType.TO,
new InternetAddress(to));
}
List <String> copyToList = mail.getCopyToList();
for( String cc : toList ){
mimeMsg.setRecipient(Message.RecipientType.CC,
new InternetAddress(cc));
}
mimeMsg.setSubject( mail.getSubject() );
mimeMsg.setContent(mail.getMultipart());
mimeMsg.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect((String) props.get("mail.smtp.host"), user,password);
transport.sendMessage(mimeMsg, mimeMsg
.getRecipients(Message.RecipientType.TO));
//transport.send(mimeMsg);
//System.out.println("send mail sucess");
transport.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public static void main( String [] args ){
ForbesMailSender sender = new ForbesMailSender("smtp.163.com","xuxiaomin123","19830501");
ForbesMail mail = new ForbesMail();
mail.addBody("<a href='test.jsp'>邮件测试 </a>", mail.HTML_MAIL);
mail.setSubject("邮件测试");
mail.setFrom("746167@qq.com");
mail.addTo( "746167@qq.com" );
mail.addCopyTo( "746167@qq.com" );
sender.doSend( mail );
}
}
| GB18030 | Java | 2,384 | java | ForbesMailSender.java | Java | [
{
"context": "\r\n\tpublic ForbesMailSender(String smtpHost, String userName, String password) {\r\n\t\tprops.put(\"mail.host\", smt",
"end": 465,
"score": 0.7471806406974792,
"start": 457,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "rops.put(\"mail.smtp.auth\", \"true\");\r\n\t\tthis.user = userName;\r\n\t\tthis.password = password;\r\n\t}\r\n\t\r\n\tpublic boo",
"end": 717,
"score": 0.9994333386421204,
"start": 709,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "rue\");\r\n\t\tthis.user = userName;\r\n\t\tthis.password = password;\r\n\t}\r\n\t\r\n\tpublic boolean doSend( ForbesMail mail ",
"end": 746,
"score": 0.9992489814758301,
"start": 738,
"tag": "PASSWORD",
"value": "password"
},
{
"context": "der sender = new ForbesMailSender(\"smtp.163.com\",\"xuxiaomin123\",\"19830501\");\r\n\t\tForbesMail mail = new ForbesMail",
"end": 2025,
"score": 0.9994998574256897,
"start": 2013,
"tag": "USERNAME",
"value": "xuxiaomin123"
},
{
"context": "IL);\r\n\t\tmail.setSubject(\"邮件测试\");\r\n\t\tmail.setFrom(\"746167@qq.com\");\r\n\t\tmail.addTo( \"746167@qq.com\" );\r\n\t\tmail.addC",
"end": 2202,
"score": 0.9998971819877625,
"start": 2189,
"tag": "EMAIL",
"value": "746167@qq.com"
},
{
"context": "\n\t\tmail.setFrom(\"746167@qq.com\");\r\n\t\tmail.addTo( \"746167@qq.com\" );\r\n\t\tmail.addCopyTo( \"746167@qq.com\" );\r\n\t\tsend",
"end": 2235,
"score": 0.9999011158943176,
"start": 2222,
"tag": "EMAIL",
"value": "746167@qq.com"
},
{
"context": "ail.addTo( \"746167@qq.com\" );\r\n\t\tmail.addCopyTo( \"746167@qq.com\" );\r\n\t\tsender.doSend( mail );\r\n\t}\r\n}\r\n",
"end": 2273,
"score": 0.9998717308044434,
"start": 2260,
"tag": "EMAIL",
"value": "746167@qq.com"
}
] | null | [] | package com.forbes.mail;
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
public class ForbesMailSender {
private MimeMessage mimeMsg; // MIME邮件對象
private Session session; // 邮件會话對象
private Properties props = System.getProperties() ; // 系统属性
private boolean needAuth = true; // smtp是否需要認证
private String user ;
private String password;
public ForbesMailSender(String smtpHost, String userName, String password) {
props.put("mail.host", smtpHost);
props.put("mail.localhost", smtpHost);
props.put("mail.smtp.host", smtpHost);
props.put("mail.smtp.localhost", smtpHost);
props.put("mail.smtp.auth", "true");
this.user = userName;
this.password = <PASSWORD>;
}
public boolean doSend( ForbesMail mail ){
try {
session = Session.getDefaultInstance(props, null); // 获得邮件會话對象
mimeMsg = new MimeMessage(session);
mimeMsg.setFrom( new InternetAddress( mail.getFrom() ) );
List <String> toList = mail.getToList();
for( String to : toList ){
mimeMsg.setRecipient(Message.RecipientType.TO,
new InternetAddress(to));
}
List <String> copyToList = mail.getCopyToList();
for( String cc : toList ){
mimeMsg.setRecipient(Message.RecipientType.CC,
new InternetAddress(cc));
}
mimeMsg.setSubject( mail.getSubject() );
mimeMsg.setContent(mail.getMultipart());
mimeMsg.saveChanges();
Transport transport = session.getTransport("smtp");
transport.connect((String) props.get("mail.smtp.host"), user,password);
transport.sendMessage(mimeMsg, mimeMsg
.getRecipients(Message.RecipientType.TO));
//transport.send(mimeMsg);
//System.out.println("send mail sucess");
transport.close();
} catch (Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public static void main( String [] args ){
ForbesMailSender sender = new ForbesMailSender("smtp.163.com","xuxiaomin123","19830501");
ForbesMail mail = new ForbesMail();
mail.addBody("<a href='test.jsp'>邮件测试 </a>", mail.HTML_MAIL);
mail.setSubject("邮件测试");
mail.setFrom("<EMAIL>");
mail.addTo( "<EMAIL>" );
mail.addCopyTo( "<EMAIL>" );
sender.doSend( mail );
}
}
| 2,368 | 0.66436 | 0.650519 | 71 | 30.563381 | 20.943743 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.690141 | false | false | 14 |
04f9e6c9f17c45c561807f512b6b995e489a4b9a | 12,068,858,136,062 | efde0434165abb3a9e9e52a05d93ca72e3869134 | /service/customer/src/main/java/banger/dao/impl/CusProceduresCallDao.java | d4ff9a09f78a20baec5bb979dc03b15055a10d10 | [
"MIT"
] | permissive | baggio0128/colp | https://github.com/baggio0128/colp | 724571723a59b093d8c59f389b36175b402a09d2 | e7393f4c0f1d2feddf45f86a6741d3d5f87f2f93 | refs/heads/master | 2016-06-13T14:31:43.191000 | 2015-12-28T16:23:58 | 2015-12-28T16:23:58 | 48,700,390 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package banger.dao.impl;
import banger.dao.intf.ICusProceduresCallDao;
import banger.domain.customer.CrmPerCustomer;
import banger.framework.dao.PageSizeDao;
/**
* @author zhangfp
* @version $Id: CusProceduresCallDao v 0.1 ${} 10:00 zhangfp Exp $
*/
public class CusProceduresCallDao extends PageSizeDao<CrmPerCustomer> implements ICusProceduresCallDao {
/**
* 字典表存储过程调用(导入字典表数据)
*/
public void importDicInfo(){
this.execute("importDicInfo");
}
/**
* 客户表存储过程调用(导入客户表数据)
*/
public void importCustomerInfo(){
this.execute("importCustomerInfo");
}
/**
* 家庭信息存储过程调用(导入个人客户家庭信息数据)
*/
public void importPerCustomerFamilyInfo(){
this.execute("importPerCustomerFamilyInfo");
}
/**
*个人客户资产负债情况存储过程调用
*/
public void importPerCustomerAsset(){
this.execute("importPerCustomerAsset");
}
/**
* 企业客户单位关键人信息存储过程调用
*/
public void importCoCustomerKeyman(){
this.execute("importCoCustomerKeyman");
}
/**
* 企业客户股权结构信息存储过程调用
*/
public void importCoCustomerSturc(){
this.execute("importCoCustomerSturc");
}
/**
* 企业客户对外投资信息存储过程
*/
public void importCoCustomerInvest(){
this.execute("importCoCustomerInvest");
}
/**
* 清空指定表的数据
* @param tableName
*/
public void cleanRecords(String tableName){
this.execute("cleanRecords",tableName);
}
/**
* 待办事项的业务检查存储过程调用
*/
public void importBusinessCheckInfo(){
this.execute("importBusinessCheckInfo");
}
/**
* 待办事项的客户检查存储过程调用
*/
public void importCustomerCheckInfo(){
this.execute("importCustomerCheckInfo");
}
public void importCustomerAFFILIATEDInfo() {
this.execute("importCustomerAFFILIATEDInfo");
}
public void importGrKhxx(){
this.execute("importGrKhxx");
}
public void importQyKhxx(){
this.execute("importQyKhxx");
}
}
| UTF-8 | Java | 2,322 | java | CusProceduresCallDao.java | Java | [
{
"context": " banger.framework.dao.PageSizeDao;\n\n/**\n * @author zhangfp\n * @version $Id: CusProceduresCallDao v 0.1 ${} 1",
"end": 182,
"score": 0.9997212290763855,
"start": 175,
"tag": "USERNAME",
"value": "zhangfp"
}
] | null | [] | package banger.dao.impl;
import banger.dao.intf.ICusProceduresCallDao;
import banger.domain.customer.CrmPerCustomer;
import banger.framework.dao.PageSizeDao;
/**
* @author zhangfp
* @version $Id: CusProceduresCallDao v 0.1 ${} 10:00 zhangfp Exp $
*/
public class CusProceduresCallDao extends PageSizeDao<CrmPerCustomer> implements ICusProceduresCallDao {
/**
* 字典表存储过程调用(导入字典表数据)
*/
public void importDicInfo(){
this.execute("importDicInfo");
}
/**
* 客户表存储过程调用(导入客户表数据)
*/
public void importCustomerInfo(){
this.execute("importCustomerInfo");
}
/**
* 家庭信息存储过程调用(导入个人客户家庭信息数据)
*/
public void importPerCustomerFamilyInfo(){
this.execute("importPerCustomerFamilyInfo");
}
/**
*个人客户资产负债情况存储过程调用
*/
public void importPerCustomerAsset(){
this.execute("importPerCustomerAsset");
}
/**
* 企业客户单位关键人信息存储过程调用
*/
public void importCoCustomerKeyman(){
this.execute("importCoCustomerKeyman");
}
/**
* 企业客户股权结构信息存储过程调用
*/
public void importCoCustomerSturc(){
this.execute("importCoCustomerSturc");
}
/**
* 企业客户对外投资信息存储过程
*/
public void importCoCustomerInvest(){
this.execute("importCoCustomerInvest");
}
/**
* 清空指定表的数据
* @param tableName
*/
public void cleanRecords(String tableName){
this.execute("cleanRecords",tableName);
}
/**
* 待办事项的业务检查存储过程调用
*/
public void importBusinessCheckInfo(){
this.execute("importBusinessCheckInfo");
}
/**
* 待办事项的客户检查存储过程调用
*/
public void importCustomerCheckInfo(){
this.execute("importCustomerCheckInfo");
}
public void importCustomerAFFILIATEDInfo() {
this.execute("importCustomerAFFILIATEDInfo");
}
public void importGrKhxx(){
this.execute("importGrKhxx");
}
public void importQyKhxx(){
this.execute("importQyKhxx");
}
}
| 2,322 | 0.628231 | 0.625248 | 95 | 20.178947 | 20.177622 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.189474 | false | false | 14 |
f59b18b3eb61d8570a85abe49663285093424543 | 15,341,623,187,018 | 50c46cef55211e1ea17c52a5dded77b02c726cff | /src/main/java/gg/gamello/ludo/gamemode/application/dto/GameModeDtoAssembler.java | faa22ab7dcbecae0178a0ea56e66588a180ae3ca | [] | no_license | MilyGosc/gamello-ludo | https://github.com/MilyGosc/gamello-ludo | 8cbd4f23fbe71f63e7e16511d2cd72d8067757f3 | b9ffd7c4da059ef231670be6adc79dfc39cbfa4a | refs/heads/master | 2021-03-29T07:20:18.874000 | 2020-03-17T09:42:57 | 2020-03-17T09:42:57 | 247,926,790 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package gg.gamello.ludo.gamemode.application.dto;
import gg.gamello.ludo.gamemode.domain.GameMode;
import org.springframework.stereotype.Component;
@Component
public class GameModeDtoAssembler {
public GameModeDto convertDefault(GameMode gameMode) {
var dto = new GameModeDto();
dto.setName(gameMode.getName());
return dto;
}
public GameModeDetailsDto convertDetails(GameMode gameMode) {
GameModeDetailsDto dto = new GameModeDetailsDto();
dto.setName(gameMode.getName());
dto.setSlots(gameMode.getSlots());
dto.setSquares(gameMode.getSquares());
dto.setPawns(gameMode.getPawns());
return dto;
}
}
| UTF-8 | Java | 623 | java | GameModeDtoAssembler.java | Java | [] | null | [] | package gg.gamello.ludo.gamemode.application.dto;
import gg.gamello.ludo.gamemode.domain.GameMode;
import org.springframework.stereotype.Component;
@Component
public class GameModeDtoAssembler {
public GameModeDto convertDefault(GameMode gameMode) {
var dto = new GameModeDto();
dto.setName(gameMode.getName());
return dto;
}
public GameModeDetailsDto convertDetails(GameMode gameMode) {
GameModeDetailsDto dto = new GameModeDetailsDto();
dto.setName(gameMode.getName());
dto.setSlots(gameMode.getSlots());
dto.setSquares(gameMode.getSquares());
dto.setPawns(gameMode.getPawns());
return dto;
}
}
| 623 | 0.773676 | 0.773676 | 23 | 26.086956 | 20.857515 | 62 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.478261 | false | false | 14 |
0dbd49b247694d2094dc3247b89617912cd11761 | 13,125,420,069,900 | a16d26cc3e82a4c724a1beca06e8141c73ac2330 | /src/main/java/com/example/HamburgerAdminPanel/Service/UserServiceImpl.java | f81243300c35d9c73f6ea9b59a1d05f47d3998b3 | [] | no_license | sai9615/HamburgerAdminPanel | https://github.com/sai9615/HamburgerAdminPanel | 6bb27b2c9a21c15e2c191f72ba6725528da0f507 | f70a7e3887c8d73f9065eba96104393e5cce273f | refs/heads/master | 2023-02-24T10:13:33.040000 | 2021-01-28T00:45:13 | 2021-01-28T00:45:13 | 329,817,418 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.HamburgerAdminPanel.Service;
import com.example.HamburgerAdminPanel.Entity.User;
import com.example.HamburgerAdminPanel.Exception.ResourceNotFoundException;
import com.example.HamburgerAdminPanel.Repository.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Optional;
@Service
@Transactional
@Slf4j
public class UserServiceImpl implements UserService{
@Autowired
UserRepository userRepository;
@Autowired
BCryptPasswordEncoder bCryptPasswordEncoder;
@Override
public User findByUserEmail(String emailId) {
Optional<User> user = userRepository.findByEmail(emailId);
if (user.isEmpty()){
log.debug( "User with emailId: "+emailId+" doesn't exist");
throw new ResourceNotFoundException("User with emailId: "+emailId+" doesn't exist");
}
return user.get();
}
@Override
public Optional<User> findByUserName(String userName) {
Optional<User> user = userRepository.findByUserName(userName);
if (user.isEmpty()){
log.debug(" User with emailId: "+userName+" doesn't exist");
throw new ResourceNotFoundException("User with emailId: "+userName+" doesn't exist");
}
return user;
}
@Override
public Iterable<User> findAllUsers() {
return userRepository.findAll();
}
@Override
public void addUser(User user) {
Optional<User> userExist =userRepository.findByUserName(user.getUserName());
if(!userExist.isEmpty()) {
log.debug( " User already exist in the database");
throw new RuntimeException("User already exist in the database");
}
String pass= user.getPassword();
String encode= bCryptPasswordEncoder.encode(pass);
user.setPassword(encode);
userRepository.save(user);
}
@Override
public void deleteByUserName(String userName) {
try {
userRepository.deleteByUserName(userName);
} catch (Exception e){
log.debug(" User name: "+userName+" not found");
throw new ResourceNotFoundException("User name: "+userName+" not found");
}
}
@Override
public void deleteAllUsers() {
try {
userRepository.deleteAll();
} catch (Exception e){
log.debug( " Internal server error");
throw new ResourceNotFoundException("Internal error");
}
}
}
| UTF-8 | Java | 2,716 | java | UserServiceImpl.java | Java | [
{
"context": "xception e){\n log.debug(\" User name: \"+userName+\" not found\");\n throw new ResourceNotF",
"end": 2328,
"score": 0.9905023574829102,
"start": 2320,
"tag": "USERNAME",
"value": "userName"
},
{
"context": "throw new ResourceNotFoundException(\"User name: \"+userName+\" not found\");\n }\n }\n\n @Override\n ",
"end": 2414,
"score": 0.7403409481048584,
"start": 2406,
"tag": "USERNAME",
"value": "userName"
}
] | null | [] | package com.example.HamburgerAdminPanel.Service;
import com.example.HamburgerAdminPanel.Entity.User;
import com.example.HamburgerAdminPanel.Exception.ResourceNotFoundException;
import com.example.HamburgerAdminPanel.Repository.UserRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
import javax.transaction.Transactional;
import java.util.Optional;
@Service
@Transactional
@Slf4j
public class UserServiceImpl implements UserService{
@Autowired
UserRepository userRepository;
@Autowired
BCryptPasswordEncoder bCryptPasswordEncoder;
@Override
public User findByUserEmail(String emailId) {
Optional<User> user = userRepository.findByEmail(emailId);
if (user.isEmpty()){
log.debug( "User with emailId: "+emailId+" doesn't exist");
throw new ResourceNotFoundException("User with emailId: "+emailId+" doesn't exist");
}
return user.get();
}
@Override
public Optional<User> findByUserName(String userName) {
Optional<User> user = userRepository.findByUserName(userName);
if (user.isEmpty()){
log.debug(" User with emailId: "+userName+" doesn't exist");
throw new ResourceNotFoundException("User with emailId: "+userName+" doesn't exist");
}
return user;
}
@Override
public Iterable<User> findAllUsers() {
return userRepository.findAll();
}
@Override
public void addUser(User user) {
Optional<User> userExist =userRepository.findByUserName(user.getUserName());
if(!userExist.isEmpty()) {
log.debug( " User already exist in the database");
throw new RuntimeException("User already exist in the database");
}
String pass= user.getPassword();
String encode= bCryptPasswordEncoder.encode(pass);
user.setPassword(encode);
userRepository.save(user);
}
@Override
public void deleteByUserName(String userName) {
try {
userRepository.deleteByUserName(userName);
} catch (Exception e){
log.debug(" User name: "+userName+" not found");
throw new ResourceNotFoundException("User name: "+userName+" not found");
}
}
@Override
public void deleteAllUsers() {
try {
userRepository.deleteAll();
} catch (Exception e){
log.debug( " Internal server error");
throw new ResourceNotFoundException("Internal error");
}
}
}
| 2,716 | 0.665317 | 0.664212 | 81 | 32.530865 | 27.003469 | 97 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.419753 | false | false | 14 |
b3aa7f3d2d67b742e923eed4d7c6830703123921 | 20,469,814,173,438 | fe336c5983915dd35d4aadbed4dd8bc592c09c39 | /team1_proyerin/src/net/member/action/joinmemberAction.java | 10e13651ca80fd6c3c89222ba7002bb7c0991694 | [] | no_license | watermelon-class6/none | https://github.com/watermelon-class6/none | e55d2943208424d2ba5229afa4040fde38f11726 | ed34c45ed8a4dfde52451f86b4cba150d10b1b90 | refs/heads/master | 2020-07-01T14:31:06.170000 | 2019-08-15T09:40:18 | 2019-08-15T09:40:18 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package net.member.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.member.db.membersBean;
import net.member.db.membersDAO;
import net.member.db.userlikeBean;
import net.member.db.userlikeDAO;
public class joinmemberAction implements Action {
@Override
public ActionForward execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("MemberJoinAction execute()");
//회원가입 폼(join.jsp)에서 입력한 한글 정보들이 깨지지 않도록 인코딩 설정
request.setCharacterEncoding("utf-8");
/*1,2클라이언트 요청 정보 받기*/
/*3. 자바빈 DTO에 저장*/
/*회원가입폼(join.jsp)에서 입력한 정보들을 MemberBean객체(자바빈)에 저장한다.*/
membersBean mb = new membersBean();
mb.setEmail(request.getParameter("email"));
mb.setPassword(request.getParameter("password"));
mb.setName(request.getParameter("name"));
mb.setGender(request.getParameter("gender"));
mb.setBirth(request.getParameter("birth"));
//회원가입 성공 여부를 담을 변수 선언
boolean result = false;
//MemberBean객체를 매개변수로 DAO클래스의 insertMember()메소드에 전달하여 회원가입 처리
membersDAO mdao = new membersDAO();
String[] likeArr = request.getParameterValues("like");
if(likeArr.length==0){
mb.setLikegenre(0);
//회원가입 내용을 담고 있는 mb객체를 전달하여 가입에 성공하면 true 실패 false
result = mdao.insertMember(mb);
}else{
mb.setLikegenre(1);
userlikeBean userlike = new userlikeBean();
String likelist="";
for(String s : likeArr){
likelist+=(s+"/");
}
System.out.println(likelist);
userlike.setEmail(request.getParameter("email"));
userlike.setGenre(likelist);
//회원가입 내용을 담고 있는 mb객체를 전달하여 가입에 성공하면 true 실패 false
result = mdao.insertMember(mb);
userlikeDAO likedao = new userlikeDAO();
likedao.insertLike(userlike); //선호장르 추가
}
//회원가입실패시 null반환
if(result==false){
System.out.println("회원가입 실패");
return null;
}
//회원가입 성공시 로그인페이지로 이동/페이지 이동 방식 여부 값, 이동페이지 경로 값 저장하여 리턴해주는 객체 생성
ActionForward forward = new ActionForward();
//페이지 이동 방식 여부 값 true로 저장
//sendRedirect() 방식은 이동할 페이지 주소 경로 노출
forward.setRedirect(true);
// ./member/login.jsp이동할 페이지 주소 저장
forward.setPath("./login.me");
System.out.println("여기");
return forward;
}
}
| UTF-8 | Java | 2,851 | java | joinmemberAction.java | Java | [] | null | [] | package net.member.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.member.db.membersBean;
import net.member.db.membersDAO;
import net.member.db.userlikeBean;
import net.member.db.userlikeDAO;
public class joinmemberAction implements Action {
@Override
public ActionForward execute(HttpServletRequest request, HttpServletResponse response) throws Exception {
System.out.println("MemberJoinAction execute()");
//회원가입 폼(join.jsp)에서 입력한 한글 정보들이 깨지지 않도록 인코딩 설정
request.setCharacterEncoding("utf-8");
/*1,2클라이언트 요청 정보 받기*/
/*3. 자바빈 DTO에 저장*/
/*회원가입폼(join.jsp)에서 입력한 정보들을 MemberBean객체(자바빈)에 저장한다.*/
membersBean mb = new membersBean();
mb.setEmail(request.getParameter("email"));
mb.setPassword(request.getParameter("password"));
mb.setName(request.getParameter("name"));
mb.setGender(request.getParameter("gender"));
mb.setBirth(request.getParameter("birth"));
//회원가입 성공 여부를 담을 변수 선언
boolean result = false;
//MemberBean객체를 매개변수로 DAO클래스의 insertMember()메소드에 전달하여 회원가입 처리
membersDAO mdao = new membersDAO();
String[] likeArr = request.getParameterValues("like");
if(likeArr.length==0){
mb.setLikegenre(0);
//회원가입 내용을 담고 있는 mb객체를 전달하여 가입에 성공하면 true 실패 false
result = mdao.insertMember(mb);
}else{
mb.setLikegenre(1);
userlikeBean userlike = new userlikeBean();
String likelist="";
for(String s : likeArr){
likelist+=(s+"/");
}
System.out.println(likelist);
userlike.setEmail(request.getParameter("email"));
userlike.setGenre(likelist);
//회원가입 내용을 담고 있는 mb객체를 전달하여 가입에 성공하면 true 실패 false
result = mdao.insertMember(mb);
userlikeDAO likedao = new userlikeDAO();
likedao.insertLike(userlike); //선호장르 추가
}
//회원가입실패시 null반환
if(result==false){
System.out.println("회원가입 실패");
return null;
}
//회원가입 성공시 로그인페이지로 이동/페이지 이동 방식 여부 값, 이동페이지 경로 값 저장하여 리턴해주는 객체 생성
ActionForward forward = new ActionForward();
//페이지 이동 방식 여부 값 true로 저장
//sendRedirect() 방식은 이동할 페이지 주소 경로 노출
forward.setRedirect(true);
// ./member/login.jsp이동할 페이지 주소 저장
forward.setPath("./login.me");
System.out.println("여기");
return forward;
}
}
| 2,851 | 0.678216 | 0.675184 | 85 | 25.164705 | 21.249136 | 106 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.223529 | false | false | 14 |
64e6eb119f4b348059796fbe23fcc4dc5dcf6b7e | 26,697,516,723,971 | 77f3b7bd2ee4cf9943bb2e11d61f214481ab0500 | /src/main/java/BusinessLogic/LoginInterface.java | b58d0fb482b9ec00c9c3fa0a7c96ac2da7b72708 | [] | no_license | Jenslopes/FirstYear | https://github.com/Jenslopes/FirstYear | 9adf45ec95caaaf1a9e778545c2b6a358cf0fd19 | 20cb6d58ea1274a1a5a16dfc20aaa11fd2944c54 | refs/heads/master | 2020-06-22T04:48:22.362000 | 2016-12-13T21:57:36 | 2016-12-13T21:57:36 | 74,756,704 | 0 | 5 | null | false | 2016-12-08T11:02:09 | 2016-11-25T12:28:29 | 2016-11-30T19:03:12 | 2016-12-08T11:02:09 | 354 | 0 | 1 | 0 | Java | null | null | package BusinessLogic;
/**
* Created by Julius on 07-12-2016.
*/
public interface LoginInterface {
int handleLogin();
}
| UTF-8 | Java | 127 | java | LoginInterface.java | Java | [
{
"context": "package BusinessLogic;\n\n/**\n * Created by Julius on 07-12-2016.\n */\npublic interface LoginInterfac",
"end": 48,
"score": 0.9996596574783325,
"start": 42,
"tag": "NAME",
"value": "Julius"
}
] | null | [] | package BusinessLogic;
/**
* Created by Julius on 07-12-2016.
*/
public interface LoginInterface {
int handleLogin();
}
| 127 | 0.692913 | 0.629921 | 8 | 14.875 | 13.833271 | 35 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.25 | false | false | 14 |
be29e188068dbca38f53b0c23059a3be046773ca | 8,452,495,708,325 | e65847f4c29cc7b9827637ed645c9070baba91b8 | /src/main/java/owl2vowl/export/JsonGeneratorVisitor.java | c755cd95f89f5c7bfb97ab46c0c311fdad8a1e17 | [
"MIT"
] | permissive | VVangyan/OWL2VOWL | https://github.com/VVangyan/OWL2VOWL | 79ef444fdcea8a6d0e39da97da04b0db3d12ce86 | 5c358792b0ff5bbf2b754aadbdca95d809207040 | refs/heads/master | 2020-07-10T21:21:10.223000 | 2019-09-01T19:25:23 | 2019-09-01T19:25:23 | 204,374,591 | 0 | 0 | null | true | 2019-08-26T01:46:09 | 2019-08-26T01:46:08 | 2019-06-28T16:52:18 | 2019-06-28T16:52:16 | 1,042 | 0 | 0 | 0 | null | false | false | /*
* JsonGeneratorVisitor.java
*
*/
package owl2vowl.export;
import owl2vowl.model.visitor.VowlElementVisitor;
/**
*
*/
public interface JsonGeneratorVisitor extends VowlElementVisitor {
}
| UTF-8 | Java | 197 | java | JsonGeneratorVisitor.java | Java | [] | null | [] | /*
* JsonGeneratorVisitor.java
*
*/
package owl2vowl.export;
import owl2vowl.model.visitor.VowlElementVisitor;
/**
*
*/
public interface JsonGeneratorVisitor extends VowlElementVisitor {
}
| 197 | 0.756345 | 0.746193 | 14 | 13.071428 | 20.292377 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.142857 | false | false | 14 |
18e6341d602ecb6a1c7e43994f015ee2b59764ea | 6,811,818,131,761 | 0fa18dbf39b0bbef53ca5e5fd3d73e2d6cc9075b | /module03/src/MovingObject.java | a9c08ccfd897487563a2db7ec8ae77123e0095b9 | [
"MIT"
] | permissive | zzc-tongji/gwu-csci-6341-continuous-algorithms | https://github.com/zzc-tongji/gwu-csci-6341-continuous-algorithms | 7f35883212527dc297bb27eccef43051522a3bcd | 2dd257d92d82ab4e38cd7c251ccc7df7ea2df0c5 | refs/heads/master | 2020-05-23T09:41:29.720000 | 2019-05-14T22:42:14 | 2019-05-14T22:42:14 | 186,707,218 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
class DrawPanel extends JPanel {
double t = 0;
double d = 0;
double v = 0;
double a = 4.9;
double delT = 0.1;
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Clear.
Dimension D = this.getSize();
g.setColor(Color.white);
g.fillRect(0, 0, D.width, D.height);
g.setColor(Color.red);
int x = (int) d;
int y = D.height / 2;
g.fillOval(x, y, 10, 10);
}
void reset() {
t = 0;
d = 0;
v = 0;
Thread t = new Thread(() -> animate());
t.start();
}
void animate() {
Function V = new Function("Velocity");
Function D = new Function("Distance");
while (t <= 12) {
t = t + delT;
v = v + delT * a;
d = d + delT * v;
D.add(t, d);
V.add(t, v);
this.repaint();
sleep();
}
Function.show(V, D);
}
void sleep() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
System.out.println(e);
}
}
}
public class MovingObject extends JFrame {
DrawPanel drawPanel;
public MovingObject() {
this.setSize(500, 200);
Container cPane = this.getContentPane();
drawPanel = new DrawPanel();
JPanel panel = new JPanel();
JButton resetB = new JButton("Reset");
resetB.addActionListener(a -> drawPanel.reset());
panel.add(resetB);
panel.add(new JLabel(" "));
JButton quitB = new JButton("Quit");
quitB.addActionListener(a -> System.exit(0));
panel.add(quitB);
cPane.add(panel, BorderLayout.SOUTH);
cPane.add(drawPanel, BorderLayout.CENTER);
this.setVisible(true);
}
public static void main(String[] argv) {
new MovingObject();
}
}
| UTF-8 | Java | 2,065 | java | MovingObject.java | Java | [] | null | [] | import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.border.*;
class DrawPanel extends JPanel {
double t = 0;
double d = 0;
double v = 0;
double a = 4.9;
double delT = 0.1;
public void paintComponent(Graphics g) {
super.paintComponent(g);
// Clear.
Dimension D = this.getSize();
g.setColor(Color.white);
g.fillRect(0, 0, D.width, D.height);
g.setColor(Color.red);
int x = (int) d;
int y = D.height / 2;
g.fillOval(x, y, 10, 10);
}
void reset() {
t = 0;
d = 0;
v = 0;
Thread t = new Thread(() -> animate());
t.start();
}
void animate() {
Function V = new Function("Velocity");
Function D = new Function("Distance");
while (t <= 12) {
t = t + delT;
v = v + delT * a;
d = d + delT * v;
D.add(t, d);
V.add(t, v);
this.repaint();
sleep();
}
Function.show(V, D);
}
void sleep() {
try {
Thread.sleep(50);
} catch (InterruptedException e) {
System.out.println(e);
}
}
}
public class MovingObject extends JFrame {
DrawPanel drawPanel;
public MovingObject() {
this.setSize(500, 200);
Container cPane = this.getContentPane();
drawPanel = new DrawPanel();
JPanel panel = new JPanel();
JButton resetB = new JButton("Reset");
resetB.addActionListener(a -> drawPanel.reset());
panel.add(resetB);
panel.add(new JLabel(" "));
JButton quitB = new JButton("Quit");
quitB.addActionListener(a -> System.exit(0));
panel.add(quitB);
cPane.add(panel, BorderLayout.SOUTH);
cPane.add(drawPanel, BorderLayout.CENTER);
this.setVisible(true);
}
public static void main(String[] argv) {
new MovingObject();
}
}
| 2,065 | 0.514286 | 0.500726 | 95 | 20.736841 | 16.145529 | 57 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.673684 | false | false | 14 |
4f65d3e3325adb473939e5d76856ec3b892fc0e3 | 22,780,506,566,668 | e08129cc09d5fa3d7d8bba3e23b3dfde316ddcf9 | /projects/openquote/1.4/openquote/openquote.ear/lib/openquote.jar/com/ail/openquote/ui/PageFlow.java | dd609edc94d61a9b8c1295d297cce7b27b9ed137 | [] | no_license | zhangjh953166/open-quote | https://github.com/zhangjh953166/open-quote | 459dd7b58e7faa8cbb970af30b377c1c1e51c0a2 | d0823cff3254293e0031d818bb1289fbbf3e6aa2 | refs/heads/master | 2020-03-29T05:13:19.380000 | 2014-10-08T08:52:38 | 2014-10-08T08:52:38 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* Copyright Applied Industrial Logic Limited 2006. All rights Reserved */
/*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.ail.openquote.ui;
import java.io.IOException;
import java.util.ArrayList;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.ail.core.Type;
import com.ail.openquote.Quotation;
/**
* The PageFlow class is the root of the openquote product UI concept. It contains
* a collection of pages and implements life-cycle methods which simply delegate to
* the "current" page.<br/>
* In all cases the page flow assumes that the model it is processing is a {@link com.ail.openquote.Quotation Quotation}.
* The name of the "current" page is indicated by the Quotation's {@link com.ail.openquote.Quotation#getPage() page}
* property.
* @see com.ail.openquote.Quotation
* @see com.ail.openquote.portlet.QuotationPortlet
* @see com.ail.openquote.portlet.SandpitPortlet
*/
public class PageFlow extends PageElement {
private static final long serialVersionUID = -3699440857377974385L;
/** List of pages which are part of this flow */
private ArrayList<Page> page;
/** Optional definition of the page on which the quote process should start. */
private String startPage=null;
/** Set true when elements IDs have been applied so we can avoid applying them twice. */
private transient boolean appliedElementId=false;
/**
* Default constructor
*/
public PageFlow() {
super();
page=new ArrayList<Page>();
}
/**
* The list of pages associated with this PageFlow
* @return list of pages
*/
public ArrayList<Page> getPage() {
return page;
}
/**
* @see #getPage()
* @param page List of pages
*/
public void setPage(ArrayList<Page> page) {
this.page = page;
}
/**
* Get the name of the page on which the quote process should start. This can also
* be defined in the Quotation's XML. If defined in both places, the setting here
* takes precedence.
* @return Name of the page to start the process on.
*/
public String getStartPage() {
return startPage;
}
/**
* @see #getStartPage()
* @param startPage
*/
public void setStartPage(String startPage) {
this.startPage = startPage;
}
@Override
public Type applyRequestValues(ActionRequest request, ActionResponse response, Type model) {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.applyRequestValues(request, response, model);
break;
}
}
return model;
}
@Override
public boolean processValidations(ActionRequest request, ActionResponse response, Type model) {
boolean errors=false;
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
errors |= p.processValidations(request, response, model);
break;
}
}
return errors;
}
@Override
public Type processActions(ActionRequest request, ActionResponse response, Type model) {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.processActions(request, response, model);
break;
}
}
return model;
}
@Override
public Type renderResponse(RenderRequest request, RenderResponse response, Type model) throws IllegalStateException, IOException {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.renderResponse(request, response, model);
break;
}
}
return model;
}
@Override
public void applyElementId(String baseId) {
if (!appliedElementId) {
int idx=-0;
for(Page p: page) {
p.applyElementId(baseId+ID_SEPARATOR+(idx++));
}
appliedElementId=true;
}
}
}
| UTF-8 | Java | 4,499 | java | PageFlow.java | Java | [] | null | [] | /* Copyright Applied Industrial Logic Limited 2006. All rights Reserved */
/*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
package com.ail.openquote.ui;
import java.io.IOException;
import java.util.ArrayList;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.ail.core.Type;
import com.ail.openquote.Quotation;
/**
* The PageFlow class is the root of the openquote product UI concept. It contains
* a collection of pages and implements life-cycle methods which simply delegate to
* the "current" page.<br/>
* In all cases the page flow assumes that the model it is processing is a {@link com.ail.openquote.Quotation Quotation}.
* The name of the "current" page is indicated by the Quotation's {@link com.ail.openquote.Quotation#getPage() page}
* property.
* @see com.ail.openquote.Quotation
* @see com.ail.openquote.portlet.QuotationPortlet
* @see com.ail.openquote.portlet.SandpitPortlet
*/
public class PageFlow extends PageElement {
private static final long serialVersionUID = -3699440857377974385L;
/** List of pages which are part of this flow */
private ArrayList<Page> page;
/** Optional definition of the page on which the quote process should start. */
private String startPage=null;
/** Set true when elements IDs have been applied so we can avoid applying them twice. */
private transient boolean appliedElementId=false;
/**
* Default constructor
*/
public PageFlow() {
super();
page=new ArrayList<Page>();
}
/**
* The list of pages associated with this PageFlow
* @return list of pages
*/
public ArrayList<Page> getPage() {
return page;
}
/**
* @see #getPage()
* @param page List of pages
*/
public void setPage(ArrayList<Page> page) {
this.page = page;
}
/**
* Get the name of the page on which the quote process should start. This can also
* be defined in the Quotation's XML. If defined in both places, the setting here
* takes precedence.
* @return Name of the page to start the process on.
*/
public String getStartPage() {
return startPage;
}
/**
* @see #getStartPage()
* @param startPage
*/
public void setStartPage(String startPage) {
this.startPage = startPage;
}
@Override
public Type applyRequestValues(ActionRequest request, ActionResponse response, Type model) {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.applyRequestValues(request, response, model);
break;
}
}
return model;
}
@Override
public boolean processValidations(ActionRequest request, ActionResponse response, Type model) {
boolean errors=false;
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
errors |= p.processValidations(request, response, model);
break;
}
}
return errors;
}
@Override
public Type processActions(ActionRequest request, ActionResponse response, Type model) {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.processActions(request, response, model);
break;
}
}
return model;
}
@Override
public Type renderResponse(RenderRequest request, RenderResponse response, Type model) throws IllegalStateException, IOException {
for(Page p: page) {
if (p.getId().equals(((Quotation)model).getPage())) {
model=p.renderResponse(request, response, model);
break;
}
}
return model;
}
@Override
public void applyElementId(String baseId) {
if (!appliedElementId) {
int idx=-0;
for(Page p: page) {
p.applyElementId(baseId+ID_SEPARATOR+(idx++));
}
appliedElementId=true;
}
}
}
| 4,499 | 0.69571 | 0.687708 | 152 | 28.598684 | 30.067307 | 131 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.282895 | false | false | 14 |
6b88513e6968a1db915f41b08e75959c5293e0fa | 13,778,255,148,857 | b085e5ae552567f375fad2376ec61755e0dc2902 | /Android-Tutorial/app_design_pattern/src/main/java/com/design/pattern/FactoryMethod/VolvoFactory.java | 48042d6a3041e6225b18de865904eddd1790dc0b | [] | no_license | kamaihamaiha/Tutorial | https://github.com/kamaihamaiha/Tutorial | 50aff4d8a69fb6831107d4af85a2325d23686c59 | c1f2bfaf53703c36f1c4c45308b11b49ec09b917 | refs/heads/master | 2023-06-02T21:18:23.572000 | 2021-06-18T03:52:07 | 2021-06-18T03:52:07 | 207,139,444 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.design.pattern.FactoryMethod;
/**
* @Author: kk
* @Date: 2019-10-21 19:36
* @Description:
*/
public class VolvoFactory extends Factory {
@Override
Car product() {
return new Volvo();
}
}
| UTF-8 | Java | 224 | java | VolvoFactory.java | Java | [
{
"context": "com.design.pattern.FactoryMethod;\n\n/**\n * @Author: kk\n * @Date: 2019-10-21 19:36\n * @Description:\n */\np",
"end": 61,
"score": 0.9977633357048035,
"start": 59,
"tag": "USERNAME",
"value": "kk"
}
] | null | [] | package com.design.pattern.FactoryMethod;
/**
* @Author: kk
* @Date: 2019-10-21 19:36
* @Description:
*/
public class VolvoFactory extends Factory {
@Override
Car product() {
return new Volvo();
}
}
| 224 | 0.625 | 0.571429 | 13 | 16.23077 | 13.967841 | 43 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.153846 | false | false | 14 |
5ae915790823998d773c21d6b07efed2ff3ac6ce | 21,801,254,057,752 | b276ba21470d94e789f119e3558dee0480d820d6 | /app/src/main/java/com/example/kapil/mediaapplication/recycler_view/adapters/CustomRvAdapter.java | 2f63298b70af346685ab7e8500f1c9d4f7200ffe | [] | no_license | kaxp/Media-Application | https://github.com/kaxp/Media-Application | 6f4009e09b1b90809fbd70d68f1f0302ad2ef260 | ab844cd36b0ca3907f0ae43fdf01fa6812d1a9e4 | refs/heads/master | 2020-03-29T06:02:53.927000 | 2018-10-30T12:09:33 | 2018-10-30T12:09:33 | 149,606,419 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.kapil.mediaapplication.recycler_view.adapters;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;
import com.example.kapil.mediaapplication.R;
import com.example.kapil.mediaapplication.recycler_view.media.Media;
import com.example.kapil.mediaapplication.recycler_view.callback.OnMediaCellClick;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
public class CustomRvAdapter extends RecyclerView.Adapter<CustomRvAdapter.CustomRVViewHolder> {
private Context mContext;
private ArrayList<Media> mList;
private OnMediaCellClick mListner;
public CustomRvAdapter(Context mContext, ArrayList<Media> mList, OnMediaCellClick mListener) {
this.mContext = mContext;
this.mList = mList;
this.mListner = mListener;
}
@NonNull
@Override
public CustomRvAdapter.CustomRVViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(mContext).inflate(R.layout.list_items, viewGroup, false);
CustomRvAdapter.CustomRVViewHolder vh = new CustomRvAdapter.CustomRVViewHolder(view);
return vh;
}
@Override
public void onBindViewHolder(@NonNull CustomRVViewHolder customRVViewHolder, int i) {
final Media m = this.mList.get(i);
customRVViewHolder.title.setText(m.Title);
customRVViewHolder.year.setText(String.valueOf(m.Year));
customRVViewHolder.genre.setText(m.Genre);
customRVViewHolder.director.setText(m.Director);
customRVViewHolder.rating.setRating(Float.parseFloat(m.Rating.toString())/2);
customRVViewHolder.duration.setText(String.valueOf(m.Duration));
Picasso.with(this.mContext)
.load(m.ThumbnailImage)
.into(customRVViewHolder.img);
customRVViewHolder.ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListner.onMovieCellClickedListener(m);
}
});
}
@Override
public int getItemCount() {
return mList != null ? mList.size() : 0;
}
public class CustomRVViewHolder extends RecyclerView.ViewHolder {
private ImageView img;
private TextView title;
private TextView genre;
private TextView year;
private RatingBar rating;
private TextView director;
private TextView duration;
private LinearLayout ll;
public CustomRVViewHolder(@NonNull View itemView) {
super(itemView);
img = itemView.findViewById(R.id.rv_img);
title = itemView.findViewById(R.id.rv_title);
genre = itemView.findViewById(R.id.rv_genre);
year = itemView.findViewById(R.id.rv_year);
rating = itemView.findViewById(R.id.rv_rating);
director = itemView.findViewById(R.id.rv_director);
duration = itemView.findViewById(R.id.rv_duration);
ll = itemView.findViewById(R.id.rv_ll);
}
}
}
| UTF-8 | Java | 3,338 | java | CustomRvAdapter.java | Java | [] | null | [] | package com.example.kapil.mediaapplication.recycler_view.adapters;
import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RatingBar;
import android.widget.TextView;
import com.example.kapil.mediaapplication.R;
import com.example.kapil.mediaapplication.recycler_view.media.Media;
import com.example.kapil.mediaapplication.recycler_view.callback.OnMediaCellClick;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
public class CustomRvAdapter extends RecyclerView.Adapter<CustomRvAdapter.CustomRVViewHolder> {
private Context mContext;
private ArrayList<Media> mList;
private OnMediaCellClick mListner;
public CustomRvAdapter(Context mContext, ArrayList<Media> mList, OnMediaCellClick mListener) {
this.mContext = mContext;
this.mList = mList;
this.mListner = mListener;
}
@NonNull
@Override
public CustomRvAdapter.CustomRVViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
View view = LayoutInflater.from(mContext).inflate(R.layout.list_items, viewGroup, false);
CustomRvAdapter.CustomRVViewHolder vh = new CustomRvAdapter.CustomRVViewHolder(view);
return vh;
}
@Override
public void onBindViewHolder(@NonNull CustomRVViewHolder customRVViewHolder, int i) {
final Media m = this.mList.get(i);
customRVViewHolder.title.setText(m.Title);
customRVViewHolder.year.setText(String.valueOf(m.Year));
customRVViewHolder.genre.setText(m.Genre);
customRVViewHolder.director.setText(m.Director);
customRVViewHolder.rating.setRating(Float.parseFloat(m.Rating.toString())/2);
customRVViewHolder.duration.setText(String.valueOf(m.Duration));
Picasso.with(this.mContext)
.load(m.ThumbnailImage)
.into(customRVViewHolder.img);
customRVViewHolder.ll.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
mListner.onMovieCellClickedListener(m);
}
});
}
@Override
public int getItemCount() {
return mList != null ? mList.size() : 0;
}
public class CustomRVViewHolder extends RecyclerView.ViewHolder {
private ImageView img;
private TextView title;
private TextView genre;
private TextView year;
private RatingBar rating;
private TextView director;
private TextView duration;
private LinearLayout ll;
public CustomRVViewHolder(@NonNull View itemView) {
super(itemView);
img = itemView.findViewById(R.id.rv_img);
title = itemView.findViewById(R.id.rv_title);
genre = itemView.findViewById(R.id.rv_genre);
year = itemView.findViewById(R.id.rv_year);
rating = itemView.findViewById(R.id.rv_rating);
director = itemView.findViewById(R.id.rv_director);
duration = itemView.findViewById(R.id.rv_duration);
ll = itemView.findViewById(R.id.rv_ll);
}
}
}
| 3,338 | 0.696824 | 0.695926 | 96 | 33.770832 | 27.822159 | 103 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.614583 | false | false | 14 |
d74ceb4db01c01c186bf3aacf3a6fcfa8fd43783 | 23,416,161,763,050 | bbf8c7015c7249befcc0ddf8720efe910ae57a76 | /modules/referencing/geotk-referencing/src/main/java/org/geotoolkit/referencing/operation/provider/package-info.java | e081ab626487f40fd31bdd5cbe56b3bce06c7615 | [] | no_license | cyrilleKla/geotoolkit | https://github.com/cyrilleKla/geotoolkit | a779f78bb7d080e1fde9fc8bbc440c35c16a0ee2 | 17a163bf7c902c363d953f32264a9898c519c0ad | refs/heads/master | 2021-01-12T19:00:11.537000 | 2015-04-16T16:04:46 | 2015-04-16T16:05:01 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* Geotoolkit.org - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2008-2012, Open Source Geospatial Foundation (OSGeo)
* (C) 2009-2012, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
/**
* {@linkplain org.geotoolkit.referencing.operation.MathTransformProvider Providers} of
* {@linkplain org.geotoolkit.referencing.operation.transform transforms} and
* {@linkplain org.geotoolkit.referencing.operation.projection projections} implementations.
* This package is provided mostly for documentation purpose, since the javadoc of each provider
* lists the operation names, identifiers (e.g. EPSG codes) and parameters. The preferred way to
* get a provider is to use the {@link org.opengis.referencing.operation.MathTransformFactory} class.
*
* {@section Standard parameters}
*
* Each provider declares a single {@link org.opengis.parameter.ParameterDescriptorGroup} constant
* named {@code PARAMETERS}. Each group describes all the parameters expected by an operation method.
* The set of parameters varies for each projection, but the following can be considered typical:
* <p>
* <ul>
* <li>A <cite>semi-major</cite> and <cite>semi-minor</cite> axis length in metres.</li>
* <li>A <cite>central meridian</cite> and <cite>latitude of origin</cite> in decimal degrees.</li>
* <li>A <cite>scale factor</cite>, which default to 1.</li>
* <li>A <cite>false easting</cite> and <cite>false northing</cite> in metres, which default to 0.</li>
* </ul>
* <p>
* Each descriptor has many aliases, and those aliases may vary between different projections.
* For example the <cite>false easting</cite> parameter is usually called {@code "false_easting"}
* by OGC, while EPSG uses various names like "<cite>False easting</cite>" or "<cite>Easting at
* false origin</cite>".
*
* {@section Dynamic parameters}
*
* A few non-standard parameters are defined for compatibility reasons,
* but delegates their work to standard parameters. Those dynamic parameters are not listed in the
* {@linkplain org.opengis.referencing.parameter.ParameterValueGroup#values() parameter values}.
* Dynamic parameters are:
* <p>
* <ul>
* <li>{@code "earth_radius"}, which copy its value to the {@code "semi_major"} and
* {@code "semi_minor"} parameter values.</li>
* <li>{@code "inverse_flattening"}, which compute the {@code "semi_minor"} value from
* the {@code "semi_major"} parameter value.</li>
* <li>{@code "standard_parallel"} expecting an array of type {@code double[]}, which copy
* its elements to the {@code "standard_parallel_1"} and {@code "standard_parallel_2"}
* parameter scalar values.</li>
* </ul>
* <p>
* The main purpose of those dynamic parameters is to support some less commonly used conventions
* without duplicating the most commonly used conventions. The alternative ways are used in NetCDF
* files for example, which often use spherical models instead than ellipsoidal ones.
*
* {@section Mandatory and optional parameters}
*
* <a name="Obligation">Parameters are flagged as either <cite>mandatory</cite> or <cite>optional</cite></a>.
* A parameter may be mandatory and still have a default value. In the context of this package, "mandatory"
* means that the parameter is an essential part of the projection defined by standards. Such
* mandatory parameters will always appears in any <cite>Well Known Text</cite> (WKT) formatting,
* even if not explicitly set by the user. For example the central meridian is typically a mandatory
* parameter with a default value of 0° (the Greenwich meridian).
* <p>
* Optional parameters, on the other hand, are often non-standard extensions. They will appear
* in WKT formatting only if the user defined explicitly a value which is different than the
* default value.
*
*
* {@section Geotoolkit.org extensions}
*
* Geotk defines a {@code "roll_longitude"} boolean parameter.
* If this parameter is set to {@code TRUE}, then any longitude outside the
* [-180 … 180)° range (upper value is exclusive) will be forced to that range by the
* addition or subtraction of some multiple of 360°. This applies to both the input of
* projections and the output of inverse projections.
* <p>
* If this parameter is not provided, then the default behavior is to roll longitudes only if
* the central meridian is different than zero.
*
*
* {@section ESRI extensions}
*
* In Geotk, axis flips are inferred from the {@linkplain org.opengis.referencing.is.AxisOrientation
* axis orientation}. In <cite>Well Known Text</cite> (WKT), they are given by {@code AXIS} elements.
* But ESRI ignores {@code AXIS} elements and uses instead some additional parameters:
* {@code "X_Scale"}, {@code "Y_Scale"} and {@code "XY_Plane_Rotation"}.
* Those parameters are not OGC standards, but are nevertheless provided in Geotk for better
* inter-operability with ESRI definitions of coordinate reference systems.
*
* @author Martin Desruisseaux (Geomatys)
* @author Rueben Schulz (UBC)
* @version 3.20
*
* @see <a href="{@docRoot}/../modules/referencing/operation-parameters.html">Geotk coordinate operations matrix</a>
* @see <a href="http://www.remotesensing.org/geotiff/proj_list">Projections list on RemoteSensing.org</a>
* @see org.geotoolkit.referencing.operation.MathTransformProvider
*
* @since 3.00
* @level advanced
* @module
*/
package org.geotoolkit.referencing.operation.provider;
| UTF-8 | Java | 5,943 | java | package-info.java | Java | [
{
"context": "ons of coordinate reference systems.\n *\n * @author Martin Desruisseaux (Geomatys)\n * @author Rueben Schulz (UBC)\n * @ver",
"end": 5482,
"score": 0.9998261332511902,
"start": 5463,
"tag": "NAME",
"value": "Martin Desruisseaux"
},
{
"context": " @author Martin Desruisseaux (Geomatys)\n * @author Rueben Schulz (UBC)\n * @version 3.20\n *\n * @see <a href=\"{@docR",
"end": 5518,
"score": 0.9998445510864258,
"start": 5505,
"tag": "NAME",
"value": "Rueben Schulz"
}
] | null | [] | /*
* Geotoolkit.org - An Open Source Java GIS Toolkit
* http://www.geotoolkit.org
*
* (C) 2008-2012, Open Source Geospatial Foundation (OSGeo)
* (C) 2009-2012, Geomatys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
/**
* {@linkplain org.geotoolkit.referencing.operation.MathTransformProvider Providers} of
* {@linkplain org.geotoolkit.referencing.operation.transform transforms} and
* {@linkplain org.geotoolkit.referencing.operation.projection projections} implementations.
* This package is provided mostly for documentation purpose, since the javadoc of each provider
* lists the operation names, identifiers (e.g. EPSG codes) and parameters. The preferred way to
* get a provider is to use the {@link org.opengis.referencing.operation.MathTransformFactory} class.
*
* {@section Standard parameters}
*
* Each provider declares a single {@link org.opengis.parameter.ParameterDescriptorGroup} constant
* named {@code PARAMETERS}. Each group describes all the parameters expected by an operation method.
* The set of parameters varies for each projection, but the following can be considered typical:
* <p>
* <ul>
* <li>A <cite>semi-major</cite> and <cite>semi-minor</cite> axis length in metres.</li>
* <li>A <cite>central meridian</cite> and <cite>latitude of origin</cite> in decimal degrees.</li>
* <li>A <cite>scale factor</cite>, which default to 1.</li>
* <li>A <cite>false easting</cite> and <cite>false northing</cite> in metres, which default to 0.</li>
* </ul>
* <p>
* Each descriptor has many aliases, and those aliases may vary between different projections.
* For example the <cite>false easting</cite> parameter is usually called {@code "false_easting"}
* by OGC, while EPSG uses various names like "<cite>False easting</cite>" or "<cite>Easting at
* false origin</cite>".
*
* {@section Dynamic parameters}
*
* A few non-standard parameters are defined for compatibility reasons,
* but delegates their work to standard parameters. Those dynamic parameters are not listed in the
* {@linkplain org.opengis.referencing.parameter.ParameterValueGroup#values() parameter values}.
* Dynamic parameters are:
* <p>
* <ul>
* <li>{@code "earth_radius"}, which copy its value to the {@code "semi_major"} and
* {@code "semi_minor"} parameter values.</li>
* <li>{@code "inverse_flattening"}, which compute the {@code "semi_minor"} value from
* the {@code "semi_major"} parameter value.</li>
* <li>{@code "standard_parallel"} expecting an array of type {@code double[]}, which copy
* its elements to the {@code "standard_parallel_1"} and {@code "standard_parallel_2"}
* parameter scalar values.</li>
* </ul>
* <p>
* The main purpose of those dynamic parameters is to support some less commonly used conventions
* without duplicating the most commonly used conventions. The alternative ways are used in NetCDF
* files for example, which often use spherical models instead than ellipsoidal ones.
*
* {@section Mandatory and optional parameters}
*
* <a name="Obligation">Parameters are flagged as either <cite>mandatory</cite> or <cite>optional</cite></a>.
* A parameter may be mandatory and still have a default value. In the context of this package, "mandatory"
* means that the parameter is an essential part of the projection defined by standards. Such
* mandatory parameters will always appears in any <cite>Well Known Text</cite> (WKT) formatting,
* even if not explicitly set by the user. For example the central meridian is typically a mandatory
* parameter with a default value of 0° (the Greenwich meridian).
* <p>
* Optional parameters, on the other hand, are often non-standard extensions. They will appear
* in WKT formatting only if the user defined explicitly a value which is different than the
* default value.
*
*
* {@section Geotoolkit.org extensions}
*
* Geotk defines a {@code "roll_longitude"} boolean parameter.
* If this parameter is set to {@code TRUE}, then any longitude outside the
* [-180 … 180)° range (upper value is exclusive) will be forced to that range by the
* addition or subtraction of some multiple of 360°. This applies to both the input of
* projections and the output of inverse projections.
* <p>
* If this parameter is not provided, then the default behavior is to roll longitudes only if
* the central meridian is different than zero.
*
*
* {@section ESRI extensions}
*
* In Geotk, axis flips are inferred from the {@linkplain org.opengis.referencing.is.AxisOrientation
* axis orientation}. In <cite>Well Known Text</cite> (WKT), they are given by {@code AXIS} elements.
* But ESRI ignores {@code AXIS} elements and uses instead some additional parameters:
* {@code "X_Scale"}, {@code "Y_Scale"} and {@code "XY_Plane_Rotation"}.
* Those parameters are not OGC standards, but are nevertheless provided in Geotk for better
* inter-operability with ESRI definitions of coordinate reference systems.
*
* @author <NAME> (Geomatys)
* @author <NAME> (UBC)
* @version 3.20
*
* @see <a href="{@docRoot}/../modules/referencing/operation-parameters.html">Geotk coordinate operations matrix</a>
* @see <a href="http://www.remotesensing.org/geotiff/proj_list">Projections list on RemoteSensing.org</a>
* @see org.geotoolkit.referencing.operation.MathTransformProvider
*
* @since 3.00
* @level advanced
* @module
*/
package org.geotoolkit.referencing.operation.provider;
| 5,923 | 0.73229 | 0.725896 | 113 | 51.592922 | 39.076199 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.292035 | false | false | 14 |
271c3ab4826875504be1d995848a1a7c432231ce | 31,705,448,580,833 | 9d5bf34aae27298afef4059860b3cda28b3485a0 | /src/main/java/tropico/PlayerManagement.java | e2a1a57031d889962eea335a05f63c97dc452b1f | [] | no_license | SebastienDS/Tropico | https://github.com/SebastienDS/Tropico | 38556f953be863d7dba0dda76cd5ba886931cade | 54c431fc9583fe20816cefa55b5862942376e6d4 | refs/heads/main | 2023-02-17T05:21:43.136000 | 2021-01-19T22:52:02 | 2021-01-19T22:52:02 | 312,605,693 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package tropico;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import tropico.utils.UtilsDeserialization;
/**
* This class serves as a way to manage the players, using :
* <ul>
* <li>A list of all the players</li>
* <li>The current player</li>
* </ul>
*
* @author Corentin OGER and Sébastien DOS SANTOS
*
*/
public class PlayerManagement implements Serializable {
/**
* Necessary field to avoid warning while implementing Serializable.
*/
private static final long serialVersionUID = 1L;
/**
* The list of all the players of a game.
*/
private final List<Player> players = new ArrayList<>();
/**
* An int to know who is the player that plays this turn. Doesn't have a lot of
* utility outside of this class.
*/
private int currentPlayer = 0;
/**
* <b>PlayerManagement's first constructor</b>
*
* Creates the players' list and the base factions and resources using
* UtilsDeserialization class.
*
* @param path A String containing the path to the json files of the factions
* and the resources.
* @param count An int representing the number of players in this game.
* @throws FileNotFoundException Throws a FileNotFoundException if the path is
* wrong.
*/
public PlayerManagement(String path, int count) throws FileNotFoundException {
if (count <= 0)
throw new IllegalStateException("Must have players");
// Deserializes the factions and resources, which is the same for all players at
// the start
List<Faction> factions = UtilsDeserialization.loadFactions(path + "factions.json");
Resources resources = UtilsDeserialization.loadResources(path + "resources.json");
for (int i = 0; i < count; i++) {
players.add(new Player("Player " + (i + 1), List.copyOf(factions), resources.copy()));
}
}
/**
* <b>PlayerManagement's second constructor</b>
*
* Use this constructor if you want to create a solo game, but choose the
* gamemode.
*
* @param path A String containing the path to the json files of the factions
* and the resources.
* @throws FileNotFoundException Throws a FileNotFoundException if the path is
* wrong.
*/
public PlayerManagement(String path) throws FileNotFoundException {
this(path, 1);
}
/**
* This method gives you the current player using the currentPlayer field.
*
* @return Returns the current player.
*/
public Player getPlayer() {
return players.get(currentPlayer);
}
/**
* Getter for the field currentPlayer.
*
* @return Returns the index of the current player in the list of players.
*/
public int getCurrentPlayer() {
return currentPlayer;
}
/**
* Use this method when a turn is over. In this case, the field currentPlayer is
* incremented or goes back to zero to change the current player.
*/
public void nextTurn() {
currentPlayer = (currentPlayer + 1) % players.size();
}
/**
* Searches if a player is dead.
*
* @return Returns true if a player lost, false otherwise.
*/
public boolean havePlayerDead() {
for (Player player : players) {
if (player.isDead()) {
return true;
}
}
return false;
}
@Override
public String toString() {
return "PlayerManagement{" + "players=" + players + ", currentPlayer=" + currentPlayer + '}';
}
}
| UTF-8 | Java | 3,405 | java | PlayerManagement.java | Java | [
{
"context": "li>The current player</li>\n * </ul>\n * \n * @author Corentin OGER and Sébastien DOS SANTOS\n *\n */\npublic class Play",
"end": 360,
"score": 0.9998793601989746,
"start": 347,
"tag": "NAME",
"value": "Corentin OGER"
},
{
"context": "yer</li>\n * </ul>\n * \n * @author Corentin OGER and Sébastien DOS SANTOS\n *\n */\npublic class PlayerManagement implements S",
"end": 385,
"score": 0.9998586773872375,
"start": 365,
"tag": "NAME",
"value": "Sébastien DOS SANTOS"
}
] | null | [] | package tropico;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import tropico.utils.UtilsDeserialization;
/**
* This class serves as a way to manage the players, using :
* <ul>
* <li>A list of all the players</li>
* <li>The current player</li>
* </ul>
*
* @author <NAME> and <NAME>
*
*/
public class PlayerManagement implements Serializable {
/**
* Necessary field to avoid warning while implementing Serializable.
*/
private static final long serialVersionUID = 1L;
/**
* The list of all the players of a game.
*/
private final List<Player> players = new ArrayList<>();
/**
* An int to know who is the player that plays this turn. Doesn't have a lot of
* utility outside of this class.
*/
private int currentPlayer = 0;
/**
* <b>PlayerManagement's first constructor</b>
*
* Creates the players' list and the base factions and resources using
* UtilsDeserialization class.
*
* @param path A String containing the path to the json files of the factions
* and the resources.
* @param count An int representing the number of players in this game.
* @throws FileNotFoundException Throws a FileNotFoundException if the path is
* wrong.
*/
public PlayerManagement(String path, int count) throws FileNotFoundException {
if (count <= 0)
throw new IllegalStateException("Must have players");
// Deserializes the factions and resources, which is the same for all players at
// the start
List<Faction> factions = UtilsDeserialization.loadFactions(path + "factions.json");
Resources resources = UtilsDeserialization.loadResources(path + "resources.json");
for (int i = 0; i < count; i++) {
players.add(new Player("Player " + (i + 1), List.copyOf(factions), resources.copy()));
}
}
/**
* <b>PlayerManagement's second constructor</b>
*
* Use this constructor if you want to create a solo game, but choose the
* gamemode.
*
* @param path A String containing the path to the json files of the factions
* and the resources.
* @throws FileNotFoundException Throws a FileNotFoundException if the path is
* wrong.
*/
public PlayerManagement(String path) throws FileNotFoundException {
this(path, 1);
}
/**
* This method gives you the current player using the currentPlayer field.
*
* @return Returns the current player.
*/
public Player getPlayer() {
return players.get(currentPlayer);
}
/**
* Getter for the field currentPlayer.
*
* @return Returns the index of the current player in the list of players.
*/
public int getCurrentPlayer() {
return currentPlayer;
}
/**
* Use this method when a turn is over. In this case, the field currentPlayer is
* incremented or goes back to zero to change the current player.
*/
public void nextTurn() {
currentPlayer = (currentPlayer + 1) % players.size();
}
/**
* Searches if a player is dead.
*
* @return Returns true if a player lost, false otherwise.
*/
public boolean havePlayerDead() {
for (Player player : players) {
if (player.isDead()) {
return true;
}
}
return false;
}
@Override
public String toString() {
return "PlayerManagement{" + "players=" + players + ", currentPlayer=" + currentPlayer + '}';
}
}
| 3,383 | 0.679495 | 0.677438 | 123 | 26.674797 | 28.116915 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.203252 | false | false | 14 |
87307e002cf166e6717767dc24c21bb1dcffd824 | 15,470,472,212,611 | 014f566ab22cc6dabe1ec7237077fa2c44b71d57 | /java/spring/spring-all-in-one/15-spring-method-security/src/main/java/com/wjiec/springaio/method/security/service/SystemService.java | 49ca06ab7ceac56d904e8d1a5635bcc2297603aa | [
"MIT"
] | permissive | JShadowMan/packages | https://github.com/JShadowMan/packages | ab2b6c56854601923c0334e051ff47b0e4540b95 | 755ee1918e2fca5f414131eb028f222da095ba45 | refs/heads/master | 2021-05-22T10:49:33.556000 | 2021-05-20T15:23:04 | 2021-05-20T15:23:04 | 48,322,192 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wjiec.springaio.method.security.service;
import com.wjiec.springaio.method.security.model.Setting;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Service;
import javax.annotation.security.RolesAllowed;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Service
public class SystemService {
@Secured("ROLE_ADMIN")
public void shutdown() {
System.out.println("SystemService::shutdown");
}
@RolesAllowed({"ROLE_USER", "ROLE_ADMIN"})
public void syncTimezone() {
System.out.println("SystemService::stat");
}
@PreAuthorize("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and #message.length() <= 10)")
public void broadcast(String message) {
System.out.println("SystemService::broadcast -> " + message);
}
@PostAuthorize("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and returnObject.id < 10)")
public Setting getSettingById(long id) {
return Setting.builder()
.id(id)
.name("setting-" + id)
.value("value-" + id)
.build();
}
@PostFilter("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and filterObject.id < 10) or (filterObject.id == 0)")
public List<Setting> stat() {
return new ArrayList<>(List.of(
Setting.builder().id(0L).name("opening").value("on").build(),
Setting.builder().id(1L).name("customer").value("spring").build(),
Setting.builder().id(10L).name("profit").value("123").build()
));
}
@RolesAllowed({"ROLE_ADMIN", "ROLE_USER"})
@PreFilter("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and filterObject.id < 10)")
public void update(List<Setting> settings) {
System.out.println("Update setting : " + settings);
}
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER')")
@PreFilter("hasPermission(filterObject, 'delete')")
public void delete(List<Setting> settings) {
System.out.println("Delete setting : " + settings);
}
public static class SettingPermissionEvaluator implements PermissionEvaluator {
private static final GrantedAuthority ROLE_ADMIN_AUTHORITY = new SimpleGrantedAuthority("ROLE_ADMIN");
@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
if (targetDomainObject instanceof Setting) {
return isAdmin(authentication) || ((Setting) targetDomainObject).getId() < 10;
}
throw new UnsupportedOperationException();
}
@Override
public boolean hasPermission(Authentication authentication, Serializable targetId,
String targetType, Object permission) {
throw new UnsupportedOperationException();
}
private boolean isAdmin(Authentication authentication) {
return authentication.getAuthorities().contains(ROLE_ADMIN_AUTHORITY);
}
}
}
| UTF-8 | Java | 3,666 | java | SystemService.java | Java | [] | null | [] | package com.wjiec.springaio.method.security.service;
import com.wjiec.springaio.method.security.model.Setting;
import org.springframework.security.access.PermissionEvaluator;
import org.springframework.security.access.annotation.Secured;
import org.springframework.security.access.prepost.PostAuthorize;
import org.springframework.security.access.prepost.PostFilter;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.access.prepost.PreFilter;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.stereotype.Service;
import javax.annotation.security.RolesAllowed;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@Service
public class SystemService {
@Secured("ROLE_ADMIN")
public void shutdown() {
System.out.println("SystemService::shutdown");
}
@RolesAllowed({"ROLE_USER", "ROLE_ADMIN"})
public void syncTimezone() {
System.out.println("SystemService::stat");
}
@PreAuthorize("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and #message.length() <= 10)")
public void broadcast(String message) {
System.out.println("SystemService::broadcast -> " + message);
}
@PostAuthorize("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and returnObject.id < 10)")
public Setting getSettingById(long id) {
return Setting.builder()
.id(id)
.name("setting-" + id)
.value("value-" + id)
.build();
}
@PostFilter("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and filterObject.id < 10) or (filterObject.id == 0)")
public List<Setting> stat() {
return new ArrayList<>(List.of(
Setting.builder().id(0L).name("opening").value("on").build(),
Setting.builder().id(1L).name("customer").value("spring").build(),
Setting.builder().id(10L).name("profit").value("123").build()
));
}
@RolesAllowed({"ROLE_ADMIN", "ROLE_USER"})
@PreFilter("hasRole('ROLE_ADMIN') or (hasRole('ROLE_USER') and filterObject.id < 10)")
public void update(List<Setting> settings) {
System.out.println("Update setting : " + settings);
}
@PreAuthorize("hasAnyRole('ROLE_ADMIN', 'ROLE_USER')")
@PreFilter("hasPermission(filterObject, 'delete')")
public void delete(List<Setting> settings) {
System.out.println("Delete setting : " + settings);
}
public static class SettingPermissionEvaluator implements PermissionEvaluator {
private static final GrantedAuthority ROLE_ADMIN_AUTHORITY = new SimpleGrantedAuthority("ROLE_ADMIN");
@Override
public boolean hasPermission(Authentication authentication, Object targetDomainObject, Object permission) {
if (targetDomainObject instanceof Setting) {
return isAdmin(authentication) || ((Setting) targetDomainObject).getId() < 10;
}
throw new UnsupportedOperationException();
}
@Override
public boolean hasPermission(Authentication authentication, Serializable targetId,
String targetType, Object permission) {
throw new UnsupportedOperationException();
}
private boolean isAdmin(Authentication authentication) {
return authentication.getAuthorities().contains(ROLE_ADMIN_AUTHORITY);
}
}
}
| 3,666 | 0.666394 | 0.661484 | 93 | 37.419353 | 32.19775 | 117 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.44086 | false | false | 14 |
219c435e99e4247f10a4e08c363a57ea0d9033d9 | 19,095,424,640,514 | 2ea5c734dce119e34057c3d3a1029cf8c9d1df90 | /my collections/src/learncollections/SyncronizedArrayList.java | f4144b46bc106181677ef3e1fa450703ee7cd155 | [] | no_license | ajitgaurkhede/Collections-Concepts | https://github.com/ajitgaurkhede/Collections-Concepts | 68a9616aeb3b52e4c49c68948911fefb59d31e73 | 5dc1a985a9d7213f57ba3323823bed614d81df18 | refs/heads/main | 2023-02-27T05:35:12.427000 | 2021-02-04T12:05:53 | 2021-02-04T12:05:53 | 335,941,363 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package learncollections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class SyncronizedArrayList {
public static void main(String[] args) {
// 1. Coolections.synchronizedList
List<String> nameList = Collections.synchronizedList(new ArrayList<String>());
nameList.add("Java");
nameList.add("python");
nameList.add("Ruby");
// add, remove - we don't need explicit synchronization
// to fetch/traverse the values from this -- we have to use explicit synchronization
synchronized(nameList) {
Iterator<String> it = nameList.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
}
//2. CopyOnWriteArrayList -- its a class:
CopyOnWriteArrayList<String> empList = new CopyOnWriteArrayList<String>();
empList.add("Tom");
empList.add("Steve");
empList.add("Jerry");
// we dont need explicit synchronization for any operation : add / remove / traverse
Iterator<String> it = empList.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
}
}
| UTF-8 | Java | 1,311 | java | SyncronizedArrayList.java | Java | [
{
"context": "pyOnWriteArrayList<String>();\r\n\t\t\r\n\t\tempList.add(\"Tom\");\r\n\t\t\r\n\t\tempList.add(\"Steve\");\r\n\t\t\r\n\t\tempList.ad",
"end": 994,
"score": 0.9995510578155518,
"start": 991,
"tag": "NAME",
"value": "Tom"
},
{
"context": ");\r\n\t\t\r\n\t\tempList.add(\"Tom\");\r\n\t\t\r\n\t\tempList.add(\"Steve\");\r\n\t\t\r\n\t\tempList.add(\"Jerry\");\r\n\t\t\r\n\t\t// we dont",
"end": 1023,
"score": 0.9987532496452332,
"start": 1018,
"tag": "NAME",
"value": "Steve"
},
{
"context": "\r\n\t\t\r\n\t\tempList.add(\"Steve\");\r\n\t\t\r\n\t\tempList.add(\"Jerry\");\r\n\t\t\r\n\t\t// we dont need explicit synchronizatio",
"end": 1052,
"score": 0.9995911121368408,
"start": 1047,
"tag": "NAME",
"value": "Jerry"
}
] | null | [] | package learncollections;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class SyncronizedArrayList {
public static void main(String[] args) {
// 1. Coolections.synchronizedList
List<String> nameList = Collections.synchronizedList(new ArrayList<String>());
nameList.add("Java");
nameList.add("python");
nameList.add("Ruby");
// add, remove - we don't need explicit synchronization
// to fetch/traverse the values from this -- we have to use explicit synchronization
synchronized(nameList) {
Iterator<String> it = nameList.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
}
//2. CopyOnWriteArrayList -- its a class:
CopyOnWriteArrayList<String> empList = new CopyOnWriteArrayList<String>();
empList.add("Tom");
empList.add("Steve");
empList.add("Jerry");
// we dont need explicit synchronization for any operation : add / remove / traverse
Iterator<String> it = empList.iterator();
while(it.hasNext()) {
System.out.println(it.next());
}
}
}
| 1,311 | 0.623188 | 0.621663 | 71 | 16.464788 | 21.844412 | 86 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.056338 | false | false | 14 |
385e08fe8cfebd27b03286531c5d6f7e0fd09c35 | 33,131,377,766,840 | 026364938826fa256fbb9ffca137a055373ac79b | /demo/src/main/java/com/example/GeoLookUpHistory.java | ccf9f2ce6d9fcc7df493a9576ca6a47c15e272a4 | [] | no_license | danmc2007/geolookup | https://github.com/danmc2007/geolookup | 3dd136caa3139a20287fb1486cf4fc207ed9a0db | 31f1a0b596f0b7306d0b9370c538f888422cceda | refs/heads/master | 2021-01-22T07:39:48.170000 | 2017-02-16T23:32:47 | 2017-02-16T23:32:47 | 81,842,789 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* © 2002-2017 AT&T Knowledge Ventures, L.P. All rights reserved.
*/
package com.example;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
@Entity
public class GeoLookUpHistory implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
protected long id;
@Version
protected int version;
double latitude;
double longitude;
String address;
Date timeStamp;
public double getLatitude()
{
return latitude;
}
public void setLatitude(double latitude)
{
this.latitude = latitude;
}
public double getLongitude()
{
return longitude;
}
public void setLongitude(double longitude)
{
this.longitude = longitude;
}
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public Date getTimeStamp()
{
return timeStamp;
}
public void setTimeStamp(Date timeStamp)
{
this.timeStamp = timeStamp;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address = address;
}
}
| UTF-8 | Java | 1,465 | java | GeoLookUpHistory.java | Java | [] | null | [] | /*
* © 2002-2017 AT&T Knowledge Ventures, L.P. All rights reserved.
*/
package com.example;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Version;
@Entity
public class GeoLookUpHistory implements Serializable
{
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
protected long id;
@Version
protected int version;
double latitude;
double longitude;
String address;
Date timeStamp;
public double getLatitude()
{
return latitude;
}
public void setLatitude(double latitude)
{
this.latitude = latitude;
}
public double getLongitude()
{
return longitude;
}
public void setLongitude(double longitude)
{
this.longitude = longitude;
}
public long getId()
{
return id;
}
public void setId(long id)
{
this.id = id;
}
public Date getTimeStamp()
{
return timeStamp;
}
public void setTimeStamp(Date timeStamp)
{
this.timeStamp = timeStamp;
}
public String getAddress()
{
return address;
}
public void setAddress(String address)
{
this.address = address;
}
}
| 1,465 | 0.627049 | 0.620902 | 87 | 14.827586 | 16.27932 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.298851 | false | false | 14 |
bce1edef724ce6a7e1b5c49dbb44422344c9100b | 13,761,075,260,934 | f12fe1cea95f5fb8d7d36fd82f8296b5cd325a88 | /src/main/java/cn/luojia/domain/Export.java | 45d8a72e96a2c7b48b8c79daaab9e6dcb1cb4f0d | [] | no_license | Romantic-Lei/luojiaBusiness | https://github.com/Romantic-Lei/luojiaBusiness | 1d44ad3ce6086547c3c3c61e2856c7555242896e | d6cddb55acb9c1e7bfc06d107a56328ff52de116 | refs/heads/master | 2022-12-21T13:12:46.287000 | 2020-05-07T12:44:30 | 2020-05-07T12:44:30 | 238,875,549 | 4 | 1 | null | false | 2022-12-16T09:41:45 | 2020-02-07T08:25:18 | 2020-07-03T01:28:18 | 2022-12-16T09:41:42 | 54,833 | 2 | 0 | 13 | Java | false | false | package cn.luojia.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @author luojiaBusiness
* @CreateDate 2020年2月14日
* @Description 货物报运
*/
@Data
public class Export implements Serializable {
private String id;
private Date inputDate;
private String epnum; //报运货物数
private String extnum; //报运附件数
private String contractIds; //打断设计,合同的ID集合
private String customerContract; //合同或确认书号
private String lcno; //信用证号
private String consignee; //收货人及地址
private String marks; //唛头
private String remark; //说明
private String shipmentPort; //装运港
private String destinationPort; //目的港
private String transportMode; //运输方式
private String priceCondition; //价格条件
private Integer state; //0-草稿 1-已上报 2-装箱 3-委托 4-发票 5-财务
private Double grossWeight; //毛重
private Double netWeight; //净重
private Double measurement; //体积
private String createBy;
private String createDept;
private Date createTime;
}
| UTF-8 | Java | 1,149 | java | Export.java | Java | [
{
"context": "til.Date;\n\nimport lombok.Data;\n\n/**\n * \n * @author luojiaBusiness\n * @CreateDate 2020年2月14日\n * @Description 货物报运\n *",
"end": 134,
"score": 0.9994970560073853,
"start": 120,
"tag": "USERNAME",
"value": "luojiaBusiness"
}
] | null | [] | package cn.luojia.domain;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
*
* @author luojiaBusiness
* @CreateDate 2020年2月14日
* @Description 货物报运
*/
@Data
public class Export implements Serializable {
private String id;
private Date inputDate;
private String epnum; //报运货物数
private String extnum; //报运附件数
private String contractIds; //打断设计,合同的ID集合
private String customerContract; //合同或确认书号
private String lcno; //信用证号
private String consignee; //收货人及地址
private String marks; //唛头
private String remark; //说明
private String shipmentPort; //装运港
private String destinationPort; //目的港
private String transportMode; //运输方式
private String priceCondition; //价格条件
private Integer state; //0-草稿 1-已上报 2-装箱 3-委托 4-发票 5-财务
private Double grossWeight; //毛重
private Double netWeight; //净重
private Double measurement; //体积
private String createBy;
private String createDept;
private Date createTime;
}
| 1,149 | 0.72847 | 0.715299 | 40 | 23.674999 | 15.584267 | 59 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.475 | false | false | 14 |
17573bc16bd8c6fb85faa4f7a9fc38fab6dc7930 | 25,950,192,417,503 | 23f5e9ddee7f329d082aa980585f71f22c9cb2fb | /flink-hadoop/src/main/java/com/lzhpo/flinkhadoop/utils/HadoopUtil.java | bc81c8b01eacd724b1d435bf21fe2c2d72966e87 | [] | no_license | changsongyang/flink-tool | https://github.com/changsongyang/flink-tool | 2f5c011fc713c6892217df7aba8afb71415c5458 | 610df3c2131989341eee885433b70990ae3dcf0a | refs/heads/master | 2022-11-25T08:49:40.240000 | 2020-07-28T15:47:54 | 2020-07-28T15:47:54 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.lzhpo.flinkhadoop.utils;
import com.lzhpo.flinkhadoop.config.HadoopConnectionConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.Progressable;
import java.io.*;
/**
* 封装的HDFS操作工具
*
* @author Zhaopo Liu
* @date 2020/6/20 03:14
*/
@Slf4j
public class HadoopUtil {
private HadoopConnectionConfig hadoopConnectionConfig;
protected FileSystem fileSystem;
public HadoopUtil(HadoopConnectionConfig hadoopConnectionConfig) {
this.hadoopConnectionConfig = hadoopConnectionConfig;
}
/**
* 创建目录
* <p>
* 支持递归创建目录
*
* @param filePath 目录
* @throws Exception Exception
* @return boolean 成功与否
*/
public boolean mkDir(String filePath) throws Exception {
try {
return fileSystem.mkdirs(new Path(filePath));
} catch (IOException | IllegalArgumentException e) {
log.error("创建目录 {} 失败!", filePath, e);
return false;
}
}
/**
* 创建指定权限的目录
* <p>
* FsPermission(FsAction u, FsAction g, FsAction o) 的三个参数分别对应:
* 创建者权限,同组其他用户权限,其他用户权限,权限值定义在 FsAction 枚举类中。
*
* @param filePath
* @param u
* @param g
* @param o
* @throws Exception
* @return boolean 成功与否
*/
public boolean mkDirWithPermission(String filePath,
FsAction u, FsAction g, FsAction o) throws Exception {
// fileSystem.mkdirs(new Path("/hdfs-api/test1/"), new FsPermission(FsAction.READ_WRITE, FsAction.READ, FsAction.READ));
try {
return fileSystem.mkdirs(new Path(filePath), new FsPermission(u, g, o));
} catch (IOException | IllegalArgumentException e) {
log.error("创建目录 {} 失败!", filePath, e);
return false;
}
}
/**
* 创建文件,并写入内容
*
* @throws Exception
* @return boolean 成功与否
*/
public boolean create(String fileWithPath, byte[] dataBytes, boolean overwrite, Integer bufferSize) throws Exception {
// 如果文件存在,默认会覆盖, 可以通过第二个参数进行控制。第三个参数可以控制使用缓冲区的大小
try {
FSDataOutputStream out = fileSystem.create(new Path(fileWithPath), overwrite, bufferSize);
out.write(dataBytes);
// 强制将缓冲区中内容刷出
out.flush();
out.close();
return true;
} catch (IOException | IllegalArgumentException e) {
log.error("创建文件 {} 写入内容失败!", fileWithPath, e);
return false;
}
}
/**
* 判断文件是否存在
*
* @param fileWithPath
* @throws Exception
* @return boolean 是否存在
*/
public boolean exist(String fileWithPath) throws Exception {
return fileSystem.exists(new Path(fileWithPath));
}
/**
* 查看文件内容
*
* @param fileWithPath
* @param encode 编码,例如:UTF-8
* @throws Exception
* @return boolean 是否存在
*/
public String readToString(String fileWithPath, String encode) throws Exception {
FSDataInputStream inputStream = fileSystem.open(new Path(fileWithPath));
String content = inputStreamToString(inputStream, encode);
log.info("文件内容:{}", content);
return content;
}
/**
* 文件重命名
*
* @param oldFileWithPath 旧文件名称以及路径
* @param newFileWithPath 新文件名称以及路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean rename(String oldFileWithPath, String newFileWithPath) throws Exception {
Path oldPath = new Path(oldFileWithPath);
Path newPath = new Path(newFileWithPath);
return fileSystem.rename(oldPath, newPath);
}
/**
* 删除目录或文件
*
* @param fileWithPath 要删除的文件以及路径
* @param recursiveDelete 是否递归删除
* @throws Exception Exception
* @return boolean 结果
*/
public boolean delete(String fileWithPath, boolean recursiveDelete) throws Exception {
/*
* 第二个参数代表是否递归删除
* + 如果 path 是一个目录且递归删除为 true, 则删除该目录及其中所有文件;
* + 如果 path 是一个目录但递归删除为 false,则会则抛出异常。
*/
return fileSystem.delete(new Path(fileWithPath), recursiveDelete);
}
/**
* 上传文件到HDFS
*
* @param localFileWithPath 需要上传的文件路径
* @param hdfsFileWithPath 上传到HDFS的文件路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyFromLocalFile(String localFileWithPath, String hdfsFileWithPath) throws Exception {
try {
// 如果指定的是目录,则会把目录及其中的文件都复制到指定目录下
Path src = new Path(localFileWithPath);
Path dst = new Path(hdfsFileWithPath);
fileSystem.copyFromLocalFile(src, dst);
return true;
} catch (IllegalArgumentException | IOException e) {
return false;
}
}
/**
* 上传大文件并显示上传进度
*
* @param localFileWithPath 需要上传的文件路径
* @param hdfsFileWithPath 上传到HDFS的文件路径
* @param bufferSize 缓冲大小 例如:4096
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyFromLocalBigFile(String localFileWithPath, String hdfsFileWithPath, Integer bufferSize) throws Exception {
try {
File file = new File(localFileWithPath);
final float fileSize = file.length();
InputStream in = new BufferedInputStream(new FileInputStream(file));
FSDataOutputStream out = fileSystem.create(new Path(hdfsFileWithPath),
new Progressable() {
long fileCount = 0;
@Override
public void progress() {
fileCount++;
// progress 方法每上传大约 64KB 的数据后就会被调用一次
System.out.println("上传进度:" + (fileCount * 64 * 1024 / fileSize) * 100 + " %");
}
});
IOUtils.copyBytes(in, out, bufferSize);
return true;
} catch (IOException | IllegalArgumentException e) {
e.printStackTrace();
log.error("上传大文件 {} 到HDFS失败!", localFileWithPath, e);
return false;
}
}
/**
* 从HDFS上下载文件
*
* @param hdfsFileWithPath hdfs上的文件路径
* @param downLoadToLocalPath 下载到本地的文件路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyToLocalFile(String hdfsFileWithPath, String downLoadToLocalPath) throws Exception {
try {
Path src = new Path(hdfsFileWithPath);
Path dst = new Path(downLoadToLocalPath);
/*
* 第一个参数控制下载完成后是否删除源文件,默认是 true,即删除;
* 最后一个参数表示是否将 RawLocalFileSystem 用作本地文件系统;
* RawLocalFileSystem 默认为 false,通常情况下可以不设置,
* 但如果你在执行时候抛出 NullPointerException 异常,则代表你的文件系统与程序可能存在不兼容的情况 (window 下常见),
* 此时可以将 RawLocalFileSystem 设置为 true
*/
fileSystem.copyToLocalFile(false, src, dst, true);
return true;
} catch (IllegalArgumentException | IOException e) {
log.error("从HDFS上读取文件 {} 失败!", hdfsFileWithPath, e);
return false;
}
}
/**
* 查看指定目录下所有文件的信息
*
* @param hdfsFilePath hdfs上的文件目录
* @throws Exception Exception
* @return String 结果
*/
public String listFiles(String hdfsFilePath) throws Exception {
FileStatus[] statuses = fileSystem.listStatus(new Path(hdfsFilePath));
for (FileStatus fileStatus : statuses) {
//fileStatus 的 toString 方法被重写过,直接打印可以看到所有信息
System.out.println(fileStatus.toString());
}
return statuses.toString();
}
/**
* 递归查看指定目录下所有文件的信息
*
* @param hdfsFilePath hdfs上的文件目录
* @param recursiveDelete 是否递归查看
* @throws Exception Exception
* @return String 结果
*/
public String listFilesRecursive(String hdfsFilePath, boolean recursiveDelete) throws Exception {
RemoteIterator<LocatedFileStatus> files = fileSystem.listFiles(new Path(hdfsFilePath), recursiveDelete);
while (files.hasNext()) {
System.out.println(files.next());
}
return files.toString();
}
/**
* 查看文件的块信息
*
* @param hdfsFileWithPath hdfs上的文件以及路径
* @throws Exception Exception
* @return String 结果
*/
public String getFileBlockLocations(String hdfsFileWithPath) throws Exception {
FileStatus fileStatus = fileSystem.getFileStatus(new Path(hdfsFileWithPath));
BlockLocation[] blocks = fileSystem.getFileBlockLocations(fileStatus, 0, fileStatus.getLen());
for (BlockLocation block : blocks) {
System.out.println(block);
}
return blocks.toString();
}
/**
* 把输入流转换为指定编码的字符
*
* @param inputStream 输入流
* @param encode 指定编码类型
*/
private String inputStreamToString(InputStream inputStream, String encode) {
try {
if (encode == null || ("".equals(encode))) {
encode = "utf-8";
}
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, encode));
StringBuilder builder = new StringBuilder();
String str = "";
while ((str = reader.readLine()) != null) {
builder.append(str).append("\n");
}
return builder.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
| UTF-8 | Java | 11,016 | java | HadoopUtil.java | Java | [
{
"context": "mport java.io.*;\n\n/**\n * 封装的HDFS操作工具\n *\n * @author Zhaopo Liu\n * @date 2020/6/20 03:14\n */\n@Slf4j\npublic class ",
"end": 409,
"score": 0.9998530745506287,
"start": 399,
"tag": "NAME",
"value": "Zhaopo Liu"
}
] | null | [] | package com.lzhpo.flinkhadoop.utils;
import com.lzhpo.flinkhadoop.config.HadoopConnectionConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.hadoop.fs.*;
import org.apache.hadoop.fs.permission.FsAction;
import org.apache.hadoop.fs.permission.FsPermission;
import org.apache.hadoop.io.IOUtils;
import org.apache.hadoop.util.Progressable;
import java.io.*;
/**
* 封装的HDFS操作工具
*
* @author <NAME>
* @date 2020/6/20 03:14
*/
@Slf4j
public class HadoopUtil {
private HadoopConnectionConfig hadoopConnectionConfig;
protected FileSystem fileSystem;
public HadoopUtil(HadoopConnectionConfig hadoopConnectionConfig) {
this.hadoopConnectionConfig = hadoopConnectionConfig;
}
/**
* 创建目录
* <p>
* 支持递归创建目录
*
* @param filePath 目录
* @throws Exception Exception
* @return boolean 成功与否
*/
public boolean mkDir(String filePath) throws Exception {
try {
return fileSystem.mkdirs(new Path(filePath));
} catch (IOException | IllegalArgumentException e) {
log.error("创建目录 {} 失败!", filePath, e);
return false;
}
}
/**
* 创建指定权限的目录
* <p>
* FsPermission(FsAction u, FsAction g, FsAction o) 的三个参数分别对应:
* 创建者权限,同组其他用户权限,其他用户权限,权限值定义在 FsAction 枚举类中。
*
* @param filePath
* @param u
* @param g
* @param o
* @throws Exception
* @return boolean 成功与否
*/
public boolean mkDirWithPermission(String filePath,
FsAction u, FsAction g, FsAction o) throws Exception {
// fileSystem.mkdirs(new Path("/hdfs-api/test1/"), new FsPermission(FsAction.READ_WRITE, FsAction.READ, FsAction.READ));
try {
return fileSystem.mkdirs(new Path(filePath), new FsPermission(u, g, o));
} catch (IOException | IllegalArgumentException e) {
log.error("创建目录 {} 失败!", filePath, e);
return false;
}
}
/**
* 创建文件,并写入内容
*
* @throws Exception
* @return boolean 成功与否
*/
public boolean create(String fileWithPath, byte[] dataBytes, boolean overwrite, Integer bufferSize) throws Exception {
// 如果文件存在,默认会覆盖, 可以通过第二个参数进行控制。第三个参数可以控制使用缓冲区的大小
try {
FSDataOutputStream out = fileSystem.create(new Path(fileWithPath), overwrite, bufferSize);
out.write(dataBytes);
// 强制将缓冲区中内容刷出
out.flush();
out.close();
return true;
} catch (IOException | IllegalArgumentException e) {
log.error("创建文件 {} 写入内容失败!", fileWithPath, e);
return false;
}
}
/**
* 判断文件是否存在
*
* @param fileWithPath
* @throws Exception
* @return boolean 是否存在
*/
public boolean exist(String fileWithPath) throws Exception {
return fileSystem.exists(new Path(fileWithPath));
}
/**
* 查看文件内容
*
* @param fileWithPath
* @param encode 编码,例如:UTF-8
* @throws Exception
* @return boolean 是否存在
*/
public String readToString(String fileWithPath, String encode) throws Exception {
FSDataInputStream inputStream = fileSystem.open(new Path(fileWithPath));
String content = inputStreamToString(inputStream, encode);
log.info("文件内容:{}", content);
return content;
}
/**
* 文件重命名
*
* @param oldFileWithPath 旧文件名称以及路径
* @param newFileWithPath 新文件名称以及路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean rename(String oldFileWithPath, String newFileWithPath) throws Exception {
Path oldPath = new Path(oldFileWithPath);
Path newPath = new Path(newFileWithPath);
return fileSystem.rename(oldPath, newPath);
}
/**
* 删除目录或文件
*
* @param fileWithPath 要删除的文件以及路径
* @param recursiveDelete 是否递归删除
* @throws Exception Exception
* @return boolean 结果
*/
public boolean delete(String fileWithPath, boolean recursiveDelete) throws Exception {
/*
* 第二个参数代表是否递归删除
* + 如果 path 是一个目录且递归删除为 true, 则删除该目录及其中所有文件;
* + 如果 path 是一个目录但递归删除为 false,则会则抛出异常。
*/
return fileSystem.delete(new Path(fileWithPath), recursiveDelete);
}
/**
* 上传文件到HDFS
*
* @param localFileWithPath 需要上传的文件路径
* @param hdfsFileWithPath 上传到HDFS的文件路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyFromLocalFile(String localFileWithPath, String hdfsFileWithPath) throws Exception {
try {
// 如果指定的是目录,则会把目录及其中的文件都复制到指定目录下
Path src = new Path(localFileWithPath);
Path dst = new Path(hdfsFileWithPath);
fileSystem.copyFromLocalFile(src, dst);
return true;
} catch (IllegalArgumentException | IOException e) {
return false;
}
}
/**
* 上传大文件并显示上传进度
*
* @param localFileWithPath 需要上传的文件路径
* @param hdfsFileWithPath 上传到HDFS的文件路径
* @param bufferSize 缓冲大小 例如:4096
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyFromLocalBigFile(String localFileWithPath, String hdfsFileWithPath, Integer bufferSize) throws Exception {
try {
File file = new File(localFileWithPath);
final float fileSize = file.length();
InputStream in = new BufferedInputStream(new FileInputStream(file));
FSDataOutputStream out = fileSystem.create(new Path(hdfsFileWithPath),
new Progressable() {
long fileCount = 0;
@Override
public void progress() {
fileCount++;
// progress 方法每上传大约 64KB 的数据后就会被调用一次
System.out.println("上传进度:" + (fileCount * 64 * 1024 / fileSize) * 100 + " %");
}
});
IOUtils.copyBytes(in, out, bufferSize);
return true;
} catch (IOException | IllegalArgumentException e) {
e.printStackTrace();
log.error("上传大文件 {} 到HDFS失败!", localFileWithPath, e);
return false;
}
}
/**
* 从HDFS上下载文件
*
* @param hdfsFileWithPath hdfs上的文件路径
* @param downLoadToLocalPath 下载到本地的文件路径
* @throws Exception Exception
* @return boolean 结果
*/
public boolean copyToLocalFile(String hdfsFileWithPath, String downLoadToLocalPath) throws Exception {
try {
Path src = new Path(hdfsFileWithPath);
Path dst = new Path(downLoadToLocalPath);
/*
* 第一个参数控制下载完成后是否删除源文件,默认是 true,即删除;
* 最后一个参数表示是否将 RawLocalFileSystem 用作本地文件系统;
* RawLocalFileSystem 默认为 false,通常情况下可以不设置,
* 但如果你在执行时候抛出 NullPointerException 异常,则代表你的文件系统与程序可能存在不兼容的情况 (window 下常见),
* 此时可以将 RawLocalFileSystem 设置为 true
*/
fileSystem.copyToLocalFile(false, src, dst, true);
return true;
} catch (IllegalArgumentException | IOException e) {
log.error("从HDFS上读取文件 {} 失败!", hdfsFileWithPath, e);
return false;
}
}
/**
* 查看指定目录下所有文件的信息
*
* @param hdfsFilePath hdfs上的文件目录
* @throws Exception Exception
* @return String 结果
*/
public String listFiles(String hdfsFilePath) throws Exception {
FileStatus[] statuses = fileSystem.listStatus(new Path(hdfsFilePath));
for (FileStatus fileStatus : statuses) {
//fileStatus 的 toString 方法被重写过,直接打印可以看到所有信息
System.out.println(fileStatus.toString());
}
return statuses.toString();
}
/**
* 递归查看指定目录下所有文件的信息
*
* @param hdfsFilePath hdfs上的文件目录
* @param recursiveDelete 是否递归查看
* @throws Exception Exception
* @return String 结果
*/
public String listFilesRecursive(String hdfsFilePath, boolean recursiveDelete) throws Exception {
RemoteIterator<LocatedFileStatus> files = fileSystem.listFiles(new Path(hdfsFilePath), recursiveDelete);
while (files.hasNext()) {
System.out.println(files.next());
}
return files.toString();
}
/**
* 查看文件的块信息
*
* @param hdfsFileWithPath hdfs上的文件以及路径
* @throws Exception Exception
* @return String 结果
*/
public String getFileBlockLocations(String hdfsFileWithPath) throws Exception {
FileStatus fileStatus = fileSystem.getFileStatus(new Path(hdfsFileWithPath));
BlockLocation[] blocks = fileSystem.getFileBlockLocations(fileStatus, 0, fileStatus.getLen());
for (BlockLocation block : blocks) {
System.out.println(block);
}
return blocks.toString();
}
/**
* 把输入流转换为指定编码的字符
*
* @param inputStream 输入流
* @param encode 指定编码类型
*/
private String inputStreamToString(InputStream inputStream, String encode) {
try {
if (encode == null || ("".equals(encode))) {
encode = "utf-8";
}
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, encode));
StringBuilder builder = new StringBuilder();
String str = "";
while ((str = reader.readLine()) != null) {
builder.append(str).append("\n");
}
return builder.toString();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
| 11,012 | 0.599813 | 0.596286 | 307 | 30.394136 | 27.201344 | 129 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.47557 | false | false | 3 |
1f06adb5c360737dd4436db53d633909eb3fb257 | 18,253,611,011,658 | 7f5976f2a5bc9a3d21e94dc5c6a081681080fb97 | /src/main/java/com/michal/todolist/dao/TodoListDaoImpl.java | e9021aab2dafb8e08ae13f77c3e75c132a2d958e | [] | no_license | mich-s/todolist-app | https://github.com/mich-s/todolist-app | 8dbc8aae8f41447748d75ec0a53566a9ad766b9d | 31b27840505a0ac62532c497258b414240953e56 | refs/heads/master | 2020-03-29T17:48:42.643000 | 2018-09-28T08:18:33 | 2018-09-28T08:18:33 | 150,181,042 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.michal.todolist.dao;
import java.util.List;
//import java.util.logging.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.michal.todolist.entity.Task;
import com.michal.todolist.entity.TodoList;
@Repository
public class TodoListDaoImpl implements TodoListDao {
@Autowired
private SessionFactory sessionFactory;
// private Logger logger = Logger.getLogger(getClass().getName());
//Lists
@Override
public List<TodoList> getTodoLists(String username) {
Session currentSession = sessionFactory.getCurrentSession();
Query<TodoList> query = currentSession.createQuery("from TodoList where todoListUser.username =: username", TodoList.class);
query.setParameter("username", username);
List<TodoList> todoLists2 = query.getResultList();
return todoLists2;
}
@Override
public void addList(TodoList todoList) {
Session currentSession = sessionFactory.getCurrentSession();
currentSession.saveOrUpdate(todoList);
}
@Override
public void deleteList(int listId) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("delete from TodoList where id=:listId");
query.setParameter("listId", listId);
query.executeUpdate();
}
@Override
public TodoList getTodoList(int listId) {
Session currentSession = sessionFactory.getCurrentSession();
TodoList todoList = currentSession.get(TodoList.class, listId);
return todoList;
}
//Tasks
@Override
public void addTask(Task task) {
Session currentSession = sessionFactory.getCurrentSession();
currentSession.save(task);
}
@Override
public void deleteTask(int taskId) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("delete from Task where id=:taskId");
query.setParameter("taskId", taskId);
query.executeUpdate();
}
@Override
public Task getTask(int taskId) {
Session currentSession = sessionFactory.getCurrentSession();
Task task = currentSession.get(Task.class, taskId);
return task;
}
@Override
public void updateTask(Task task) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("update Task set task=:taskName where id=:taskId");
query.setParameter("taskName", task.getTask());
query.setParameter("taskId", task.getId());
query.executeUpdate();
}
@Override
public void toggleDone(Task task, int taskDone) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("update Task set done=:done where id=:taskId");
query.setParameter("done", taskDone);
query.setParameter("taskId", task.getId());
query.executeUpdate();
}
}
| UTF-8 | Java | 2,877 | java | TodoListDaoImpl.java | Java | [] | null | [] | package com.michal.todolist.dao;
import java.util.List;
//import java.util.logging.Logger;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.michal.todolist.entity.Task;
import com.michal.todolist.entity.TodoList;
@Repository
public class TodoListDaoImpl implements TodoListDao {
@Autowired
private SessionFactory sessionFactory;
// private Logger logger = Logger.getLogger(getClass().getName());
//Lists
@Override
public List<TodoList> getTodoLists(String username) {
Session currentSession = sessionFactory.getCurrentSession();
Query<TodoList> query = currentSession.createQuery("from TodoList where todoListUser.username =: username", TodoList.class);
query.setParameter("username", username);
List<TodoList> todoLists2 = query.getResultList();
return todoLists2;
}
@Override
public void addList(TodoList todoList) {
Session currentSession = sessionFactory.getCurrentSession();
currentSession.saveOrUpdate(todoList);
}
@Override
public void deleteList(int listId) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("delete from TodoList where id=:listId");
query.setParameter("listId", listId);
query.executeUpdate();
}
@Override
public TodoList getTodoList(int listId) {
Session currentSession = sessionFactory.getCurrentSession();
TodoList todoList = currentSession.get(TodoList.class, listId);
return todoList;
}
//Tasks
@Override
public void addTask(Task task) {
Session currentSession = sessionFactory.getCurrentSession();
currentSession.save(task);
}
@Override
public void deleteTask(int taskId) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("delete from Task where id=:taskId");
query.setParameter("taskId", taskId);
query.executeUpdate();
}
@Override
public Task getTask(int taskId) {
Session currentSession = sessionFactory.getCurrentSession();
Task task = currentSession.get(Task.class, taskId);
return task;
}
@Override
public void updateTask(Task task) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("update Task set task=:taskName where id=:taskId");
query.setParameter("taskName", task.getTask());
query.setParameter("taskId", task.getId());
query.executeUpdate();
}
@Override
public void toggleDone(Task task, int taskDone) {
Session currentSession = sessionFactory.getCurrentSession();
Query query = currentSession.createQuery("update Task set done=:done where id=:taskId");
query.setParameter("done", taskDone);
query.setParameter("taskId", task.getId());
query.executeUpdate();
}
}
| 2,877 | 0.766076 | 0.765381 | 100 | 27.77 | 26.94656 | 126 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.66 | false | false | 3 |
213e84bc7543a322bda31cff5376ca6363660dcb | 5,059,471,527,330 | 74fe69a445684a35077b177bec0909016ae4845a | /src/main/java/com/yaoa/hibatis/query/Direction.java | 7dffe40ff0da836db8a5b4f90b11bc7ab54e00ad | [
"Apache-2.0"
] | permissive | springer63/hibatis | https://github.com/springer63/hibatis | 84a60659e160bb454cab13598b25f33b33a3a961 | 9fbc9e182e8712140d8f80f40408b5466fc37aa0 | refs/heads/master | 2021-01-11T14:25:36.338000 | 2017-02-10T06:42:12 | 2017-02-10T06:42:12 | 81,409,642 | 0 | 0 | null | true | 2017-02-09T04:38:42 | 2017-02-09T04:38:42 | 2017-01-17T02:10:59 | 2017-02-09T03:24:20 | 111 | 0 | 0 | 0 | null | null | null | /*
* Copyright 2015-2016 Yaoa & Co., Ltd.
*/
package com.yaoa.hibatis.query;
/**
*
* 排序方向
*
* @author kingsy.lin
* @version 1.0 , 2016年7月15日
*/
public enum Direction {
DESC ,
ASC
}
| UTF-8 | Java | 208 | java | Direction.java | Java | [
{
"context": "yaoa.hibatis.query;\n\n/**\n * \n * 排序方向\n *\n * @author kingsy.lin\n * @version 1.0 , 2016年7月15日\n */\npublic enum Dire",
"end": 120,
"score": 0.9985516667366028,
"start": 110,
"tag": "USERNAME",
"value": "kingsy.lin"
}
] | null | [] | /*
* Copyright 2015-2016 Yaoa & Co., Ltd.
*/
package com.yaoa.hibatis.query;
/**
*
* 排序方向
*
* @author kingsy.lin
* @version 1.0 , 2016年7月15日
*/
public enum Direction {
DESC ,
ASC
}
| 208 | 0.597938 | 0.510309 | 17 | 10.411765 | 12.252533 | 39 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.352941 | false | false | 3 |
a43060a9c2a9dff8d3aef3ac5e07ec39054f5a51 | 7,112,465,906,022 | 2af354be1cf4c7395b26627c71403320fd1d88a2 | /Source/14장 중첩클래스_인터페이스/src/ex_anonymous_object_using_localVar/Calculable.java | c6e6485fd56c00e23a13787acfcec746fac54bf6 | [] | no_license | john911120/Java_2nd_project | https://github.com/john911120/Java_2nd_project | 59a5c9da3edc73bb40d3208340753cbd4c759ff0 | 04cab3140578f7418e38cff4d2518e15ac3b189a | refs/heads/master | 2020-12-07T19:13:11.735000 | 2020-01-29T02:40:27 | 2020-01-29T02:40:27 | 232,778,063 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package ex_anonymous_object_using_localVar;
/*
계산가능한 인터페이스 기능을 구현한다.(익명 객체의 로컬 변수를 사용하는 예제)
작성일 : 1226
*/
public interface Calculable {
public int sum();
}
| UHC | Java | 250 | java | Calculable.java | Java | [] | null | [] | package ex_anonymous_object_using_localVar;
/*
계산가능한 인터페이스 기능을 구현한다.(익명 객체의 로컬 변수를 사용하는 예제)
작성일 : 1226
*/
public interface Calculable {
public int sum();
}
| 250 | 0.640449 | 0.617977 | 10 | 15.8 | 17.092688 | 47 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.9 | false | false | 3 |
be1ffe7421c1e94035e2342b07e8f20a2c2e3d6a | 2,911,987,840,224 | ad0ad8397e0c1f6e46f51a4c2fb46513644fdd0d | /app/src/main/java/vn/sunasterisk/english_conversations/screen/sentences/SentencesAdapter.java | f144728ee2b95853463fe1d01830f942f2411f82 | [] | no_license | awesome-academy/English-Conversations | https://github.com/awesome-academy/English-Conversations | 811e0e0f85f253fd43155a5812afc9ad13f32bbd | 5de80921038db32ca04bfc8b844b904a1f32e97b | refs/heads/master | 2020-09-28T21:41:49.381000 | 2020-03-04T09:04:46 | 2020-03-04T09:04:46 | 226,871,486 | 0 | 2 | null | false | 2020-03-04T09:04:48 | 2019-12-09T12:56:41 | 2020-03-04T08:54:07 | 2020-03-04T09:04:47 | 357 | 0 | 2 | 0 | Java | false | false | package vn.sunasterisk.english_conversations.screen.sentences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import java.util.List;
import vn.sunasterisk.english_conversations.R;
import vn.sunasterisk.english_conversations.data.model.Conversation;
import vn.sunasterisk.english_conversations.data.model.Sentence;
import vn.sunasterisk.english_conversations.data.repository.ScoreRepository;
import vn.sunasterisk.english_conversations.utils.SentenceAudioPlayer;
public class SentencesAdapter
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater mLayoutInflater;
private List<Sentence> mSentences;
private Conversation mConversation;
private SentenceClickListener mSentenceClickListener;
private ScoreRepository mScoreRepository;
public SentencesAdapter(Conversation conversation, SentenceClickListener sentenceClickListener) {
mConversation = conversation;
mSentenceClickListener = sentenceClickListener;
mScoreRepository = ScoreRepository.getInstance();
}
public void setSentences(List<Sentence> sentences) {
mSentences = sentences;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (mLayoutInflater == null) {
mLayoutInflater = LayoutInflater.from(parent.getContext());
}
switch (viewType) {
case 0:
View viewLeft = mLayoutInflater.inflate(
R.layout.sentence_item_left,
parent,
false);
return new SentenceLeft(viewLeft);
case 1:
View viewRight = mLayoutInflater.inflate(
R.layout.sentence_item_right,
parent,
false);
return new SentenceRight(viewRight);
}
return null;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
SentenceViewHolder sententceViewHolder = (SentenceViewHolder) holder;
sententceViewHolder.display(mSentences.get(position));
}
@Override
public int getItemViewType(int position) {
return position % 2;
}
@Override
public int getItemCount() {
return mSentences == null ? 0 : mSentences.size();
}
private class SentenceLeft extends SentenceViewHolder {
private SentenceLeft(@NonNull View itemView) {
super(itemView);
}
@Override
protected String getAvatarUrl() {
return mConversation.getUserA().getFullAvatarUrl(mConversation.getId());
}
}
public class SentenceRight extends SentenceViewHolder {
private SentenceRight(@NonNull View itemView) {
super(itemView);
}
@Override
protected String getAvatarUrl() {
return mConversation.getUserB().getFullAvatarUrl(mConversation.getId());
}
}
private abstract class SentenceViewHolder extends RecyclerView.ViewHolder implements SentenceAudioPlayer.SentenceAudioPlayerListener {
private ImageView mImageUserAvatar;
private ImageView mImageStar;
private TextView mTextSentence;
private ImageView mImageSpeaker;
private Sentence mSentence;
private SentenceAudioPlayer mAudioPlayer;
private SentenceViewHolder(@NonNull View itemView) {
super(itemView);
initComponents();
registerListeners();
}
private void registerListeners() {
mImageSpeaker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playAudio();
}
});
mImageUserAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mSentenceClickListener.onAvatarClicked(mSentence);
}
});
}
private void initComponents() {
mImageStar = itemView.findViewById(R.id.image_star);
mImageUserAvatar = itemView.findViewById(R.id.image_user_avatar);
mTextSentence = itemView.findViewById(R.id.text_sentence);
mImageSpeaker = itemView.findViewById(R.id.speaker);
}
void display(Sentence sentence) {
mSentence = sentence;
mTextSentence.setText(sentence.getText());
String url = getAvatarUrl();
Glide.with(itemView.getContext())
.load(url).transform(new CircleCrop())
.into(mImageUserAvatar);
int score = mScoreRepository.getScoresOfSentences(mConversation, getLayoutPosition());
int starResourceId;
if (score == 0) {
starResourceId = R.drawable.star_0;
} else if (score < 30) {
starResourceId = R.drawable.star_1;
} else if (score < 45) {
starResourceId = R.drawable.star_2;
} else if (score < 60) {
starResourceId = R.drawable.star_3;
} else if (score < 80) {
starResourceId = R.drawable.star_4;
} else {
starResourceId = R.drawable.star_5;
}
mImageStar.setImageResource(starResourceId);
}
private void playAudio() {
if (mAudioPlayer == null) {
mAudioPlayer = new SentenceAudioPlayer(mSentence, mConversation, this);
}
mAudioPlayer.play();
}
protected abstract String getAvatarUrl();
@Override
public void onSentencePlayCompleted() {
}
@Override
public void onSentencePlayFailure(String message) {
Toast.makeText(itemView.getContext(), message, Toast.LENGTH_SHORT).show();
}
}
interface SentenceClickListener {
void onAvatarClicked(Sentence sentence);
}
}
| UTF-8 | Java | 6,454 | java | SentencesAdapter.java | Java | [] | null | [] | package vn.sunasterisk.english_conversations.screen.sentences;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import java.util.List;
import vn.sunasterisk.english_conversations.R;
import vn.sunasterisk.english_conversations.data.model.Conversation;
import vn.sunasterisk.english_conversations.data.model.Sentence;
import vn.sunasterisk.english_conversations.data.repository.ScoreRepository;
import vn.sunasterisk.english_conversations.utils.SentenceAudioPlayer;
public class SentencesAdapter
extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private LayoutInflater mLayoutInflater;
private List<Sentence> mSentences;
private Conversation mConversation;
private SentenceClickListener mSentenceClickListener;
private ScoreRepository mScoreRepository;
public SentencesAdapter(Conversation conversation, SentenceClickListener sentenceClickListener) {
mConversation = conversation;
mSentenceClickListener = sentenceClickListener;
mScoreRepository = ScoreRepository.getInstance();
}
public void setSentences(List<Sentence> sentences) {
mSentences = sentences;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
if (mLayoutInflater == null) {
mLayoutInflater = LayoutInflater.from(parent.getContext());
}
switch (viewType) {
case 0:
View viewLeft = mLayoutInflater.inflate(
R.layout.sentence_item_left,
parent,
false);
return new SentenceLeft(viewLeft);
case 1:
View viewRight = mLayoutInflater.inflate(
R.layout.sentence_item_right,
parent,
false);
return new SentenceRight(viewRight);
}
return null;
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
SentenceViewHolder sententceViewHolder = (SentenceViewHolder) holder;
sententceViewHolder.display(mSentences.get(position));
}
@Override
public int getItemViewType(int position) {
return position % 2;
}
@Override
public int getItemCount() {
return mSentences == null ? 0 : mSentences.size();
}
private class SentenceLeft extends SentenceViewHolder {
private SentenceLeft(@NonNull View itemView) {
super(itemView);
}
@Override
protected String getAvatarUrl() {
return mConversation.getUserA().getFullAvatarUrl(mConversation.getId());
}
}
public class SentenceRight extends SentenceViewHolder {
private SentenceRight(@NonNull View itemView) {
super(itemView);
}
@Override
protected String getAvatarUrl() {
return mConversation.getUserB().getFullAvatarUrl(mConversation.getId());
}
}
private abstract class SentenceViewHolder extends RecyclerView.ViewHolder implements SentenceAudioPlayer.SentenceAudioPlayerListener {
private ImageView mImageUserAvatar;
private ImageView mImageStar;
private TextView mTextSentence;
private ImageView mImageSpeaker;
private Sentence mSentence;
private SentenceAudioPlayer mAudioPlayer;
private SentenceViewHolder(@NonNull View itemView) {
super(itemView);
initComponents();
registerListeners();
}
private void registerListeners() {
mImageSpeaker.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
playAudio();
}
});
mImageUserAvatar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mSentenceClickListener.onAvatarClicked(mSentence);
}
});
}
private void initComponents() {
mImageStar = itemView.findViewById(R.id.image_star);
mImageUserAvatar = itemView.findViewById(R.id.image_user_avatar);
mTextSentence = itemView.findViewById(R.id.text_sentence);
mImageSpeaker = itemView.findViewById(R.id.speaker);
}
void display(Sentence sentence) {
mSentence = sentence;
mTextSentence.setText(sentence.getText());
String url = getAvatarUrl();
Glide.with(itemView.getContext())
.load(url).transform(new CircleCrop())
.into(mImageUserAvatar);
int score = mScoreRepository.getScoresOfSentences(mConversation, getLayoutPosition());
int starResourceId;
if (score == 0) {
starResourceId = R.drawable.star_0;
} else if (score < 30) {
starResourceId = R.drawable.star_1;
} else if (score < 45) {
starResourceId = R.drawable.star_2;
} else if (score < 60) {
starResourceId = R.drawable.star_3;
} else if (score < 80) {
starResourceId = R.drawable.star_4;
} else {
starResourceId = R.drawable.star_5;
}
mImageStar.setImageResource(starResourceId);
}
private void playAudio() {
if (mAudioPlayer == null) {
mAudioPlayer = new SentenceAudioPlayer(mSentence, mConversation, this);
}
mAudioPlayer.play();
}
protected abstract String getAvatarUrl();
@Override
public void onSentencePlayCompleted() {
}
@Override
public void onSentencePlayFailure(String message) {
Toast.makeText(itemView.getContext(), message, Toast.LENGTH_SHORT).show();
}
}
interface SentenceClickListener {
void onAvatarClicked(Sentence sentence);
}
}
| 6,454 | 0.627518 | 0.624574 | 192 | 32.614582 | 26.340269 | 138 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.453125 | false | false | 3 |
b76448fe794d7686449fc3a55ee45de1016cd813 | 4,964,982,195,339 | 127a7f0b41aca5809686caa4affd933c6bcc1b6c | /CadastroLivros/CadastroLivro/src/java/br/cefetmg/inf/cadlivros/controller/EditarLivro.java | a2c0478c48d613c9799a8f61dabbb28ecc9677c2 | [] | no_license | vitorricoy/AtividadesLPII | https://github.com/vitorricoy/AtividadesLPII | 98760b3008e0dd9b01d2750ccf7e30f7e6dcdf39 | cea2daf8834ef2ff3e16ce9a1525610632b77f1d | refs/heads/master | 2020-12-03T09:24:31.956000 | 2017-09-03T22:53:29 | 2017-09-03T22:53:29 | 95,619,302 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.cefetmg.inf.cadlivros.controller;
import br.cefetmg.inf.cadlivros.model.domain.Livro;
import br.cefetmg.inf.cadlivros.model.service.ManterLivros;
import br.cefetmg.inf.cadlivros.model.service.impl.ManterLivrosImpl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author umcan
*/
public class EditarLivro {
public static String processar(HttpServletRequest request){
String jsp = "";
try {
Livro l = new Livro();
l.setAutor(request.getParameter("autor"));
String data = request.getParameter("data");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
l.setData(sdf.parse(data));
} catch (ParseException ex) {
throw new ServletException(ex.getMessage());
}
l.setEditora(request.getParameter("editora"));
l.setIsbn(Long.parseLong(request.getParameter("isbn")));
l.setNome(request.getParameter("nome"));
l.setNumPaginas(Integer.parseInt(request.getParameter("numPaginas")));
l.setVolume(Integer.parseInt(request.getParameter("volume")));
ManterLivros manter = new ManterLivrosImpl();
manter.atualizar(l);
jsp="index.html";
} catch (Exception e) {
request.setAttribute("erro", e.getMessage());
jsp = "erro.jsp";
}
return jsp;
}
}
| UTF-8 | Java | 1,738 | java | EditarLivro.java | Java | [
{
"context": "ervlet.http.HttpServletRequest;\n\n/**\n *\n * @author umcan\n */\npublic class EditarLivro {\n public static ",
"end": 589,
"score": 0.9992590546607971,
"start": 584,
"tag": "USERNAME",
"value": "umcan"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package br.cefetmg.inf.cadlivros.controller;
import br.cefetmg.inf.cadlivros.model.domain.Livro;
import br.cefetmg.inf.cadlivros.model.service.ManterLivros;
import br.cefetmg.inf.cadlivros.model.service.impl.ManterLivrosImpl;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
/**
*
* @author umcan
*/
public class EditarLivro {
public static String processar(HttpServletRequest request){
String jsp = "";
try {
Livro l = new Livro();
l.setAutor(request.getParameter("autor"));
String data = request.getParameter("data");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
l.setData(sdf.parse(data));
} catch (ParseException ex) {
throw new ServletException(ex.getMessage());
}
l.setEditora(request.getParameter("editora"));
l.setIsbn(Long.parseLong(request.getParameter("isbn")));
l.setNome(request.getParameter("nome"));
l.setNumPaginas(Integer.parseInt(request.getParameter("numPaginas")));
l.setVolume(Integer.parseInt(request.getParameter("volume")));
ManterLivros manter = new ManterLivrosImpl();
manter.atualizar(l);
jsp="index.html";
} catch (Exception e) {
request.setAttribute("erro", e.getMessage());
jsp = "erro.jsp";
}
return jsp;
}
}
| 1,738 | 0.642117 | 0.642117 | 47 | 35.978722 | 24.080088 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.638298 | false | false | 3 |
d3251acb7027af8e8a4ca711c68b068b64c37ad6 | 8,143,258,041,245 | 34700739897a68b7920e561093462dfcb5fce8e2 | /advertising-admin/src/main/java/com/stylefeng/guns/modular/api/RestUserController.java | 5f21d0173a30f119f153665b754142279a9f3df2 | [] | no_license | 2557606319/advertising | https://github.com/2557606319/advertising | 1f6cd3f5fe96a0eae57e07cabc3e5e54a0c3944b | 9b684aa2206eb40b4a9c7ba4b8fa9a19166c9ce2 | refs/heads/master | 2022-10-25T09:21:21.387000 | 2020-09-24T15:49:59 | 2020-09-24T15:49:59 | 244,639,777 | 0 | 0 | null | false | 2022-10-12T20:40:56 | 2020-03-03T13:13:18 | 2020-09-24T15:50:25 | 2022-10-12T20:40:54 | 3,379 | 0 | 0 | 8 | Java | false | false | package com.stylefeng.guns.modular.api;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.util.JwtTokenUtil;
import com.stylefeng.guns.modular.api.dto.ClientUserDto;
import com.stylefeng.guns.modular.api.vo.*;
import com.stylefeng.guns.modular.system.dao.ClientUserMapper;
import com.stylefeng.guns.modular.system.dao.RebateMapper;
import com.stylefeng.guns.modular.system.dao.SettingMapper;
import com.stylefeng.guns.modular.system.enums.PayAmountType;
import com.stylefeng.guns.modular.system.model.ClientUser;
import com.stylefeng.guns.modular.system.service.IClientUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* user模块controller
*
* @author joey
*/
@Slf4j
@RestController
@RequestMapping("/restApi/auth/user")
public class RestUserController extends BaseController {
@Autowired
IClientUserService clientUserService;
@Autowired
ClientUserMapper clientUserMapper;
@Autowired
RebateMapper rebateMapper;
@Autowired
SettingMapper settingMapper;
@GetMapping("/info")
public ResultBody info() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
ClientUserDto result = new ClientUserDto();
BeanUtils.copyProperties(clientUser, result);
return new ResultBody(result);
}
@PostMapping("/editInfo")
public ResultBody editInfo(ClientUser user) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
user.setId(uid);
boolean flag = clientUserService.updateById(user);
return new ResultBody(flag);
}
@GetMapping("/levelInfo")
public ResultBody levelInfo() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
Map<String, Object> result = new HashMap<>();
result.put("level", clientUser.getAgencyLevel());
result.put("levelInfo", PayAmountType.toJsonObjects());
return new ResultBody(result);
}
@GetMapping("/earnings")
public ResultBody meEarnings() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
MyEarningsVo myEarningsVo = new MyEarningsVo();
myEarningsVo.setNick(clientUser.getNick());
myEarningsVo.setAvatar(clientUser.getAvatar());
myEarningsVo.setLevel(clientUser.getAgencyLevel());
myEarningsVo.setTotalRevenue(clientUser.getSumCommission().add(clientUser.getSumLower()));
myEarningsVo.setUpgrade(PayAmountType.valueOf("AGENT_" + myEarningsVo.getLevel()).getUpgrade());
myEarningsVo.setLower1Ratio(clientUser.getEarnings1());
myEarningsVo.setLower2Ratio(clientUser.getEarnings2());
myEarningsVo.setLower3Ratio(clientUser.getEarnings3());
return new ResultBody(myEarningsVo);
}
@GetMapping("/earnings/count")
public ResultBody earningsCount(String date) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
EarningsCountVo result = new EarningsCountVo();
if (StringUtils.isBlank(date)) {
ClientUser clientUser = clientUserService.selectById(uid);
result.setSumCommission(clientUser.getSumCommission());
result.setSumLower(clientUser.getSumLower());
return new ResultBody(result);
}
//直推用户id列表
List<Long> level1Ids = clientUserMapper.selectIdByPid(uid);
result.setSumCommission(rebateMapper.countCommissionByDate(date, uid,level1Ids));
if (level1Ids.size() > 0)
result.setSumLower(rebateMapper.countLowerCommissionByDate(date, uid, level1Ids));
return new ResultBody(result);
}
@GetMapping("/earnings/details")
public ResultBody earningsDetails(String date) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
List<RebateVo> rebateVos = rebateMapper.rebateListByPid(date, uid);
return new ResultBody(rebateVos);
}
@GetMapping("/invitation/list")
public ResultBody myInvitationList(){
long uid = JwtTokenUtil.getClientUserIdFromToken();
Map<String,Object> where=new HashMap<>();
where.put("pid",uid);
List<ClientUser> clientUsers = clientUserMapper.selectByMap(where);
List<InvitationVo> result=new ArrayList<>();
clientUsers.forEach((v)->{
InvitationVo vo = new InvitationVo();
BeanUtils.copyProperties(v,vo);
result.add(vo);
});
return new ResultBody(result);
}
}
| UTF-8 | Java | 5,119 | java | RestUserController.java | Java | [
{
"context": "a.util.Map;\n\n/**\n * user模块controller\n *\n * @author joey\n */\n@Slf4j\n@RestController\n@RequestMapping(\"/rest",
"end": 1201,
"score": 0.9994159936904907,
"start": 1197,
"tag": "USERNAME",
"value": "joey"
}
] | null | [] | package com.stylefeng.guns.modular.api;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.util.JwtTokenUtil;
import com.stylefeng.guns.modular.api.dto.ClientUserDto;
import com.stylefeng.guns.modular.api.vo.*;
import com.stylefeng.guns.modular.system.dao.ClientUserMapper;
import com.stylefeng.guns.modular.system.dao.RebateMapper;
import com.stylefeng.guns.modular.system.dao.SettingMapper;
import com.stylefeng.guns.modular.system.enums.PayAmountType;
import com.stylefeng.guns.modular.system.model.ClientUser;
import com.stylefeng.guns.modular.system.service.IClientUserService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* user模块controller
*
* @author joey
*/
@Slf4j
@RestController
@RequestMapping("/restApi/auth/user")
public class RestUserController extends BaseController {
@Autowired
IClientUserService clientUserService;
@Autowired
ClientUserMapper clientUserMapper;
@Autowired
RebateMapper rebateMapper;
@Autowired
SettingMapper settingMapper;
@GetMapping("/info")
public ResultBody info() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
ClientUserDto result = new ClientUserDto();
BeanUtils.copyProperties(clientUser, result);
return new ResultBody(result);
}
@PostMapping("/editInfo")
public ResultBody editInfo(ClientUser user) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
user.setId(uid);
boolean flag = clientUserService.updateById(user);
return new ResultBody(flag);
}
@GetMapping("/levelInfo")
public ResultBody levelInfo() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
Map<String, Object> result = new HashMap<>();
result.put("level", clientUser.getAgencyLevel());
result.put("levelInfo", PayAmountType.toJsonObjects());
return new ResultBody(result);
}
@GetMapping("/earnings")
public ResultBody meEarnings() {
long uid = JwtTokenUtil.getClientUserIdFromToken();
ClientUser clientUser = clientUserService.selectById(uid);
MyEarningsVo myEarningsVo = new MyEarningsVo();
myEarningsVo.setNick(clientUser.getNick());
myEarningsVo.setAvatar(clientUser.getAvatar());
myEarningsVo.setLevel(clientUser.getAgencyLevel());
myEarningsVo.setTotalRevenue(clientUser.getSumCommission().add(clientUser.getSumLower()));
myEarningsVo.setUpgrade(PayAmountType.valueOf("AGENT_" + myEarningsVo.getLevel()).getUpgrade());
myEarningsVo.setLower1Ratio(clientUser.getEarnings1());
myEarningsVo.setLower2Ratio(clientUser.getEarnings2());
myEarningsVo.setLower3Ratio(clientUser.getEarnings3());
return new ResultBody(myEarningsVo);
}
@GetMapping("/earnings/count")
public ResultBody earningsCount(String date) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
EarningsCountVo result = new EarningsCountVo();
if (StringUtils.isBlank(date)) {
ClientUser clientUser = clientUserService.selectById(uid);
result.setSumCommission(clientUser.getSumCommission());
result.setSumLower(clientUser.getSumLower());
return new ResultBody(result);
}
//直推用户id列表
List<Long> level1Ids = clientUserMapper.selectIdByPid(uid);
result.setSumCommission(rebateMapper.countCommissionByDate(date, uid,level1Ids));
if (level1Ids.size() > 0)
result.setSumLower(rebateMapper.countLowerCommissionByDate(date, uid, level1Ids));
return new ResultBody(result);
}
@GetMapping("/earnings/details")
public ResultBody earningsDetails(String date) {
long uid = JwtTokenUtil.getClientUserIdFromToken();
List<RebateVo> rebateVos = rebateMapper.rebateListByPid(date, uid);
return new ResultBody(rebateVos);
}
@GetMapping("/invitation/list")
public ResultBody myInvitationList(){
long uid = JwtTokenUtil.getClientUserIdFromToken();
Map<String,Object> where=new HashMap<>();
where.put("pid",uid);
List<ClientUser> clientUsers = clientUserMapper.selectByMap(where);
List<InvitationVo> result=new ArrayList<>();
clientUsers.forEach((v)->{
InvitationVo vo = new InvitationVo();
BeanUtils.copyProperties(v,vo);
result.add(vo);
});
return new ResultBody(result);
}
}
| 5,119 | 0.718205 | 0.715266 | 133 | 37.360901 | 24.984308 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.669173 | false | false | 3 |
e31d33d4c4dfad1baeafdd0b92a44ba27e720969 | 14,001,593,432,695 | a1ed801b72aa774576d8c7e4c116bd631044b9d6 | /Sample7_03.java | d2f73d06181b740a79f342e2d938106675e41f13 | [] | no_license | u0391/practice | https://github.com/u0391/practice | fbb1ea2e910f52bd048894a7cf2e094f3614569b | d58473fc777af67b3441a8c05eb1ccc85489cd5c | refs/heads/master | 2023-07-28T09:23:43.165000 | 2021-09-17T09:22:48 | 2021-09-17T09:22:48 | 397,498,563 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package rensyuuproject;
public class Sample7_03 {
public static void main(String[] args) {
int[] a= {1,2,3,4,5};
int[] b= a;
a[0]=100;
for(int i=0; i<=4; i++) {
System.out.println(a[i]);
}
for(int i=0; i<=4; i++) {
System.out.println(b[i]);
}
}
}
| UTF-8 | Java | 302 | java | Sample7_03.java | Java | [] | null | [] | package rensyuuproject;
public class Sample7_03 {
public static void main(String[] args) {
int[] a= {1,2,3,4,5};
int[] b= a;
a[0]=100;
for(int i=0; i<=4; i++) {
System.out.println(a[i]);
}
for(int i=0; i<=4; i++) {
System.out.println(b[i]);
}
}
}
| 302 | 0.490066 | 0.437086 | 27 | 10.185185 | 12.101537 | 41 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.074074 | false | false | 3 |
b0336a5b4dd66d180dad8241713eb414b6b39798 | 29,652,454,253,771 | cea54ff328cbcddd1a61277fd266d45421c2e990 | /src/main/java/com/hotel/common/dwr3/DWRMsgPushManager.java | 4257aae34f91133a35c5fd04c76dfc82b40eb6df | [] | no_license | TellMeTech/TellMeMgr | https://github.com/TellMeTech/TellMeMgr | 1a6217130e34f042ecb68cd370f1198e1a85525f | fd0e1816a225006933f391e2cb55246a385973c4 | refs/heads/master | 2016-09-15T03:04:04.553000 | 2016-03-29T05:46:53 | 2016-03-29T05:46:53 | 53,632,760 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.hotel.common.dwr3;
public class DWRMsgPushManager
{
} | UTF-8 | Java | 66 | java | DWRMsgPushManager.java | Java | [] | null | [] | package com.hotel.common.dwr3;
public class DWRMsgPushManager
{
} | 66 | 0.80303 | 0.787879 | 5 | 12.4 | 14.374978 | 30 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 3 |
8871f41231ad9fd91c281039116e3cc285449c32 | 10,428,180,619,313 | f2bcc9234c8037e57e7b18e508924dbc12663bc6 | /src/cryptopals/set5/Ch35_ManipulateG.java | 555f9edc40dbd1a1b6370141b94da6383476e605 | [] | no_license | HariAarthi/CryptoPals | https://github.com/HariAarthi/CryptoPals | 01530f875afc0c59faaeb76e6f0ab7c34afe525c | 1e369748f93602a0c22185568b5c081dffa78da5 | refs/heads/master | 2020-04-13T23:33:54.003000 | 2019-01-01T12:00:02 | 2019-01-01T12:00:02 | 163,509,938 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package cryptopals.set5;
//TODO : really don't think what needs to be done here.
/*
* its about manipulation of g.
*
* with g = 1, session key would always be 1
* with g = p, session key would always be 0
* with g = p-1, session key would be 0 if p is a odd number & session key would be 1 if p is even number
*
* need to refer some other implementation to see if I am missing something here. That has to be done later!
*/
public class Ch35_ManipulateG {
public static void main(String args[]) {
}
}
| UTF-8 | Java | 519 | java | Ch35_ManipulateG.java | Java | [] | null | [] | package cryptopals.set5;
//TODO : really don't think what needs to be done here.
/*
* its about manipulation of g.
*
* with g = 1, session key would always be 1
* with g = p, session key would always be 0
* with g = p-1, session key would be 0 if p is a odd number & session key would be 1 if p is even number
*
* need to refer some other implementation to see if I am missing something here. That has to be done later!
*/
public class Ch35_ManipulateG {
public static void main(String args[]) {
}
}
| 519 | 0.687861 | 0.67052 | 19 | 26.31579 | 32.965775 | 108 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.473684 | false | false | 3 |
e319f035537cf3ca445b3b18c7900de04e882683 | 14,697,378,152,069 | 03c6bf7aa970ef896456c40c0ce0d47d909f789c | /core-erp/src/main/java/br/com/control/vendas/cadastro/modelo/ocorrencia/Ocorrencia.java | 28c1851a4af0d1ccacb007399d98eb3511c163d1 | [] | no_license | DiegoDigo/erp-online | https://github.com/DiegoDigo/erp-online | 5322b735f4bfe53323b6749e66daa74cefcaeb4d | 078e367b760d89371e12b32e0cd4403633f0b4fd | refs/heads/master | 2022-10-22T08:07:37.006000 | 2019-04-09T20:35:08 | 2019-04-09T20:35:08 | 210,057,389 | 0 | 0 | null | false | 2022-09-22T18:53:01 | 2019-09-21T21:47:34 | 2019-09-21T21:49:37 | 2022-09-22T18:52:58 | 75,115 | 0 | 0 | 1 | Java | false | false | package br.com.control.vendas.cadastro.modelo.ocorrencia;
import java.io.Serializable;
@SuppressWarnings("serial")
public class Ocorrencia implements Serializable {
private Long recId;
private Boolean ativo;
private String codigoOcorrencia;
private String descricao;
private String descricaoReduzida;
private String desdobro;
private String empresa;
private Boolean geraMotivoFinanc;
private String naturezaOperacao;
// private String naturezaOperacaoM;
// private String naturezaOperacaoO;
private Boolean ocorrDispPortal;
private String sinal;
private String tipo;
private String tipoProduto;
private String codigoTipoOcorrenciaERP;
public String getCodigoTipoOcorrenciaERP() {
return codigoTipoOcorrenciaERP;
}
public void setCodigoTipoOcorrenciaERP(String codigoTipoOcorrenciaERP) {
this.codigoTipoOcorrenciaERP = codigoTipoOcorrenciaERP;
}
public Long getRecId() {
return recId;
}
public void setRecId(Long recId) {
this.recId = recId;
}
public Boolean getAtivo() {
return ativo;
}
public void setAtivo(Boolean ativo) {
this.ativo = ativo;
}
public String getCodigoOcorrencia() {
return codigoOcorrencia;
}
public void setCodigoOcorrencia(String codigoOcorrencia) {
this.codigoOcorrencia = codigoOcorrencia;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public String getDescricaoReduzida() {
return descricaoReduzida;
}
public void setDescricaoReduzida(String descricaoReduzida) {
this.descricaoReduzida = descricaoReduzida;
}
public String getDesdobro() {
return desdobro;
}
public void setDesdobro(String desdobro) {
this.desdobro = desdobro;
}
public String getEmpresa() {
return empresa;
}
public void setEmpresa(String empresa) {
this.empresa = empresa;
}
public Boolean getGeraMotivoFinanc() {
return geraMotivoFinanc;
}
public void setGeraMotivoFinanc(Boolean geraMotivoFinanc) {
this.geraMotivoFinanc = geraMotivoFinanc;
}
public String getNaturezaOperacao() {
return naturezaOperacao;
}
public void setNaturezaOperacao(String naturezaOperacao) {
this.naturezaOperacao = naturezaOperacao;
}
//
// public String getNaturezaOperacaoM() {
// return naturezaOperacaoM;
// }
//
// public void setNaturezaOperacaoM(String naturezaOperacaoM) {
// this.naturezaOperacaoM = naturezaOperacaoM;
// }
//
// public String getNaturezaOperacaoO() {
// return naturezaOperacaoO;
// }
//
// public void setNaturezaOperacaoO(String naturezaOperacaoO) {
// this.naturezaOperacaoO = naturezaOperacaoO;
// }
public Boolean getOcorrDispPortal() {
return ocorrDispPortal;
}
public void setOcorrDispPortal(Boolean ocorrDispPortal) {
this.ocorrDispPortal = ocorrDispPortal;
}
public String getSinal() {
return sinal;
}
public void setSinal(String sinal) {
this.sinal = sinal;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
public String getTipoProduto() {
return tipoProduto;
}
public void setTipoProduto(String tipoProduto) {
this.tipoProduto = tipoProduto;
}
}
| UTF-8 | Java | 3,306 | java | Ocorrencia.java | Java | [] | null | [] | package br.com.control.vendas.cadastro.modelo.ocorrencia;
import java.io.Serializable;
@SuppressWarnings("serial")
public class Ocorrencia implements Serializable {
private Long recId;
private Boolean ativo;
private String codigoOcorrencia;
private String descricao;
private String descricaoReduzida;
private String desdobro;
private String empresa;
private Boolean geraMotivoFinanc;
private String naturezaOperacao;
// private String naturezaOperacaoM;
// private String naturezaOperacaoO;
private Boolean ocorrDispPortal;
private String sinal;
private String tipo;
private String tipoProduto;
private String codigoTipoOcorrenciaERP;
public String getCodigoTipoOcorrenciaERP() {
return codigoTipoOcorrenciaERP;
}
public void setCodigoTipoOcorrenciaERP(String codigoTipoOcorrenciaERP) {
this.codigoTipoOcorrenciaERP = codigoTipoOcorrenciaERP;
}
public Long getRecId() {
return recId;
}
public void setRecId(Long recId) {
this.recId = recId;
}
public Boolean getAtivo() {
return ativo;
}
public void setAtivo(Boolean ativo) {
this.ativo = ativo;
}
public String getCodigoOcorrencia() {
return codigoOcorrencia;
}
public void setCodigoOcorrencia(String codigoOcorrencia) {
this.codigoOcorrencia = codigoOcorrencia;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public String getDescricaoReduzida() {
return descricaoReduzida;
}
public void setDescricaoReduzida(String descricaoReduzida) {
this.descricaoReduzida = descricaoReduzida;
}
public String getDesdobro() {
return desdobro;
}
public void setDesdobro(String desdobro) {
this.desdobro = desdobro;
}
public String getEmpresa() {
return empresa;
}
public void setEmpresa(String empresa) {
this.empresa = empresa;
}
public Boolean getGeraMotivoFinanc() {
return geraMotivoFinanc;
}
public void setGeraMotivoFinanc(Boolean geraMotivoFinanc) {
this.geraMotivoFinanc = geraMotivoFinanc;
}
public String getNaturezaOperacao() {
return naturezaOperacao;
}
public void setNaturezaOperacao(String naturezaOperacao) {
this.naturezaOperacao = naturezaOperacao;
}
//
// public String getNaturezaOperacaoM() {
// return naturezaOperacaoM;
// }
//
// public void setNaturezaOperacaoM(String naturezaOperacaoM) {
// this.naturezaOperacaoM = naturezaOperacaoM;
// }
//
// public String getNaturezaOperacaoO() {
// return naturezaOperacaoO;
// }
//
// public void setNaturezaOperacaoO(String naturezaOperacaoO) {
// this.naturezaOperacaoO = naturezaOperacaoO;
// }
public Boolean getOcorrDispPortal() {
return ocorrDispPortal;
}
public void setOcorrDispPortal(Boolean ocorrDispPortal) {
this.ocorrDispPortal = ocorrDispPortal;
}
public String getSinal() {
return sinal;
}
public void setSinal(String sinal) {
this.sinal = sinal;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
public String getTipoProduto() {
return tipoProduto;
}
public void setTipoProduto(String tipoProduto) {
this.tipoProduto = tipoProduto;
}
}
| 3,306 | 0.722928 | 0.722928 | 155 | 19.329033 | 19.270605 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.264516 | false | false | 3 |
d6c34863bba3659a06b6bdc42c65e9604904a609 | 11,673,721,175,948 | 91533500885a317a18517d43f6c51763eea1a9c6 | /抽象介面/Generator_ITF.java | 6cf764571bee9813f9967d6e9fa6da9be6dac31c | [] | no_license | JamJer/PLC_simulator | https://github.com/JamJer/PLC_simulator | d14f53bbc461956dd893bc980bb10345bf331cfe | 296c2e19f967cabc4e76268d61a45e8b498e1c98 | refs/heads/master | 2021-01-21T14:43:49.943000 | 2016-06-18T13:25:41 | 2016-06-18T13:25:41 | 59,085,888 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null |
public interface Generator_ITF { // Transform code to execute and export result.
}
| UTF-8 | Java | 85 | java | Generator_ITF.java | Java | [] | null | [] |
public interface Generator_ITF { // Transform code to execute and export result.
}
| 85 | 0.752941 | 0.752941 | 2 | 41 | 40 | 81 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0 | false | false | 3 |
963ac15435f7b2d9323d569d2ce0116fc6528359 | 4,217,657,892,481 | 30fac463eef07d3749ea8b5474712456aaa38050 | /code/ingest/src/test/java/org/jesterj/ingest/processors/DocumentFieldMatchCounter.java | a441f38e4d3570709f097eb75cad17d03cf3cd8f | [
"Apache-2.0",
"LicenseRef-scancode-unicode",
"BSD-3-Clause",
"EPL-1.0",
"Classpath-exception-2.0",
"LGPL-2.0-or-later",
"CDDL-1.1",
"ANTLR-PD",
"NAIST-2003",
"CPL-1.0",
"GPL-2.0-only",
"CC-PDDC",
"GCC-exception-3.1",
"CC0-1.0",
"Artistic-2.0",
"LGPL-2.1-or-later",
"APSL-2.0",
"LicenseRef-scancode-public-domain",
"bzip2-1.0.6",
"BSD-2-Clause",
"CC-BY-SA-3.0",
"LicenseRef-scancode-proprietary-license",
"LicenseRef-scancode-other-copyleft",
"OpenSSL",
"LicenseRef-scancode-unknown-license-reference",
"CDDL-1.0",
"MIT",
"LicenseRef-scancode-generic-export-compliance",
"LicenseRef-scancode-other-permissive"
] | permissive | nsoft/jesterj | https://github.com/nsoft/jesterj | 3e9c6e456e44454ac08e7d16ed66cbcf2afca7dc | 4e7161c5988286417565dc00c72390b3e47cdc82 | refs/heads/master | 2023-04-29T19:02:54.128000 | 2023-04-22T21:09:04 | 2023-04-22T21:10:23 | 24,558,581 | 42 | 50 | Apache-2.0 | false | 2023-04-04T03:58:48 | 2014-09-28T12:06:27 | 2023-02-21T18:15:19 | 2023-04-04T03:58:47 | 6,009 | 27 | 32 | 19 | Java | false | false | package org.jesterj.ingest.processors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jesterj.ingest.model.*;
import org.jesterj.ingest.model.impl.NamedBuilder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Processor for tests to use as a output step (destination)
*/
public class DocumentFieldMatchCounter implements DocumentProcessor {
private static final Logger log = LogManager.getLogger();
private final Map<String,Map<String, DocCounted>> scannedDocsByValue = new HashMap<>();
private String name;
private String fieldName;
private boolean block;
public DocumentFieldMatchCounter() {
}
@Override
public String getName() {
return name;
}
@Override
public Document[] processDocument(Document document) {
while(block) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// ignore, would be shutting down.
}
}
String firstValue = document.getFirstValue(fieldName);
Map<String, DocCounted> valueMap = getScannedDocsByValue().computeIfAbsent(firstValue, (fValue) -> new HashMap<>());
valueMap.computeIfAbsent(document.getId(), (id) -> new DocCounted(document)).timesSeen.incrementAndGet();
log.info("Recording {} for value {}", document.getId(), firstValue);
document.setStatus(Status.INDEXED,"Document counted for value of {}", firstValue);
return new Document[]{document};
}
@Override
public boolean isPotent() {
return true;
}
@Override
public boolean isSafe() {
return false;
}
public Map<String, Map<String, DocCounted>> getScannedDocsByValue() {
return scannedDocsByValue;
}
public void setBlock(boolean block) {
this.block = block;
}
public static class Builder extends NamedBuilder<DocumentFieldMatchCounter> {
DocumentFieldMatchCounter obj = new DocumentFieldMatchCounter();
@Override
public Builder named(String name) {
getObj().name = name;
return this;
}
@Override
public DocumentFieldMatchCounter build() {
DocumentFieldMatchCounter result = getObj();
obj = new DocumentFieldMatchCounter();
return result;
}
@Override
protected DocumentFieldMatchCounter getObj() {
return obj;
}
public ConfiguredBuildable<? extends DocumentProcessor> matchesForField(String field) {
getObj().fieldName = field;
return this;
}
}
public static class DocCounted {
public final Document document;
public final AtomicInteger timesSeen = new AtomicInteger(0);
public DocCounted(Document document) {
this.document = document;
}
@Override
public String toString() {
return "DocCounted{" +
"document=" + document +
", timesSeen=" + timesSeen +
'}';
}
}
}
| UTF-8 | Java | 2,894 | java | DocumentFieldMatchCounter.java | Java | [] | null | [] | package org.jesterj.ingest.processors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jesterj.ingest.model.*;
import org.jesterj.ingest.model.impl.NamedBuilder;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
/**
* Processor for tests to use as a output step (destination)
*/
public class DocumentFieldMatchCounter implements DocumentProcessor {
private static final Logger log = LogManager.getLogger();
private final Map<String,Map<String, DocCounted>> scannedDocsByValue = new HashMap<>();
private String name;
private String fieldName;
private boolean block;
public DocumentFieldMatchCounter() {
}
@Override
public String getName() {
return name;
}
@Override
public Document[] processDocument(Document document) {
while(block) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// ignore, would be shutting down.
}
}
String firstValue = document.getFirstValue(fieldName);
Map<String, DocCounted> valueMap = getScannedDocsByValue().computeIfAbsent(firstValue, (fValue) -> new HashMap<>());
valueMap.computeIfAbsent(document.getId(), (id) -> new DocCounted(document)).timesSeen.incrementAndGet();
log.info("Recording {} for value {}", document.getId(), firstValue);
document.setStatus(Status.INDEXED,"Document counted for value of {}", firstValue);
return new Document[]{document};
}
@Override
public boolean isPotent() {
return true;
}
@Override
public boolean isSafe() {
return false;
}
public Map<String, Map<String, DocCounted>> getScannedDocsByValue() {
return scannedDocsByValue;
}
public void setBlock(boolean block) {
this.block = block;
}
public static class Builder extends NamedBuilder<DocumentFieldMatchCounter> {
DocumentFieldMatchCounter obj = new DocumentFieldMatchCounter();
@Override
public Builder named(String name) {
getObj().name = name;
return this;
}
@Override
public DocumentFieldMatchCounter build() {
DocumentFieldMatchCounter result = getObj();
obj = new DocumentFieldMatchCounter();
return result;
}
@Override
protected DocumentFieldMatchCounter getObj() {
return obj;
}
public ConfiguredBuildable<? extends DocumentProcessor> matchesForField(String field) {
getObj().fieldName = field;
return this;
}
}
public static class DocCounted {
public final Document document;
public final AtomicInteger timesSeen = new AtomicInteger(0);
public DocCounted(Document document) {
this.document = document;
}
@Override
public String toString() {
return "DocCounted{" +
"document=" + document +
", timesSeen=" + timesSeen +
'}';
}
}
}
| 2,894 | 0.688321 | 0.686593 | 115 | 24.165216 | 26.060776 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.443478 | false | false | 3 |
28e4d55e2461502a0dc03c1701f03b80cdb4a3b1 | 3,272,765,148,166 | 67872a381f102dfe4e16eb6626cf5f2275195ad3 | /modules/messaging/src/main/java/org/torquebox/messaging/destinations/processors/TopicsYamlParsingProcessor.java | 28a1d9e9e3e583e4db2dfb70889ce91fcdf55e14 | [] | no_license | zaccari/torquebox | https://github.com/zaccari/torquebox | e2f338d000d486f2bd047893bc17757ad646839b | 8e1ec1c9457471fe9864421279f4c8761695457c | refs/heads/3x-maint | 2021-09-14T19:23:43.651000 | 2016-09-16T14:15:23 | 2016-09-16T14:15:23 | 45,135,482 | 1 | 0 | null | true | 2019-11-13T20:45:43 | 2015-10-28T19:03:15 | 2018-05-17T18:53:18 | 2018-05-17T20:31:37 | 76,833 | 0 | 0 | 0 | Java | false | false | /*
* Copyright 2008-2013 Red Hat, Inc, and individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.torquebox.messaging.destinations.processors;
import java.util.Map;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.projectodd.polyglot.messaging.destinations.TopicMetaData;
/**
* <pre>
* Stage: PARSE
* In: topics.yml
* Out: TopicMetaData
* </pre>
*
* Creates TopicMetaData instances from topics.yml
*/
public class TopicsYamlParsingProcessor extends AbstractDestinationYamlParsingProcessor {
public TopicsYamlParsingProcessor() {
super();
setSectionName( "topics" );
}
@SuppressWarnings("unchecked")
public void parse(DeploymentUnit unit, Object dataObject) throws DeploymentUnitProcessingException {
Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) dataObject;
for (String topicName : data.keySet()) {
TopicMetaData topicMetaData = new TopicMetaData( topicName );
Map<String, Object> topicOptions = data.get(topicName);
if (topicOptions != null) {
if (topicOptions.containsKey("exported")) {
topicMetaData.setExported((Boolean) topicOptions.get("exported"));
}
parseRemote(topicMetaData, topicOptions.get("remote"));
}
unit.addToAttachmentList( TopicMetaData.ATTACHMENTS_KEY, topicMetaData );
}
}
}
| UTF-8 | Java | 2,294 | java | TopicsYamlParsingProcessor.java | Java | [] | null | [] | /*
* Copyright 2008-2013 Red Hat, Inc, and individual contributors.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.torquebox.messaging.destinations.processors;
import java.util.Map;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.projectodd.polyglot.messaging.destinations.TopicMetaData;
/**
* <pre>
* Stage: PARSE
* In: topics.yml
* Out: TopicMetaData
* </pre>
*
* Creates TopicMetaData instances from topics.yml
*/
public class TopicsYamlParsingProcessor extends AbstractDestinationYamlParsingProcessor {
public TopicsYamlParsingProcessor() {
super();
setSectionName( "topics" );
}
@SuppressWarnings("unchecked")
public void parse(DeploymentUnit unit, Object dataObject) throws DeploymentUnitProcessingException {
Map<String, Map<String, Object>> data = (Map<String, Map<String, Object>>) dataObject;
for (String topicName : data.keySet()) {
TopicMetaData topicMetaData = new TopicMetaData( topicName );
Map<String, Object> topicOptions = data.get(topicName);
if (topicOptions != null) {
if (topicOptions.containsKey("exported")) {
topicMetaData.setExported((Boolean) topicOptions.get("exported"));
}
parseRemote(topicMetaData, topicOptions.get("remote"));
}
unit.addToAttachmentList( TopicMetaData.ATTACHMENTS_KEY, topicMetaData );
}
}
}
| 2,294 | 0.700087 | 0.690933 | 65 | 34.292309 | 31.622156 | 104 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.553846 | false | false | 3 |
aa71e4a2cd5fc9b119b86c570abc37ecddeccdfe | 10,703,058,517,152 | 4d45e004ffa8b1a923442dc640731d5f68173f00 | /算法第四版答案/Algorithms/src/ThrowEggs_1_4_25_b.java | 6ad7bfa5474d0cc8779f17512c9817738568fa40 | [] | no_license | LlorandoLau/Algorithms | https://github.com/LlorandoLau/Algorithms | 56757bb98a51abe82075b898e7a5c547513272c1 | ac406de76180bf02997d346dc84a3a312ecdf760 | refs/heads/master | 2021-07-04T10:56:47.786000 | 2017-09-27T01:17:44 | 2017-09-27T01:17:44 | 104,900,231 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | public class ThrowEggs_1_4_25_b {
public static int rank(int[] a, int key) {
int N = a.length - 1;
int j = -1;
if (a[0] == key)
return 0;
else {
for (int i = 1; i < N; i *= 2) {
if (a[i] > key) {
j = i;
break;
}
}
StdOut.println("F: " + j / 2 + " F_higer:" + j);
return BinarySearch(a, key, j / 2, j);
}
}
public static int BinarySearch(int[] a, int key, int lo, int hi) {
if (lo > hi)
return -1;
int mid = (int) (lo + (hi - lo) / 2);
int index = -1;
if (key > a[mid])
index = BinarySearch(a, key, mid + 1, hi);
else if (key < a[mid])
index = BinarySearch(a, key, lo, mid - 1);
else
return mid;
return index;
}
public static void main(String[] args) {
int[] a=new int[10000];
for(int i=0;i<10000;i++){
a[i]=i;
}
StdOut.print(rank(a, 500));
}
}
| UTF-8 | Java | 843 | java | ThrowEggs_1_4_25_b.java | Java | [] | null | [] | public class ThrowEggs_1_4_25_b {
public static int rank(int[] a, int key) {
int N = a.length - 1;
int j = -1;
if (a[0] == key)
return 0;
else {
for (int i = 1; i < N; i *= 2) {
if (a[i] > key) {
j = i;
break;
}
}
StdOut.println("F: " + j / 2 + " F_higer:" + j);
return BinarySearch(a, key, j / 2, j);
}
}
public static int BinarySearch(int[] a, int key, int lo, int hi) {
if (lo > hi)
return -1;
int mid = (int) (lo + (hi - lo) / 2);
int index = -1;
if (key > a[mid])
index = BinarySearch(a, key, mid + 1, hi);
else if (key < a[mid])
index = BinarySearch(a, key, lo, mid - 1);
else
return mid;
return index;
}
public static void main(String[] args) {
int[] a=new int[10000];
for(int i=0;i<10000;i++){
a[i]=i;
}
StdOut.print(rank(a, 500));
}
}
| 843 | 0.510083 | 0.47331 | 45 | 17.688889 | 16.627718 | 67 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.777778 | false | false | 3 |
a93af4accbe072a317869d0b41780a10d2c8268c | 2,147,483,694,548 | af1f59152e08d4834b852df97e24ddade27a2b63 | /Jave_Operator/src/com/biz/op/DateInput01.java | 8e5dab5a5fdb4bcc072ed2050c7d6ecb2cda733e | [] | no_license | whdghks8021/Java | https://github.com/whdghks8021/Java | 2e86cfaf8cd53ba0cfc31417857530cf115dcd64 | 53edab878a90632468307d0df574f9a2a8f3748e | refs/heads/master | 2020-04-05T20:19:01.535000 | 2019-01-18T06:31:51 | 2019-01-18T06:31:51 | 157,174,621 | 0 | 1 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.biz.op;
import java.text.SimpleDateFormat;
import java.util.Scanner;
public class DateInput01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* 키보드에서 날짜값을 입력받고 유효한 날짜인지 체크
*/
Scanner scanner = new Scanner(System.in);
String[] dateForm = {
"yyyyMMdd",
"yyyy/MM/dd",
"yyyyMM",
"yyyy-MM-dd",
"yyyy.MM.dd"
};
int index = 0;
while(true) {
System.out.println("다음 형식에 맞도록 날짜 입력");
System.out.print(dateForm[index % 5] + ">> ");
String strDate = scanner.nextLine();
SimpleDateFormat dcheck = new SimpleDateFormat(dateForm[index++ % 5]);
dcheck.setLenient(false);
try {
dcheck.parse(strDate);
} catch (Exception e) {
// TODO: handle exception
System.out.println("날짜가 유효하지 않습니다.");
index--;
continue;
}
System.out.println("입력한 날짜는 유효합니다.");
}
}
}
| UTF-8 | Java | 1,000 | java | DateInput01.java | Java | [] | null | [] | package com.biz.op;
import java.text.SimpleDateFormat;
import java.util.Scanner;
public class DateInput01 {
public static void main(String[] args) {
// TODO Auto-generated method stub
/*
* 키보드에서 날짜값을 입력받고 유효한 날짜인지 체크
*/
Scanner scanner = new Scanner(System.in);
String[] dateForm = {
"yyyyMMdd",
"yyyy/MM/dd",
"yyyyMM",
"yyyy-MM-dd",
"yyyy.MM.dd"
};
int index = 0;
while(true) {
System.out.println("다음 형식에 맞도록 날짜 입력");
System.out.print(dateForm[index % 5] + ">> ");
String strDate = scanner.nextLine();
SimpleDateFormat dcheck = new SimpleDateFormat(dateForm[index++ % 5]);
dcheck.setLenient(false);
try {
dcheck.parse(strDate);
} catch (Exception e) {
// TODO: handle exception
System.out.println("날짜가 유효하지 않습니다.");
index--;
continue;
}
System.out.println("입력한 날짜는 유효합니다.");
}
}
}
| 1,000 | 0.620495 | 0.614865 | 43 | 19.651163 | 16.746931 | 73 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.72093 | false | false | 3 |
0446a81a916baec5b767eabcb9df52e462f01684 | 12,618,613,967,547 | 7bac6ceb38b002a35581304cc88b68b1e78d1817 | /src/test/java/com/siletti/iscs/MyFixedWidthParserFootballTest.java | 32223559f26c6fee07b287d3266ace7d814bd76d | [] | no_license | siletti/iscs01 | https://github.com/siletti/iscs01 | 6536225c3c4301b485109a5ece20d15ac0a93f59 | d27f7a05c3319463ebe3ddaf2ed6dffb39a7a748 | refs/heads/master | 2021-07-11T21:22:32.819000 | 2019-09-18T17:45:37 | 2019-09-18T17:45:37 | 209,281,750 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.siletti.iscs;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertTrue;
public class MyFixedWidthParserFootballTest {
MyFixedWidthParser myFixedWidthParser;
File footballFile;
@Before
public void setUp() throws Exception {
URL url = this.getClass().getResource("/football.dat");
footballFile = new File(url.getFile());
myFixedWidthParser = new MyFixedWidthParserFootball(footballFile);
}
@Test
public void getKeyWithMinIntVal() {
String result = myFixedWidthParser.getKeyWithMinIntVal();
assertTrue(result.equals("Aston_Villa"));
}
@Test
public void getTheList() throws IOException {
List<String[]> result = myFixedWidthParser.getTheList(footballFile);
assertTrue(result.size() == 21);
}
@Test
public void stringIntegerMap() {
Map<String, Integer> result = myFixedWidthParser.stringIntegerMap();
assertTrue(result.size() == 20);
}
} | UTF-8 | Java | 1,130 | java | MyFixedWidthParserFootballTest.java | Java | [
{
"context": "MinIntVal();\n assertTrue(result.equals(\"Aston_Villa\"));\n }\n\n @Test\n public void getThe",
"end": 755,
"score": 0.5044211745262146,
"start": 753,
"tag": "NAME",
"value": "on"
}
] | null | [] | package com.siletti.iscs;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.List;
import java.util.Map;
import static org.junit.Assert.assertTrue;
public class MyFixedWidthParserFootballTest {
MyFixedWidthParser myFixedWidthParser;
File footballFile;
@Before
public void setUp() throws Exception {
URL url = this.getClass().getResource("/football.dat");
footballFile = new File(url.getFile());
myFixedWidthParser = new MyFixedWidthParserFootball(footballFile);
}
@Test
public void getKeyWithMinIntVal() {
String result = myFixedWidthParser.getKeyWithMinIntVal();
assertTrue(result.equals("Aston_Villa"));
}
@Test
public void getTheList() throws IOException {
List<String[]> result = myFixedWidthParser.getTheList(footballFile);
assertTrue(result.size() == 21);
}
@Test
public void stringIntegerMap() {
Map<String, Integer> result = myFixedWidthParser.stringIntegerMap();
assertTrue(result.size() == 20);
}
} | 1,130 | 0.69292 | 0.689381 | 44 | 24.704546 | 23.258018 | 76 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.477273 | false | false | 3 |
0c900e5bf8c58eb97e1bb8caf8eb395856f5a08b | 30,142,080,500,357 | 7dc67336c59568b659d3485a68fc5e210271e3ef | /miner-topo/src/test/java/miner/loop/DistributeWordByTypeBolt.java | 90752f2cc4aed25d412ea34534ff338aabfaf24c | [
"MIT"
] | permissive | cryptobuks/miner-1 | https://github.com/cryptobuks/miner-1 | 8ec9490d7790b36bde0518fbd65c0be7e2afaac5 | 72252b61c0b45737e1e00459b3d272bf9ebb63d3 | refs/heads/master | 2021-01-24T06:19:11.217000 | 2016-07-14T03:20:53 | 2016-07-14T03:20:53 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package miner.loop;
import backtype.storm.generated.GlobalStreamId;
import backtype.storm.generated.Grouping;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.tuple.Values;
import java.util.Map;
/**
* Created by cutoutsy on 8/21/15.
*/
public class DistributeWordByTypeBolt extends BaseRichBolt{
private static final long serivalVersionUID = 1L;
private OutputCollector collector;
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector){
this.collector = collector;
Map<GlobalStreamId, Grouping> sources = context.getThisSources();
System.out.println("sources====>"+sources);
}
public void execute(Tuple input){
String type = input.getString(0);
String word = input.getString(1);
// switch(type) {
// case Type.NUMBER:
// emit("stream-number-saver", type, input, word);
// break;
// case Type.STRING:
// emit("stream-string-saver", type, input, word);
// break;
// case Type.SIGN:
// emit("stream-sign-saver", type, input, word);
// break;
// default:
// emit("stream-discarder", type, input, word);
// }
if(type.equals(Type.NUMBER)){
emit("stream-number-saver", type, input, word);
}else if(type.equals(Type.STRING)){
emit("stream-string-saver", type, input, word);
}else if(type.equals(Type.SIGN)){
emit("stream-sign-saver", type, input, word);
}else{
emit("stream-discarder", type, input, word);
}
collector.ack(input);
}
private void emit(String streamId, String type, Tuple input, String word){
collector.emit(streamId, input, new Values(type, word));
System.out.println("Distribution, typed word emitted: type="+type+", word="+word);
}
public void declareOutputFields(OutputFieldsDeclarer declarer){
// declarer.declare(new Fields("type", "word"));
declarer.declareStream("stream-number-saver", new Fields("type", "word"));
declarer.declareStream("stream-string-saver", new Fields("type", "word"));
declarer.declareStream("stream-sign-saver", new Fields("type", "word"));
}
}
| UTF-8 | Java | 2,546 | java | DistributeWordByTypeBolt.java | Java | [
{
"context": ".Values;\n\nimport java.util.Map;\n\n/**\n * Created by cutoutsy on 8/21/15.\n */\npublic class DistributeWordByType",
"end": 459,
"score": 0.9995891451835632,
"start": 451,
"tag": "USERNAME",
"value": "cutoutsy"
}
] | null | [] | package miner.loop;
import backtype.storm.generated.GlobalStreamId;
import backtype.storm.generated.Grouping;
import backtype.storm.task.OutputCollector;
import backtype.storm.task.TopologyContext;
import backtype.storm.topology.OutputFieldsDeclarer;
import backtype.storm.topology.base.BaseRichBolt;
import backtype.storm.tuple.Fields;
import backtype.storm.tuple.Tuple;
import backtype.storm.tuple.Values;
import java.util.Map;
/**
* Created by cutoutsy on 8/21/15.
*/
public class DistributeWordByTypeBolt extends BaseRichBolt{
private static final long serivalVersionUID = 1L;
private OutputCollector collector;
public void prepare(Map stormConf, TopologyContext context, OutputCollector collector){
this.collector = collector;
Map<GlobalStreamId, Grouping> sources = context.getThisSources();
System.out.println("sources====>"+sources);
}
public void execute(Tuple input){
String type = input.getString(0);
String word = input.getString(1);
// switch(type) {
// case Type.NUMBER:
// emit("stream-number-saver", type, input, word);
// break;
// case Type.STRING:
// emit("stream-string-saver", type, input, word);
// break;
// case Type.SIGN:
// emit("stream-sign-saver", type, input, word);
// break;
// default:
// emit("stream-discarder", type, input, word);
// }
if(type.equals(Type.NUMBER)){
emit("stream-number-saver", type, input, word);
}else if(type.equals(Type.STRING)){
emit("stream-string-saver", type, input, word);
}else if(type.equals(Type.SIGN)){
emit("stream-sign-saver", type, input, word);
}else{
emit("stream-discarder", type, input, word);
}
collector.ack(input);
}
private void emit(String streamId, String type, Tuple input, String word){
collector.emit(streamId, input, new Values(type, word));
System.out.println("Distribution, typed word emitted: type="+type+", word="+word);
}
public void declareOutputFields(OutputFieldsDeclarer declarer){
// declarer.declare(new Fields("type", "word"));
declarer.declareStream("stream-number-saver", new Fields("type", "word"));
declarer.declareStream("stream-string-saver", new Fields("type", "word"));
declarer.declareStream("stream-sign-saver", new Fields("type", "word"));
}
}
| 2,546 | 0.634721 | 0.631579 | 70 | 35.371429 | 26.087311 | 91 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.114286 | false | false | 3 |
308d73b4788e02c0b5e997ac7301f27f0aff1b1b | 23,313,082,548,968 | 34a4054cce0fa78fd5de9aea4a775fcda85654d5 | /ElasticSearch/ElasticSearch_CRUD/src/main/java/com/bigdata/es/base/TestConnectionApi.java | 857c3c34fe0a1413ac32ed67f2587755a217af25 | [] | no_license | tulaycaglayan/Big-Data | https://github.com/tulaycaglayan/Big-Data | 5ce618d989db01b2ef2b4c5b69fbddc264cb5c02 | 64022331e6a4c161e6c8df28b1d40e3b5d9cb154 | refs/heads/master | 2022-12-20T08:55:06.686000 | 2020-10-07T08:21:42 | 2020-10-07T08:21:42 | 298,812,012 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.bigdata.es.base;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
public class TestConnectionApi {
public static void main(String[] args) throws UnknownHostException {
Settings settings= Settings.builder()
.put("cluster.name","elasticsearch").build();
TransportClient client= null;
try {
client = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));//9300 port is for REST Api
} catch (UnknownHostException e) {
e.printStackTrace();
}
List<DiscoveryNode> discoveryNodes = client.listedNodes();
for ( int i =0; i<discoveryNodes.size(); i++){
System.out.println(" Connection successful. Node : " + discoveryNodes.get(i) );
}
client.close();
}
}
| UTF-8 | Java | 1,281 | java | TestConnectionApi.java | Java | [] | null | [] | package com.bigdata.es.base;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.List;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.cluster.node.DiscoveryNode;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.TransportAddress;
import org.elasticsearch.transport.client.PreBuiltTransportClient;
public class TestConnectionApi {
public static void main(String[] args) throws UnknownHostException {
Settings settings= Settings.builder()
.put("cluster.name","elasticsearch").build();
TransportClient client= null;
try {
client = new PreBuiltTransportClient(settings)
.addTransportAddress(new TransportAddress(InetAddress.getByName("localhost"), 9300));//9300 port is for REST Api
} catch (UnknownHostException e) {
e.printStackTrace();
}
List<DiscoveryNode> discoveryNodes = client.listedNodes();
for ( int i =0; i<discoveryNodes.size(); i++){
System.out.println(" Connection successful. Node : " + discoveryNodes.get(i) );
}
client.close();
}
}
| 1,281 | 0.660422 | 0.653396 | 34 | 35.676472 | 29.915293 | 133 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.205882 | false | false | 3 |
15471aabd4cf46fed9c5143161f272fda8203495 | 28,956,669,560,927 | ffb268efe06a8899c841947860143572f8f5f3d9 | /Block.java | 8d0fe83b2704c80ea7c056a02031d7331b25162f | [] | no_license | AlexWizz11/TasksJava | https://github.com/AlexWizz11/TasksJava | 82c823e0383ed424d5fac8f1cc63f2e54460f2c6 | a79fd23049d939464722641e7aef804c7ebefbd7 | refs/heads/master | 2021-01-09T05:56:15.903000 | 2017-02-15T11:42:54 | 2017-02-15T11:42:54 | 80,841,902 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.io.*;
/**
* Created by User on 2/3/2017.
*/
public class Fibonacci {
public static void main(String[] args) throws Exception {
while (true) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); //ввод числа
int in = Integer.parseInt(reader.readLine());
int pr = 0;
int this1 = 0;
int next = 1;
while (this1 != in) { //первый цикл с переопределением переменных
pr = this1;
this1 = next;
next = this1 + pr;
if (this1 == in)
System.out.println("yes"); //исходное условие для проверки соответсвия числа ряду
if (this1 > in) {
System.out.println("No"); //дополнительное условие для исключения некорректной работы
break;
}
}
}
}
}
| UTF-8 | Java | 1,109 | java | Block.java | Java | [] | null | [] | import java.io.*;
/**
* Created by User on 2/3/2017.
*/
public class Fibonacci {
public static void main(String[] args) throws Exception {
while (true) {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); //ввод числа
int in = Integer.parseInt(reader.readLine());
int pr = 0;
int this1 = 0;
int next = 1;
while (this1 != in) { //первый цикл с переопределением переменных
pr = this1;
this1 = next;
next = this1 + pr;
if (this1 == in)
System.out.println("yes"); //исходное условие для проверки соответсвия числа ряду
if (this1 > in) {
System.out.println("No"); //дополнительное условие для исключения некорректной работы
break;
}
}
}
}
}
| 1,109 | 0.489119 | 0.472539 | 29 | 31.137932 | 30.314131 | 105 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.413793 | false | false | 3 |
10db77b60f71c633dad9dc443abb98cdc797591e | 11,476,152,657,945 | 1064d54b0c6553629c1a98c7f2de325108e7b677 | /powergrab/src/main/java/uk/ac/ed/inf/powergrab/Charger.java | 705b13b5fc6d8d108892b1be19bffe1cc0f6bd8d | [] | no_license | TYTTYTTYT/ILP-coursework | https://github.com/TYTTYTTYT/ILP-coursework | f5765e1cb444d5656931a390ddf38164a6503430 | 5eefece6b2bbb03f0f7683c8d5242abae124d6a9 | refs/heads/master | 2023-08-04T18:11:15.867000 | 2021-09-18T13:47:16 | 2021-09-18T13:47:16 | 210,612,703 | 0 | 0 | null | false | 2020-10-14T00:33:03 | 2019-09-24T13:41:11 | 2020-09-25T10:10:30 | 2020-10-14T00:33:01 | 32,580 | 0 | 0 | 1 | HTML | false | false | package uk.ac.ed.inf.powergrab;
/**
* The charger class, an implementation of Geography interface with coins and power attributes.
* <p>
* A charger object is a geographic object with coins and power attributes.
* It represents a charger on the map. Once it initialized,
* the location of it will not change.
*
* @author Tai Yintao s1891075@ed.ac.uk
* @version 1.1
* @since 0.3
*/
public class Charger implements Geography {
/**
* Coins of this charger.
*/
float coins;
/**
* Power of this charger.
*/
float power;
/**
* the position of this charger.
*/
private Position myPosition;
/**
* Constructs a charger with given latitude, longitude, coins and power.
* <p>
* This is the only constructor of a charger, the latitude and longitude are given
* by parameters and stored in a Position object. The charger also have coins and
* power attributes.
*
* @param latitude the latitude of the new charger
* @param longitude the longitude of the new charger
* @param coins the initial coins of the new charger
* @param power the initial power of the new charger
*/
public Charger(double latitude, double longitude, float coins, float power) {
this.coins = coins;
this.power = power;
this.myPosition = new Position(latitude, longitude);
}
/**
* Return the latitude of this charger.
*
* @return the latitude.
*/
@Override
public double latitude() {
return myPosition.latitude();
}
/**
* Return the longitude of this charger.
*
* @return the longitude.
*/
@Override
public double longitude() {
return myPosition.longitude();
}
}
| UTF-8 | Java | 1,635 | java | Charger.java | Java | [
{
"context": "cation of it will not change.\n * \n * @author Tai Yintao s1891075@ed.ac.uk\n * @version 1.1\n * @since ",
"end": 346,
"score": 0.9998347163200378,
"start": 336,
"tag": "NAME",
"value": "Tai Yintao"
},
{
"context": "t will not change.\n * \n * @author Tai Yintao s1891075@ed.ac.uk\n * @version 1.1\n * @since 0.3\n */\npubli",
"end": 364,
"score": 0.9999247193336487,
"start": 347,
"tag": "EMAIL",
"value": "s1891075@ed.ac.uk"
}
] | null | [] | package uk.ac.ed.inf.powergrab;
/**
* The charger class, an implementation of Geography interface with coins and power attributes.
* <p>
* A charger object is a geographic object with coins and power attributes.
* It represents a charger on the map. Once it initialized,
* the location of it will not change.
*
* @author <NAME> <EMAIL>
* @version 1.1
* @since 0.3
*/
public class Charger implements Geography {
/**
* Coins of this charger.
*/
float coins;
/**
* Power of this charger.
*/
float power;
/**
* the position of this charger.
*/
private Position myPosition;
/**
* Constructs a charger with given latitude, longitude, coins and power.
* <p>
* This is the only constructor of a charger, the latitude and longitude are given
* by parameters and stored in a Position object. The charger also have coins and
* power attributes.
*
* @param latitude the latitude of the new charger
* @param longitude the longitude of the new charger
* @param coins the initial coins of the new charger
* @param power the initial power of the new charger
*/
public Charger(double latitude, double longitude, float coins, float power) {
this.coins = coins;
this.power = power;
this.myPosition = new Position(latitude, longitude);
}
/**
* Return the latitude of this charger.
*
* @return the latitude.
*/
@Override
public double latitude() {
return myPosition.latitude();
}
/**
* Return the longitude of this charger.
*
* @return the longitude.
*/
@Override
public double longitude() {
return myPosition.longitude();
}
}
| 1,621 | 0.685015 | 0.678287 | 67 | 23.402985 | 24.768215 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.089552 | false | false | 3 |
11c2fd039fa8d6ed04e6f8a62d5b633f74310201 | 21,234,318,315,907 | 2017592cdb9185164aa58e1ec5a0143aa05198f4 | /sem2TestyNaCesty_jacmac/src/ui/Main.java | 01435ce2f307943529202a65a9f9177054597a94 | [] | no_license | Pazitkovnik/semestralniPrace_testyNaCesty | https://github.com/Pazitkovnik/semestralniPrace_testyNaCesty | d55d03e617913c3abb6b418ee50dd342e7e6c334 | 2151b1e63e6fb887ad6ef525e5c7206f275d62eb | refs/heads/master | 2020-03-18T17:32:05.750000 | 2018-05-27T10:33:51 | 2018-05-27T10:33:51 | 135,034,070 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ui;
import app.Test;
import app.Question;
import app.TestList;
import com.itextpdf.text.DocumentException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
import utils.FileHandler;
import utils.TextToSpeech;
/**
* Class Main implements basic UI for the TEST app
* @author Jachym
*/
public class Main
{
public static Scanner sc = new Scanner(System.in, "Cp1250");
public static TestList testList = new TestList();
//public static TextToSpeech tts = new TextToSpeech();
public static void main(String[] args) throws IOException, FileNotFoundException, DocumentException
{
TextToSpeech.speak("TESTY NA CESTY, nejlepsi testovac na svete celem");
testList.loadTests();
System.out.print("Zadejte své jméno: ");
boolean exit = false;
String name = "";
while(!exit)
{
try
{
name = sc.nextLine();
testList.setUserName(name);
exit = true;
}
catch(IllegalArgumentException e)
{
System.out.println(e.getMessage());
}
}
TextToSpeech.speak("Welcome " + name);
menu();
}
/**
* provides basic UI menu with all the needed functions
*/
public static void menu()
{
System.out.println("\nTESTY NA CESTY");
System.out.println("=================");
System.out.println("vybrat test 1");
System.out.println("vytvořit test 2");
System.out.println("nastavení 3");
System.out.println("využít tts 4");
System.out.println("o programu 5");
System.out.println("konec programu 0");
System.out.println("---------------------------");
System.out.print ("vaše volba: ");
char charChoice = sc.next().charAt(0);
//check if user typed number and parse it
int choice = Character.isDigit(charChoice)
?Integer.parseInt(String.valueOf(charChoice)):-1;
//clear the buffer
sc.nextLine();
try
{
switch(choice)
{
case 1:
chooseTest();
break;
case 2:
makeTest();
break;
case 3:
settings();
break;
case 4:
tts();
break;
case 5:
about();
break;
case 0:
return;
default:
System.out.println("Neplatny vstup!");
break;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
menu();
}
/**
* prints basic info about this program
*/
public static void about()
{
System.out.println("");
System.out.println("Testy na Cesty je testovací program, díky kterému si "
+ "procvičíte svoje mozečkové buňky jako nikdy předtím.");
System.out.println("Jeho úžasné uživatelsky přívětivé prostředí Vás vtrhne "
+ "do světa hlavolamů a hádanek tak silně, že bude velice těžké "
+ "se od něho odtrhnout!");
System.out.println("Návod:");
System.out.println(" - pomocí funkce \"vybrat test\" si vyberete test, ktery budete chtit zpracovat.");
System.out.println(" po jeho napsani se do slozky results vypise formatovany vystup vysledku ve forme pdf");
System.out.println(" pro znovu napsani testu vypnete a zapnete tento program");
System.out.println(" - pomocí funkce \"vytvori test\" vytvorite test,"
+ " ktery se na konci zapise do souboru tests a zaroven pripise do souboru tests/index.txt");
System.out.println(" - pomocí funkce \"nastaveni\" nastavite ruzne parametry programu");
System.out.println(" - pomocí funkce \"vyuzit tts\" si muzete vyzkouset TextToSpeech pomocnika");
System.out.println("");
}
public static void tts()
{
System.out.println();
System.out.println(" TTS :-)");
System.out.println(" ---------");
System.out.println(" zadejte větu (exit pro ukončení): ");
String line = sc.nextLine();
if(line.matches("exit"))
return;
TextToSpeech.speak(line);
tts();
}
/**
* provide basic interface to change settings of this program
*/
public static void settings()
{
System.out.println();
System.out.println(" NASTAVENI");
System.out.println(" ---------");
System.out.println(" zmenit trideni testu: 1");
System.out.println(" vypnout/zapnout hlas: 2");
System.out.println(" txt/csv vysledky testu: 3");
System.out.println(" zpet do menu: 0");
System.out.println(" -------------------------");
System.out.print (" vase volba: ");
char charChoice = sc.next().charAt(0);
//check if user typed number and parse it
int choice = Character.isDigit(charChoice)
?Integer.parseInt(String.valueOf(charChoice)):-1;
switch(choice)
{
case 1:
System.out.println(" podle jmena: 1");
System.out.println(" podle obtiznosti: 2");
System.out.println(" podle poctu otazek: 3");
System.out.print (" vase volba: ");
char charChoice2 = sc.next().charAt(0);
if(!Character.isDigit(charChoice2))
{
System.out.println("spatna volba");
break;
}
//check if user typed number and parse it
int choice2 = Character.isDigit(charChoice2)
?Integer.parseInt(String.valueOf(charChoice2)):-1;
if(choice2 > 3 || choice2 < 1)
{
System.out.println("spatna volba");
break;
}
else if(choice2 == 1)
testList.sortOption = "name";
else if(choice2 == 2)
testList.sortOption = "difficulty";
else if(choice2 == 3)
testList.sortOption = "questions";
break;
case 2:
testList.voice = !testList.voice;
break;
case 3:
testList.txtOut = !testList.txtOut;
break;
case 0:
return;
default:
System.out.println("spatna volba");
break;
}
}
/**
* provide basic interface to choose a test
* @throws FileNotFoundException
* @throws DocumentException
*/
public static void chooseTest() throws FileNotFoundException, DocumentException
{
System.out.println(testList);
System.out.print("zadejte název testu, který chcete spustit: ");
Test t;
t = testList.getTest(sc.nextLine());
while(t == null)
{
System.out.println("Zadany nazev neexistuje. Zkuste to znovu.");
t = testList.getTest(sc.nextLine());
}
runTest(t);
}
/**
* runs the test and provides basic interface to answer its questions
* @param t
* @throws FileNotFoundException
* @throws DocumentException
*/
public static void runTest(Test t) throws FileNotFoundException, DocumentException
{
t.runTest();
Question q;
while( (q = t.getCurrentQuestion()) != null)
{
if(testList.voice)
TextToSpeech.speak(q.getQuestion());
System.out.println(q);
System.out.print("Zvolte odpoved: ");
int choice;
boolean choiceEnd = false;
while(!choiceEnd)
{
try
{
choice = Integer.parseInt( String.valueOf(sc.next().charAt(0)) );
t.answerCurrentQuestion(choice);
choiceEnd = true;
}
catch(IllegalArgumentException e)
{
System.out.println("spatna volba");
}
}
}
System.out.println(t.getResults());
if(testList.voice)
TextToSpeech.speak( Test.getCheer(t.getCurrentPoints(), t.getCurrentMaxPoints()) );
if(testList.txtOut)
t.saveResultsToPDF();
else
t.saveResultsToCsv();
}
/**
* provides basic interface to make a new test
* @throws FileNotFoundException
* @throws UnsupportedEncodingException
* @throws IOException
*/
public static void makeTest() throws FileNotFoundException, UnsupportedEncodingException, IOException
{
sc.nextLine();
System.out.print("Zadejte název testu: ");
String testName = sc.nextLine();
System.out.print("Zadejte typ testu: ");
String testType = sc.nextLine();
boolean exit = false;
ArrayList<Question> questions = new ArrayList();
while(!exit)
{
System.out.print("Chcete zadat novou otazku(ano = a, ne = cokoliv jineho): ");
if(!sc.nextLine().matches("a"))
exit = true;
else
{
System.out.print("Zadejte otazku: ");
String question = sc.nextLine();
System.out.print("Zadejte typ otazky: ");
String type = sc.nextLine();
System.out.print("Zadejte pocet moznych odpovedi: ");
int choiceQuant = sc.nextInt();
sc.nextLine();
ArrayList<String> choices = new ArrayList();
for (int i = 0; i < choiceQuant; i++)
{
System.out.println("Zadejte " + (i + 1) + ". moznou odpoved: ");
choices.add(sc.nextLine());
}
System.out.print("Zadejte spravnou odpoved: ");
int correctAnswer = sc.nextInt();
System.out.print("Zadejte pocet bodu teto otazky: ");
int points = sc.nextInt();
sc.nextLine();
questions.add(new Question(question, type, choices, correctAnswer, points));
}
}
System.out.print("Zadejte pocet max. otazek(-1 pro vsechny): ");
int questionQuant = sc.nextInt();
System.out.print("Zadejte obtiznost testu(1 = nejsnazsi): ");
int testDifficulty = sc.nextInt();
Test t = new Test(testName, testType, questions, questionQuant, testDifficulty);
t.saveTestToFile();
testList.addTest(t);
}
}
| UTF-8 | Java | 12,141 | java | Main.java | Java | [
{
"context": "n implements basic UI for the TEST app\r\n * @author Jachym\r\n */\r\npublic class Main\r\n{\r\n public static Sca",
"end": 655,
"score": 0.8128092288970947,
"start": 649,
"tag": "USERNAME",
"value": "Jachym"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ui;
import app.Test;
import app.Question;
import app.TestList;
import com.itextpdf.text.DocumentException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.InputMismatchException;
import java.util.Scanner;
import utils.FileHandler;
import utils.TextToSpeech;
/**
* Class Main implements basic UI for the TEST app
* @author Jachym
*/
public class Main
{
public static Scanner sc = new Scanner(System.in, "Cp1250");
public static TestList testList = new TestList();
//public static TextToSpeech tts = new TextToSpeech();
public static void main(String[] args) throws IOException, FileNotFoundException, DocumentException
{
TextToSpeech.speak("TESTY NA CESTY, nejlepsi testovac na svete celem");
testList.loadTests();
System.out.print("Zadejte své jméno: ");
boolean exit = false;
String name = "";
while(!exit)
{
try
{
name = sc.nextLine();
testList.setUserName(name);
exit = true;
}
catch(IllegalArgumentException e)
{
System.out.println(e.getMessage());
}
}
TextToSpeech.speak("Welcome " + name);
menu();
}
/**
* provides basic UI menu with all the needed functions
*/
public static void menu()
{
System.out.println("\nTESTY NA CESTY");
System.out.println("=================");
System.out.println("vybrat test 1");
System.out.println("vytvořit test 2");
System.out.println("nastavení 3");
System.out.println("využít tts 4");
System.out.println("o programu 5");
System.out.println("konec programu 0");
System.out.println("---------------------------");
System.out.print ("vaše volba: ");
char charChoice = sc.next().charAt(0);
//check if user typed number and parse it
int choice = Character.isDigit(charChoice)
?Integer.parseInt(String.valueOf(charChoice)):-1;
//clear the buffer
sc.nextLine();
try
{
switch(choice)
{
case 1:
chooseTest();
break;
case 2:
makeTest();
break;
case 3:
settings();
break;
case 4:
tts();
break;
case 5:
about();
break;
case 0:
return;
default:
System.out.println("Neplatny vstup!");
break;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
menu();
}
/**
* prints basic info about this program
*/
public static void about()
{
System.out.println("");
System.out.println("Testy na Cesty je testovací program, díky kterému si "
+ "procvičíte svoje mozečkové buňky jako nikdy předtím.");
System.out.println("Jeho úžasné uživatelsky přívětivé prostředí Vás vtrhne "
+ "do světa hlavolamů a hádanek tak silně, že bude velice těžké "
+ "se od něho odtrhnout!");
System.out.println("Návod:");
System.out.println(" - pomocí funkce \"vybrat test\" si vyberete test, ktery budete chtit zpracovat.");
System.out.println(" po jeho napsani se do slozky results vypise formatovany vystup vysledku ve forme pdf");
System.out.println(" pro znovu napsani testu vypnete a zapnete tento program");
System.out.println(" - pomocí funkce \"vytvori test\" vytvorite test,"
+ " ktery se na konci zapise do souboru tests a zaroven pripise do souboru tests/index.txt");
System.out.println(" - pomocí funkce \"nastaveni\" nastavite ruzne parametry programu");
System.out.println(" - pomocí funkce \"vyuzit tts\" si muzete vyzkouset TextToSpeech pomocnika");
System.out.println("");
}
public static void tts()
{
System.out.println();
System.out.println(" TTS :-)");
System.out.println(" ---------");
System.out.println(" zadejte větu (exit pro ukončení): ");
String line = sc.nextLine();
if(line.matches("exit"))
return;
TextToSpeech.speak(line);
tts();
}
/**
* provide basic interface to change settings of this program
*/
public static void settings()
{
System.out.println();
System.out.println(" NASTAVENI");
System.out.println(" ---------");
System.out.println(" zmenit trideni testu: 1");
System.out.println(" vypnout/zapnout hlas: 2");
System.out.println(" txt/csv vysledky testu: 3");
System.out.println(" zpet do menu: 0");
System.out.println(" -------------------------");
System.out.print (" vase volba: ");
char charChoice = sc.next().charAt(0);
//check if user typed number and parse it
int choice = Character.isDigit(charChoice)
?Integer.parseInt(String.valueOf(charChoice)):-1;
switch(choice)
{
case 1:
System.out.println(" podle jmena: 1");
System.out.println(" podle obtiznosti: 2");
System.out.println(" podle poctu otazek: 3");
System.out.print (" vase volba: ");
char charChoice2 = sc.next().charAt(0);
if(!Character.isDigit(charChoice2))
{
System.out.println("spatna volba");
break;
}
//check if user typed number and parse it
int choice2 = Character.isDigit(charChoice2)
?Integer.parseInt(String.valueOf(charChoice2)):-1;
if(choice2 > 3 || choice2 < 1)
{
System.out.println("spatna volba");
break;
}
else if(choice2 == 1)
testList.sortOption = "name";
else if(choice2 == 2)
testList.sortOption = "difficulty";
else if(choice2 == 3)
testList.sortOption = "questions";
break;
case 2:
testList.voice = !testList.voice;
break;
case 3:
testList.txtOut = !testList.txtOut;
break;
case 0:
return;
default:
System.out.println("spatna volba");
break;
}
}
/**
* provide basic interface to choose a test
* @throws FileNotFoundException
* @throws DocumentException
*/
public static void chooseTest() throws FileNotFoundException, DocumentException
{
System.out.println(testList);
System.out.print("zadejte název testu, který chcete spustit: ");
Test t;
t = testList.getTest(sc.nextLine());
while(t == null)
{
System.out.println("Zadany nazev neexistuje. Zkuste to znovu.");
t = testList.getTest(sc.nextLine());
}
runTest(t);
}
/**
* runs the test and provides basic interface to answer its questions
* @param t
* @throws FileNotFoundException
* @throws DocumentException
*/
public static void runTest(Test t) throws FileNotFoundException, DocumentException
{
t.runTest();
Question q;
while( (q = t.getCurrentQuestion()) != null)
{
if(testList.voice)
TextToSpeech.speak(q.getQuestion());
System.out.println(q);
System.out.print("Zvolte odpoved: ");
int choice;
boolean choiceEnd = false;
while(!choiceEnd)
{
try
{
choice = Integer.parseInt( String.valueOf(sc.next().charAt(0)) );
t.answerCurrentQuestion(choice);
choiceEnd = true;
}
catch(IllegalArgumentException e)
{
System.out.println("spatna volba");
}
}
}
System.out.println(t.getResults());
if(testList.voice)
TextToSpeech.speak( Test.getCheer(t.getCurrentPoints(), t.getCurrentMaxPoints()) );
if(testList.txtOut)
t.saveResultsToPDF();
else
t.saveResultsToCsv();
}
/**
* provides basic interface to make a new test
* @throws FileNotFoundException
* @throws UnsupportedEncodingException
* @throws IOException
*/
public static void makeTest() throws FileNotFoundException, UnsupportedEncodingException, IOException
{
sc.nextLine();
System.out.print("Zadejte název testu: ");
String testName = sc.nextLine();
System.out.print("Zadejte typ testu: ");
String testType = sc.nextLine();
boolean exit = false;
ArrayList<Question> questions = new ArrayList();
while(!exit)
{
System.out.print("Chcete zadat novou otazku(ano = a, ne = cokoliv jineho): ");
if(!sc.nextLine().matches("a"))
exit = true;
else
{
System.out.print("Zadejte otazku: ");
String question = sc.nextLine();
System.out.print("Zadejte typ otazky: ");
String type = sc.nextLine();
System.out.print("Zadejte pocet moznych odpovedi: ");
int choiceQuant = sc.nextInt();
sc.nextLine();
ArrayList<String> choices = new ArrayList();
for (int i = 0; i < choiceQuant; i++)
{
System.out.println("Zadejte " + (i + 1) + ". moznou odpoved: ");
choices.add(sc.nextLine());
}
System.out.print("Zadejte spravnou odpoved: ");
int correctAnswer = sc.nextInt();
System.out.print("Zadejte pocet bodu teto otazky: ");
int points = sc.nextInt();
sc.nextLine();
questions.add(new Question(question, type, choices, correctAnswer, points));
}
}
System.out.print("Zadejte pocet max. otazek(-1 pro vsechny): ");
int questionQuant = sc.nextInt();
System.out.print("Zadejte obtiznost testu(1 = nejsnazsi): ");
int testDifficulty = sc.nextInt();
Test t = new Test(testName, testType, questions, questionQuant, testDifficulty);
t.saveTestToFile();
testList.addTest(t);
}
}
| 12,141 | 0.492516 | 0.488134 | 339 | 33.672565 | 24.668459 | 120 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.560472 | false | false | 3 |
0431bcec9ed7b91350c731afd8dffc5f455c53bc | 9,964,324,183,634 | f5f147e3c931fba1d33ab3641382fc7ffab35e7d | /src/main/java/wang/tyrael/util/DateTimeUtil.java | 7be45e9b4d10ce708843c4ae8fb9864bddf01405 | [] | no_license | TyraelYoung/LibJava | https://github.com/TyraelYoung/LibJava | f9b117131e39ba1d7825ce312e31a9e4dfe36090 | 340229906e0a395535d380c1fb1c44d187debd56 | refs/heads/master | 2021-08-01T16:36:33.854000 | 2021-07-23T10:05:34 | 2021-07-23T10:05:34 | 104,977,230 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package wang.tyrael.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
public class DateTimeUtil {
private static final long INTERVAL_IN_MILLISECONDS = 30000L;
public static long getTodayStart(){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTimeInMillis();
}
/**
*
* @return 00:00
*/
public static String formatMinSec(int ms){
int secTotal = ms / 1000;
int sec = secTotal % 60;
int minTotal = secTotal / 60;
if(minTotal > 9){
return String.valueOf(minTotal) + ":" + String.format("%02d", sec);
}else{
return String.format("%02d", minTotal) + ":" + String.format("%02d", sec);
}
}
public static String getForamtTimes(String data) {
SimpleDateFormat mat = new SimpleDateFormat("yyyy.MM.dd");
String d = mat.format(new Date(Long.valueOf(data) * 1000));
return d;
}
public static String getTimes(String data) {
SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
String d = mat.format(new Date(Long.valueOf(data) * 1000));
return d;
}
public static String getDateAndTimes(String data) {
String t1 = "";
if (!data.equals("")) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = new Date(Long.valueOf(data) * 1000);
t1 = format.format(d1);
}
return t1;
}
public static String getSpaceTime(long oldtime, long newtime) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = "";
try {
long diff = newtime - oldtime;//这样得到的差值是微秒级别
long days = diff / (60 * 60 * 24);
long hours = (diff - days * (60 * 60 * 24)) / (60 * 60);
long minutes = (diff - days * (60 * 60 * 24) - hours * (60 * 60)) / (60);
long second = (diff - days * (60 * 60 * 24) - hours * (60 * 60) - minutes * (60));
value = String.format("%02d", days) + "天" + String.format("%02d", hours) + "小时" + String.format("%02d", minutes) + "分" + String.format
("%02d", second) + "秒";
} catch (Exception e) {
}
return value;
}
public static long getTwoDay(long oldtime, long newtime) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
long diff = newtime - oldtime;//这样得到的差值是微秒级别
long days = diff / (60 * 60 * 24);
return days;
} catch (Exception e) {
}
return 0;
}
public static String diffTime(String time) {
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
long d2 = date.getTime();
long d1 = Long.valueOf(time) * 1000;
long diff = (d2 - d1);
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours
* (1000 * 60 * 60))
/ (1000 * 60);
String timeString;
if (days > 0) {
timeString = days + "天前";
} else if (hours > 0) {
timeString = hours + "小时前";
} else {
timeString = minutes + "分钟前";
}
return timeString;
}
public static Date stringToDate(String dateString) {
ParsePosition position = new ParsePosition(0);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateValue = simpleDateFormat.parse(dateString, position);
return dateValue;
}
/**
* 调用此方法输入所要转换的时间戳输入例如(1402733340)输出("16:09")
*/
public static String timetHour(String time) {
SimpleDateFormat sdr = new SimpleDateFormat("HH:mm");
@SuppressWarnings("unused")
long lcc = Long.valueOf(time);
int i = Integer.parseInt(time);
String times = sdr.format(new Date(i * 1000L));
return times;
}
/**
* 获取现在时间
*
* @return返回短时间格式 yyyyMMdd
*/
public static String getStringToday() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 调用此方法输入所要转换的时间戳输入例如(1402733340)输出("20140614")
*/
public static String timetDay(String time) {
SimpleDateFormat sdr = new SimpleDateFormat("yyyyMMdd");
@SuppressWarnings("unused")
long lcc = Long.valueOf(time);
int i = Integer.parseInt(time);
String times = sdr.format(new Date(i * 1000L));
return times;
}
/**
* 得到二个日期间的间隔天数
*/
public static String getTwoDay(String sj1, String sj2) {
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyyMMdd");
long day = 0;
try {
java.util.Date date = myFormatter.parse(sj1);
java.util.Date mydate = myFormatter.parse(sj2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
return "";
}
return day + "";
}
public static String getTimestampString(Date var0) {
String var1 = null;
long var2 = var0.getTime();
if (isSameDay(var2)) {
Calendar var4 = GregorianCalendar.getInstance();
var4.setTime(var0);
int var5 = var4.get(Calendar.HOUR_OF_DAY);
if (var5 > 17) {
var1 = "晚上 hh:mm";
} else if (var5 >= 0 && var5 <= 6) {
var1 = "凌晨 hh:mm";
} else if (var5 > 11 && var5 <= 17) {
var1 = "下午 hh:mm";
} else {
var1 = "上午 hh:mm";
}
} else if (isYesterday(var2)) {
var1 = "昨天 HH:mm";
} else {
var1 = "M月d日 HH:mm";
}
return (new SimpleDateFormat(var1, Locale.CHINA)).format(var0);
}
public static boolean isCloseEnough(long var0, long var2) {
long var4 = var0 - var2;
if (var4 < 0L) {
var4 = -var4;
}
return var4 < 30000L;
}
private static boolean isSameDay(long var0) {
TimeInfo var2 = getTodayStartAndEndTime();
return var0 > var2.getStartTime() && var0 < var2.getEndTime();
}
private static boolean isYesterday(long var0) {
TimeInfo var2 = getYesterdayStartAndEndTime();
return var0 > var2.getStartTime() && var0 < var2.getEndTime();
}
public static Date StringToDate(String var0, String var1) {
SimpleDateFormat var2 = new SimpleDateFormat(var1);
Date var3 = null;
try {
var3 = var2.parse(var0);
} catch (ParseException var5) {
var5.printStackTrace();
}
return var3;
}
public static String toTime(int var0) {
var0 /= 1000;
int var1 = var0 / 60;
boolean var2 = false;
if (var1 >= 60) {
int var4 = var1 / 60;
var1 %= 60;
}
int var3 = var0 % 60;
return String.format("%02d:%02d", Integer.valueOf(var1), Integer.valueOf(var3));
}
public static String toTimeBySecond(int var0) {
int var1 = var0 / 60;
boolean var2 = false;
if (var1 >= 60) {
int var4 = var1 / 60;
var1 %= 60;
}
int var3 = var0 % 60;
return String.format("%02d:%02d", Integer.valueOf(var1), Integer.valueOf(var3));
}
public static TimeInfo getYesterdayStartAndEndTime() {
Calendar var0 = Calendar.getInstance();
var0.add(Calendar.DAY_OF_MONTH, -1);
var0.set(Calendar.HOUR_OF_DAY, 0);
var0.set(Calendar.MINUTE, 0);
var0.set(Calendar.SECOND, 0);
var0.set(Calendar.MILLISECOND, 0);
Date var1 = var0.getTime();
long var2 = var1.getTime();
Calendar var4 = Calendar.getInstance();
var4.add(Calendar.DAY_OF_MONTH, -1);
var4.set(Calendar.HOUR_OF_DAY, 23);
var4.set(Calendar.MINUTE, 59);
var4.set(Calendar.SECOND, 59);
var4.set(Calendar.MILLISECOND, 999);
Date var5 = var4.getTime();
long var6 = var5.getTime();
TimeInfo var8 = new TimeInfo();
var8.setStartTime(var2);
var8.setEndTime(var6);
return var8;
}
public static TimeInfo getTodayStartAndEndTime() {
Calendar var0 = Calendar.getInstance();
var0.set(Calendar.HOUR_OF_DAY, 0);
var0.set(Calendar.MINUTE, 0);
var0.set(Calendar.SECOND, 0);
var0.set(Calendar.MILLISECOND, 0);
Date var1 = var0.getTime();
long var2 = var1.getTime();
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss S");
Calendar todayEnd = Calendar.getInstance();
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);
Date var6 = todayEnd.getTime();
long var7 = var6.getTime();
TimeInfo var9 = new TimeInfo();
var9.setStartTime(var2);
var9.setEndTime(var7);
return var9;
}
/**
* 计算两个时间戳的时间间隔,返回的String[]数组为时间间隔的{时,分,秒}
* @param fT 较早的时间
* @param sT 较晚的时间
* @return
*/
public static String[] getTimeInterval(String fT,String sT){
if (fT == null || sT == null){
return new String[]{"00","00","00"};
}
long diff = Long.parseLong(sT) - Long.parseLong(fT);
if (diff <= 0){
return new String[]{"00","00","00"};
}
long hour = diff / (60 * 60);
long min = diff / 60 - hour * 60;
long sec = diff - hour * 60 * 60 - min * 60;
return new String[]{String.format("%02d",hour),String.format("%02d",min),String.format("%02d",sec)};
}
}
| UTF-8 | Java | 10,709 | java | DateTimeUtil.java | Java | [] | null | [] | package wang.tyrael.util;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
public class DateTimeUtil {
private static final long INTERVAL_IN_MILLISECONDS = 30000L;
public static long getTodayStart(){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTimeInMillis();
}
/**
*
* @return 00:00
*/
public static String formatMinSec(int ms){
int secTotal = ms / 1000;
int sec = secTotal % 60;
int minTotal = secTotal / 60;
if(minTotal > 9){
return String.valueOf(minTotal) + ":" + String.format("%02d", sec);
}else{
return String.format("%02d", minTotal) + ":" + String.format("%02d", sec);
}
}
public static String getForamtTimes(String data) {
SimpleDateFormat mat = new SimpleDateFormat("yyyy.MM.dd");
String d = mat.format(new Date(Long.valueOf(data) * 1000));
return d;
}
public static String getTimes(String data) {
SimpleDateFormat mat = new SimpleDateFormat("yyyy-MM-dd");
String d = mat.format(new Date(Long.valueOf(data) * 1000));
return d;
}
public static String getDateAndTimes(String data) {
String t1 = "";
if (!data.equals("")) {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date d1 = new Date(Long.valueOf(data) * 1000);
t1 = format.format(d1);
}
return t1;
}
public static String getSpaceTime(long oldtime, long newtime) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String value = "";
try {
long diff = newtime - oldtime;//这样得到的差值是微秒级别
long days = diff / (60 * 60 * 24);
long hours = (diff - days * (60 * 60 * 24)) / (60 * 60);
long minutes = (diff - days * (60 * 60 * 24) - hours * (60 * 60)) / (60);
long second = (diff - days * (60 * 60 * 24) - hours * (60 * 60) - minutes * (60));
value = String.format("%02d", days) + "天" + String.format("%02d", hours) + "小时" + String.format("%02d", minutes) + "分" + String.format
("%02d", second) + "秒";
} catch (Exception e) {
}
return value;
}
public static long getTwoDay(long oldtime, long newtime) {
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
long diff = newtime - oldtime;//这样得到的差值是微秒级别
long days = diff / (60 * 60 * 24);
return days;
} catch (Exception e) {
}
return 0;
}
public static String diffTime(String time) {
Calendar calendar = Calendar.getInstance();
Date date = calendar.getTime();
long d2 = date.getTime();
long d1 = Long.valueOf(time) * 1000;
long diff = (d2 - d1);
long days = diff / (1000 * 60 * 60 * 24);
long hours = (diff - days * (1000 * 60 * 60 * 24)) / (1000 * 60 * 60);
long minutes = (diff - days * (1000 * 60 * 60 * 24) - hours
* (1000 * 60 * 60))
/ (1000 * 60);
String timeString;
if (days > 0) {
timeString = days + "天前";
} else if (hours > 0) {
timeString = hours + "小时前";
} else {
timeString = minutes + "分钟前";
}
return timeString;
}
public static Date stringToDate(String dateString) {
ParsePosition position = new ParsePosition(0);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
Date dateValue = simpleDateFormat.parse(dateString, position);
return dateValue;
}
/**
* 调用此方法输入所要转换的时间戳输入例如(1402733340)输出("16:09")
*/
public static String timetHour(String time) {
SimpleDateFormat sdr = new SimpleDateFormat("HH:mm");
@SuppressWarnings("unused")
long lcc = Long.valueOf(time);
int i = Integer.parseInt(time);
String times = sdr.format(new Date(i * 1000L));
return times;
}
/**
* 获取现在时间
*
* @return返回短时间格式 yyyyMMdd
*/
public static String getStringToday() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMdd");
String dateString = formatter.format(currentTime);
return dateString;
}
/**
* 调用此方法输入所要转换的时间戳输入例如(1402733340)输出("20140614")
*/
public static String timetDay(String time) {
SimpleDateFormat sdr = new SimpleDateFormat("yyyyMMdd");
@SuppressWarnings("unused")
long lcc = Long.valueOf(time);
int i = Integer.parseInt(time);
String times = sdr.format(new Date(i * 1000L));
return times;
}
/**
* 得到二个日期间的间隔天数
*/
public static String getTwoDay(String sj1, String sj2) {
SimpleDateFormat myFormatter = new SimpleDateFormat("yyyyMMdd");
long day = 0;
try {
java.util.Date date = myFormatter.parse(sj1);
java.util.Date mydate = myFormatter.parse(sj2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
} catch (Exception e) {
return "";
}
return day + "";
}
public static String getTimestampString(Date var0) {
String var1 = null;
long var2 = var0.getTime();
if (isSameDay(var2)) {
Calendar var4 = GregorianCalendar.getInstance();
var4.setTime(var0);
int var5 = var4.get(Calendar.HOUR_OF_DAY);
if (var5 > 17) {
var1 = "晚上 hh:mm";
} else if (var5 >= 0 && var5 <= 6) {
var1 = "凌晨 hh:mm";
} else if (var5 > 11 && var5 <= 17) {
var1 = "下午 hh:mm";
} else {
var1 = "上午 hh:mm";
}
} else if (isYesterday(var2)) {
var1 = "昨天 HH:mm";
} else {
var1 = "M月d日 HH:mm";
}
return (new SimpleDateFormat(var1, Locale.CHINA)).format(var0);
}
public static boolean isCloseEnough(long var0, long var2) {
long var4 = var0 - var2;
if (var4 < 0L) {
var4 = -var4;
}
return var4 < 30000L;
}
private static boolean isSameDay(long var0) {
TimeInfo var2 = getTodayStartAndEndTime();
return var0 > var2.getStartTime() && var0 < var2.getEndTime();
}
private static boolean isYesterday(long var0) {
TimeInfo var2 = getYesterdayStartAndEndTime();
return var0 > var2.getStartTime() && var0 < var2.getEndTime();
}
public static Date StringToDate(String var0, String var1) {
SimpleDateFormat var2 = new SimpleDateFormat(var1);
Date var3 = null;
try {
var3 = var2.parse(var0);
} catch (ParseException var5) {
var5.printStackTrace();
}
return var3;
}
public static String toTime(int var0) {
var0 /= 1000;
int var1 = var0 / 60;
boolean var2 = false;
if (var1 >= 60) {
int var4 = var1 / 60;
var1 %= 60;
}
int var3 = var0 % 60;
return String.format("%02d:%02d", Integer.valueOf(var1), Integer.valueOf(var3));
}
public static String toTimeBySecond(int var0) {
int var1 = var0 / 60;
boolean var2 = false;
if (var1 >= 60) {
int var4 = var1 / 60;
var1 %= 60;
}
int var3 = var0 % 60;
return String.format("%02d:%02d", Integer.valueOf(var1), Integer.valueOf(var3));
}
public static TimeInfo getYesterdayStartAndEndTime() {
Calendar var0 = Calendar.getInstance();
var0.add(Calendar.DAY_OF_MONTH, -1);
var0.set(Calendar.HOUR_OF_DAY, 0);
var0.set(Calendar.MINUTE, 0);
var0.set(Calendar.SECOND, 0);
var0.set(Calendar.MILLISECOND, 0);
Date var1 = var0.getTime();
long var2 = var1.getTime();
Calendar var4 = Calendar.getInstance();
var4.add(Calendar.DAY_OF_MONTH, -1);
var4.set(Calendar.HOUR_OF_DAY, 23);
var4.set(Calendar.MINUTE, 59);
var4.set(Calendar.SECOND, 59);
var4.set(Calendar.MILLISECOND, 999);
Date var5 = var4.getTime();
long var6 = var5.getTime();
TimeInfo var8 = new TimeInfo();
var8.setStartTime(var2);
var8.setEndTime(var6);
return var8;
}
public static TimeInfo getTodayStartAndEndTime() {
Calendar var0 = Calendar.getInstance();
var0.set(Calendar.HOUR_OF_DAY, 0);
var0.set(Calendar.MINUTE, 0);
var0.set(Calendar.SECOND, 0);
var0.set(Calendar.MILLISECOND, 0);
Date var1 = var0.getTime();
long var2 = var1.getTime();
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss S");
Calendar todayEnd = Calendar.getInstance();
todayEnd.set(Calendar.HOUR_OF_DAY, 23);
todayEnd.set(Calendar.MINUTE, 59);
todayEnd.set(Calendar.SECOND, 59);
todayEnd.set(Calendar.MILLISECOND, 999);
Date var6 = todayEnd.getTime();
long var7 = var6.getTime();
TimeInfo var9 = new TimeInfo();
var9.setStartTime(var2);
var9.setEndTime(var7);
return var9;
}
/**
* 计算两个时间戳的时间间隔,返回的String[]数组为时间间隔的{时,分,秒}
* @param fT 较早的时间
* @param sT 较晚的时间
* @return
*/
public static String[] getTimeInterval(String fT,String sT){
if (fT == null || sT == null){
return new String[]{"00","00","00"};
}
long diff = Long.parseLong(sT) - Long.parseLong(fT);
if (diff <= 0){
return new String[]{"00","00","00"};
}
long hour = diff / (60 * 60);
long min = diff / 60 - hour * 60;
long sec = diff - hour * 60 * 60 - min * 60;
return new String[]{String.format("%02d",hour),String.format("%02d",min),String.format("%02d",sec)};
}
}
| 10,709 | 0.553577 | 0.510253 | 324 | 31.055555 | 23.485548 | 146 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.682099 | false | false | 3 |
8d4ce6307a0d0d9110da16843bb7de3772d39f10 | 35,167,192,237,094 | e73678462ce98317558a6ad3022e9ba256f913c0 | /UserDaoImpl.java | dea6118e02d22defd79135cd1484f03835b63e1c | [] | no_license | AjzForYou/OnlineLibraryManagement | https://github.com/AjzForYou/OnlineLibraryManagement | 9cc565dc7423c8049e8ad039e31ad03e480b87d3 | 2edfda69ac228a72102511777982bf3102fb07cf | refs/heads/master | 2021-08-15T19:10:30.649000 | 2017-11-18T05:19:26 | 2017-11-18T05:19:26 | 111,178,786 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.app.dao;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.app.pojo.Book;
import com.app.pojo.Users;
@Repository
public class UserDaoImpl implements UserDao
{
@Autowired
private SessionFactory factory;
@Override
public Users validateUser(String email, String password) {
String hql = "select u from Users u where u.email=:em and u.password=:pass";
return factory.getCurrentSession().createQuery(hql, Users.class).setParameter("em", email).setParameter("pass", password).getSingleResult();
}
@Override
public Integer registerUser(Users user)
{
return (Integer) factory.getCurrentSession().save(user);
}
@Override
public List<Users> getUserList() {
String hql = "select b from Users b";
return (List<Users>) factory.getCurrentSession().createQuery(hql, Users.class).getResultList();
}
@Override
public void deleteUser(int uid) {
Users user = factory.getCurrentSession().get(Users.class, uid);
factory.getCurrentSession().remove(user);
}
public Book IssueBook() {
String hql = "select b from Book b where b.stock=:bstock";;
return null;
}
@Override
public Book issueBook() {
// TODO Auto-generated method stub
return null;
}
}
| UTF-8 | Java | 1,395 | java | UserDaoImpl.java | Java | [] | null | [] | package com.app.dao;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import com.app.pojo.Book;
import com.app.pojo.Users;
@Repository
public class UserDaoImpl implements UserDao
{
@Autowired
private SessionFactory factory;
@Override
public Users validateUser(String email, String password) {
String hql = "select u from Users u where u.email=:em and u.password=:pass";
return factory.getCurrentSession().createQuery(hql, Users.class).setParameter("em", email).setParameter("pass", password).getSingleResult();
}
@Override
public Integer registerUser(Users user)
{
return (Integer) factory.getCurrentSession().save(user);
}
@Override
public List<Users> getUserList() {
String hql = "select b from Users b";
return (List<Users>) factory.getCurrentSession().createQuery(hql, Users.class).getResultList();
}
@Override
public void deleteUser(int uid) {
Users user = factory.getCurrentSession().get(Users.class, uid);
factory.getCurrentSession().remove(user);
}
public Book IssueBook() {
String hql = "select b from Book b where b.stock=:bstock";;
return null;
}
@Override
public Book issueBook() {
// TODO Auto-generated method stub
return null;
}
}
| 1,395 | 0.74767 | 0.74767 | 55 | 24.363636 | 28.220795 | 142 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.345455 | false | false | 3 |
59840c108a20e3009ee449dd83d658e19a513cab | 1,417,339,215,934 | 40547b91873a132648ef3f02dbc41eacce0c1ada | /Gartenplaner/src/dbController/Weather.java | 16e7f12cf3895ba79920d99941746476242fa60c | [] | no_license | MaxiSonntag/Gardenplanner-RESTful-Webservice | https://github.com/MaxiSonntag/Gardenplanner-RESTful-Webservice | 85a6d892b054cbf7e5f90fef25170cb3a691912b | 7e6875313acdcebf38249790c870f4f59628a07e | refs/heads/master | 2021-04-12T12:02:35.824000 | 2018-03-22T13:58:25 | 2018-03-22T13:58:25 | 126,343,649 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package dbController;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.*;
import org.hibernate.annotations.GenericGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
@Table(name ="WEATHER")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Weather {
@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy = "increment")
@Column(columnDefinition = "UNSIGNED INT(10)", name="id")
private int id;
@JsonIgnore
@ManyToOne(fetch=FetchType.LAZY)
private Location location;
@Override
public String toString() {
return "Weather [id=" + id + ", location=" + location + ", date=" + date + ", rainfall=" + rainfall
+ ", sun_hours=" + sun_hours + ", temperature=" + temperature + "]";
}
@Column(name = "date")
private Timestamp date;
@Column(name = "rainfall")
private float rainfall;
@Column(name = "sun_hours")
private float sun_hours;
@Column (name = "temperature")
private double temperature;
public int getId() {
return id;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public Timestamp getDate() {
return date;
}
public void setDate(Timestamp date) {
this.date = date;
}
public float getRainfall() {
return rainfall;
}
public void setRainfall(float rainfall) {
this.rainfall = rainfall;
}
public float getSun_hours() {
return sun_hours;
}
public void setSun_hours(float sun_hours) {
this.sun_hours = sun_hours;
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
}
}
| UTF-8 | Java | 1,782 | java | Weather.java | Java | [] | null | [] | package dbController;
import java.sql.Date;
import java.sql.Timestamp;
import javax.persistence.*;
import org.hibernate.annotations.GenericGenerator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@Entity
@Table(name ="WEATHER")
@JsonIgnoreProperties({"hibernateLazyInitializer", "handler"})
public class Weather {
@Id
@GeneratedValue(generator="increment")
@GenericGenerator(name="increment", strategy = "increment")
@Column(columnDefinition = "UNSIGNED INT(10)", name="id")
private int id;
@JsonIgnore
@ManyToOne(fetch=FetchType.LAZY)
private Location location;
@Override
public String toString() {
return "Weather [id=" + id + ", location=" + location + ", date=" + date + ", rainfall=" + rainfall
+ ", sun_hours=" + sun_hours + ", temperature=" + temperature + "]";
}
@Column(name = "date")
private Timestamp date;
@Column(name = "rainfall")
private float rainfall;
@Column(name = "sun_hours")
private float sun_hours;
@Column (name = "temperature")
private double temperature;
public int getId() {
return id;
}
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
public Timestamp getDate() {
return date;
}
public void setDate(Timestamp date) {
this.date = date;
}
public float getRainfall() {
return rainfall;
}
public void setRainfall(float rainfall) {
this.rainfall = rainfall;
}
public float getSun_hours() {
return sun_hours;
}
public void setSun_hours(float sun_hours) {
this.sun_hours = sun_hours;
}
public double getTemperature() {
return temperature;
}
public void setTemperature(double temperature) {
this.temperature = temperature;
}
}
| 1,782 | 0.712121 | 0.710999 | 81 | 21 | 20.213062 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.345679 | false | false | 3 |
8586da451e08ad3f343f9f59b1c8e395e84bc0f0 | 18,657,337,946,436 | 8b8c345d4f3e3b77341b400a304a865127ec29fa | /vie-shared/vie-une/src/main/java/com/vie/fixed/Constants.java | 771ba55c3d31afec9c1fb4bf1e8b245f4e332760 | [] | no_license | silentbalanceyh/vie | https://github.com/silentbalanceyh/vie | 7038dfcf40c58f9ee186b8682c11048a7436297f | 696b88345639af0bd3de974e5e51b7760cebfaca | refs/heads/master | 2016-12-13T18:47:23.436000 | 2016-05-11T15:13:47 | 2016-05-11T15:13:47 | 58,053,292 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.vie.fixed;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 【Constant::常量接口】系统常量
* @author Lang
* @see All system constants which must not be changed
*/
public interface Constants { // NOPMD
// ~ Static Fields =======================================
/** 全局统一属性ID信息 **/
// TODO: 这里改动过后可能很多地方无法通过编译
String PID = "uniqueId";
/** 默认的Pool名 **/
String DFT_POOL = "$$DEFAULT$$";
/** **/
String TCP_PASSWORD = "db6ea8d90fa0cad8597d332cb1ee3903143588bce135c1f1100a6e62c523dd70";
/** Script Engine 名称 **/
String SCRIPT_ENGINE = "nashorn";
/** **/
interface EXTENSION { // NOPMD
/** INIT 后缀名 **/
String SQL = "sql";
/** JSON 后缀名 **/
String JSON = "json";
/** Properties 后缀名 **/
String PROP = "properties";
/** JavaScript后缀 **/
String JS = "js";
}
// ~ System ==============================================
/** System value 2 **/
int TWO = 2;
/** System value 1 **/
int ONE = 1;
/** System value 0 **/
int ZERO = 0;
/** 数据库影响0记录常量 **/
int NO_ROW = ZERO;
/** 读取Buffer的开始值 **/
int POS = ZERO;
/** 索引的开始值 **/
int IDX = ZERO;
/** 系统边界值:-1,用于很多地方的临界值使用 **/
int RANGE = -1;
/** HashCode base number **/
int HASH_BASE = 31;
/** Default StringBuilder/Buffer Size **/
int BUFFER_SIZE = 32;
/** Byte Array Default Buffer Size **/
int BYTE_BUF_SIZE = 4096;
// ~ Simple Response Code ================================
/** 成功返回值 **/
int RC_SUCCESS = ZERO;
/** 失败返回值 **/
int RC_FAILURE = -1;
// ~ Type Constants ======================================
/** 字符串数组类型 **/
String[] T_STR_ARR = new String[] {};
/** 用于传参数 **/
Object[] T_OBJ_ARR = new Object[] {};
/** 空集合:仅用于传参 **/
Set<String> T_STR_SET = new HashSet<>();
/** 空列表 :仅用于传参 **/
List<String> T_STR_LST = new ArrayList<>();
// ~ Spec Literal ========================================
/** Json空对象 **/
String EMPTY_JOBJ = "{}";
/** Json空数组 **/
String EMPTY_JARR = "[]";
/** String空字符串 **/
String EMPTY_STR = "";
// ~ Util ================================================
/** 16进制字节数组 **/
char[] UTI_HEX_ARR = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/** H2的数据类型 **/
String[] H2_TYPES = new String[] { "INT", "BOOLEAN", "TINYINT", "SMALLINT", "BIGINT", "IDENTITY", "DECIMAL",
"DOUBLE", "REAL", "TIME", "DATE", "TIMESTAMP", "BINARY", "OTHER", "VARCHAR", "VARCHAR IGNORECASE", "CHAR",
"BLOB", "CLOB", "UUID", "ARRAY" };
// ~ Vertx Default =======================================
/** HA Group Default **/
String VX_GROUP = "__DEFAULT__";
/** Default Convertor,默认Convertor,什么都不做 **/
String VX_CONVERTOR = VX_GROUP;
/** **/
interface PARAM { // NOPMD
/** **/
String ID = "identifier"; // NOPMD
/** **/
String DATA = "data";
/** **/
String SESSION = "session.id";
/** **/
String METHOD = "method";
/** **/
String SCRIPT = "script";
/** 查询根节点 **/
String QUERY = "query";
/** Query用的特殊参数 **/
interface ADMINICLE {
/** Projection中的列信息,返回内容从这里读取 **/
String FILTERS = "filters";
/** Pager分页参数 **/
String PAGER = "pager";
/** OrderBy参数 **/
String ORDERS = "orders";
/** **/
interface PAGE { // NOPMD
/** Index 参数:最小为1即表示第一页 **/
String INDEX = "index";
/** Size 参数:每一页的数量 **/
String SIZE = "size";
/** Return Counter **/
interface RET {
/** Counter **/
String COUNT = "count";
/** List **/
String LIST = "list";
}
}
}
}
}
| UTF-8 | Java | 4,634 | java | Constants.java | Java | [
{
"context": "l.Set;\r\n\r\n/**\r\n * 【Constant::常量接口】系统常量\r\n * @author Lang\r\n * @see All system constants which must not be c",
"end": 176,
"score": 0.9820345640182495,
"start": 172,
"tag": "NAME",
"value": "Lang"
},
{
"context": "AULT$$\";\r\n /** **/\r\n String TCP_PASSWORD = \"db6ea8d90fa0cad8597d332cb1ee3903143588bce135c1f1100a6e62c523dd70\";\r\n /** Script Engine 名称 **/\r\n String SCRIP",
"end": 593,
"score": 0.998993992805481,
"start": 529,
"tag": "PASSWORD",
"value": "db6ea8d90fa0cad8597d332cb1ee3903143588bce135c1f1100a6e62c523dd70"
}
] | null | [] | package com.vie.fixed;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* 【Constant::常量接口】系统常量
* @author Lang
* @see All system constants which must not be changed
*/
public interface Constants { // NOPMD
// ~ Static Fields =======================================
/** 全局统一属性ID信息 **/
// TODO: 这里改动过后可能很多地方无法通过编译
String PID = "uniqueId";
/** 默认的Pool名 **/
String DFT_POOL = "$$DEFAULT$$";
/** **/
String TCP_PASSWORD = "<PASSWORD>";
/** Script Engine 名称 **/
String SCRIPT_ENGINE = "nashorn";
/** **/
interface EXTENSION { // NOPMD
/** INIT 后缀名 **/
String SQL = "sql";
/** JSON 后缀名 **/
String JSON = "json";
/** Properties 后缀名 **/
String PROP = "properties";
/** JavaScript后缀 **/
String JS = "js";
}
// ~ System ==============================================
/** System value 2 **/
int TWO = 2;
/** System value 1 **/
int ONE = 1;
/** System value 0 **/
int ZERO = 0;
/** 数据库影响0记录常量 **/
int NO_ROW = ZERO;
/** 读取Buffer的开始值 **/
int POS = ZERO;
/** 索引的开始值 **/
int IDX = ZERO;
/** 系统边界值:-1,用于很多地方的临界值使用 **/
int RANGE = -1;
/** HashCode base number **/
int HASH_BASE = 31;
/** Default StringBuilder/Buffer Size **/
int BUFFER_SIZE = 32;
/** Byte Array Default Buffer Size **/
int BYTE_BUF_SIZE = 4096;
// ~ Simple Response Code ================================
/** 成功返回值 **/
int RC_SUCCESS = ZERO;
/** 失败返回值 **/
int RC_FAILURE = -1;
// ~ Type Constants ======================================
/** 字符串数组类型 **/
String[] T_STR_ARR = new String[] {};
/** 用于传参数 **/
Object[] T_OBJ_ARR = new Object[] {};
/** 空集合:仅用于传参 **/
Set<String> T_STR_SET = new HashSet<>();
/** 空列表 :仅用于传参 **/
List<String> T_STR_LST = new ArrayList<>();
// ~ Spec Literal ========================================
/** Json空对象 **/
String EMPTY_JOBJ = "{}";
/** Json空数组 **/
String EMPTY_JARR = "[]";
/** String空字符串 **/
String EMPTY_STR = "";
// ~ Util ================================================
/** 16进制字节数组 **/
char[] UTI_HEX_ARR = new char[] { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
/** H2的数据类型 **/
String[] H2_TYPES = new String[] { "INT", "BOOLEAN", "TINYINT", "SMALLINT", "BIGINT", "IDENTITY", "DECIMAL",
"DOUBLE", "REAL", "TIME", "DATE", "TIMESTAMP", "BINARY", "OTHER", "VARCHAR", "VARCHAR IGNORECASE", "CHAR",
"BLOB", "CLOB", "UUID", "ARRAY" };
// ~ Vertx Default =======================================
/** HA Group Default **/
String VX_GROUP = "__DEFAULT__";
/** Default Convertor,默认Convertor,什么都不做 **/
String VX_CONVERTOR = VX_GROUP;
/** **/
interface PARAM { // NOPMD
/** **/
String ID = "identifier"; // NOPMD
/** **/
String DATA = "data";
/** **/
String SESSION = "session.id";
/** **/
String METHOD = "method";
/** **/
String SCRIPT = "script";
/** 查询根节点 **/
String QUERY = "query";
/** Query用的特殊参数 **/
interface ADMINICLE {
/** Projection中的列信息,返回内容从这里读取 **/
String FILTERS = "filters";
/** Pager分页参数 **/
String PAGER = "pager";
/** OrderBy参数 **/
String ORDERS = "orders";
/** **/
interface PAGE { // NOPMD
/** Index 参数:最小为1即表示第一页 **/
String INDEX = "index";
/** Size 参数:每一页的数量 **/
String SIZE = "size";
/** Return Counter **/
interface RET {
/** Counter **/
String COUNT = "count";
/** List **/
String LIST = "list";
}
}
}
}
}
| 4,580 | 0.42337 | 0.406235 | 138 | 28.449276 | 20.604654 | 119 | false | false | 0 | 0 | 0 | 0 | 64 | 0.015231 | 0.608696 | false | false | 3 |
3f839ebdf34cdcad9859d4be856fcf237b0d4e43 | 25,950,192,441,861 | 4505141188573778466b1e4a274e55f46a4a9762 | /src/app/Controller.java | 4fbafb8f5743035dfa3a2ad8250ea3ee300d1fb6 | [
"MIT"
] | permissive | MAbdurahman/JavaFX-Future-Value-Calculator | https://github.com/MAbdurahman/JavaFX-Future-Value-Calculator | 0b009f67a6981b286ec152806d748b31cc837d11 | 1de42a0a3f3b9daea897272f814ac7a130f94797 | refs/heads/master | 2021-05-18T22:09:17.278000 | 2020-03-31T01:39:56 | 2020-03-31T01:39:56 | 251,446,810 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package app;
import com.mahdi_abdurrahman.utilities.Calculator;
import com.mahdi_abdurrahman.utilities.Validator;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;
import java.text.NumberFormat;
public class Controller {
@FXML private TextField investmentField;
@FXML private TextField interestRateField;
@FXML private TextField numberYearsField;
@FXML private TextField futureValueField;
@FXML
protected void calculateButtonClicked() {
Validator validation = new Validator();
String errorMsg = "";
errorMsg += validation.isDouble(investmentField.getText(), "Monthly Investment");
errorMsg += validation.isDouble(interestRateField.getText(), "Yearly Interest Rate");
errorMsg += validation.isInteger(numberYearsField.getText(), "Number of Years");
if (errorMsg.isEmpty()) {
double investment = Double.parseDouble(investmentField.getText());
double interest = Double.parseDouble(interestRateField.getText());
int years = Integer.parseInt(numberYearsField.getText());
double futureValue = Calculator.calculateFutureValue(investment, interest, years);
NumberFormat currency = NumberFormat.getCurrencyInstance();
futureValueField.setText(currency.format(futureValue));
} else {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText("Invalid Data");
alert.setContentText(errorMsg);
alert.showAndWait();
}
}//end of the calculateButtonClicked Method
@FXML
protected void terminateButtonClicked() {
Platform.exit();
}//end of the terminatedButtonClicked Method
public void resetButtonClicked() {
investmentField.setText("");
interestRateField.setText("");
numberYearsField.setText("");
futureValueField.setText("");
}//end of the resetButtonClicked Method
}//end of the Controller Class
| UTF-8 | Java | 2,100 | java | Controller.java | Java | [] | null | [] | package app;
import com.mahdi_abdurrahman.utilities.Calculator;
import com.mahdi_abdurrahman.utilities.Validator;
import javafx.application.Platform;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.scene.control.Alert;
import javafx.scene.control.TextField;
import java.text.NumberFormat;
public class Controller {
@FXML private TextField investmentField;
@FXML private TextField interestRateField;
@FXML private TextField numberYearsField;
@FXML private TextField futureValueField;
@FXML
protected void calculateButtonClicked() {
Validator validation = new Validator();
String errorMsg = "";
errorMsg += validation.isDouble(investmentField.getText(), "Monthly Investment");
errorMsg += validation.isDouble(interestRateField.getText(), "Yearly Interest Rate");
errorMsg += validation.isInteger(numberYearsField.getText(), "Number of Years");
if (errorMsg.isEmpty()) {
double investment = Double.parseDouble(investmentField.getText());
double interest = Double.parseDouble(interestRateField.getText());
int years = Integer.parseInt(numberYearsField.getText());
double futureValue = Calculator.calculateFutureValue(investment, interest, years);
NumberFormat currency = NumberFormat.getCurrencyInstance();
futureValueField.setText(currency.format(futureValue));
} else {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setHeaderText("Invalid Data");
alert.setContentText(errorMsg);
alert.showAndWait();
}
}//end of the calculateButtonClicked Method
@FXML
protected void terminateButtonClicked() {
Platform.exit();
}//end of the terminatedButtonClicked Method
public void resetButtonClicked() {
investmentField.setText("");
interestRateField.setText("");
numberYearsField.setText("");
futureValueField.setText("");
}//end of the resetButtonClicked Method
}//end of the Controller Class
| 2,100 | 0.696667 | 0.696667 | 61 | 33.426231 | 26.80987 | 95 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.622951 | false | false | 3 |
bfbab1916ba845df7ec7b51ba762eddc4e9826cc | 28,252,294,873,390 | 1225d8b81eb2af80f8c703042283dda03ffae566 | /src/programming/Minesweeper.java | 5719a1d7fd2e87c4790e8e60f855e3c53910bf67 | [] | no_license | enosent/algorithms | https://github.com/enosent/algorithms | 8e714db6adca9fd6619b8aa33d1fd74364a27366 | ef097d59bfa097ae54949343aa4addd11c4a1e5c | refs/heads/master | 2016-09-06T18:30:54.168000 | 2014-01-12T11:03:17 | 2014-01-12T11:03:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package programming;
public class Minesweeper {
public String[][] minesweeper(int m, int n, String[][] input){
String[][] mine = input;
String[][] sweeper = new String[m][n];
// init
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if("*".equals(mine[i][j])){
sweeper[i][j] = "*";
}else{
sweeper[i][j] = "0";
}
}
}
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if("*".equals(sweeper[i][j])){
if(i-1 >= 0){
this.increase(i-1, j, n, sweeper);
}
if((j-1) >= 0 && !"*".equals(sweeper[i][j-1])){
sweeper[i][j-1] = String.valueOf(Integer.parseInt(sweeper[i][j-1]) + 1);
}
if((j+1) < n && !"*".equals(sweeper[i][j+1])){
sweeper[i][j+1] = String.valueOf(Integer.parseInt(sweeper[i][j+1]) + 1);
}
if(i+1 < m){
this.increase(i+1, j, n, sweeper);
}
}
}
}
return sweeper;
}
private void increase(int i, int j, int n, String[][] sweeper){
if((j-1) >= 0 && !"*".equals(sweeper[i][j-1])){
sweeper[i][j-1] = String.valueOf(Integer.parseInt(sweeper[i][j-1]) + 1);
}
if(!"*".equals(sweeper[i][j])){
sweeper[i][j] = String.valueOf(Integer.parseInt(sweeper[i][j]) + 1);
}
if((j+1) < n && !"*".equals(sweeper[i][j+1])){
sweeper[i][j+1] = String.valueOf(Integer.parseInt(sweeper[i][j+1]) + 1);
}
}
}
| UTF-8 | Java | 1,806 | java | Minesweeper.java | Java | [] | null | [] | package programming;
public class Minesweeper {
public String[][] minesweeper(int m, int n, String[][] input){
String[][] mine = input;
String[][] sweeper = new String[m][n];
// init
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if("*".equals(mine[i][j])){
sweeper[i][j] = "*";
}else{
sweeper[i][j] = "0";
}
}
}
for(int i = 0; i < m; i++){
for(int j = 0; j < n; j++){
if("*".equals(sweeper[i][j])){
if(i-1 >= 0){
this.increase(i-1, j, n, sweeper);
}
if((j-1) >= 0 && !"*".equals(sweeper[i][j-1])){
sweeper[i][j-1] = String.valueOf(Integer.parseInt(sweeper[i][j-1]) + 1);
}
if((j+1) < n && !"*".equals(sweeper[i][j+1])){
sweeper[i][j+1] = String.valueOf(Integer.parseInt(sweeper[i][j+1]) + 1);
}
if(i+1 < m){
this.increase(i+1, j, n, sweeper);
}
}
}
}
return sweeper;
}
private void increase(int i, int j, int n, String[][] sweeper){
if((j-1) >= 0 && !"*".equals(sweeper[i][j-1])){
sweeper[i][j-1] = String.valueOf(Integer.parseInt(sweeper[i][j-1]) + 1);
}
if(!"*".equals(sweeper[i][j])){
sweeper[i][j] = String.valueOf(Integer.parseInt(sweeper[i][j]) + 1);
}
if((j+1) < n && !"*".equals(sweeper[i][j+1])){
sweeper[i][j+1] = String.valueOf(Integer.parseInt(sweeper[i][j+1]) + 1);
}
}
}
| 1,806 | 0.376523 | 0.35825 | 54 | 32.148148 | 26.657921 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.592593 | false | false | 3 |
d74eb68ff1603896561ef5c2a3630713ace30d4a | 1,743,756,746,061 | 9da81bb4ac5cd41155466bda90e2c356eeaa8dae | /src/main/java/br/com/sysfit/http/Pessoa.java | 444ca6e03ee63794fff5a3c56ec36cd67328289c | [] | no_license | PabloBarbosa/Sysfit-Server | https://github.com/PabloBarbosa/Sysfit-Server | f28efff1bb343080370fb963a9d1bade00e94a13 | d21765bc3eef3e564905d7b58644de2be0d30d60 | refs/heads/master | 2021-01-20T17:40:14.656000 | 2017-05-17T17:21:12 | 2017-05-17T17:21:12 | 90,882,654 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.sysfit.http;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Pessoa {
private Long id;
private String nmPessoa;
private Long nuCPF;
private String sexo;
private Long nuMatricula;
private String descricao;
private String nmApelido;
private List<Perfil> perfil;
public Pessoa(){
}
public Pessoa(Long id, String nmPessoa, Long nuCPF, String sexo,
Long nuMatricula, String descricao, String nmApelido,
List<Perfil> perfil) {
super();
this.id = id;
this.nmPessoa = nmPessoa;
this.nuCPF = nuCPF;
this.sexo = sexo;
this.nuMatricula = nuMatricula;
this.descricao = descricao;
this.nmApelido = nmApelido;
this.perfil = perfil;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNmPessoa() {
return nmPessoa;
}
public void setNmPessoa(String nmPessoa) {
this.nmPessoa = nmPessoa;
}
public Long getNuCPF() {
return nuCPF;
}
public void setNuCPF(Long nuCPF) {
this.nuCPF = nuCPF;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public Long getNuMatricula() {
return nuMatricula;
}
public void setNuMatricula(Long nuMatricula) {
this.nuMatricula = nuMatricula;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public String getNmApelido() {
return nmApelido;
}
public void setNmApelido(String nmApelido) {
this.nmApelido = nmApelido;
}
public List<Perfil> getPerfil() {
return perfil;
}
public void setPerfil(List<Perfil> perfil) {
this.perfil = perfil;
}
} | UTF-8 | Java | 1,827 | java | Pessoa.java | Java | [] | null | [] | package br.com.sysfit.http;
import java.util.List;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Pessoa {
private Long id;
private String nmPessoa;
private Long nuCPF;
private String sexo;
private Long nuMatricula;
private String descricao;
private String nmApelido;
private List<Perfil> perfil;
public Pessoa(){
}
public Pessoa(Long id, String nmPessoa, Long nuCPF, String sexo,
Long nuMatricula, String descricao, String nmApelido,
List<Perfil> perfil) {
super();
this.id = id;
this.nmPessoa = nmPessoa;
this.nuCPF = nuCPF;
this.sexo = sexo;
this.nuMatricula = nuMatricula;
this.descricao = descricao;
this.nmApelido = nmApelido;
this.perfil = perfil;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getNmPessoa() {
return nmPessoa;
}
public void setNmPessoa(String nmPessoa) {
this.nmPessoa = nmPessoa;
}
public Long getNuCPF() {
return nuCPF;
}
public void setNuCPF(Long nuCPF) {
this.nuCPF = nuCPF;
}
public String getSexo() {
return sexo;
}
public void setSexo(String sexo) {
this.sexo = sexo;
}
public Long getNuMatricula() {
return nuMatricula;
}
public void setNuMatricula(Long nuMatricula) {
this.nuMatricula = nuMatricula;
}
public String getDescricao() {
return descricao;
}
public void setDescricao(String descricao) {
this.descricao = descricao;
}
public String getNmApelido() {
return nmApelido;
}
public void setNmApelido(String nmApelido) {
this.nmApelido = nmApelido;
}
public List<Perfil> getPerfil() {
return perfil;
}
public void setPerfil(List<Perfil> perfil) {
this.perfil = perfil;
}
} | 1,827 | 0.662288 | 0.662288 | 104 | 15.586538 | 15.370808 | 65 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.423077 | false | false | 3 |
d4637d37d000fd43440543987e95faa346236706 | 31,516,470,039,909 | 9d64b8b98f757b0285624af1ea5acccd558c4d05 | /mytest/src/main/java/com/example/demo/service/IUserService.java | 550a4035e84f1a751e2797ed0ca56f4ce8916526 | [] | no_license | Dokaka/java_team_homework | https://github.com/Dokaka/java_team_homework | 298d189667a6603048c1ee7d1c258eda6c4dce5b | 05cd60fce69b3eca922d0455116e7ca65e86212d | refs/heads/master | 2020-12-01T18:22:55.995000 | 2019-12-29T09:08:27 | 2019-12-29T09:08:27 | 230,726,493 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.demo.service;
import com.example.demo.dto.UserDTO;
import com.example.demo.entity.UserEntity;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface IUserService {
public List<UserDTO> getAllUsers();
}
| UTF-8 | Java | 270 | java | IUserService.java | Java | [] | null | [] | package com.example.demo.service;
import com.example.demo.dto.UserDTO;
import com.example.demo.entity.UserEntity;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public interface IUserService {
public List<UserDTO> getAllUsers();
}
| 270 | 0.796296 | 0.796296 | 12 | 21.5 | 17.675312 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 3 |
f50f2037ae4a4f772d037d578710abe6e5710215 | 32,229,434,659,600 | 0946ef55152086b2abeb90799310f71f05fcd978 | /Lesson4/src/by/epam/jb25/home/Task3.java | 9c1121d18f1a760a1163357689512717f35e876f | [] | no_license | VolhaDubovik/HomeTasks4 | https://github.com/VolhaDubovik/HomeTasks4 | 57801226bc4f4918071e6e284c797ab05435bb30 | ca6f4a85ebf97eb8f6036a1984097be00e34e17c | refs/heads/master | 2020-03-21T00:37:07.171000 | 2018-06-19T14:23:26 | 2018-06-19T14:23:26 | 137,901,593 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package by.epam.jb25.home;
import java.util.Random;
import java.util.Scanner;
public class Task3 {
public static int [] mas;
public static void main (String[] args) {
mas = new int [10];
enterArrayFromConsole(mas);
printArray(mas);
isAscending (mas);
System.out.println (isAscending(mas));
}
public static void enterArrayFromConsole(int[] mas) {
Scanner sc = new Scanner(System.in);
for (int i = 0; i < mas.length; i++) {
System.out.print("ar[" + i + "]=>");
mas[i] = sc.nextInt();
}
}
public static void printArray(int[] mas) {
System.out.println("--------------------------------------------");
for (int i = 0; i < mas.length; i++) {
System.out.print("mas[" + i + "]=" + mas[i] + "; ");
}
System.out.println();
System.out.println("--------------------------------------------");
}
public static String isAscending(int[] mas) {
for (int i = 1; i < mas.length; i++) {
if (mas[i] < mas[i - 1]) {
return "Массив не возрастает";
}
}
return "Массив возрастает";
}
}
| UTF-8 | Java | 1,195 | java | Task3.java | Java | [] | null | [] | package by.epam.jb25.home;
import java.util.Random;
import java.util.Scanner;
public class Task3 {
public static int [] mas;
public static void main (String[] args) {
mas = new int [10];
enterArrayFromConsole(mas);
printArray(mas);
isAscending (mas);
System.out.println (isAscending(mas));
}
public static void enterArrayFromConsole(int[] mas) {
Scanner sc = new Scanner(System.in);
for (int i = 0; i < mas.length; i++) {
System.out.print("ar[" + i + "]=>");
mas[i] = sc.nextInt();
}
}
public static void printArray(int[] mas) {
System.out.println("--------------------------------------------");
for (int i = 0; i < mas.length; i++) {
System.out.print("mas[" + i + "]=" + mas[i] + "; ");
}
System.out.println();
System.out.println("--------------------------------------------");
}
public static String isAscending(int[] mas) {
for (int i = 1; i < mas.length; i++) {
if (mas[i] < mas[i - 1]) {
return "Массив не возрастает";
}
}
return "Массив возрастает";
}
}
| 1,195 | 0.490095 | 0.482343 | 48 | 22.104166 | 20.027315 | 69 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.8125 | false | false | 3 |
4619982a1a5182c7deb026fa907ea3b59d51bc36 | 29,618,094,476,982 | 9b426438b74983f3b38f11dc9baa6c160778b7e8 | /ProjectOOP/src/Model/Process/GroupTopRubberVol.java | 9f3fade1850529d3f9a6a1eb667d9751fd44db7d | [] | no_license | Toan1251/ProjectOOP | https://github.com/Toan1251/ProjectOOP | 4209d14fdc7a1d73041e72ae4a9a05422753dd41 | 05f17e0623586bbf1f33016251a284740f389561 | refs/heads/main | 2023-02-03T08:50:38.997000 | 2020-12-21T17:42:48 | 2020-12-21T17:42:48 | 310,890,982 | 0 | 6 | null | false | 2020-12-21T10:27:33 | 2020-11-07T16:56:02 | 2020-12-21T10:24:41 | 2020-12-21T10:24:39 | 1,011 | 0 | 4 | 3 | Java | false | false | package ProjectOOP.src.Model.Process;
import ProjectOOP.src.Model.Handle.DataOutput;
import java.util.List;
public class GroupTopRubberVol extends Group {
//override lại phương thức để lấy value ứng với key
@Override
public String replaceVariable(String key) {
return this.eachMap.get(key);
}
@Override
public String begin(List<DataOutput> data) {
//thêm câu vào list sentences chung chờ xử lí
addGroupSentences("Ở nhóm cao su, <CVname1> có mức thanh khoản tốt nhất, với <CVnum1> cổ phiếu được bán trên tổng số <totalC> của cả ngành, chiếm tỷ lệ <timeC1>%, sau đó là <CVname2> khi bán được <timeC2>%, tương ứng với <CVnum2> cổ phiếu.");
addGroupSentences("Riêng nhóm cao su,với tổng <totalC> cổ phiếu được bán, <CVname1> đang dẫn đầu khi bán được <CVnum1> cổ phiếu, ngay sau đó là <CVname2> với <CVnum2> cổ phiếu được bán.");
// phương thức dùng để tạo 1 map chứa các giá trị cần thay và tên biến tương ứng.
this.eachMap = (new RuleRubber()).PushInMap(data);
//phương thức xử lí và đưa câu đã lựa chọn vào list chung để phục vụ việc tạo đoạn văn sau này
return getOutput();
}
}
//top lượng cổ phiếu bán ra ở nhóm cao su. | UTF-8 | Java | 1,416 | java | GroupTopRubberVol.java | Java | [] | null | [] | package ProjectOOP.src.Model.Process;
import ProjectOOP.src.Model.Handle.DataOutput;
import java.util.List;
public class GroupTopRubberVol extends Group {
//override lại phương thức để lấy value ứng với key
@Override
public String replaceVariable(String key) {
return this.eachMap.get(key);
}
@Override
public String begin(List<DataOutput> data) {
//thêm câu vào list sentences chung chờ xử lí
addGroupSentences("Ở nhóm cao su, <CVname1> có mức thanh khoản tốt nhất, với <CVnum1> cổ phiếu được bán trên tổng số <totalC> của cả ngành, chiếm tỷ lệ <timeC1>%, sau đó là <CVname2> khi bán được <timeC2>%, tương ứng với <CVnum2> cổ phiếu.");
addGroupSentences("Riêng nhóm cao su,với tổng <totalC> cổ phiếu được bán, <CVname1> đang dẫn đầu khi bán được <CVnum1> cổ phiếu, ngay sau đó là <CVname2> với <CVnum2> cổ phiếu được bán.");
// phương thức dùng để tạo 1 map chứa các giá trị cần thay và tên biến tương ứng.
this.eachMap = (new RuleRubber()).PushInMap(data);
//phương thức xử lí và đưa câu đã lựa chọn vào list chung để phục vụ việc tạo đoạn văn sau này
return getOutput();
}
}
//top lượng cổ phiếu bán ra ở nhóm cao su. | 1,416 | 0.68878 | 0.679771 | 30 | 39.733334 | 56.546696 | 250 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.533333 | false | false | 3 |
a6e1e679b649f08a07d79980b3596f8ab309c347 | 25,082,609,023,641 | 343214ead5b2531e75bc92cd0a6f5cb19367c923 | /src/behavioral/template/WelcomePage.java | 35020b4de6f2ba1041289bf3c4337b7cc8ab7994 | [] | no_license | obi1kenoby/OOP-Patterns | https://github.com/obi1kenoby/OOP-Patterns | 63650f49407357e751e43f97bba27489ce3ff6bf | db4f16394ce4e7a0a32c725c1dc60949c2eef94d | refs/heads/master | 2021-01-21T20:07:38.590000 | 2018-11-18T14:37:13 | 2018-11-18T14:37:13 | 92,193,650 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package behavioral.template;
public class WelcomePage extends WebSitePage{
@Override
public void body() {
System.out.println("show welcome");
}
}
| UTF-8 | Java | 169 | java | WelcomePage.java | Java | [] | null | [] | package behavioral.template;
public class WelcomePage extends WebSitePage{
@Override
public void body() {
System.out.println("show welcome");
}
}
| 169 | 0.674556 | 0.674556 | 10 | 15.9 | 17.032028 | 45 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 3 |
4a9d544fa9d83392794164fea7abeaed3b47bfdc | 1,271,310,334,971 | b287e4b20aa363e07d2b4399e156b4730fe5ba2c | /L2/E1/src/lp2g17/biblioteca/EmprestadoPara.java | 03be1ff125eadb34e7d8d6351757c3c092e238f8 | [] | no_license | munirwanis/LP2 | https://github.com/munirwanis/LP2 | 55204928d91d02f671654c0098d7e3a4743b1d56 | 21e9e4bc211f16c6170a4b9e27b3e7f65ba37d25 | refs/heads/master | 2021-01-10T06:54:11.659000 | 2015-12-05T20:12:45 | 2015-12-05T20:12:45 | 44,253,361 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lp2g17.biblioteca;
import java.util.GregorianCalendar;
/**
*
* @author munir
*/
public class EmprestadoPara {
private GregorianCalendar dataEmprestimo;
private GregorianCalendar dataDevolucao;
private int codigoUsuario;
public EmprestadoPara(GregorianCalendar dataEmprestimo, GregorianCalendar dataDevolucao, int codigoUsuario) {
this.dataEmprestimo = dataEmprestimo;
this.dataDevolucao = dataDevolucao;
this.codigoUsuario = codigoUsuario;
}
public GregorianCalendar getDataEmprestimo() {
return dataEmprestimo;
}
public GregorianCalendar getDataDevolucao() {
return dataDevolucao;
}
public int getCodigoUsuario() {
return codigoUsuario;
}
}
| UTF-8 | Java | 946 | java | EmprestadoPara.java | Java | [
{
"context": "rt java.util.GregorianCalendar;\n\n/**\n *\n * @author munir\n */\npublic class EmprestadoPara {\n private Gre",
"end": 273,
"score": 0.9992557168006897,
"start": 268,
"tag": "USERNAME",
"value": "munir"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package lp2g17.biblioteca;
import java.util.GregorianCalendar;
/**
*
* @author munir
*/
public class EmprestadoPara {
private GregorianCalendar dataEmprestimo;
private GregorianCalendar dataDevolucao;
private int codigoUsuario;
public EmprestadoPara(GregorianCalendar dataEmprestimo, GregorianCalendar dataDevolucao, int codigoUsuario) {
this.dataEmprestimo = dataEmprestimo;
this.dataDevolucao = dataDevolucao;
this.codigoUsuario = codigoUsuario;
}
public GregorianCalendar getDataEmprestimo() {
return dataEmprestimo;
}
public GregorianCalendar getDataDevolucao() {
return dataDevolucao;
}
public int getCodigoUsuario() {
return codigoUsuario;
}
}
| 946 | 0.714588 | 0.711416 | 38 | 23.894737 | 25.413206 | 113 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.421053 | false | false | 3 |
208d2c117005dd86869d8138f86e93dd3a7237f1 | 9,500,467,726,716 | ae15eb6c8f1c389fb68580f8f782ebea7d877173 | /HB-JoinUnAssociatedEntities/src/main/java/com/rs/app/JoinTest.java | 8a99b8a7a96b5a7ea0a0f619294501841154ab6d | [] | no_license | Git-Ramesh/Hibernate5.x | https://github.com/Git-Ramesh/Hibernate5.x | 15a7d61e5e5fd9626cbcb20b214e8251d3b53756 | d87b4b658f716767e5b60c3debc1cf8d05a92678 | refs/heads/master | 2020-04-24T09:14:27.402000 | 2020-01-20T09:21:21 | 2020-01-20T09:21:21 | 171,856,383 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* com.rs.app.JoinTest.java Dec 21, 2018
*
* © Radiant Sage.
* Manjeera Trinity Corporate, Plot No. 912,K P H B Phase 3, Kukatpally, Hyderabad, Telangana 500072,INDIA.
* All rights reserved.
*
* This software is the confidential and proprietary information of
* Radiant Sage . ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Radiant Sage.
*/
package com.rs.app;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import com.rs.app.util.HibernateUtil;
/**
* @author Ramesh
* @version 1.0
* @since 2018-12-21 16:45:12.731
*/
//Introduced in 5.1
public class JoinTest {
public static void main(String[] args) {
final String CROSS_JOIN_QUERY = "SELECT e.id, e.empNo,e.email, d.id, d.deptNo, d.location from Employee e, Department d WHERE d.deptNo = e.deptNo";
final String JOIN_QUERY1 = "SELECT e.id, e.empNo,e.email, d.id, d.deptNo, d.location from Employee e JOIN Department d ON d.deptNo = e.deptNo";
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
try (Session session = sessionFactory.openSession()) {
//Query<Object[]> query = session.createQuery(CROSS_JOIN_QUERY);
Query<Object[]> query = session.createQuery(JOIN_QUERY1);
List<Object[]> results = query.getResultList();
for (Object[] result : results) {
for (Object obj : result) {
System.out.print(obj + " ");
}
System.out.print("\n");
}
} catch (HibernateException hex) {
hex.printStackTrace();
} finally {
HibernateUtil.closeSessionFactory(sessionFactory);
}
}
}
| UTF-8 | Java | 1,783 | java | JoinTest.java | Java | [
{
"context": "ort com.rs.app.util.HibernateUtil;\n\n/**\n * @author Ramesh\n * @version 1.0\n * @since 2018-12-21 16:45:12.731",
"end": 754,
"score": 0.9998008608818054,
"start": 748,
"tag": "NAME",
"value": "Ramesh"
}
] | null | [] | /*
* com.rs.app.JoinTest.java Dec 21, 2018
*
* © Radiant Sage.
* Manjeera Trinity Corporate, Plot No. 912,K P H B Phase 3, Kukatpally, Hyderabad, Telangana 500072,INDIA.
* All rights reserved.
*
* This software is the confidential and proprietary information of
* Radiant Sage . ("Confidential Information"). You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with Radiant Sage.
*/
package com.rs.app;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.query.Query;
import com.rs.app.util.HibernateUtil;
/**
* @author Ramesh
* @version 1.0
* @since 2018-12-21 16:45:12.731
*/
//Introduced in 5.1
public class JoinTest {
public static void main(String[] args) {
final String CROSS_JOIN_QUERY = "SELECT e.id, e.empNo,e.email, d.id, d.deptNo, d.location from Employee e, Department d WHERE d.deptNo = e.deptNo";
final String JOIN_QUERY1 = "SELECT e.id, e.empNo,e.email, d.id, d.deptNo, d.location from Employee e JOIN Department d ON d.deptNo = e.deptNo";
SessionFactory sessionFactory = HibernateUtil.getSessionFactory();
try (Session session = sessionFactory.openSession()) {
//Query<Object[]> query = session.createQuery(CROSS_JOIN_QUERY);
Query<Object[]> query = session.createQuery(JOIN_QUERY1);
List<Object[]> results = query.getResultList();
for (Object[] result : results) {
for (Object obj : result) {
System.out.print(obj + " ");
}
System.out.print("\n");
}
} catch (HibernateException hex) {
hex.printStackTrace();
} finally {
HibernateUtil.closeSessionFactory(sessionFactory);
}
}
}
| 1,783 | 0.710438 | 0.688552 | 54 | 32 | 33.222038 | 149 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.648148 | false | false | 3 |
348c298e075198274240ac7400f7e82e299e0a09 | 24,927,990,252,883 | 0086175ca7a35f4906fb7c6db1fb1929ed195834 | /open-web/src/main/java/com.xulihuazj.cssp.web/action/LogoutAction.java | 1b175dee4993db0686716b1b86f42cd020680b70 | [] | no_license | xulihuazj/open | https://github.com/xulihuazj/open | 068092a4b1bf09056c72b95e22ee439c3f412f04 | e059aaf3bc978822295f5c3b22e8e329ba7865dd | refs/heads/master | 2021-01-21T20:46:32.382000 | 2017-05-25T08:01:59 | 2017-05-25T08:01:59 | 92,276,829 | 4 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.xulihuazj.cssp.web.action;
public class LogoutAction {
}
| UTF-8 | Java | 71 | java | LogoutAction.java | Java | [] | null | [] | package com.xulihuazj.cssp.web.action;
public class LogoutAction {
}
| 71 | 0.774648 | 0.774648 | 5 | 13.2 | 16.14187 | 38 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.2 | false | false | 3 |
58d5f3a0075f62e0f9408cc73e16f1143cd48453 | 27,358,941,742,814 | 9ed3ceed7beb8f68b903024313edf9f31fc46b06 | /src/main/java/Exercer03/Vetor015.java | bd2be398c038dcc97a5991f40a1ff483ec0f9bff | [] | no_license | Liudimilla/R-vision | https://github.com/Liudimilla/R-vision | fae42313cdf952db5291fc13c407d4d2d14d0e8d | c6d6a98a610790e6e7e3192f0944b321eccac5df | refs/heads/main | 2023-07-05T22:43:12.389000 | 2021-08-09T02:44:47 | 2021-08-09T02:44:47 | 375,879,045 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /* Questao 19.15; Criar um vetor A com 10 elementos inteiros. Desenvolver um programa que defina
o percentual de elementos pares e ímpares, respectivamente, armazenados neste vetor
*/
package Exercer03;
import java.util.Scanner;
public class Vetor015 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] vetorA = new int[10];
for (int i=0; i<vetorA.length; i++) {
System.out.println("Entre com o valor da posiçao " +1);
vetorA[i] = scan.nextInt();
}
int impar = 0;
for (int i=0; i<vetorA.length; i++) {
if (vetorA[i] % 2 != 0) {
impar++;
}
}
int par = vetorA.length - impar;
//vetorA.length - 100%
//par - x
//= x*vetorA.length == par * 100
//= x == (par * 100)/vetorA.length
double porPar = (par * 100)/vetorA.length;
double porImpar = 100 - porPar;
System.out.println("Vetor A = ");
for (int i=0; i<vetorA.length; i++) {
System.out.println(vetorA[i] + " ");
}
System.out.println();
System.out.println("Porcentagem Pares: "+porPar);
System.out.println("Porcentagem Pares: "+porImpar);
}
}
| UTF-8 | Java | 1,284 | java | Vetor015.java | Java | [] | null | [] | /* Questao 19.15; Criar um vetor A com 10 elementos inteiros. Desenvolver um programa que defina
o percentual de elementos pares e ímpares, respectivamente, armazenados neste vetor
*/
package Exercer03;
import java.util.Scanner;
public class Vetor015 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] vetorA = new int[10];
for (int i=0; i<vetorA.length; i++) {
System.out.println("Entre com o valor da posiçao " +1);
vetorA[i] = scan.nextInt();
}
int impar = 0;
for (int i=0; i<vetorA.length; i++) {
if (vetorA[i] % 2 != 0) {
impar++;
}
}
int par = vetorA.length - impar;
//vetorA.length - 100%
//par - x
//= x*vetorA.length == par * 100
//= x == (par * 100)/vetorA.length
double porPar = (par * 100)/vetorA.length;
double porImpar = 100 - porPar;
System.out.println("Vetor A = ");
for (int i=0; i<vetorA.length; i++) {
System.out.println(vetorA[i] + " ");
}
System.out.println();
System.out.println("Porcentagem Pares: "+porPar);
System.out.println("Porcentagem Pares: "+porImpar);
}
}
| 1,284 | 0.546022 | 0.518721 | 44 | 28.136364 | 23.812326 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.568182 | false | false | 3 |
37f42a7b521e1784729861cb376a6e4a65a56f8f | 24,541,443,158,944 | b3418633bf03a546a5254ea422e40de17489980c | /src/main/java/com/fhd/icm/web/controller/statics/IcmMyDatasControl.java | 18a87be6fc86d15632e6978c6180fec1a3586419 | [] | no_license | vincent-dixin/Financial-Street-ERMIS | https://github.com/vincent-dixin/Financial-Street-ERMIS | d819fd319293e55578e3067c9a5de0cd33c56a93 | 87d6bc6a4ddc52abca2c341eb476c1ea283d70e7 | refs/heads/master | 2016-09-06T13:56:46.197000 | 2015-03-30T02:47:46 | 2015-03-30T02:47:46 | 33,099,786 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.fhd.icm.web.controller.statics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fhd.core.utils.DateUtils;
import com.fhd.core.utils.Identities;
import com.fhd.icm.business.statics.IcmMyDatasBO;
/**
* 内控我的数据(包括 我的流程 我的风险 我的制度 我的标准 我的控制措施 我的任务)
* @author 邓广义
* @date 2013-5-15
* @since fhd Ver 1.1
*/
@Controller
public class IcmMyDatasControl {
@Autowired
private IcmMyDatasBO o_icmMyDatasBO;
/**
* <pre>
* 流程统计情况
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或公司
* @param limit 页容量
* @param start 起始值
* @param pagable 是否更多页面
* @param query 查询条件:流程编号或流程名称
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findprocessbysome.f")
public Map<String,Object> findProcessBySome(String orgId, String query, String start, String limit, String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("processCode".equals(property)){
sortDirection.append("p.PROCESSURE_CODE ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("p.LAST_MODIFY_TIME ").append(direction).append(", p.CREATE_TIME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("empName".equals(property)){
sortDirection.append("e.EMP_NAME ").append(direction);
}else if("frequency".equals(property)){
sortDirection.append("p.PROCESS_CLASS ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("pp.PROCESSURE_NAME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findProcessBySome(result, orgId, query, start, limit, sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称(责任部门)
row.put("empId", null!=objects[2]?objects[2]:"");//员工ID
row.put("empName", null!=objects[3]?objects[3]:"");//员工姓名(责任人)
row.put("parentName", null!=objects[4]?objects[4]:"");//流程分类名称
row.put("frequency", null!=objects[11]?objects[11]:"");//发生频率
row.put("processCode", null!=objects[6]?objects[6]:"");//流程编号
row.put("processName", null!=objects[7]?objects[7]:"");//流程名称
row.put("id", null!=objects[8]?objects[8]:"");//流程ID
String updateDate = "";
if(null != objects[10]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[10]).substring(0,String.valueOf(objects[10]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[9]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[9]).substring(0,String.valueOf(objects[9]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* 我的控制措施
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/icmmycontroldatas.f")
public Map<String,Object> findMyControlDatasByOrgId(String orgid,String limit,String start,boolean pagable,String query){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
/*List<Object[]> objects = o_icmMyDatasBO.findMyControlDatasByOrgId(result,orgid,limit,query,start);
if(!pagable){//每个小块儿中的gird传送limit参数
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("code", null!=o[2]?o[2]:"");
row.put("name", null!=o[3]?o[3]:"");
datas.add(row);
}
}else{ //点击更多 无参数 显示所有
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("risk", null!=o[1]?this.o_riskBO.findRiskById((String)o[1]).getName():"");//所属风险
row.put("code", o[2]);
row.put("name", o[3]);
row.put("controlMode", null!=o[4]?this.o_dictBO.findDictEntryById((String)o[4]).getName():"");//控制方式
row.put("isKeyPoint", null!=o[5]?"0yn_n".equals(o[5])?"否":"是":"");//是否关键控制点
datas.add(row);
}
}*/
result.put("datas", datas);
return result;
}
/**
* 我的风险 “风险水平”???
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/findriskbysome.f")
public Map<String,Object> findRiskBySome(String orgId,String limit,String start,String query,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("riskCode".equals(property)){
sortDirection.append("r.RISK_CODE ").append(direction);
}else if("riskName".equals(property)){
sortDirection.append("r.RISK_NAME ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("pr.RISK_NAME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("r.LAST_MODIFY_TIME ").append(direction).append(", r.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findRiskBySome(result, orgId, query, start, limit, sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", null!=objects[0]?objects[0]:"");
row.put("riskCode", null!=objects[1]?objects[1]:"");//要求编号
row.put("riskName", null!=objects[2]?objects[2]:"");//要求名称
row.put("parentId", null!=objects[3]?objects[3]:"");//内控标准ID
row.put("parentName", null!=objects[4]?objects[4]:"");//内控标准名称
row.put("orgId", null!=objects[5]?objects[5]:"");//机构ID
row.put("orgName", null!=objects[6]?objects[6]:"");//机构名称
String updateDate = "";
if(null != objects[8]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[8]).substring(0,String.valueOf(objects[8]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[7]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[7]).substring(0,String.valueOf(objects[7]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询内控要求信息
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @param limit 页面显示记录数
* @param start 开始数
* @param query 查询条件
* @param sort 排序
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findstandardbysome.f")
public Map<String,Object> findStandardBySome(String orgId,String limit,String start,String query,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("standardCode".equals(property)){
sortDirection.append("s.STANDARD_CODE ").append(direction);
}else if("standardName".equals(property)){
sortDirection.append("s.STANDARD_NAME ").append(direction);
}else if("controlLevel".equals(property)){
sortDirection.append("e1.DICT_ENTRY_NAME ").append(direction);
}else if("controlPoint".equals(property)){
sortDirection.append("e2.DICT_ENTRY_NAME ").append(direction);
}else if("dealStatus".equals(property)){
sortDirection.append("e3.DICT_ENTRY_NAME ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("ps.STANDARD_NAME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("s.LAST_MODIFY_TIME ").append(direction).append(", s.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findStandardBySome(result,orgId,query,start,limit,sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", null!=objects[0]?objects[0]:"");
row.put("standardCode", null!=objects[1]?objects[1]:"");//要求编号
row.put("standardName", null!=objects[2]?objects[2]:"");//要求名称
row.put("controlLevel", null!=objects[4]?objects[4]:"");//控制层级中文
row.put("controlPoint", null!=objects[6]?objects[6]:"");//控制要素中文
row.put("dealStatus", null!=objects[8]?objects[8]:"");//处理状态中文
row.put("parentId", null!=objects[9]?objects[9]:"");//内控标准ID
row.put("parentName", null!=objects[10]?objects[10]:"");//内控标准名称
row.put("orgId", null!=objects[11]?objects[11]:"");//机构ID
row.put("orgName", null!=objects[12]?objects[12]:"");//机构名称
String updateDate = "";
if(null != objects[14]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[14]).substring(0,String.valueOf(objects[14]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[13]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[13]).substring(0,String.valueOf(objects[13]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计内控要求的数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findstandardcountbysome.f")
public Map<String,Object> findStandardCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findStandardCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("parentId", null!=objects[2]?objects[2]:"");//内控标准ID
row.put("parentName", null!=objects[3]?objects[3]:"");//内控标准名称
row.put("dealStatus", null!=objects[5]?objects[5]:"");//处理状态
row.put("controlPoint", null!=objects[7]?objects[7]:"");//控制要素
row.put("controlLevel", null!=objects[9]?objects[9]:"");//控制层级
row.put("createYear", null!=objects[10]?objects[10]:"");//控制层级
row.put("standardCount", objects[11]);//内控要求数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* 我的制度 :制度分类 制度编号 制度名称 责任部门
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/icmmyinstitutiondatas.f")
public Map<String,Object> findMyInstitutionDatasByOrgId(String orgid,String limit,String start,boolean pagable,String query){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
/*List<Object[]> objects = o_icmMyDatasBO.findMyInstitutionDatasByOrgId(result,orgid,limit,query,start);
if(!pagable){//每个小块儿中的gird传送limit参数
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("code", o[2]);
row.put("name", o[3]);
datas.add(row);
}
}else{
for(Object[] o: objects){//更多
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("classify", null!=o[1]?this.o_ruleBO.findRuleByRuleId(o[1].toString()).getName():"");//分类
row.put("code", o[2]);
row.put("name", o[3]);
row.put("org", null!=o[4]?this.o_organizationBO.getRootOrgByCompanyId(o[4].toString()).getOrgname():"");
datas.add(row);
}
}*/
result.put("datas", datas);
return result;
}
/**
* 判断当前登录人是否为内控部门员工
* @param empid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/judgeificmdept.f")
public boolean judgeIfIcmDept(){
return this.o_icmMyDatasBO.judgeIfIcmDept();
}
/**
* <pre>
* 统计缺陷数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或
* @param planId 评价计划ID
* @param iPlanId 整改计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/finddefectcountbysome.f")
public Map<String,Object> findDefectCountBySome(String orgId, String planId, String iPlanId, String processId, String processPointId, String measureId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findDefectCountBySome(orgId, planId, iPlanId, processId, processPointId, measureId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("planId", null!=objects[2]?objects[2]:"");//评价计划ID
row.put("planName", null!=objects[3]?objects[3]:"");//评价计划名称
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("dealStatus", null!=objects[12]?objects[12]:"");//整改状态
row.put("defectCount", objects[15]);//缺陷数量
row.put("defectLevel", null!=objects[16]?objects[16]:"");//缺陷等级
row.put("defectType", null!=objects[17]?objects[17]:"");//缺陷类型
row.put("createYear", null!=objects[18]?objects[18]:"");//年份
row.put("iPlanId", null!=objects[19]?objects[19]:"");//整改计划ID
row.put("iPlanName", null!=objects[20]?objects[20]:"");//整改计划名称
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询缺陷信息
* </pre>
*
* @author 张 雷
* @param orgId 机构ID
* @param query 查询条件
* @param planId 评价计划ID
* @param iPlanId 整改计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/finddefectbysome.f")
public Map<String,Object> findDefectBySome(String orgId, String query, String planId, String processId, String processPointId, String measureId,String limit,String start,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("planName".equals(property)){
sortDirection.append("plan.PLAN_NAME ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("processPointName".equals(property)){
sortDirection.append("c.CONTROL_POINT_NAME ").append(direction);
}else if("measureName".equals(property)){
sortDirection.append("m.MEASURE_NAME ").append(direction);
}else if("assessPointName".equals(property)){
sortDirection.append("ap.EDESC ").append(direction);
}else if("dealStatus".equals(property)){
sortDirection.append("d.DEAL_STATUS ").append(direction);
}else if("defectDesc".equals(property)){
sortDirection.append("d.EDESC ").append(direction);
}else if("defectLevel".equals(property)){
sortDirection.append("e1.DICT_ENTRY_NAME ").append(direction);
}else if("defectType".equals(property)){
sortDirection.append("e2.DICT_ENTRY_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("d.LAST_MODIFY_TIME ").append(direction).append(", d.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findDefectBySome(result,orgId, query, planId, processId, processPointId, measureId, start, limit, sortDirection.toString());
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("planId", null!=objects[2]?objects[2]:"");//评价计划ID
row.put("planName", null!=objects[3]?objects[3]:"");//评价计划名称
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("dealStatus", null!=objects[12]?objects[12]:"");//整改状态
row.put("id", objects[15]);//缺陷ID
row.put("defectDesc", null!=objects[16]?objects[16]:"");//缺陷描述
row.put("defectLevel", null!=objects[17]?objects[17]:"");//缺陷等级
row.put("defectType", null!=objects[18]?objects[18]:"");//缺陷类型
String updateDate = "";
if(null != objects[20]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[20]).substring(0,String.valueOf(objects[20]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[19]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[19]).substring(0,String.valueOf(objects[19]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计评价结果的数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或公司
* @param planId 评价计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @param assessPointId 评价点ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessresultcountbysome.f")
public Map<String,Object> findAssessResultCountBySome(String orgId, String planId, String empId,
String processId, String processPointId, String measureId, String assessPointId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessResultCountBySome(orgId, planId, empId,
processId, processPointId, measureId, assessPointId);
Integer allCount = 0;
for (Object[] objects : objectList) {
allCount += Integer.valueOf(String.valueOf(objects[10]));
}
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("planId", null!=objects[0]?objects[0]:"");//评价计划ID
row.put("planName", null!=objects[1]?objects[1]:"");//评价计划名称
row.put("empId", null!=objects[2]?objects[2]:"");//员工ID
row.put("empName", null!=objects[3]?objects[3]:"");//员工姓名
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
/*row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
*/ row.put("assessMeasure", null!=objects[7]?objects[7]:"");//评价方式
row.put("isValid", null!=objects[8]?objects[8]:"");//是否合格
row.put("isFinished", null!=objects[9]?objects[9]:"");//是否完成
if(allCount!=0){
row.put("assessResultRate", (double)Integer.valueOf(String.valueOf(objects[10]))/allCount*100);//评价结果占比
}else{
row.put("assessResultRate", 0);//评价结果占比
}
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询评价结果的明细
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @param planId 评价计划ID
* @param empId 评价人ID
* @param processPointId 流程节点ID
* @param processId 流程ID
* @param measureId 控制措施ID
* @param assessPointId 评价点ID
* @param query 查询条件
* @param limit 限制数
* @param start 起始数
* @param sort 排序
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessresultbysome.f")
public Map<String,Object> findAssessResultBySome(String orgId, String planId, String empId, String processPointId,
String processId,String measureId, String assessPointId, String query, String limit,String start,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("planName".equals(property)){
sortDirection.append("plan.PLAN_NAME ").append(direction);
}else if("empName".equals(property)){
sortDirection.append("e.EMP_NAME ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("processPointName".equals(property)){
sortDirection.append("c.CONTROL_POINT_NAME ").append(direction);
}else if("measureName".equals(property)){
sortDirection.append("m.MEASURE_NAME ").append(direction);
}else if("assessPointName".equals(property)){
sortDirection.append("ap.EDESC ").append(direction);
}else if("assessMeasure".equals(property)){
sortDirection.append("r.ASSESSMENT_MEASURE ").append(direction);
}else if("isQualified".equals(property)){
sortDirection.append("CASE WHEN ")
.append("r.HAS_DEFECT_ADJUST IS NULL ")
.append("THEN ")
.append("(CASE WHEN r.HAS_DEFECT IS NULL THEN NULL ELSE (CASE WHEN r.HAS_DEFECT='0' THEN '不合格' ELSE '合格' END) END) ")
.append("ELSE ")
.append("(CASE WHEN r.HAS_DEFECT_ADJUST='0' THEN '不合格' ELSE '合格' END) ")
.append("END ").append(direction);
}else if("isDone".equals(property)){
sortDirection.append("CASE WHEN ")
.append("r.has_defect IS NOT NULL ")
.append("THEN ")
.append("'已完成' ")
.append("ELSE ")
.append("'未完成' ")
.append("END ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("plan.LAST_MODIFY_TIME ").append(direction).append(", plan.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessResultBySome(result, orgId, planId, empId, processId, processPointId, measureId, assessPointId, query, start, limit, sortDirection.toString());
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("planId", null!=objects[0]?objects[0]:"");//评价计划ID
row.put("planName", null!=objects[1]?objects[1]:"");//评价计划名称
row.put("empId", null!=objects[2]?objects[2]:"");//评价人ID
row.put("empName", null!=objects[3]?objects[3]:"");//评价人姓名
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("assessMeasure", null!=objects[13]?objects[13]:"");//评价方式
row.put("isQualified", null!=objects[14]?objects[14]:"");//样本合格状态
row.put("isDone", null!=objects[15]?objects[15]:"");//评价完成状态
String updateDate = "";
if(null != objects[17]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[17]).substring(0,String.valueOf(objects[17]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[16]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[16]).substring(0,String.valueOf(objects[16]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
row.put("sampleCount", null!=objects[18]?objects[18]:0);//样本数量
row.put("id", null!=objects[19]?objects[19]:"");//ID
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计评价计划的数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessplancountbysome.f")
public Map<String,Object> findAssessPlanCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessPlanCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("type", null!=objects[2]?objects[2]:"");//评价类型中文
row.put("dealStatus", null!=objects[3]?objects[3]:"");//处理状态
row.put("assessMeasure", null!=objects[5]?objects[5]:"");//评价方式中文
row.put("planCount", null!=objects[6]?objects[6]:"");//评价计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计整改计划数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findimprovecountbysome.f")
public Map<String,Object> findImproveCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findImproveCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("dealStatus", null!=objects[1]?objects[1]:"");//处理状态
row.put("planCount", null!=objects[2]?objects[2]:"");//整改计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计整改计划的数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findconstructplancountbysome.f")
public Map<String,Object> findConstructPlanCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findConstructPlanCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("type", null!=objects[2]?objects[2]:"");//评价类型中文
row.put("dealStatus", null!=objects[3]?objects[3]:"");//处理状态
row.put("planCount", null!=objects[4]?objects[4]:"");//评价计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
}
| UTF-8 | Java | 32,267 | java | IcmMyDatasControl.java | Java | [
{
"context": "数据(包括 我的流程 我的风险 我的制度 我的标准 我的控制措施 我的任务)\n * @author 邓广义\n * @date 2013-5-15\n * @since fhd Ver 1.1\n */\n@Co",
"end": 679,
"score": 0.9998617768287659,
"start": 676,
"tag": "NAME",
"value": "邓广义"
},
{
"context": "\n\t * <pre>\n\t * 流程统计情况\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:部门或公司\n\t * @param limit 页容量\n",
"end": 880,
"score": 0.9998384714126587,
"start": 877,
"tag": "NAME",
"value": "张 雷"
},
{
"context": " * <pre>\n\t * 查询内控要求信息\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:公司或部门\n\t * @param limit 页面显示",
"end": 7844,
"score": 0.9998564720153809,
"start": 7841,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "* <pre>\n\t * 统计内控要求的数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:公司或部门\n\t * @return\n\t * @sinc",
"end": 11151,
"score": 0.9998552203178406,
"start": 11148,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "\n\t * <pre>\n\t * 统计缺陷数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:部门或\n\t * @param planId 评价计划I",
"end": 13833,
"score": 0.9998540282249451,
"start": 13830,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "\n\t * <pre>\n\t * 查询缺陷信息\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID\n\t * @param query 查询条件\n\t * @",
"end": 16032,
"score": 0.9998675584793091,
"start": 16029,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "* <pre>\n\t * 统计评价结果的数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:部门或公司\n\t * @param planId 评价计",
"end": 20299,
"score": 0.9998405575752258,
"start": 20296,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "* <pre>\n\t * 查询评价结果的明细\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param orgId 机构ID:公司或部门\n\t * @param planId 评价计",
"end": 22639,
"score": 0.9998442530632019,
"start": 22636,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "* <pre>\n\t * 统计评价计划的数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param companyId 公司ID\n\t * @return\n\t * @since ",
"end": 27486,
"score": 0.9998453259468079,
"start": 27483,
"tag": "NAME",
"value": "张 雷"
},
{
"context": " * <pre>\n\t * 统计整改计划数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param companyId 公司ID\n\t * @return\n\t * @since ",
"end": 28507,
"score": 0.9998742341995239,
"start": 28504,
"tag": "NAME",
"value": "张 雷"
},
{
"context": "* <pre>\n\t * 统计整改计划的数量\n\t * </pre>\n\t * \n\t * @author 张 雷\n\t * @param companyId 公司ID\n\t * @return\n\t * @since ",
"end": 29391,
"score": 0.9998824000358582,
"start": 29388,
"tag": "NAME",
"value": "张 雷"
}
] | null | [] | package com.fhd.icm.web.controller.statics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.fhd.core.utils.DateUtils;
import com.fhd.core.utils.Identities;
import com.fhd.icm.business.statics.IcmMyDatasBO;
/**
* 内控我的数据(包括 我的流程 我的风险 我的制度 我的标准 我的控制措施 我的任务)
* @author 邓广义
* @date 2013-5-15
* @since fhd Ver 1.1
*/
@Controller
public class IcmMyDatasControl {
@Autowired
private IcmMyDatasBO o_icmMyDatasBO;
/**
* <pre>
* 流程统计情况
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或公司
* @param limit 页容量
* @param start 起始值
* @param pagable 是否更多页面
* @param query 查询条件:流程编号或流程名称
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findprocessbysome.f")
public Map<String,Object> findProcessBySome(String orgId, String query, String start, String limit, String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("processCode".equals(property)){
sortDirection.append("p.PROCESSURE_CODE ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("p.LAST_MODIFY_TIME ").append(direction).append(", p.CREATE_TIME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("empName".equals(property)){
sortDirection.append("e.EMP_NAME ").append(direction);
}else if("frequency".equals(property)){
sortDirection.append("p.PROCESS_CLASS ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("pp.PROCESSURE_NAME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findProcessBySome(result, orgId, query, start, limit, sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称(责任部门)
row.put("empId", null!=objects[2]?objects[2]:"");//员工ID
row.put("empName", null!=objects[3]?objects[3]:"");//员工姓名(责任人)
row.put("parentName", null!=objects[4]?objects[4]:"");//流程分类名称
row.put("frequency", null!=objects[11]?objects[11]:"");//发生频率
row.put("processCode", null!=objects[6]?objects[6]:"");//流程编号
row.put("processName", null!=objects[7]?objects[7]:"");//流程名称
row.put("id", null!=objects[8]?objects[8]:"");//流程ID
String updateDate = "";
if(null != objects[10]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[10]).substring(0,String.valueOf(objects[10]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[9]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[9]).substring(0,String.valueOf(objects[9]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* 我的控制措施
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/icmmycontroldatas.f")
public Map<String,Object> findMyControlDatasByOrgId(String orgid,String limit,String start,boolean pagable,String query){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
/*List<Object[]> objects = o_icmMyDatasBO.findMyControlDatasByOrgId(result,orgid,limit,query,start);
if(!pagable){//每个小块儿中的gird传送limit参数
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("code", null!=o[2]?o[2]:"");
row.put("name", null!=o[3]?o[3]:"");
datas.add(row);
}
}else{ //点击更多 无参数 显示所有
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("risk", null!=o[1]?this.o_riskBO.findRiskById((String)o[1]).getName():"");//所属风险
row.put("code", o[2]);
row.put("name", o[3]);
row.put("controlMode", null!=o[4]?this.o_dictBO.findDictEntryById((String)o[4]).getName():"");//控制方式
row.put("isKeyPoint", null!=o[5]?"0yn_n".equals(o[5])?"否":"是":"");//是否关键控制点
datas.add(row);
}
}*/
result.put("datas", datas);
return result;
}
/**
* 我的风险 “风险水平”???
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/findriskbysome.f")
public Map<String,Object> findRiskBySome(String orgId,String limit,String start,String query,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("riskCode".equals(property)){
sortDirection.append("r.RISK_CODE ").append(direction);
}else if("riskName".equals(property)){
sortDirection.append("r.RISK_NAME ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("pr.RISK_NAME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("r.LAST_MODIFY_TIME ").append(direction).append(", r.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findRiskBySome(result, orgId, query, start, limit, sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", null!=objects[0]?objects[0]:"");
row.put("riskCode", null!=objects[1]?objects[1]:"");//要求编号
row.put("riskName", null!=objects[2]?objects[2]:"");//要求名称
row.put("parentId", null!=objects[3]?objects[3]:"");//内控标准ID
row.put("parentName", null!=objects[4]?objects[4]:"");//内控标准名称
row.put("orgId", null!=objects[5]?objects[5]:"");//机构ID
row.put("orgName", null!=objects[6]?objects[6]:"");//机构名称
String updateDate = "";
if(null != objects[8]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[8]).substring(0,String.valueOf(objects[8]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[7]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[7]).substring(0,String.valueOf(objects[7]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询内控要求信息
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @param limit 页面显示记录数
* @param start 开始数
* @param query 查询条件
* @param sort 排序
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findstandardbysome.f")
public Map<String,Object> findStandardBySome(String orgId,String limit,String start,String query,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("standardCode".equals(property)){
sortDirection.append("s.STANDARD_CODE ").append(direction);
}else if("standardName".equals(property)){
sortDirection.append("s.STANDARD_NAME ").append(direction);
}else if("controlLevel".equals(property)){
sortDirection.append("e1.DICT_ENTRY_NAME ").append(direction);
}else if("controlPoint".equals(property)){
sortDirection.append("e2.DICT_ENTRY_NAME ").append(direction);
}else if("dealStatus".equals(property)){
sortDirection.append("e3.DICT_ENTRY_NAME ").append(direction);
}else if("parentName".equals(property)){
sortDirection.append("ps.STANDARD_NAME ").append(direction);
}else if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("s.LAST_MODIFY_TIME ").append(direction).append(", s.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Object[]> objectsList = o_icmMyDatasBO.findStandardBySome(result,orgId,query,start,limit,sortDirection.toString());
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
for(Object[] objects: objectsList){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", null!=objects[0]?objects[0]:"");
row.put("standardCode", null!=objects[1]?objects[1]:"");//要求编号
row.put("standardName", null!=objects[2]?objects[2]:"");//要求名称
row.put("controlLevel", null!=objects[4]?objects[4]:"");//控制层级中文
row.put("controlPoint", null!=objects[6]?objects[6]:"");//控制要素中文
row.put("dealStatus", null!=objects[8]?objects[8]:"");//处理状态中文
row.put("parentId", null!=objects[9]?objects[9]:"");//内控标准ID
row.put("parentName", null!=objects[10]?objects[10]:"");//内控标准名称
row.put("orgId", null!=objects[11]?objects[11]:"");//机构ID
row.put("orgName", null!=objects[12]?objects[12]:"");//机构名称
String updateDate = "";
if(null != objects[14]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[14]).substring(0,String.valueOf(objects[14]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[13]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[13]).substring(0,String.valueOf(objects[13]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计内控要求的数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findstandardcountbysome.f")
public Map<String,Object> findStandardCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findStandardCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("parentId", null!=objects[2]?objects[2]:"");//内控标准ID
row.put("parentName", null!=objects[3]?objects[3]:"");//内控标准名称
row.put("dealStatus", null!=objects[5]?objects[5]:"");//处理状态
row.put("controlPoint", null!=objects[7]?objects[7]:"");//控制要素
row.put("controlLevel", null!=objects[9]?objects[9]:"");//控制层级
row.put("createYear", null!=objects[10]?objects[10]:"");//控制层级
row.put("standardCount", objects[11]);//内控要求数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* 我的制度 :制度分类 制度编号 制度名称 责任部门
* @param orgid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/icmmyinstitutiondatas.f")
public Map<String,Object> findMyInstitutionDatasByOrgId(String orgid,String limit,String start,boolean pagable,String query){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
/*List<Object[]> objects = o_icmMyDatasBO.findMyInstitutionDatasByOrgId(result,orgid,limit,query,start);
if(!pagable){//每个小块儿中的gird传送limit参数
for(Object[] o: objects){
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("code", o[2]);
row.put("name", o[3]);
datas.add(row);
}
}else{
for(Object[] o: objects){//更多
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", o[0]);
row.put("classify", null!=o[1]?this.o_ruleBO.findRuleByRuleId(o[1].toString()).getName():"");//分类
row.put("code", o[2]);
row.put("name", o[3]);
row.put("org", null!=o[4]?this.o_organizationBO.getRootOrgByCompanyId(o[4].toString()).getOrgname():"");
datas.add(row);
}
}*/
result.put("datas", datas);
return result;
}
/**
* 判断当前登录人是否为内控部门员工
* @param empid
* @return
*/
@ResponseBody
@RequestMapping("/icm/statics/judgeificmdept.f")
public boolean judgeIfIcmDept(){
return this.o_icmMyDatasBO.judgeIfIcmDept();
}
/**
* <pre>
* 统计缺陷数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或
* @param planId 评价计划ID
* @param iPlanId 整改计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/finddefectcountbysome.f")
public Map<String,Object> findDefectCountBySome(String orgId, String planId, String iPlanId, String processId, String processPointId, String measureId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findDefectCountBySome(orgId, planId, iPlanId, processId, processPointId, measureId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("planId", null!=objects[2]?objects[2]:"");//评价计划ID
row.put("planName", null!=objects[3]?objects[3]:"");//评价计划名称
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("dealStatus", null!=objects[12]?objects[12]:"");//整改状态
row.put("defectCount", objects[15]);//缺陷数量
row.put("defectLevel", null!=objects[16]?objects[16]:"");//缺陷等级
row.put("defectType", null!=objects[17]?objects[17]:"");//缺陷类型
row.put("createYear", null!=objects[18]?objects[18]:"");//年份
row.put("iPlanId", null!=objects[19]?objects[19]:"");//整改计划ID
row.put("iPlanName", null!=objects[20]?objects[20]:"");//整改计划名称
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询缺陷信息
* </pre>
*
* @author 张 雷
* @param orgId 机构ID
* @param query 查询条件
* @param planId 评价计划ID
* @param iPlanId 整改计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/finddefectbysome.f")
public Map<String,Object> findDefectBySome(String orgId, String query, String planId, String processId, String processPointId, String measureId,String limit,String start,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("orgName".equals(property)){
sortDirection.append("o.ORG_NAME ").append(direction);
}else if("planName".equals(property)){
sortDirection.append("plan.PLAN_NAME ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("processPointName".equals(property)){
sortDirection.append("c.CONTROL_POINT_NAME ").append(direction);
}else if("measureName".equals(property)){
sortDirection.append("m.MEASURE_NAME ").append(direction);
}else if("assessPointName".equals(property)){
sortDirection.append("ap.EDESC ").append(direction);
}else if("dealStatus".equals(property)){
sortDirection.append("d.DEAL_STATUS ").append(direction);
}else if("defectDesc".equals(property)){
sortDirection.append("d.EDESC ").append(direction);
}else if("defectLevel".equals(property)){
sortDirection.append("e1.DICT_ENTRY_NAME ").append(direction);
}else if("defectType".equals(property)){
sortDirection.append("e2.DICT_ENTRY_NAME ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("d.LAST_MODIFY_TIME ").append(direction).append(", d.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findDefectBySome(result,orgId, query, planId, processId, processPointId, measureId, start, limit, sortDirection.toString());
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("orgId", null!=objects[0]?objects[0]:"");//机构ID
row.put("orgName", null!=objects[1]?objects[1]:"");//机构名称
row.put("planId", null!=objects[2]?objects[2]:"");//评价计划ID
row.put("planName", null!=objects[3]?objects[3]:"");//评价计划名称
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("dealStatus", null!=objects[12]?objects[12]:"");//整改状态
row.put("id", objects[15]);//缺陷ID
row.put("defectDesc", null!=objects[16]?objects[16]:"");//缺陷描述
row.put("defectLevel", null!=objects[17]?objects[17]:"");//缺陷等级
row.put("defectType", null!=objects[18]?objects[18]:"");//缺陷类型
String updateDate = "";
if(null != objects[20]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[20]).substring(0,String.valueOf(objects[20]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[19]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[19]).substring(0,String.valueOf(objects[19]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计评价结果的数量
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:部门或公司
* @param planId 评价计划ID
* @param processId 流程ID
* @param processPointId 流程节点ID
* @param measureId 控制措施ID
* @param assessPointId 评价点ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessresultcountbysome.f")
public Map<String,Object> findAssessResultCountBySome(String orgId, String planId, String empId,
String processId, String processPointId, String measureId, String assessPointId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessResultCountBySome(orgId, planId, empId,
processId, processPointId, measureId, assessPointId);
Integer allCount = 0;
for (Object[] objects : objectList) {
allCount += Integer.valueOf(String.valueOf(objects[10]));
}
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("planId", null!=objects[0]?objects[0]:"");//评价计划ID
row.put("planName", null!=objects[1]?objects[1]:"");//评价计划名称
row.put("empId", null!=objects[2]?objects[2]:"");//员工ID
row.put("empName", null!=objects[3]?objects[3]:"");//员工姓名
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
/*row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
*/ row.put("assessMeasure", null!=objects[7]?objects[7]:"");//评价方式
row.put("isValid", null!=objects[8]?objects[8]:"");//是否合格
row.put("isFinished", null!=objects[9]?objects[9]:"");//是否完成
if(allCount!=0){
row.put("assessResultRate", (double)Integer.valueOf(String.valueOf(objects[10]))/allCount*100);//评价结果占比
}else{
row.put("assessResultRate", 0);//评价结果占比
}
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 查询评价结果的明细
* </pre>
*
* @author 张 雷
* @param orgId 机构ID:公司或部门
* @param planId 评价计划ID
* @param empId 评价人ID
* @param processPointId 流程节点ID
* @param processId 流程ID
* @param measureId 控制措施ID
* @param assessPointId 评价点ID
* @param query 查询条件
* @param limit 限制数
* @param start 起始数
* @param sort 排序
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessresultbysome.f")
public Map<String,Object> findAssessResultBySome(String orgId, String planId, String empId, String processPointId,
String processId,String measureId, String assessPointId, String query, String limit,String start,String sort){
StringBuffer sortDirection = new StringBuffer();
if(StringUtils.isNotBlank(sort)){//排序
JSONArray jsonArray=JSONArray.fromObject(sort);
if(jsonArray.size()!=0){
for(int i=0;i<jsonArray.size();i++){
JSONObject jsonObject=jsonArray.getJSONObject(i);
String property = jsonObject.getString("property");
String direction = jsonObject.getString("direction");
if("planName".equals(property)){
sortDirection.append("plan.PLAN_NAME ").append(direction);
}else if("empName".equals(property)){
sortDirection.append("e.EMP_NAME ").append(direction);
}else if("processName".equals(property)){
sortDirection.append("p.PROCESSURE_NAME ").append(direction);
}else if("processPointName".equals(property)){
sortDirection.append("c.CONTROL_POINT_NAME ").append(direction);
}else if("measureName".equals(property)){
sortDirection.append("m.MEASURE_NAME ").append(direction);
}else if("assessPointName".equals(property)){
sortDirection.append("ap.EDESC ").append(direction);
}else if("assessMeasure".equals(property)){
sortDirection.append("r.ASSESSMENT_MEASURE ").append(direction);
}else if("isQualified".equals(property)){
sortDirection.append("CASE WHEN ")
.append("r.HAS_DEFECT_ADJUST IS NULL ")
.append("THEN ")
.append("(CASE WHEN r.HAS_DEFECT IS NULL THEN NULL ELSE (CASE WHEN r.HAS_DEFECT='0' THEN '不合格' ELSE '合格' END) END) ")
.append("ELSE ")
.append("(CASE WHEN r.HAS_DEFECT_ADJUST='0' THEN '不合格' ELSE '合格' END) ")
.append("END ").append(direction);
}else if("isDone".equals(property)){
sortDirection.append("CASE WHEN ")
.append("r.has_defect IS NOT NULL ")
.append("THEN ")
.append("'已完成' ")
.append("ELSE ")
.append("'未完成' ")
.append("END ").append(direction);
}else if("updateDate".equals(property)){
sortDirection.append("plan.LAST_MODIFY_TIME ").append(direction).append(", plan.CREATE_TIME ").append(direction);
}
}
}
}
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessResultBySome(result, orgId, planId, empId, processId, processPointId, measureId, assessPointId, query, start, limit, sortDirection.toString());
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("planId", null!=objects[0]?objects[0]:"");//评价计划ID
row.put("planName", null!=objects[1]?objects[1]:"");//评价计划名称
row.put("empId", null!=objects[2]?objects[2]:"");//评价人ID
row.put("empName", null!=objects[3]?objects[3]:"");//评价人姓名
row.put("processId", null!=objects[4]?objects[4]:"");//流程ID
row.put("processName", null!=objects[5]?objects[5]:"");//流程名称
row.put("processPointId", null!=objects[6]?objects[6]:"");//流程节点ID
row.put("processPointName", null!=objects[7]?objects[7]:"");//流程节点名称
row.put("measureId", null!=objects[8]?objects[8]:"");//控制措施ID
row.put("measureName", null!=objects[9]?objects[9]:"");//控制措施名称
row.put("assessPointId", null!=objects[10]?objects[10]:"");//评价点ID
row.put("assessPointName", null!=objects[11]?objects[11]:"");//评价点名称
row.put("assessMeasure", null!=objects[13]?objects[13]:"");//评价方式
row.put("isQualified", null!=objects[14]?objects[14]:"");//样本合格状态
row.put("isDone", null!=objects[15]?objects[15]:"");//评价完成状态
String updateDate = "";
if(null != objects[17]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[17]).substring(0,String.valueOf(objects[17]).lastIndexOf("."))), "yyyy-MM-dd");
}else{
if(null != objects[16]){
updateDate = DateUtils.formatDate(DateUtils.parseTimeStamp(String.valueOf(objects[16]).substring(0,String.valueOf(objects[16]).lastIndexOf("."))), "yyyy-MM-dd");
}
}
row.put("updateDate", updateDate);//更新日期
row.put("sampleCount", null!=objects[18]?objects[18]:0);//样本数量
row.put("id", null!=objects[19]?objects[19]:"");//ID
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计评价计划的数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findassessplancountbysome.f")
public Map<String,Object> findAssessPlanCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findAssessPlanCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("type", null!=objects[2]?objects[2]:"");//评价类型中文
row.put("dealStatus", null!=objects[3]?objects[3]:"");//处理状态
row.put("assessMeasure", null!=objects[5]?objects[5]:"");//评价方式中文
row.put("planCount", null!=objects[6]?objects[6]:"");//评价计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计整改计划数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findimprovecountbysome.f")
public Map<String,Object> findImproveCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findImproveCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("dealStatus", null!=objects[1]?objects[1]:"");//处理状态
row.put("planCount", null!=objects[2]?objects[2]:"");//整改计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
/**
* <pre>
* 统计整改计划的数量
* </pre>
*
* @author 张 雷
* @param companyId 公司ID
* @return
* @since fhd Ver 1.1
*/
@ResponseBody
@RequestMapping("/icm/statics/findconstructplancountbysome.f")
public Map<String,Object> findConstructPlanCountBySome(String orgId){
Map<String,Object> result = new HashMap<String,Object>();
List<Map<String, Object>> datas = new ArrayList<Map<String, Object>>();
List<Object[]> objectList = o_icmMyDatasBO.findConstructPlanCountBySome(orgId);
for (Object[] objects : objectList) {
Map<String, Object> row = new HashMap<String, Object>();
row.put("id", Identities.uuid());//ID
row.put("createYear", null!=objects[0]?objects[0]:"");//创建年份
row.put("type", null!=objects[2]?objects[2]:"");//评价类型中文
row.put("dealStatus", null!=objects[3]?objects[3]:"");//处理状态
row.put("planCount", null!=objects[4]?objects[4]:"");//评价计划数量
datas.add(row);
}
result.put("datas", datas);
return result;
}
}
| 32,267 | 0.668075 | 0.653913 | 735 | 40.214966 | 32.556431 | 198 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.609524 | false | false | 3 |
79b54688d2ee2942c4c78b03ced30d66129171b3 | 11,304,353,989,553 | 1997b02359cde0d10c5a66b8b322634e9e438062 | /tictactoe/src/tictactoe/PlayingWithCompController.java | 9a84e5c6b98d99c889fa0dae796339b06f8939a2 | [] | no_license | ahmedelbaiomy/Tic-Tac-Toe | https://github.com/ahmedelbaiomy/Tic-Tac-Toe | 0d40d6a65ae6379268e60b36a03dc9b8a19bc7c5 | 6f8cc8cc4be870ef2a125263f840b993ccea8641 | refs/heads/master | 2023-03-22T18:28:34.119000 | 2021-03-17T10:54:41 | 2021-03-17T10:54:41 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tictactoe;
import com.jfoenix.controls.JFXButton;
import java.util.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import static tictactoe.LoginController.in;
import static tictactoe.LoginController.out;
import static tictactoe.LoginController.socket;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
/**
* FXML Controller class
*
* @author i
*/
public class PlayingWithCompController implements Initializable {
protected MediaPlayer videoForWinner;
protected Stage secondStage2;
private Redirection redirect = new Redirection();
Parent root = null;
Stage stage;
@FXML
private Label playerscore;
Image x = new Image("assets/x_1.png");
Image o = new Image("assets/o_1.png");
Image img;
//int player; //flag to detect win player
static String playerNickname;
private int xCount = 0;
private int oCount = 0;
int[] clickChecker = new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1};
int[] playerPosition = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
private char[][] gameBoard = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}};
int flag = 1;
int counter = 0;
private Scanner in;
private PrintWriter out;
private Socket socket;
@FXML
private JFXButton playBtn;
@FXML
private JFXButton stopBtn;
@FXML
private Label playerName;
@FXML
private ImageView topleft;
@FXML
private ImageView topcenter;
@FXML
private ImageView topright;
@FXML
private ImageView centerleft;
@FXML
private ImageView centercenter;
@FXML
private ImageView centerright;
@FXML
private ImageView bottomleft;
@FXML
private ImageView bottomcenter;
@FXML
private ImageView bottomright;
private static PlayingWithCompController instance;
@FXML
private Font x1;
@FXML
private JFXButton backBtn;
@FXML
void back(ActionEvent event) throws IOException {
redirect.redirction("StartMenu.fxml", event);
}
public void computerMove() {
System.out.println("hen fe computermove ");
Random rgen = new Random(); // Computer
if (rgen.nextBoolean()) { // sometimes blocks when easy
if (blockWin()) {
return;
}
}
if (playOppositeCorner()) {
return;
}
if (playEmptyCorner()) {
return;
}
playEmptySide();
}
// Plays an empty corner and returns true if move is made.
private boolean playEmptyCorner() {
System.out.println("hen fe playempty momken return false");
if (gameBoard[0][0] == ' ') {
makeMoveInSquare(0, 0);
return true;
} else if (gameBoard[0][2] == ' ') {
makeMoveInSquare(0, 2);
return true;
} else if (gameBoard[2][0] == ' ') {
makeMoveInSquare(2, 0);
return true;
} else if (gameBoard[2][2] == ' ') {
makeMoveInSquare(2, 2);
return true;
}
return false;
}
// Plays a corner opposite a corner already played by 'x'
// and returns true if move is made.
private boolean playOppositeCorner() {
System.out.println("hen fe playOppositeCorner momken return false");
if (gameBoard[0][0] == 'x' && gameBoard[2][2] == ' ') {
makeMoveInSquare(2, 2);
return true;
} else if (gameBoard[2][2] == 'x' && gameBoard[0][0] == ' ') {
makeMoveInSquare(0, 0);
return true;
} else if (gameBoard[0][2] == 'x' && gameBoard[2][0] == ' ') {
makeMoveInSquare(2, 0);
return true;
} else if (gameBoard[2][0] == 'x' && gameBoard[0][2] == ' ') {
makeMoveInSquare(0, 2);
return true;
}
return false;
}
// Plays the center and returns true if move is made.
private boolean playCenter() {
System.out.println("hen fe playcenter momken return false");
if (gameBoard[1][1] == ' ') {
System.out.println("da5l el if w el mafrod gggggggggg");
makeMoveInSquare(1, 1);
return true;
}
return false;
}
private void playEmptySide() {
System.out.println("hen fe emptyside momken return false");
if (gameBoard[0][1] == ' ') {
makeMoveInSquare(0, 1);
} else if (gameBoard[1][0] == ' ') {
makeMoveInSquare(1, 0);
} else if (gameBoard[1][2] == ' ') {
makeMoveInSquare(1, 2);
} else if (gameBoard[2][1] == ' ') {
makeMoveInSquare(2, 1);
}
}
// Prevents fork scenarios that allow x to win
private boolean preventForkScenarios() {
System.out.println("hen fe preventForkScenarios momken return false");
if (counter == 3) {
if (gameBoard[0][0] == 'x' && gameBoard[1][1] == 'o' && gameBoard[2][2] == 'x') {
playEmptySide();
return true;
}
if (gameBoard[2][0] == 'x' && gameBoard[1][1] == 'o' && gameBoard[0][2] == 'x') {
playEmptySide();
return true;
}
if (gameBoard[2][1] == 'x' && gameBoard[1][2] == 'x') {
makeMoveInSquare(2, 2);
return true;
}
}
return false;
}
private boolean blockWin() {
System.out.println("hen fe blockwin ");
return false;
}
public void makeMoveInSquare(int row, int col) { //hena h3ml nestedloop check beha 3la el makan elly el mafrod a7d feh el img bt3ati
System.out.println("hen fe makeMoveInSquare ");
gameBoard[row][col] = 'o';
//img = o;
//check squre empty or not
if (row == 0 && col == 0) {
//need to detect position that i will set img in
topleft.setImage(setImage());
}
if (row == 0 && col == 1) {
//need to detect position that i will set img in
topcenter.setImage(setImage());
}
if (row == 0 && col == 2) {
//need to detect position that i will set img in
topright.setImage(setImage());
}
if (row == 1 && col == 0) {
//need to detect position that i will set img in
centerleft.setImage(setImage());
}
if (row == 1 && col == 1) {
//need to detect position that i will set img in
centercenter.setImage(setImage());
}
if (row == 1 && col == 2) {
//need to detect position that i will set img in
centerright.setImage(setImage());
}
if (row == 2 && col == 0) {
//need to detect position that i will set img in
bottomleft.setImage(setImage());
}
if (row == 2 && col == 1) {
//need to detect position that i will set img in
bottomcenter.setImage(setImage());
}
if (row == 2 && col == 2) {
//need to detect position that i will set img in
bottomright.setImage(setImage());
}
}
private Image setImage() {
System.out.println("set img befoer inc " + counter);
if (counter % 2 == 0) {
img = x;
} else {
img = o;
}
counter++;
return img;
}
private void alertMsg(String w) {
try {
if (w == "X" || w == "O") {
int xscore = Integer.parseInt(playerscore.getText()) + 5;
Integer xxscore = new Integer(xscore);
String usernameScore = xscore + "," + tictactoe.LoginController.usernamePlayer;
playerscore.setText(xxscore.toString());
out.println("insertscore");
out.println(usernameScore);
System.out.println(usernameScore);
winnerVideo(SingleController.playername);
} else {
}
} catch (Exception e) {
System.out.println("error in alert");
}
}
public void winnerVideo(String player) {
StackPane secondaryLayout2 = new StackPane();
videoForWinner = new MediaPlayer(new Media(getClass().getResource("2.mp4").toExternalForm()));
MediaView mediaView2 = new MediaView(videoForWinner);
secondaryLayout2.getChildren().addAll(mediaView2);
Scene secondScene2 = new Scene(secondaryLayout2, 700, 500);
secondStage2 = new Stage();
secondStage2.setTitle("Congratulations");
secondStage2.setResizable(false);
secondStage2.setX(500);
secondStage2.setY(60);
secondStage2.setScene(secondScene2);
secondStage2.show();
videoForWinner.play();
}
private void reset() {
try {
topleft.setImage(null);
topcenter.setImage(null);
topright.setImage(null);
centerleft.setImage(null);
centercenter.setImage(null);
centerright.setImage(null);
bottomleft.setImage(null);
bottomcenter.setImage(null);
bottomright.setImage(null);
counter = 0;
// Arrays.fill(clickChecker,1);
for (int i = 0; i < 9; i++) {
clickChecker[i] = 1;
playerPosition[i] = 0;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
gameBoard[i][j] = ' ';
}
}
} catch (Exception e) {
System.out.println("error in reset");
}
flag = 0;
}
private void winningGame() {
System.out.println("win check " + counter);
Image b1 = topleft.getImage();
Image b2 = topcenter.getImage();
Image b3 = topright.getImage();
Image b4 = centerleft.getImage();
Image b5 = centercenter.getImage();
Image b6 = centerright.getImage();
Image b7 = bottomleft.getImage();
Image b8 = bottomcenter.getImage();
Image b9 = bottomright.getImage();
try {
if (b1 == x && b2 == x && b3 == x) {
xCount++;
alertMsg("X");
reset();
// gameScore();
} else if (b4 == x && b5 == x && b6 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b7 == x && b8 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b1 == x && b4 == x && b7 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b2 == x && b5 == x && b8 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b3 == x && b6 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b1 == x && b5 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b3 == x && b5 == x && b7 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} //player O
else if (b1 == o && b2 == o && b3 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b4 == o && b5 == o && b6 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b7 == o && b8 == o && b9 == o) {
oCount++;
alertMsg("O");
//gameScore()
} else if (b1 == o && b4 == o && b7 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b2 == o && b5 == o && b8 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b3 == o && b6 == o && b9 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b1 == o && b5 == o && b9 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore();
} else if (b3 == o && b5 == o && b7 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (clickChecker[0] == 0 && clickChecker[1] == 0 && clickChecker[2] == 0 && clickChecker[3] == 0 && clickChecker[4] == 0 && clickChecker[5] == 0 && clickChecker[6] == 0 && clickChecker[7] == 0 && clickChecker[8] == 0) {
alertMsg("NO player wins");
reset();
}
} catch (Exception e) {
System.out.println("clicked");
}
if (counter == 9) {
alertMsg(" equal state no one win ");
reset();
return;
}
}
@FXML
public void drawTopLeft() throws FileNotFoundException {
// Client client = new Client("playWithOther","0","1",onlinePlayer.getValue().toString());
System.out.println(playerNickname + "essssssslam");
if (clickChecker[0] == 1) {
topleft.setImage(setImage());
if (img == x) {
playerPosition[0] = 1;
gameBoard[0][0] = 'x';
} else {
playerPosition[0] = 2;
}
clickChecker[0] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawTopCenter() throws FileNotFoundException {
if (clickChecker[1] == 1) {
topcenter.setImage(setImage());
if (img == x) {
playerPosition[1] = 1;
gameBoard[0][1] = 'x';
} else {
playerPosition[1] = 2;
}
clickChecker[1] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawTopRight() throws FileNotFoundException {
if (clickChecker[2] == 1) {
topright.setImage(setImage());
if (img == x) {
playerPosition[2] = 1;
gameBoard[0][2] = 'x';
} else {
playerPosition[2] = 2;
}
clickChecker[2] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterLeft() throws FileNotFoundException {
if (clickChecker[3] == 1) {
centerleft.setImage(setImage());
if (img == x) {
playerPosition[3] = 1;
gameBoard[1][0] = 'x';
} else {
playerPosition[3] = 2;
}
winningGame();
clickChecker[3] = 0;
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterCenter() throws FileNotFoundException {
if (clickChecker[4] == 1) {
centercenter.setImage(setImage());
if (img == x) {
playerPosition[4] = 1;
gameBoard[1][1] = 'x';
} else {
playerPosition[4] = 2;
}
clickChecker[4] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterRight() throws FileNotFoundException {
if (clickChecker[5] == 1) {
centerright.setImage(setImage());
if (img == x) {
playerPosition[5] = 1;
gameBoard[1][2] = 'x';
} else {
playerPosition[5] = 2;
}
clickChecker[5] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomLeft() throws FileNotFoundException {
if (clickChecker[6] == 1) {
bottomleft.setImage(setImage());
if (img == x) {
playerPosition[6] = 1;
gameBoard[2][0] = 'x';
} else {
playerPosition[6] = 2;
}
clickChecker[6] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomCenter() throws FileNotFoundException {
if (clickChecker[7] == 1) {
bottomcenter.setImage(setImage());
if (img == x) {
playerPosition[7] = 1;
gameBoard[2][1] = 'x';
} else {
playerPosition[7] = 2;
}
clickChecker[7] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomRight() throws FileNotFoundException {
if (clickChecker[8] == 1) {
bottomright.setImage(setImage());
if (img == x) {
playerPosition[8] = 1;
gameBoard[2][2] = 'x';
} else {
playerPosition[8] = 2;
}
clickChecker[8] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
public void winVideo(String player) {
try {
root = FXMLLoader.load(getClass().getResource("MediaScreenWinner.fxml"));
} catch (IOException ex) {
Logger.getLogger(TwoPlayersLocalPlayController.class.getName()).log(Level.SEVERE, null, ex);
}
root.getStylesheets().add(getClass().getResource("css/menu-background.css").toString());
Scene scene = new Scene(root);
stage.setTitle(player);
stage.setScene(scene);
stage.show();
}
@FXML
void play(ActionEvent event) {
tictactoe.Tictactoe.mediaPlayer.play();
playBtn.setVisible(false);
stopBtn.setVisible(true);
}
@FXML
void stop(ActionEvent event) {
tictactoe.Tictactoe.mediaPlayer.stop();
playBtn.setVisible(true);
stopBtn.setVisible(false);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println(SingleController.playername);
playerName.setText(SingleController.playername);
playerscore.setText(tictactoe.LoginController.score);
try {
socket = new Socket("localhost", 5005);
in = new Scanner(socket.getInputStream());
out = new PrintWriter(socket.getOutputStream(), true);
} catch (Exception e) {
System.out.println(e);
}
}
}
| UTF-8 | Java | 21,046 | java | PlayingWithCompController.java | Java | [
{
"context": "aView;\n\n/**\n * FXML Controller class\n *\n * @author i\n */\npublic class PlayingWithCompController implem",
"end": 1539,
"score": 0.8843929171562195,
"start": 1538,
"tag": "USERNAME",
"value": "i"
},
{
"context": "());\n System.out.println(playerNickname + \"essssssslam\");\n if (clickChecker[0] == 1) {\n ",
"end": 14846,
"score": 0.8884507417678833,
"start": 14835,
"tag": "USERNAME",
"value": "essssssslam"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package tictactoe;
import com.jfoenix.controls.JFXButton;
import java.util.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.net.Socket;
import java.net.URL;
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Platform;
import javafx.collections.FXCollections;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Node;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Alert.AlertType;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.StackPane;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
import javafx.scene.text.Font;
import javafx.stage.Stage;
import static tictactoe.LoginController.in;
import static tictactoe.LoginController.out;
import static tictactoe.LoginController.socket;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
/**
* FXML Controller class
*
* @author i
*/
public class PlayingWithCompController implements Initializable {
protected MediaPlayer videoForWinner;
protected Stage secondStage2;
private Redirection redirect = new Redirection();
Parent root = null;
Stage stage;
@FXML
private Label playerscore;
Image x = new Image("assets/x_1.png");
Image o = new Image("assets/o_1.png");
Image img;
//int player; //flag to detect win player
static String playerNickname;
private int xCount = 0;
private int oCount = 0;
int[] clickChecker = new int[]{1, 1, 1, 1, 1, 1, 1, 1, 1};
int[] playerPosition = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0};
private char[][] gameBoard = {{' ', ' ', ' '}, {' ', ' ', ' '}, {' ', ' ', ' '}};
int flag = 1;
int counter = 0;
private Scanner in;
private PrintWriter out;
private Socket socket;
@FXML
private JFXButton playBtn;
@FXML
private JFXButton stopBtn;
@FXML
private Label playerName;
@FXML
private ImageView topleft;
@FXML
private ImageView topcenter;
@FXML
private ImageView topright;
@FXML
private ImageView centerleft;
@FXML
private ImageView centercenter;
@FXML
private ImageView centerright;
@FXML
private ImageView bottomleft;
@FXML
private ImageView bottomcenter;
@FXML
private ImageView bottomright;
private static PlayingWithCompController instance;
@FXML
private Font x1;
@FXML
private JFXButton backBtn;
@FXML
void back(ActionEvent event) throws IOException {
redirect.redirction("StartMenu.fxml", event);
}
public void computerMove() {
System.out.println("hen fe computermove ");
Random rgen = new Random(); // Computer
if (rgen.nextBoolean()) { // sometimes blocks when easy
if (blockWin()) {
return;
}
}
if (playOppositeCorner()) {
return;
}
if (playEmptyCorner()) {
return;
}
playEmptySide();
}
// Plays an empty corner and returns true if move is made.
private boolean playEmptyCorner() {
System.out.println("hen fe playempty momken return false");
if (gameBoard[0][0] == ' ') {
makeMoveInSquare(0, 0);
return true;
} else if (gameBoard[0][2] == ' ') {
makeMoveInSquare(0, 2);
return true;
} else if (gameBoard[2][0] == ' ') {
makeMoveInSquare(2, 0);
return true;
} else if (gameBoard[2][2] == ' ') {
makeMoveInSquare(2, 2);
return true;
}
return false;
}
// Plays a corner opposite a corner already played by 'x'
// and returns true if move is made.
private boolean playOppositeCorner() {
System.out.println("hen fe playOppositeCorner momken return false");
if (gameBoard[0][0] == 'x' && gameBoard[2][2] == ' ') {
makeMoveInSquare(2, 2);
return true;
} else if (gameBoard[2][2] == 'x' && gameBoard[0][0] == ' ') {
makeMoveInSquare(0, 0);
return true;
} else if (gameBoard[0][2] == 'x' && gameBoard[2][0] == ' ') {
makeMoveInSquare(2, 0);
return true;
} else if (gameBoard[2][0] == 'x' && gameBoard[0][2] == ' ') {
makeMoveInSquare(0, 2);
return true;
}
return false;
}
// Plays the center and returns true if move is made.
private boolean playCenter() {
System.out.println("hen fe playcenter momken return false");
if (gameBoard[1][1] == ' ') {
System.out.println("da5l el if w el mafrod gggggggggg");
makeMoveInSquare(1, 1);
return true;
}
return false;
}
private void playEmptySide() {
System.out.println("hen fe emptyside momken return false");
if (gameBoard[0][1] == ' ') {
makeMoveInSquare(0, 1);
} else if (gameBoard[1][0] == ' ') {
makeMoveInSquare(1, 0);
} else if (gameBoard[1][2] == ' ') {
makeMoveInSquare(1, 2);
} else if (gameBoard[2][1] == ' ') {
makeMoveInSquare(2, 1);
}
}
// Prevents fork scenarios that allow x to win
private boolean preventForkScenarios() {
System.out.println("hen fe preventForkScenarios momken return false");
if (counter == 3) {
if (gameBoard[0][0] == 'x' && gameBoard[1][1] == 'o' && gameBoard[2][2] == 'x') {
playEmptySide();
return true;
}
if (gameBoard[2][0] == 'x' && gameBoard[1][1] == 'o' && gameBoard[0][2] == 'x') {
playEmptySide();
return true;
}
if (gameBoard[2][1] == 'x' && gameBoard[1][2] == 'x') {
makeMoveInSquare(2, 2);
return true;
}
}
return false;
}
private boolean blockWin() {
System.out.println("hen fe blockwin ");
return false;
}
public void makeMoveInSquare(int row, int col) { //hena h3ml nestedloop check beha 3la el makan elly el mafrod a7d feh el img bt3ati
System.out.println("hen fe makeMoveInSquare ");
gameBoard[row][col] = 'o';
//img = o;
//check squre empty or not
if (row == 0 && col == 0) {
//need to detect position that i will set img in
topleft.setImage(setImage());
}
if (row == 0 && col == 1) {
//need to detect position that i will set img in
topcenter.setImage(setImage());
}
if (row == 0 && col == 2) {
//need to detect position that i will set img in
topright.setImage(setImage());
}
if (row == 1 && col == 0) {
//need to detect position that i will set img in
centerleft.setImage(setImage());
}
if (row == 1 && col == 1) {
//need to detect position that i will set img in
centercenter.setImage(setImage());
}
if (row == 1 && col == 2) {
//need to detect position that i will set img in
centerright.setImage(setImage());
}
if (row == 2 && col == 0) {
//need to detect position that i will set img in
bottomleft.setImage(setImage());
}
if (row == 2 && col == 1) {
//need to detect position that i will set img in
bottomcenter.setImage(setImage());
}
if (row == 2 && col == 2) {
//need to detect position that i will set img in
bottomright.setImage(setImage());
}
}
private Image setImage() {
System.out.println("set img befoer inc " + counter);
if (counter % 2 == 0) {
img = x;
} else {
img = o;
}
counter++;
return img;
}
private void alertMsg(String w) {
try {
if (w == "X" || w == "O") {
int xscore = Integer.parseInt(playerscore.getText()) + 5;
Integer xxscore = new Integer(xscore);
String usernameScore = xscore + "," + tictactoe.LoginController.usernamePlayer;
playerscore.setText(xxscore.toString());
out.println("insertscore");
out.println(usernameScore);
System.out.println(usernameScore);
winnerVideo(SingleController.playername);
} else {
}
} catch (Exception e) {
System.out.println("error in alert");
}
}
public void winnerVideo(String player) {
StackPane secondaryLayout2 = new StackPane();
videoForWinner = new MediaPlayer(new Media(getClass().getResource("2.mp4").toExternalForm()));
MediaView mediaView2 = new MediaView(videoForWinner);
secondaryLayout2.getChildren().addAll(mediaView2);
Scene secondScene2 = new Scene(secondaryLayout2, 700, 500);
secondStage2 = new Stage();
secondStage2.setTitle("Congratulations");
secondStage2.setResizable(false);
secondStage2.setX(500);
secondStage2.setY(60);
secondStage2.setScene(secondScene2);
secondStage2.show();
videoForWinner.play();
}
private void reset() {
try {
topleft.setImage(null);
topcenter.setImage(null);
topright.setImage(null);
centerleft.setImage(null);
centercenter.setImage(null);
centerright.setImage(null);
bottomleft.setImage(null);
bottomcenter.setImage(null);
bottomright.setImage(null);
counter = 0;
// Arrays.fill(clickChecker,1);
for (int i = 0; i < 9; i++) {
clickChecker[i] = 1;
playerPosition[i] = 0;
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
gameBoard[i][j] = ' ';
}
}
} catch (Exception e) {
System.out.println("error in reset");
}
flag = 0;
}
private void winningGame() {
System.out.println("win check " + counter);
Image b1 = topleft.getImage();
Image b2 = topcenter.getImage();
Image b3 = topright.getImage();
Image b4 = centerleft.getImage();
Image b5 = centercenter.getImage();
Image b6 = centerright.getImage();
Image b7 = bottomleft.getImage();
Image b8 = bottomcenter.getImage();
Image b9 = bottomright.getImage();
try {
if (b1 == x && b2 == x && b3 == x) {
xCount++;
alertMsg("X");
reset();
// gameScore();
} else if (b4 == x && b5 == x && b6 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b7 == x && b8 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b1 == x && b4 == x && b7 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b2 == x && b5 == x && b8 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b3 == x && b6 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b1 == x && b5 == x && b9 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} else if (b3 == x && b5 == x && b7 == x) {
xCount++;
alertMsg("X");
reset();
//gameScore();
} //player O
else if (b1 == o && b2 == o && b3 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b4 == o && b5 == o && b6 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b7 == o && b8 == o && b9 == o) {
oCount++;
alertMsg("O");
//gameScore()
} else if (b1 == o && b4 == o && b7 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b2 == o && b5 == o && b8 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b3 == o && b6 == o && b9 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (b1 == o && b5 == o && b9 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore();
} else if (b3 == o && b5 == o && b7 == o) {
oCount++;
alertMsg("O");
reset();
//gameScore()
} else if (clickChecker[0] == 0 && clickChecker[1] == 0 && clickChecker[2] == 0 && clickChecker[3] == 0 && clickChecker[4] == 0 && clickChecker[5] == 0 && clickChecker[6] == 0 && clickChecker[7] == 0 && clickChecker[8] == 0) {
alertMsg("NO player wins");
reset();
}
} catch (Exception e) {
System.out.println("clicked");
}
if (counter == 9) {
alertMsg(" equal state no one win ");
reset();
return;
}
}
@FXML
public void drawTopLeft() throws FileNotFoundException {
// Client client = new Client("playWithOther","0","1",onlinePlayer.getValue().toString());
System.out.println(playerNickname + "essssssslam");
if (clickChecker[0] == 1) {
topleft.setImage(setImage());
if (img == x) {
playerPosition[0] = 1;
gameBoard[0][0] = 'x';
} else {
playerPosition[0] = 2;
}
clickChecker[0] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawTopCenter() throws FileNotFoundException {
if (clickChecker[1] == 1) {
topcenter.setImage(setImage());
if (img == x) {
playerPosition[1] = 1;
gameBoard[0][1] = 'x';
} else {
playerPosition[1] = 2;
}
clickChecker[1] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawTopRight() throws FileNotFoundException {
if (clickChecker[2] == 1) {
topright.setImage(setImage());
if (img == x) {
playerPosition[2] = 1;
gameBoard[0][2] = 'x';
} else {
playerPosition[2] = 2;
}
clickChecker[2] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterLeft() throws FileNotFoundException {
if (clickChecker[3] == 1) {
centerleft.setImage(setImage());
if (img == x) {
playerPosition[3] = 1;
gameBoard[1][0] = 'x';
} else {
playerPosition[3] = 2;
}
winningGame();
clickChecker[3] = 0;
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterCenter() throws FileNotFoundException {
if (clickChecker[4] == 1) {
centercenter.setImage(setImage());
if (img == x) {
playerPosition[4] = 1;
gameBoard[1][1] = 'x';
} else {
playerPosition[4] = 2;
}
clickChecker[4] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawCenterRight() throws FileNotFoundException {
if (clickChecker[5] == 1) {
centerright.setImage(setImage());
if (img == x) {
playerPosition[5] = 1;
gameBoard[1][2] = 'x';
} else {
playerPosition[5] = 2;
}
clickChecker[5] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomLeft() throws FileNotFoundException {
if (clickChecker[6] == 1) {
bottomleft.setImage(setImage());
if (img == x) {
playerPosition[6] = 1;
gameBoard[2][0] = 'x';
} else {
playerPosition[6] = 2;
}
clickChecker[6] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomCenter() throws FileNotFoundException {
if (clickChecker[7] == 1) {
bottomcenter.setImage(setImage());
if (img == x) {
playerPosition[7] = 1;
gameBoard[2][1] = 'x';
} else {
playerPosition[7] = 2;
}
clickChecker[7] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
@FXML
private void drawBottomRight() throws FileNotFoundException {
if (clickChecker[8] == 1) {
bottomright.setImage(setImage());
if (img == x) {
playerPosition[8] = 1;
gameBoard[2][2] = 'x';
} else {
playerPosition[8] = 2;
}
clickChecker[8] = 0;
winningGame();
if (flag == 1) {
computerMove();
winningGame();
}
flag = 1;
}
}
public void winVideo(String player) {
try {
root = FXMLLoader.load(getClass().getResource("MediaScreenWinner.fxml"));
} catch (IOException ex) {
Logger.getLogger(TwoPlayersLocalPlayController.class.getName()).log(Level.SEVERE, null, ex);
}
root.getStylesheets().add(getClass().getResource("css/menu-background.css").toString());
Scene scene = new Scene(root);
stage.setTitle(player);
stage.setScene(scene);
stage.show();
}
@FXML
void play(ActionEvent event) {
tictactoe.Tictactoe.mediaPlayer.play();
playBtn.setVisible(false);
stopBtn.setVisible(true);
}
@FXML
void stop(ActionEvent event) {
tictactoe.Tictactoe.mediaPlayer.stop();
playBtn.setVisible(true);
stopBtn.setVisible(false);
}
@Override
public void initialize(URL url, ResourceBundle rb) {
System.out.println(SingleController.playername);
playerName.setText(SingleController.playername);
playerscore.setText(tictactoe.LoginController.score);
try {
socket = new Socket("localhost", 5005);
in = new Scanner(socket.getInputStream());
out = new PrintWriter(socket.getOutputStream(), true);
} catch (Exception e) {
System.out.println(e);
}
}
}
| 21,046 | 0.484985 | 0.467927 | 727 | 27.949106 | 21.432762 | 238 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.570839 | false | false | 3 |
67cb96c36ccf1c0fb9e34736b436ac826d64be50 | 16,338,055,648,235 | 61916347aa9d426b8fe27023f2e0e873fe20eee5 | /src/main/java/com/sanver/basics/collections/HashSetSortingWithItsHashCode.java | 2b56ab4f230ea857d4dba4df4b402c3d0060a149 | [] | no_license | adacayi/java_basics | https://github.com/adacayi/java_basics | 8279f8b4cab0adf86583eaa07e4019c77878e329 | df389cf6dbba7ee58c161d6caf646e93c50bb49f | refs/heads/master | 2023-09-03T19:25:23.950000 | 2023-08-29T16:24:20 | 2023-08-29T16:24:20 | 133,782,859 | 0 | 0 | null | false | 2023-07-16T22:19:32 | 2018-05-17T08:27:28 | 2021-11-11T14:18:44 | 2023-07-16T22:19:32 | 1,538 | 0 | 0 | 3 | Java | false | false | package com.sanver.basics.collections;
import java.util.HashSet;
import java.util.Set;
public class HashSetSortingWithItsHashCode {
static class Person {
private String name;
public Person(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
@Override
public int hashCode() {
return name.charAt(4);
}
}
public static void main(String[] args) {
// HashSet sorts elements according to their HashCode
Set<Person> set = new HashSet<>();
set.add(new Person("Muhammed"));
set.add(new Person("Ahmet"));
set.add(new Person("Mustafa"));
System.out.println(set);
set.forEach(t -> System.out.printf("Value: %s Hash code: %s\n", t, t.hashCode())); // Hashcode changes order
// but couldn't understand how its does it
}
}
| UTF-8 | Java | 939 | java | HashSetSortingWithItsHashCode.java | Java | [
{
"context": "et = new HashSet<>();\n set.add(new Person(\"Muhammed\"));\n set.add(new Person(\"Ahmet\"));\n ",
"end": 646,
"score": 0.9995927810668945,
"start": 638,
"tag": "NAME",
"value": "Muhammed"
},
{
"context": " Person(\"Muhammed\"));\n set.add(new Person(\"Ahmet\"));\n set.add(new Person(\"Mustafa\"));\n ",
"end": 684,
"score": 0.9996383190155029,
"start": 679,
"tag": "NAME",
"value": "Ahmet"
},
{
"context": "new Person(\"Ahmet\"));\n set.add(new Person(\"Mustafa\"));\n System.out.println(set);\n set.",
"end": 724,
"score": 0.9996898770332336,
"start": 717,
"tag": "NAME",
"value": "Mustafa"
}
] | null | [] | package com.sanver.basics.collections;
import java.util.HashSet;
import java.util.Set;
public class HashSetSortingWithItsHashCode {
static class Person {
private String name;
public Person(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
@Override
public int hashCode() {
return name.charAt(4);
}
}
public static void main(String[] args) {
// HashSet sorts elements according to their HashCode
Set<Person> set = new HashSet<>();
set.add(new Person("Muhammed"));
set.add(new Person("Ahmet"));
set.add(new Person("Mustafa"));
System.out.println(set);
set.forEach(t -> System.out.printf("Value: %s Hash code: %s\n", t, t.hashCode())); // Hashcode changes order
// but couldn't understand how its does it
}
}
| 939 | 0.578275 | 0.57721 | 37 | 24.378378 | 23.024488 | 116 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.405405 | false | false | 3 |
c0c405736a9f8cc1f0cbd2764c1d7e4339d85d5f | 790,274,005,128 | c259424c330ea33266cf1381293e43d4b97f4c11 | /eo-db/src/main/java/org/fluentcodes/projects/elasticobjects/calls/db/DbModelsCreateCall.java | f3e4feb0ceea28a8d81b0ad873c6932b931dbc17 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-unknown"
] | permissive | fluentcodes/elasticobjects | https://github.com/fluentcodes/elasticobjects | 1acdfa829548ff94fb20dcf82d9aff9587bbbda7 | 8140990f4d3046c3fb1fa6b15d344a57330b9f38 | refs/heads/master | 2023-06-10T05:45:22.459000 | 2022-10-14T10:20:51 | 2022-10-14T10:20:51 | 153,377,625 | 0 | 1 | Apache-2.0 | false | 2023-05-26T22:12:33 | 2018-10-17T01:30:01 | 2022-01-07T08:46:38 | 2023-05-26T22:12:31 | 70,890 | 0 | 1 | 7 | Java | false | false | package org.fluentcodes.projects.elasticobjects.calls.db;
import org.fluentcodes.projects.elasticobjects.EOInterfaceScalar;
import org.fluentcodes.projects.elasticobjects.calls.PermissionType;
import org.fluentcodes.projects.elasticobjects.calls.commands.ConfigWriteCommand;
/**
* Remove an entry from database by creating a delete sql from entry in sourcePath.
*/
public class DbModelsCreateCall extends DbModelCall implements ConfigWriteCommand {
public DbModelsCreateCall() {
super();
}
public DbModelsCreateCall(final String hostConfigKey) {
super(hostConfigKey);
}
public DbModelsCreateCall(final String hostConfigKey, final String targetPath) {
super(hostConfigKey, targetPath);
}
@Override
public Object execute(final EOInterfaceScalar eo) {
return create(eo);
}
public Object create(final EOInterfaceScalar eo) {
DbModelsConfig config = init(PermissionType.CREATE, eo);
StringBuilder feedback = new StringBuilder("CREATE DATABASE: \n");
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
dbModelConfig.getDropStatement()
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append(dbModelConfig.getDropStatement());
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
}
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
dbModelConfig.getCreateStatement()
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append(dbModelConfig.getCreateStatement());
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
for (String unique: dbModelConfig.getUniqueList()) {
StatementPreparedValues uniqueStatement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
unique
);
int uniqueResponse = uniqueStatement.execute(config.getDbConfig().getConnection());
feedback.append(unique);
feedback.append(": ");
feedback.append(uniqueResponse);
feedback.append("\n");
}
}
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
for (String constraint: dbModelConfig.getForeignKeys()) {
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
constraint
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append("Constraint ");
feedback.append(constraint);
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
}
}
if (hasTargetPath()) {
eo.set(feedback.toString(), getTargetPath());
}
return feedback;
}
}
| UTF-8 | Java | 3,734 | java | DbModelsCreateCall.java | Java | [] | null | [] | package org.fluentcodes.projects.elasticobjects.calls.db;
import org.fluentcodes.projects.elasticobjects.EOInterfaceScalar;
import org.fluentcodes.projects.elasticobjects.calls.PermissionType;
import org.fluentcodes.projects.elasticobjects.calls.commands.ConfigWriteCommand;
/**
* Remove an entry from database by creating a delete sql from entry in sourcePath.
*/
public class DbModelsCreateCall extends DbModelCall implements ConfigWriteCommand {
public DbModelsCreateCall() {
super();
}
public DbModelsCreateCall(final String hostConfigKey) {
super(hostConfigKey);
}
public DbModelsCreateCall(final String hostConfigKey, final String targetPath) {
super(hostConfigKey, targetPath);
}
@Override
public Object execute(final EOInterfaceScalar eo) {
return create(eo);
}
public Object create(final EOInterfaceScalar eo) {
DbModelsConfig config = init(PermissionType.CREATE, eo);
StringBuilder feedback = new StringBuilder("CREATE DATABASE: \n");
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
dbModelConfig.getDropStatement()
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append(dbModelConfig.getDropStatement());
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
}
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
dbModelConfig.getCreateStatement()
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append(dbModelConfig.getCreateStatement());
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
for (String unique: dbModelConfig.getUniqueList()) {
StatementPreparedValues uniqueStatement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
unique
);
int uniqueResponse = uniqueStatement.execute(config.getDbConfig().getConnection());
feedback.append(unique);
feedback.append(": ");
feedback.append(uniqueResponse);
feedback.append("\n");
}
}
for (Class<?> modelClass: config.getDbModelClassSet()) {
DbModelConfig dbModelConfig = config.getDbModelConfig(modelClass);
for (String constraint: dbModelConfig.getForeignKeys()) {
StatementPreparedValues statement = new StatementPreparedValues(
StatementPreparedValues.SqlType.CREATE,
constraint
);
int executeResponse = statement.execute(config.getDbConfig().getConnection());
feedback.append("Constraint ");
feedback.append(constraint);
feedback.append(": ");
feedback.append(executeResponse);
feedback.append("\n");
}
}
if (hasTargetPath()) {
eo.set(feedback.toString(), getTargetPath());
}
return feedback;
}
}
| 3,734 | 0.62587 | 0.62587 | 88 | 41.43182 | 28.851419 | 99 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.545455 | false | false | 3 |
7a539fee7c9cd50738a87021f4f68b43d546d90d | 18,614,388,315,007 | 12ce9e88317b9f9abc5abac7d964fa1cecb7f1f0 | /app/src/main/java/CSTool/model/FileEvent.java | 7ff6f41e75f83a3afb22780768c61eeae45544ef | [
"Apache-2.0"
] | permissive | neruda000/CSTool | https://github.com/neruda000/CSTool | c34634656ae75e6dcb0298c5f85de25c4cfc7241 | 4fa0eed00ce377bad1021994f17a3773fe7a0b12 | refs/heads/main | 2023-09-01T01:30:03.019000 | 2021-10-19T15:11:34 | 2021-10-19T15:11:34 | 418,875,954 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package CSTool.model;
import java.io.Serializable;
import java.util.Objects;
public class FileEvent implements Serializable{
private static final long serialVersionUID = 6547375154140520270L;
private String id;
private Status state;
private String type;
private String host;
private long timestamp;
public FileEvent(String id, Status state) {
setState(state);
setId(id);
}
public FileEvent(String id) {
setId(id);
}
public enum Status {
STARTED, FINISHED
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Status getState() {
return state;
}
public void setState(Status state) {
this.state = state;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
@Override
public int hashCode() {
return Objects.hash(host, id, type);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FileEvent other = (FileEvent) obj;
return Objects.equals(host, other.host) && Objects.equals(id, other.id) && Objects.equals(type, other.type);
}
}
| UTF-8 | Java | 1,445 | java | FileEvent.java | Java | [] | null | [] | package CSTool.model;
import java.io.Serializable;
import java.util.Objects;
public class FileEvent implements Serializable{
private static final long serialVersionUID = 6547375154140520270L;
private String id;
private Status state;
private String type;
private String host;
private long timestamp;
public FileEvent(String id, Status state) {
setState(state);
setId(id);
}
public FileEvent(String id) {
setId(id);
}
public enum Status {
STARTED, FINISHED
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public Status getState() {
return state;
}
public void setState(Status state) {
this.state = state;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public long getTimestamp() {
return timestamp;
}
public void setTimestamp(long timestamp) {
this.timestamp = timestamp;
}
@Override
public int hashCode() {
return Objects.hash(host, id, type);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
FileEvent other = (FileEvent) obj;
return Objects.equals(host, other.host) && Objects.equals(id, other.id) && Objects.equals(type, other.type);
}
}
| 1,445 | 0.685121 | 0.671972 | 86 | 15.802325 | 17.617262 | 110 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.476744 | false | false | 3 |
fc4781f2b84e8d64fca7ba8deb187242abb9065a | 30,279,519,446,255 | 23dbb45d9d81dfd8be9053b90f3d7f7bedd77ee1 | /fluentgen/src/main/java/com/azure/autorest/fluent/model/clientmodel/fluentmodel/method/FluentConstructorByName.java | 575ac52150df0f6d928d8cb7ee94cc70cd918619 | [
"MIT",
"LicenseRef-scancode-generic-cla"
] | permissive | Azure/autorest.java | https://github.com/Azure/autorest.java | aa15d03b3024938305ea8eaf5f441c7928410f13 | 6d3a0b853cdaffa269231eeb1c2cb581161888cc | refs/heads/main | 2023-09-03T07:10:13.771000 | 2023-09-01T02:53:08 | 2023-09-01T02:53:08 | 100,315,700 | 34 | 81 | MIT | false | 2023-09-14T07:04:49 | 2017-08-14T22:53:39 | 2023-08-24T20:21:59 | 2023-09-14T07:04:47 | 203,551 | 29 | 78 | 124 | Java | false | false | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.autorest.fluent.model.clientmodel.fluentmodel.method;
import com.azure.autorest.fluent.model.clientmodel.FluentResourceModel;
import com.azure.autorest.fluent.model.clientmodel.ModelNaming;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.LocalVariable;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.ResourceLocalVariables;
import com.azure.autorest.model.clientmodel.ClassType;
import com.azure.autorest.model.clientmodel.IType;
import com.azure.autorest.model.clientmodel.ReturnValue;
import com.azure.autorest.model.javamodel.JavaJavadocComment;
import com.azure.autorest.model.javamodel.JavaVisibility;
import com.azure.autorest.template.prototype.MethodTemplate;
import java.util.Set;
public class FluentConstructorByName extends FluentMethod {
private final boolean constantResourceName; // resource name is constant, "name" is not needed
private final IType resourceNameType;
private final ClassType managerType;
public static FluentConstructorByName constructorMethodWithConstantResourceName(
FluentResourceModel model, FluentMethodType type, ClassType managerType, ResourceLocalVariables resourceLocalVariables) {
return new FluentConstructorByName(model, type, null, null, managerType, resourceLocalVariables);
}
public FluentConstructorByName(FluentResourceModel model, FluentMethodType type,
IType resourceNameType, String propertyNameForResourceName, ClassType managerType,
ResourceLocalVariables resourceLocalVariables) {
super(model, type);
this.constantResourceName = resourceNameType == null;
this.resourceNameType = resourceNameType;
this.managerType = managerType;
this.implementationReturnValue = new ReturnValue("", model.getImplementationType());
this.implementationMethodTemplate = MethodTemplate.builder()
.visibility(JavaVisibility.PackagePrivate)
.methodSignature(this.getImplementationMethodSignature())
.method(block -> {
block.line(String.format("this.%1$s = new %2$s();", ModelNaming.MODEL_PROPERTY_INNER, model.getInnerModel().getName()));
block.line(String.format("this.%1$s = %2$s;", ModelNaming.MODEL_PROPERTY_MANAGER, ModelNaming.MODEL_PROPERTY_MANAGER));
if (!constantResourceName) {
block.line(String.format("this.%1$s = name;", propertyNameForResourceName));
}
// init
resourceLocalVariables.getLocalVariablesMap().values().stream()
.filter(LocalVariable::isInitializeRequired)
.forEach(var -> {
block.line(String.format("this.%1$s = %2$s;", var.getName(), var.getInitializeExpression()));
});
})
.build();
}
@Override
public String getImplementationMethodSignature() {
if (constantResourceName) {
return String.format("%1$s(%2$s %3$s)",
implementationReturnValue.getType().toString(),
managerType.getFullName(), ModelNaming.MODEL_PROPERTY_MANAGER);
} else {
return String.format("%1$s(%2$s name, %3$s %4$s)",
implementationReturnValue.getType().toString(),
resourceNameType.toString(),
managerType.getFullName(), ModelNaming.MODEL_PROPERTY_MANAGER);
}
}
@Override
protected String getBaseMethodSignature() {
throw new UnsupportedOperationException();
}
@Override
public void writeJavadoc(JavaJavadocComment commentBlock) {
// NOOP
}
@Override
public void addImportsTo(Set<String> imports, boolean includeImplementationImports) {
if (includeImplementationImports) {
if (resourceNameType != null) {
resourceNameType.addImportsTo(imports, false);
}
/* use full name for FooManager, to avoid naming conflict
managerType.addImportsTo(imports, false);
*/
}
}
}
| UTF-8 | Java | 4,365 | java | FluentConstructorByName.java | Java | [] | null | [] | // Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.autorest.fluent.model.clientmodel.fluentmodel.method;
import com.azure.autorest.fluent.model.clientmodel.FluentResourceModel;
import com.azure.autorest.fluent.model.clientmodel.ModelNaming;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.LocalVariable;
import com.azure.autorest.fluent.model.clientmodel.fluentmodel.ResourceLocalVariables;
import com.azure.autorest.model.clientmodel.ClassType;
import com.azure.autorest.model.clientmodel.IType;
import com.azure.autorest.model.clientmodel.ReturnValue;
import com.azure.autorest.model.javamodel.JavaJavadocComment;
import com.azure.autorest.model.javamodel.JavaVisibility;
import com.azure.autorest.template.prototype.MethodTemplate;
import java.util.Set;
public class FluentConstructorByName extends FluentMethod {
private final boolean constantResourceName; // resource name is constant, "name" is not needed
private final IType resourceNameType;
private final ClassType managerType;
public static FluentConstructorByName constructorMethodWithConstantResourceName(
FluentResourceModel model, FluentMethodType type, ClassType managerType, ResourceLocalVariables resourceLocalVariables) {
return new FluentConstructorByName(model, type, null, null, managerType, resourceLocalVariables);
}
public FluentConstructorByName(FluentResourceModel model, FluentMethodType type,
IType resourceNameType, String propertyNameForResourceName, ClassType managerType,
ResourceLocalVariables resourceLocalVariables) {
super(model, type);
this.constantResourceName = resourceNameType == null;
this.resourceNameType = resourceNameType;
this.managerType = managerType;
this.implementationReturnValue = new ReturnValue("", model.getImplementationType());
this.implementationMethodTemplate = MethodTemplate.builder()
.visibility(JavaVisibility.PackagePrivate)
.methodSignature(this.getImplementationMethodSignature())
.method(block -> {
block.line(String.format("this.%1$s = new %2$s();", ModelNaming.MODEL_PROPERTY_INNER, model.getInnerModel().getName()));
block.line(String.format("this.%1$s = %2$s;", ModelNaming.MODEL_PROPERTY_MANAGER, ModelNaming.MODEL_PROPERTY_MANAGER));
if (!constantResourceName) {
block.line(String.format("this.%1$s = name;", propertyNameForResourceName));
}
// init
resourceLocalVariables.getLocalVariablesMap().values().stream()
.filter(LocalVariable::isInitializeRequired)
.forEach(var -> {
block.line(String.format("this.%1$s = %2$s;", var.getName(), var.getInitializeExpression()));
});
})
.build();
}
@Override
public String getImplementationMethodSignature() {
if (constantResourceName) {
return String.format("%1$s(%2$s %3$s)",
implementationReturnValue.getType().toString(),
managerType.getFullName(), ModelNaming.MODEL_PROPERTY_MANAGER);
} else {
return String.format("%1$s(%2$s name, %3$s %4$s)",
implementationReturnValue.getType().toString(),
resourceNameType.toString(),
managerType.getFullName(), ModelNaming.MODEL_PROPERTY_MANAGER);
}
}
@Override
protected String getBaseMethodSignature() {
throw new UnsupportedOperationException();
}
@Override
public void writeJavadoc(JavaJavadocComment commentBlock) {
// NOOP
}
@Override
public void addImportsTo(Set<String> imports, boolean includeImplementationImports) {
if (includeImplementationImports) {
if (resourceNameType != null) {
resourceNameType.addImportsTo(imports, false);
}
/* use full name for FooManager, to avoid naming conflict
managerType.addImportsTo(imports, false);
*/
}
}
}
| 4,365 | 0.659565 | 0.656357 | 96 | 44.46875 | 36.255157 | 140 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.739583 | false | false | 3 |
e9040abb0bf10fc46c46387fcb0c2ed78f6dc7aa | 5,566,277,676,548 | 81f0d033e0aeb8a75de1a337d8a08a23ad3335dc | /app/src/main/java/com/example/foodorderingapp/Common/Common.java | 71ff3b20519dff23d7de4e700a44ad0155de0a30 | [] | no_license | rsthind/FoodOrderingApp | https://github.com/rsthind/FoodOrderingApp | d05219fee6c21d950f5b2b14ef52b117428b6f8c | e0648ede3139c2912a1b129433bef6117ba55a2c | refs/heads/master | 2020-12-01T00:35:18.468000 | 2020-01-01T23:43:21 | 2020-01-01T23:43:21 | 230,522,442 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.example.foodorderingapp.Common;
import com.example.foodorderingapp.Model.User;
public class Common {
public static User currentUser;
}
| UTF-8 | Java | 155 | java | Common.java | Java | [] | null | [] | package com.example.foodorderingapp.Common;
import com.example.foodorderingapp.Model.User;
public class Common {
public static User currentUser;
}
| 155 | 0.787097 | 0.787097 | 9 | 16.222221 | 19.042513 | 46 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.333333 | false | false | 3 |
8482bd360ec851087b634e401c23d23dda7e30b7 | 24,077,586,666,556 | 3f3f6bf6637ed7c0737256d8d8923a8faa319cb2 | /presentation/src/main/java/presentation/models/messages/MessageModel.java | ee5f6b79f6346d4f010e7c4a99c42a60a96560c2 | [] | no_license | dtrilsbeek/RouteCalc | https://github.com/dtrilsbeek/RouteCalc | aa97745b89f0a27c2538f18bd7347f29b817c894 | 82726e243e999a0df9393fa3543843fd86e72d55 | refs/heads/master | 2021-06-30T04:42:21.740000 | 2020-01-22T11:07:07 | 2020-01-22T11:07:07 | 225,844,768 | 0 | 0 | null | false | 2021-03-10T23:31:19 | 2019-12-04T10:53:45 | 2020-01-22T11:07:15 | 2021-03-10T23:31:17 | 247 | 0 | 0 | 2 | Java | false | false | package presentation.models.messages;
public class MessageModel extends EmptyMessageModel {
private String message;
public MessageModel() {
}
public MessageModel(String message, String type) {
super(type);
this.message = message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
| UTF-8 | Java | 425 | java | MessageModel.java | Java | [] | null | [] | package presentation.models.messages;
public class MessageModel extends EmptyMessageModel {
private String message;
public MessageModel() {
}
public MessageModel(String message, String type) {
super(type);
this.message = message;
}
public void setMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}
| 425 | 0.64 | 0.64 | 23 | 17.47826 | 18.105656 | 54 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.304348 | false | false | 3 |
722deff7debca2b77cc8c4369882ae3102f91c51 | 31,834,297,600,073 | 41ef1bd8b195240fe3f4073e84df6024d6166840 | /src/main/java/com/sushi/shop/order/management/service/OrderService.java | 51b768eef4687205e5643f808fbc97ddc512db20 | [] | no_license | Vikas1717/LiveBarn | https://github.com/Vikas1717/LiveBarn | 05df0e0d7c8b25e200391b15bb073fda6bf1c0d5 | 3f9863641cf671aa22319a3d5a12f59af9d7d0e3 | refs/heads/main | 2023-08-07T18:04:08.659000 | 2021-09-28T16:40:59 | 2021-09-28T16:40:59 | 411,361,576 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sushi.shop.order.management.service;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sushi.shop.order.management.dao.OrderDao;
import com.sushi.shop.order.management.dto.OrderResponseDTO;
import com.sushi.shop.order.management.model.Status;
import com.sushi.shop.order.management.model.Sushi;
import com.sushi.shop.order.management.model.SushiOrder;
@Service
public class OrderService {
@Autowired
private OrderDao orderDao;
private List<Sushi> sushis;
private List<Status> statuses;
@PostConstruct
public void loadData() {
sushis=orderDao.loadSushi();
statuses=orderDao.loadStatus();
}
public int getSushiId(String name) {
System.out.println(sushis);
return sushis.stream().filter(obj->obj.getName().equalsIgnoreCase(name)).findAny().get().getId();
}
public int getStatusId(String name) {
System.out.println(statuses);
return statuses.stream().filter(obj->obj.getName().equalsIgnoreCase(name)).findAny().get().getId();
}
public OrderResponseDTO createOrder(Sushi sushi) {
SushiOrder sushiOrder=new SushiOrder();
sushiOrder.setSushiId(getSushiId(sushi.getName()));
sushiOrder.setStatusId(getStatusId("created"));
sushiOrder.setCreatedAt(new Timestamp(new Date().getTime()));
int status=orderDao.createOrder(sushiOrder);
OrderResponseDTO dto=new OrderResponseDTO();
if(status>0) {
sushiOrder.setId(status);
dto.setOrder(sushiOrder);
dto.setCode(0);
dto.setMsg("Order Created");
}
return dto;
}
public OrderResponseDTO updateOrder(Integer orderId,String statusVal) {
System.out.println("updat eto id :::"+getStatusId(statusVal));
int status= orderDao.updateOrder(orderId, getStatusId(statusVal));
System.out.println("sttaus:::::"+status);
OrderResponseDTO dto=new OrderResponseDTO();
if(status>=0) {
dto.setCode(0);
dto.setMsg("Order cancelled");
}
return dto;
}
public List<Map<String, Object>> getOrdersByStatus() {
return orderDao.getOderbyStatus();
}
}
| UTF-8 | Java | 2,187 | java | OrderService.java | Java | [] | null | [] | package com.sushi.shop.order.management.service;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sushi.shop.order.management.dao.OrderDao;
import com.sushi.shop.order.management.dto.OrderResponseDTO;
import com.sushi.shop.order.management.model.Status;
import com.sushi.shop.order.management.model.Sushi;
import com.sushi.shop.order.management.model.SushiOrder;
@Service
public class OrderService {
@Autowired
private OrderDao orderDao;
private List<Sushi> sushis;
private List<Status> statuses;
@PostConstruct
public void loadData() {
sushis=orderDao.loadSushi();
statuses=orderDao.loadStatus();
}
public int getSushiId(String name) {
System.out.println(sushis);
return sushis.stream().filter(obj->obj.getName().equalsIgnoreCase(name)).findAny().get().getId();
}
public int getStatusId(String name) {
System.out.println(statuses);
return statuses.stream().filter(obj->obj.getName().equalsIgnoreCase(name)).findAny().get().getId();
}
public OrderResponseDTO createOrder(Sushi sushi) {
SushiOrder sushiOrder=new SushiOrder();
sushiOrder.setSushiId(getSushiId(sushi.getName()));
sushiOrder.setStatusId(getStatusId("created"));
sushiOrder.setCreatedAt(new Timestamp(new Date().getTime()));
int status=orderDao.createOrder(sushiOrder);
OrderResponseDTO dto=new OrderResponseDTO();
if(status>0) {
sushiOrder.setId(status);
dto.setOrder(sushiOrder);
dto.setCode(0);
dto.setMsg("Order Created");
}
return dto;
}
public OrderResponseDTO updateOrder(Integer orderId,String statusVal) {
System.out.println("updat eto id :::"+getStatusId(statusVal));
int status= orderDao.updateOrder(orderId, getStatusId(statusVal));
System.out.println("sttaus:::::"+status);
OrderResponseDTO dto=new OrderResponseDTO();
if(status>=0) {
dto.setCode(0);
dto.setMsg("Order cancelled");
}
return dto;
}
public List<Map<String, Object>> getOrdersByStatus() {
return orderDao.getOderbyStatus();
}
}
| 2,187 | 0.7508 | 0.748971 | 80 | 26.3375 | 24.234243 | 101 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.7375 | false | false | 3 |
a8f9dad56015514817bfcec563ab0bf9e24e153c | 4,191,888,143,805 | ce6c9ae88b545bf75dcb7fe4c3f7e2521c4b4efa | /src/main/java/com/tahir/project/model/FeedUsed.java | 8a42e1bedb9dd93d49e753fbc66e6cb868ade388 | [] | no_license | Abudl-Majid/cattle_farm | https://github.com/Abudl-Majid/cattle_farm | f438b2fdea6c7fe9412cf02ca160d6bf6554e38e | c50f75a685523313196b84be7d22d01b2bfd74e2 | refs/heads/master | 2021-01-20T07:46:08.551000 | 2017-05-26T11:37:58 | 2017-05-26T11:37:58 | 90,040,376 | 0 | 1 | null | false | 2017-05-05T11:22:35 | 2017-05-02T14:05:30 | 2017-05-02T14:17:11 | 2017-05-05T11:22:35 | 40,728 | 0 | 1 | 0 | JavaScript | null | null | package com.tahir.project.model;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Date;
/**
* Created by Tahir on 1/12/2017.
*/
@Entity
@Table(name = "feed_used", catalog = "cattlefarm")
public class FeedUsed implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", unique = true, nullable = false)
private Integer id;
@Column(name = "QUANTITY")
private
float quantity;
@ManyToOne ( fetch=FetchType.EAGER ) //employ lazy loading, you can put that on @OneToMany too
@JoinColumn( name="ANIMAL_ID", nullable=false )
private
Animal animal;
public FeedUsed(){
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public float getQuantity() {
return quantity;
}
public void setQuantity(float quantity) {
this.quantity = quantity;
}
public Animal getAnimal() {
return animal;
}
public void setAnimal(Animal animal) {
this.animal = animal;
}
}
| UTF-8 | Java | 1,134 | java | FeedUsed.java | Java | [
{
"context": "gDecimal;\nimport java.sql.Date;\n\n/**\n * Created by Tahir on 1/12/2017.\n */\n@Entity\n@Table(name = \"feed_use",
"end": 166,
"score": 0.998774528503418,
"start": 161,
"tag": "NAME",
"value": "Tahir"
}
] | null | [] | package com.tahir.project.model;
import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.sql.Date;
/**
* Created by Tahir on 1/12/2017.
*/
@Entity
@Table(name = "feed_used", catalog = "cattlefarm")
public class FeedUsed implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "ID", unique = true, nullable = false)
private Integer id;
@Column(name = "QUANTITY")
private
float quantity;
@ManyToOne ( fetch=FetchType.EAGER ) //employ lazy loading, you can put that on @OneToMany too
@JoinColumn( name="ANIMAL_ID", nullable=false )
private
Animal animal;
public FeedUsed(){
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public float getQuantity() {
return quantity;
}
public void setQuantity(float quantity) {
this.quantity = quantity;
}
public Animal getAnimal() {
return animal;
}
public void setAnimal(Animal animal) {
this.animal = animal;
}
}
| 1,134 | 0.635802 | 0.62963 | 54 | 20 | 19.828897 | 98 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.351852 | false | false | 3 |
1fb3132ebef81f6735516769a029fbdef961ac7d | 6,493,990,567,881 | 7c62ca50a77efac8501118a3994aa5c6b56a0396 | /games/trunk/code/src/server/lobby/HandlerLogin.java | 65e8b849c0c4123c067589e47d3af4d674787d5c | [] | no_license | tryonn/CarRent | https://github.com/tryonn/CarRent | 170555b467d776ec4ba49586893d615504397b7a | f4386c18a9c1a8ea3654043e6276b6f27be1e0fb | refs/heads/master | 2021-01-17T05:21:38.161000 | 2012-09-17T19:35:17 | 2012-09-17T19:35:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package server.lobby;
import java.io.IOException;
import java.util.Iterator;
import java.util.Vector;
import server.Constantes;
import server.Protocol;
import server.Util;
import server.management.IthreadAmadeus;
import server.management.PoolThread;
public class HandlerLogin implements IthreadAmadeus{
private static HandlerLogin instance = null;
private static PoolThread instancePoolThread = null;
private Vector protocols;
private HandlerLogin(){
protocols = new Vector();
}
public static HandlerLogin getInstance(){
if(instance == null){
instance = new HandlerLogin();
Thread t = new PoolThread();
t.start();
}
return instance;
}
//Adiciona a instancio do HandlerLogin na fila do PoolThread
public void addProtocol(Protocol protocol) {
protocols.addElement(protocol);
add( (IthreadAmadeus) instance);
}
//Transfere o protocolo ao PoolLobby e depois exclui o protocolo de sua lista
public void work() throws IOException{
Iterator i =protocols.iterator();
while(i.hasNext()){
Protocol temp = (Protocol)i.next();
if(temp.isReady()){
directLobby(temp);
i.remove();
}
}
}
private void directLobby(Protocol protocol) throws IOException {
try{
StringBuffer msg = new StringBuffer("");
msg.append( protocol.getCommand() );
if ( msg.substring(0,5).equals( Integer.toString(Constantes.LOBBY) +
Integer.toString(Constantes.CLIENTE_SERVIDOR)+Constantes.L_CS_LoginUser) ){
protocol.setNome( (Util.getParametro(1,msg)).toString() );
PoolLobby pollLobby = PoolLobby.getInstance();
pollLobby.userToYourLobby(protocol, Integer.parseInt((Util.getParametro(2,msg)).toString()));
}
} catch (Exception e) {
System.out.println("Ocorreu um erro na entrega do cliente ao LOBBY");
//e.printStackTrace();
}
}
public void add(IthreadAmadeus hl){
if ( instancePoolThread == null){
instancePoolThread = PoolThread.getInstance();
instancePoolThread.newIthreadAmadeus( (IthreadAmadeus) hl);
}
}
}
| UTF-8 | Java | 2,103 | java | HandlerLogin.java | Java | [] | null | [] | package server.lobby;
import java.io.IOException;
import java.util.Iterator;
import java.util.Vector;
import server.Constantes;
import server.Protocol;
import server.Util;
import server.management.IthreadAmadeus;
import server.management.PoolThread;
public class HandlerLogin implements IthreadAmadeus{
private static HandlerLogin instance = null;
private static PoolThread instancePoolThread = null;
private Vector protocols;
private HandlerLogin(){
protocols = new Vector();
}
public static HandlerLogin getInstance(){
if(instance == null){
instance = new HandlerLogin();
Thread t = new PoolThread();
t.start();
}
return instance;
}
//Adiciona a instancio do HandlerLogin na fila do PoolThread
public void addProtocol(Protocol protocol) {
protocols.addElement(protocol);
add( (IthreadAmadeus) instance);
}
//Transfere o protocolo ao PoolLobby e depois exclui o protocolo de sua lista
public void work() throws IOException{
Iterator i =protocols.iterator();
while(i.hasNext()){
Protocol temp = (Protocol)i.next();
if(temp.isReady()){
directLobby(temp);
i.remove();
}
}
}
private void directLobby(Protocol protocol) throws IOException {
try{
StringBuffer msg = new StringBuffer("");
msg.append( protocol.getCommand() );
if ( msg.substring(0,5).equals( Integer.toString(Constantes.LOBBY) +
Integer.toString(Constantes.CLIENTE_SERVIDOR)+Constantes.L_CS_LoginUser) ){
protocol.setNome( (Util.getParametro(1,msg)).toString() );
PoolLobby pollLobby = PoolLobby.getInstance();
pollLobby.userToYourLobby(protocol, Integer.parseInt((Util.getParametro(2,msg)).toString()));
}
} catch (Exception e) {
System.out.println("Ocorreu um erro na entrega do cliente ao LOBBY");
//e.printStackTrace();
}
}
public void add(IthreadAmadeus hl){
if ( instancePoolThread == null){
instancePoolThread = PoolThread.getInstance();
instancePoolThread.newIthreadAmadeus( (IthreadAmadeus) hl);
}
}
}
| 2,103 | 0.691393 | 0.689491 | 82 | 23.646341 | 23.360573 | 96 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 2.012195 | false | false | 3 |
567e5158e066228ce6f9c331724ada706e1e1a51 | 20,598,663,210,031 | af9ae6e3a6320028684310a9a06ff756e1e0e1b7 | /neo4j-migrations-core/src/main/java/ac/simons/neo4j/migrations/core/LifecycleEvent.java | 2229cde081ad195dc3ff25081cbdeb66553779e1 | [
"Apache-2.0"
] | permissive | michael-simons/neo4j-migrations | https://github.com/michael-simons/neo4j-migrations | 9f472f6f2e4facf5721a1722eecdfa9dce1919cb | 15c190f10a863ff6b4c134e9f9e6f38bab82e75d | refs/heads/main | 2023-08-17T09:11:36.728000 | 2023-08-14T08:13:01 | 2023-08-14T08:13:01 | 232,664,319 | 95 | 17 | Apache-2.0 | false | 2023-09-11T04:52:04 | 2020-01-08T21:33:52 | 2023-08-25T17:01:24 | 2023-09-11T04:52:01 | 76,620 | 96 | 20 | 15 | Java | false | false | /*
* Copyright 2020-2023 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ac.simons.neo4j.migrations.core;
/**
* An event in the lifecycle of a migration.
*
* @author Michael J. Simons
* @since 1.2.2
*/
interface LifecycleEvent {
/**
* @return the phase in which the event happened
*/
LifecyclePhase getPhase();
/**
* @return the global migration context
*/
MigrationContext getContext();
}
| UTF-8 | Java | 967 | java | LifecycleEvent.java | Java | [
{
"context": "ent in the lifecycle of a migration.\n *\n * @author Michael J. Simons\n * @since 1.2.2\n */\ninterface LifecycleEvent {\n\n\t",
"end": 744,
"score": 0.9998511075973511,
"start": 727,
"tag": "NAME",
"value": "Michael J. Simons"
}
] | null | [] | /*
* Copyright 2020-2023 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ac.simons.neo4j.migrations.core;
/**
* An event in the lifecycle of a migration.
*
* @author <NAME>
* @since 1.2.2
*/
interface LifecycleEvent {
/**
* @return the phase in which the event happened
*/
LifecyclePhase getPhase();
/**
* @return the global migration context
*/
MigrationContext getContext();
}
| 956 | 0.717684 | 0.701138 | 35 | 26.628571 | 25.895489 | 75 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.457143 | false | false | 3 |
593a02cf68f984859229ca50e29fdc075322e07c | 10,093,173,172,639 | 14746c4b8511abe301fd470a152de627327fe720 | /soroush-android-1.10.0_source_from_JADX/com/google/android/gms/p160b/C1689a.java | 73f214cba87cb0263da588f75cba52b2f3427079 | [] | no_license | maasalan/soroush-messenger-apis | https://github.com/maasalan/soroush-messenger-apis | 3005c4a43123c6543dbcca3dd9084f95e934a6f4 | 29867bf53a113a30b1aa36719b1c7899b991d0a8 | refs/heads/master | 2020-03-21T21:23:20.693000 | 2018-06-28T19:57:01 | 2018-06-28T19:57:01 | 139,060,676 | 3 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.google.android.gms.p160b;
public interface C1689a {
void mo3005a();
}
| UTF-8 | Java | 87 | java | C1689a.java | Java | [] | null | [] | package com.google.android.gms.p160b;
public interface C1689a {
void mo3005a();
}
| 87 | 0.724138 | 0.597701 | 5 | 16.4 | 14.221111 | 37 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.4 | false | false | 3 |
7054571e1cab268b6f2fb520961649163505d698 | 28,862,180,280,087 | e57da34371967fc1c24225f549abcf810be8158e | /src/main/java/com/feue/missyou/api/v1/BannerController.java | 6341e78928516d698cfc108d48880cd8e374dcb9 | [] | no_license | Feue/online_retailers | https://github.com/Feue/online_retailers | 93309eabf94aee3e68d392c2a56453c1021fe340 | e76cd1ba6cd3a7432887373064bb474779926382 | refs/heads/master | 2023-07-06T00:18:21.398000 | 2021-08-12T07:51:45 | 2021-08-12T07:51:45 | 389,309,234 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.feue.missyou.api.v1;
import com.feue.missyou.Service.BannerService;
import com.feue.missyou.core.interceptors.ScopeLevel;
import com.feue.missyou.dto.PersonDTO;
import com.feue.missyou.exception.http.ForbiddenException;
import com.feue.missyou.exception.http.NotFoundException;
import com.feue.missyou.model.Banner;
import com.feue.missyou.sample.IConnect;
import com.feue.missyou.sample.ISkill;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
/**
* @author Feue
* @create 2021-06-04 16:28
*/
//@Lazy // 延迟加载标记
@RestController
@RequestMapping("/banner")
@Validated
public class BannerController {
@Autowired
private BannerService bannerService;
@GetMapping("/name/{name}")
@ScopeLevel
public Banner getByName(@PathVariable @NotBlank String name) {
Banner banner = bannerService.getByName(name);
if (banner == null) {
throw new NotFoundException(30005);
}
return banner;
}
} | UTF-8 | Java | 1,286 | java | BannerController.java | Java | [
{
"context": "x.validation.constraints.NotBlank;\n\n/**\n * @author Feue\n * @create 2021-06-04 16:28\n */\n//@Lazy // 延迟加载标记",
"end": 791,
"score": 0.8695015907287598,
"start": 787,
"tag": "USERNAME",
"value": "Feue"
}
] | null | [] | package com.feue.missyou.api.v1;
import com.feue.missyou.Service.BannerService;
import com.feue.missyou.core.interceptors.ScopeLevel;
import com.feue.missyou.dto.PersonDTO;
import com.feue.missyou.exception.http.ForbiddenException;
import com.feue.missyou.exception.http.NotFoundException;
import com.feue.missyou.model.Banner;
import com.feue.missyou.sample.IConnect;
import com.feue.missyou.sample.ISkill;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotBlank;
/**
* @author Feue
* @create 2021-06-04 16:28
*/
//@Lazy // 延迟加载标记
@RestController
@RequestMapping("/banner")
@Validated
public class BannerController {
@Autowired
private BannerService bannerService;
@GetMapping("/name/{name}")
@ScopeLevel
public Banner getByName(@PathVariable @NotBlank String name) {
Banner banner = bannerService.getByName(name);
if (banner == null) {
throw new NotFoundException(30005);
}
return banner;
}
} | 1,286 | 0.764521 | 0.750392 | 41 | 30.073172 | 20.187403 | 66 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.487805 | false | false | 3 |
9f6d23d124f218b397c078d4d6a5ad7dae512941 | 6,167,573,044,880 | 37616c49d057f88724fb88425b7f87b41a0a03f3 | /Matcha_ItemStack/src/main/java/net/matcha/matcha_itemstack/commands/Item.java | ad1c8c8fd078adf1b8fa1e6a9b7af04b1a9d9289 | [] | no_license | Ikirudo/MatchaRPGServerPlugins | https://github.com/Ikirudo/MatchaRPGServerPlugins | 3ceb31f87129645437ae25235217e61038823565 | 3145422a126c4cf0e28c1031de293c7cdff39841 | refs/heads/master | 2020-04-14T18:41:19.983000 | 2019-01-22T09:52:52 | 2019-01-22T09:52:52 | 164,029,322 | 0 | 2 | null | false | 2019-04-09T10:17:34 | 2019-01-03T22:28:30 | 2019-01-22T09:53:05 | 2019-01-22T09:53:03 | 564 | 0 | 1 | 1 | Java | false | false | package net.matcha.matcha_itemstack.commands;
import net.matcha.matcha_itemstack.Matcha_ItemStack;
import net.matcha.matcha_itemstack.util.Prefixs;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Item implements CommandExecutor {
private Matcha_ItemStack plugin = (Matcha_ItemStack)Matcha_ItemStack.getPlugin(Matcha_ItemStack.class);
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage(this.plugin.prefix.getErrorPrefix + "プレイヤーのみ");
return true;
}
if (args.length == 0)
{
sendHelp((Player)sender);
return true;
}
switch (args[0])
{
//deprecated
}
sendHelp((Player)sender);
return true;
}
private void sendHelp(Player sender)
{
//deprecated
}
} | UTF-8 | Java | 1,056 | java | Item.java | Java | [] | null | [] | package net.matcha.matcha_itemstack.commands;
import net.matcha.matcha_itemstack.Matcha_ItemStack;
import net.matcha.matcha_itemstack.util.Prefixs;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class Item implements CommandExecutor {
private Matcha_ItemStack plugin = (Matcha_ItemStack)Matcha_ItemStack.getPlugin(Matcha_ItemStack.class);
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage(this.plugin.prefix.getErrorPrefix + "プレイヤーのみ");
return true;
}
if (args.length == 0)
{
sendHelp((Player)sender);
return true;
}
switch (args[0])
{
//deprecated
}
sendHelp((Player)sender);
return true;
}
private void sendHelp(Player sender)
{
//deprecated
}
} | 1,056 | 0.651631 | 0.649712 | 38 | 26.447369 | 25.565908 | 107 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.447368 | false | false | 3 |
8092a425662c359e97632f0e00e7290c4efa7cd6 | 28,535,762,746,496 | a5e810f96f51bb5aa2808c3607316c3c36cec65b | /PropertiesLocator/PropertyLocatorAddition/build/classes/com/java/SourceKeyForm.java | 9cf758266a17290ac0902eec74da676d6404c032 | [] | no_license | kevin-lii/Properties-Locator | https://github.com/kevin-lii/Properties-Locator | c0151e5abc4001b04105bb26309694a1ea779a80 | 6cde57ed5e3ab54e166b96eee7a0830012b29ca0 | refs/heads/master | 2020-04-03T21:08:07.310000 | 2019-08-25T07:12:17 | 2019-08-25T07:12:17 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.java;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.struts.action.ActionForm;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SourceKeyForm extends ActionForm {
public String source = null;
public String key = null;
private Map<String, String> storageMap = new HashMap<String, String>();
public SourceKeyForm() {
super();
}
public String getSource() {
return source;
}
public String getKey() {
return key;
}
public void setSource(String source) {
this.source = source;
}
public void setKey(String key) {
this.key = key;
}
}
| UTF-8 | Java | 859 | java | SourceKeyForm.java | Java | [] | null | [] | package com.java;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.struts.action.ActionForm;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class SourceKeyForm extends ActionForm {
public String source = null;
public String key = null;
private Map<String, String> storageMap = new HashMap<String, String>();
public SourceKeyForm() {
super();
}
public String getSource() {
return source;
}
public String getKey() {
return key;
}
public void setSource(String source) {
this.source = source;
}
public void setKey(String key) {
this.key = key;
}
}
| 859 | 0.749709 | 0.745052 | 40 | 20.475 | 17.020557 | 72 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.25 | false | false | 3 |
a6a2ae432a722efd35a4550655488e870b3a7094 | 15,040,975,488,846 | 4fae0bbfecd806c7ea1156e39de65ace29eb08d6 | /hibernate_cache_level_1/src/main/java/hibernate/hibernate_cache_level_1/dao/UserDao.java | 642ce625986dc20890f50038eb5f06594b1be6e2 | [] | no_license | xgwfhn/hibernate4.2 | https://github.com/xgwfhn/hibernate4.2 | 69b6bb2016ff6ed1c5781245bd1c325cb2342d78 | ea654b8b1f30912367455f7d4fc2b0f57f5710b8 | refs/heads/master | 2021-01-18T00:47:45.168000 | 2016-10-10T04:02:03 | 2016-10-10T04:02:03 | 68,528,793 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package hibernate.hibernate_cache_level_1.dao;
import hibernate.hibernate_cache_level_1.entity.user.User;
import java.util.List;
public interface UserDao extends BaseDao<User> {
public List<User> queryUser(String openid, String date);
}
| UTF-8 | Java | 252 | java | UserDao.java | Java | [] | null | [] | package hibernate.hibernate_cache_level_1.dao;
import hibernate.hibernate_cache_level_1.entity.user.User;
import java.util.List;
public interface UserDao extends BaseDao<User> {
public List<User> queryUser(String openid, String date);
}
| 252 | 0.757937 | 0.75 | 9 | 26 | 25.046623 | 58 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.666667 | false | false | 3 |
671b004a69d760a78bb9f57062475d614013aebf | 5,248,450,088,429 | 47ea9fd7a8634312e825dc24d29931a7f8a1b626 | /sfpp-web/src/main/java/com/sf/sfpp/web/user/shiro/CaptchaUsernamePasswordToken.java | f45f5cac6c7cdcaaf5050d9131aa484cf83cbb28 | [] | no_license | HashZhang/sfpp | https://github.com/HashZhang/sfpp | 7b3bab05450844f909552bbd68e6a8471af11122 | ce74477babed050c86e1f282719f8da5a14c16f6 | refs/heads/master | 2016-08-25T06:27:56.559000 | 2016-08-24T08:10:29 | 2016-08-24T08:10:29 | 65,202,782 | 0 | 2 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.sf.sfpp.web.user.shiro;
import org.apache.shiro.authc.UsernamePasswordToken;
/**
* Created by rqzheng on 2016/3/8.
*/
public class CaptchaUsernamePasswordToken extends UsernamePasswordToken {
private static final long serialVersionUID = -2793965333840597519L;
private String captcha;
public CaptchaUsernamePasswordToken(String username, char[] password, boolean rememberMe, String captcha) {
super(username, password, rememberMe);
this.captcha = captcha;
}
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
}
| UTF-8 | Java | 658 | java | CaptchaUsernamePasswordToken.java | Java | [
{
"context": "ro.authc.UsernamePasswordToken;\n\n/**\n * Created by rqzheng on 2016/3/8.\n */\npublic class CaptchaUsernamePass",
"end": 116,
"score": 0.9996547102928162,
"start": 109,
"tag": "USERNAME",
"value": "rqzheng"
}
] | null | [] | package com.sf.sfpp.web.user.shiro;
import org.apache.shiro.authc.UsernamePasswordToken;
/**
* Created by rqzheng on 2016/3/8.
*/
public class CaptchaUsernamePasswordToken extends UsernamePasswordToken {
private static final long serialVersionUID = -2793965333840597519L;
private String captcha;
public CaptchaUsernamePasswordToken(String username, char[] password, boolean rememberMe, String captcha) {
super(username, password, rememberMe);
this.captcha = captcha;
}
public String getCaptcha() {
return captcha;
}
public void setCaptcha(String captcha) {
this.captcha = captcha;
}
}
| 658 | 0.711246 | 0.673252 | 26 | 24.307692 | 28.25947 | 111 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.5 | false | false | 3 |
96378ebfbf4922744a63569df3c441382e267f30 | 1,924,145,380,793 | f691f4fbc5e55bacaad2d28061b887a4fa0b7427 | /src/main/java/com/alpha5/autoaid/dto/request/AddSectionRequest.java | b96b794100f1090443a221d0712568eff3e826c9 | [
"MIT"
] | permissive | Hasantha96/autoaid-API-1 | https://github.com/Hasantha96/autoaid-API-1 | fe48b910cab053604183147fbe08927e2fdad1a3 | 93354758f9f9ec7424e650530866b4679dc325d3 | refs/heads/main | 2023-08-12T13:49:09.464000 | 2021-10-13T19:11:52 | 2021-10-13T19:11:52 | 377,477,757 | 0 | 0 | null | true | 2021-08-12T21:25:45 | 2021-06-16T11:48:55 | 2021-08-12T19:36:10 | 2021-08-12T21:25:45 | 295 | 0 | 0 | 0 | Java | false | false | package com.alpha5.autoaid.dto.request;
public class AddSectionRequest {
private String sectionName;
public String getSectionName() {
return sectionName;
}
public void setSectionName(String sectionName) {
this.sectionName = sectionName;
}
}
| UTF-8 | Java | 280 | java | AddSectionRequest.java | Java | [] | null | [] | package com.alpha5.autoaid.dto.request;
public class AddSectionRequest {
private String sectionName;
public String getSectionName() {
return sectionName;
}
public void setSectionName(String sectionName) {
this.sectionName = sectionName;
}
}
| 280 | 0.696429 | 0.692857 | 13 | 20.538462 | 18.236124 | 52 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.307692 | false | false | 3 |
dcb98f80dce114765b2a970cfff7b9316fda658d | 1,924,145,382,089 | cb87baa76e20e1ca7cd254f5552ca8e49587433e | /src/main/java/slc/mb/GraficoLinhaBean.java | eb60d6d846776a1f0d57ce73e45e7f0f624963d0 | [] | no_license | vunge7/GestPTApp | https://github.com/vunge7/GestPTApp | 3a713cc7f48f4fad4a9c152a5e48bcd2a19d884a | ee666df8b8efe921ed2fd321a591057f4a6430de | refs/heads/master | 2023-04-01T19:53:50.432000 | 2021-04-04T18:17:31 | 2021-04-04T18:17:31 | 327,698,122 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package slc.mb;
/**
*
* @author Domingos Dala Vunge
*/
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.inject.Named;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.CategoryAxis;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartModel;
@Named( value = "graficoLinhaBean" )
public class GraficoLinhaBean implements Serializable
{
private LineChartModel lineModel1;
@PostConstruct
public void init()
{
createLineModels();
}
public CartesianChartModel getLineModel1()
{
return lineModel1;
}
private void createLineModels()
{
lineModel1 = initLinearModel();
lineModel1.setTitle( "Pesquisa de Opinião" );
lineModel1.setLegendPosition( "e" );
lineModel1.setShowPointLabels( true );
lineModel1.getAxes().put( AxisType.X, new CategoryAxis( "Pesquisas" ) );
lineModel1.setZoom( true );
Axis yAxis = lineModel1.getAxis( AxisType.Y );
yAxis.setLabel( "% de votos" );
yAxis.setMin( 0 );
yAxis.setMax( 100 );
}
private LineChartModel initLinearModel()
{
LineChartModel model = new LineChartModel();
ChartSeries series1 = new ChartSeries();
series1.setLabel( "Candidato 1" );
series1.set( "Pesquisa 1", 40 );
series1.set( "Pesquisa 2", 42 );
series1.set( "Pesquisa 3", 47 );
series1.set( "Pesquisa 4", 44 );
series1.set( "Pesquisa 5", 40 );
ChartSeries series2 = new ChartSeries();
series2.setLabel( "Candidato 2" );
series2.set( "Pesquisa 1", 20 );
series2.set( "Pesquisa 2", 22 );
series2.set( "Pesquisa 3", 26 );
series2.set( "Pesquisa 4", 25 );
series2.set( "Pesquisa 5", 29 );
ChartSeries series3 = new ChartSeries();
series3.setLabel( "Candidato 3" );
series3.set( "Pesquisa 1", 10 );
series3.set( "Pesquisa 2", 12 );
series3.set( "Pesquisa 3", 16 );
series3.set( "Pesquisa 4", 15 );
series3.set( "Pesquisa 5", 19 );
model.addSeries( series1 );
model.addSeries( series2 );
model.addSeries( series3 );
return model;
}
}
| UTF-8 | Java | 2,576 | java | GraficoLinhaBean.java | Java | [
{
"context": "the editor.\n */\npackage slc.mb;\n\n/**\n *\n * @author Domingos Dala Vunge\n */\nimport java.io.Serializable;\nimport javax.ann",
"end": 239,
"score": 0.9998709559440613,
"start": 220,
"tag": "NAME",
"value": "Domingos Dala Vunge"
}
] | null | [] | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package slc.mb;
/**
*
* @author <NAME>
*/
import java.io.Serializable;
import javax.annotation.PostConstruct;
import javax.inject.Named;
import org.primefaces.model.chart.Axis;
import org.primefaces.model.chart.AxisType;
import org.primefaces.model.chart.CartesianChartModel;
import org.primefaces.model.chart.CategoryAxis;
import org.primefaces.model.chart.ChartSeries;
import org.primefaces.model.chart.LineChartModel;
@Named( value = "graficoLinhaBean" )
public class GraficoLinhaBean implements Serializable
{
private LineChartModel lineModel1;
@PostConstruct
public void init()
{
createLineModels();
}
public CartesianChartModel getLineModel1()
{
return lineModel1;
}
private void createLineModels()
{
lineModel1 = initLinearModel();
lineModel1.setTitle( "Pesquisa de Opinião" );
lineModel1.setLegendPosition( "e" );
lineModel1.setShowPointLabels( true );
lineModel1.getAxes().put( AxisType.X, new CategoryAxis( "Pesquisas" ) );
lineModel1.setZoom( true );
Axis yAxis = lineModel1.getAxis( AxisType.Y );
yAxis.setLabel( "% de votos" );
yAxis.setMin( 0 );
yAxis.setMax( 100 );
}
private LineChartModel initLinearModel()
{
LineChartModel model = new LineChartModel();
ChartSeries series1 = new ChartSeries();
series1.setLabel( "Candidato 1" );
series1.set( "Pesquisa 1", 40 );
series1.set( "Pesquisa 2", 42 );
series1.set( "Pesquisa 3", 47 );
series1.set( "Pesquisa 4", 44 );
series1.set( "Pesquisa 5", 40 );
ChartSeries series2 = new ChartSeries();
series2.setLabel( "Candidato 2" );
series2.set( "Pesquisa 1", 20 );
series2.set( "Pesquisa 2", 22 );
series2.set( "Pesquisa 3", 26 );
series2.set( "Pesquisa 4", 25 );
series2.set( "Pesquisa 5", 29 );
ChartSeries series3 = new ChartSeries();
series3.setLabel( "Candidato 3" );
series3.set( "Pesquisa 1", 10 );
series3.set( "Pesquisa 2", 12 );
series3.set( "Pesquisa 3", 16 );
series3.set( "Pesquisa 4", 15 );
series3.set( "Pesquisa 5", 19 );
model.addSeries( series1 );
model.addSeries( series2 );
model.addSeries( series3 );
return model;
}
}
| 2,563 | 0.633398 | 0.6 | 93 | 26.688171 | 20.74317 | 80 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.731183 | false | false | 3 |
1f0ece5ea920f06a86a64035d4460510f2f935f1 | 22,840,636,111,466 | 79a1b9a436c824e97ee24264150cc87292b74b17 | /src/main/java/step/Cities.java | 71cfa7dfee115907d4b36a77a30d502116b37afb | [] | no_license | siriusgurban/stepproject- | https://github.com/siriusgurban/stepproject- | ba3380a2c2d0a78c76a9614c4a6cc33e19c79603 | e06161597f9db11313fc4c3e6d79fd62c8835d65 | refs/heads/master | 2020-09-09T14:39:26.591000 | 2019-12-11T17:06:34 | 2019-12-11T17:06:34 | 221,473,416 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package step;
import step.entity.City;
import step.entity.Country;
import step.io.IOCity;
import step.io.IOCountry;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class Cities implements Iterable<City>{
private final Countries countries = new Countries();
City city1 = new City(1, "Riga",countries.country1);
City city2 = new City(2, "Valletta",countries.country2);
City city3 = new City(3, "Tokyo",countries.country3);
City city4 = new City(4, "Helsinki",countries.country4);
City city5 = new City(5, "Paris",countries.country5);
City city6 = new City(6, "Sofia",countries.country6);
City city7 = new City(7, "Roma",countries.country7);
City city8 = new City(8, "Vienna",countries.country8);
City city9 = new City(9, "Nicosia",countries.country9);
City city10 = new City(10, "Budapest",countries.country10);
City city11 = new City(11, "Tallinn",countries.country11);
City city12 = new City(12, "Tirana",countries.country12);
City city13 = new City(13, "Athens",countries.country13);
City city14 = new City(14, "Beijing",countries.country14);
City city15 = new City(15, "Brussels",countries.country15);
City city16 = new City(16, "London",countries.country16);
City city17 = new City(17, "Stockholm",countries.country17);
City city18 = new City(18, "Berlin",countries.country18);
City city19 = new City(19, "Washington",countries.country19);
City city20 = new City(20, "Copenhagen",countries.country20);
private final List<City> data = Arrays.asList(city1, city2, city3, city4, city5,
city6, city7, city8, city9, city10,
city11, city12, city13, city14, city15,
city16, city17, city18, city19, city20
);
@Override
public Iterator<City> iterator() {
return data.iterator();
}
public void create(){
IOCity ioCity = new IOCity();
data.forEach(city -> {
try {
ioCity.write(city);
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
| UTF-8 | Java | 2,041 | java | Cities.java | Java | [] | null | [] | package step;
import step.entity.City;
import step.entity.Country;
import step.io.IOCity;
import step.io.IOCountry;
import java.io.IOException;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
public class Cities implements Iterable<City>{
private final Countries countries = new Countries();
City city1 = new City(1, "Riga",countries.country1);
City city2 = new City(2, "Valletta",countries.country2);
City city3 = new City(3, "Tokyo",countries.country3);
City city4 = new City(4, "Helsinki",countries.country4);
City city5 = new City(5, "Paris",countries.country5);
City city6 = new City(6, "Sofia",countries.country6);
City city7 = new City(7, "Roma",countries.country7);
City city8 = new City(8, "Vienna",countries.country8);
City city9 = new City(9, "Nicosia",countries.country9);
City city10 = new City(10, "Budapest",countries.country10);
City city11 = new City(11, "Tallinn",countries.country11);
City city12 = new City(12, "Tirana",countries.country12);
City city13 = new City(13, "Athens",countries.country13);
City city14 = new City(14, "Beijing",countries.country14);
City city15 = new City(15, "Brussels",countries.country15);
City city16 = new City(16, "London",countries.country16);
City city17 = new City(17, "Stockholm",countries.country17);
City city18 = new City(18, "Berlin",countries.country18);
City city19 = new City(19, "Washington",countries.country19);
City city20 = new City(20, "Copenhagen",countries.country20);
private final List<City> data = Arrays.asList(city1, city2, city3, city4, city5,
city6, city7, city8, city9, city10,
city11, city12, city13, city14, city15,
city16, city17, city18, city19, city20
);
@Override
public Iterator<City> iterator() {
return data.iterator();
}
public void create(){
IOCity ioCity = new IOCity();
data.forEach(city -> {
try {
ioCity.write(city);
} catch (IOException e) {
e.printStackTrace();
}
});
}
}
| 2,041 | 0.689368 | 0.628613 | 60 | 33 | 23.710054 | 82 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.583333 | false | false | 3 |
086d8d679ad35124e6ff585d8a07326a6ec55f4e | 13,099,650,317,629 | 885e2667ceb32b82fa18bd5808ac315143003aa1 | /AtCoder/ABC/ABC197/B/Main.java | 24aa2ac8215f4ab5a1561fa6cddd553b2c31f5ff | [] | no_license | T45K/kyopuro | https://github.com/T45K/kyopuro | f804b1c73c8c1404ffcc5e2070ad518495abf4e7 | 74df98c0b83be246fdcc8846fec5cbfdcf29e6bc | refs/heads/master | 2023-06-29T14:14:49.033000 | 2023-06-11T14:14:32 | 2023-06-11T14:14:32 | 154,971,544 | 2 | 0 | null | false | 2020-07-25T14:14:24 | 2018-10-27T14:08:20 | 2020-07-25T10:13:06 | 2020-07-25T14:14:23 | 716 | 0 | 0 | 0 | Java | false | false | package AtCoder.ABC.ABC197.B;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(final String[] args) {
final FastScanner scanner = new FastScanner(System.in);
final int h = scanner.nextInt();
final int w = scanner.nextInt();
final int x = scanner.nextInt() - 1;
final int y = scanner.nextInt() - 1;
final boolean[][] table = new boolean[h][w];
for (int i = 0; i < h; i++) {
final String s = scanner.next();
for (int j = 0; j < w; j++) {
table[i][j] = s.charAt(j) == '.';
}
}
int count = 1;
for (int i = x - 1; i >= 0 && table[i][y]; i--) {
count++;
}
for (int i = x + 1; i < h && table[i][y]; i++) {
count++;
}
for (int j = y - 1; j >= 0 && table[x][j]; j--) {
count++;
}
for (int j = y + 1; j < w && table[x][j]; j++) {
count++;
}
System.out.println(count);
}
private static class FastScanner {
private final BufferedReader reader;
private StringTokenizer tokenizer;
FastScanner(final InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
}
String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
}
}
| UTF-8 | Java | 1,873 | java | Main.java | Java | [] | null | [] | package AtCoder.ABC.ABC197.B;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(final String[] args) {
final FastScanner scanner = new FastScanner(System.in);
final int h = scanner.nextInt();
final int w = scanner.nextInt();
final int x = scanner.nextInt() - 1;
final int y = scanner.nextInt() - 1;
final boolean[][] table = new boolean[h][w];
for (int i = 0; i < h; i++) {
final String s = scanner.next();
for (int j = 0; j < w; j++) {
table[i][j] = s.charAt(j) == '.';
}
}
int count = 1;
for (int i = x - 1; i >= 0 && table[i][y]; i--) {
count++;
}
for (int i = x + 1; i < h && table[i][y]; i++) {
count++;
}
for (int j = y - 1; j >= 0 && table[x][j]; j--) {
count++;
}
for (int j = y + 1; j < w && table[x][j]; j++) {
count++;
}
System.out.println(count);
}
private static class FastScanner {
private final BufferedReader reader;
private StringTokenizer tokenizer;
FastScanner(final InputStream in) {
reader = new BufferedReader(new InputStreamReader(in));
}
String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (final IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
}
}
| 1,873 | 0.491725 | 0.48425 | 63 | 28.730158 | 20.082533 | 71 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.650794 | false | false | 3 |
cd216eab79d3b82cc770f8747cd23f8427695796 | 32,487,132,681,462 | f70fdc2f27fdf9efff2fbdbdba9630a714b43816 | /src/main/java/br/com/robhawk/financas/resources/MovimentacoesResource.java | a3b9fb48777a9486637f9d3bd3c3289c4408b0ab | [] | no_license | RobHawk90/minhas-financas-java-rest-api | https://github.com/RobHawk90/minhas-financas-java-rest-api | 1f2d1bcbd42f009eb59e704170a9e04d5223b1bf | 2d704c35126b9b29d694a5bb823e6220c42467ce | refs/heads/master | 2021-01-10T16:13:58.942000 | 2016-02-13T14:31:18 | 2016-02-13T14:31:18 | 48,922,866 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package br.com.robhawk.financas.resources;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.eclipse.jetty.http.HttpStatus.CREATED_201;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import br.com.robhawk.financas.daos.MovimentacaoDAO;
import br.com.robhawk.financas.daos.ParcelaDAO;
import br.com.robhawk.financas.models.Movimentacao;
import br.com.robhawk.financas.models.Parcela;
@Path("/movimentacoes")
public class MovimentacoesResource {
private final MovimentacaoDAO dao;
private final ParcelaDAO parcelaDAO;
public MovimentacoesResource() {
dao = new MovimentacaoDAO();
parcelaDAO = new ParcelaDAO();
}
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response salvaMovimentacao(Movimentacao movimentacao) {
movimentacao.constroiParcelasSeNecessario();
boolean sucesso = dao.insere(movimentacao);
if (sucesso)
return Response.ok(movimentacao).status(CREATED_201).build();
return Response.serverError().build();
}
@PUT
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/parcela")
public Response atualizaParcela(Parcela parcela) {
if (parcela.getDataPagamento() == null)
parcela.setDataPagamento(parcela.getDataVencimento());
boolean sucesso = parcelaDAO.atualiza(parcela);
if (sucesso)
return Response.ok(parcelaDAO.buscaPor(parcela.getId())).build();
return Response.serverError().build();
}
@DELETE
@Path("/{id}")
public Response removeMovimentacao(@PathParam("id") int id) {
if (dao.deleta(id))
return Response.noContent().build();
return Response.serverError().build();
}
@GET
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{id}")
public Response buscaMovimentacaoPorId(@PathParam("id") int id) {
Movimentacao movimentacao = dao.buscaPor(id);
if (movimentacao == null)
return Response.status(404).build();
return Response.ok(movimentacao).build();
}
}
| UTF-8 | Java | 2,130 | java | MovimentacoesResource.java | Java | [] | null | [] | package br.com.robhawk.financas.resources;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.eclipse.jetty.http.HttpStatus.CREATED_201;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import br.com.robhawk.financas.daos.MovimentacaoDAO;
import br.com.robhawk.financas.daos.ParcelaDAO;
import br.com.robhawk.financas.models.Movimentacao;
import br.com.robhawk.financas.models.Parcela;
@Path("/movimentacoes")
public class MovimentacoesResource {
private final MovimentacaoDAO dao;
private final ParcelaDAO parcelaDAO;
public MovimentacoesResource() {
dao = new MovimentacaoDAO();
parcelaDAO = new ParcelaDAO();
}
@POST
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
public Response salvaMovimentacao(Movimentacao movimentacao) {
movimentacao.constroiParcelasSeNecessario();
boolean sucesso = dao.insere(movimentacao);
if (sucesso)
return Response.ok(movimentacao).status(CREATED_201).build();
return Response.serverError().build();
}
@PUT
@Consumes(APPLICATION_JSON)
@Produces(APPLICATION_JSON)
@Path("/parcela")
public Response atualizaParcela(Parcela parcela) {
if (parcela.getDataPagamento() == null)
parcela.setDataPagamento(parcela.getDataVencimento());
boolean sucesso = parcelaDAO.atualiza(parcela);
if (sucesso)
return Response.ok(parcelaDAO.buscaPor(parcela.getId())).build();
return Response.serverError().build();
}
@DELETE
@Path("/{id}")
public Response removeMovimentacao(@PathParam("id") int id) {
if (dao.deleta(id))
return Response.noContent().build();
return Response.serverError().build();
}
@GET
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@Path("/{id}")
public Response buscaMovimentacaoPorId(@PathParam("id") int id) {
Movimentacao movimentacao = dao.buscaPor(id);
if (movimentacao == null)
return Response.status(404).build();
return Response.ok(movimentacao).build();
}
}
| 2,130 | 0.75493 | 0.750704 | 83 | 24.662651 | 20.757507 | 68 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.240964 | false | false | 3 |
0ff1f1e34bafe82a8fa6c8d872cf18b469e2f6b2 | 29,119,878,314,673 | 7e17bcc81f74eb8da539e902761df63048f768be | /Scripting/src/aron/sinoai/templatemaniac/scripting/model/matcher/ByteMatch.java | f77cde7b3d1dfce73b753d008afed648f2c27c80 | [] | no_license | arnoldvakaria/TemplateManiac | https://github.com/arnoldvakaria/TemplateManiac | 72a82ff3e904b8bb84b0a7b1b18b508f741e71cb | 6d21388cf013658e77374ec949dbbbdde13acffe | refs/heads/master | 2020-04-02T18:55:36.892000 | 2014-02-14T22:45:05 | 2014-02-14T22:45:05 | null | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package aron.sinoai.templatemaniac.scripting.model.matcher;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.xerces.impl.dv.util.Base64;
import aron.sinoai.templatemaniac.scripting.model.ScriptingContext;
import aron.sinoai.templatemaniac.scripting.model.ScriptingItem;
@XmlRootElement(name = "byte-match")
@XmlAccessorType(XmlAccessType.FIELD)
public class ByteMatch extends MatcherItemWithStringBase {
public ByteMatch() {
super();
}
@Override
public void compile(ScriptingContext context, ScriptingItem parent) {
super.compile(context, parent);
setTheString(new String(Base64.decode(getTheString())));
}
protected boolean isAMatchOverride() {
Source source = getSource();
String theString = getTheString();
boolean isMatch = source.isAValidPosition(source.getPos() + theString.length() - 1)
&& (theString.equals(source.getParseString(theString.length())));
if (isMatch) {
source.incPos(theString.length());
}
return isMatch;
}
}
| UTF-8 | Java | 1,095 | java | ByteMatch.java | Java | [] | null | [] | package aron.sinoai.templatemaniac.scripting.model.matcher;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.apache.xerces.impl.dv.util.Base64;
import aron.sinoai.templatemaniac.scripting.model.ScriptingContext;
import aron.sinoai.templatemaniac.scripting.model.ScriptingItem;
@XmlRootElement(name = "byte-match")
@XmlAccessorType(XmlAccessType.FIELD)
public class ByteMatch extends MatcherItemWithStringBase {
public ByteMatch() {
super();
}
@Override
public void compile(ScriptingContext context, ScriptingItem parent) {
super.compile(context, parent);
setTheString(new String(Base64.decode(getTheString())));
}
protected boolean isAMatchOverride() {
Source source = getSource();
String theString = getTheString();
boolean isMatch = source.isAValidPosition(source.getPos() + theString.length() - 1)
&& (theString.equals(source.getParseString(theString.length())));
if (isMatch) {
source.incPos(theString.length());
}
return isMatch;
}
}
| 1,095 | 0.770776 | 0.76621 | 38 | 27.81579 | 25.721029 | 85 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 1.447368 | false | false | 3 |
5d6c6d4864753bb7e573480e1d70b8ab0078878e | 12,738,873,039,393 | 0cf1361def051f5b51638d9d5f130980e545011c | /cf1360B.java | 38c1a202d7bd4faeac44ae6eb9f71d34015070a3 | [] | no_license | njw95/Java | https://github.com/njw95/Java | 8d6d7c5bb758c98e10d3bcb80572229db586180f | c7dff5c0ec5c04bc3cd7409b644cda9613c7ccc7 | refs/heads/master | 2023-08-24T08:59:30.482000 | 2021-10-23T10:03:51 | 2021-10-23T10:03:51 | 333,238,458 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | import java.util.Arrays;
import java.util.Scanner;
public class cf1360B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt();
int[] s = new int[n];
for(int i=0; i<n; i++) {
s[i] = sc.nextInt();
}
Arrays.sort(s);
int mi = Integer.MAX_VALUE;
for(int i=1; i<n; i++) {
mi = Math.min(s[i] - s[i-1] , mi);
}
System.out.println(mi);
}
sc.close();
}
} | UTF-8 | Java | 623 | java | cf1360B.java | Java | [] | null | [] | import java.util.Arrays;
import java.util.Scanner;
public class cf1360B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt();
int[] s = new int[n];
for(int i=0; i<n; i++) {
s[i] = sc.nextInt();
}
Arrays.sort(s);
int mi = Integer.MAX_VALUE;
for(int i=1; i<n; i++) {
mi = Math.min(s[i] - s[i-1] , mi);
}
System.out.println(mi);
}
sc.close();
}
} | 623 | 0.425361 | 0.41252 | 27 | 22.111111 | 15.659179 | 50 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.62963 | false | false | 3 |
85509aa084f08712d381c72ac4b94e8e1ceb6f49 | 12,738,873,040,120 | 3c5db55e7356dd54c13bc596c9d05c9f2983615a | /WRM-API/src/main/java/com/wrm/model/UserResponse.java | cac3b334acb8f6f717b60280162e166a6105571a | [
"Apache-2.0"
] | permissive | Clair-Water-Consultants/WRM | https://github.com/Clair-Water-Consultants/WRM | b4c96ec9b81db1cd821e25edef62f280414fa725 | 1069ffcac5a04de4ad102eba15158ac995061b59 | refs/heads/master | 2020-09-19T13:31:30.614000 | 2016-10-22T19:40:25 | 2016-10-22T19:40:25 | 66,762,050 | 1 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.wrm.model;
import java.util.Date;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;
/**
* UserResponse
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-09-04T10:25:35.178Z")
public class UserResponse {
private String id = null;
private String name = null;
private String pass = null;
private String groupId = null;
private String firstName = null;
private String lastName = null;
private String emailId = null;
private Boolean category = false;
private Date createdTime = null;
private Date updatedTime = null;
public UserResponse id(String id) {
this.id = id;
return this;
}
/**
* unique identifier of the user inserted
* @return id
**/
@ApiModelProperty(value = "unique identifier of the user inserted")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public UserResponse name(String name) {
this.name = name;
return this;
}
/**
* unique userid (alphanumberic) of the user
* @return name
**/
@ApiModelProperty(value = "unique userid (alphanumberic) of the user")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UserResponse pass(String pass) {
this.pass = pass;
return this;
}
/**
* password of the user
* @return pass
**/
@ApiModelProperty(value = "password of the user")
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public UserResponse groupId(String groupId) {
this.groupId = groupId;
return this;
}
/**
* groupId that this user belongs to
* @return groupId
**/
@ApiModelProperty(value = "groupId that this user belongs to")
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public UserResponse firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* first name of the user
* @return firstName
**/
@ApiModelProperty(value = "first name of the user")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public UserResponse lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* last name of the user
* @return lastName
**/
@ApiModelProperty(value = "last name of the user")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public UserResponse emailId(String emailId) {
this.emailId = emailId;
return this;
}
/**
* emailId of the user
* @return emailId
**/
@ApiModelProperty(value = "emailId of the user")
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
@ApiModelProperty(value = "category of user")
public Boolean getCategory() {
return category;
}
public void setCategory(Boolean category) {
this.category = category;
}
public UserResponse createdTime(Date createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* time when the user is added to database
* @return createdTime
**/
@ApiModelProperty(value = "time when the user is added to database")
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public UserResponse updatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
return this;
}
/**
* time this user row is recently updated
* @return updatedTime
**/
@ApiModelProperty(value = "time this user row is recently updated")
public Date getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserResponse userResponse = (UserResponse) o;
return Objects.equals(this.id, userResponse.id) &&
Objects.equals(this.name, userResponse.name) &&
Objects.equals(this.pass, userResponse.pass) &&
Objects.equals(this.groupId, userResponse.groupId) &&
Objects.equals(this.firstName, userResponse.firstName) &&
Objects.equals(this.lastName, userResponse.lastName) &&
Objects.equals(this.emailId, userResponse.emailId) &&
Objects.equals(this.category, userResponse.category) &&
Objects.equals(this.createdTime, userResponse.createdTime) &&
Objects.equals(this.updatedTime, userResponse.updatedTime);
}
@Override
public int hashCode() {
return Objects.hash(id, name, pass, groupId, firstName, lastName, emailId, category, createdTime, updatedTime);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UserResponse {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" pass: ").append(toIndentedString(pass)).append("\n");
sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" emailId: ").append(toIndentedString(emailId)).append("\n");
sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append(" createdTime: ").append(toIndentedString(createdTime)).append("\n");
sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).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 ");
}
}
| UTF-8 | Java | 6,531 | java | UserResponse.java | Java | [
{
"context": "firstName(String firstName) {\n this.firstName = firstName;\n return this;\n }\n\n /**\n * first name of ",
"end": 2255,
"score": 0.8846542239189148,
"start": 2246,
"tag": "NAME",
"value": "firstName"
},
{
"context": "{\n return Objects.hash(id, name, pass, groupId, firstName, lastName, emailId, category, createdTime, update",
"end": 5216,
"score": 0.875070333480835,
"start": 5207,
"tag": "NAME",
"value": "firstName"
},
{
"context": "n Objects.hash(id, name, pass, groupId, firstName, lastName, emailId, category, createdTime, updatedTime);\n ",
"end": 5226,
"score": 0.904606282711029,
"start": 5218,
"tag": "NAME",
"value": "lastName"
}
] | null | [] | package com.wrm.model;
import java.util.Date;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.joda.time.DateTime;
/**
* UserResponse
*/
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringCodegen", date = "2016-09-04T10:25:35.178Z")
public class UserResponse {
private String id = null;
private String name = null;
private String pass = null;
private String groupId = null;
private String firstName = null;
private String lastName = null;
private String emailId = null;
private Boolean category = false;
private Date createdTime = null;
private Date updatedTime = null;
public UserResponse id(String id) {
this.id = id;
return this;
}
/**
* unique identifier of the user inserted
* @return id
**/
@ApiModelProperty(value = "unique identifier of the user inserted")
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public UserResponse name(String name) {
this.name = name;
return this;
}
/**
* unique userid (alphanumberic) of the user
* @return name
**/
@ApiModelProperty(value = "unique userid (alphanumberic) of the user")
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public UserResponse pass(String pass) {
this.pass = pass;
return this;
}
/**
* password of the user
* @return pass
**/
@ApiModelProperty(value = "password of the user")
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public UserResponse groupId(String groupId) {
this.groupId = groupId;
return this;
}
/**
* groupId that this user belongs to
* @return groupId
**/
@ApiModelProperty(value = "groupId that this user belongs to")
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public UserResponse firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* first name of the user
* @return firstName
**/
@ApiModelProperty(value = "first name of the user")
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public UserResponse lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* last name of the user
* @return lastName
**/
@ApiModelProperty(value = "last name of the user")
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public UserResponse emailId(String emailId) {
this.emailId = emailId;
return this;
}
/**
* emailId of the user
* @return emailId
**/
@ApiModelProperty(value = "emailId of the user")
public String getEmailId() {
return emailId;
}
public void setEmailId(String emailId) {
this.emailId = emailId;
}
@ApiModelProperty(value = "category of user")
public Boolean getCategory() {
return category;
}
public void setCategory(Boolean category) {
this.category = category;
}
public UserResponse createdTime(Date createdTime) {
this.createdTime = createdTime;
return this;
}
/**
* time when the user is added to database
* @return createdTime
**/
@ApiModelProperty(value = "time when the user is added to database")
public Date getCreatedTime() {
return createdTime;
}
public void setCreatedTime(Date createdTime) {
this.createdTime = createdTime;
}
public UserResponse updatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
return this;
}
/**
* time this user row is recently updated
* @return updatedTime
**/
@ApiModelProperty(value = "time this user row is recently updated")
public Date getUpdatedTime() {
return updatedTime;
}
public void setUpdatedTime(Date updatedTime) {
this.updatedTime = updatedTime;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserResponse userResponse = (UserResponse) o;
return Objects.equals(this.id, userResponse.id) &&
Objects.equals(this.name, userResponse.name) &&
Objects.equals(this.pass, userResponse.pass) &&
Objects.equals(this.groupId, userResponse.groupId) &&
Objects.equals(this.firstName, userResponse.firstName) &&
Objects.equals(this.lastName, userResponse.lastName) &&
Objects.equals(this.emailId, userResponse.emailId) &&
Objects.equals(this.category, userResponse.category) &&
Objects.equals(this.createdTime, userResponse.createdTime) &&
Objects.equals(this.updatedTime, userResponse.updatedTime);
}
@Override
public int hashCode() {
return Objects.hash(id, name, pass, groupId, firstName, lastName, emailId, category, createdTime, updatedTime);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UserResponse {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" pass: ").append(toIndentedString(pass)).append("\n");
sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" emailId: ").append(toIndentedString(emailId)).append("\n");
sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append(" createdTime: ").append(toIndentedString(createdTime)).append("\n");
sb.append(" updatedTime: ").append(toIndentedString(updatedTime)).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 ");
}
}
| 6,531 | 0.662839 | 0.660083 | 267 | 23.456928 | 23.737978 | 122 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 0.382022 | false | false | 3 |
7c5fa11b73f4163c48fce58ffb2295ff87bb7995 | 32,710,470,944,469 | 99751836e13190748740671f22fe0b53ed8d04f6 | /autointerface/src/main/java/com/answern/automatest4inter/util/CsvUtils.java | db082bb3544347cf1706f9a00fdf4f69bc44a1b6 | [] | no_license | itasher/answern_automation | https://github.com/itasher/answern_automation | 518d7eb9c6d541cccc97bdb1a07241e62eefdc7c | 21df0052c3614d0c536029d2b04a6613d2cad077 | refs/heads/master | 2018-10-24T23:49:22.506000 | 2018-09-14T10:23:53 | 2018-09-14T10:23:53 | 145,087,903 | 0 | 0 | null | null | null | null | null | null | null | null | null | null | null | null | null | package com.answern.automatest4inter.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.answern.automatest4inter.config.Constants;
import com.answern.automatest4inter.config.KW;
import com.answern.automatest4inter.exception.CommonException;
import com.csvreader.CsvReader;
/**
*
* @author 张志刚 2017年8月19日 下午6:39:09
* @功能 : 数据驱动工具类
* 从CSV格式的文件中读取数据且封装到List中
*/
public class CsvUtils {
private CsvUtils() {}
/**
* <p>
* Title : 从指定的CSV格式的资源文件中获取内容,将内容封装成List<Map<String, String>>形式返回
* CSV第一行内容是标题,对应的是Map中的key
* 其他行的内容是values,通过逗号进行隔开
* 相对jar包路径
* </p>
* @author 张志刚 2017年8月19日 下午6:42:26
* @param ppath 资源文件路径,相对路径
* @param encoding 编码格式
*/
public static List<Map<String, String>> readCsv(String path, String encoding) throws IOException {
if(path.trim().toLowerCase().endsWith(".map")) return readMapFile(path);
if(path.trim().toLowerCase().endsWith(".json")) return readJSONFile(path);
List<Map<String, String>> resList =new ArrayList<>();
CsvReader reader = new CsvReader(CsvUtils.class.getResourceAsStream(path),',', Charset.forName(encoding));
reader.setSafetySwitch(false);
reader.setUseComments(true);
reader.readHeaders();
int i = reader.getHeaderCount();
String[] headers = new String[i];
for(int j=0;j<=i-1;j++){
headers[j] = reader.getHeader(j);
}
while (reader.readRecord()) {
if("".equals(reader.getRawRecord()) || reader.getRawRecord()==null) continue;
Map<String,String> map = new HashMap<>();
for(int j=0;j<=i-1;j++) {
map.put(headers[j], reader.get(headers[j]));
}
resList.add(map);
}
reader.close();
/**
* 调整异常CSV中testKey和testValue的数据
*/
for(Map<String, String> map : resList) {
Set<String> set = new HashSet<>(map.keySet());
for(String key : set) {
if(StringHelper.isEmpty(key)) continue;
if(key.startsWith(KW.testKey)) {
String testKey = map.get(key);
String testValue = map.get(key.replace(KW.testKey, KW.testValue));
map.put(testKey, testValue);
}
}
}
return resList;
}
/**
* @author 张志刚 2017年8月22日 下午4:13:38
* @param path
* @功能 : 从csv中获取数据封装成List对象,缺省enconding参数,默认为UTF-8
*/
public static List<Map<String, String>> readCsv(String path) throws IOException {
return readCsv(path, Constants.encoding_UTF8);
}
/**
* @author 张志刚 2018年1月29日 下午6:03:21
* @param path
* @param channelCode
* @功能 : 新增方法,可以在反向case或者正向case中省去channelCode的编写, 通过代码填充渠道编号
*/
public static List<Map<String, String>> readCsvAndFillChannelCode(String path, String channelCode) throws IOException{
List<Map<String, String>> result = readCsv(path);
for(Map<String, String> map : result) {
map.putIfAbsent(KW.channelCode, channelCode);
}
return result;
}
/**
* @author 张志刚 2017年11月6日 下午7:21:47
* @param rightpath 正确报文填充内容的文件地址
* @功能 : 根据正确数据文件填充map
* 1. 通过packageHeaderAndChannelInfo获取了包含了所有公共字段的map
* 2. 根据rightpath得到为当前接口预置的字段以及值
* 3. 将预置的字段以及值,填充到正确的map中,此时得到一个包含了所有正确数值的一条数据
*/
public static Map<String, String> readRightMapCsv(String rightpath) throws IOException {
Map<String, String> rightDataMap = new HashMap<>();
List<Map<String, String>> dataList = readCsv(rightpath);
for(Map<String, String> map : dataList) {
String fieldName = map.get(KW.fieldName);
String fieldValue = map.get(KW.fieldValue);
rightDataMap.put(fieldName, fieldValue);
}
return rightDataMap;
}
/**
* @author 张志刚 2017年11月13日 下午6:16:58
* @param path
* @功能 : 根据map类型的文件,读取异常case填充的数据
* 可以编写的格式
*
* 1. 可兼容最后一行以逗号(,)结尾
* 2. 可兼容中间行不以逗号(,)号结尾
* 3. 可以兼容多个key值写在一行内
* 4. 可以兼容一行中有逗号(,)存在,但是这一行不可填写多个key值
* 5. 不可兼容key或者value中存在等号(=)
*
*/
public static List<Map<String, String>> readMapFile(String path) throws IOException {
/**
* 定义一些初始变量
*/
URL url = CsvUtils.class.getResource(path);
InputStream is = null;
BufferedReader reader = null;
List<Map<String, String>> res = new ArrayList<>();
try{
is = url.openStream();
reader = new BufferedReader(new InputStreamReader(is));
int lineNum = 1;
boolean start = false;
boolean end = false;
Map<String, String> map = new HashMap<>();
String line = "";
String channelCode = "";
String productCode = "";
String responseCode = "";
/**
* 循环读取每一行数据
*/
while((line = reader.readLine()) != null) {
/**
* 1. 空行跳过
* 2. 注释行跳过
*/
lineNum++;
line = line.trim();
if(StringHelper.isEmpty(line) || line.startsWith("#")) continue;
/**
* 获取全局变量——channelCode、productCode、responseCode
*/
if(line.toLowerCase().startsWith("@set")) {
String[] arr = line.substring(4).split("=");
String key = arr[0].trim();
String value = arr[1].trim().replace(";", "").replace(";", "");
if(key.equals(KW.channelCode)) {
channelCode = value;
} else if(key.equals(KW.productCode)) {
productCode = value;
} else if(key.equals(KW.responseCode)) {
responseCode = value;
}
continue;
}
/**
* 1. 以 { 作为case的开始标识
* 2. 以 } 作为case的结束标识
* 3. 去除行尾的(, 逗号)
*/
if(line.startsWith("{")) {
start = true;
line = line.substring(1).trim();
}
if(line.endsWith("}")) {
end = true;
line = line.substring(0, line.length() - 1).trim();
}
if(line.endsWith(",")) {
line = line.substring(0, line.length() - 1).trim();
}
/**
* 剔除符号之后如何不为空,则执行数据填充进map
* 1. lineArr.length > 2 : 表示当前行是多个键值对
* 2. lineArr.length == 2: 表示当前行是标准的一个键值对
* 3. lineArr.length == 1: 表示当前行是一个非标准的键值对(只有key, 没有value)
*/
if(StringHelper.isNotEmpty(line)) {
String[] lineArr = line.split("=");
if(lineArr.length > 2) {
String[] arr = line.split(",");
for(String str :arr) {
str = str.trim();
if(str.endsWith(",")) str = str.substring(0, str.length() - 1);
if(StringHelper.isEmpty(str)) continue;
String[] arr2 = str.split("=");
if(arr2.length > 2) {
throw CommonException.get("数据异常:===ERROR===数据文件编写错误===第 " + lineNum + " 行附近!");
}
if(arr2.length == 2) {
map.put(arr2[0].trim(), arr2[1].trim());
} else {
map.put(arr2[0].trim(), "");
}
}
} else if(lineArr.length == 2) {
map.put(lineArr[0].trim(), lineArr[1].trim());
} else {
map.put(lineArr[0], "");
}
}
/**
* 当{ } 都出现后, 说明一条case结束, 封装成map, 存入list
*/
if(start && end) {
start = false;
end = false;
map.putIfAbsent(KW.channelCode, channelCode);
map.putIfAbsent(KW.productCode, productCode);
map.putIfAbsent(KW.responseCode, responseCode);
res.add(map);
map = new HashMap<>();
}
}
} finally {
if(reader != null) try {reader.close();} catch (IOException e) {throw CommonException.get(e);}
if(is != null) try {is.close();} catch (IOException e) {throw CommonException.get(e);}
}
return res;
}
/**
* @author 张志刚 2017年11月13日 下午6:16:58
* @param path
* @throws IOException
* @功能 : 根据json类型的文件,读取异常case填充的数据
* 可以编写的格式
*
* 1. JSON格式
* 2. 不可嵌套{}
*
*/
@SuppressWarnings("unchecked")
public static List<Map<String, String>> readJSONFile(String path) throws IOException {
/**
* 定义一些初始变量
*/
URL url = CsvUtils.class.getResource(path);
List<Map<String, String>> res = new ArrayList<>();
try(InputStream is = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is)) ){
boolean start = false;
boolean end = false;
String jsonstr = "";
String line = "";
String channelCode = "";
String productCode = "";
String responseCode = "";
while((line = reader.readLine()) != null) {
/**
* 1. 空行跳过
* 2. 注释行跳过
*/
line = line.trim();
if(StringHelper.isEmpty(line) || line.startsWith("#")) continue;
/**
* 获取全局变量——channelCode、productCode、responseCode
*/
if(line.toLowerCase().startsWith("@set")) {
String[] arr = line.substring(4).split("=");
String key = arr[0].trim();
String value = arr[1].trim().replace(";", "").replace(";", "");
if(key.equals(KW.channelCode)) {
channelCode = value;
} else if(key.equals(KW.productCode)) {
productCode = value;
} else if(key.equals(KW.responseCode)) {
responseCode = value;
}
continue;
}
/**
* 1. 以 { 为case开始节点
* 2. 以 } 为case结束节点
*/
if(line.startsWith("{")) {
start = true;
}
if(line.endsWith("}")) {
end = true;
}
jsonstr += line;
/**
* 当{ } 都出现后, 说明一条case结束, 封装成map, 存入list
*/
if(start && end) {
Map<String, String> map = JSONObject.parseObject(jsonstr, Map.class);
if(StringHelper.isNotEmpty(channelCode)) map.putIfAbsent(KW.channelCode, channelCode);
if(StringHelper.isNotEmpty(productCode)) map.putIfAbsent(KW.productCode, productCode);
if(StringHelper.isNotEmpty(responseCode)) map.putIfAbsent(KW.responseCode, responseCode);
res.add(map);
start = false;
end = false;
jsonstr = "";
}
}
}
return res;
}
public static void main(String[] args) throws IOException {
String path = "/demo/exceptioncase_type.csv";
CsvUtils.readCsv(path);
}
}
| UTF-8 | Java | 10,956 | java | CsvUtils.java | Java | [
{
"context": "port com.csvreader.CsvReader;\n\n/**\n * \n * @author 张志刚 2017年8月19日 下午6:39:09\n * @功能 : 数据驱动工具类\n * \t\t ",
"end": 626,
"score": 0.9976492524147034,
"start": 623,
"tag": "NAME",
"value": "张志刚"
},
{
"context": "alues,通过逗号进行隔开\n\t * 相对jar包路径\n\t * </p>\n\t * @author 张志刚 2017年8月19日 下午6:42:26 \n\t * @param ppath \t资源文件路径,",
"end": 933,
"score": 0.9950494170188904,
"start": 930,
"tag": "NAME",
"value": "张志刚"
},
{
"context": "\t}\n\t\t}\n\t\t\n\t\treturn resList;\n\t}\n\t\n\t/**\n\t * @author 张志刚 2017年8月22日 下午4:13:38 \n\t * @param path\n\t * @功能 :",
"end": 2419,
"score": 0.9974367618560791,
"start": 2416,
"tag": "NAME",
"value": "张志刚"
},
{
"context": ", Constants.encoding_UTF8);\n\t}\n\t\n\t/**\n\t * @author 张志刚 2018年1月29日 下午6:03:21 \n\t * @param path\n\t * @para",
"end": 2674,
"score": 0.9959903359413147,
"start": 2671,
"tag": "NAME",
"value": "张志刚"
},
{
"context": "Code);\n\t\t}\n\t\treturn result;\n\t}\n\t\n\t/**\n\t * @author 张志刚 2017年11月6日 下午7:21:47 \n\t * @param rightpath 正确报",
"end": 3116,
"score": 0.9790775179862976,
"start": 3113,
"tag": "NAME",
"value": "张志刚"
},
{
"context": "\n\t\t}\n\t\treturn rightDataMap;\n\t}\n\t\n\t/**\n\t * @author 张志刚 2017年11月13日 下午6:16:58 \n\t * @param path\n\t * @功能 ",
"end": 3778,
"score": 0.9635270237922668,
"start": 3775,
"tag": "NAME",
"value": "张志刚"
},
{
"context": "t(e);}\n\t\t}\n\t\t\n\t\treturn res;\n\t}\n\t\n\t/**\n\t * @author 张志刚 2017年11月13日 下午6:16:58 \n\t * @param path\n\t * @thr",
"end": 7329,
"score": 0.999340832233429,
"start": 7326,
"tag": "NAME",
"value": "张志刚"
}
] | null | [] | package com.answern.automatest4inter.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.answern.automatest4inter.config.Constants;
import com.answern.automatest4inter.config.KW;
import com.answern.automatest4inter.exception.CommonException;
import com.csvreader.CsvReader;
/**
*
* @author 张志刚 2017年8月19日 下午6:39:09
* @功能 : 数据驱动工具类
* 从CSV格式的文件中读取数据且封装到List中
*/
public class CsvUtils {
private CsvUtils() {}
/**
* <p>
* Title : 从指定的CSV格式的资源文件中获取内容,将内容封装成List<Map<String, String>>形式返回
* CSV第一行内容是标题,对应的是Map中的key
* 其他行的内容是values,通过逗号进行隔开
* 相对jar包路径
* </p>
* @author 张志刚 2017年8月19日 下午6:42:26
* @param ppath 资源文件路径,相对路径
* @param encoding 编码格式
*/
public static List<Map<String, String>> readCsv(String path, String encoding) throws IOException {
if(path.trim().toLowerCase().endsWith(".map")) return readMapFile(path);
if(path.trim().toLowerCase().endsWith(".json")) return readJSONFile(path);
List<Map<String, String>> resList =new ArrayList<>();
CsvReader reader = new CsvReader(CsvUtils.class.getResourceAsStream(path),',', Charset.forName(encoding));
reader.setSafetySwitch(false);
reader.setUseComments(true);
reader.readHeaders();
int i = reader.getHeaderCount();
String[] headers = new String[i];
for(int j=0;j<=i-1;j++){
headers[j] = reader.getHeader(j);
}
while (reader.readRecord()) {
if("".equals(reader.getRawRecord()) || reader.getRawRecord()==null) continue;
Map<String,String> map = new HashMap<>();
for(int j=0;j<=i-1;j++) {
map.put(headers[j], reader.get(headers[j]));
}
resList.add(map);
}
reader.close();
/**
* 调整异常CSV中testKey和testValue的数据
*/
for(Map<String, String> map : resList) {
Set<String> set = new HashSet<>(map.keySet());
for(String key : set) {
if(StringHelper.isEmpty(key)) continue;
if(key.startsWith(KW.testKey)) {
String testKey = map.get(key);
String testValue = map.get(key.replace(KW.testKey, KW.testValue));
map.put(testKey, testValue);
}
}
}
return resList;
}
/**
* @author 张志刚 2017年8月22日 下午4:13:38
* @param path
* @功能 : 从csv中获取数据封装成List对象,缺省enconding参数,默认为UTF-8
*/
public static List<Map<String, String>> readCsv(String path) throws IOException {
return readCsv(path, Constants.encoding_UTF8);
}
/**
* @author 张志刚 2018年1月29日 下午6:03:21
* @param path
* @param channelCode
* @功能 : 新增方法,可以在反向case或者正向case中省去channelCode的编写, 通过代码填充渠道编号
*/
public static List<Map<String, String>> readCsvAndFillChannelCode(String path, String channelCode) throws IOException{
List<Map<String, String>> result = readCsv(path);
for(Map<String, String> map : result) {
map.putIfAbsent(KW.channelCode, channelCode);
}
return result;
}
/**
* @author 张志刚 2017年11月6日 下午7:21:47
* @param rightpath 正确报文填充内容的文件地址
* @功能 : 根据正确数据文件填充map
* 1. 通过packageHeaderAndChannelInfo获取了包含了所有公共字段的map
* 2. 根据rightpath得到为当前接口预置的字段以及值
* 3. 将预置的字段以及值,填充到正确的map中,此时得到一个包含了所有正确数值的一条数据
*/
public static Map<String, String> readRightMapCsv(String rightpath) throws IOException {
Map<String, String> rightDataMap = new HashMap<>();
List<Map<String, String>> dataList = readCsv(rightpath);
for(Map<String, String> map : dataList) {
String fieldName = map.get(KW.fieldName);
String fieldValue = map.get(KW.fieldValue);
rightDataMap.put(fieldName, fieldValue);
}
return rightDataMap;
}
/**
* @author 张志刚 2017年11月13日 下午6:16:58
* @param path
* @功能 : 根据map类型的文件,读取异常case填充的数据
* 可以编写的格式
*
* 1. 可兼容最后一行以逗号(,)结尾
* 2. 可兼容中间行不以逗号(,)号结尾
* 3. 可以兼容多个key值写在一行内
* 4. 可以兼容一行中有逗号(,)存在,但是这一行不可填写多个key值
* 5. 不可兼容key或者value中存在等号(=)
*
*/
public static List<Map<String, String>> readMapFile(String path) throws IOException {
/**
* 定义一些初始变量
*/
URL url = CsvUtils.class.getResource(path);
InputStream is = null;
BufferedReader reader = null;
List<Map<String, String>> res = new ArrayList<>();
try{
is = url.openStream();
reader = new BufferedReader(new InputStreamReader(is));
int lineNum = 1;
boolean start = false;
boolean end = false;
Map<String, String> map = new HashMap<>();
String line = "";
String channelCode = "";
String productCode = "";
String responseCode = "";
/**
* 循环读取每一行数据
*/
while((line = reader.readLine()) != null) {
/**
* 1. 空行跳过
* 2. 注释行跳过
*/
lineNum++;
line = line.trim();
if(StringHelper.isEmpty(line) || line.startsWith("#")) continue;
/**
* 获取全局变量——channelCode、productCode、responseCode
*/
if(line.toLowerCase().startsWith("@set")) {
String[] arr = line.substring(4).split("=");
String key = arr[0].trim();
String value = arr[1].trim().replace(";", "").replace(";", "");
if(key.equals(KW.channelCode)) {
channelCode = value;
} else if(key.equals(KW.productCode)) {
productCode = value;
} else if(key.equals(KW.responseCode)) {
responseCode = value;
}
continue;
}
/**
* 1. 以 { 作为case的开始标识
* 2. 以 } 作为case的结束标识
* 3. 去除行尾的(, 逗号)
*/
if(line.startsWith("{")) {
start = true;
line = line.substring(1).trim();
}
if(line.endsWith("}")) {
end = true;
line = line.substring(0, line.length() - 1).trim();
}
if(line.endsWith(",")) {
line = line.substring(0, line.length() - 1).trim();
}
/**
* 剔除符号之后如何不为空,则执行数据填充进map
* 1. lineArr.length > 2 : 表示当前行是多个键值对
* 2. lineArr.length == 2: 表示当前行是标准的一个键值对
* 3. lineArr.length == 1: 表示当前行是一个非标准的键值对(只有key, 没有value)
*/
if(StringHelper.isNotEmpty(line)) {
String[] lineArr = line.split("=");
if(lineArr.length > 2) {
String[] arr = line.split(",");
for(String str :arr) {
str = str.trim();
if(str.endsWith(",")) str = str.substring(0, str.length() - 1);
if(StringHelper.isEmpty(str)) continue;
String[] arr2 = str.split("=");
if(arr2.length > 2) {
throw CommonException.get("数据异常:===ERROR===数据文件编写错误===第 " + lineNum + " 行附近!");
}
if(arr2.length == 2) {
map.put(arr2[0].trim(), arr2[1].trim());
} else {
map.put(arr2[0].trim(), "");
}
}
} else if(lineArr.length == 2) {
map.put(lineArr[0].trim(), lineArr[1].trim());
} else {
map.put(lineArr[0], "");
}
}
/**
* 当{ } 都出现后, 说明一条case结束, 封装成map, 存入list
*/
if(start && end) {
start = false;
end = false;
map.putIfAbsent(KW.channelCode, channelCode);
map.putIfAbsent(KW.productCode, productCode);
map.putIfAbsent(KW.responseCode, responseCode);
res.add(map);
map = new HashMap<>();
}
}
} finally {
if(reader != null) try {reader.close();} catch (IOException e) {throw CommonException.get(e);}
if(is != null) try {is.close();} catch (IOException e) {throw CommonException.get(e);}
}
return res;
}
/**
* @author 张志刚 2017年11月13日 下午6:16:58
* @param path
* @throws IOException
* @功能 : 根据json类型的文件,读取异常case填充的数据
* 可以编写的格式
*
* 1. JSON格式
* 2. 不可嵌套{}
*
*/
@SuppressWarnings("unchecked")
public static List<Map<String, String>> readJSONFile(String path) throws IOException {
/**
* 定义一些初始变量
*/
URL url = CsvUtils.class.getResource(path);
List<Map<String, String>> res = new ArrayList<>();
try(InputStream is = url.openStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(is)) ){
boolean start = false;
boolean end = false;
String jsonstr = "";
String line = "";
String channelCode = "";
String productCode = "";
String responseCode = "";
while((line = reader.readLine()) != null) {
/**
* 1. 空行跳过
* 2. 注释行跳过
*/
line = line.trim();
if(StringHelper.isEmpty(line) || line.startsWith("#")) continue;
/**
* 获取全局变量——channelCode、productCode、responseCode
*/
if(line.toLowerCase().startsWith("@set")) {
String[] arr = line.substring(4).split("=");
String key = arr[0].trim();
String value = arr[1].trim().replace(";", "").replace(";", "");
if(key.equals(KW.channelCode)) {
channelCode = value;
} else if(key.equals(KW.productCode)) {
productCode = value;
} else if(key.equals(KW.responseCode)) {
responseCode = value;
}
continue;
}
/**
* 1. 以 { 为case开始节点
* 2. 以 } 为case结束节点
*/
if(line.startsWith("{")) {
start = true;
}
if(line.endsWith("}")) {
end = true;
}
jsonstr += line;
/**
* 当{ } 都出现后, 说明一条case结束, 封装成map, 存入list
*/
if(start && end) {
Map<String, String> map = JSONObject.parseObject(jsonstr, Map.class);
if(StringHelper.isNotEmpty(channelCode)) map.putIfAbsent(KW.channelCode, channelCode);
if(StringHelper.isNotEmpty(productCode)) map.putIfAbsent(KW.productCode, productCode);
if(StringHelper.isNotEmpty(responseCode)) map.putIfAbsent(KW.responseCode, responseCode);
res.add(map);
start = false;
end = false;
jsonstr = "";
}
}
}
return res;
}
public static void main(String[] args) throws IOException {
String path = "/demo/exceptioncase_type.csv";
CsvUtils.readCsv(path);
}
}
| 10,956 | 0.620718 | 0.605045 | 351 | 26.447294 | 22.812176 | 119 | false | false | 0 | 0 | 0 | 0 | 0 | 0 | 3.427351 | false | false | 3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.