blob_id
stringlengths 40
40
| directory_id
stringlengths 40
40
| path
stringlengths 4
410
| content_id
stringlengths 40
40
| detected_licenses
sequencelengths 0
51
| license_type
stringclasses 2
values | repo_name
stringlengths 5
132
| snapshot_id
stringlengths 40
40
| revision_id
stringlengths 40
40
| branch_name
stringlengths 4
80
| visit_date
timestamp[us] | revision_date
timestamp[us] | committer_date
timestamp[us] | github_id
int64 5.85k
689M
⌀ | star_events_count
int64 0
209k
| fork_events_count
int64 0
110k
| gha_license_id
stringclasses 22
values | gha_event_created_at
timestamp[us] | gha_created_at
timestamp[us] | gha_language
stringclasses 131
values | src_encoding
stringclasses 34
values | language
stringclasses 1
value | is_vendor
bool 1
class | is_generated
bool 2
classes | length_bytes
int64 3
9.45M
| extension
stringclasses 32
values | content
stringlengths 3
9.45M
| authors
sequencelengths 1
1
| author_id
stringlengths 0
313
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6baf146f5ca5c0912785c51ee88982dfb9f390c3 | 9e8f28c189f2b98916a34865044e794989aff314 | /eclipse-workspace-desk/BeeGame_Assign 2/src/BeeGame/BQueen.java | 7417bd1dc00098e3747aee2db9e97a8c58875b56 | [] | no_license | quyetdong/Funix-Projects | 1831cf3006d24e707a9578d00cd68ff80cdd1470 | f3329f0e35e1b6ab1a377631f3566fa15ecc73a4 | refs/heads/master | 2020-06-10T15:59:12.017019 | 2019-06-25T08:36:45 | 2019-06-25T08:36:45 | 193,667,528 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133 | java | package BeeGame;
class BQueen extends Bee {
String bLife() {
if(getHealth() < 20) {
return "Death";
}
return "Alive";
}
} | [
"[email protected]"
] | |
8ea3366bb5fcf9151c1a42f06d4b6be1f2730034 | 32199ea7c0b80334d750764cb411d98fde72540e | /src/main/java/net/neferett/coreengine/Processors/Logger/Logger.java | 7c2b691cb983efc331df691823dcba64c1b63af7 | [] | no_license | jordanbonaldi/CoreEngine | 39ac4a708c616cbc0f052bdd45c39d87538b1cd6 | 762c2ea6096488bc31af5b3ac25b478436ca3e35 | refs/heads/master | 2020-06-28T15:40:28.123828 | 2019-08-10T20:28:02 | 2019-08-10T20:28:02 | 200,270,943 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,458 | java | package net.neferett.coreengine.Processors.Logger;
import lombok.NonNull;
import net.neferett.coreengine.CoreEngine;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
public class Logger {
private static void print(String msg) {
final Calendar cal = Calendar.getInstance();
final SimpleDateFormat date = new SimpleDateFormat("hh:mm:ss");
System.out.println("[" + date.format(cal.getTime()) + "] " + msg);
}
public static void log(String msg) {
final String channel = CoreEngine.getInstance().getLoggerChannelManager().getActual();
final LoggerChannel logger = CoreEngine.getInstance().getLoggerChannelManager().getChannel(channel);
logger.put(msg, true);
print(msg);
}
public static void logInChannel(String msg, @NonNull String channel)
{
LoggerChannel chan = CoreEngine.getInstance().getLoggerChannelManager().getChannel(channel);
if (null == chan) {
LoggerChannel __chan = new LoggerChannel(channel);
__chan.put(msg, false);
CoreEngine.getInstance().addChannel(__chan);
return;
}
if (channel.equalsIgnoreCase(CoreEngine.getInstance().getLoggerChannelManager().getActual())) {
chan.getMessages().forEach((message, read) -> { if(!read) log(message); });
log(msg);
} else
chan.put(msg, false);
}
}
| [
"[email protected]"
] | |
bafb1963fdafdcafaca986e30275e0b64fa71dd7 | 09259c2296b37ace458d917a2d147ba787d9cb51 | /src/com/itteam/yutang/bean/PondBean.java | c16f6e526bdda5ac8c76d27c211a7a025b9e8b7c | [] | no_license | heikeking/yutang | 8dc90ae37074de9e199b32865453c3eb52513eb9 | fcea58002af71d196f6dce27a13ce6dd9d880759 | refs/heads/master | 2022-02-23T17:48:54.646913 | 2017-04-20T02:19:58 | 2017-04-20T02:19:58 | 88,750,709 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 680 | java | package com.itteam.yutang.bean;
public class PondBean {
public String deviceCount; //"1",
public String deviceOnlineCount; // "1",
public String pondId; //"1",
public String pondName; //"高桥村1号塘",
public String pondArea; //: "5",
public String pondDepth; //: "6",
public String pondDensity; //: "400",
public String pondUsage; //: "13",
public String pondO2_power; //: "20",
public String pondRental; //: "2000",
public String pondO2_add; //: "叶轮式增氧机",
public String pondWaterSupplies; //: "普通淡水",
public String pondTop; //: "无蓬",
public String pondBottom; //: "普通土壤",
public String pondDischargeMode; //: "无法排污"
}
| [
"周翔"
] | 周翔 |
4272c01db7a189dfb98248306e640800383be723 | 238af1d51e5252b22793ae7f6bf6f555bada5360 | /msvolley/src/main/java/com/maxis7567/msvolley/uploder/Initializer.java | cf12c3ba2ea28bfccdfbc920906f0cea43810747 | [] | no_license | maxis7567/msVolley | 27716b70d539bf674a40862ae8a70663d6f97630 | e5ca87ab5d7be4d40027772b478a79b4ce600095 | refs/heads/master | 2021-06-25T08:34:32.704244 | 2020-06-17T01:14:22 | 2020-06-17T01:14:22 | 166,653,916 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 906 | java | package com.maxis7567.msvolley.uploder;
import android.app.Application;
import net.gotev.uploadservice.BuildConfig;
import net.gotev.uploadservice.UploadService;
import net.gotev.uploadservice.okhttp.OkHttpStack;
import okhttp3.OkHttpClient;
public class Initializer extends Application {
@Override
public void onCreate() {
super.onCreate();
// setup the broadcast action namespace string which will
// be used to notify upload status.
// Gradle automatically generates proper variable as below.
UploadService.NAMESPACE = BuildConfig.APPLICATION_ID;
// Or, you can define it manually.
// UploadService.NAMESPACE = "com.yourcompany.yourapp";
OkHttpClient client = new OkHttpClient(); // create your own OkHttp client
UploadService.HTTP_STACK = new OkHttpStack(client); // make the library use your own OkHttp client
}
} | [
"[email protected]"
] | |
e1f2a2786f9287980fd54f9a4627480eed8b4299 | 0d855a70668b1cc9158032470110f54a449b4870 | /Chapter1예제/FinalArchitecture/JavaApp/src/main/java/com/charlezz/javaapp/util/ImageBindingAdapter.java | 4b967b27104d3159e7afe2e33cf7e6fc6684eb4a | [] | no_license | conquerex/AndroidArchitecture | 9faad7670e8e07fc992404dcf5195fa2976673d5 | 4226142d3048b7f5c3ec758cbc30fa0b5eac71e3 | refs/heads/master | 2022-12-04T02:52:54.792063 | 2020-08-25T11:29:41 | 2020-08-25T11:29:41 | 282,128,767 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 553 | java | package com.charlezz.javaapp.util;
import android.text.TextUtils;
import android.widget.ImageView;
import androidx.databinding.BindingAdapter;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
public class ImageBindingAdapter {
@BindingAdapter("image")
public void setImage(ImageView imageView, String path){
if(!TextUtils.isEmpty(path)){
Glide.with(imageView).load(path).transition(DrawableTransitionOptions.withCrossFade()).into(imageView);
}
}
}
| [
"[email protected]"
] | |
3cbddeb3269547d02ce31605152d2e74e14b912c | 7eb1963820ccfb8d3fdb34e6dcb22fc94c12e0ca | /tensquare_spit/src/main/java/com/tensquare/spit/dao/SpitDao.java | 304abd3a5650d17c76226afb232b14504c459440 | [] | no_license | wukongshuo/tensquare | f155fafabc33d052b376eabdaf1d33ec79e667eb | 5563717f3f576a7372c9964dd72bd28905f3f047 | refs/heads/main | 2023-03-31T15:47:25.921626 | 2021-04-07T09:44:28 | 2021-04-07T09:44:28 | 355,488,304 | 0 | 0 | null | 2021-04-07T09:50:42 | 2021-04-07T09:35:25 | Java | UTF-8 | Java | false | false | 547 | java | package com.tensquare.spit.dao;
import com.tensquare.spit.pojo.Spit;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.repository.MongoRepository;
/**
* 吐槽数据访问层
* @author xxw
*
*/
public interface SpitDao extends MongoRepository<Spit, String> {
/**
* 根据上级ID查询吐槽列表(分页)
* @param parentId
* @param pageable
* @return
*/
Page<Spit> findByParentId(String parentId, Pageable pageable);
} | [
"[email protected]"
] | |
96f858769d24672453e1413fd9e09613c9b50e2b | e9674ce67dd3a1fa0749c4b600fc8fdf4589f1ce | /src/test/Test4.java | b8fceb73652bd3ad9598df759737eb1541230fa7 | [] | no_license | scoopy87/eclipseProject | 48ac70b5bd899bdb3fd1950fde8ae3ed5c8b2e9d | b6e616b455d4ac6ded2301f3d20982de56d2e0c6 | refs/heads/master | 2020-06-19T12:18:40.547367 | 2019-07-13T09:29:20 | 2019-07-13T09:29:20 | 196,703,801 | 0 | 0 | null | 2019-07-13T09:32:08 | 2019-07-13T09:32:08 | null | UTF-8 | Java | false | false | 227 | java | package test;
public class Test4 {
String name;
public Test4(String name) {
this.name = name;
}
int a;
public Test4(int a) {
this.a = a;
}
long b;
public Test4(long b) {
this.b = b;
}
}
| [
"[email protected]"
] | |
29bb729af5a39fba829ed7eebc38f8bdb86f3046 | 30c456c8c5a5ff6d9e450d339c921b4bc22a96d3 | /MedData/wear/src/main/java/com/android/meddata/Adapters/DashBoardAdapter.java | e250ed1c06ab1d6378adc7fd96e63acdb1bf5c4c | [] | no_license | chandragithub2014/PatientList | c8739626d409d125555fe6bb123b902a7786a9a1 | d8dac365e04ca280d7f1ea93350dbb1447b16b39 | refs/heads/master | 2021-01-10T13:31:40.139373 | 2015-12-14T22:04:44 | 2015-12-14T22:04:44 | 44,579,019 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,928 | java | package com.android.meddata.Adapters;
import android.content.Context;
import android.support.wearable.view.CircledImageView;
import android.support.wearable.view.WearableListView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import com.android.meddata.R;
import java.util.ArrayList;
import java.util.List;
/**
* Created by CHANDRASAIMOHAN on 10/20/2015.
*/
public class DashBoardAdapter extends WearableListView.Adapter {
private List<Integer> mIcons;
private final LayoutInflater mInflater;
private List<String> mTitles;
Context ctx;
public DashBoardAdapter(Context ctx,List<Integer> mIcons,List<String> mTitles){
mInflater = LayoutInflater.from(ctx);
this.mIcons = mIcons;
this.mTitles = mTitles;
this.ctx = ctx;
}
@Override
public WearableListView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new WearableListView.ViewHolder(new WearableListItemLayout(ctx));
}
@Override
public void onBindViewHolder(WearableListView.ViewHolder holder, int position) {
WearableListItemLayout listViewRowView = (WearableListItemLayout) holder.itemView;
listViewRowView.getImage().setImageResource(mIcons.get(position));
listViewRowView.getText().setText(mTitles.get(position));
}
@Override
public int getItemCount() {
return mTitles.size();
}
/* private static class ItemViewHolder extends WearableListView.ViewHolder {
private CircledImageView mCircledImageView;
private TextView mItemTextView;
public ItemViewHolder(View itemView) {
super(itemView);
mCircledImageView = (CircledImageView)
itemView.findViewById(R.id.circle);
mItemTextView = (TextView) itemView.findViewById(R.id.name);
}
}*/
}
| [
"[email protected]"
] | |
2bd56f2560278dad7b19ee91c5f31aba186edecc | 4aba07b1799b729d5e084bcff05e306b154fcbed | /base_webapp/src/main/java/db/UserCart.java | 634a0786467dc55b31b19bba654a480b5b9aa533 | [] | no_license | Xander17/java_ee | 883cd1dddfe3c9a426c27e8eea4c55920d34a06c | 5fa8707895958f3597d90a48608a03d00dce691e | refs/heads/master | 2022-12-06T07:45:29.694065 | 2020-03-03T20:21:16 | 2020-03-03T20:21:16 | 228,226,818 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,309 | java | package db;
import javax.servlet.http.HttpSession;
import java.util.Map;
import java.util.TreeMap;
public class UserCart {
private Map<Integer, Integer> cart;
private HttpSession session;
private UserCart() {
cart = new TreeMap<>();
}
public static UserCart getSessionCart(HttpSession session) {
UserCart cart = (UserCart) session.getAttribute("cart");
if (cart == null) {
cart = new UserCart();
cart.session = session;
session.setAttribute("cart", cart);
cart.updateSession();
}
return cart;
}
public void add(int id, int quantity) {
if (quantity <= 0) return;
cart.put(id, cart.getOrDefault(id, 0) + quantity);
updateSession();
}
public void set(int id, int quantity) {
if (quantity < 0) return;
if (quantity == 0) remove(id);
else cart.put(id, quantity);
updateSession();
}
public void remove(int id) {
cart.remove(id);
updateSession();
}
public Map<Integer, Integer> getCart() {
return cart;
}
public void clear() {
cart.clear();
updateSession();
}
private void updateSession() {
session.setAttribute("cartSize", cart.size());
}
}
| [
"[email protected]"
] | |
dbc9950a324945975c9ccf365acd79eeca5d7ad4 | 61f915179540dc2f1c36aae756f21fee6a5a49da | /src/main/java/com/nayaragomes/cursomc/repositories/CategoriaRepository.java | 9cb590fd2f233dfe3edcbf75539439b9235db44f | [] | no_license | naynivea/curso-spring-boot-ionic-backend | 7e50b49519af666e53f4415c081d97fbff6446b3 | 1c063c3dc4d0020680e288bb01ec1260149cd1b5 | refs/heads/master | 2023-03-28T18:18:37.979491 | 2021-03-29T12:05:17 | 2021-03-29T12:05:17 | 347,600,391 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 306 | java | package com.nayaragomes.cursomc.repositories;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.nayaragomes.cursomc.domain.Categoria;
@Repository
public interface CategoriaRepository extends JpaRepository<Categoria, Integer> {
}
| [
"[email protected]"
] | |
0b80b90bdd95edd2ffb200fae11db044b7556d61 | 17ee9efb60428b70e851cbf54a8a5f371de4685a | /src/main/java/exception/ReaderException.java | c69c52772fbcbf5475c306a497fe2ef003e7ba6a | [] | no_license | SetrinaOlesia/TaskJoinTables | 8c330ad397a7584e7d142ee82512316bd217cde2 | 19c221a2d68e894b8bc66ff96003bbf393c10290 | refs/heads/main | 2023-04-10T17:29:46.691413 | 2021-04-25T15:04:00 | 2021-04-25T15:04:00 | 361,389,648 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 147 | java | package exception;
public class ReaderException extends RuntimeException {
public ReaderException(String msg) {
super(msg);
}
}
| [
"[email protected]"
] | |
1dee50b90116a9c22c9bad00522b9ad1ed4a7c62 | dff0b1e47c558e2453048b87dd2d35c39b4a7379 | /src/main/java/symbolic/computations/App.java | 187c99a120e99d808e0ca530a44ece2630b48541 | [] | no_license | TatianaFomina/symb_calc_labs23 | 759c6f50616681f88e131ba4db26e3b25c0c3905 | 839274004261cb6ffa2daa7f0c7e07c7d266c65a | refs/heads/master | 2020-04-03T04:16:15.886874 | 2019-01-20T12:32:42 | 2019-01-20T12:32:42 | 155,008,959 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,076 | java | package symbolic.computations;
import ast.BinaryOperation;
import ast.Operation;
import ast.UnaryOperation;
import parser.JsonParser;
import parser.ParserException;
import visitor.DerivativeVisitor;
import visitor.Visitor;
import writer.EqnWriter;
import writer.WritingTool;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class App
{
public static void main( String[] args ) throws IOException, ParserException {
//ParsingTool parsingTool = new ParsingTool(); //stub
JsonParser parser = new JsonParser();
Operation expressionTree = parser.getAbstractSyntaxTree("exp_tree2.json");
Operation derivative = expressionTree.accept(new DerivativeVisitor());
System.out.println(derivative);
//writing result
BufferedWriter writer = new BufferedWriter(new FileWriter("result1.eqn"));
writer.write(".EQ\n");
writer.write(expressionTree.acceptWriter(new EqnWriter()));
writer.write("\n.EN");
writer.close();
}
}
| [
"[email protected]"
] | |
c0df96aed3be3a0b82288cbff80058e7a3104953 | b55109e36f35eda6cb84bfbe67cf2f363ace235e | /Client/src/Presentation/DocUI/GoodDoc/GoodDocDataHelper.java | b105b6e3cfa1c7de5523b699e1581fa7aa9ba4f9 | [] | no_license | JonySheep/XiangXiangDeng | cb87e65e24080302f3f135e9e22f23735fe424d5 | 4ad25e3781d30050c5c7e0b29767e07477cae750 | refs/heads/master | 2021-04-30T12:18:09.803163 | 2018-02-12T16:51:37 | 2018-02-12T16:51:37 | 121,271,929 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,544 | java | package Presentation.DocUI.GoodDoc;
import BusinessLogic.DocBL.DocController;
import BusinessLogic.UserBL.UserController;
import BusinessLogicService.DocBLService;
import Presentation.DocUI.GoodDoc.model.GoodDoc;
import Util.*;
import VO.*;
import com.sun.org.apache.regexp.internal.RE;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import java.util.ArrayList;
public class GoodDocDataHelper {
private ObservableList<GoodDoc> currentGoodDocList= FXCollections.observableArrayList();
private UserVO currentUser=new UserController().getCurrentUser();
//private UserVO currentUser=new UserVO("00000001","YangYang", "YangYang",UserLevel.GENERAL, UserRole.INVENTORY);
private DocBLService blService=new DocController();
public GoodDocDataHelper(){
/*ArrayList<GoodItemForGoodDocVO> goods=new ArrayList<>();
goods.add(new GoodItemForGoodDocVO("0000001","超级香香灯","xxxxxx",100,23));
goods.add(new GoodItemForGoodDocVO("0000002","撒撒芳心纵火犯明灯","ssssss",200,30));
currentGoodDocList.add(new GoodDoc("",new UserForDocVO("0000001","羊"),DocType.GOOD_OVERFLOW,goods,"倒计时十小时"));
currentGoodDocList.add(new GoodDoc("",new UserForDocVO("0000001","羊"),DocType.GOOD_OVERFLOW,goods,"倒计时十小时"));
currentGoodDocList.add(new GoodDoc("",new UserForDocVO("0000001","羊"),DocType.GOOD_LOSS,goods,"倒计时十小时"));
currentGoodDocList.add(new GoodDoc("",new UserForDocVO("0000001","羊"),DocType.GOOD_LOSS,goods,"倒计时十小时"));
*/
}
public ResultMessage addGoodDoc(String prKey, UserForDocVO operator, DocType type, ArrayList<GoodItemForGoodDocVO> itemList, String comment){
ResultMessage isSuccess=ResultMessage.SUCCESS;
GoodDoc newDoc=new GoodDoc(prKey,operator,type,itemList,comment);
try{
isSuccess=blService.addDocDraft(this.convererToVO(newDoc));
}
catch (Exception e){
e.printStackTrace();
}
if(isSuccess==ResultMessage.SUCCESS){
currentGoodDocList.add(newDoc);
}
return isSuccess;
}
/**
* 删除单据
* @param list
* @return
*/
public ResultMessage delGoodDoc(ObservableList<Integer> list){
ResultMessage isSuccess=ResultMessage.SUCCESS;
GoodDoc delCus=new GoodDoc();
try{
for(Integer e:list){
delCus=currentGoodDocList.get(e);
isSuccess=blService.delDocDraft(this.convererToVO(delCus));
if(isSuccess==ResultMessage.SUCCESS){
currentGoodDocList.remove(e,e+1);
}
}
}
catch (Exception e){
e.printStackTrace();
}
return ResultMessage.SUCCESS;
}
/**
* 修改库存报警单
* @param Doc 库存报警单
* @return
*/
public ResultMessage modifyGoodDoc(GoodDoc Doc){
ResultMessage isSuccess=ResultMessage.SUCCESS;
try{
isSuccess=blService.editDocDraft(this.convererToVO(Doc));
}
catch (Exception e){
e.printStackTrace();
}
//check data
for(GoodDoc oldDoc:currentGoodDocList){
if(oldDoc.getPrKey().equals(Doc.getPrKey())){
//找到相应改动的单据后进行比对
if(Doc.getGoods()!=null&&Doc.getGoods().size()!=0){
oldDoc.setGoods(Doc.getGoods());
}
if(!Doc.getComment().equals(EmptyValue.getString())){
oldDoc.setComment(Doc.getComment());
}
}
break;
}
return isSuccess;
}
public ObservableList<GoodDoc> gerCurrentDocList(){
/*
链接bl
*/
ObservableList<GoodDoc> Goods=FXCollections.observableArrayList();
try{
ArrayList<GoodDocVO> GoodVOs=blService.getGoodOverflowDraftList(currentUser.getUserID());
ArrayList<GoodDocVO> GoodLossVO=blService.getGoodLossDraftList(currentUser.getUserID());
for(GoodDocVO vo:GoodVOs){
Goods.add(this.converterToModel(vo));
}
for(GoodDocVO vo:GoodLossVO){
Goods.add(this.converterToModel(vo));
}
}
catch (Exception e){
e.printStackTrace();
}
currentGoodDocList=Goods;
return currentGoodDocList;
}
/**
* 提交单据
* @param doc 选中的单据
* @param list 选中的单据列表
* @return
*/
public ResultMessage submitDoc(GoodDoc doc,ObservableList<Integer> list){
ResultMessage isSuccess=ResultMessage.SUCCESS;
try{
isSuccess=blService.submitDocDraft(this.convererToVO(doc));
}
catch (Exception e){
e.printStackTrace();
}
if(isSuccess==ResultMessage.SUCCESS){
for(Integer e:list){
currentGoodDocList.remove(e,e+1);
}
}
return isSuccess;
}
public GoodDoc converterToModel (GoodDocVO vo){
return new GoodDoc(vo.getPrKey(),vo.getOperator(),vo.getType(),vo.getItemList(),vo.getComment());
}
public GoodDocVO convererToVO(GoodDoc doc){
return new GoodDocVO(doc.getPrKey(),doc.getCurrentOperator(),doc.getType(),doc.getGoods(),doc.getComment());
}
public UserVO getUser(){return currentUser;}
}
| [
"[email protected]"
] | |
24bf0f36f1b1cb1aa6cf44e8edc3a41d24056273 | 6b8d9df67c199fa56b01cdda0e7b36188d6ef3f5 | /src/main/java/com/project/brunch/config/handler/exception/MyUserIdNotFoundException.java | 07f65d56256e5eec7d11210d49649600c9b555f5 | [] | no_license | ah-ryeong/server-brunch-project | 922c0829f20caae573cc6700950f7df4a952c472 | bf3692fbe3d1150210e6a527e3c074d4ea16cb79 | refs/heads/master | 2022-12-18T10:16:19.872628 | 2020-09-16T05:53:16 | 2020-09-16T05:53:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 432 | java | package com.project.brunch.config.handler.exception;
public class MyUserIdNotFoundException extends RuntimeException{
private String message;
public MyUserIdNotFoundException() {
this.message = "해당 유저의 ID를 찾을 수 없습니다.";
}
public MyUserIdNotFoundException(String message) {
this.message = message;
}
@Override
public String getMessage() {
return message; // super.getMessage() → null
}
}
| [
"[email protected]"
] | |
dbbd5ce60ec7490c4687a7282d46c9a9c3e0f171 | bf6193d15430c408b42f754f53d27d3d3efb548f | /app/src/test/java/com/example/ins15/cardapp/ExampleUnitTest.java | d74f18bf7aede423ad8646f1bd19ddf46a6bb166 | [] | no_license | ngreeshmaa/cardapp | 23e962ca213073182cd455842cc18d9c692d5f10 | 874a1d3e3979ba9327a09b26996fe93b39cd2b7f | refs/heads/master | 2020-03-15T05:46:10.297386 | 2018-05-03T12:47:03 | 2018-05-03T12:47:03 | 131,993,932 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package com.example.ins15.cardapp;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
a9735af2ed0260886d3ab9568648387d33389181 | 561278a507d3bdb377d1750c99fe60cc768cfe0a | /app/src/main/java/tk/sbarjola/pa/featherlyricsapp/PerfilesUsuarios/TabLayoutFragments/UserArtists.java | fa478cc96503262d37271b36172d99a155b7a085 | [] | no_license | meirinf/FeatherLyrics_APP | 5d9a87386424a4e068d8f77d54cf9ade6c2770aa | e62198ad78d1cd8951c3c479727ff59420b7635d | refs/heads/master | 2021-01-15T13:50:17.785644 | 2016-09-06T12:13:29 | 2016-09-06T12:13:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,097 | java | package tk.sbarjola.pa.featherlyricsapp.PerfilesUsuarios.TabLayoutFragments;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.TextView;
import com.firebase.client.DataSnapshot;
import com.firebase.client.Firebase;
import com.firebase.client.FirebaseError;
import com.firebase.client.ValueEventListener;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import tk.sbarjola.pa.featherlyricsapp.Firebase.FirebaseItem;
import tk.sbarjola.pa.featherlyricsapp.Firebase.FirebaseConfig;
import tk.sbarjola.pa.featherlyricsapp.Firebase.Usuario;
import tk.sbarjola.pa.featherlyricsapp.MainActivity;
import tk.sbarjola.pa.featherlyricsapp.PerfilesUsuarios.Adapters.userArtistsAdapter;
import tk.sbarjola.pa.featherlyricsapp.R;
/**
* Created by 46465442z on 27/04/16.
*/
public class UserArtists extends Fragment {
// Firebase
FirebaseConfig config; // Configuración de firebase
private Firebase referenciaUsuario; // Apunta al usuario loggeado
private Firebase referenciaListaUsuarios; // Apunta a la lista de usuarios
// Instancia del usuario que mostraremos y su UID
Usuario userToShow;
String userUID = "";
GridView historial;
// Adapter y diferentes contenedores para la lista de artistas
private userArtistsAdapter myGridAdapter;
List<String> listCollectionArtist = new ArrayList<>();
public View onCreateView(LayoutInflater inflater, final ViewGroup container, Bundle savedInstanceState){
View view = inflater.inflate(R.layout.fragment_user_artists, container, false); //Definimos el fragment
// Instancia de la configuración
config = (FirebaseConfig) getActivity().getApplication();
referenciaUsuario = config.getReferenciaUsuarioLogeado();
referenciaListaUsuarios = config.getReferenciaListaUsuarios();
// Instancia de la configuración
config = (FirebaseConfig) getActivity().getApplication();
referenciaListaUsuarios = config.getReferenciaListaUsuarios();
// Primero extraemos el del main activity
userUID = ((MainActivity) getActivity()).getOpenedProfile();
// Si no se ha buscado ninguno, el nuestro por defecto
if(userUID.equals("no profile") || userUID.equals("") || userUID == null){
userUID = config.getUserUID();
}
try{
historial = (GridView) view.findViewById(R.id.user_artists_grid);
// Seccion del grid y los albumes
myGridAdapter = new userArtistsAdapter(container.getContext(), 0, listCollectionArtist); // Definimos nuestro adaptador
// Primero extraemos el del main activity
userUID = ((MainActivity) getActivity()).getOpenedProfile();
}catch(RuntimeException e){}
// Si no se ha buscado ninguno, el nuestro por defecto
if(userUID.equals("no profile") || userUID.equals("") || userUID == null){
userUID = config.getUserUID();
}
/*
Comprobamos si queremos consultar los datos del mismo usuario o de otro diferente al tuyo
Si es del usuario, utilizamos su referencia directamente ahorrando datos
*/
if(!userUID.contains(config.getUserUID())) {
// Descargamos la lista de usuarios
referenciaListaUsuarios.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
try {
Usuario usuario = userSnapshot.getValue(Usuario.class);
if (usuario.getUID().equals(userUID)) {
// Cuando encotremos el usuario anyadimos la infromación a la vista
userToShow = usuario;
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(usuario.getNombre());
final Firebase referenciaMusicaContacto = new Firebase(config.getReferenciaListaUsuarios().toString() + "/" + usuario.getKey() + "/Artistas");
// Descargamos la lista de usuarios
referenciaMusicaContacto.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
FirebaseItem grupo = userSnapshot.getValue(FirebaseItem.class);
listCollectionArtist.add(userSnapshot.getKey() + "-" + grupo.getItemUrl());
}
try {
// Limpiamos los duplicados. Gracias al LinkedHashSet mantenemos el orden de los elementos
Set<String> hs = new LinkedHashSet<>(listCollectionArtist);
hs.addAll(listCollectionArtist);
myGridAdapter.clear();
myGridAdapter.addAll(hs);
// Setteamos el adapter
historial.setAdapter(myGridAdapter);
setGridViewHeightBasedOnChildren(historial, 2);
} catch (NullPointerException e) {
e.printStackTrace();
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
} catch (NullPointerException e) {
}
}
}
@Override
public void onCancelled(FirebaseError firebaseError) {
}
});
}
else{
// Descargamos la lista de usuarios
referenciaUsuario.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
try {
Usuario usuario = dataSnapshot.getValue(Usuario.class);
if (usuario.getUID().equals(userUID)) {
// Cuando encotremos el usuario anyadimos la infromación a la vista
userToShow = usuario;
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(usuario.getNombre());
final Firebase referenciaMusicaContacto = new Firebase(config.getReferenciaListaUsuarios().toString() + "/" + usuario.getKey() + "/Artistas");
// Descargamos la lista de usuarios
referenciaMusicaContacto.addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot userSnapshot : dataSnapshot.getChildren()) {
FirebaseItem grupo = userSnapshot.getValue(FirebaseItem.class);
listCollectionArtist.add(userSnapshot.getKey() + "-" + grupo.getItemUrl());
}
try {
// Limpiamos los duplicados. Gracias al LinkedHashSet mantenemos el orden de los elementos
Set<String> hs = new LinkedHashSet<>(listCollectionArtist);
hs.addAll(listCollectionArtist);
myGridAdapter.clear();
myGridAdapter.addAll(hs);
// Setteamos el adapter
historial.setAdapter(myGridAdapter);
setGridViewHeightBasedOnChildren(historial, 2);
} catch (NullPointerException e) {}
}
@Override
public void onCancelled(FirebaseError firebaseError) {}
});
}
} catch (NullPointerException e) {}
}
@Override
public void onCancelled(FirebaseError firebaseError) {}
});
}
historial.setOnItemClickListener(new AdapterView.OnItemClickListener() { //Listener para el list
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
// Extraemos el artista del listView
TextView textViewAuxiliar = (TextView) view.findViewById(R.id.user_artists_artistName);
String text = textViewAuxiliar.getText().toString();
// Cortamos el nombre de la pista y el artista
String artist = text.split("-")[0];
// Y lo mandamos al fragment de canciones
((MainActivity) getActivity()).setDiscographyStart(artist);
((MainActivity) getActivity()).abrirArtistas();
}
});
return view;
}
public void setGridViewHeightBasedOnChildren(GridView gridView, int columnas) {
// Calculamos caunto hay que desplegar el GridView para poder mostrarlo todo dentro del ScrollView
try {
int alturaTotal = 0;
int items = myGridAdapter.getCount();
int filas = 0;
View listItem = myGridAdapter.getView(0, null, gridView);
listItem.measure(0, 0);
alturaTotal = listItem.getMeasuredHeight();
float x = 1;
if (items > columnas) {
x = items / columnas;
filas = (int) (x + 2);
alturaTotal *= filas;
}
ViewGroup.LayoutParams params = gridView.getLayoutParams();
params.height = alturaTotal;
gridView.setLayoutParams(params);
} catch (IndexOutOfBoundsException e){}
}
}
| [
"[email protected]"
] | |
c4649453feea5bf19ed1b9ac1120d82ff1e00685 | 622c7d671a4120a3ea3569800426b0fdb93c682d | /JaydeStudy/src/net/jayde/app/abyssrium/AbyssriumGame.java | c1cb684c2cf12810d5598db59db40d2a3f237fe7 | [] | no_license | jaydezhou/JaydeCS | dac701a8e2c39d75724823a6413d2341d7bba8ea | c940063374aa476e76e5ed750e6a3a5e1715f80d | refs/heads/master | 2021-09-03T09:39:57.638365 | 2018-01-08T03:08:15 | 2018-01-08T03:08:15 | 106,308,540 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 777 | java | package net.jayde.app.abyssrium;
import net.jayde.app.abyssrium.gameInfo.GameActionInfo;
import net.jayde.app.abyssrium.gameInfo.GameBaseInfo;
import net.jayde.app.abyssrium.gameInfo.GameCoralInfo;
import net.jayde.app.abyssrium.gameInfo.GameFishInfo;
import net.jayde.app.abyssrium.gameInfo.GamePrizeInfo;
import net.jayde.app.abyssrium.gameInfo.GameSpecialInfo;
import net.jayde.app.abyssrium.gameInfo.GameStoneInfo;
/**
* Created by jayde on 2017-1-10 15:54.
* 版权所有
*/
public class AbyssriumGame {
private GameStoneInfo stoneInfo;
private GameCoralInfo coralInfo;
private GameFishInfo fishInfo;
private GamePrizeInfo prizeInfo;
private GameActionInfo actionInfo;
private GameSpecialInfo specialInfo;
private GameBaseInfo gameInfo;
}
| [
"[email protected]"
] | |
4ac05eadd303493815b1e38e671ab317e816a801 | ddf535dfd71dc034b5497aaa6091f49fdaa9dfb1 | /EmployeeTravelRequesition/src/main/java/com/mindgate/service/SlabService.java | eed4fdf8f3c4613560cd524f0ecae04fa3b41a85 | [] | no_license | SalethPraveen/Domo-Project-Employee-Travel | c88834ab81e50dc2ca91f66dd359b0701890fe2c | 94987ef42849688764b965e333de3785616d18ad | refs/heads/master | 2020-12-22T04:04:13.957675 | 2020-01-28T05:35:24 | 2020-01-28T05:35:24 | 236,665,404 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 368 | java | package com.mindgate.service;
import java.util.List;
import com.mindgate.pojo.SlabDetails;
public interface SlabService {
public boolean addSlab(SlabDetails slabDetails);
public boolean updateSlab(int slabId, SlabDetails slabDetails);
public boolean deleteSlab(int slabId);
public SlabDetails getSlab(int slabId);
public List<SlabDetails> getAllSlab();
}
| [
"[email protected]"
] | |
70c9ad7738697d48292dc49875720df3c8e3083a | 5251e35969b3dee33403ddb1ad6b0f8b90e2dfed | /src/libreria/Libro.java | 706bc510f26c7efb45e0581771cdeaab22d71b2b | [] | no_license | albapc/Boletin21 | 3fae0cfbdc47022529ab725813e6f826fc31393b | 2d2a0f5968fa5d9ce1856f00c19e5cc1dc4de584 | refs/heads/master | 2020-04-22T15:38:30.412951 | 2019-02-13T23:02:06 | 2019-02-13T23:02:06 | 170,483,648 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,390 | java | package libreria;
import java.util.Objects;
public class Libro implements Comparable {
private String titulo, autor, isbn;
private float precio;
private int nUnidades;
public Libro() {
}
public Libro(String titulo, String autor, String isbn, float precio, int nUnidades) {
this.titulo = titulo;
this.autor = autor;
this.isbn = isbn;
this.precio = precio;
this.nUnidades = nUnidades;
}
public String getTitulo() {
return titulo;
}
public void setTitulo(String titulo) {
this.titulo = titulo;
}
public String getAutor() {
return autor;
}
public void setAutor(String autor) {
this.autor = autor;
}
public String getIsbn() {
return isbn;
}
public void setIsbn(String isbn) {
this.isbn = isbn;
}
public float getPrecio() {
return precio;
}
public void setPrecio(float precio) {
this.precio = precio;
}
public int getnUnidades() {
return nUnidades;
}
public void setnUnidades(int nUnidades) {
this.nUnidades = nUnidades;
}
@Override
public String toString() {
return "Libro: " + "titulo => " + titulo + ", autor => " + autor
+ ", isbn => " + isbn + ", precio => " + precio
+ ", unidades => " + nUnidades;
}
@Override
public int hashCode() {
int hash = 3;
hash = 17 * hash + Objects.hashCode(this.titulo);
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
final Libro other = (Libro) obj;
if (!Objects.equals(this.titulo, other.titulo)) {
return false;
}
return true;
}
@Override
public int compareTo(Object t) {
Libro li = (Libro) t;
if (this.titulo.compareToIgnoreCase(li.titulo) == 0) {
return 0;
} else if (this.titulo.compareToIgnoreCase(li.titulo) > 0) {
return 1;
} else {
return -1;
}
}
}
| [
"[email protected]"
] | |
42d236c043594b7ac7f31f37cec549941664ed02 | 3f67f033f92962eaa645b8a286a1a4a504020825 | /smartlock/mobile/app/src/main/java/com/lyoko/smartlock/Activities/AutoUnlockDevicesActivity.java | bc202039be57195f2a27090c876a970180f779c6 | [] | no_license | HienPhuong99/SmartLock2 | 6c677a5a626abd52c20c52708470452b472f6ec4 | 7c512fbddbd0e5d77a60d5e6bf1a79f4112d8b3a | refs/heads/master | 2022-09-08T13:12:00.496707 | 2020-05-23T11:24:37 | 2020-05-23T11:24:37 | 266,321,353 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,536 | java | package com.lyoko.smartlock.Activities;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.widget.Toolbar;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothManager;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.lyoko.smartlock.Adapters.TrustedDevicesAdapter;
import com.lyoko.smartlock.Adapters.UnknownDevicesAdapter;
import com.lyoko.smartlock.Interface.iTrustedDevice;
import com.lyoko.smartlock.LyokoActivity;
import com.lyoko.smartlock.Models.BLE_Device;
import com.lyoko.smartlock.R;
import com.lyoko.smartlock.Utils.Database_Helper;
import com.lyoko.smartlock.Utils.LoadingDialog;
import com.lyoko.smartlock.Utils.SetupStatusBar;
import java.util.ArrayList;
import static com.lyoko.smartlock.Utils.LyokoString.DEVICE_ADDRESS;
import static com.lyoko.smartlock.Utils.LyokoString.DEVICE_TYPE;
import static com.lyoko.smartlock.Utils.LyokoString.OWNER_PHONE_NUMBER;
import static com.lyoko.smartlock.Utils.LyokoString.TRUSTED_DEVICES_ADDRESS;
import static com.lyoko.smartlock.Utils.LyokoString.TRUSTED_DEVICES_NAME;
import static com.lyoko.smartlock.Utils.LyokoString.TRUSTED_DEVICES_UPDATE;
import static com.lyoko.smartlock.Utils.LyokoString.phone_login;
public class AutoUnlockDevicesActivity extends LyokoActivity implements UnknownDevicesAdapter.OnUnknownBLEDeviceClickedListener, TrustedDevicesAdapter.OnTrustedDeviceClickedListener, iTrustedDevice {
private static final int REQUEST_ENABLE_BT = 1;
Toolbar trusted_devices_toolbar;
static RecyclerView trusted_device_recycle_view;
Button btn_add_trusted_device;
String device_count = "0";
String add_trusted_device_name, add_trusted_device_address, device_type;
ArrayList<BLE_Device> unknownList = new ArrayList<>();
ArrayList<String> _unknownList = new ArrayList<>();
ArrayList<String> trustedList = new ArrayList<>();
BluetoothAdapter bluetoothAdapter;
BluetoothManager bluetoothManager;
LoadingDialog loadingDialog ;
private boolean mScanning;
private Handler handler;
private static final long SCAN_PERIOD = 3000;
String current_device_address, owner_phone_number;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_auto_unlock_devices);
SetupStatusBar.setup(AutoUnlockDevicesActivity.this);
trusted_devices_toolbar = findViewById(R.id.trusted_devices_toolbar);
trusted_device_recycle_view = findViewById(R.id.trusted_device_recycle_view);
btn_add_trusted_device = findViewById(R.id.btn_add_trusted_device);
loadingDialog = new LoadingDialog(AutoUnlockDevicesActivity.this);
trusted_devices_toolbar.setTitle("Quản lý thiết bị Auto Unlock");
// setSupportActionBar(trusted_devices_toolbar);
Bundle bundle = getIntent().getExtras();
current_device_address = bundle.getString(DEVICE_ADDRESS);
owner_phone_number = bundle.getString(OWNER_PHONE_NUMBER);
device_type = bundle.getString(DEVICE_TYPE);
new Database_Helper().getTrustedDevice(current_device_address, this);
loadingDialog.startLoading("Đang lấy giữ liệu");
bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
bluetoothAdapter = bluetoothManager.getAdapter();
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
handler = new Handler();
mScanning = false;
btn_add_trusted_device.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!mScanning) scanLeDevice(false);
loadingDialog.startLoading("Đang tìm kiếm");
_unknownList.clear();
unknownList.clear();
scanLeDevice(true);
}
});
}
private BluetoothAdapter.LeScanCallback leScanCallback =
new BluetoothAdapter.LeScanCallback() {
@Override
public void onLeScan(final BluetoothDevice device, final int rssi,
byte[] scanRecord) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (device.getName() != null )
if (!trustedList.contains(device.getName()))
if (!_unknownList.contains(device.getAddress()) && rssi > -69){
_unknownList.add(device.getAddress());
unknownList.add(new BLE_Device(device.getName(),device.getAddress().toLowerCase()));
}
}
});
}
};
private void scanLeDevice(final boolean enable) {
if (enable) {
handler.postDelayed(new Runnable() {
@Override
public void run() {
mScanning = false;
bluetoothAdapter.stopLeScan(leScanCallback);
loadingDialog.stopLoading();
showUnknownDevice();
}
}, SCAN_PERIOD);
mScanning = true;
bluetoothAdapter.startLeScan(leScanCallback);
} else {
mScanning = false;
bluetoothAdapter.stopLeScan(leScanCallback);
}
}
private void showUnknownDevice() {
AlertDialog.Builder builder = new AlertDialog.Builder(AutoUnlockDevicesActivity.this);
LayoutInflater inflater = getLayoutInflater();
final View view = inflater.inflate(R.layout.dialog_scanned_unknown_devices,null);
RecyclerView unknown_device_recycle_view = view.findViewById(R.id.unknown_device_recycle_view);
TextView tv_rescan = view.findViewById(R.id.tv_rescan);
TextView tv_add_trusted_device_confirm = view.findViewById(R.id.tv_add_trusted_device_confirm);
TextView tv_nothing_to_show = view.findViewById(R.id.tv_nothing_to_show);
if (unknownList.size()== 0) {
tv_add_trusted_device_confirm.setEnabled(false);
tv_nothing_to_show.setVisibility(View.VISIBLE);
}
UnknownDevicesAdapter unknownDevicesAdapter = new UnknownDevicesAdapter(this, unknownList);
unknownDevicesAdapter.setOnUnknownBLEDeviceClickedListener(this);
unknown_device_recycle_view.setAdapter(unknownDevicesAdapter);
unknown_device_recycle_view.setLayoutManager(new LinearLayoutManager(this));
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
tv_add_trusted_device_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(AutoUnlockDevicesActivity.this, "Thêm Thành Công", Toast.LENGTH_SHORT).show();
new Database_Helper().addTrustedDevice(current_device_address, device_count, add_trusted_device_name, add_trusted_device_address, device_type);
dialog.dismiss();
}
});
tv_rescan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
loadingDialog.startLoading("Đang tìm lại");
_unknownList.clear();
unknownList.clear();
scanLeDevice(true);
}
});
dialog.show();
}
@Override
public void onUnknownBLEDeviceClickedListener(final String ble_name, final String ble_address) {
add_trusted_device_name = ble_name;
add_trusted_device_address = ble_address;
}
@Override
public void onTrustedDeviceClickedListener(final int position) {
AlertDialog.Builder builder = new AlertDialog.Builder(AutoUnlockDevicesActivity.this);
LayoutInflater inflater = getLayoutInflater();
final View view = inflater.inflate(R.layout.dialog_remove_trusted_device,null);
TextView tv_trusted_device_name = view.findViewById(R.id.tv_trusted_device_name);
TextView tv_dialog_remove_trusted_device_cancel = view.findViewById(R.id.tv_dialog_remove_trusted_device_cancel);
TextView tv_dialog_remove_trusted_device_confirm = view.findViewById(R.id.tv_dialog_remove_trusted_device_confirm);
tv_trusted_device_name.setText("Bạn có muốn xóa thiết bị "+ trustedList.get(position)+ " ra khỏi danh sách thiết bị tin cậy không?");
builder.setView(view);
final AlertDialog dialog = builder.create();
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
tv_dialog_remove_trusted_device_confirm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
trustedList.remove(position);
UnknownDevicesAdapter unknownDevicesAdapter = new UnknownDevicesAdapter(AutoUnlockDevicesActivity.this, unknownList);
unknownDevicesAdapter.setOnUnknownBLEDeviceClickedListener(AutoUnlockDevicesActivity.this);
trusted_device_recycle_view.setAdapter(unknownDevicesAdapter);
trusted_device_recycle_view.setLayoutManager(new LinearLayoutManager(AutoUnlockDevicesActivity.this));
Toast.makeText(AutoUnlockDevicesActivity.this, "Xóa Thành Công", Toast.LENGTH_SHORT).show();
new Database_Helper().updateTrustedDevices(position,current_device_address,TRUSTED_DEVICES_ADDRESS);
new Database_Helper().updateTrustedDevices(position,current_device_address,TRUSTED_DEVICES_NAME);
new Database_Helper().changed_update_code(owner_phone_number,current_device_address,device_type,TRUSTED_DEVICES_UPDATE);
dialog.dismiss();
}
});
tv_dialog_remove_trusted_device_cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
@Override
public void showTrustedDevice(ArrayList<String> list) {
trustedList = list;
loadingDialog.stopLoading();
device_count = String.valueOf(list.size());
TrustedDevicesAdapter adapter = new TrustedDevicesAdapter(AutoUnlockDevicesActivity.this, trustedList);
adapter.setOnTrustedDeviceClickedListener(this);
trusted_device_recycle_view.setAdapter(adapter);
trusted_device_recycle_view.setLayoutManager(new LinearLayoutManager(this));
}
@Override
public void noDeviceToShow() {
Toast.makeText(AutoUnlockDevicesActivity.this, "Không có gì", Toast.LENGTH_SHORT).show();
}
}
| [
"[email protected]"
] | |
5a1cce429006a43514a70ef9bf94133527911e0e | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/8/8_1f2a2392e006b5ef5529b32e0fbc9abae3ea3f26/MouseHandler/8_1f2a2392e006b5ef5529b32e0fbc9abae3ea3f26_MouseHandler_t.java | 12780cc19b13ecd32e703618ecc3db259606be5a | [] | no_license | zhongxingyu/Seer | 48e7e5197624d7afa94d23f849f8ea2075bcaec0 | c11a3109fdfca9be337e509ecb2c085b60076213 | refs/heads/master | 2023-07-06T12:48:55.516692 | 2023-06-22T07:55:56 | 2023-06-22T07:55:56 | 259,613,157 | 6 | 2 | null | 2023-06-22T07:55:57 | 2020-04-28T11:07:49 | null | UTF-8 | Java | false | false | 1,251 | java | package net.schattenkind.androidLove;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnLongClickListener;
import android.view.View.OnTouchListener;
public class MouseHandler implements OnClickListener, OnLongClickListener,
OnTouchListener {
private LoveVM vm;
private View view;
public MouseHandler(View view, LoveVM vm) {
this.view = view;
this.vm = vm;
this.view.setOnClickListener(this);
this.view.setOnLongClickListener(this);
this.view.setOnTouchListener(this);
}
//~ @Override // compile error on arch linux sun java
public boolean onLongClick(View v) {
return false;
}
//~ @Override // compile error on arch linux sun java
public void onClick(View v) {
}
//~ @Override // compile error on arch linux sun java
public boolean onTouch(View v, MotionEvent event) {
int x = (int) event.getX();
int y = (int) event.getY();
vm.feedPosition(x, y);
int action = event.getAction();
if (action == MotionEvent.ACTION_DOWN) {
vm.feedButtonState(true, false, false);
} else if (action == MotionEvent.ACTION_UP) {
vm.feedButtonState(false, false, false);
}
return true;
}
}
| [
"[email protected]"
] | |
a3b8035b79dff7f4c7219666123cf9397de8e1f9 | 4fdb3d11b2a6f7ec83bd6c603d95b24db8a8a3f5 | /plugin/src/main/java/com/stratio/cassandra/lucene/util/GeospatialUtils.java | 6768cbda940fe999ad2dca2950b0a16a4d70137a | [
"Apache-2.0"
] | permissive | adelapena/cassandra-lucene-index | ab3e87c931feecb86b7214ed9adbd551801782ef | b54d4e646104c33c20283bfd57287e18f7db3cca | refs/heads/branch-2.2.4 | 2021-01-01T05:24:10.488883 | 2016-03-04T14:03:17 | 2016-03-04T14:03:17 | 48,164,726 | 1 | 0 | null | 2015-12-17T09:21:35 | 2015-12-17T09:21:35 | null | UTF-8 | Java | false | false | 1,847 | java | /*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.stratio.cassandra.lucene.util;
import com.stratio.cassandra.lucene.IndexException;
import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
/**
* Utilities for geospatial related stuff.
*
* @author Andres de la Pena {@literal <[email protected]>}
*/
public class GeospatialUtils {
public static final int DEFAULT_GEOHASH_MAX_LEVELS = 11;
/**
* Checks if the specified max levels is correct.
*
* @param maxLevels The maximum number of levels in the tree.
* @return The validated max levels.
*/
public static int validateGeohashMaxLevels(Integer maxLevels) {
if (maxLevels == null) {
return DEFAULT_GEOHASH_MAX_LEVELS;
} else if (maxLevels < 1 || maxLevels > GeohashPrefixTree.getMaxLevelsPossible()) {
throw new IndexException("max_levels must be in range [1, %s], but found %s",
GeohashPrefixTree.getMaxLevelsPossible(),
maxLevels);
}
return maxLevels;
}
}
| [
"[email protected]"
] | |
dbaa6358d0df8c2aa57966e219d27483af7da697 | 8859916fdb4c5a35c43e13c5fc9b86f5fcfce1ef | /nware/src/main/java/com/ware/narang/security/repository/AuthoritiesRepository.java | 3e83029d1c43ec3c65602f394b390dfe4ba61ff2 | [] | no_license | kuku2000213/naws | f858199e57cc56278699a4173307602397113bc5 | 20c22da4f30d5ac593970e3514ff835dd31ef58d | refs/heads/main | 2023-01-22T13:57:46.254351 | 2020-12-04T08:38:41 | 2020-12-04T08:38:41 | 318,129,742 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 246 | java | package com.ware.narang.security.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.ware.narang.security.entity.Authorities;
public interface AuthoritiesRepository extends JpaRepository<Authorities, Long>{
}
| [
"[email protected]"
] | |
7c5b6fe4bcaa419bfc940435b3a84e8fd75d1f95 | 64c3541fd204070a74881818a8905359a641799b | /src/main/java/cn/net/yto/o2iMonitor/config/redis/O2iConfigRedisConfig.java | 159ca18e22ae6d5b0feafd4192f7865460adf90b | [
"Apache-2.0"
] | permissive | YWADMIN/MonitorPlatform | 71ec2712be098920f49fce82e390eef0c7326898 | dfe31bf9f125b76246d1ed8f1ff805c3f0fe95d6 | refs/heads/master | 2023-04-18T14:38:20.585090 | 2017-07-25T08:49:24 | 2017-07-25T08:49:24 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,787 | java | /*
* Copyright © 2015-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cn.net.yto.o2iMonitor.config.redis;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
/**
*
*
* @author zhangxin
* @since 2017年6月26日
*/
@Configuration
public class O2iConfigRedisConfig {
@Bean(name="o2iConfigJedisPoolConfig")
@ConfigurationProperties(prefix = "spring.redis.o2iConfig")
public JedisPoolConfig getJedisPoolConfig() {
return new JedisPoolConfig();
}
@Bean(name="o2iConfigJedisPool")
public JedisPool getJedisPool(@Qualifier("o2iConfigJedisPoolConfig") JedisPoolConfig config,
@Value("${spring.redis.o2iConfig.host}")String host,
@Value("${spring.redis.o2iConfig.port}")int port,
@Value("${spring.redis.o2iConfig.timeOut}")int timeOut) {
return new JedisPool(config, host, port, timeOut);
}
}
| [
"[email protected]"
] | |
64749916f0b8e1f08e85523509a6516039b1f979 | 60b955106287c3704d0b9f71e28e74f76c162134 | /src/main/java/kr/ac/kopo/board/dao/BoardDAOImpl.java | 9d500667e357e6948b735ddc47997be83c4c5305 | [] | no_license | park-cheonho/numberTicket | 3001951734ad6eda2fd93eed75ed0a83eab3c713 | 4f743365a78cdc9593d2e2d47d6ceb3bb4ee8e8f | refs/heads/master | 2022-12-29T09:05:13.224504 | 2020-10-19T04:59:23 | 2020-10-19T04:59:23 | 305,265,240 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,209 | java | package kr.ac.kopo.board.dao;
import java.util.List;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import kr.ac.kopo.board.vo.BoardVO;
/**
* impl = implements
* @author cheon
*
*/
//디비에 관련된 애들은 어노테이션으로 @Repository 많이씀
@Repository
//커넥션 객체 필요없고 마이바티스로 함
public class BoardDAOImpl implements BoardDAO{
@Autowired
private SqlSessionTemplate sqlSession;
@Override
public List<BoardVO> selectAll() {
List<BoardVO> boardList = sqlSession.selectList("board.dao.BoardDAO.selectAll");
return boardList;
}
@Override
public void insert(BoardVO board) {
sqlSession.insert("board.dao.BoardDAO.insert", board);
}
@Override
public BoardVO selectByNo(int no) {
BoardVO board = sqlSession.selectOne("board.dao.BoardDAO.selectByNo", no);
return board;
}
@Override
public void incrementReplyCnt(int no) {
sqlSession.update("board.dao.BoardDAO.incrementReplyCnt", no);
}
@Override
public void reduceReplyCnt(int no) {
sqlSession.update("board.dao.BoardDAO.reduceReplyCnt", no);
}
}
| [
"[email protected]"
] | |
3f9566912e6b8716a8ac4c7d9a1839b79649ebfc | 591e7a4053e2b6e8397ea0c0a47c446d7476e3a9 | /hystrix-dashboard/src/main/java/cn/blackme/hystrixdashboard/controller/ConsumerController.java | d0ff28ace499fb2b922ed8c84a688fce73951131 | [
"MIT"
] | permissive | linch1996/springcloudexample | 1354f8b3bae20d76fbaf982d132a42ee8dec33a5 | de1855883821db57e465b62f7e5a7676e8b2a9b2 | refs/heads/master | 2020-07-02T02:26:48.167330 | 2020-02-19T02:37:56 | 2020-02-19T02:37:56 | 201,384,651 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 763 | java | package cn.blackme.hystrixdashboard.controller;
import cn.blackme.hystrixdashboard.service.RemoteService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class ConsumerController {
@Autowired
RemoteService remoteService;
// 需要使用HystrixCommand才能看到图表
@HystrixCommand
@GetMapping("/hello/{name}")
public String home(@PathVariable("name") String name) {
return remoteService.home(name);
}
}
| [
"[email protected]"
] | |
03c9be332492aaa13a6ab08d7da9de3b69550717 | 445b3528c2b82ad740c06b0aefaa251154f85e43 | /src/soc/qase/file/dm2/DM2Recorder.java | e585ed8a6c17f1aede325318ed1792a4d0a634d8 | [] | no_license | orb1t-ua/qase | 1e8cc6ca7187110603a2dd58488fdf3cd898681b | 43dfb531e533c6481dfac75bd1c44e48a73984c3 | refs/heads/master | 2021-12-06T15:36:20.353041 | 2009-07-30T06:42:48 | 2015-11-15T14:53:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,225 | java | //---------------------------------------------------------------------
// Name: DM2Recorder.java
// Author: [email protected]
//---------------------------------------------------------------------
package soc.qase.file.dm2;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import soc.qase.com.message.Message;
import soc.qase.com.message.ServerData;
import soc.qase.com.message.ServerDownload;
import soc.qase.com.message.ServerReconnect;
import soc.qase.com.message.ServerStuffText;
import soc.qase.com.packet.ServerPacket;
import soc.qase.tools.Utils;
/*-------------------------------------------------------------------*/
/** The DM2Recorder allows the agent to automatically record a demo of
* itself during play. Improves upon Quake 2's standard recording
* facilities by allowing demos spanning multiple maps to be recorded
* in playable format. The incoming network stream is sampled, edited
* as necessary, and saved to file when the agent disconnects from
* the server or as an intermediate step whenever the map is changed. */
/*-------------------------------------------------------------------*/
public class DM2Recorder
{
protected File dm2File = null;
protected String filename = null;
protected byte[] inData = null;
protected byte[] blockLength = null;
protected BufferedInputStream bufIn = null;
protected BufferedOutputStream bufOut = null;
protected ByteArrayOutputStream store = null;
protected ByteArrayOutputStream storeHeader = null;
protected boolean recording = false;
/*-------------------------------------------------------------------*/
/** Default constructor. Prepares the DM2Recorder to start saving the
* session. */
/*-------------------------------------------------------------------*/
public DM2Recorder()
{
initRecorder();
}
/*-------------------------------------------------------------------*/
/** Constructor. Instantiates the DM2Recorder and creates the specified
* file.
* @param fName the filename under which to save the recording */
/*-------------------------------------------------------------------*/
public DM2Recorder(String fName)
{
initRecorder();
startRecording(fName);
}
private void initRecorder()
{
blockLength = new byte[4];
store = new ByteArrayOutputStream(500 * 1024);
storeHeader = new ByteArrayOutputStream(500 * 1024);
}
/*-------------------------------------------------------------------*/
/** Start recording to the specified file. Called by Proxy if the user
* stipulates that the session should be saved while connecting to
* the game server.
* @param fName the filename under which to save the recording
* @return true if the file was successfully created, false otherwise
* @see soc.qase.com.Proxy#connect(String, int, String) */
/*-------------------------------------------------------------------*/
public synchronized boolean startRecording(String fName)
{
if(recording)
stopRecording();
filename = fName;
try
{ bufOut = new BufferedOutputStream(new FileOutputStream(filename)); }
catch(Exception e)
{ return false; }
return (recording = true);
}
/*-------------------------------------------------------------------*/
/** Add a block of data to the recording. Called by Proxy to record a
* block of normal in-game data, as distinct from header data.
* @param block the block of data to be added
* @see #addHeader(byte[])
* @see soc.qase.com.Proxy#processIncomingDataPacket(byte[]) */
/*-------------------------------------------------------------------*/
public synchronized void addData(byte[] block)
{
if(!recording)
return;
block = filterData(block);
Utils.intToByteArray(block.length, blockLength, 0);
try
{
store.write(blockLength);
store.write(block);
}
catch(IOException ioe)
{ }
}
/*-------------------------------------------------------------------*/
/** Add a block of header data to the recording. Called by Proxy to
* record the header data received upon entering a new map, as distinct
* from normal in-game data.
* @param block the block of header data to be added
* @see #addData(byte[])
* @see soc.qase.com.Proxy#processIncomingDataPacket(byte[]) */
/*-------------------------------------------------------------------*/
public synchronized void addHeader(byte[] block)
{
block = filterData(block);
Utils.intToByteArray(block.length, blockLength, 0);
try
{
storeHeader.write(blockLength);
storeHeader.write(block);
}
catch(IOException ioe)
{ }
}
private byte[] filterData(byte[] incomingData)
{
byte[] temp = new byte[0];
byte[] result = new byte[0];
byte[] curData = new byte[0];
if(incomingData != null)
{
int dataIndex = 8;
while(dataIndex != incomingData.length)
{
ServerPacket sPacket = new ServerPacket(incomingData, dataIndex);
Message msg = sPacket.getMessage();
if(msg instanceof ServerStuffText)
{
String text = Utils.stringValue(incomingData, dataIndex + 1, Utils.stringLength(incomingData, dataIndex + 1));
if(text.indexOf("precache") != -1)
curData = new byte[]{11, 'p', 'r', 'e', 'c', 'a', 'c', 'h', 'e', '\n', '\0'};
else if(text.indexOf("cmd configstring") != -1 || text.indexOf("cmd baseline") != -1 || text.indexOf("record") != -1)
curData = null;
else
curData = Utils.extractBytes(incomingData, dataIndex, sPacket.getLength());
}
else if(msg instanceof ServerData)
{
curData = Utils.extractBytes(incomingData, dataIndex, sPacket.getLength());
Utils.intToByteArray(65578, curData, 5);
curData[9] = 1;
}
else if(msg instanceof ServerReconnect || msg instanceof ServerDownload)
curData = null;
else
curData = Utils.extractBytes(incomingData, dataIndex, sPacket.getLength());
if(curData != null)
result = Utils.concatBytes(result, curData);
dataIndex += sPacket.getLength();
}
}
return result;
}
/*-------------------------------------------------------------------*/
/** Signal to the DM2Recorder that the agent has entered a new map. The
* data recorded thus far is dumped to file, in preparation for the
* data to be received from the new map. Called by the Proxy upon
* receipt of a ServerReconnect message.
* @see soc.qase.com.Proxy#run */
/*-------------------------------------------------------------------*/
public synchronized void newMap()
{
writeCurrentData();
}
/*-------------------------------------------------------------------*/
/** Stop recording and close the specified file. Called by Proxy when the
* agent disconnects from the game server.
* @return true if the file was successfully closed, false otherwise
* @see soc.qase.com.Proxy#disconnect(boolean) */
/*-------------------------------------------------------------------*/
public synchronized boolean stopRecording()
{
if(!recording)
return false;
try
{
Utils.intToByteArray(-1, blockLength, 0);
store.write(blockLength);
writeCurrentData();
bufOut.close();
}
catch(IOException ioe)
{
return false;
}
recording = false;
return true;
}
private boolean writeCurrentData()
{
if(store.size() < 5) // no game data was recorded, only an endblock
{
store.reset();
storeHeader.reset();
return true;
}
try
{ storeHeader.writeTo(bufOut);
store.writeTo(bufOut);
storeHeader.reset();
store.reset();
bufOut.flush();
}
catch(Exception e)
{
return false;
}
return true;
}
/*-------------------------------------------------------------------*/
/** Check whether the DM2Recorder is currently recording to file.
* @return true if the DM2Recorder is recording, false otherwise */
/*-------------------------------------------------------------------*/
public boolean isRecording()
{
return recording;
}
}
| [
"[email protected]"
] | |
edc36ec524796ddbb69cd311d2f3b40728750055 | ed70f3b7189afd587fe9a9ecbdf49b6cb2bea43a | /A684_RedundantConnection.java | b051e3056932ae09bc2fcf5b9626804e56137a65 | [] | no_license | wfei26/LeetCode-Java | 9fb25a3f5a8377469a74b2945ecbd4114e57e860 | ed710da888d25e3d67342c16d957423c8e06873f | refs/heads/master | 2020-03-28T15:21:57.599960 | 2019-04-23T01:09:31 | 2019-04-23T01:09:31 | 148,585,375 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,032 | java | public class A684_RedundantConnection {
public static void main(String[] args) {
A684_RedundantConnection solution = new A684_RedundantConnection();
int[][] inputs = {{1,2}, {1,3}, {2,3}};
int[] output = solution.findRedundantConnection(inputs);
System.out.println(output[0] + " " + output[1]);
}
class UnionFind {
private int[] parent;
private int[] rank;
public UnionFind(int size) {
//WARNING: we should use size + 1 at here, since this problem start from number 1, not 0
parent = new int[size + 1];
rank = new int[size + 1];
for (int i = 1; i < size + 1; i++) {
parent[i] = i;
rank[i] = 1;
}
}
public int find(int x) {
if (x != parent[x]) {
parent[x] = find(parent[x]);
}
return parent[x];
}
public boolean union(int a, int b) {
int parentA = find(a);
int parentB = find(b);
if (parentA == parentB) {
return false;
}
//CAUTION: DO NOT use input a or b below, must use parentA or parentB
if (rank[parentA] == rank[parentB]) {
parent[parentA] = parentB;
rank[parentB]++;
}
else if (rank[parentA] > rank[parentB]) {
parent[parentB] = parentA;
}
else {
parent[parentA] = parentB;
}
return true;
}
}
public int[] findRedundantConnection(int[][] edges) {
UnionFind unionFind = new UnionFind(edges.length);
//traverse all edges, once find two number in an edge cannot union together,
//it means they have already union before, this edge is redundant
for (int[] edge : edges) {
if (!unionFind.union(edge[0], edge[1])) {
return edge;
}
}
return null;
}
}
| [
"[email protected]"
] | |
782b893cf3c7dd5c6a8d3321ef095abf74e7cace | 8e48ee5cfbaf19d3bfd1da6620068f59be5c8287 | /app/src/main/java/com/kidozh/discuzhub/adapter/ForumAdapter.java | dafe8352e4f3a044689812c11944afa3bbe6cfda | [
"MIT",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | qzznbbs/DiscuzHub | 05382dbeafe5a2975380799aa5853df920f4d684 | 83f3ae0850cc6ac37eeb040d47196cc7532fb454 | refs/heads/master | 2022-12-07T03:51:10.017034 | 2020-09-06T16:30:34 | 2020-09-06T16:30:34 | 292,602,447 | 0 | 0 | MIT | 2020-09-06T16:30:35 | 2020-09-03T15:03:11 | Java | UTF-8 | Java | false | false | 8,730 | java | package com.kidozh.discuzhub.adapter;
import android.content.Context;
import android.content.Intent;
import android.text.Html;
import android.text.SpannableString;
import android.text.Spanned;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.cardview.widget.CardView;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.request.RequestOptions;
import com.kidozh.discuzhub.R;
import com.kidozh.discuzhub.activities.ForumActivity;
import com.kidozh.discuzhub.entities.bbsInformation;
import com.kidozh.discuzhub.entities.ForumInfo;
import com.kidozh.discuzhub.entities.forumUserBriefInfo;
import com.kidozh.discuzhub.utilities.UserPreferenceUtils;
import com.kidozh.discuzhub.utilities.VibrateUtils;
import com.kidozh.discuzhub.utilities.bbsConstUtils;
import java.io.InputStream;
import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
import static com.kidozh.discuzhub.utilities.networkUtils.getPreferredClient;
public class ForumAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private String TAG = ForumAdapter.class.getSimpleName();
private Context mContext;
private List<ForumInfo> forumInfoList;
private String jsonString;
private bbsInformation bbsInfo;
private forumUserBriefInfo curUser;
ForumAdapter(Context context, String jsonObject, bbsInformation bbsInformation, forumUserBriefInfo curUser){
this.mContext = context;
this.jsonString = jsonObject;
this.bbsInfo = bbsInformation;
this.curUser = curUser;
}
public void setForumInfoList(List<ForumInfo> forumInfoList) {
this.forumInfoList = forumInfoList;
notifyDataSetChanged();
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = LayoutInflater.from(context);
boolean shouldAttachToParentImmediately = false;
if(UserPreferenceUtils.conciseRecyclerView(context)){
View view = inflater.inflate(R.layout.item_forum_concise, parent, shouldAttachToParentImmediately);
return new ConciseForumViewHolder(view);
}
else {
View view = inflater.inflate(R.layout.item_forum, parent, shouldAttachToParentImmediately);
return new ForumViewHolder(view);
}
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holderRaw, int position) {
ForumInfo forum = forumInfoList.get(position);
if(holderRaw instanceof ConciseForumViewHolder){
// support rich text
ConciseForumViewHolder holder = (ConciseForumViewHolder) holderRaw;
Spanned sp = Html.fromHtml(forum.name,null,null);
holder.mForumName.setText(sp, TextView.BufferType.SPANNABLE);
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(getPreferredClient(this.mContext));
Glide.get(mContext).getRegistry().replace(GlideUrl.class, InputStream.class,factory);
Glide.with(mContext)
.load(forum.iconUrl)
.apply(RequestOptions
.placeholderOf(R.drawable.ic_forum_24px)
.error(R.drawable.ic_forum_24px))
.into(holder.mBBSForumImage);
holder.mCardview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, ForumActivity.class);
intent.putExtra(bbsConstUtils.PASS_FORUM_THREAD_KEY,forum);
intent.putExtra(bbsConstUtils.PASS_BBS_ENTITY_KEY,bbsInfo);
intent.putExtra(bbsConstUtils.PASS_BBS_USER_KEY,curUser);
Log.d(TAG,"put base url "+bbsInfo.base_url);
VibrateUtils.vibrateForClick(mContext);
mContext.startActivity(intent);
}
});
if(forum.todayPosts != 0){
holder.mTodayPosts.setVisibility(View.VISIBLE);
if(forum.todayPosts >= 100){
holder.mTodayPosts.setText(R.string.forum_today_posts_over_much);
holder.mTodayPosts.setBackgroundColor(mContext.getColor(R.color.colorAlizarin));
}
else {
holder.mTodayPosts.setText(String.valueOf(forum.todayPosts));
holder.mTodayPosts.setBackgroundColor(mContext.getColor(R.color.colorPrimary));
}
}
else {
holder.mTodayPosts.setVisibility(View.GONE);
}
}
else {
ForumViewHolder holder = (ForumViewHolder) holderRaw;
Spanned sp = Html.fromHtml(forum.name,null,null);
holder.mForumName.setText(sp, TextView.BufferType.SPANNABLE);
OkHttpUrlLoader.Factory factory = new OkHttpUrlLoader.Factory(getPreferredClient(this.mContext));
Glide.get(mContext).getRegistry().replace(GlideUrl.class, InputStream.class,factory);
Glide.with(mContext)
.load(forum.iconUrl)
.apply(RequestOptions
.placeholderOf(R.drawable.ic_forum_24px)
.error(R.drawable.ic_forum_24px))
.into(holder.mBBSForumImage);
holder.mCardview.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(mContext, ForumActivity.class);
intent.putExtra(bbsConstUtils.PASS_FORUM_THREAD_KEY,forum);
intent.putExtra(bbsConstUtils.PASS_BBS_ENTITY_KEY,bbsInfo);
intent.putExtra(bbsConstUtils.PASS_BBS_USER_KEY,curUser);
Log.d(TAG,"put base url "+bbsInfo.base_url);
VibrateUtils.vibrateForClick(mContext);
mContext.startActivity(intent);
}
});
if(forum.todayPosts != 0){
holder.mTodayPosts.setVisibility(View.VISIBLE);
if(forum.todayPosts >= 100){
holder.mTodayPosts.setText(R.string.forum_today_posts_over_much);
holder.mTodayPosts.setTextColor(mContext.getColor(R.color.colorAlizarin));
}
else {
holder.mTodayPosts.setText(String.valueOf(forum.todayPosts));
holder.mTodayPosts.setTextColor(mContext.getColor(R.color.colorPrimary));
}
}
else {
holder.mTodayPosts.setVisibility(View.GONE);
}
// description
sp = Html.fromHtml(forum.description);
SpannableString spannableString = new SpannableString(sp);
holder.mDescription.setText(spannableString, TextView.BufferType.SPANNABLE);
}
}
@Override
public int getItemCount() {
if(forumInfoList == null){
return 0;
}
else {
return forumInfoList.size();
}
}
public class ForumViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.bbs_forum_imageview)
ImageView mBBSForumImage;
@BindView(R.id.bbs_forum_name)
TextView mForumName;
@BindView(R.id.bbs_forum_cardview)
CardView mCardview;
@BindView(R.id.bbs_forum_today_posts)
TextView mTodayPosts;
@BindView(R.id.bbs_forum_description)
TextView mDescription;
public ForumViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this,itemView);
}
}
public class ConciseForumViewHolder extends RecyclerView.ViewHolder{
@BindView(R.id.bbs_forum_imageview)
ImageView mBBSForumImage;
@BindView(R.id.bbs_forum_name)
TextView mForumName;
@BindView(R.id.bbs_forum_cardview)
CardView mCardview;
@BindView(R.id.bbs_forum_today_posts)
TextView mTodayPosts;
public ConciseForumViewHolder(@NonNull View itemView) {
super(itemView);
ButterKnife.bind(this,itemView);
}
}
}
| [
"[email protected]"
] | |
84b05b0762454050a38efe677ceaf8e48a3686f4 | fd14952a6051714024ad36d202e32f026196fada | /unit-03-spring-cloud-ribbon/unit-03-micro-service-consumer-ribbon/src/main/java/com/zhoufa/RestTemplateConfiguration.java | 7a1b274c537018f6b675aa623403b31f2a493b7f | [] | no_license | zhoufangan/demo-spring-cloud | 6b37fc48897a60b306f427b5a181d5b891fc0e01 | aef3f4695dbc1e18ea650bb39068be0b3880725d | refs/heads/master | 2021-08-14T14:46:16.673342 | 2017-11-16T02:11:54 | 2017-11-16T02:11:54 | 107,628,115 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 480 | java | package com.zhoufa;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
/**
* @author Created by zhoufangan on 2017/10/31.
*/
@Configuration
public class RestTemplateConfiguration {
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
}
| [
"[email protected]"
] | |
e325c79d514414447b313ca9338f158ff268584a | 2fe6cc6d2fae9b9a9b400bd3de286a3d09165769 | /Exercise/Exercise10/src/main/java/com/impubudu/exercise10/listeners/StepResultListener.java | bcbf3d6ab360f9dfe94daad3922c51925aaf9aee | [] | no_license | impubudu/JavaTraining | c269c3036aac9cdc24f856cc759e7bba639ba6ee | 54d3f4fc75df60084def037800a2a92ef16c65aa | refs/heads/master | 2022-10-16T10:52:23.149312 | 2022-10-04T10:33:35 | 2022-10-04T10:33:35 | 200,842,576 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 745 | java | package com.impubudu.exercise10.listeners;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.annotation.AfterStep;
import org.springframework.batch.core.annotation.BeforeStep;
import org.springframework.stereotype.Component;
@Component
public class StepResultListener {
@BeforeStep
public void beforeStep(StepExecution stepExecution) {
System.out.println("Called beforeStep().");
stepExecution.getJobExecution().getExecutionContext().get("name");
}
@AfterStep
public ExitStatus afterStep(StepExecution stepExecution) {
System.out.println("Called afterStep().");
return ExitStatus.COMPLETED;
}
}
| [
"[email protected]"
] | |
2fd4a0f8c56831057ebd99226bfbcd94ee70c656 | d182a803fa165f5e2841feb41d2a593c4c36923f | /2021-03-23/2021-03-23 -- Java Inheritance & polymorphism Sec2/src/resource/Pistol.java | c5daf8d97210e901e995715717c5fdb3a65e7ac2 | [] | no_license | RafiKK98/CSE213Spr21 | 259d673b0fe97777099b597d82216bcda83c0bd9 | 443d308744b22c5a38bc6c2e2ba86da320f85f70 | refs/heads/main | 2023-04-03T23:41:07.387244 | 2021-04-06T08:34:04 | 2021-04-06T08:34:04 | 338,596,147 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 297 | java | package resource;
public class Pistol extends Weapon{
//public void overhaulPistol(){
@Override
public void overhaul(){
System.out.println("Pistol is overhauled");
}
public void loadMagazine(){
System.out.println("Magazine is loaded.");
}
}
| [
"[email protected]"
] | |
964a674a643f8691666a87a03f64d24e1463b50e | 290e28e293a1e3ae6583a2bc22f2b11353a2180a | /module_listen/src/main/java/com/housaiying/qingting/listen/fragment/HistoryFragment.java | 2e6cf749c3fd000e87162561d3568aae59fe8671 | [
"Apache-2.0"
] | permissive | shuaixiaohou/Qingting | 4fe6814a2373cebe1596efc421520b35fe954b31 | 23db484be25c94e45f71b9f1d766a1b9b407b0ac | refs/heads/master | 2021-03-29T13:56:59.499958 | 2020-07-08T06:52:09 | 2020-07-08T06:52:09 | 252,336,951 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,585 | java | package com.housaiying.qingting.listen.fragment;
import android.app.AlertDialog;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModelProvider;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.blankj.utilcode.util.CollectionUtils;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.housaiying.qingting.common.Constants;
import com.housaiying.qingting.common.databinding.CommonLayoutListBinding;
import com.housaiying.qingting.common.mvvm.view.BaseRefreshMvvmFragment;
import com.housaiying.qingting.common.mvvm.view.status.ListSkeleton;
import com.housaiying.qingting.listen.R;
import com.housaiying.qingting.listen.adapter.HistoryAdapter;
import com.housaiying.qingting.listen.bean.PlayHistoryItem;
import com.housaiying.qingting.listen.mvvm.ViewModelFactory;
import com.housaiying.qingting.listen.mvvm.viewmodel.HistoryViewModel;
import com.kingja.loadsir.callback.Callback;
import java.util.List;
/**
* Author: housaiying
* <br/>Date: 2020/3/16 8:44
* <br/>Email: [email protected]
* <br/>Description:
*/
@Route(path = Constants.Router.Listen.F_HISTORY)
public class HistoryFragment extends BaseRefreshMvvmFragment<CommonLayoutListBinding, HistoryViewModel, PlayHistoryItem> implements
BaseQuickAdapter.OnItemClickListener {
private HistoryAdapter mHistoryAdapter;
@Override
protected int onBindLayout() {
return R.layout.common_layout_list;
}
@Override
protected void initView() {
mBinding.recyclerview.setLayoutManager(new LinearLayoutManager(mActivity));
mBinding.recyclerview.setHasFixedSize(true);
mHistoryAdapter = new HistoryAdapter(null);
mHistoryAdapter.bindToRecyclerView(mBinding.recyclerview);
}
@Override
public void initListener() {
super.initListener();
mHistoryAdapter.setOnItemClickListener(this);
}
@NonNull
@Override
protected WrapRefresh onBindWrapRefresh() {
return new WrapRefresh(mBinding.refreshLayout, mHistoryAdapter);
}
@Override
public void initData() {
mViewModel.init();
}
@Override
public String[] onBindBarTitleText() {
return new String[]{"播放历史"};
}
@Override
public Integer[] onBindBarRightIcon() {
return new Integer[]{R.drawable.ic_listen_history_delete};
}
@Override
public Class<HistoryViewModel> onBindViewModel() {
return HistoryViewModel.class;
}
@Override
public ViewModelProvider.Factory onBindViewModelFactory() {
return ViewModelFactory.getInstance(mApplication);
}
@Override
public void initViewObservable() {
mViewModel.getInitHistorysEvent().observe(this, historyItems -> mHistoryAdapter.setNewData(historyItems));
}
@Override
protected void onLoadMoreSucc(List<PlayHistoryItem> list) {
//两页衔接处处理
if (!CollectionUtils.isEmpty(mHistoryAdapter.getData()) && mViewModel.dateCovert(
mHistoryAdapter.getItem(mHistoryAdapter.getData().size() - 1).data.getDatatime())
.equals(list.get(0).header)) {
list.remove(0);
}
mHistoryAdapter.addData(list);
}
@Override
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
PlayHistoryItem playHistoryItem = mHistoryAdapter.getItem(position);
if (playHistoryItem.itemType != PlayHistoryItem.HEADER) {
if (playHistoryItem.itemType == PlayHistoryItem.TRACK) {
mViewModel.playRadio(playHistoryItem.data.getGroupId(),
playHistoryItem.data.getTrack().getDataId());
} else {
mViewModel.playRadio(String.valueOf(playHistoryItem.data.getGroupId()));
}
}
}
@Override
public void onRight1Click(View v) {
super.onRight1Click(v);
new AlertDialog.Builder(mActivity)
.setMessage("确定要清空播放历史吗?")
.setNegativeButton("取消", (dialog, which) -> dialog.dismiss())
.setPositiveButton("确定", (dialog, which) -> {
mViewModel.clear();
mHistoryAdapter.getData().clear();
showEmptyView();
}).show();
}
@Override
protected boolean enableLazy() {
return false;
}
@Override
public Callback getInitStatus() {
return new ListSkeleton();
}
}
| [
"[email protected]"
] | |
d261fc821375ca8dc9d54ac37930fd2e303dfdb5 | 8e1a0e65d4537f389492c105f7e461fa13f50c0a | /app/src/test/java/com/datasoft/aidapitest/ExampleUnitTest.java | ad73d43ecf1da9821cc7dd808dfcd9434516f987 | [] | no_license | DataSoft/AIDAPItest | 81edb383e4bbbe445881fdf534c3f04726937bf4 | 83105c58abcfa3c0e39a04ad10836dc53fe669f7 | refs/heads/master | 2021-01-10T18:01:39.216847 | 2016-03-03T22:18:02 | 2016-03-03T22:18:02 | 53,088,348 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 316 | java | package com.datasoft.aidapitest;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* To work on unit tests, switch the Test Artifact in the Build Variants view.
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
7ed7fa60a5ccd7566eca51c5364cb98ea5dd254b | 5ff48b3bfdb61ed80f528f6f167d490367093806 | /src/main/java/xavier/lin/file/aggregation/FileAggregation.java | 5d4cd30995b5f7f4a5a0c65ab3c5e7dd25d2f42f | [] | no_license | Xavier321/FileAggregation | 8d3fe8bd9d321464977193108ac317559073de75 | 88e3768243de759034a5763e1b2d4aa52064e2e4 | refs/heads/master | 2021-01-23T07:08:45.147604 | 2014-10-03T19:17:52 | 2014-10-03T19:17:52 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,624 | java | package xavier.lin.file.aggregation;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileWriter;
import java.io.PrintWriter;
import java.nio.channels.FileChannel;
import java.util.Scanner;
public class FileAggregation {
public static String aggregationFileName;
public static void main(String[] args) {
String folderPath;
Scanner scanner = new Scanner(System.in);
System.out.println("Folder name (EX: pic or D:/pic):");
folderPath = scanner.next();
// getFileList("D:/eclipse_osgi/OSGI_EZB/Karaf-My-Test/JavaSE-Test/pic");
// getFileList("pic1");
// new
// File("D:/eclipse_osgi/OSGI_EZB/Karaf-My-Test/JavaSE-Test/pic/image(0).php").renameTo(
// new
// File("D:/eclipse_osgi/OSGI_EZB/Karaf-My-Test/JavaSE-Test/pic/001.jpg"));
// getFileList2(folderPath);
//getFileList3("D:/eclipse_osgi/OSGI_EZB/Karaf-My-Test/JavaSE-Test/FileAggregation/com");
aggregationFileName = folderPath + ".txt";
getFileList3(folderPath);
System.out.println("File Aggregation OK");
}
/**
* 輸入資料夾的路徑, 顯示得該資料夾下的所有檔案
*
* @param String
* folderPath
* @author Lupin
**/
public static void getFileList(String folderPath) {
// String folderPath = "C:\\";//資料夾路徑
StringBuffer fileList = new StringBuffer();
try {
File folder = new File(folderPath);
String[] list = folder.list();
for (int i = 0; i < list.length; i++) {
fileList.append(list[i]).append(", ");
}
} catch (Exception e) {
System.out.println("'" + folderPath + "'此資料夾不存在");
}
System.out.println(fileList);
}
public static void getFileList2(String folderPath) {
// String folderPath = "C:\\";//資料夾路徑
String[] list = null;
try {
File folder = new File(folderPath);
list = folder.list();
for (int i = 0; i < list.length; i++) {
// fileList.append(list[i]).append(", ");
if (i < 10) {
new File(folderPath + "/" + list[i]).renameTo(new File(
folderPath + "/" + "00" + i + ".jpg"));
} else if (i < 100) {
new File(folderPath + "/" + list[i]).renameTo(new File(
folderPath + "/" + "0" + i + ".jpg"));
} else {
new File(folderPath + "/" + list[i]).renameTo(new File(
folderPath + "/" + i + ".jpg"));
}
}
} catch (Exception e) {
System.out.println("'" + folderPath + "'此資料夾不存在");
}
}
public static void getFileList3(String folderPath) {
File a = new File(folderPath);
String[] filenames;
String fullpath = a.getAbsolutePath();
if (a.isDirectory()) {
filenames = a.list();
for (int i = 0; i < filenames.length; i++) {
File tempFile = new File(fullpath + "\\" + filenames[i]);
if (tempFile.isDirectory()) {
System.out.println("目錄:" + fullpath + "\\" + filenames[i]);
getFileList3(fullpath + "\\" + filenames[i]);
} else {
System.out.println("檔案:" + filenames[i]);
try {
//copyFileUsingFileChannels(fullpath + "\\" + filenames[i],
// "D:/eclipse_osgi/OSGI_EZB/Karaf-My-Test/JavaSE-Test/FileAggregation/test.txt");
copyFileUsingFileChannels(filenames[i], aggregationFileName, fullpath);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
} else {
System.out.println("[" + a + "] 不是目錄");
}
}
private static void copyFileUsingFileChannels(String sourcePath,
String destPath, String fullPath) throws IOException {
PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("./" + destPath, true)));
out.println("");
out.println("");
out.println("////////////////////////////////////////////////////////////////////////");
out.println(fullPath + "\\" + sourcePath);
out.close();
File source = new File(fullPath + "\\" + sourcePath);
File dest = new File("./" + destPath);
//File spaceTxt = new File("./" + "space.txt");
FileChannel inputChannel = null;
FileChannel outputChannel = null;
//FileChannel spaceChannel = null;
try {
inputChannel = new FileInputStream(source).getChannel();
outputChannel = new FileOutputStream(dest, true).getChannel();
//spaceChannel = new FileInputStream(spaceTxt).getChannel();
outputChannel.transferFrom(inputChannel, outputChannel.size(), inputChannel.size());
//outputChannel.transferFrom(spaceChannel, outputChannel.size(), spaceChannel.size());
} finally {
inputChannel.close();
outputChannel.close();
//spaceChannel.close();
}
}
}
| [
"[email protected]"
] | |
3bde59f76189360074c5e704c924354f1a47affd | a00326c0e2fc8944112589cd2ad638b278f058b9 | /src/main/java/000/136/981/CWE369_Divide_by_Zero__int_listen_tcp_modulo_67b.java | 697f62ad339e9f63f41d14367aa4a013702cf31f | [] | no_license | Lanhbao/Static-Testing-for-Juliet-Test-Suite | 6fd3f62713be7a084260eafa9ab221b1b9833be6 | b095b11c7cb6d4a5bb2b76181e35d6ee00e96e68 | refs/heads/master | 2020-08-24T13:34:04.004149 | 2019-10-25T09:26:00 | 2019-10-25T09:26:00 | 216,822,684 | 0 | 1 | null | 2019-11-08T09:51:54 | 2019-10-22T13:37:13 | Java | UTF-8 | Java | false | false | 1,984 | java | /* TEMPLATE GENERATED TESTCASE FILE
Filename: CWE369_Divide_by_Zero__int_listen_tcp_modulo_67b.java
Label Definition File: CWE369_Divide_by_Zero__int.label.xml
Template File: sources-sinks-67b.tmpl.java
*/
/*
* @description
* CWE: 369 Divide by zero
* BadSource: listen_tcp Read data using a listening tcp connection
* GoodSource: A hardcoded non-zero, non-min, non-max, even number
* Sinks: modulo
* GoodSink: Check for zero before modulo
* BadSink : Modulo by a value that may be zero
* Flow Variant: 67 Data flow: data passed in a class from one method to another in different source files in the same package
*
* */
public class CWE369_Divide_by_Zero__int_listen_tcp_modulo_67b
{
public void badSink(CWE369_Divide_by_Zero__int_listen_tcp_modulo_67a.Container dataContainer ) throws Throwable
{
int data = dataContainer.containerOne;
/* POTENTIAL FLAW: Zero modulus will cause an issue. An integer division will
result in an exception. */
IO.writeLine("100%" + data + " = " + (100 % data) + "\n");
}
/* goodG2B() - use goodsource and badsink */
public void goodG2BSink(CWE369_Divide_by_Zero__int_listen_tcp_modulo_67a.Container dataContainer ) throws Throwable
{
int data = dataContainer.containerOne;
/* POTENTIAL FLAW: Zero modulus will cause an issue. An integer division will
result in an exception. */
IO.writeLine("100%" + data + " = " + (100 % data) + "\n");
}
/* goodB2G() - use badsource and goodsink */
public void goodB2GSink(CWE369_Divide_by_Zero__int_listen_tcp_modulo_67a.Container dataContainer ) throws Throwable
{
int data = dataContainer.containerOne;
/* FIX: test for a zero modulus */
if (data != 0)
{
IO.writeLine("100%" + data + " = " + (100 % data) + "\n");
}
else
{
IO.writeLine("This would result in a modulo by zero");
}
}
}
| [
"[email protected]"
] | |
616e6397470dbefba0fbf5fa2051a20ce99d16b6 | a65c82396d57638cd196fdd8522afdeb795c6139 | /src/main/java/com/arcuman/borto/services/impl/MarkServiceImpl.java | 831781cd221e0b71185dabc0aeab5114026da3ec | [] | no_license | Arcuman/JavaDocument | 3bcc694a6758321552baefd7072006cc2cde6c83 | d5c4f77c08a7494e4d542a63555867dea0bb029e | refs/heads/main | 2023-02-01T23:19:16.622014 | 2020-12-13T13:01:34 | 2020-12-13T13:01:34 | 300,378,076 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,731 | java | package com.arcuman.borto.services.impl;
import com.arcuman.borto.Repository.DocumentRepository;
import com.arcuman.borto.Repository.MarkRepository;
import com.arcuman.borto.Repository.UserRepository;
import com.arcuman.borto.dto.MarkDTO;
import com.arcuman.borto.models.Mark;
import com.arcuman.borto.models.TypeMark;
import com.arcuman.borto.services.MarkService;
import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
@Service
@Log4j2
public class MarkServiceImpl implements MarkService {
private final MarkRepository markRepository;
private final UserRepository userRepository;
private final DocumentRepository documentRepository;
public MarkServiceImpl(MarkRepository markRepository, DocumentRepository documentService, UserRepository userRepository) {
this.markRepository = markRepository;
this.documentRepository = documentService;
this.userRepository = userRepository;
}
@Override
public List<MarkDTO> getAllFromDocumentByTypeMark(Long documentId, TypeMark typeMark) {
return markRepository.findAllByDocumentIdAndTypeMark(documentId,typeMark).stream()
.map((MarkDTO::fromMark)).collect(Collectors.toList());
}
@Override
public void addNewMark(MarkDTO markDTO) {
Mark mark = markDTO.toMark(
documentRepository.findById(markDTO.getDocumentId()).get(),
userRepository.findByUsername(markDTO.getUserName()));
markRepository.save(mark);
log.info("IN addNewComment - comment added successfully");
}
@Override
public void deleteMarkById(Long id) {
markRepository.deleteById(id);
log.info("IN delete - mark with id: ${id} successfully deleted");
}
}
| [
"[email protected]"
] | |
ae455a0b72661e93cdb8d49cd14cec188e475a1a | ce74ec2c4b423fbd092bba5cb56d7d93d750d010 | /src/main/java/com/challenge/entity/Candidate.java | 4486e830d616208d9ea9a12aaa4ec2723ca3c1e3 | [] | no_license | diego-isquierdo/AceleraDev-Java-Entidades-de-Banco-de-Dados | c429a474c7608ce2ee83ac52f1e3c19e0c4f7022 | 8cdcd336fb71521e7ae0a56603b3357e65c1058d | refs/heads/master | 2022-07-04T03:16:05.270425 | 2020-05-13T02:30:39 | 2020-05-13T02:30:39 | 262,664,241 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 673 | java | package com.challenge.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;
@Entity
@AllArgsConstructor
@NoArgsConstructor
@Data
@EntityListeners(AuditingEntityListener.class)
public class Candidate {
@EmbeddedId
private CandidateId id;
@NotNull
private Integer status;
@NotNull
@CreatedDate
@Column(name = "created_at")
private LocalDateTime createdAt;
}
| [
"[email protected]"
] | |
5ab5b5ef0f405aef2358023c3e20b49667c0505f | d1bb4302b7f052fb6f31e340d605abf91f3b2db5 | /app/src/main/java/com/juba/fedora/Messages.java | ff1ee109e3949754f36a1a917e1e9bfa5794b398 | [] | no_license | JubaDwidar/Fedora | e70ba77796ec330b242dcb1527f385c326f7fc01 | 162518b972c09e2bd83ba8b0402a86765360979f | refs/heads/master | 2020-08-22T16:00:44.824069 | 2019-10-20T21:52:40 | 2019-10-20T21:52:40 | 214,495,774 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 720 | java | package com.juba.fedora;
public class Messages {
private String from;
private String to;
private String messageText;
public Messages(String from, String to, String messageText) {
this.from = from;
this.to = to;
this.messageText = messageText;
}
public String getFrom() {
return from;
}
public void setFrom(String from) {
this.from = from;
}
public String getTo() {
return to;
}
public void setTo(String to) {
this.to = to;
}
public String getMessageText() {
return messageText;
}
public void setMessageText(String messageText) {
this.messageText = messageText;
}
}
| [
"[email protected]"
] | |
ba476cfe8dc94250a06e923cae77acbb03f6f13d | 44e7adc9a1c5c0a1116097ac99c2a51692d4c986 | /aws-java-sdk-apigatewayv2/src/main/java/com/amazonaws/services/apigatewayv2/model/AccessLogSettings.java | 4744c1204d23eeecd7856fb1019c010fa5e0a44c | [
"Apache-2.0"
] | permissive | QiAnXinCodeSafe/aws-sdk-java | f93bc97c289984e41527ae5bba97bebd6554ddbe | 8251e0a3d910da4f63f1b102b171a3abf212099e | refs/heads/master | 2023-01-28T14:28:05.239019 | 2020-12-03T22:09:01 | 2020-12-03T22:09:01 | 318,460,751 | 1 | 0 | Apache-2.0 | 2020-12-04T10:06:51 | 2020-12-04T09:05:03 | null | UTF-8 | Java | false | false | 6,427 | java | /*
* Copyright 2015-2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.apigatewayv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
* <p>
* Settings for logging access in a stage.
* </p>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AccessLogSettings implements Serializable, Cloneable, StructuredPojo {
/**
* <p>
* The ARN of the CloudWatch Logs log group to receive access logs.
* </p>
*/
private String destinationArn;
/**
* <p>
* A single line format of the access logs of data, as specified by selected $context variables. The format must
* include at least $context.requestId.
* </p>
*/
private String format;
/**
* <p>
* The ARN of the CloudWatch Logs log group to receive access logs.
* </p>
*
* @param destinationArn
* The ARN of the CloudWatch Logs log group to receive access logs.
*/
public void setDestinationArn(String destinationArn) {
this.destinationArn = destinationArn;
}
/**
* <p>
* The ARN of the CloudWatch Logs log group to receive access logs.
* </p>
*
* @return The ARN of the CloudWatch Logs log group to receive access logs.
*/
public String getDestinationArn() {
return this.destinationArn;
}
/**
* <p>
* The ARN of the CloudWatch Logs log group to receive access logs.
* </p>
*
* @param destinationArn
* The ARN of the CloudWatch Logs log group to receive access logs.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AccessLogSettings withDestinationArn(String destinationArn) {
setDestinationArn(destinationArn);
return this;
}
/**
* <p>
* A single line format of the access logs of data, as specified by selected $context variables. The format must
* include at least $context.requestId.
* </p>
*
* @param format
* A single line format of the access logs of data, as specified by selected $context variables. The format
* must include at least $context.requestId.
*/
public void setFormat(String format) {
this.format = format;
}
/**
* <p>
* A single line format of the access logs of data, as specified by selected $context variables. The format must
* include at least $context.requestId.
* </p>
*
* @return A single line format of the access logs of data, as specified by selected $context variables. The format
* must include at least $context.requestId.
*/
public String getFormat() {
return this.format;
}
/**
* <p>
* A single line format of the access logs of data, as specified by selected $context variables. The format must
* include at least $context.requestId.
* </p>
*
* @param format
* A single line format of the access logs of data, as specified by selected $context variables. The format
* must include at least $context.requestId.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public AccessLogSettings withFormat(String format) {
setFormat(format);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getDestinationArn() != null)
sb.append("DestinationArn: ").append(getDestinationArn()).append(",");
if (getFormat() != null)
sb.append("Format: ").append(getFormat());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof AccessLogSettings == false)
return false;
AccessLogSettings other = (AccessLogSettings) obj;
if (other.getDestinationArn() == null ^ this.getDestinationArn() == null)
return false;
if (other.getDestinationArn() != null && other.getDestinationArn().equals(this.getDestinationArn()) == false)
return false;
if (other.getFormat() == null ^ this.getFormat() == null)
return false;
if (other.getFormat() != null && other.getFormat().equals(this.getFormat()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getDestinationArn() == null) ? 0 : getDestinationArn().hashCode());
hashCode = prime * hashCode + ((getFormat() == null) ? 0 : getFormat().hashCode());
return hashCode;
}
@Override
public AccessLogSettings clone() {
try {
return (AccessLogSettings) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.apigatewayv2.model.transform.AccessLogSettingsMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}
| [
""
] | |
17b6140bb603eaf7a8ea94a47ce3b16147b70193 | 7101fb712143092126af62835223dbc22394c08d | /app/src/main/java/it/unimib/librichepassione/model/Book.java | 945d7ca6f61648447e79f16095bc643649a4a07e | [] | no_license | gmele9/LibriChePassione | 31a9af7228a93dad42bfb65237cedf5a0f3eea9c | f8a3eb86152c9c1ae836a312165aa80a5e863b67 | refs/heads/master | 2022-11-28T15:48:06.137113 | 2020-07-16T15:46:04 | 2020-07-16T15:46:04 | 277,797,985 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 667 | java | package it.unimib.librichepassione.model;
import java.util.List;
public class Book {
private Object volumeInfo;
public Book(Object volumeInfo, String title, String subtitle, List<String> author, String publisher, String publishedDate, List<ISBN> industryIdentifiers, List<String> categories, String thumbnail) {
this.volumeInfo = volumeInfo;
}
public Object getVolumeInfo() {
return volumeInfo;
}
public void setVolumeInfo(Object volumeInfo) {
this.volumeInfo = volumeInfo;
}
@Override
public String toString() {
return "Book{" +
"volume ='" + volumeInfo + '\'' + '}';
}
}
| [
"[email protected]"
] | |
29815ed414a04c622d69665eb847d6c9fd8428d3 | b5bd14674d1495f9a1db3fe80160cea78a0ef1a5 | /auto-generated-sdk/src/main/java/factset/analyticsapi/engines/models/Column.java | e464e282d29259670ae5d5924620258140b52c49 | [
"Apache-2.0"
] | permissive | afernandes85/analyticsapi-engines-java-sdk | cd0457d6f2898bfd0ee7f846ff64a3e2a01994a5 | dd38ea51939b49944c893c6b5394dd9a7d311102 | refs/heads/master | 2022-12-20T14:36:06.154175 | 2020-10-09T17:41:51 | 2020-10-09T17:41:51 | 293,884,485 | 0 | 0 | Apache-2.0 | 2020-10-02T19:59:42 | 2020-09-08T17:44:12 | Java | UTF-8 | Java | false | false | 5,226 | java | /*
* Engines API
* Allow clients to fetch Analytics through APIs.
*
* The version of the OpenAPI document: 2
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package factset.analyticsapi.engines.models;
import java.util.Objects;
import java.util.Arrays;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
/**
* Column
*/
@JsonPropertyOrder({
Column.JSON_PROPERTY_DEFAULTSTATISTICSIDS,
Column.JSON_PROPERTY_NAME,
Column.JSON_PROPERTY_DIRECTORY,
Column.JSON_PROPERTY_CATEGORY
})
public class Column implements Serializable {
private static final long serialVersionUID = 1L;
public static final String JSON_PROPERTY_DEFAULTSTATISTICSIDS = "defaultstatisticsids";
private java.util.List<String> defaultstatisticsids = null;
public static final String JSON_PROPERTY_NAME = "name";
private String name;
public static final String JSON_PROPERTY_DIRECTORY = "directory";
private String directory;
public static final String JSON_PROPERTY_CATEGORY = "category";
private String category;
public Column defaultstatisticsids(java.util.List<String> defaultstatisticsids) {
this.defaultstatisticsids = defaultstatisticsids;
return this;
}
public Column addDefaultstatisticsidsItem(String defaultstatisticsidsItem) {
if (this.defaultstatisticsids == null) {
this.defaultstatisticsids = new java.util.ArrayList<String>();
}
this.defaultstatisticsids.add(defaultstatisticsidsItem);
return this;
}
/**
* Column statistic Id
* @return defaultstatisticsids
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Column statistic Id")
@JsonProperty(JSON_PROPERTY_DEFAULTSTATISTICSIDS)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public java.util.List<String> getDefaultstatisticsids() {
return defaultstatisticsids;
}
public void setDefaultstatisticsids(java.util.List<String> defaultstatisticsids) {
this.defaultstatisticsids = defaultstatisticsids;
}
public Column name(String name) {
this.name = name;
return this;
}
/**
* Column Name
* @return name
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Column Name")
@JsonProperty(JSON_PROPERTY_NAME)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Column directory(String directory) {
this.directory = directory;
return this;
}
/**
* Column Directory
* @return directory
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Column Directory")
@JsonProperty(JSON_PROPERTY_DIRECTORY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getDirectory() {
return directory;
}
public void setDirectory(String directory) {
this.directory = directory;
}
public Column category(String category) {
this.category = category;
return this;
}
/**
* Column Category
* @return category
**/
@javax.annotation.Nullable
@ApiModelProperty(value = "Column Category")
@JsonProperty(JSON_PROPERTY_CATEGORY)
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
@Override
public boolean equals(java.lang.Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Column column = (Column) o;
return Objects.equals(this.defaultstatisticsids, column.defaultstatisticsids) &&
Objects.equals(this.name, column.name) &&
Objects.equals(this.directory, column.directory) &&
Objects.equals(this.category, column.category);
}
@Override
public int hashCode() {
return Objects.hash(defaultstatisticsids, name, directory, category);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Column {\n");
sb.append(" defaultstatisticsids: ").append(toIndentedString(defaultstatisticsids)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" directory: ").append(toIndentedString(directory)).append("\n");
sb.append(" category: ").append(toIndentedString(category)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces
* (except the first line).
*/
private String toIndentedString(java.lang.Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
}
| [
"[email protected]"
] | |
1717a75f84f4a005d6a2f34bccf9d9148b6d68c0 | a1eece46ab7d7cfb961c5b8f5dcd2d419c986a93 | /src/main/java/com/lumiata/exception/BadRequestException.java | a43b8d5e08a3d98eeb84ce99fe70b6d3165e7382 | [] | no_license | rakeshnemade/snowflakej | 35fa83bb7dfebbdbb54d3cc010cac890cf7e21da | be9c5670845e3dd44f0608346ee267d29883d17f | refs/heads/master | 2021-06-01T15:26:40.607695 | 2018-02-10T14:59:56 | 2018-02-10T14:59:56 | 22,878,545 | 0 | 0 | null | 2018-02-10T14:59:57 | 2014-08-12T13:37:48 | JavaScript | UTF-8 | Java | false | false | 445 | java | /**
*<p>
*This program is confidential and proprietary to Lumiata Inc. and
*may not be reproduced, published, or disclosed to others without
*company authorization. Copyright 2013-2016 by Lumiata Inc.
*/
package com.lumiata.exception;
/**
* @author rakesh
*
*/
public class BadRequestException extends ApiException {
private int code;
public BadRequestException(int code, String msg) {
super(code, msg);
this.code = code;
}
}
| [
"[email protected]"
] | |
5c535ce2be7379d338ff3e80269e52c901f038c4 | a216c2d0076c42ba46b1c4ea20304364ead46c2d | /src/main/java/com/winning/hic/service/impl/MbzLogServiceImpl.java | 1581478a2123021f970c347a829ff9013254834c | [] | no_license | flylee85/hic | 29ba217a89a24e7959430b43346eb3c2c865c5f7 | eed876c6a67e2d5e40e61fa9030afd99730a85fa | refs/heads/master | 2021-09-28T08:17:50.921955 | 2018-11-16T00:23:07 | 2018-11-16T00:23:07 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,327 | java | package com.winning.hic.service.impl;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import com.winning.hic.model.MbzLog;
import com.winning.hic.dao.data.MbzLogDao;
import com.winning.hic.service.MbzLogService;
/**
* @author MBZ
* @title MBZ_LOG
* @email Winning Health
* @package com.winning.hic.service.impl
* @date 2018-23-25 12:23:54
*/
@Service
public class MbzLogServiceImpl implements MbzLogService {
@Autowired
private MbzLogDao mbzLogDao;
public int createMbzLog(MbzLog mbzLog){
return this.mbzLogDao.insertMbzLog(mbzLog);
}
public int modifyMbzLog(MbzLog mbzLog){
return this.mbzLogDao.updateMbzLog(mbzLog);
}
public int removeMbzLog(MbzLog mbzLog){
return this.mbzLogDao.deleteMbzLog(mbzLog);
}
public MbzLog getMbzLog(MbzLog mbzLog){
return this.mbzLogDao.selectMbzLog(mbzLog);
}
public int getMbzLogCount(MbzLog mbzLog){
return (Integer)this.mbzLogDao.selectMbzLogCount(mbzLog);
}
public List<MbzLog> getMbzLogList(MbzLog mbzLog){
return this.mbzLogDao.selectMbzLogList(mbzLog);
}
public List<MbzLog> getMbzLogPageList(MbzLog mbzLog){
return this.mbzLogDao.selectMbzLogPageList(mbzLog);
}
} | [
"[email protected]"
] | |
bb0aeeb74d95c2d372e3024f35203db9a62e5152 | 7664ee84dea4bc27578f7ae05393877b83b6a6e4 | /src/bl/ReportDoctorRepository.java | 298bbee4d6a094ab24524c009924700f128f2cd4 | [] | no_license | ardit95/Ordinanca | e6ad309c5d875f7628bd7eb4574c7171471abf72 | f884d323a0213149f23ade4d6036c99a5614f517 | refs/heads/master | 2021-01-11T00:46:21.913099 | 2017-01-03T20:29:21 | 2017-01-03T20:29:21 | 70,492,852 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,298 | java | package bl;
import ejbView.ReportDoctor;
import java.util.List;
import javax.persistence.EntityManager;
import ExceptionPackage.AppException;
public class ReportDoctorRepository extends EntMngClass implements ReportDoctorInterface {
public ReportDoctorRepository(EntityManager tempEm) {
super(tempEm);
}
@Override
public ReportDoctor create(ReportDoctor reportDoctor) throws AppException {
try {
em.getTransaction().begin();
em.persist(reportDoctor);
em.flush();
em.getTransaction().commit();
return reportDoctor;
} catch (Throwable thro) {
if (thro.getMessage().contains("2627")) {
if (thro.getMessage().toLowerCase().contains("unique")) {
throw new AppException("Ekziston një kompani me këto vlera.Secila kompani duhet të jetë unike.");
} else {
throw new AppException("Ekziston nje kompani me këtë çelës primarë.");
}
} else {
throw new AppException("Create : " + thro.getClass() + " - " + thro.getMessage());
}
}
}
@Override
public void edit(ReportDoctor reportDoctor) throws AppException {
try {
em.getTransaction().begin();
em.merge(reportDoctor);
em.getTransaction().commit();
} catch (Throwable thro) {
if (thro.getMessage().contains("2627")) {
if (thro.getMessage().toLowerCase().contains("unique")) {
throw new AppException("Ekziston një kompani me këto vlera.Secila kompani duhet të jetë unike.");
} else {
throw new AppException("Ekziston nje kompani me këtë çelës primarë.");
}
} else {
throw new AppException("Create : " + thro.getClass() + " - " + thro.getMessage());
}
}
}
@Override
public void remove(ReportDoctor reportDoctor) {
em.getTransaction().begin();
em.remove(reportDoctor);
em.getTransaction().commit();
}
@Override
public List<ReportDoctor> findAll() {
return em.createNamedQuery("ReportDoctor.findAll").getResultList();
}
}
| [
"[email protected]"
] | |
1b955ca3c7876180cbb2b1e6f69d841dea868cfe | fd0455cd034234fcd6d41344dbb8f74046a60491 | /src/main/java/com/pessoas/models/dto/PessoaDTO.java | 19965f02307ef37bcb7b67d4ddffd3db9ce51b50 | [] | no_license | willyms/api-pessoas | 102220aba2e6137d306d838143a10b7cddbcb8df | cb6b3dfdff53348996d64ca5b71a5273e5510eae | refs/heads/master | 2021-08-22T11:41:16.882376 | 2021-07-15T19:39:36 | 2021-07-15T19:39:36 | 211,405,995 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 946 | java | package com.pessoas.models.dto;
import lombok.*;
import org.hibernate.validator.constraints.br.*;
import javax.validation.constraints.*;
import java.util.*;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class PessoaDTO {
private Long id;
@NotEmpty
@Size(min = 2, max = 100)
private String nome;
@NotEmpty
@Size(min = 2, max = 100)
private String sobreNome;
@NotEmpty
@CPF
private String cpf;
@NotNull
private String dataNascimento;
private Set<TelefoneDTO> telefones;
private Set<EnderecoDTO> enderecos;
public void addEnderecos(EnderecoDTO endereco) {
if(this.enderecos == null)
this.enderecos = new HashSet<>();
this.enderecos.add(endereco);
}
public void addTelefones(TelefoneDTO telefone) {
if(this.telefones == null)
this.telefones = new HashSet<>();
this.telefones.add(telefone);
}
}
| [
"[email protected]"
] | |
33181aa223177b1371bf784e1e78f328ed654495 | e637cad6cc28792c10f0a9693c434f30654d7748 | /sandbox/src/main/java/ru/stqa/tr/Point.java | c73fd8edc0a88a3f4f325693d80577bcc26c055e | [
"Apache-2.0"
] | permissive | gennadykr/java_training | c351b6e806b75a71ebae3009bedd8bc47b882831 | 528fd61cc926f6bc6fc04647a9013dad5f3061f3 | refs/heads/master | 2020-12-30T15:53:39.310257 | 2017-07-21T18:18:59 | 2017-07-21T18:18:59 | 91,174,945 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 386 | java | package ru.stqa.tr;
import static java.lang.Math.sqrt;
public class Point {
public double x;
public double y;
public Point(double x, double y) {
this.x = x;
this.y = y;
}
public double distance(Point p) {
double deltax = p.x - this.x;
double deltay = p.y - this.y;
return sqrt(deltax * deltax + deltay * deltay);
}
}
| [
"[email protected]"
] | |
d3c21418b3387e126a791ed36308755ad5939daa | 53c3d031335b84334e25e760104f3e071b476db2 | /Assignment 0/TSPLooper.java | c765f7c7758191253bee2981296eb5fb53ea72e5 | [
"MIT"
] | permissive | jet76/CSCI-136 | 008e58580787830597b5b968837b4bc88f0ce554 | 940daee876aab5f02ad63e59b41d21873873f93f | refs/heads/main | 2023-05-01T01:53:13.379666 | 2021-05-23T15:44:43 | 2021-05-23T15:44:43 | 365,305,709 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,391 | java | /*************************************************************************
* YOU DO NOT NEED TO MODIFY THIS FILE
*
* Compilation: javac TSPTimer.java
* Execution: java TSPTimer N
* Dependencies: Tour.java Point.java
*
* Time the two heuristics by generated random instances of size N.
*
* % java TSPTimer N
*
*************************************************************************/
// I modified this file anyhow
public class TSPLooper
{
public static void main(String[] args)
{
final int SIZE = 600;
final int MODE = Integer.parseInt(args[0]);
int N = 1000;
double elapsed1;
double elapsed2;
if (MODE == 0 )
{
do
{
System.out.println(N);
// generate data and run nearest insertion heuristic
Stopwatch timer1 = new Stopwatch();
Tour tour1 = new Tour();
for (int i = 0; i < N; i++)
{
double x = Math.random() * SIZE;
double y = Math.random() * SIZE;
Point p = new Point(x, y);
tour1.insertNearest(p);
}
elapsed1 = timer1.elapsedTime();
System.out.println("Tour distance = " + tour1.distance());
System.out.println("Nearest insertion: " + elapsed1 + " seconds");
System.out.println();
N *= 2;
} while (elapsed1 < 100);
}
else if (MODE == 1)
{
do {
System.out.println(N);
// generate data and run smallest insertion heuristic
Stopwatch timer2 = new Stopwatch();
Tour tour2 = new Tour();
for (int i = 0; i < N; i++)
{
double x = Math.random() * SIZE;
double y = Math.random() * SIZE;
Point p = new Point(x, y);
tour2.insertSmallest(p);
}
elapsed2 = timer2.elapsedTime();
System.out.println("Tour distance = " + tour2.distance());
System.out.println("Smallest insertion: " + elapsed2 + " seconds");
System.out.println();
N *= 2;
} while (elapsed2 < 100);
}
}
}
| [
"[email protected]"
] | |
6a590f3d1391a14d2f8e12131314547b95aaa9fc | 048d0419a3d6e2c70718f222e2eed516cda01b35 | /src/main/java/com/agency04/sbss/pizza/model/CustomerDetails.java | 3bf7bf084150155d58559254215dbc9b2b408bc3 | [] | no_license | kmandalinic/sbss-km | 440a698ff9f0d6a7a131c9a2a290e54581771d5c | ec06cb568d043eaf1abf7d665c538a1b9a5c9f45 | refs/heads/main | 2023-07-14T12:36:47.815800 | 2021-08-18T10:43:25 | 2021-08-18T10:43:25 | 389,728,174 | 0 | 0 | null | 2021-08-18T10:43:25 | 2021-07-26T18:13:48 | Java | UTF-8 | Java | false | false | 1,517 | java | package com.agency04.sbss.pizza.model;
import javax.persistence.*;
import java.util.Objects;
@Entity
public class CustomerDetails {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String firstName;
private String lastName;
private String phoneNumber;
public CustomerDetails() {
}
public CustomerDetails(String firstName, String lastName, String phoneNumber) {
this.firstName = firstName;
this.lastName = lastName;
this.phoneNumber = phoneNumber;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public String getPhoneNumber() {
return phoneNumber;
}
public void setPhoneNumber(String phoneNumber) {
this.phoneNumber = phoneNumber;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
CustomerDetails that = (CustomerDetails) o;
return Objects.equals(firstName, that.firstName) && Objects.equals(lastName, that.lastName) && Objects.equals(phoneNumber, that.phoneNumber);
}
@Override
public int hashCode() {
return Objects.hash(firstName, lastName, phoneNumber);
}
}
| [
"[email protected]"
] | |
ba5445090b6642625b3f5f099da674235f54c627 | c21ceb7d3ccb7ed0653b9adab834046159c345e4 | /service-feign/src/test/java/com/servicefeign/ServiceFeignApplicationTests.java | 07787275b083f2e29299a89b3ed5cf6c0eb8ad83 | [] | no_license | moyoti/SpringCloudStudy | 6f82debc39d3936abf9c5e24a8ff31ed963cec76 | c1198e50eaf9a466d20b6094067e02e750980b83 | refs/heads/master | 2020-05-14T15:43:05.506884 | 2019-06-19T02:33:07 | 2019-06-19T02:33:07 | 181,859,575 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package com.servicefeign;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class ServiceFeignApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
5cbc633a64ad6cd0f2fee02536dc42b7910b92f6 | 56059fae62120b7e9ca627e09dbb5c242e35c143 | /Upper Triangular Matrix/Main.java | 751784404ee330761579d879d2bee85f4ff68bdd | [] | no_license | zaidumarajz/Playground | 34f6b97c94ae30de8e6bc430fd2cee5866d6c42f | 29922dc63c2610d0f50314fa280d1036aef24689 | refs/heads/master | 2020-07-11T08:53:04.669715 | 2019-09-03T16:47:57 | 2019-09-03T16:47:57 | 204,496,314 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 577 | java |
import java.util.Scanner;
class Main
{
public static void main(String args[])
{Scanner in=new Scanner(System.in);
int n=in.nextInt();
int a[][]=new int[n][n];
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
a[i][j]=in.nextInt();
}
}
for (int i = 1; i < n ; i++)
{
for (int j = 0; j < i; j++)
{
if (a[i][j] != 0)
{
System.out.println("no");
System.exit(0);
}
System.out.println("yes");
System.exit(0);
}
}
}
} | [
"[email protected]"
] | |
96776789e1d751781da5008c1d50396c72fe260f | b4dbb38d218b1e474fb22580a98377c0bae7c127 | /src/advancedTCP/Server.java | 5fb96369afdd34dbe2ce5b8d3016a35328d27350 | [] | no_license | niranjana687/Java-Network-Application | f1c9670128c02f77d2be9ec4237b5cebd7425f86 | f5ed5b152ee273af96b7ee519dc98d7fca65ccd4 | refs/heads/main | 2023-06-01T18:03:02.113754 | 2021-06-14T08:22:16 | 2021-06-14T08:22:16 | 374,040,429 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,263 | java | package advancedTCP;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
public class Server {
public Server() throws Exception {
var serverSocket = new ServerSocket(6969); //opening a new port.
System.out.println("Port 6969 is open");
Socket socket = serverSocket.accept();
System.out.println("Client: " + socket.getInetAddress() + " has connected");
// I/O Buffers.
BufferedReader inSocket = new BufferedReader(new InputStreamReader(socket.getInputStream()));
PrintWriter outSocket = new PrintWriter(new OutputStreamWriter (socket.getOutputStream()));
String message;
int secretNumber = (int)(Math.random()*10+1);
do {
outSocket.println("Guess a number [1-10]: ");
message = inSocket.readLine();
} while ( !(Integer.parseInt(message) == secretNumber));
outSocket.println("You got the number right! \n Exiting the app");
serverSocket.close();
socket.close();
System.out.println("Socket is closed");
}
public static void main(String[] args) {
try {
new Server();
} catch (Exception e) {
//TODO: handle exception
e.printStackTrace();
}
}
} | [
"[email protected]"
] | |
113cfc95ae31cae61596a7533bfc4a735a76c19a | 7ac0cc2c28bb479caf7d1402e3a6d094a35b0559 | /problems/dp/NumWaysToFormNum.java | f0c1372845b3e1d66c128a241b82ffccbbc44e64 | [] | no_license | luisalfonsopreciado/The-Algorithms | 5349c499d43c73721673165fe261cb9fc8c5caf0 | 8ed01ff59c757228ce9288b405b273661e4d7f46 | refs/heads/master | 2023-05-03T03:26:20.154530 | 2021-05-25T22:48:10 | 2021-05-25T22:48:10 | 314,413,738 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,075 | java | package problems.dp;
/*
Problem Statement: given a list of numbers arr with length N, count the number of ways
we can form a number num using the sum of the given numbers in arr.
*/
public class NumWaysToFormNum {
/**
* Dynamic Programming solution
*
* @param arr
* @param num
* @return int number of ways to arrive at num
*/
public static int solution(int[] arr, int num) {
int[] dp = new int[num + 1];
for (int n : arr) {
if (n > num || n < 0)
continue;
dp[n] = 1;
}
for (int i = 0; i < dp.length; i++) {
if (dp[i] == 1)
continue;
int sum = 0;
for (int n : arr) {
if (i - n < 0)
continue;
sum += dp[i - n];
}
dp[i] = sum;
}
return dp[num];
}
public static void main(String[] args) {
int[] arr = { 1, 3, 5 };
int num = 8;
System.out.println(solution(arr, num));
}
}
| [
"[email protected]"
] | |
6aa0a782c13a58402f63080023ae39708496865a | eb30f649523bdfe7696a345a2079fed65c6590b4 | /src/test/java/com/cybertek/EtcyExample.java | 1946ef015aee44e0b82a99360f4d04a833b5fa59 | [] | no_license | AyASIYE/Meaven_project | fcc036c7f60629f5c925497bb1e048df9881253f | f85f5d0c7f61ef79d06125ee9e54a8608b990fe8 | refs/heads/master | 2020-04-21T20:03:54.343077 | 2019-02-09T03:57:12 | 2019-02-09T03:57:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 696 | java | package com.cybertek;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
public class EtcyExample {
public static void main(String[] args) {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("https://www.etsy.com/");
WebElement input = driver.findElement(By.id("search-query"));
input.sendKeys("decal");
WebElement submit = driver.findElement
(By.id("//button[@class='btn btn-primary']"));
submit.click();
}
}
| [
"[email protected]"
] | |
ff21cafda2d7a64ce74d3e6deb63b4d860b37387 | 04356a015a17e00cf1dfce934f63cc0ba656350b | /contacts-core/src/main/java/example/app/model/Customer.java | 1b8cd0d0a909e3444d859eaaaa5cfd06ab9318cd | [] | no_license | sunlynx/contacts-application | adb1e09b67a1cdf6541989516eee28551d460ad1 | 7892179deeb40cd37657c9c6d8b18c4b0e9182fc | refs/heads/master | 2021-05-18T04:57:19.591911 | 2019-08-08T22:00:36 | 2019-08-08T22:00:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,760 | java | /*
* Copyright 2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
package example.app.model;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.MappedSuperclass;
import org.springframework.data.gemfire.mapping.annotation.Region;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
* The {@link Customer} class is an Abstract Data Type (ADT) that models a customer.
*
* @author John Blum
* @see example.app.model.Person
* @see org.springframework.data.gemfire.mapping.annotation.Region
* @since 1.0.0
*/
@MappedSuperclass
@DiscriminatorValue("customer")
@Region("Customers")
@SuppressWarnings("unused")
public class Customer extends Person {
private String accountNumber;
public static Customer newCustomer(String firstName, String lastName) {
Assert.hasText(firstName, "firstName is required");
Assert.hasText(lastName, "lastName is required");
Customer customer = new Customer();
customer.setFirstName(firstName);
customer.setLastName(lastName);
return customer;
}
public boolean hasAccount() {
return StringUtils.hasText(getAccountNumber());
}
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
}
@Column(name = "account_number", nullable = false, unique = true)
public String getAccountNumber() {
return accountNumber;
}
@Override
public boolean equals(Object obj) {
if (!super.equals(obj)) {
return false;
}
if (!(obj instanceof Customer)) {
return false;
}
Customer that = (Customer) obj;
return super.equals(obj)
&& ObjectUtils.nullSafeEquals(this.getAccountNumber(), that.getAccountNumber());
}
@Override
public int hashCode() {
int hashValue = super.hashCode();
hashValue = 37 * hashValue + ObjectUtils.nullSafeHashCode(getAccountNumber());
return hashValue;
}
@Override
public String toString() {
return String.format("{ @type = %1$s, name = %2$s, accountNumber = %3$s }",
getClass().getName(), getName(), getAccountNumber());
}
public Customer with(String accountNumber) {
setAccountNumber(accountNumber);
return this;
}
}
| [
"[email protected]"
] | |
94a6bd321d94eff51934196b8016d7564b215695 | cecd5d4bcf944900185183a76961f718d3157cc9 | /src/main/java/fr/afcepf/atod/onwine/ws/soap/tax/GetAllCountryTax.java | 64d148a4befd8d5a60349b00b19475e312085751 | [] | no_license | n1kk018/Wine-Web | d7140d028834b4df310244c88b0d94a42fb9e375 | 0d3578be3df39a43b273e64422a282976cb96869 | refs/heads/master | 2020-09-14T07:50:03.478207 | 2016-11-23T19:51:39 | 2016-11-23T19:51:39 | 67,427,031 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 781 | java |
package fr.afcepf.atod.onwine.ws.soap.tax;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for getAllCountryTax complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="getAllCountryTax">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getAllCountryTax")
public class GetAllCountryTax {
}
| [
"[email protected]"
] | |
0a9acdbd8f40ec275c770852aec54d0a345a6cb4 | 0e51981b8fcb6bc9fe547dc98b75d75577ad467d | /spring5_pro/src/main/java/am/gitc/ch4/provider/MessageProvider.java | e14b2d25b81c6b1c0009e3b82f0132c28df983aa | [] | no_license | h-r-a-c-h-y-a/Spring-5-Modules | afd6a01c054351c7a93ca9f8f4e45e7d8e4ad887 | b734966270e34d633eed1bf876ccaab39bd0530e | refs/heads/master | 2023-06-06T11:47:53.541695 | 2021-06-26T13:20:48 | 2021-06-26T13:20:48 | 285,902,182 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 121 | java | package am.gitc.ch4.provider;
public interface MessageProvider {
String getDefMessage();
String getMessage();
}
| [
"[email protected]"
] | |
3205f1c4deb622584f686b87f927d6591ee1f858 | 24ff668090b1d6e93ba44fffa11a81c6597aaff0 | /aut/5382JAVA프로그래망기초넘나들기소스코드/sourceANSI/본문소스ANSI/ch6/UpDown.java | 30963d63f10f864eff6f2440608607aeed038ede | [] | no_license | angelpjn/practice | b7ed60752fb24d6ffb7282fd53e4de2e1fc27efd | 24c338fdfc972f769af40bd21811bab4f4e06f5d | refs/heads/master | 2021-09-15T08:17:25.078282 | 2018-05-29T05:10:29 | 2018-05-29T05:10:29 | 104,207,988 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 690 | java | class Sub extends Object {
void info( ) {
System.out.println("서브 클래스");
}
public String toString( ) { // toString 오버라이딩: 객체 출력용
return ("업캐스팅된 것을 원래대로 다운캐스팅");
}
}
public class UpDown {
public static void main(String[ ] args) {
// (슈퍼클래스 < 서브클래스)이므로 명시적 형변환을 하지 않아도
Object obj = new Sub( ); // 업캐스팅, 자동으로 형변환
if (obj instanceof Sub) { // 타입 확인
Sub a = (Sub) obj; // 업캐스팅된것을 원래대로 다운캐스팅
System.out.println("Sub: " + a);
} else {
System.out.println("타입이 일치하지 않음");
}
}
} | [
"[email protected]"
] | |
c6cd23f1889f4ac870e29ffe9d6d8c573620a61e | e99f78a1d7d244a8def43ca73d570f3a1b0c435f | /SDPOngoing/src/day1/generics/s4/Box.java | 8bef2811959275b8de2d36e9843e878280d7d45c | [] | no_license | BBK-PiJ-2015-10/Ongoing | 5e153280a7772b1ec6ad5df02ec2cf8115ec272d | 3a6099079c5413d864c8b3ec435f14660d6fad5e | refs/heads/master | 2021-01-13T11:59:36.191993 | 2017-06-29T18:35:31 | 2017-06-29T18:35:31 | 77,915,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 155 | java | package day1.generics.s4;
public class Box<T> {
T data;
public Box (T data) {
this.data = data;
}
public T getData(){
return this.data;
}
} | [
"[email protected]"
] | |
66b76d5ff1632429fd936671b391937c23e5fdd7 | 8522f64cdcf9c15dd756ddb8bdf8f547087c3555 | /data-customize/src/jvm/billtenor/graduation/datacustomization/topology/TimeNoBlockAggregateSpoutComponent.java | 10f26d0d616db9817330bdfa7c438684dfbe1e75 | [
"Apache-2.0"
] | permissive | billtenor/equipment | e0551a2242210ad3a8e3563b9ee47b4b3e93b9ff | 58ff32679d03e9fc911204080d0c476a878a8cd6 | refs/heads/master | 2021-06-17T08:17:24.475814 | 2017-05-21T14:12:14 | 2017-05-21T14:12:14 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,268 | java | package billtenor.graduation.datacustomization.topology;
import billtenor.graduation.datacustomization.dataType.KafkaSpoutConfig;
import billtenor.graduation.datacustomization.fieldTransform.IBaseKeyTransform;
import billtenor.graduation.datacustomization.spout.TimeNoBlockAggregateScheme;
import org.apache.storm.kafka.BrokerHosts;
import org.apache.storm.kafka.KafkaSpout;
import org.apache.storm.kafka.SpoutConfig;
import org.apache.storm.kafka.ZkHosts;
import org.apache.storm.spout.SchemeAsMultiScheme;
import org.apache.storm.topology.TopologyBuilder;
/**
* Created by lyj on 17-4-6.
*/
public class TimeNoBlockAggregateSpoutComponent extends StormComponent{
final private KafkaSpoutConfig kafkaSpoutConfig;
private TimeNoBlockAggregateScheme timeNoBlockAggregateScheme;
public TimeNoBlockAggregateSpoutComponent(
int parallel,
KafkaSpoutConfig kafkaSpoutConfig
){
super(parallel);
this.kafkaSpoutConfig=kafkaSpoutConfig;
this.timeNoBlockAggregateScheme=new TimeNoBlockAggregateScheme();
}
@Override
public void setKeyTransform(IBaseKeyTransform keyTransform) {
this.timeNoBlockAggregateScheme.setKeyTransform(keyTransform);
}
@Override
public IBaseKeyTransform getKeyTransform() {
return this.timeNoBlockAggregateScheme.getKeyTransform();
}
@Override
protected String getComponentBaseName() {
return "timeNoBlockAggregateSpout";
}
@Override
public TopologyBuilder addToTopology(TopologyBuilder in) {
//spout create and config
BrokerHosts hosts = new ZkHosts(
kafkaSpoutConfig.zkConnString,kafkaSpoutConfig.zkKafkaPrefix+"/brokers"
);
SpoutConfig spoutConfig = new SpoutConfig(
hosts,kafkaSpoutConfig.topicName,
kafkaSpoutConfig.zkKafkaPrefix+"/topic/"+kafkaSpoutConfig.topicName,
kafkaSpoutConfig.kafkaSpoutID
);
spoutConfig.scheme = new SchemeAsMultiScheme(timeNoBlockAggregateScheme);
spoutConfig.startOffsetTime = kafka.api.OffsetRequest.LatestTime();
KafkaSpout kafkaSpout = new KafkaSpout(spoutConfig);
in.setSpout(componentName,kafkaSpout,parallel);
return in;
}
}
| [
"[email protected]"
] | |
89e668b59f83e98aa02c553b3c548d771af42479 | f9daf274ad044ce1e656422b49086ece0d4b7ac8 | /scms1/src/com/wencheng/web/controller/AddTeacher.java | c4259c723a2720d99d423a857dcd6165e80f5cb1 | [] | no_license | wencheng256/scms | a9bc7780926825c985dfe990d7f9b782dfc58cf0 | d022c3f0783e1050f775cafa16585cc70701d962 | refs/heads/master | 2021-01-10T01:39:13.319706 | 2015-10-06T06:48:44 | 2015-10-06T06:48:44 | 43,734,518 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,226 | java | package com.wencheng.web.controller;
import java.io.IOException;
import java.net.URLEncoder;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.wencheng.service.ProjectService;
import com.wencheng.service.impl.ProjectServiceImpl;
public class AddTeacher extends HttpServlet {
/**
* Constructor of the object.
*/
public AddTeacher() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
ProjectService ps = new ProjectServiceImpl();
if(ps.addTeacher(request)){
response.sendRedirect(request.getContextPath()+"/student/teacher");
return;
}else{
response.sendRedirect(request.getContextPath()+"/student/teacher?errormessage="+URLEncoder.encode("添加失败请重试","utf-8"));
}
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to post.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//doGet
doGet(request, response);
}
/**
* Initialization of the servlet. <br>
*
* @throws ServletException if an error occurs
*/
public void init() throws ServletException {
// Put your code here
}
}
| [
"[email protected]"
] | |
842c75dfb13dfed8d6250d921a8ad1d040216126 | 62dcffd4b568e41c8ec97510b91f6f819c95bea9 | /src/com/nikolajbaer/game/objects/BulletObject.java | 52c541e7d5567763b1b6a44ea94a04070a1668db | [
"BSD-2-Clause",
"Zlib",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | nikolajbaer/android-jplay | a701a7e11b9729eb6d2e3ff931533c7d095c00b1 | 661fa12d039ccb639003728f56bcf91d5e5c895d | refs/heads/master | 2020-05-17T02:57:12.626771 | 2010-06-13T21:43:03 | 2010-06-13T21:43:03 | 719,170 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 531 | java | package com.nikolajbaer.game.objects;
/* jbox2d */
import org.jbox2d.dynamics.Body;
import org.jbox2d.dynamics.BodyDef;
import org.jbox2d.common.Vec2;
/* local */
import com.nikolajbaer.game.Game;
public class BulletObject extends GameObject {
public BulletObject(Body b,int damage){
super(b);
this.m_damage=damage;
}
public boolean survivesImpact(){
return false;
}
public boolean doesDamage(){
return true;
}
public String getRenderKey(){ return "bullet"; }
}
| [
"nikolaj@stinkpad.(none)"
] | nikolaj@stinkpad.(none) |
222f57ceab65759d12409a567042070668a844f2 | 13540049fe12108f2ac73df16d2482b3840f8b41 | /src/main/java/com/hankcs/hanlp/tokenizer/lexical/AbstractLexicalAnalyzer.java | 24ae903c0e8233b769442626988927b518092718 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | AsyncNetwork/HanLP | 0ed26cb28689368deb6ffac327aa781c4d487cbe | a97449906b7537cfe02239efc839cd953983095e | refs/heads/master | 2020-03-07T18:21:23.587195 | 2018-03-31T04:28:55 | 2018-03-31T04:28:55 | 127,635,697 | 0 | 0 | null | 2018-04-01T14:17:37 | 2018-04-01T14:17:37 | null | UTF-8 | Java | false | false | 12,042 | java | /*
* <author>Han He</author>
* <email>[email protected]</email>
* <create-date>2018-03-30 下午7:42</create-date>
*
* <copyright file="AbstractLexicalAnalyzer.java">
* Copyright (c) 2018, Han He. All Right Reserved, http://www.hankcs.com/
* This source is subject to Han He. Please contact Han He to get more information.
* </copyright>
*/
package com.hankcs.hanlp.tokenizer.lexical;
import com.hankcs.hanlp.collection.AhoCorasick.AhoCorasickDoubleArrayTrie;
import com.hankcs.hanlp.corpus.document.sentence.Sentence;
import com.hankcs.hanlp.corpus.document.sentence.word.CompoundWord;
import com.hankcs.hanlp.corpus.document.sentence.word.IWord;
import com.hankcs.hanlp.corpus.document.sentence.word.Word;
import com.hankcs.hanlp.corpus.tag.Nature;
import com.hankcs.hanlp.dictionary.CoreDictionary;
import com.hankcs.hanlp.dictionary.CustomDictionary;
import com.hankcs.hanlp.dictionary.other.CharTable;
import com.hankcs.hanlp.model.perceptron.tagset.NERTagSet;
import com.hankcs.hanlp.model.perceptron.utility.PosTagUtility;
import com.hankcs.hanlp.seg.CharacterBasedSegment;
import com.hankcs.hanlp.seg.common.Term;
import java.util.*;
/**
* 词法分析器基类(中文分词、词性标注和命名实体识别)
*
* @author hankcs
*/
public abstract class AbstractLexicalAnalyzer extends CharacterBasedSegment implements LexicalAnalyzer
{
protected Segmenter segmenter;
protected POSTagger posTagger;
protected NERecognizer neRecognizer;
@Override
public void segment(String text, String normalized, List<String> output)
{
segmenter.segment(text, normalized, output);
}
/**
* 中文分词
*
* @param sentence
* @return
*/
public List<String> segment(String sentence)
{
return segmenter.segment(sentence);
}
@Override
public String[] recognize(String[] wordArray, String[] posArray)
{
return neRecognizer.recognize(wordArray, posArray);
}
@Override
public String[] tag(String... words)
{
return posTagger.tag(words);
}
@Override
public String[] tag(List<String> wordList)
{
return posTagger.tag(wordList);
}
@Override
public NERTagSet getNERTagSet()
{
return neRecognizer.getNERTagSet();
}
@Override
public Sentence analyze(final String sentence)
{
if (sentence.isEmpty())
{
return new Sentence(Collections.<IWord>emptyList());
}
final String normalized = CharTable.convert(sentence);
// 查询词典中的长词
final List<String> wordList = new LinkedList<String>();
final int[] offset = new int[]{0};
if (config.useCustomDictionary)
{
CustomDictionary.parseLongestText(sentence, new AhoCorasickDoubleArrayTrie.IHit<CoreDictionary.Attribute>()
{
@Override
public void hit(int begin, int end, CoreDictionary.Attribute value)
{
if (end - begin >= 4 && !value.hasNatureStartsWith("nr") && !value.hasNatureStartsWith("ns") && !value.hasNatureStartsWith("nt")) // 将命名实体识别交给下面去做
{
if (begin != offset[0])
{
segment(sentence.substring(offset[0], begin), normalized.substring(offset[0], begin), wordList);
}
wordList.add(sentence.substring(begin, end));
offset[0] = end;
}
}
});
if (offset[0] != sentence.length())
{
segment(sentence.substring(offset[0]), normalized.substring(offset[0]), wordList);
}
}
else
{
segment(sentence, normalized, wordList);
}
String[] wordArray = new String[wordList.size()];
offset[0] = 0;
int id = 0;
for (String word : wordList)
{
wordArray[id] = normalized.substring(offset[0], offset[0] + word.length());
++id;
offset[0] += word.length();
}
List<IWord> termList = new ArrayList<IWord>(wordList.size());
if (posTagger != null)
{
String[] posArray = tag(wordArray);
if (neRecognizer != null)
{
String[] nerArray = neRecognizer.recognize(wordArray, posArray);
wordList.toArray(wordArray);
List<Word> result = new LinkedList<Word>();
result.add(new Word(wordArray[0], posArray[0]));
String prePos = posArray[0];
NERTagSet tagSet = getNERTagSet();
for (int i = 1; i < nerArray.length; i++)
{
if (nerArray[i].charAt(0) == tagSet.B_TAG_CHAR || nerArray[i].charAt(0) == tagSet.S_TAG_CHAR || nerArray[i].charAt(0) == tagSet.O_TAG_CHAR)
{
termList.add(result.size() > 1 ? new CompoundWord(result, prePos) : result.get(0));
result = new ArrayList<Word>();
}
result.add(new Word(wordArray[i], posArray[i]));
if (nerArray[i].charAt(0) == tagSet.O_TAG_CHAR || nerArray[i].charAt(0) == tagSet.S_TAG_CHAR)
{
prePos = posArray[i];
}
else
{
prePos = NERTagSet.posOf(nerArray[i]);
}
}
if (result.size() != 0)
{
termList.add(result.size() > 1 ? new CompoundWord(result, prePos) : result.get(0));
}
}
else
{
for (int i = 0; i < wordArray.length; i++)
{
termList.add(new Word(wordArray[i], posArray[i]));
}
}
}
else
{
for (String word : wordArray)
{
termList.add(new Word(word, null));
}
}
return new Sentence(termList);
}
@Override
protected List<Term> roughSegSentence(char[] sentence)
{
return null;
}
@Override
protected List<Term> segSentence(char[] sentence)
{
if (sentence.length == 0)
{
return Collections.emptyList();
}
String original = new String(sentence);
CharTable.normalization(sentence);
String normalized = new String(sentence);
List<String> wordList = new LinkedList<String>();
segment(original, normalized, wordList);
List<Term> termList = new ArrayList<Term>(wordList.size());
int offset = 0;
for (String word : wordList)
{
Term term = new Term(word, null);
term.offset = offset;
offset += term.length();
termList.add(term);
}
if (config.speechTagging)
{
if (posTagger != null)
{
String[] wordArray = new String[wordList.size()];
offset = 0;
int id = 0;
for (String word : wordList)
{
wordArray[id] = normalized.substring(offset, offset + word.length());
++id;
offset += word.length();
}
String[] posArray = tag(wordArray);
Iterator<Term> iterator = termList.iterator();
for (String pos : posArray)
{
iterator.next().nature = Nature.create(pos);
}
if (config.ner && neRecognizer != null)
{
List<Term> childrenList = null;
if (config.isIndexMode())
{
childrenList = new LinkedList<Term>();
iterator = termList.iterator();
}
termList = new ArrayList<Term>(termList.size());
String[] nerArray = recognize(wordArray, posArray);
wordList.toArray(wordArray);
StringBuilder result = new StringBuilder();
result.append(wordArray[0]);
if (childrenList != null)
{
childrenList.add(iterator.next());
}
String prePos = posArray[0];
offset = 0;
for (int i = 1; i < nerArray.length; i++)
{
NERTagSet tagSet = getNERTagSet();
if (nerArray[i].charAt(0) == tagSet.B_TAG_CHAR || nerArray[i].charAt(0) == tagSet.S_TAG_CHAR || nerArray[i].charAt(0) == tagSet.O_TAG_CHAR)
{
Term term = new Term(result.toString(), Nature.create(prePos));
term.offset = offset;
offset += term.length();
termList.add(term);
if (childrenList != null)
{
if (childrenList.size() > 1)
{
for (Term shortTerm : childrenList)
{
if (shortTerm.length() >= config.indexMode)
{
termList.add(shortTerm);
}
}
}
childrenList.clear();
}
result.setLength(0);
}
result.append(wordArray[i]);
if (childrenList != null)
{
childrenList.add(iterator.next());
}
if (nerArray[i].charAt(0) == tagSet.O_TAG_CHAR || nerArray[i].charAt(0) == tagSet.S_TAG_CHAR)
{
prePos = posArray[i];
}
else
{
prePos = NERTagSet.posOf(nerArray[i]);
}
}
if (result.length() != 0)
{
Term term = new Term(result.toString(), Nature.create(posArray[posArray.length - 1]));
term.offset = offset;
termList.add(term);
if (childrenList != null)
{
if (childrenList.size() > 1)
{
for (Term shortTerm : childrenList)
{
if (shortTerm.length() >= config.indexMode)
{
termList.add(shortTerm);
}
}
}
}
}
}
}
else
{
for (Term term : termList)
{
CoreDictionary.Attribute attribute = CoreDictionary.get(term.word);
if (attribute != null)
{
term.nature = Nature.create(PosTagUtility.convert(attribute.nature[0]));
}
else
{
term.nature = Nature.n;
}
}
}
}
return termList;
}
}
| [
"[email protected]"
] | |
0f88ec4850c86aaa6c7c1b46f5396b5661f441fc | fa6e73b00d2a4ab95a2a8275d06ad7f148c05002 | /mvnrep-web/src/main/java/cn/v5cn/mvnrep/action/IndexAction.java | 061ef8b8a880c668e4dbc9fa9f65d553cedfd9e3 | [] | no_license | zyw/mvnrep-parent | e84057374b541871b69be0b658fe940ff5d82418 | c724b542e58892a851ea2297f7371ec860ed73ab | refs/heads/master | 2016-09-01T16:49:51.727628 | 2014-11-19T02:24:21 | 2014-11-19T02:24:21 | 23,395,767 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,467 | java | package cn.v5cn.mvnrep.action;
import cn.v5cn.mvnrep.entity.JarInfo;
import cn.v5cn.mvnrep.entity.JarTypeInfo;
import cn.v5cn.mvnrep.services.JarInfoService;
import cn.v5cn.mvnrep.services.JarTypeClickRatioService;
import cn.v5cn.mvnrep.services.JarTypeInfoService;
import cn.v5cn.mvnrep.services.SearchKeyService;
import cn.v5cn.mvnrep.utils.HttpUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.collect.ImmutableMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* Created by ZYW on 2014/8/27.
*/
@Controller
public class IndexAction {
@Autowired
private SearchKeyService searchKeyService;
@Autowired
private JarTypeInfoService jarTypeInfoService;
@Autowired
private JarTypeClickRatioService jarTypeClickRatioService;
@Autowired
private JarInfoService jarInfoService;
@RequestMapping(value = {"/","/index"},method = RequestMethod.GET)
public String index(ModelMap modelMap) throws IOException {
modelMap.addAttribute("searchText","");
return "index";
}
@RequestMapping(value = "/search/{s}",method = RequestMethod.GET)
public String searchList(@PathVariable String s,ModelMap modelMap) throws IOException{
searchKeyService.addOrUpdateSearchKey(s);
String searchUrl = "http://search.maven.org/solrsearch/select?q="+s+"&rows=200&wt=json";
ObjectMapper mapper = new ObjectMapper();
Map<String,Map> result = mapper.readValue(HttpUtils.getResult(searchUrl),Map.class);
HttpUtils.closeHttpResponse();
List<JarTypeInfo> searchInfos = jarTypeInfoService.addSearchJarInfo(((List)(result.get("response").get("docs"))));
modelMap.addAttribute("list", searchInfos);
modelMap.addAttribute("searchText",s);
return "search_list";
}
@RequestMapping(value = "/cvl/{g}/{a}",method = RequestMethod.GET)
public String componesVersionList(@PathVariable String g,@PathVariable String a,ModelMap modelMap) throws IOException{
String q = "http://search.maven.org/solrsearch/select?q=g%3A%22";
String z = "%22%20AND%20a%3A%22";
String h = "%22&rows=200&core=gav&wt=json";
String zh = q+g+z+a+h;
jarTypeClickRatioService.addOrUpdateClickRatio(g,a);
ObjectMapper mapper = new ObjectMapper();
Map<String,Map> httpRsult = mapper.readValue(HttpUtils.getResult(zh),Map.class);
HttpUtils.closeHttpResponse();
List<JarInfo> jarInfos = jarInfoService.addJarInfo((List<Map<String, Object>>) httpRsult.get("response").get("docs"));
modelMap.addAttribute("list", jarInfos);
modelMap.addAttribute("searchText",a);
return "cvl_list";
}
@RequestMapping(value = "/jcre/edit",method = RequestMethod.POST)
public ImmutableMap<String,String> jarClickRatioEdit(String g,String a,String v){
JarInfo jarInfo = jarInfoService.findByGAR(g,a,v);
Long result = jarInfoService.updateClickRatio(jarInfo.getJarInfoId(),jarInfo.getClickRatio()+1L);
return ImmutableMap.of("status","1","message","成功!");
}
} | [
"[email protected]"
] | |
57fc14a3d59305e7355f2874de713b3e52c60946 | 95333ca3fe4ba827f9f5149188998ce5892e4d07 | /demomall-coupon/src/main/java/cn/com/lan/demomall/coupon/controller/CouponController.java | 30111d308073578f13c702b9342cdd37874584a5 | [
"Apache-2.0"
] | permissive | lan-xianshen/lanmall | 66ce24eb5941fc78bf4a4f0c7d544b2614dd34b0 | d0a5a2d6862aa7bfb660a509dd9e7ac40b1938eb | refs/heads/main | 2023-02-19T18:46:05.347884 | 2021-01-18T10:37:10 | 2021-01-18T10:37:10 | 330,541,777 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,459 | java | package cn.com.lan.demomall.coupon.controller;
import java.util.Arrays;
import java.util.Map;
//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import cn.com.lan.demomall.coupon.entity.CouponEntity;
import cn.com.lan.demomall.coupon.service.CouponService;
import cn.com.lan.common.utils.PageUtils;
import cn.com.lan.common.utils.R;
/**
* 优惠券信息
*
* @author lan
* @email [email protected]
* @date 2021-01-18 16:22:42
*/
@RestController
@RequestMapping("coupon/coupon")
public class CouponController {
@Autowired
private CouponService couponService;
@RequestMapping("/member/list")
public R getCoupon(){
CouponEntity couponEntity = new CouponEntity ();
couponEntity.setCouponName ("买5赠送1");
return R.ok ().put ("coupon", Arrays.asList (couponEntity));
}
/**
* 列表
*/
@RequestMapping("/list")
//@RequiresPermissions("coupon:coupon:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = couponService.queryPage(params);
return R.ok().put("page", page);
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
//@RequiresPermissions("coupon:coupon:info")
public R info(@PathVariable("id") Long id){
CouponEntity coupon = couponService.getById(id);
return R.ok().put("coupon", coupon);
}
/**
* 保存
*/
@RequestMapping("/save")
//@RequiresPermissions("coupon:coupon:save")
public R save(@RequestBody CouponEntity coupon){
couponService.save(coupon);
return R.ok();
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("coupon:coupon:update")
public R update(@RequestBody CouponEntity coupon){
couponService.updateById(coupon);
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
//@RequiresPermissions("coupon:coupon:delete")
public R delete(@RequestBody Long[] ids){
couponService.removeByIds(Arrays.asList(ids));
return R.ok();
}
}
| [
"[email protected]"
] | |
319c232960cceb29361e11d85364230805a5e47b | 8a38bc7a1061cfb01cd581da9958033ccbdee654 | /dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/trackedentity/DefaultTrackerAccessManager.java | c4654a8293b0d45d805a577cf8f8134b02085489 | [
"BSD-3-Clause",
"BSD-2-Clause"
] | permissive | abyot/eotcnor | e4432448c91ca8a761fcb3088ecb52d97d0931e5 | 7220fd9f830a7a718c1231aa383589986f6ac5b9 | refs/heads/main | 2022-11-05T14:48:38.028658 | 2022-10-28T10:07:33 | 2022-10-28T10:07:33 | 120,287,850 | 0 | 0 | null | 2018-02-05T11:02:05 | 2018-02-05T10:10:22 | null | UTF-8 | Java | false | false | 28,389 | java | /*
* Copyright (c) 2004-2021, University of Oslo
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* Neither the name of the HISP project nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package org.hisp.dhis.trackedentity;
import static com.google.common.base.Preconditions.checkNotNull;
import java.util.ArrayList;
import java.util.List;
import org.hisp.dhis.category.CategoryOption;
import org.hisp.dhis.category.CategoryOptionCombo;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
import org.hisp.dhis.program.Program;
import org.hisp.dhis.program.ProgramInstance;
import org.hisp.dhis.program.ProgramStage;
import org.hisp.dhis.program.ProgramStageInstance;
import org.hisp.dhis.relationship.Relationship;
import org.hisp.dhis.relationship.RelationshipItem;
import org.hisp.dhis.relationship.RelationshipType;
import org.hisp.dhis.security.acl.AclService;
import org.hisp.dhis.user.User;
import org.springframework.stereotype.Component;
/**
* @author Morten Olav Hansen <[email protected]>
* @author Ameen Mohamed <[email protected]>
*/
@Component( "org.hisp.dhis.dxf2.events.TrackerAccessManager" )
public class DefaultTrackerAccessManager implements TrackerAccessManager
{
private final AclService aclService;
private final TrackerOwnershipManager ownershipAccessManager;
private final OrganisationUnitService organisationUnitService;
public DefaultTrackerAccessManager( AclService aclService, TrackerOwnershipManager ownershipAccessManager,
OrganisationUnitService organisationUnitService )
{
checkNotNull( aclService );
checkNotNull( ownershipAccessManager );
checkNotNull( organisationUnitService );
this.aclService = aclService;
this.ownershipAccessManager = ownershipAccessManager;
this.organisationUnitService = organisationUnitService;
}
@Override
public List<String> canRead( User user, TrackedEntityInstance trackedEntityInstance )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || trackedEntityInstance == null )
{
return errors;
}
OrganisationUnit ou = trackedEntityInstance.getOrganisationUnit();
if ( ou != null )
{ // ou should never be null, but needs to be checked for legacy reasons
if ( !organisationUnitService.isInUserSearchHierarchyCached( user, ou ) )
{
errors.add( "User has no read access to organisation unit: " + ou.getUid() );
}
}
TrackedEntityType trackedEntityType = trackedEntityInstance.getTrackedEntityType();
if ( !aclService.canDataRead( user, trackedEntityType ) )
{
errors.add( "User has no data read access to tracked entity: " + trackedEntityType.getUid() );
}
return errors;
}
@Override
public List<String> canWrite( User user, TrackedEntityInstance trackedEntityInstance )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || trackedEntityInstance == null )
{
return errors;
}
OrganisationUnit ou = trackedEntityInstance.getOrganisationUnit();
if ( ou != null )
{ // ou should never be null, but needs to be checked for legacy reasons
if ( !organisationUnitService.isInUserSearchHierarchyCached( user, ou ) )
{
errors.add( "User has no write access to organisation unit: " + ou.getUid() );
}
}
TrackedEntityType trackedEntityType = trackedEntityInstance.getTrackedEntityType();
if ( !aclService.canDataWrite( user, trackedEntityType ) )
{
errors.add( "User has no data write access to tracked entity: " + trackedEntityType.getUid() );
}
return errors;
}
@Override
public List<String> canRead( User user, TrackedEntityInstance trackedEntityInstance, Program program,
boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || trackedEntityInstance == null )
{
return errors;
}
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
TrackedEntityType trackedEntityType = trackedEntityInstance.getTrackedEntityType();
if ( !aclService.canDataRead( user, trackedEntityType ) )
{
errors.add( "User has no data read access to tracked entity: " + trackedEntityType.getUid() );
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user, trackedEntityInstance, program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
return errors;
}
@Override
public List<String> canWrite( User user, TrackedEntityInstance trackedEntityInstance, Program program,
boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || trackedEntityInstance == null )
{
return errors;
}
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
TrackedEntityType trackedEntityType = trackedEntityInstance.getTrackedEntityType();
if ( !aclService.canDataWrite( user, trackedEntityType ) )
{
errors.add( "User has no data write access to tracked entity: " + trackedEntityType.getUid() );
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user, trackedEntityInstance, program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
return errors;
}
@Override
public List<String> canRead( User user, ProgramInstance programInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programInstance == null )
{
return errors;
}
Program program = programInstance.getProgram();
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
if ( !program.isWithoutRegistration() )
{
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck
&& !ownershipAccessManager.hasAccess( user, programInstance.getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
else // this branch will only happen if coming from /events
{
OrganisationUnit ou = programInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserSearchHierarchyCached( user, ou ) )
{
errors.add( "User has no read access to organisation unit: " + ou.getUid() );
}
}
}
return errors;
}
@Override
public List<String> canCreate( User user, ProgramInstance programInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programInstance == null )
{
return errors;
}
Program program = programInstance.getProgram();
OrganisationUnit ou = programInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserHierarchyCached( user, ou ) )
{
errors.add( "User has no create access to organisation unit: " + ou.getUid() );
}
}
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
if ( !program.isWithoutRegistration() )
{
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck
&& !ownershipAccessManager.hasAccess( user, programInstance.getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
return errors;
}
@Override
public List<String> canUpdate( User user, ProgramInstance programInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programInstance == null )
{
return errors;
}
Program program = programInstance.getProgram();
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
if ( !program.isWithoutRegistration() )
{
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck
&& !ownershipAccessManager.hasAccess( user, programInstance.getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
else
{
OrganisationUnit ou = programInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserHierarchyCached( user, ou ) )
{
errors.add( "User has no write access to organisation unit: " + ou.getUid() );
}
}
}
return errors;
}
@Override
public List<String> canDelete( User user, ProgramInstance programInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programInstance == null )
{
return errors;
}
Program program = programInstance.getProgram();
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
if ( !program.isWithoutRegistration() )
{
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck
&& !ownershipAccessManager.hasAccess( user, programInstance.getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
else
{
OrganisationUnit ou = programInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserHierarchyCached( user, ou ) )
{
errors.add( "User has no delete access to organisation unit: " + ou.getUid() );
}
}
}
return errors;
}
@Override
public List<String> canRead( User user, ProgramStageInstance programStageInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programStageInstance == null )
{
return errors;
}
ProgramStage programStage = programStageInstance.getProgramStage();
if ( isNull( programStage ) )
{
return errors;
}
Program program = programStage.getProgram();
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
if ( !program.isWithoutRegistration() )
{
if ( !aclService.canDataRead( user, programStage ) )
{
errors.add( "User has no data read access to program stage: " + programStage.getUid() );
}
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user,
programStageInstance.getProgramInstance().getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
else
{
OrganisationUnit ou = programStageInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserSearchHierarchyCached( user, ou ) )
{
errors.add( "User has no read access to organisation unit: " + ou.getUid() );
}
}
}
errors.addAll( canRead( user, programStageInstance.getAttributeOptionCombo() ) );
return errors;
}
@Override
public List<String> canCreate( User user, ProgramStageInstance programStageInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programStageInstance == null )
{
return errors;
}
ProgramStage programStage = programStageInstance.getProgramStage();
if ( isNull( programStage ) )
{
return errors;
}
Program program = programStage.getProgram();
OrganisationUnit ou = programStageInstance.getOrganisationUnit();
if ( ou != null )
{
if ( programStageInstance.isCreatableInSearchScope()
? !organisationUnitService.isInUserSearchHierarchyCached( user, ou )
: !organisationUnitService.isInUserHierarchyCached( user, ou ) )
{
errors.add( "User has no create access to organisation unit: " + ou.getUid() );
}
}
if ( program.isWithoutRegistration() )
{
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
}
else
{
if ( !aclService.canDataWrite( user, programStage ) )
{
errors.add( "User has no data write access to program stage: " + programStage.getUid() );
}
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user,
programStageInstance.getProgramInstance().getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
errors.addAll( canWrite( user, programStageInstance.getAttributeOptionCombo() ) );
return errors;
}
@Override
public List<String> canUpdate( User user, ProgramStageInstance programStageInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programStageInstance == null )
{
return errors;
}
ProgramStage programStage = programStageInstance.getProgramStage();
if ( isNull( programStage ) )
{
return errors;
}
Program program = programStage.getProgram();
if ( program.isWithoutRegistration() )
{
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
}
else
{
if ( !aclService.canDataWrite( user, programStage ) )
{
errors.add( "User has no data write access to program stage: " + programStage.getUid() );
}
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
OrganisationUnit ou = programStageInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserSearchHierarchyCached( user, ou ) )
{
errors.add( "User has no update access to organisation unit: " + ou.getUid() );
}
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user,
programStageInstance.getProgramInstance().getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
errors.addAll( canWrite( user, programStageInstance.getAttributeOptionCombo() ) );
return errors;
}
@Override
public List<String> canDelete( User user, ProgramStageInstance programStageInstance, boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || programStageInstance == null )
{
return errors;
}
ProgramStage programStage = programStageInstance.getProgramStage();
if ( isNull( programStage ) )
{
return errors;
}
Program program = programStage.getProgram();
if ( program.isWithoutRegistration() )
{
OrganisationUnit ou = programStageInstance.getOrganisationUnit();
if ( ou != null )
{
if ( !organisationUnitService.isInUserHierarchyCached( user, ou ) )
{
errors.add( "User has no delete access to organisation unit: " + ou.getUid() );
}
}
if ( !aclService.canDataWrite( user, program ) )
{
errors.add( "User has no data write access to program: " + program.getUid() );
}
}
else
{
if ( !aclService.canDataWrite( user, programStage ) )
{
errors.add( "User has no data write access to program stage: " + programStage.getUid() );
}
if ( !aclService.canDataRead( user, program ) )
{
errors.add( "User has no data read access to program: " + program.getUid() );
}
if ( !aclService.canDataRead( user, program.getTrackedEntityType() ) )
{
errors.add(
"User has no data read access to tracked entity type: " + program.getTrackedEntityType().getUid() );
}
if ( !skipOwnershipCheck && !ownershipAccessManager.hasAccess( user,
programStageInstance.getProgramInstance().getEntityInstance(), program ) )
{
errors.add( TrackerOwnershipManager.OWNERSHIP_ACCESS_DENIED );
}
}
errors.addAll( canWrite( user, programStageInstance.getAttributeOptionCombo() ) );
return errors;
}
@Override
public List<String> canRead( User user, Relationship relationship )
{
List<String> errors = new ArrayList<>();
RelationshipType relationshipType;
RelationshipItem from;
RelationshipItem to;
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || relationship == null )
{
return errors;
}
relationshipType = relationship.getRelationshipType();
if ( !aclService.canDataRead( user, relationshipType ) )
{
errors.add( "User has no data read access to relationshipType: " + relationshipType.getUid() );
}
from = relationship.getFrom();
to = relationship.getTo();
errors.addAll( canRead( user, from.getTrackedEntityInstance() ) );
errors.addAll( canRead( user, from.getProgramInstance(), false ) );
errors.addAll( canRead( user, from.getProgramStageInstance(), false ) );
errors.addAll( canRead( user, to.getTrackedEntityInstance() ) );
errors.addAll( canRead( user, to.getProgramInstance(), false ) );
errors.addAll( canRead( user, to.getProgramStageInstance(), false ) );
return errors;
}
@Override
public List<String> canWrite( User user, Relationship relationship )
{
List<String> errors = new ArrayList<>();
RelationshipType relationshipType;
RelationshipItem from;
RelationshipItem to;
// always allow if user == null (internal process) or user is superuser
if ( user == null || user.isSuper() || relationship == null )
{
return errors;
}
relationshipType = relationship.getRelationshipType();
if ( !aclService.canDataWrite( user, relationshipType ) )
{
errors.add( "User has no data write access to relationshipType: " + relationshipType.getUid() );
}
from = relationship.getFrom();
to = relationship.getTo();
errors.addAll( canWrite( user, from.getTrackedEntityInstance() ) );
errors.addAll( canUpdate( user, from.getProgramInstance(), false ) );
errors.addAll( canUpdate( user, from.getProgramStageInstance(), false ) );
errors.addAll( canWrite( user, to.getTrackedEntityInstance() ) );
errors.addAll( canUpdate( user, to.getProgramInstance(), false ) );
errors.addAll( canUpdate( user, to.getProgramStageInstance(), false ) );
return errors;
}
@Override
public List<String> canRead( User user, ProgramStageInstance programStageInstance, DataElement dataElement,
boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
if ( user == null || user.isSuper() )
{
return errors;
}
errors.addAll( canRead( user, programStageInstance, skipOwnershipCheck ) );
if ( !aclService.canRead( user, dataElement ) )
{
errors.add( "User has no read access to data element: " + dataElement.getUid() );
}
return errors;
}
@Override
public List<String> canWrite( User user, ProgramStageInstance programStageInstance, DataElement dataElement,
boolean skipOwnershipCheck )
{
List<String> errors = new ArrayList<>();
if ( user == null || user.isSuper() )
{
return errors;
}
errors.addAll( canUpdate( user, programStageInstance, skipOwnershipCheck ) );
if ( !aclService.canRead( user, dataElement ) )
{
errors.add( "User has no read access to data element: " + dataElement.getUid() );
}
return errors;
}
@Override
public List<String> canRead( User user, CategoryOptionCombo categoryOptionCombo )
{
List<String> errors = new ArrayList<>();
if ( user == null || user.isSuper() || categoryOptionCombo == null )
{
return errors;
}
for ( CategoryOption categoryOption : categoryOptionCombo.getCategoryOptions() )
{
if ( !aclService.canDataRead( user, categoryOption ) )
{
errors.add( "User has no read access to category option: " + categoryOption.getUid() );
}
}
return errors;
}
@Override
public List<String> canWrite( User user, CategoryOptionCombo categoryOptionCombo )
{
List<String> errors = new ArrayList<>();
if ( user == null || user.isSuper() || categoryOptionCombo == null )
{
return errors;
}
for ( CategoryOption categoryOption : categoryOptionCombo.getCategoryOptions() )
{
if ( !aclService.canDataWrite( user, categoryOption ) )
{
errors.add( "User has no write access to category option: " + categoryOption.getUid() );
}
}
return errors;
}
private boolean isNull( ProgramStage programStage )
{
return programStage == null || programStage.getProgram() == null;
}
}
| [
"[email protected]"
] | |
cf3d8f2afde77746f239c46c1b32beead0f2bfb6 | 7f298c2bf9ff5a61eeb87e3929e072c9a04c8832 | /spring-context/src/test/java/org/springframework/scheduling/annotation/AsyncAnnotationBeanPostProcessorTests.java | 239837bebd9d754434867a1d662c36247cafebb2 | [
"Apache-2.0"
] | permissive | stwen/my-spring5 | 1ca1e85786ba1b5fdb90a583444a9c030fe429dd | d44be68874b8152d32403fe87c39ae2a8bebac18 | refs/heads/master | 2023-02-17T19:51:32.686701 | 2021-01-15T05:39:14 | 2021-01-15T05:39:14 | 322,756,105 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,220 | java | /*
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.scheduling.annotation;
import java.lang.reflect.Method;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Executor;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.junit.Test;
import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
import org.springframework.aop.support.AopUtils;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.RootBeanDefinition;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.GenericXmlApplicationContext;
import org.springframework.context.support.StaticApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.ReflectionUtils;
import org.springframework.util.concurrent.ListenableFuture;
import static org.junit.Assert.*;
/**
* @author Mark Fisher
* @author Juergen Hoeller
* @author Stephane Nicoll
*/
public class AsyncAnnotationBeanPostProcessorTests {
@Test
public void proxyCreated() {
ConfigurableApplicationContext context = initContext(
new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
Object target = context.getBean("target");
assertTrue(AopUtils.isAopProxy(target));
context.close();
}
@Test
public void invokedAsynchronously() {
ConfigurableApplicationContext context = initContext(
new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class));
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
Thread mainThread = Thread.currentThread();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertNotSame(mainThread, asyncThread);
context.close();
}
@Test
public void threadNamePrefix() {
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setThreadNamePrefix("testExecutor");
executor.afterPropertiesSet();
processorDefinition.getPropertyValues().add("executor", executor);
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor"));
context.close();
}
@Test
public void taskExecutorByBeanType() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
context.registerBeanDefinition("postProcessor", processorDefinition);
BeanDefinition executorDefinition = new RootBeanDefinition(ThreadPoolTaskExecutor.class);
executorDefinition.getPropertyValues().add("threadNamePrefix", "testExecutor");
context.registerBeanDefinition("myExecutor", executorDefinition);
BeanDefinition targetDefinition =
new RootBeanDefinition(AsyncAnnotationBeanPostProcessorTests.TestBean.class);
context.registerBeanDefinition("target", targetDefinition);
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor"));
context.close();
}
@Test
public void taskExecutorByBeanName() {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
context.registerBeanDefinition("postProcessor", processorDefinition);
BeanDefinition executorDefinition = new RootBeanDefinition(ThreadPoolTaskExecutor.class);
executorDefinition.getPropertyValues().add("threadNamePrefix", "testExecutor");
context.registerBeanDefinition("myExecutor", executorDefinition);
BeanDefinition executorDefinition2 = new RootBeanDefinition(ThreadPoolTaskExecutor.class);
executorDefinition2.getPropertyValues().add("threadNamePrefix", "testExecutor2");
context.registerBeanDefinition("taskExecutor", executorDefinition2);
BeanDefinition targetDefinition =
new RootBeanDefinition(AsyncAnnotationBeanPostProcessorTests.TestBean.class);
context.registerBeanDefinition("target", targetDefinition);
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor2"));
context.close();
}
@Test
public void configuredThroughNamespace() {
GenericXmlApplicationContext context = new GenericXmlApplicationContext();
context.load(new ClassPathResource("taskNamespaceTests.xml", getClass()));
context.refresh();
ITestBean testBean = context.getBean("target", ITestBean.class);
testBean.test();
testBean.await(3000);
Thread asyncThread = testBean.getThread();
assertTrue(asyncThread.getName().startsWith("testExecutor"));
TestableAsyncUncaughtExceptionHandler exceptionHandler =
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertFalse("handler should not have been called yet", exceptionHandler.isCalled());
testBean.failWithVoid();
exceptionHandler.await(3000);
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
context.close();
}
@Test
public void handleExceptionWithFuture() {
ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
ITestBean testBean = context.getBean("target", ITestBean.class);
TestableAsyncUncaughtExceptionHandler exceptionHandler =
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertFalse("handler should not have been called yet", exceptionHandler.isCalled());
Future<Object> result = testBean.failWithFuture();
assertFutureWithException(result, exceptionHandler);
}
@Test
public void handleExceptionWithListenableFuture() {
ConfigurableApplicationContext context =
new AnnotationConfigApplicationContext(ConfigWithExceptionHandler.class);
ITestBean testBean = context.getBean("target", ITestBean.class);
TestableAsyncUncaughtExceptionHandler exceptionHandler =
context.getBean("exceptionHandler", TestableAsyncUncaughtExceptionHandler.class);
assertFalse("handler should not have been called yet", exceptionHandler.isCalled());
Future<Object> result = testBean.failWithListenableFuture();
assertFutureWithException(result, exceptionHandler);
}
private void assertFutureWithException(Future<Object> result,
TestableAsyncUncaughtExceptionHandler exceptionHandler) {
try {
result.get();
} catch (InterruptedException ex) {
fail("Should not have failed with InterruptedException: " + ex);
} catch (ExecutionException ex) {
// expected
assertEquals("Wrong exception cause", UnsupportedOperationException.class, ex.getCause().getClass());
}
assertFalse("handler should never be called with Future return type", exceptionHandler.isCalled());
}
@Test
public void handleExceptionWithCustomExceptionHandler() {
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
TestableAsyncUncaughtExceptionHandler exceptionHandler =
new TestableAsyncUncaughtExceptionHandler();
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
processorDefinition.getPropertyValues().add("exceptionHandler", exceptionHandler);
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.class);
assertFalse("Handler should not have been called", exceptionHandler.isCalled());
testBean.failWithVoid();
exceptionHandler.await(3000);
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
}
@Test
public void exceptionHandlerThrowsUnexpectedException() {
Method m = ReflectionUtils.findMethod(TestBean.class, "failWithVoid");
TestableAsyncUncaughtExceptionHandler exceptionHandler =
new TestableAsyncUncaughtExceptionHandler(true);
BeanDefinition processorDefinition = new RootBeanDefinition(AsyncAnnotationBeanPostProcessor.class);
processorDefinition.getPropertyValues().add("exceptionHandler", exceptionHandler);
processorDefinition.getPropertyValues().add("executor", new DirectExecutor());
ConfigurableApplicationContext context = initContext(processorDefinition);
ITestBean testBean = context.getBean("target", ITestBean.class);
assertFalse("Handler should not have been called", exceptionHandler.isCalled());
try {
testBean.failWithVoid();
exceptionHandler.assertCalledWith(m, UnsupportedOperationException.class);
} catch (Exception e) {
fail("No unexpected exception should have been received");
}
}
private ConfigurableApplicationContext initContext(BeanDefinition asyncAnnotationBeanPostProcessorDefinition) {
StaticApplicationContext context = new StaticApplicationContext();
BeanDefinition targetDefinition =
new RootBeanDefinition(AsyncAnnotationBeanPostProcessorTests.TestBean.class);
context.registerBeanDefinition("postProcessor", asyncAnnotationBeanPostProcessorDefinition);
context.registerBeanDefinition("target", targetDefinition);
context.refresh();
return context;
}
private interface ITestBean {
Thread getThread();
void test();
Future<Object> failWithFuture();
ListenableFuture<Object> failWithListenableFuture();
void failWithVoid();
void await(long timeout);
}
public static class TestBean implements ITestBean {
private Thread thread;
private final CountDownLatch latch = new CountDownLatch(1);
@Override
public Thread getThread() {
return this.thread;
}
@Override
@Async
public void test() {
this.thread = Thread.currentThread();
this.latch.countDown();
}
@Async
@Override
public Future<Object> failWithFuture() {
throw new UnsupportedOperationException("failWithFuture");
}
@Async
@Override
public ListenableFuture<Object> failWithListenableFuture() {
throw new UnsupportedOperationException("failWithListenableFuture");
}
@Async
@Override
public void failWithVoid() {
throw new UnsupportedOperationException("failWithVoid");
}
@Override
public void await(long timeout) {
try {
this.latch.await(timeout, TimeUnit.MILLISECONDS);
} catch (Exception e) {
Thread.currentThread().interrupt();
}
}
}
private static class DirectExecutor implements Executor {
@Override
public void execute(Runnable r) {
r.run();
}
}
@Configuration
@EnableAsync
static class ConfigWithExceptionHandler extends AsyncConfigurerSupport {
@Bean
public ITestBean target() {
return new TestBean();
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return exceptionHandler();
}
@Bean
public TestableAsyncUncaughtExceptionHandler exceptionHandler() {
return new TestableAsyncUncaughtExceptionHandler();
}
}
}
| [
"[email protected]"
] | |
1d66342a2a885f2229ff9ce2b859e7192cd7c62f | 973e0ef0d9b41a14d585370a260ffe4605cb9091 | /服务器/src/main/java/com/shi/dao/impl/UserRoleRelDaoImpl.java | 67866476392c3b61c23617d51e483a82e3e7d440 | [] | no_license | Mrlong12/GCXL | 65a69195fe9a706d1bbea016c6ebac99a7d27bf2 | 4bc479bbe838b5f992561619937fd435220024f9 | refs/heads/master | 2023-01-24T07:45:36.833291 | 2019-07-07T04:41:29 | 2019-07-07T04:41:29 | 194,100,757 | 0 | 0 | null | 2023-01-05T03:14:15 | 2019-06-27T13:29:05 | JavaScript | UTF-8 | Java | false | false | 293 | java | package com.shi.dao.impl;
import org.springframework.stereotype.Repository;
import com.shi.dao.UserRoleRelDao;
import com.shi.entity.Role;
import com.shi.entity.UserRoleRel;
@Repository
public class UserRoleRelDaoImpl extends BaseDaoImpl<UserRoleRel, String> implements UserRoleRelDao {
}
| [
"[email protected]"
] | |
7889b53cfede68854d98c50f12ce35bcbf06ab27 | 55fd0dbda650f4744058c68ff7bef1308842c0e3 | /src/TableModels/PostesModel.java | dfebe98f88e75d102af20bceb0c7f6cbc767e482 | [] | no_license | Luis-Medina/EstimateManager | ac93d3f7dd086d0bd4f6a32cc5cdf908c8f3f522 | d2eea67e075714cb154867854e4616bc52f80545 | refs/heads/master | 2021-01-10T21:31:55.237539 | 2015-03-25T22:22:57 | 2015-03-25T22:22:57 | 32,044,114 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,849 | java | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package TableModels;
import omarproject.*;
import java.util.ArrayList;
import javax.swing.table.AbstractTableModel;
/**
*
* @author Luiso
*/
public class PostesModel extends AbstractTableModel {
private ArrayList<Poste> datalist = new ArrayList<Poste>();
private String[] columns = {"Clase", "Alto (pies)", "Precio ($)"};
public int getRowCount() {
return datalist.size();
}
public int getColumnCount() {
return columns.length;
}
public String getColumnName(int col) {
return columns[col];
}
public PostesModel() {
}
public PostesModel(ArrayList<Poste> l) {
datalist = l;
}
public void setList(ArrayList<Poste> l) {
datalist = l;
fireTableDataChanged();
}
public Object getValueAt(int row, int col) {
Poste m = (Poste) datalist.get(row);
switch (col) {
case 0:
return m.getClase();
case 1:
return m.getHeight();
case 2:
return m.getPrice();
default:
return null;
}
}
public void addPoste(Poste a) {
datalist.add(a);
fireTableDataChanged();
}
public void addPosteList(ArrayList<Poste> l) {
datalist.addAll(l);
fireTableDataChanged();
}
public Poste getPosteAt(int row) {
return (Poste) datalist.get(row);
}
public Poste removePosteAt(int row) {
Poste a = (Poste) datalist.remove(row);
fireTableDataChanged();
return a;
}
public Class getColumnClass(int col) {
switch (col) {
case 0:
return String.class;
case 1:
return Integer.class;
case 2:
return Double.class;
default:
return Object.class;
}
}
public void setValueAt(Object value, int row, int col) {
Poste a = (Poste) datalist.get(row);
switch (col) {
case 0:
a.setClase(value.toString());
break;
case 1:
Integer valor = (Integer) value;
a.setHeight(valor.intValue());
break;
case 2:
Double valor1 = (Double) value;
a.setPrice(valor1.doubleValue());
break;
}
}
public boolean isCellEditable(int row, int col) {
switch (col) {
case 0: //Name
return true;
case 1: //value
return true;
case 2: //location
return true;
default:
return true;
}
}
}
| [
"[email protected]"
] | |
6b4246f30904b1fd6060c3c9a39f8b506c9b9674 | c5de6f4aef66d7bbd0c6f5f3bcb3170fa544a35f | /lista_dupla/src/noh/ListaDupla.java | c44e4abef14b2f7bdd43cdd0adc13ab3edda8db7 | [] | no_license | cukier/C | 01a1b6aadd4cd114a1a2079ba8a28ef30bf5e689 | 18d261704f126ed3dadf8f97d089c1eb673db8f7 | refs/heads/master | 2016-09-09T20:14:57.462127 | 2016-01-13T23:47:45 | 2016-01-13T23:47:45 | 18,097,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 305 | java | package noh;
public class ListaDupla {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Lista root = new Lista ();
root.criaNoh(10);
root.criaNoh(20);
root.criaNoh(30);
root.criaNoh(20);
root.criaNoh(10);
root.imprimeNoh();
}
}
| [
"[email protected]"
] | |
ba4a1342822639e9f1a45320174b32f12dea5ca1 | bc1dd1f6330d22da6f3681f793c443efe573965a | /JavaBasics-Nov/src/com/wbl/opertorsLoops/Operators.java | f21b2966bbf0ef3e39d1b913d1a6151a0f8a57e0 | [] | no_license | medhawbl/Nov-ClassCode | 17800689c7a597db80ec4408b35bf8739939a494 | 0bc56ff86c88727efb6a275e636af12979132f5e | refs/heads/master | 2021-01-13T14:54:55.333802 | 2017-05-16T19:25:50 | 2017-05-16T19:25:50 | 76,693,193 | 0 | 3 | null | null | null | null | UTF-8 | Java | false | false | 2,064 | java | package com.wbl.opertorsLoops;
import com.wbl.oops.Loan;
import com.wbl.oops.MortgageLoan;
public class Operators {
public static void main(String[] args) {
int a = 40;
int b= 5;
//arithmetic
int result = a+b;
System.out.println("a+b:"+result);
result = a-b;
System.out.println("a-b:"+result);
System.out.println("a*b:"+(a*b));
System.out.println("a/b:"+(a/b));
System.out.println("a%b:"+(a%b));
result = (4+6)*5;
System.out.println("result:"+result);
//unary opeartors
int i = 10;
System.out.println("post increment::"+(i++));
System.out.println("post increment after statement::"+(i));
System.out.println("prefix increment::"+(++i));
System.out.println("prefix increment after statement::"+(i));
int b1 = 6;//0110
b1= ~b1;
System.out.println("negation::"+(b1));
boolean b2 = true;
System.out.println("not on boolean:"+ !b2);
//equality or relational- always evaluate to boolean-true or false
System.out.println(a>b);
System.out.println(a<b);
System.out.println(a>=b);
System.out.println(a<=b);
System.out.println(a==b);
System.out.println(a!=b);
a=50;
b=250;
int c= 17;
//logical or short circuit and and or
if( a>b && a>c){
System.out.println("a is greater");
}
if( a>b || a>c){
System.out.println("a is greater");
}
//ternary operator
/*if(a>b){
result=a;
}else{
result =b;
}*/
result = a>b ? a : b;
System.out.println(result);
//instanceof operator - to check object is instance of specfic class or not
Loan l = new Loan();
if(l instanceof MortgageLoan){
System.out.println("l is instance of loan");
}else{
System.out.println("it is not instance");
}
//bitwise operators
int i1 = 6;
i1= i1>>1;//signed right shift
System.out.println(i1);
i1=6;
i1= i1<<2;//signed left shift
System.out.println(i1);
i1 = 6;
i1= i1>>>1;//unsigned right shift which is only for positive
System.out.println(i1);
int res = 6&5;
System.out.println(res);
int k=5;
k = k+5;
k = 5;
}
}
| [
"[email protected]"
] | |
281d836f929447a42aa201a73ab8c2925be8ff15 | 8174a0af1e807ed7c4a8169e2c0ba6c91597159e | /gestoli/.svn/pristine/28/281d836f929447a42aa201a73ab8c2925be8ff15.svn-base | 2330f29aeb78d81af9a054767f6f5421d33f1fa7 | [] | no_license | gestoli/gestoli | 458caf53253175fddd81bf7128c6b28447e6f65b | 7c2d84e4827944ab40ef82caddfbb32186394f94 | refs/heads/master | 2020-04-06T03:56:53.363810 | 2017-02-25T01:35:31 | 2017-02-25T01:35:31 | 83,093,533 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,916 | /**
* GestionarDocumentValidator.java
*
* Creada el 28 de juliol de 2009
* © at4.net 2009
*/
package es.caib.gestoli.front.spring;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;
/**
* Validador para los campos asociados con el formulario de creación/edición.
*/
public class GestionarDocumentValidator implements Validator {
private HibernateTemplate hibernateTemplate;
/**
* Indica las clases que soporta este validador.
* @see Validator#supports(java.lang.Class)
*/
public boolean supports(Class clazz) {
return clazz.equals(GestionarDocumentCommand.class);
}
/**
* Valida el objeto.
* @see Validator#validate(java.lang.Object, org.springframework.validation.Errors)
*/
public void validate(Object obj, Errors errors) {
ValidationUtils.rejectIfEmpty(
errors,
"titol",
"error.titol.buit",
"El camp titol no pot estar buit");
GestionarDocumentCommand command = (GestionarDocumentCommand) obj;
if (command.getArxiu() == null && (command.getFitxer() == null || (command.getFitxer() != null && command.getFitxer().length == 0))) {
ValidationUtils.rejectIfEmpty(
errors,
"fitxer",
"error.fitxer.buit",
"Ha de seleccionar un fixer");
}
}
/**
* set the hibernate template.
* @param hibernateTemplate the hibernate spring template.
* @spring.property ref="hibernateTemplate"
*/
public void setHibernateTemplate(HibernateTemplate hibernateTemplate){
this.hibernateTemplate = hibernateTemplate;
}
/**
* get the hibernate template.
* @return the hibernate spring template.
*/
public HibernateTemplate getHibernateTemplate(){
return this.hibernateTemplate;
}
}
| [
"[email protected]"
] | ||
b6984c79ee1fb5e518170e59830fda06b8d3e502 | 872775d142e9269681d331844ce0d0892ef4ebce | /src/com/hm/pattern/proxy/gumballmonitor/NoQuarterState.java | 5fc2f003675372d7dfc22b8f7ff6b3587a70b46c | [] | no_license | humanheima/JavaBase | b756274931b21040ca80a74ac00dc7a20ff7b92b | dba8fc5940f16795a0c2bad34d639f5e5713c8f6 | refs/heads/master | 2023-06-08T20:02:31.280986 | 2023-05-25T10:04:40 | 2023-05-25T10:04:40 | 88,835,885 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 769 | java | package com.hm.pattern.proxy.gumballmonitor;
public class NoQuarterState implements State {
private static final long serialVersionUID = 2L;
GumballMachine gumballMachine;
public NoQuarterState(GumballMachine gumballMachine) {
this.gumballMachine = gumballMachine;
}
public void insertQuarter() {
System.out.println("You inserted a quarter");
gumballMachine.setState(gumballMachine.getHasQuarterState());
}
public void ejectQuarter() {
System.out.println("You haven't inserted a quarter");
}
public void turnCrank() {
System.out.println("You turned, but there's no quarter");
}
public void dispense() {
System.out.println("You need to pay first");
}
public String toString() {
return "waiting for quarter";
}
}
| [
"[email protected]"
] | |
1d789b2df8aad63e4b519bbe252372f5c0452b1c | 80f03f14c7f8f5d6b3776fa5a2ed1844c8488fbf | /src/Producer.java | 4a9bac45560c2a0325ccf7f0e4b7d9f9623698ea | [] | no_license | Ilovitt19/Project-1_Iteration-2 | 15b2b5d176b67ae4d59749e4d2bea894ff2d0d5e | aa32a93263b9d1b6d62dc1a88d2ec3460d13222b | refs/heads/master | 2016-09-05T17:27:16.934799 | 2015-03-19T04:15:12 | 2015-03-19T04:15:12 | 32,500,296 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,092 | java | import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;
/**
* Stores producers
*
*/
public class Producer implements Serializable, Matchable<String> {
private static final long serialVersionUID = 1L;
private String name;
private String id;
private String address;
private String phone;
private double balance = 0;
private static final String PRODUCER_STRING = "P";
private List showsProduced = new LinkedList();
/**
* constructor for producer class
* @param name
* @param address
* @param phone
*/
public Producer(String name, String address, String phone){
this.name = name;
this.address = address;
this.phone = phone;
id = PRODUCER_STRING + (ProducerIdServer.instance()).getId();
}
/**
* gets pruducer name
* @return
*/
public String getName() {
return name;
}
/**
* sets producer name
* @param name
*/
public void setName(String name) {
this.name = name;
}
/**
* gets producer id
* @return id
*/
public String getId() {
return id;
}
/**
* sets producer id
* @param id
*/
public void setId(String id) {
this.id = id;
}
/**
* gets producer address
* @return adress
*/
public String getAddress() {
return address;
}
/**
* sets producer adress
* @param address
*/
public void setAddress(String address) {
this.address = address;
}
/**
* gets producer phone number
* @return
*/
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
/**
* gets balance
* @return balance
*/
public double getBalance() {
return balance;
}
/**
* sets producer balance
* @param balance
*/
public void setBalance(double balance) {
this.balance = this.balance + balance;
}
/**
* String representaion of a producer
* @return
*/
@Override
public String toString() {
String string = "Producer name: " + name + " address: " + address + " id: " + id + " phone: " + phone + " balance: " + balance;
return string;
}
@Override
public boolean matches(String key) {
return id.equals(key);
}
} | [
"[email protected]"
] | |
9ce5e4f638e52ddaf409260b223251ac2ff23800 | 83bf83bc9bcc302208062005922881a8e56cee07 | /src/main/java/com/example/karumanchi/chapter03linkedlists/ExchangeAdjacentNodes.java | 5e260b4b093477223830c7da2a5ec62e7eca8de5 | [] | no_license | aniliitr007/coding-practice | 8a16fec555667bac2a0280072fe2575b2d1b7cb7 | 107bb640b42f07c4d90b772d676ff61026b8ce6a | refs/heads/master | 2022-11-29T23:02:18.235816 | 2020-03-28T10:59:26 | 2020-03-28T10:59:26 | 250,721,345 | 1 | 0 | null | 2020-03-28T06:41:30 | 2020-03-28T05:26:47 | Java | UTF-8 | Java | false | false | 1,050 | java | /*Copyright (c) Dec 21, 2014 CareerMonk Publications and others.
* E-Mail : [email protected]
* Creation Date : 2015-01-10 06:15:46
* Last modification : 2006-05-31
by : Narasimha Karumanchi
* Book Title : Data Structures And Algorithms Made In Java
* Warranty : This software is provided "as is" without any
* warranty; without even the implied warranty of
* merchantability or fitness for a particular purpose.
*
*/
package com.example.karumanchi.chapter03linkedlists;
public class ExchangeAdjacentNodes {
public ListNode exchangeAdjacentNodes(ListNode head) {
ListNode temp = new ListNode(0);
temp.next = head;
ListNode prev = temp, curr = head;
while(curr != null && curr.next != null){
ListNode tmp = curr.next.next;
curr.next.next = prev.next;
prev.next = curr.next;
curr.next = tmp;
prev = curr;
curr = prev.next;
}
return temp.next;
}
}
| [
"[email protected]"
] | |
e58abc3422ec8c96750988bc1e84589b64f7e7f7 | 91c0a7aed24877a4453d2817858ed3cfd8d57d3d | /components/mediation/mediation-library/connectors/org.wso2.carbon.connector.googlespreadsheet/src/main/java/org/wso2/carbon/connector/googlespreadsheet/GoogleSpreadsheetGetColumnHeaders.java | 07290b5ef4d953d8640cd108ec981ad49204c328 | [] | no_license | brianwebpt/platform | 77025fd2a02f641138e7611109ddcd5f0757b868 | a98839e703d856a553c8d67a9cf701c6952aa0d2 | refs/heads/master | 2020-12-25T08:43:03.913167 | 2013-08-13T18:38:02 | 2013-08-13T18:38:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,386 | java | /*
* Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
*
* WSO2 Inc. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.wso2.carbon.connector.googlespreadsheet;
import java.io.IOException;
import java.util.List;
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.synapse.MessageContext;
import org.wso2.carbon.mediation.library.connectors.core.AbstractConnector;
import org.wso2.carbon.mediation.library.connectors.core.ConnectException;
import com.google.gdata.client.spreadsheet.SpreadsheetService;
import com.google.gdata.data.spreadsheet.SpreadsheetEntry;
import com.google.gdata.data.spreadsheet.WorksheetEntry;
import com.google.gdata.util.ServiceException;
public class GoogleSpreadsheetGetColumnHeaders extends AbstractConnector {
public static final String WORKSHEET_NAME = "worksheet.name";
public static final String SPREADSHEET_NAME = "spreadsheet.name";
private static Log log = LogFactory
.getLog(GoogleSpreadsheetGetColumnHeaders.class);
public void connect(MessageContext messageContext) throws ConnectException {
try {
String worksheetName = GoogleSpreadsheetUtils
.lookupFunctionParam(messageContext, WORKSHEET_NAME);
String spreadsheetName = GoogleSpreadsheetUtils
.lookupFunctionParam(messageContext, SPREADSHEET_NAME);
if ((worksheetName == null || "".equals(worksheetName.trim()))
|| (spreadsheetName == null
|| "".equals(spreadsheetName.trim()))
) {
log.info("Please make sure you have given a valid input for the worksheet or spreadsheet name");
return;
}
SpreadsheetService ssService = new GoogleSpreadsheetClientLoader(
messageContext).loadSpreadsheetService();
GoogleSpreadsheet gss = new GoogleSpreadsheet(ssService);
SpreadsheetEntry ssEntry = gss
.getSpreadSheetsByTitle(spreadsheetName);
GoogleSpreadsheetWorksheet gssWorksheet = new GoogleSpreadsheetWorksheet(
ssService, ssEntry.getWorksheetFeedUrl());
WorksheetEntry wsEntry = gssWorksheet
.getWorksheetByTitle(worksheetName);
List<String> resultData = gssWorksheet.getColumnHeaders(wsEntry);
int resultSize = resultData.size();
messageContext.getEnvelope().getBody().getFirstElement().detach();
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns = factory.createOMNamespace("http://org.wso2.esbconnectors.googlespreadsheet", "ns");
OMElement searchResult = factory.createOMElement("getColumnHeaders", ns);
StringBuilder csvBuilder = new StringBuilder();
for(int iterateCount=0; iterateCount < resultSize; iterateCount++)
{
csvBuilder.append(resultData.get(iterateCount));
csvBuilder.append(",");
}
//String cellNotation = "R"+resultData.get(iterateCount).getCell().getRow()+"C"+resultData.get(iterateCount).getCell().getCol();
OMElement cellId = factory.createOMElement("text", ns);
searchResult.addChild(cellId);
cellId.setText(csvBuilder.toString());
messageContext.getEnvelope().getBody().addChild(searchResult);
} catch (IOException te) {
log.error("Failed to show status: " + te.getMessage(), te);
GoogleSpreadsheetUtils.storeErrorResponseStatus(
messageContext, te);
} catch (ServiceException te) {
log.error("Failed to show status: " + te.getMessage(), te);
GoogleSpreadsheetUtils.storeErrorResponseStatus(
messageContext, te);
} catch (Exception te) {
log.error("Failed to show status: " + te.getMessage(), te);
GoogleSpreadsheetUtils.storeErrorResponseStatus(
messageContext, te);
}
}
}
| [
"[email protected]@a5903396-d722-0410-b921-86c7d4935375"
] | [email protected]@a5903396-d722-0410-b921-86c7d4935375 |
eef0f5b21a1dda611397f123dc27d4cb6f389f42 | e875c123a32e80f06a561ef003f8b23729116af5 | /spring-data-jpa/src/main/java/com/sda/spring/data/jpa/repository/PersonJpaRepository.java | 20e1e08fcc6dac6cccd0d2ed9f277f89371e70ed | [] | no_license | aleneagu96/spring | 191be91e29ecf604ada4ab171fa319f0a4693788 | 38e21cb5ba32410ec65e39a465a4ff990f961695 | refs/heads/master | 2022-12-11T16:59:40.113939 | 2020-09-17T18:24:38 | 2020-09-17T18:24:38 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 230 | java | package com.sda.spring.data.jpa.repository;
import com.sda.spring.data.jpa.model.Person;
import org.springframework.data.jpa.repository.JpaRepository;
public interface PersonJpaRepository extends JpaRepository<Person, Long> {
}
| [
"[email protected]"
] | |
ae3b05430d3992188e35d8ec9ede97f474e4e24c | 6f15cc234d8d8fa92fe9f5b7661096f1f09aaffe | /android/app/src/debug/java/com/newstoday/ReactNativeFlipper.java | 5a63835905ff10dfabe09ffb734b49a2e094578c | [] | no_license | Ulkeshwani/News-Today | cab3d13984d691f41ca373e2080c811c39ef1321 | fe997d2760637c86a1dd039eb29fe24a09a4f80f | refs/heads/master | 2023-07-27T18:07:57.958880 | 2021-09-13T08:31:13 | 2021-09-13T08:31:13 | 337,637,433 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,264 | java | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
* directory of this source tree.
*/
package com.newstoday;
import android.content.Context;
import com.facebook.flipper.android.AndroidFlipperClient;
import com.facebook.flipper.android.utils.FlipperUtils;
import com.facebook.flipper.core.FlipperClient;
import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
import com.facebook.flipper.plugins.inspector.DescriptorMapping;
import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
import com.facebook.react.ReactInstanceManager;
import com.facebook.react.bridge.ReactContext;
import com.facebook.react.modules.network.NetworkingModule;
import okhttp3.OkHttpClient;
public class ReactNativeFlipper {
public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
if (FlipperUtils.shouldEnableFlipper(context)) {
final FlipperClient client = AndroidFlipperClient.getInstance(context);
client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
client.addPlugin(new ReactFlipperPlugin());
client.addPlugin(new DatabasesFlipperPlugin(context));
client.addPlugin(new SharedPreferencesFlipperPlugin(context));
client.addPlugin(CrashReporterPlugin.getInstance());
NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
NetworkingModule.setCustomClientBuilder(
new NetworkingModule.CustomClientBuilder() {
@Override
public void apply(OkHttpClient.Builder builder) {
builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
}
});
client.addPlugin(networkFlipperPlugin);
client.start();
// Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
// Hence we run if after all native modules have been initialized
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext == null) {
reactInstanceManager.addReactInstanceEventListener(
new ReactInstanceManager.ReactInstanceEventListener() {
@Override
public void onReactContextInitialized(ReactContext reactContext) {
reactInstanceManager.removeReactInstanceEventListener(this);
reactContext.runOnNativeModulesQueueThread(
new Runnable() {
@Override
public void run() {
client.addPlugin(new FrescoFlipperPlugin());
}
});
}
});
} else {
client.addPlugin(new FrescoFlipperPlugin());
}
}
}
}
| [
"[email protected]"
] | |
bc44af2094c925bae32bc95b998403dd8a187335 | a8da4b6fbddff4d23bde520fb5cbea356da5d246 | /Test.java | 187ec0049639e0114eeaf81678fd3b7484e959ff | [] | no_license | dannymtcoder/Algorithms | 9394c7e0d71ead0d73b33f7daaae2712325a05eb | 4c2d33aa5a1526a5e9c9063a06007eb2d84c5afe | refs/heads/master | 2020-07-06T06:58:51.215077 | 2019-08-18T22:01:07 | 2019-08-18T22:01:07 | 202,932,319 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 433 | java | public class Test {
public static void main(String [] args) {
RBT rbt = new RBT();
rbt.add(25);
rbt.add(14);
rbt.add(51);
rbt.add(45);
rbt.add(55);
rbt.add(40);
rbt.add(32);
rbt.add(60);
rbt.add(57);
rbt.add(12);
rbt.add(13);
System.out.println(rbt.root.right.right);
rbt.print2D(rbt.root);
}
} | [
"[email protected]"
] | |
d4cb42f26f035a15096f18b046f5e90f73920e33 | f7eba9d0447c51fdd44b3c1964261c71ec4628ff | /src/main/java/db/infra/DenormalizedEntity.java | 0e68586fd67c30f3ddbd1b037352b79c461fddb1 | [] | no_license | eitan101/QueryServerMaven | 891e636eebf136afeddfe591ac422336f1b6dcce | b80532d9cf594132061c877a306f266c3987362e | refs/heads/master | 2016-09-06T03:36:43.664307 | 2014-08-04T20:21:34 | 2014-08-04T20:21:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,452 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package db.infra;
import com.google.common.collect.ImmutableMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
public class DenormalizedEntity<V> {
V parentEntity;
ImmutableMap<String,Object> subEntities;
public DenormalizedEntity(V entity, ImmutableMap<String,Object> subEntities) {
this.parentEntity = entity;
this.subEntities = subEntities;
}
public V getParent() {
return parentEntity;
}
public Map<String, Object> getSubEntities() {
return subEntities;
}
public <T> Optional<T> getSubEntity(Class<? extends T> c,String name) {
return Optional.ofNullable((T) subEntities.get(name));
}
public DenormalizedEntity<V> replace(String subEntityName, Object subEntity) {
HashMap<String, Object> map = new HashMap<>(subEntities);
if (subEntity==null)
map.remove(subEntityName);
else
map.put(subEntityName, subEntity);
return new DenormalizedEntity<>(parentEntity,ImmutableMap.copyOf(map));
}
@Override
public String toString() {
return "DenormalizedEntity{" + "parentEntity=" + parentEntity + ", subEntities=" + subEntities + '}';
}
}
| [
"[email protected]"
] | |
991a8444bb42e7caf0614ac1e849f6fd3b1a36cd | 6e57bdc0a6cd18f9f546559875256c4570256c45 | /packages/apps/TvSettings/Settings/src/com/android/tv/settings/connectivity/setup/UserChoiceInfo.java | 3a04cc2112fda3068534805fd2faa1f4f9aaf2f5 | [
"Apache-2.0"
] | permissive | dongdong331/test | 969d6e945f7f21a5819cd1d5f536d12c552e825c | 2ba7bcea4f9d9715cbb1c4e69271f7b185a0786e | refs/heads/master | 2023-03-07T06:56:55.210503 | 2020-12-07T04:15:33 | 2020-12-07T04:15:33 | 134,398,935 | 2 | 1 | null | 2022-11-21T07:53:41 | 2018-05-22T10:26:42 | null | UTF-8 | Java | false | false | 5,209 | java | /*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.tv.settings.connectivity.setup;
import android.arch.lifecycle.ViewModel;
import android.net.wifi.ScanResult;
import android.net.wifi.WifiConfiguration;
import android.support.annotation.IntDef;
import android.text.TextUtils;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.HashMap;
/**
* Class that stores the user choice information for basic Wi-Fi flow.
*/
public class UserChoiceInfo extends ViewModel {
public static final int SELECT_WIFI = 1;
public static final int PASSWORD = 2;
public static final int SECURITY = 3;
public static final int SSID = 4;
@IntDef({
SELECT_WIFI,
PASSWORD,
SECURITY,
SSID
})
@Retention(RetentionPolicy.SOURCE)
public @interface PAGE {
}
private HashMap<Integer, CharSequence> mDataSummary = new HashMap<>();
private WifiConfiguration mWifiConfiguration = new WifiConfiguration();
private int mWifiSecurity;
private ScanResult mChosenNetwork;
private String mConnectedNetwork;
private boolean mIsPasswordHidden = false;
/**
* Store the page summary into a HashMap.
*
* @param page The page as the key.
* @param info The info as the value.
*/
public void put(@PAGE int page, String info) {
mDataSummary.put(page, info);
}
/**
* Check if the summary of the queried page matches with expected string.
*
* @param choice The expected string.
* @param page The page queried.
* @return true if matched.
*/
public boolean choiceChosen(CharSequence choice, @PAGE int page) {
if (!mDataSummary.containsKey(page)) {
return false;
}
return TextUtils.equals(choice, mDataSummary.get(page));
}
/**
* Get summary of a page.
*
* @param page The queried page.
* @return The summary of the page.
*/
public CharSequence getPageSummary(@PAGE int page) {
if (!mDataSummary.containsKey(page)) {
return null;
}
return mDataSummary.get(page);
}
/**
* Remove the summary of a page.
*
* @param page The page.
*/
public void removePageSummary(@PAGE int page) {
mDataSummary.remove(page);
}
/**
* Get {@link ScanResult} of the chosen network.
*/
public ScanResult getChosenNetwork() {
return mChosenNetwork;
}
/**
* Set {@link ScanResult} of the chosen network.
*/
public void setChosenNetwork(ScanResult result) {
mChosenNetwork = result;
}
/**
* Get {@link WifiConfiguration}
*/
public WifiConfiguration getWifiConfiguration() {
return mWifiConfiguration;
}
/**
* Set {@link WifiConfiguration}
*/
public void setWifiConfiguration(WifiConfiguration wifiConfiguration) {
this.mWifiConfiguration = wifiConfiguration;
}
/**
* Get WifiSecurity category. The category value is defined in
* {@link com.android.settingslib.wifi.AccessPoint}
*/
public int getWifiSecurity() {
return mWifiSecurity;
}
/**
* Set WifiSecurity
*
* @param wifiSecurity WifiSecurity category defined in
* {@link com.android.settingslib.wifi.AccessPoint}.
*/
public void setWifiSecurity(int wifiSecurity) {
this.mWifiSecurity = wifiSecurity;
}
/**
* Get the SSID of the connected network.
*
* @return the SSID.
*/
public String getConnectedNetwork() {
return mConnectedNetwork;
}
/**
* Set the SSID of the connected network.
*
* @param connectedNetwork SSID of the network.
*/
public void setConnectedNetwork(String connectedNetwork) {
mConnectedNetwork = connectedNetwork;
}
/**
* Determine whether the password is hidden.
*
* @return True if hidden.
*/
public boolean isPasswordHidden() {
return this.mIsPasswordHidden;
}
/**
* Set whether the password is hidden.
*
* @param hidden true if hidden.
*/
public void setPasswordHidden(boolean hidden) {
this.mIsPasswordHidden = hidden;
}
/**
* Initialize all the information.
*/
public void init() {
mDataSummary = new HashMap<>();
mWifiConfiguration = new WifiConfiguration();
mWifiSecurity = 0;
mChosenNetwork = null;
mChosenNetwork = null;
mIsPasswordHidden = false;
}
}
| [
"[email protected]"
] | |
261974a27430abb7a0995cee4cf0cfacf7a265fd | d711038e1cbd7ee4f5556f49dbe4172b7aaaf4b9 | /2.JavaCore/src/com/javarush/task/task14/task1418/Solution.java | 361659b4ef12857b1d3b9e4342a81c2ddaf2e1a6 | [] | no_license | IgorKlyukin/JavaRushTasks | 8707b19bb397fbdbfbb381055611ea6483741884 | 1b4c7e590010bbf6c9897d87af42661780bba7c4 | refs/heads/master | 2020-04-07T02:15:30.753231 | 2019-05-21T12:28:41 | 2019-05-21T12:28:41 | 157,969,702 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,356 | java | package com.javarush.task.task14.task1418;
import java.util.LinkedList;
import java.util.List;
/*
Исправь четыре ошибки
*/
public class Solution {
public static void main(String[] args) {
List<Number> list = new LinkedList<Number>();
//3
initList(list);
list.remove(new Double("123e-445632"));
//4 - Исправь 2 ошибки
printListValues(list);
//5
processCastedObjects(list);
}
public static void initList(List<Number> list) {
list.add(new Double(1000f));
list.add(new Double("123e-445632"));
list.add(new Float(-90 / -3));
}
public static void printListValues(List<Number> list) {
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
public static void processCastedObjects(List<Number> list) {
for (Number object : list) {
//Исправь 2 ошибки
if (object instanceof Float) {
Float a = (float) object;
System.out.println("Is float value defined? " + !(a.isNaN()));
} else if (object instanceof Double) {
Double a = (double) object;
System.out.println("Is double value infinite? " + a.isInfinite());
}
}
}
}
| [
"[email protected]"
] | |
b99d70af7e1e05e1c4950d3577e78ef0fbaa023e | 451709e6462c9d0a1f648c8f780298dd52e3bfb4 | /java/JAVAAPIProject/src/org/lxh/regextdemo/RegexDemo01.java | 408aaa7e3fe88cc5e9fd3ad116cb9179386ab071 | [] | no_license | forsunchao/forsunchao | acec1606e9550f66e2eac36c6f0ee7b8a4589778 | 75ff7c7be27b8babbc03b2d3e500b9bcf2cf3753 | refs/heads/master | 2021-01-02T22:43:51.809188 | 2013-05-28T12:36:31 | 2013-05-28T12:36:31 | 34,045,525 | 2 | 1 | null | null | null | null | GB18030 | Java | false | false | 524 | java | package org.lxh.regextdemo;
public class RegexDemo01 {
public static void main(String[] args) {
String str = "121s34123414123";
char c[] = str.toCharArray(); // 将字符串变为字符数组
boolean flag = true;
for (int i = 0; i < c.length; i++) {
if (!(c[i] >= '0' && c[i] <= '9')) {// 不是数字
flag = false;
break ;
}
}
if(flag){
System.out.println("字符串是由数字组成!");
}else{
System.out.println("字符串不是由数字组成!") ;
}
}
}
| [
"forsunchao@f3c5aaa3-ccec-8fd9-5322-fc38b0fccad4"
] | forsunchao@f3c5aaa3-ccec-8fd9-5322-fc38b0fccad4 |
4b0f399a5695d0bdab4cfc033bcd472246f775bb | 7e541f3ddb96c6c59385f0e9d148e95441c70655 | /tests/serenity/src/main/java/bla/tm/pages/pantheon/AddNewAppPage.java | dff1f65bea91db89916d8e7f7827d02fae006518 | [
"MIT"
] | permissive | csvra01/ticketmaster-api.github.io | 14c4c3e5cede8e4186aeb9bd0c473c88d1054e95 | 01e8d61affa6caf5be87436c6a30db0e8eaecd3c | refs/heads/dev | 2021-01-09T06:29:57.985848 | 2018-03-22T08:26:57 | 2018-03-22T08:26:57 | 65,800,210 | 0 | 0 | MIT | 2018-08-21T10:08:13 | 2016-08-16T08:03:47 | JavaScript | UTF-8 | Java | false | false | 404 | java | package bla.tm.pages.pantheon;
import bla.tm.pages.AncestorPage;
import net.serenitybdd.core.annotations.findby.FindBy;
import net.serenitybdd.core.pages.WebElementFacade;
public class AddNewAppPage extends AncestorPage {
@FindBy(xpath = "//input[@name='human']")
private WebElementFacade nameTextInput;
public WebElementFacade getNameTextInput() {
return nameTextInput;
}
}
| [
"[email protected]"
] | |
0aa0953cc535433a4cee0cca877301aad6884cea | e81640f6eb46d7728044b2ec2ae8adb6a5c98090 | /micro-controller/src/test/java/com/jeff/controller/MicroControllerApplicationTests.java | 7bffe761480eda2b126e5d1ad0f9560e84e87d4b | [] | no_license | zyc133/micro | 24991907b4e46d9927aefd2b03cc2857b4d9319e | f5ca755a0d8a7e0f6cb6bf30605d847594c9a391 | refs/heads/master | 2020-04-10T04:16:01.125501 | 2018-11-12T03:21:22 | 2018-11-12T03:21:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 354 | java | package com.jeff.controller;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest
public class MicroControllerApplicationTests {
@Test
public void contextLoads() {
}
}
| [
"[email protected]"
] | |
bd9a3579d699c9b0b471a959e0ec279e221e3aad | 9a2971d07bc10c14e2248cb336ab1514b0291825 | /CarouselSample/CarouselSample.Android/obj/Release/90/android/src/crc64c4b278dd181275a3/SfCarouselItem.java | 8c151425f4b7663a18500fbd508a30a7d163caf8 | [] | no_license | dikshitha22/CarouselSample | 0854d2740628c5501982479f0bc001d7c9e26299 | 8c39debd253948e28ac89f80e509e0f98e556abc | refs/heads/master | 2022-11-06T17:55:43.721338 | 2020-06-23T05:20:16 | 2020-06-23T05:20:16 | 274,311,698 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,547 | java | package crc64c4b278dd181275a3;
public class SfCarouselItem
extends android.widget.FrameLayout
implements
mono.android.IGCUserPeer
{
/** @hide */
public static final String __md_methods;
static {
__md_methods =
"n_onSizeChanged:(IIII)V:GetOnSizeChanged_IIIIHandler\n" +
"";
mono.android.Runtime.register ("Com.Syncfusion.Carousel.SfCarouselItem, Syncfusion.SfCarousel.Android", SfCarouselItem.class, __md_methods);
}
public SfCarouselItem (android.content.Context p0)
{
super (p0);
if (getClass () == SfCarouselItem.class)
mono.android.TypeManager.Activate ("Com.Syncfusion.Carousel.SfCarouselItem, Syncfusion.SfCarousel.Android", "Android.Content.Context, Mono.Android", this, new java.lang.Object[] { p0 });
}
public SfCarouselItem (android.content.Context p0, android.util.AttributeSet p1)
{
super (p0, p1);
if (getClass () == SfCarouselItem.class)
mono.android.TypeManager.Activate ("Com.Syncfusion.Carousel.SfCarouselItem, Syncfusion.SfCarousel.Android", "Android.Content.Context, Mono.Android:Android.Util.IAttributeSet, Mono.Android", this, new java.lang.Object[] { p0, p1 });
}
public SfCarouselItem (android.content.Context p0, android.util.AttributeSet p1, int p2)
{
super (p0, p1, p2);
if (getClass () == SfCarouselItem.class)
mono.android.TypeManager.Activate ("Com.Syncfusion.Carousel.SfCarouselItem, Syncfusion.SfCarousel.Android", "Android.Content.Context, Mono.Android:Android.Util.IAttributeSet, Mono.Android:System.Int32, mscorlib", this, new java.lang.Object[] { p0, p1, p2 });
}
public SfCarouselItem (android.content.Context p0, android.util.AttributeSet p1, int p2, int p3)
{
super (p0, p1, p2, p3);
if (getClass () == SfCarouselItem.class)
mono.android.TypeManager.Activate ("Com.Syncfusion.Carousel.SfCarouselItem, Syncfusion.SfCarousel.Android", "Android.Content.Context, Mono.Android:Android.Util.IAttributeSet, Mono.Android:System.Int32, mscorlib:System.Int32, mscorlib", this, new java.lang.Object[] { p0, p1, p2, p3 });
}
public void onSizeChanged (int p0, int p1, int p2, int p3)
{
n_onSizeChanged (p0, p1, p2, p3);
}
private native void n_onSizeChanged (int p0, int p1, int p2, int p3);
private java.util.ArrayList refList;
public void monodroidAddReference (java.lang.Object obj)
{
if (refList == null)
refList = new java.util.ArrayList ();
refList.add (obj);
}
public void monodroidClearReferences ()
{
if (refList != null)
refList.clear ();
}
}
| [
"[email protected]"
] | |
adfe22b9d77c380167150692b69ee2a74bc59e5a | a2dec6af8a989b7ff55a7546e007b3bec9c6372e | /backend/src/main/java/com/rest/resfulwebservice/ResfulWebServiceApplication.java | cedc2979036781a3f4069fa372c7c4dd46ee9166 | [] | no_license | zemser/Todo-Applcation | 8084d2b49ad972739134a08c20b3089e65ff7ea0 | b778412a5a7b093b0e7680b3fbb44399b19b09b2 | refs/heads/main | 2023-02-05T02:00:41.775434 | 2020-12-27T08:43:02 | 2020-12-27T08:43:02 | 320,850,066 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 338 | java | package com.rest.resfulwebservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ResfulWebServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ResfulWebServiceApplication.class, args);
}
}
| [
"[email protected]"
] | |
f439f92e58109a6af0ab374a03766ef7d0255d3c | 895b61c97f49bd80825ce70018273c714d5b6779 | /src/test/java/me/aikin/mockbean/AboutControllerTest.java | 646dee65a7a327707f252a0891b3da34632786d9 | [
"MIT"
] | permissive | aikin/mockbean-annotation | b54cf289f7f663c67d180323f0ebcc07473a29eb | b6e3fba6db868b19653ef91bf3991426c64e49e1 | refs/heads/master | 2020-03-07T05:47:57.461390 | 2018-05-06T08:10:25 | 2018-05-06T08:10:25 | 127,305,846 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 339 | java | package me.aikin.mockbean;
import org.junit.jupiter.api.Test;
import static org.hamcrest.Matchers.equalTo;
class AboutControllerTest extends ApiBaseTest {
@Test
void should_can_get_about() {
given().
when().
get("/api/about").
then().
body(equalTo("just try"));
}
}
| [
"[email protected]"
] | |
3b66e6e6d7dc4814677924eb9839cdb44e6b18eb | 970ab6b338841d9b2ba16d143a3c0b2621eb16b8 | /src/main/java/com/zzheads/recipesite/model/Role.java | 8352e620563b4c2459bfb19d3ad6522f483932a2 | [] | no_license | zzheads/RecipeSite | 7863dbd57551d9e6483b897365e405ff4b43ae0d | aba82be0fc30805a1991f95247eb116d2b15464e | refs/heads/master | 2020-04-18T04:19:12.590551 | 2016-09-15T14:00:39 | 2016-09-15T14:00:39 | 66,502,446 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,058 | java | package com.zzheads.recipesite.model;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
public class Role {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
public Role(Long id, String name) {
this.id = id;
this.name = name;
}
public Role() { }
public Role(String name) {
this.name = name;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Role)) return false;
Role role = (Role) o;
return getName().equals(role.getName());
}
@Override
public int hashCode() {
return getName().hashCode();
}
}
| [
"[email protected]"
] | |
1b717c92c8b649004a66d19382841d04756888b7 | e3162d976b3a665717b9a75c503281e501ec1b1a | /src/main/java/com/alipay/api/domain/AccessProduceOrder.java | ac5d76053101e41e8a243c3a03f790dc64c9680e | [
"Apache-2.0"
] | permissive | sunandy3/alipay-sdk-java-all | 16b14f3729864d74846585796a28d858c40decf8 | 30e6af80cffc0d2392133457925dc5e9ee44cbac | refs/heads/master | 2020-07-30T14:07:34.040692 | 2019-09-20T09:35:20 | 2019-09-20T09:35:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,637 | java | package com.alipay.api.domain;
import com.alipay.api.AlipayObject;
import com.alipay.api.internal.mapping.ApiField;
/**
* 生产单对象实体
*
* @author auto create
* @since 1.0, 2017-07-27 19:58:29
*/
public class AccessProduceOrder extends AlipayObject {
private static final long serialVersionUID = 7717664473779259977L;
/**
* 口碑码批次号
*/
@ApiField("batch_id")
private String batchId;
/**
* 生产单标识
*/
@ApiField("produce_order_id")
private String produceOrderId;
/**
* 生产数量
*/
@ApiField("produce_quantity")
private Long produceQuantity;
/**
* 物料属性名称
*/
@ApiField("stuff_attr_name")
private String stuffAttrName;
/**
* 物料材质
*/
@ApiField("stuff_material")
private String stuffMaterial;
/**
* 物料尺寸
*/
@ApiField("stuff_size")
private String stuffSize;
/**
* 物料类型
*/
@ApiField("stuff_type")
private String stuffType;
/**
* 模板唯一标识
*/
@ApiField("template_id")
private String templateId;
/**
* 模板名称
*/
@ApiField("template_name")
private String templateName;
public String getBatchId() {
return this.batchId;
}
public void setBatchId(String batchId) {
this.batchId = batchId;
}
public String getProduceOrderId() {
return this.produceOrderId;
}
public void setProduceOrderId(String produceOrderId) {
this.produceOrderId = produceOrderId;
}
public Long getProduceQuantity() {
return this.produceQuantity;
}
public void setProduceQuantity(Long produceQuantity) {
this.produceQuantity = produceQuantity;
}
public String getStuffAttrName() {
return this.stuffAttrName;
}
public void setStuffAttrName(String stuffAttrName) {
this.stuffAttrName = stuffAttrName;
}
public String getStuffMaterial() {
return this.stuffMaterial;
}
public void setStuffMaterial(String stuffMaterial) {
this.stuffMaterial = stuffMaterial;
}
public String getStuffSize() {
return this.stuffSize;
}
public void setStuffSize(String stuffSize) {
this.stuffSize = stuffSize;
}
public String getStuffType() {
return this.stuffType;
}
public void setStuffType(String stuffType) {
this.stuffType = stuffType;
}
public String getTemplateId() {
return this.templateId;
}
public void setTemplateId(String templateId) {
this.templateId = templateId;
}
public String getTemplateName() {
return this.templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
}
| [
"[email protected]"
] | |
82f40ef70251afc60a24723e773053ffaafeb920 | 39cd7d703e200020f675bbc2e6f87a7a9df2e198 | /src/WellKnown/Matematicas/PrimalityTest.java | 339a7b621a33d96db79a00d1cff6a08551fc2665 | [] | no_license | afpinedac/Programming-Contests | 66433c1fae0d6d41983334d1fef08da011a4fd3d | fb3b0a72461ca35638caa66fff32d213aee732c0 | refs/heads/master | 2021-08-07T06:25:36.727803 | 2021-06-11T23:12:51 | 2021-06-11T23:12:51 | 10,565,147 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 640 | java | package WellKnown.Matematicas;
public class PrimalityTest {
public static boolean isPrime(int n) {
if (n <= 1) {
return false;
} else if (n == 2) {
return true;
}
if (n % 2 == 0) {
return false;
}
for (int i = 3; i * i <= n; i=i+2) {
if (n % i == 0) {
return false;
}
}
return true;
}
public static void main(String[] args) {
int a[] = {1,2,3,4,5,6,7,8,9,19,24,27,23};
for (int x : a) {
System.out.println(x + "=" + isPrime(x));
}
}
}
| [
"[email protected]"
] | |
e5789a8719d0449938fb353f325aeb39870ad870 | 0869c778762348ce2339d7b1a6b7d65d69fa3002 | /tools/patterns/Java_Design_Patterns_Book/chapter18/EngineManagementSystem.java | 289bf0e65863344d86c785981722f0c7da0011cf | [] | no_license | ripley57/CW_Tools | 08252944b05dffa298fd96a483abf6544a5feb25 | 3341d50ae1b936993955649acd94ed4c789acfb2 | refs/heads/master | 2023-01-03T22:45:54.031549 | 2020-02-26T20:57:37 | 2020-02-26T20:57:37 | 144,877,688 | 0 | 1 | null | 2022-12-16T05:46:08 | 2018-08-15T16:34:45 | C | UTF-8 | Java | false | false | 3,333 | java | /*
* Java Design Pattern Essentials - Second Edition, by Tony Bevis
* Copyright 2012, Ability First Limited
*
* This source code is provided to accompany the book and is provided AS-IS without warranty of any kind.
* It is intended for educational and illustrative purposes only, and may not be re-published
* without the express written permission of the publisher.
*/
package chapter18;
public class EngineManagementSystem {
private Ignition ignition;
private Gearbox gearbox;
private Accelerator accelerator;
private Brake brake;
private int currentSpeed;
public EngineManagementSystem() {
currentSpeed = 0;
}
// Methods that enable registration with this mediator...
public void registerIgnition(Ignition ignition) {
this.ignition = ignition;
}
public void registerGearbox(Gearbox gearbox) {
this.gearbox = gearbox;
}
public void registerAccelerator(Accelerator accelerator) {
this.accelerator = accelerator;
}
public void registerBrake(Brake brake) {
this.brake = brake;
}
// Methods that handle object interactions...
public void ignitionTurnedOn() {
gearbox.enable();
accelerator.enable();
brake.enable();
}
public void ignitionTurnedOff() {
gearbox.disable();
accelerator.disable();
brake.disable();
}
public void gearboxEnabled() {
System.out.println("EMS now controlling the gearbox");
}
public void gearboxDisabled() {
System.out.println("EMS no longer controlling the gearbox");
}
public void gearChanged() {
System.out.println("EMS disengaging revs while gear changing");
}
public void acceleratorEnabled() {
System.out.println("EMS now controlling the accelerator");
}
public void acceleratorDisabled() {
System.out.println("EMS no longer controlling the accelerator");
}
public void acceleratorPressed() {
brake.disable();
while (currentSpeed < accelerator.getSpeed()) {
currentSpeed++;
System.out.println("Speed currentlt " + currentSpeed);
// Set gear according to speed
if (currentSpeed <= 10) {
gearbox.setGear(Gearbox.Gear.FIRST);
} else if (currentSpeed <= 20) {
gearbox.setGear(Gearbox.Gear.SECOND);
} else if (currentSpeed <= 30) {
gearbox.setGear(Gearbox.Gear.THIRD);
} else if (currentSpeed <= 50) {
gearbox.setGear(Gearbox.Gear.FOURTH);
} else {
gearbox.setGear(Gearbox.Gear.FIFTH);
}
}
brake.enable();
}
public void brakeEnabled() {
System.out.println("EMS now controlling the brake");
}
public void brakeDisabled() {
System.out.println("EMS no longer controlling the brake");
}
public void brakePressed() {
accelerator.disable();
currentSpeed = 0;
}
public void brakeReleased() {
gearbox.setGear(Gearbox.Gear.FIRST);
accelerator.enable();
}
}
| [
"[email protected]"
] | |
0b4ffdc303dbadfa99c41052a101ed3badc4551f | 5509c6ba097b0579b0eab1f7cbecb67f21772c22 | /src/main/java/example/jbot/commands/GameHelp.java | 30c454ed8c34d2b261adadc3f8a5a1b9370cf6ef | [] | no_license | harirongali/myprojecttodo | d5e82484fda472e70407c7e4f4befcc8d9c5055c | a45d116f9affc8826757ff85ca5d09dda9ed9373 | refs/heads/master | 2021-01-21T20:47:03.464313 | 2017-06-21T23:48:14 | 2017-06-21T23:48:14 | 94,678,430 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 866 | java | package example.jbot.commands;
import example.jbot.core.GameCache;
import me.ramswaroop.jbot.core.slack.models.RichMessage;
import org.springframework.stereotype.Component;
/**
* Created by xxxxx on 6/17/17.
*/
@Component
public class GameHelp extends BaseCommand {
/**
*
* @param channelId
* @param gameCache
* @return
*/
public RichMessage handleCommand(String channelId, GameCache gameCache) {
String message = "`/ttt challenge [@username]` play tictactoe !" +
"\n`/ttt accept [@username]` a challenged game" +
"\n`/ttt place [cell name]` place move on empty space " +
gameCache.getMoves(channelId) + " of the board" +
"\n`/ttt quit` quits the current game in the channel" +
"\n`/ttt help`";
return buildMessage(message);
}
}
| [
"[email protected]"
] | |
4fa371ee91b18a87c1c186bf8a897219424b1c50 | 592d6313671b7ce42962eaa8219601a808b6fc7e | /library/src/main/java/com/haohahu/banner/ImageBannerView.java | 081b6b4c33be212baee101ff862dba14c4bf8429 | [
"Apache-2.0"
] | permissive | ronghao/banner | ede82375e59776ea5974e12ebf87778714df5643 | 26701fee6920baca419b3d9b297f0fe1f0141dfb | refs/heads/master | 2021-07-05T17:27:40.094638 | 2017-09-27T03:05:14 | 2017-09-27T03:05:14 | 104,694,255 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 470 | java | package com.haohahu.banner;
import android.view.View;
import android.widget.ImageView;
/**
* @author haohao([email protected]) on 2017/9/25 下午 05:10
* @version v1.0
*/
public class ImageBannerView implements IBannerView<String> {
private ImageView imageView;
@Override
public View getView() {
return imageView;
}
@Override
public void initView(int position, int sum, String s, IBannerViewClickListener listener) {
}
}
| [
"[email protected]"
] | |
9e55ceb2a3d90958c2006448e8f1100cffe158ec | 128eb90ce7b21a7ce621524dfad2402e5e32a1e8 | /laravel-converted/src/main/java/com/project/convertedCode/globalNamespace/namespaces/Illuminate/namespaces/Translation/classes/ArrayLoader.java | 5278f1f806ccab44833e37dfa2283177f5ea412e | [
"MIT",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | RuntimeConverter/RuntimeConverterLaravelJava | 657b4c73085b4e34fe4404a53277e056cf9094ba | 7ae848744fbcd993122347ffac853925ea4ea3b9 | refs/heads/master | 2020-04-12T17:22:30.345589 | 2018-12-22T10:32:34 | 2018-12-22T10:32:34 | 162,642,356 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,652 | java | package com.project.convertedCode.globalNamespace.namespaces.Illuminate.namespaces.Translation.classes;
import com.runtimeconverter.runtime.passByReference.PassByReferenceArgs;
import com.runtimeconverter.runtime.classes.StaticBaseClass;
import com.runtimeconverter.runtime.classes.RuntimeClassBase;
import com.project.convertedCode.globalNamespace.namespaces.Illuminate.namespaces.Contracts.namespaces.Translation.classes.Loader;
import com.runtimeconverter.runtime.RuntimeEnv;
import com.runtimeconverter.runtime.references.ReferenceClassProperty;
import com.runtimeconverter.runtime.ZVal;
import com.runtimeconverter.runtime.reflection.ReflectionClassData;
import com.runtimeconverter.runtime.annotations.ConvertedParameter;
import com.runtimeconverter.runtime.arrays.ZPair;
import java.lang.invoke.MethodHandles;
import com.runtimeconverter.runtime.classes.NoConstructor;
import com.runtimeconverter.runtime.arrays.ArrayAction;
import com.runtimeconverter.runtime.annotations.ConvertedMethod;
import static com.runtimeconverter.runtime.ZVal.arrayActionR;
import static com.runtimeconverter.runtime.ZVal.assignParameter;
/*
Converted with The Runtime Converter (runtimeconverter.com)
vendor/laravel/framework/src/Illuminate/Translation/ArrayLoader.php
*/
public class ArrayLoader extends RuntimeClassBase implements Loader {
public Object messages = ZVal.newArray();
public ArrayLoader(RuntimeEnv env, Object... args) {
super(env);
}
public ArrayLoader(NoConstructor n) {
super(n);
}
@ConvertedMethod
@ConvertedParameter(index = 0, name = "locale")
@ConvertedParameter(index = 1, name = "group")
@ConvertedParameter(
index = 2,
name = "namespace",
defaultValue = "NULL",
defaultValueType = "constant"
)
public Object load(RuntimeEnv env, Object... args) {
Object locale = assignParameter(args, 0, false);
Object group = assignParameter(args, 1, false);
Object namespace = assignParameter(args, 2, true);
if (null == namespace) {
namespace = ZVal.getNull();
}
Object ternaryExpressionTemp = null;
namespace =
ZVal.assign(
ZVal.isTrue(ternaryExpressionTemp = namespace)
? ternaryExpressionTemp
: "*");
if (arrayActionR(
ArrayAction.ISSET,
new ReferenceClassProperty(this, "messages", env),
env,
namespace,
locale,
group)) {
return ZVal.assign(
new ReferenceClassProperty(this, "messages", env)
.arrayGet(env, namespace, locale, group));
}
return ZVal.assign(ZVal.newArray());
}
@ConvertedMethod
@ConvertedParameter(index = 0, name = "namespace")
@ConvertedParameter(index = 1, name = "hint")
public Object addNamespace(RuntimeEnv env, Object... args) {
Object namespace = assignParameter(args, 0, false);
Object hint = assignParameter(args, 1, false);
return null;
}
@ConvertedMethod
@ConvertedParameter(index = 0, name = "path")
public Object addJsonPath(RuntimeEnv env, Object... args) {
Object path = assignParameter(args, 0, false);
return null;
}
@ConvertedMethod
@ConvertedParameter(index = 0, name = "locale")
@ConvertedParameter(index = 1, name = "group")
@ConvertedParameter(index = 2, name = "messages", typeHint = "array")
@ConvertedParameter(
index = 3,
name = "namespace",
defaultValue = "NULL",
defaultValueType = "constant"
)
public Object addMessages(RuntimeEnv env, Object... args) {
Object locale = assignParameter(args, 0, false);
Object group = assignParameter(args, 1, false);
Object messages = assignParameter(args, 2, false);
Object namespace = assignParameter(args, 3, true);
if (null == namespace) {
namespace = ZVal.getNull();
}
Object ternaryExpressionTemp = null;
namespace =
ZVal.assign(
ZVal.isTrue(ternaryExpressionTemp = namespace)
? ternaryExpressionTemp
: "*");
new ReferenceClassProperty(this, "messages", env)
.arrayAccess(env, namespace, locale, group)
.set(messages);
return ZVal.assign(this);
}
@ConvertedMethod
public Object namespaces(RuntimeEnv env, Object... args) {
return ZVal.assign(ZVal.newArray());
}
public static final Object CONST_class = "Illuminate\\Translation\\ArrayLoader";
// Runtime Converter Internals
// RuntimeStaticCompanion contains static methods
// RequestStaticProperties contains static (per-request) properties
// ReflectionClassData contains php reflection data used by the runtime library
public static class RuntimeStaticCompanion extends StaticBaseClass {
private static final MethodHandles.Lookup staticCompanionLookup = MethodHandles.lookup();
}
public static final RuntimeStaticCompanion runtimeStaticObject = new RuntimeStaticCompanion();
private static final ReflectionClassData runtimeConverterReflectionData =
ReflectionClassData.builder()
.setName("Illuminate\\Translation\\ArrayLoader")
.setLookup(
ArrayLoader.class,
MethodHandles.lookup(),
RuntimeStaticCompanion.staticCompanionLookup)
.setLocalProperties("messages")
.setFilename(
"vendor/laravel/framework/src/Illuminate/Translation/ArrayLoader.php")
.addInterface("Illuminate\\Contracts\\Translation\\Loader")
.get();
@Override
public ReflectionClassData getRuntimeConverterReflectionData() {
return runtimeConverterReflectionData;
}
@Override
public Object converterRuntimeCallExtended(
RuntimeEnv env,
String method,
Class<?> caller,
PassByReferenceArgs passByReferenceArgs,
Object... args) {
return RuntimeClassBase.converterRuntimeCallExtendedWithDataStatic(
this,
runtimeConverterReflectionData,
env,
method,
caller,
passByReferenceArgs,
args);
}
}
| [
"[email protected]"
] | |
ed4e16f19b90129b0b6c7b613265205f94d9f565 | 0ade87cbff61dbf518c21d8f4b6659a56c2fc59d | /src/com/test/level35/lesson06/home01/Solution.java | b88dee9d0b3902f8e9af6e18b4b98ac5f47405d2 | [] | no_license | KashkanVlad/JRHW | 1b47fb563e15c17aef0640c6fbb7b1466476ed0b | ced081ba7b59c685dc299cbfb416081acd81bbdf | refs/heads/master | 2021-07-12T04:51:44.629029 | 2017-10-15T23:22:27 | 2017-10-15T23:22:27 | 107,056,246 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,329 | java | package com.test.level35.lesson06.home01;
/* Несколько суперклассов для дженерика
Дан класс Solution, параметризированный T.
Ограничьте параметр T.
T должен быть наследником класса ClassForGenerics и одновременно реализовывать интерфейс InterfaceForGenerics.
Менять можно только класс Solution.
*/
public class Solution<T extends ClassForGenerics & InterfaceForGenerics> {
public static void main(String[] args) {
Solution<TestClassGood> testClassSolution = new Solution<>();
testClassSolution.check();
//!!! Следующие оба варианта не должны работать:
/*Solution<TestClassWrong1> wrong1Solution = new Solution<>();
wrong1Solution.check();
Solution<TestClassWrong2> wrong2Solution = new Solution<>();
wrong2Solution.check();*/
}
public void check() {
System.out.println("Works!");
}
public static class TestClassGood extends ClassForGenerics implements InterfaceForGenerics {
}
public static class TestClassWrong1 extends ClassForGenerics {
}
public static class TestClassWrong2 implements InterfaceForGenerics {
}
} | [
"[email protected]"
] | |
6ea1e38c75c761011779c7b8b977ba321607d0cc | ac42852b8be39b2eb3b6a88376c3ec024fd32049 | /src/game/db/dao/NpcDao.java | fb4988339ed8d5cc8af09cedbf183ec586738f13 | [
"BSD-3-Clause"
] | permissive | jjanuario/databaseeditor | 34940761753109a46f0c97b174a322b36afbc318 | 459c0fc459f6127b0c45e38cfcb30ed80a422f51 | refs/heads/master | 2020-06-12T22:31:26.157919 | 2020-01-23T17:13:25 | 2020-01-23T17:13:25 | 194,446,298 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,053 | java | package game.db.dao;
import game.db.entity.Npc;
import game.db.util.HibernateUtil;
import java.util.List;
import org.hibernate.Session;
import org.hibernate.Transaction;
/**
* =========================================== <br>
* PROJETO PARALLAX - Data Base Editor <br>
* Data de alteração do arquivo: 30/10/2012 <br>
* ===========================================
* <P>
*
* A classe <b>NpcDao</b> (Personagem nao Jogavel)
* Acessa os dados dos objetos no banco.
* <p>
*
* @see <a
* href="http://www.einformacao.com.br/parallax/component/content/article/35-conteudo-site/86-documentos-para-leitura">Documentos
* para Leitura</a>
* @author <a href="mailto:[email protected]">Jeferson Januario</a>
* @version 1.0.1
* @since Existe desde a versão 1.0.1 do projeto
*/
public class NpcDao {
Session session = HibernateUtil.getSessionFactory().openSession();
public void saveOrUpDate(Npc npc) {
Transaction tx = session.beginTransaction();
session.saveOrUpdate(npc);
tx.commit();
}
public void remove(Npc rnpc) {
Transaction tx = session.beginTransaction();
session.delete(rnpc);
tx.commit();
}
@SuppressWarnings("unchecked")
public List<Npc> lista() {
return session.createCriteria(Npc.class).list();
}
/**
*
* @return getImagemFaceId
* Retorna uma lista contendo todos os Ids da Classe imagem onde o tipo seja face (rosto).
*/
@SuppressWarnings("unchecked")
public List<Integer> getImagemFaceId() {
return session.createSQLQuery("select IMAGEM.ID from IMAGEM where TYPEIMAGE='face'").list();
}
/**
*
* @return getAnimationObjectMovimentId
* Retorna uma lista contendo todos os Ids da Classe getAnimationObject onde o tipo seja 'moviment' (movimento).
*/
@SuppressWarnings("unchecked")
public List<Integer> getAnimationObjectMovimentId() {
return session.createSQLQuery("select ANIMATIONOBJECT.ID from ANIMATIONOBJECT where TYPEIMAGE='moviment'").list();
}
}
| [
"[email protected]"
] | |
de5e9085d1a5d373ead485d73909c6348999cd31 | ff09074d461853694ea8173f89260c0156462530 | /ImageViewerMVP/src/view/ImageDisplay.java | 21da8fb54eea32a48693831977c8f0cc68841e6b | [] | no_license | AleksanderEZ/IS2 | b73d0cdcfc2bb26bd696e06c2887f8522277f715 | be6436e17b2502f0fa9c3d4e17a47e8c3d85839c | refs/heads/master | 2023-08-18T12:47:44.933982 | 2021-10-07T16:32:54 | 2021-10-07T16:32:54 | 414,505,680 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 216 | java | package view;
public interface ImageDisplay {
void display(String name);
String getCurrentImage();
void on(Shift shift);
interface Shift {
String left();
String right();
}
}
| [
"[email protected]"
] | |
5e9009d870b9651ab58cc6817c50149b626205b9 | e2c2b2cafdf036f67079e0d7868571568bbbe399 | /OSCJP/src/com/chris/oscjp/chapter8/A.java | 84649df8ff7e98aec2a1e3abff9f5676a3c1aae2 | [] | no_license | christopher-clark/OSCJ_Programming_Code | 60e23ea3d950232b5defe4539340ea33cefe6a53 | e9fe7d7bbfa9a4566eabcd553c9ad650d93c3064 | refs/heads/master | 2016-08-11T16:49:06.958111 | 2016-05-05T11:28:45 | 2016-05-05T11:28:45 | 48,510,276 | 0 | 0 | null | 2016-05-05T11:28:45 | 2015-12-23T20:44:16 | Java | UTF-8 | Java | false | false | 103 | java | package com.chris.oscjp.chapter8;
class A {
void m() {
System.out.println("outer");
}
}
| [
"[email protected]"
] | |
b867a153b0eb833256e7c9df74a0973c2a9e1704 | 958ff3e1cb3f6889707680e2db5fedc8662d6b4a | /src/com/rxoa/mypay/db/dao/SysUserOrgtreeTmpDao.java | 8c9dd29ba8e650193dd499d8afb9966342bc3b79 | [] | no_license | xuanyunze/dgl-server | 675d15c49b8cb275ca3a1d5b3704edb52c626221 | 1aac87905d9b41e1a03f9d06e388d4b6f2914a94 | refs/heads/master | 2020-04-17T17:29:18.156027 | 2016-08-19T01:42:01 | 2016-08-19T01:42:01 | 66,040,357 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 561 | java | package com.rxoa.mypay.db.dao;
import org.springframework.stereotype.Repository;
import com.rxoa.mypay.base.AbstractHibernateDao;
import com.rxoa.mypay.db.dao.in.ISysUserOrgtreeTmpDao;
import com.rxoa.mypay.db.po.SysUserOrgtreeTmp;
/**
* sys_user_orgtree_tmp DAO操作类
* Tue Apr 05 11:23:29 CST 2016 baiyu
*/
@Repository("sysUserOrgtreeTmpDao")
public class SysUserOrgtreeTmpDao extends AbstractHibernateDao<SysUserOrgtreeTmp> implements ISysUserOrgtreeTmpDao {
public SysUserOrgtreeTmpDao() {
super();
setClazz(SysUserOrgtreeTmp.class);
}
}
| [
"[email protected]"
] |
Subsets and Splits