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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
f19a42cf7dc2e68d6bf9822056704a649f5b9e58 | c4db2f8cea3fb135d059c05f458a2d0012248bc0 | /src/main/java/br/com/caelum/payfast/bean/CadastrarAplicacaoBean.java | 29f9f2ad433485ac1801d74daccb7f2a88b12d8e | [] | no_license | steppat/fj36-oauth-server | 575b50fcf1e033a952ee96f1e12e643bf0810a32 | 0f800d1eb13137950110ac54ef92b5b7095c2d52 | refs/heads/master | 2020-06-13T19:14:07.006940 | 2019-07-02T13:08:54 | 2019-07-02T13:08:54 | 194,762,908 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,267 | java | package br.com.caelum.payfast.bean;
import java.util.List;
import javax.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import br.com.caelum.payfast.dao.AplicacaoDao;
import br.com.caelum.payfast.modelo.Aplicacao;
@Controller
@RequestMapping("/aplicacao")
public class CadastrarAplicacaoBean {
@Autowired private AplicacaoDao aplicacaoDao;
public List<Aplicacao> getAplicacoes() {
return aplicacaoDao.getAplicacoes();
}
@RequestMapping(method=RequestMethod.GET)
public ModelAndView index() {
return createMV();
}
@RequestMapping(method=RequestMethod.POST)
public ModelAndView cadastrar(@Valid Aplicacao aplicacao, BindingResult result) {
if(!result.hasErrors()) {
aplicacaoDao.inserir(aplicacao);
}
return createMV();
}
private ModelAndView createMV() {
ModelAndView mv = new ModelAndView("aplicacao");
List<Aplicacao> aplicacoes = this.getAplicacoes();
mv.addObject("aplicacoes", aplicacoes);
return mv;
}
}
| [
"[email protected]"
] | |
5e94bcfe9bb31a2bb8032f67a583f34dc5f07478 | e051229f0a94a38a6d6eddc30fdff95df33de75a | /src/main/java/lk/spm/learning/management/repository/PaymentRepository.java | a6348b0268e0a68525ddb374cde84c1cab9bd22b | [] | no_license | SalithaEkanayaka123/SPM_LEARNING_MANAGEMENT_BACK | 0e7a6c34087137a81e338eb64cc181cd354d8c37 | c0dbe9839c2ced6cf3ee34df16f995c0b2f81386 | refs/heads/it19121048 | 2023-08-22T09:04:00.829356 | 2021-10-02T16:44:41 | 2021-10-02T16:44:41 | 388,871,768 | 1 | 0 | null | 2021-10-02T16:24:43 | 2021-07-23T17:06:39 | Java | UTF-8 | Java | false | false | 299 | java | package lk.spm.learning.management.repository;
import lk.spm.learning.management.model.Payment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface PaymentRepository extends JpaRepository<Payment, Long> {
}
| [
"[email protected]"
] | |
c7b1b8bb47a5d7294cca3cb4b8920a67324531a4 | 25729cf0666fb83f0c9b7553cd647b6c33968886 | /src/main/message/com/zg/message/dao/ReceiveMessageDao.java | 39b76b3a5e9542730d00cbb7a2a7e4ee7fdabb48 | [] | no_license | 545473750/zswxglxt | 1b55f94d8c0c8c0de47a0180406cdcdacc2ff756 | 2a7b7aeba7981bd723f99db400c99d0decb6de43 | refs/heads/master | 2020-04-23T15:42:36.490753 | 2014-08-11T00:08:39 | 2014-08-11T00:08:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,552 | java | package com.zg.message.dao;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import cn.org.rapid_framework.page.Page;
import com.opendata.common.base.BaseHibernateDao;
import com.zg.message.model.ReceiveMessage;
import com.zg.message.query.ReceiveMessageQuery;
/**
describe:消息提醒表Dao
*/
@Repository
public class ReceiveMessageDao extends BaseHibernateDao<ReceiveMessage,String>
{
public Class getEntityClass()
{
return ReceiveMessage.class;
}
/**
通过MessageQuery对象,查询消息提醒表
*/
public Page findPage(ReceiveMessageQuery query,int pageSize,int pageNum)
{
String hql=" from ReceiveMessage ett where 1=1";
List param=new ArrayList();
if(query!=null)
{
if(!StringUtils.isEmpty(query.getId()))
{
hql+=" and ett.id=?";
param.add(query.getId());
}
if(!StringUtils.isEmpty(query.getReceiverId()))
{
hql+=" and ett.receiverId=?";
param.add(query.getReceiverId());
}
if(!StringUtils.isEmpty(query.getReceiver()))
{
hql+=" and ett.receiver=?";
param.add(query.getReceiver());
}
if(!StringUtils.isEmpty(query.getSponsor()))
{
hql+=" and ett.sponsor=?";
param.add(query.getSponsor());
}
if(!StringUtils.isEmpty(query.getSponsorId()))
{
hql+=" and ett.sponsorId=?";
param.add(query.getSponsorId());
}
if(!StringUtils.isEmpty(query.getTitle()))
{
hql+=" and ett.title=?";
param.add(query.getTitle());
}
if(query.getTime()!=null)
{
hql+=" and ett.time=?";
param.add(query.getTime());
}
if(!StringUtils.isEmpty(query.getState()))
{
hql+=" and ett.state=?";
param.add(query.getState());
}
if(!StringUtils.isEmpty(query.getStatus()))
{
hql+=" and ett.status=?";
param.add(query.getStatus());
}
if(query.getChackTime()!=null)
{
hql+=" and ett.chackTime=?";
param.add(query.getChackTime());
}
if(!StringUtils.isEmpty(query.getContent()))
{
hql+=" and ett.content=?";
param.add(query.getContent());
}
if(query.getTs()!=null)
{
hql+=" and ett.ts=?";
param.add(query.getTs());
}
}
if(!StringUtils.isEmpty(query.getSortColumns())){
if(!query.getSortColumns().equals("ts")){
hql+=" order by ett."+query.getSortColumns()+" , ett.ts desc ";
}else{
hql+=" order by ett.ts desc ";
}
}else{
hql+=" order by ett.ts desc ";
}
return super.findByHql(hql, pageSize, pageNum, param.toArray());
}
}
| [
"[email protected]"
] | |
9a1b800d23caa474e38635ce530cffae686e6f57 | cec0f6b192412bca096937fc13038843b83a215f | /app/src/main/java/com/sevenlogics/babynursing/CameraItemAdapter.java | af21c51677b127539c8051deb3890ef4a10f3b4f | [] | no_license | vincentthai22/nursing-android-backup | f20854b1cad60321488b9c926c0a95b077809d5a | 3452297f13abb5e697c6af2caec32b23cf12cc20 | refs/heads/master | 2021-01-23T01:01:25.560186 | 2017-03-22T18:24:21 | 2017-03-22T18:24:21 | 85,862,092 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,042 | java | package com.sevenlogics.babynursing;
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* Created by cg-mayur on 3/2/17.
*/
public class CameraItemAdapter extends RecyclerView.Adapter<CameraItemAdapter.ViewHolder> implements View.OnClickListener {
Context context;
ItemListener mListener;
public CameraItemAdapter(Context context, ItemListener listener) {
this.context = context;
this.mListener = listener;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ViewHolder(LayoutInflater.from(parent.getContext()).
inflate(R.layout.camera_bottom_sheet_item_layout, parent, false));
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
switch (position) {
case 0: {
holder.txtItem.setText(context.getResources().getString(R.string.string_take_photo));
holder.itemView.setTag(position);
break;
}
case 1: {
holder.txtItem.setText(context.getResources().getString(R.string.string_choose_from_gallery));
holder.itemView.setTag(position);
break;
}
}
}
@Override
public int getItemCount() {
return 2;
}
@Override
public void onClick(View view) {
if (mListener != null) {
mListener.onItemClick((int) view.getTag());
}
}
public interface ItemListener {
void onItemClick(int position);
}
public class ViewHolder extends RecyclerView.ViewHolder {
TextView txtItem;
public ViewHolder(View itemView) {
super(itemView);
txtItem = (TextView) itemView.findViewById(R.id.txt_item);
itemView.setOnClickListener(CameraItemAdapter.this);
}
}
}
| [
"[email protected]"
] | |
e511ebb39165c5ef0ec70445951206117d7c5b15 | 0bfda0f91f4ec3f9eda84fa3070287a627e4fe29 | /src/ru/geekbrains/ads/lesson1/refs/PersonRec.java | 146a268a5ca09778432743c9e06128f90b6a3d68 | [] | no_license | Senpai07/algoritm-data-struct | 3538b742283da27ff6ca535fc4c014adca4ced10 | b45a000ceed305f247287a59d1a2046071d88b2d | refs/heads/master | 2023-01-24T03:49:35.731940 | 2020-11-29T16:07:51 | 2020-11-29T16:07:51 | 307,807,067 | 0 | 0 | null | 2020-11-29T16:04:37 | 2020-10-27T19:30:41 | Java | UTF-8 | Java | false | false | 91 | java | package ru.geekbrains.ads.lesson1.refs;
public record PersonRec(String name, int age) {
}
| [
"[email protected]"
] | |
c056a4f73c5b2eb5bb876c4e3a0cd87d41c675d4 | 42d57cc49a8472de13a246bc07ba3e25ae1519b4 | /src/test/java/com/qalabs/seleniumbasics/SeleniumExe2.java | 91b11c3451185b2f544b59fea7af8c0fb4b8e9f2 | [] | no_license | carlosetc83/Selenium_Mod1 | c6761041bd856d3e8d36f5a04e637f34ee69f604 | 017376d87c7c7b0dbd98bddc2657cac1cee623ae | refs/heads/master | 2021-07-14T01:43:03.673164 | 2017-10-14T19:04:34 | 2017-10-14T19:04:34 | 106,954,234 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 996 | java | package com.qalabs.seleniumbasics;
import org.openqa.selenium.WebDriver;
public class SeleniumExe2 {
public static void main(String[] args) throws InterruptedException {
//Select Browser
String Browser = "chrome";
//Get Browser Driver
WebDriver MyDriver = WebDriverFactory.getDriver(Browser);
//Open WebPage
MyDriver.get("http://www.google.com");
//Wait for Sync
Thread.sleep(1000);
//Get URL
String currentUrl = MyDriver.getCurrentUrl();
//Get Page Tittle
String currentTittle = MyDriver.getTitle();
//Get Source Code
String currentPageSource = MyDriver.getPageSource();
//Close Browser
MyDriver.close();
//Print Values
System.out.println("La URL actual es: " + currentUrl);
System.out.println("La PageTittle actual es: " + currentTittle);
System.out.println("La Page Source actual es: " + currentPageSource);
}
}
| [
"[email protected]"
] | |
fffaa42ab3c1ac3207fb4923a71b859f5d672a88 | 8b220bade4d2ab2060d898f6e9800eee22f16864 | /src/com/admin/addteacherlogin.java | 81572a6495e98dab382ba90688ac7214ef3458c5 | [] | no_license | King-azr/JavaWeb | 18540199ef57e3697ce1c49f582d6059c6265220 | 7f3157dcb9bd3a8d9c506e131d1fe0a6c6a59447 | refs/heads/master | 2022-04-14T23:20:55.067798 | 2020-04-15T15:15:18 | 2020-04-15T15:15:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,559 | java | package com.admin;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import com.admin_dao.Admin;
import com.admin_dao.adminDAOImpl;
import com.admin_dao.adminDao;
@WebServlet("/addteacherlogin")
public class addteacherlogin extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
adminDao dao=new adminDAOImpl();
Admin admin =new Admin();
String message=null;
try {
admin.setUsername(new String(request.getParameter("username")));
admin.setPassword(new String(request.getParameter("password")));
boolean success=dao.add_teacher_User(admin);
if(success){
message="<li>成功插入</li>";
}
else{
message="<li>失败插入</li>";
}
}catch (Exception e){
System.out.println(e);
message="<li>插入错误</li>";
}
request.setAttribute("result",message);
request.getRequestDispatcher("show_instructor").forward(request,response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
}
}
| [
"[email protected]"
] | |
295255ae566ff0ae1a386cd4cab587bc73aea910 | f852c4ee580cd4c04f86ef4677287e312888338a | /src/main/java/com/ducetech/framework/util/CodecUtil.java | 7988c24650f90a9d3d5f97078f1cc58298bbf3a6 | [
"Apache-2.0"
] | permissive | lisx/schedule-platform | 086d411510ac5b0b4edd3558d68a87279a7bce92 | df8688573257d402f8eb9ef3d56629054793ff53 | refs/heads/master | 2021-04-06T19:20:48.160801 | 2018-05-11T03:12:41 | 2018-05-11T03:12:41 | 124,510,580 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,561 | java | package com.ducetech.framework.util;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.UUID;
public class CodecUtil {
private static Logger logger = LoggerFactory.getLogger(CodecUtil.class);
/**
* 将 URL 编码
*/
public static String encodeURL(String str) {
String target;
try {
target = URLEncoder.encode(str, "UTF-8");
} catch (Exception e) {
logger.error("编码出错!", e);
throw new RuntimeException(e);
}
return target;
}
/**
* 将 URL 解码
*/
public static String decodeURL(String str) {
String target;
try {
target = URLDecoder.decode(str, "UTF-8");
} catch (Exception e) {
logger.error("解码出错!", e);
throw new RuntimeException(e);
}
return target;
}
/**
* 将字符串 Base64 编码
*/
public static String encodeBASE64(String str) {
String target;
try {
target = Base64.encodeBase64URLSafeString(str.getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
logger.error("编码出错!", e);
throw new RuntimeException(e);
}
return target;
}
/**
* 将字符串 Base64 解码
*/
public static String decodeBASE64(String str) {
String target;
try {
target = new String(Base64.decodeBase64(str), "UTF-8");
} catch (UnsupportedEncodingException e) {
logger.error("解码出错!", e);
throw new RuntimeException(e);
}
return target;
}
/**
* 将字符串 MD5 加密
*/
public static String encryptMD5(String str) {
return DigestUtils.md5Hex(str);
}
/**
* 将字符串 SHA 加密
*/
public static String encryptSHA(String str) {
return DigestUtils.sha256Hex(str);
}
/**
* 创建随机数
*/
public static String createRandom(int count) {
return RandomStringUtils.randomNumeric(count);
}
/**
* 获取 UUID(32位)
*/
public static String createUUID() {
return UUID.randomUUID().toString().replaceAll("-", "").toUpperCase();
}
}
| [
"[email protected]"
] | |
1dce35b68d0cc75110292e9d2bafc0e6010e1549 | e6657538e0c32a68239476f0a2930482c9a83994 | /【演示】_变量、数据类型和运算符与选择结构/案例/演示:用boolean变量来描述信息/src/demo/BoolTest.java | 1e6f2b28680d988c64cb8f6f7a54ce670094857d | [] | no_license | yanchao00551/ZJoracleJavaSE | cf4cc2ceee20bbb0436a1d80368a3d0d4c645f1d | 084ceaac4fa04e130276094da5c26f88a127f385 | refs/heads/master | 2023-07-30T00:02:54.090197 | 2021-09-19T09:00:52 | 2021-09-19T09:00:52 | 348,271,676 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 591 | java | package demo;
import java.util.Scanner;
public class BoolTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
int liSi = 80; //李四的成绩
boolean isBig; //声明一个boolean类型的变量
Scanner input = new Scanner(System.in); //java控制台输入的一种方法
System.out.println("输入学员张三成绩:");//提示要输入学员张三的成绩
int zhangSan = input.nextInt(); //输入张三的成绩
isBig = zhangSan > liSi;
System.out.println("张三成绩比李四高吗?" + isBig); //输出比较结果
}
}
| [
"[email protected]"
] | |
82a26ba756121024f2f546f0154e7bb964f474bd | 8ae0e120af4f32dbade08fc32e2cd58f20119106 | /siw-spring-siwmelier-new/src/main/java/it/uniroma3/siw/spring/validator/SiwmelierValidator.java | dffbaa37241ba224f379b84f6925e40929434a8d | [] | no_license | Francsco99/SIWmelier | b0dca36b13161bd598ed3c8a7b75bbe5517eec11 | 500b9971f66524ef9b3dc02e12b642f98e51bada | refs/heads/master | 2023-06-02T03:35:40.164580 | 2021-06-28T07:47:27 | 2021-06-28T07:47:27 | 378,968,939 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 417 | java | package it.uniroma3.siw.spring.validator;
import org.springframework.validation.Errors;
import org.springframework.validation.Validator;
public class SiwmelierValidator implements Validator {
@Override
public boolean supports(Class<?> clazz) {
// TODO Auto-generated method stub
return false;
}
@Override
public void validate(Object target, Errors errors) {
// TODO Auto-generated method stub
}
}
| [
"[email protected]"
] | |
eb8e2d798393099080fc006f4d8083f0e95ead46 | ef7322f9566033eb686735a406a91a34fc45ecb5 | /src/main/java/com/consulner/demo/SimpleUsersManager.java | c164cd986580dd8922e1ef32393b9db72acb8a3f | [] | no_license | piczmar/refactoring-demo | 98c01a4ce02cf737d897fe9093b380f544aaba4a | 5997bb51a049e727cd18de1e44ce92431fda88ec | refs/heads/master | 2021-04-03T09:03:54.920466 | 2018-03-13T11:23:54 | 2018-03-13T11:23:54 | 125,039,093 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,484 | java | package com.consulner.demo;
import java.time.LocalDate;
import java.time.Month;
import java.util.List;
public class SimpleUsersManager {
protected static final String GREETING_MAN = "Happy Man's Day";
protected static final String GREETING_WOMAN = "Happy Women's Day";
private final GenderService genderService;
private final NotificationService notificationService;
public SimpleUsersManager(GenderService genderService, NotificationService notificationService) {
this.genderService = genderService;
this.notificationService = notificationService;
}
public void processUsers(List<String> users, LocalDate date) {
for (String user : users) {
boolean isMale = genderService.isMale(user);
if (isMale && isMenDay(date)) {
notificationService.sendGreeting(user, GREETING_MAN);
} else if (!isMale && isWomenDay(date)) {
notificationService.sendGreeting(user, GREETING_WOMAN);
}
}
}
// see International Women's Day: https://en.wikipedia.org/wiki/International_Women%27s_Day
private boolean isWomenDay(LocalDate date) {
return date.getDayOfMonth() == 8 && date.getMonth() == Month.MARCH;
}
// see International Man's Day: https://en.wikipedia.org/wiki/International_Men%27s_Day
private boolean isMenDay(LocalDate date) {
return date.getDayOfMonth() == 19 && date.getMonth() == Month.NOVEMBER;
}
}
| [
"[email protected]"
] | |
9a0248dfff3f33bd42868cf0831ea139d840eccb | 20eb62855cb3962c2d36fda4377dfd47d82eb777 | /IntroClassJava/dataset/grade/489253253c866aa61b6b0d95c6072d3912f6b78dfbc01bdb2fbb663aefe33d6d353b1a61bb5fc567c9d6c334994111816edd3d43db47e4ea4a84953198736ff7/000/mutations/114/grade_48925325_000.java | 89314eb4a4da4d4def0873b44f3c0d61cb1b7ed5 | [] | no_license | ozzydong/CapGen | 356746618848065cce4e253e5d3c381baa85044a | 0ba0321b6b1191443276021f1997833342f02515 | refs/heads/master | 2023-03-18T20:12:02.923428 | 2020-08-21T03:08:28 | 2020-08-21T03:08:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,415 | java | package introclassJava;
class IntObj {
public int value;
public IntObj () {
} public IntObj (int i) {
value = i;
}
}
class FloatObj {
public float value;
public FloatObj () {
} public FloatObj (float i) {
value = i;
}
}
class LongObj {
public long value;
public LongObj () {
} public LongObj (long i) {
value = i;
}
}
class DoubleObj {
public double value;
public DoubleObj () {
} public DoubleObj (double i) {
value = i;
}
}
class CharObj {
public char value;
public CharObj () {
} public CharObj (char i) {
value = i;
}
}
public class grade_48925325_000 {
public java.util.Scanner scanner;
public String output = "";
public static void main (String[]args) throws Exception {
grade_48925325_000 mainClass = new grade_48925325_000 ();
String output;
if (args.length > 0) {
mainClass.scanner = new java.util.Scanner (args[0]);
} else {
mainClass.scanner = new java.util.Scanner (System.in);
}
mainClass.exec ();
System.out.println (mainClass.output);
}
public void exec () throws Exception {
FloatObj A = new FloatObj (), B = new FloatObj (), C =
new FloatObj (), D = new FloatObj (), percent = new FloatObj ();
output +=
(String.format
("Enter thresholds for A, B, C, D\n in that order, decreasing percentages > "));
A.value = scanner.nextFloat ();
B.value = scanner.nextFloat ();
C.value = scanner.nextFloat ();
D.value = scanner.nextFloat ();
output +=
(String.format ("Thank you. Now enter student score (percent) >"));
percent.value = scanner.nextFloat ();
if (percent.value >= A.value) {
output += (String.format ("Student has an A grade\n"));
} else if (percent.value >= B.value) {
output += (String.format ("Student has a B grade\n"));
} else if (percent.value >= C.value) {
output += (String.format ("Student has a C grade\n"));
} else if (true) return ;
if (percent.value >= D.value) {
output += (String.format ("Student has a D grade\n"));
} else {
output += (String.format ("Student has a F grade\n"));
}
if (true)
return;;
}
}
| [
"[email protected]"
] | |
686cf58d37891b74df24b70d6a49de31cd73a3e1 | bc6a4823d7966008ae9b1ef3defc0cdad2073277 | /src/main/java/com/cn/tianxia/api/utils/pay/ParamsUtils.java | ab8359b2293623f4fe0fcd1ca0916642c7d9682d | [] | no_license | github4n/tx-api | e3fee7bc45f747bf81f29aeb821c0badec8a6d08 | 362e29df36e7d5582b327b7620613d76e37fd21e | refs/heads/master | 2020-07-29T18:27:25.406987 | 2019-05-18T14:11:16 | 2019-05-18T14:11:16 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 19,193 | java | package com.cn.tianxia.api.utils.pay;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.cn.tianxia.api.utils.qyf.ToolKit;
import net.sf.json.JSONObject;
import sun.misc.BASE64Decoder;
/**
*
* @ClassName ParamsUtils
* @Description 参数工具类
* @author Hardy
* @Date 2018年9月29日 下午5:58:14
* @version 1.0.0
*/
public class ParamsUtils {
//日志
private static final Logger logger = LoggerFactory.getLogger(ParamsUtils.class);
/**
*
* @Description 获取流参数
* @param request
* @return
*/
public static Map<String,String> getReqParamsByIO(HttpServletRequest request){
Map<String,String> data = new HashMap<>();
try {
//从流里面过去请求参数
InputStream is = request.getInputStream();
//建立接收流缓冲,准备处理
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sb = new StringBuffer();
//读入流,并转换成字符串
String readLine;
while ((readLine = reader.readLine()) != null) {
sb.append(readLine);
}
reader.close();
String reqParams = sb.toString();
logger.info("从request中获取流参数报文:{}",reqParams);
if(null==reqParams||"".equals(reqParams)) {
return null;
}
JSONObject jsonObject = JSONObject.fromObject(reqParams);
if(jsonObject != null && !jsonObject.isEmpty()){
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
String val = jsonObject.getString(key);
if(StringUtils.isBlank(val)) continue;
data.put(key, val);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("解析流参数异常:" + e.getMessage());
}
return data;
}
/**
*
* @Description 获取请求参数
* @param request
* @return
*/
public static Map<String,String> getParameterNames(HttpServletRequest request){
Map<String,String> data = new HashMap<>();
try {
Enumeration enu = request.getParameterNames();
if(null == enu){
return null;
}
while (enu.hasMoreElements()) {
String key = (String) enu.nextElement();
data.put(key, request.getParameter(key));
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析请求参数异常:"+e.getMessage());
}
return data;
}
public static Map<String,String> getParameterMap(HttpServletRequest request){
Map<String,String> data = new HashMap<>();
try {
Map<String, String[]> params = request.getParameterMap();
if(params == null || params.isEmpty()){
return null;
}
Iterator<String> iterator = params.keySet().iterator();
while(iterator.hasNext()){
String key = iterator.next();
String val = params.get(key)[0].trim();
if(StringUtils.isBlank(val)) continue;
data.put(key, val);
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析请求参数异常:"+e.getMessage());
}
return data;
}
public static Map<String,String> getNotifyParams(HttpServletRequest request){
Map<String,String> data = new HashMap<>();
try {
data = getParameterNames(request);
if(data == null || data.isEmpty()){
data = getParameterMap(request);
if(data == null || data.isEmpty()){
data = getReqParamsByIO(request);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("解析请求参数异常:{}",e.getMessage());
}
return data;
}
public static String formatMapToJson(Map<String,String> data) throws Exception{
try {
StringBuffer sb = new StringBuffer();
if (data != null && !data.isEmpty()){
Iterator<String> iterator = data.keySet().iterator();
sb.append("{");
while (iterator.hasNext()){
String key = iterator.next();
String val = data.get(key);
sb.append("\"").append(key).append("\"");
sb.append(":");
sb.append("\"").append(val).append("\"");
if (iterator.hasNext()) {
sb.append(",");
}
}
sb.append("}");
}
return sb.toString();
} catch (Exception e) {
e.printStackTrace();
logger.error("Map转Json字符串参数异常:"+e.getMessage());
throw new Exception("Map转Json字符串参数异常!");
}
}
/**
*
* @Description 获取竣付通支付回调请求参数
* @param request
* @return
* @throws Exception
*/
public static Map<String,String> getJFTPNotifyParams(HttpServletRequest request){
try {
String p1_yingyongnum = request.getParameter("p1_yingyongnum");
String p2_ordernumber = request.getParameter("p2_ordernumber");
String p3_money = request.getParameter("p3_money");
String p4_zfstate = request.getParameter("p4_zfstate");
String p5_orderid = request.getParameter("p5_orderid");
String p6_productcode = request.getParameter("p6_productcode");
String p7_bank_card_code = request.getParameter("p7_bank_card_code");
String p8_charset = request.getParameter("p8_charset");
String p9_signtype = request.getParameter("p9_signtype");
String p10_sign = request.getParameter("p10_sign");
String p11_pdesc = request.getParameter("p11_pdesc");
String p12_remark = request.getParameter("p12_remark");
String p13_zfmoney = request.getParameter("p13_zfmoney");
Map<String,String> data = new HashMap<>();
data.put("p1_yingyongnum",p1_yingyongnum);//
data.put("p2_ordernumber",p2_ordernumber);//
data.put("p3_money",p3_money);//
data.put("p4_zfstate",p4_zfstate);//
data.put("p5_orderid",p5_orderid);//
data.put("p6_productcode",p6_productcode);//
data.put("p7_bank_card_code",p7_bank_card_code);//
data.put("p8_charset",p8_charset);//
data.put("p9_signtype",p9_signtype);//
data.put("p10_sign",p10_sign);//
data.put("p11_pdesc",p11_pdesc);//
data.put("p12_remark",p12_remark);//
data.put("p13_zfmoney",p13_zfmoney);//
return data;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public static Map<String,String> getParams(HttpServletRequest request){
logger.info("getParams(getParams(HttpServletRequest request = {} "+ request.toString());
Map<String,String> map = new HashMap<>();
try{
map.put("memberid",request.getParameter("memberid"));
map.put("orderid",request.getParameter("orderid"));
map.put("amount",request.getParameter("amount"));
map.put("transactionId",request.getParameter("transaction_id"));
map.put("returncode",request.getParameter("returncode"));
map.put("sign",request.getParameter("sign"));
map.put("attach",request.getParameter("attach"));
map.put("datetime",request.getParameter("datetime"));
logger.info("BFH 宝付惠支付解析参数 map:{}"+ map);
return map;
}catch (Exception e){
logger.error("BFH 宝付惠支付解析参数异常",e);
throw e;
}
}
/**
*
* 获取GPAY支付回调参数
* @param request
* @return
*/
public static Map<String,String> getGPAYNotifyParams(HttpServletRequest request) {
Map<String,String> data = new HashMap<>();
try {
//从流里面过去请求参数
InputStream is = request.getInputStream();
//建立接收流缓冲,准备处理
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sb = new StringBuffer();
//读入流,并转换成字符串
String readLine;
while ((readLine = reader.readLine()) != null) {
sb.append(readLine);
}
reader.close();
String reqParams = sb.toString();
JSONObject jsonObject = JSONObject.fromObject(reqParams);
data.put("sign",jsonObject.getString("sign"));
JSONObject dataJson = jsonObject.getJSONObject("data");
if(dataJson != null && !dataJson.isEmpty()){
Iterator<String> iterator = dataJson.keys();
while (iterator.hasNext()) {
String key = iterator.next();
String val = dataJson.getString(key);
if(StringUtils.isBlank(val))
continue;
data.put(key, val);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("解析流参数异常:" + e.getMessage());
}
return data;
}
/**
*
* @Description 宏达回到通知获取参数
* @param request
* @return
*/
public static Map<String,String> getHDZFNotifyParams(HttpServletRequest request) {
logger.info("HDZFNotify获取回调请求参数开始===========START===============");
Map<String,String> data = new HashMap<>();
try {
data.put("type",request.getParameter("type"));//支付通道alipay
data.put("money",request.getParameter("money"));//支付金额
data.put("extend",request.getParameter("extend"));//扩展信息
data.put("out_order_id",request.getParameter("out_order_id"));//商户订单号
if (StringUtils.isNotBlank(request.getParameter("no"))){
data.put("no",request.getParameter("no"));//支付宝交易号
}
data.put("pid",request.getParameter("pid"));//商户id
data.put("sign",request.getParameter("sign"));//数字签名
} catch (Exception e) {
e.printStackTrace();
logger.info("HDZFNotify获取回调请求参数异常:{}",e.getMessage());
}
return data;
}
/**
*
* 获取D15支付回调参数
* @param request
* @return
*/
public static Map<String,String> getDFIFNotifyParams(HttpServletRequest request,String privateKey) {
try {
String requestData = request.getParameter("data");
byte[] result = ToolKit.decryptByPrivateKey(new BASE64Decoder().decodeBuffer(requestData), privateKey);
String resultData = new String(result, ToolKit.CHARSET);// 解密数据
JSONObject jsonObj = JSONObject.fromObject(resultData);
return jsonObj;
} catch (Exception e) {
e.printStackTrace();
logger.info("解析流参数异常:" + e.getMessage());
}
return null;
}
/**
*
* 获取城市互联支付回调参数
* @param request
* @return
*/
public static Map<String,String> getCSHLNotifyParams(HttpServletRequest request) {
try {
String message = request.getParameter("message");
String signature = request.getParameter("signature");
byte[] result = new BASE64Decoder().decodeBuffer(message);
String resultData = new String(result, StandardCharsets.UTF_8);// 解密数据
logger.info("[CSHL]城市互联回调参数解析,message:{},signature:{}",resultData,signature);
JSONObject jsonObj = JSONObject.fromObject(resultData);
jsonObj.put("sign",signature);
return jsonObj;
} catch (Exception e) {
e.printStackTrace();
logger.info("解析城市互联参数异常:" + e.getMessage());
}
return null;
}
/**
*
* @Description 解析简付支付回调请求参数
* @param request
* @return
*/
public static Map<String,String> getJIANNotifyParams(HttpServletRequest request){
try {
Map<String,String> data = new HashMap<>();
data.put("fxid",request.getParameter("fxid"));//
data.put("fxddh",request.getParameter("fxddh"));//
data.put("fxorder",request.getParameter("fxorder"));//
data.put("fxattch",request.getParameter("fxattch"));//
data.put("fxdesc",request.getParameter("fxdesc"));//
data.put("fxfee",request.getParameter("fxfee"));//
data.put("fxstatus",request.getParameter("fxstatus"));//
data.put("fxtime",request.getParameter("fxtime"));//
data.put("fxsign",request.getParameter("fxsign"));//
return data;
} catch (Exception e) {
e.printStackTrace();
logger.info("解析简付支付回调请求参数异常:{}",e.getMessage());
}
return null;
}
/**
*
* @Description 解析安心付支付回调参数
*
*/
public static Map<String,String> getAXPNotifyParams(HttpServletRequest request) {
Map<String,String> data = new HashMap<>();
try {
Enumeration enu = request.getParameterNames();
String jsonData = (String) enu.nextElement();
logger.info("[AXP]安心付回调请求参数字符串:{}",jsonData);
JSONObject jsonObject = JSONObject.fromObject(jsonData);
if(jsonObject != null && !jsonObject.isEmpty()){
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
String val = jsonObject.getString(key);
if(StringUtils.isBlank(val))
continue;
data.put(key, val);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.error("解析请求参数异常:"+e.getMessage());
}
return data;
}
/**
*
* @Description 解析速龙支付回调参数
*
*/
public static Map<String,Object> getSLZFNotifyParams(HttpServletRequest request) {
Map<String, Object> data = new HashMap<>();
try {
String reqXml = "";
Map<String, String[]> params = request.getParameterMap();
Iterator<String> keys = params.keySet().iterator();
while(keys.hasNext()){
String key = keys.next();
if("".equals(params.get(key)[0].trim())){
reqXml = key;
break;
}
}
if(StringUtils.isBlank(reqXml)){
return null;
}
//xml转json
data = XmlUtils.xml2Json(reqXml);
} catch (Exception e) {
e.printStackTrace();
logger.error("解析请求参数异常:"+e.getMessage());
}
return data;
}
/**
*
* @Description 获取盈付支付回调参数
* @param request
* @return
*/
public static Map<String,String> getYINFNotifyParams(HttpServletRequest request){
Map<String,String> data = new HashMap<>();
try {
//从流里面过去请求参数
InputStream is = request.getInputStream();
//建立接收流缓冲,准备处理
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sb = new StringBuffer();
//读入流,并转换成字符串
String readLine;
while ((readLine = reader.readLine()) != null) {
sb.append(readLine);
}
reader.close();
String reqParams = sb.toString();
logger.info("从request中获取流参数报文:{}",reqParams);
JSONObject jsonObject = XmlUtils.parseXml(reqParams);
if(jsonObject != null && !jsonObject.isEmpty()){
Iterator<String> iterator = jsonObject.keys();
while (iterator.hasNext()) {
String key = iterator.next();
String val = jsonObject.getString(key);
if(StringUtils.isBlank(val)) continue;
data.put(key, val);
}
}
} catch (Exception e) {
e.printStackTrace();
logger.info("解析流参数异常:" + e.getMessage());
}
return data;
}
/**
*
* @Description 获取流参数
* @param request
* @return
*/
public static String getHPAYNotifyParams(HttpServletRequest request){
try {
//从流里面过去请求参数
InputStream is = request.getInputStream();
//建立接收流缓冲,准备处理
BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
StringBuffer sb = new StringBuffer();
//读入流,并转换成字符串
String readLine;
while ((readLine = reader.readLine()) != null) {
sb.append(readLine);
}
reader.close();
String reqParams = sb.toString();
logger.info("从request中获取流参数报文:{}",reqParams);
if(null==reqParams||"".equals(reqParams)) {
return null;
}
return URLDecoder.decode(reqParams, "UTF-8");
} catch (Exception e) {
e.printStackTrace();
logger.info("解析流参数异常:" + e.getMessage());
return null;
}
}
}
| [
"[email protected]"
] | |
bb99c11bdcb24f4001f572250455c74bec273b7f | f20652c48b4d9987fca0500630dcf98ad809d7e9 | /relationships/src/main/java/com/manjula/relationships/selfreference/service/EmployeeServiceImpl.java | 102c7dcd73052456587ffb47609c2d5025c5dbd4 | [] | no_license | slmanju/springtime | 07be6ae15a72985c79724dc940157ac77709c651 | 825b2cf9ca69f5a3b95531ee650ad3d53f00765f | refs/heads/master | 2022-02-09T02:34:13.403039 | 2020-05-12T09:59:13 | 2020-05-12T09:59:13 | 146,546,309 | 1 | 0 | null | 2022-01-21T23:42:17 | 2018-08-29T04:46:31 | Java | UTF-8 | Java | false | false | 2,500 | java | package com.manjula.relationships.selfreference.service;
import com.manjula.relationships.selfreference.domain.Employee;
import com.manjula.relationships.selfreference.domain.EmployeeDTO;
import com.manjula.relationships.selfreference.domain.EmployeeRepository;
import com.manjula.relationships.selfreference.domain.EmployeeType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class EmployeeServiceImpl implements EmployeeService {
private EmployeeRepository employeeRepository;
@Autowired
public EmployeeServiceImpl(EmployeeRepository employeeRepository) {
this.employeeRepository = employeeRepository;
}
@PostConstruct
public void init() {
Employee manager = Employee.instance("Iron Man", EmployeeType.MANAGER);
manager = employeeRepository.save(manager);
Employee lead1 = Employee.instance("Thor", EmployeeType.LEAD);
Employee lead2 = Employee.instance("Spider Man", EmployeeType.LEAD);
lead1.setManager(manager);
lead2.setManager(manager);
lead1 = employeeRepository.save(lead1);
lead2 = employeeRepository.save(lead2);
Employee developer1 = Employee.instance("Hulk", EmployeeType.DEVELOPER);
Employee developer2 = Employee.instance("Groot", EmployeeType.DEVELOPER);
developer1.setManager(lead1);
developer2.setManager(lead1);
employeeRepository.save(developer1);
employeeRepository.save(developer2);
Employee developer3 = Employee.instance("Ant Man", EmployeeType.DEVELOPER);
developer3.setManager(lead2);
employeeRepository.save(developer3);
Employee manager2 = Employee.instance("Bat Man", EmployeeType.MANAGER);
manager2 = employeeRepository.save(manager2);
Employee lead21 = Employee.instance("Super Man", EmployeeType.LEAD);
Employee lead22 = Employee.instance("Wonder Women", EmployeeType.LEAD);
lead21.setManager(manager2);
lead22.setManager(manager2);
employeeRepository.save(lead21);
employeeRepository.save(lead22);
}
@Override
public List<EmployeeDTO> findAllManagers() {
return employeeRepository.findAllManagers()
.stream()
.map(Employee::toDto)
.collect(Collectors.toList());
}
}
| [
"[email protected]"
] | |
8592b9e56ce0dcde9d199cf8d1a4456df6ddd21a | 4efa22abaa0bf5c03ba7a88a7fde37e8f2a77964 | /src/main/java/dz/hichsali/controller/HotelController.java | 6ee582e0d77c22d1824b4f1a0cef8de376aa4106 | [] | no_license | hichem-z/serviceone | 6da83f48f12635cbf9440580097888dc2d33ca24 | 0029c89d29ef4058944a18bce526336a1ef5699d | refs/heads/main | 2023-04-02T11:46:42.097354 | 2021-04-04T23:43:52 | 2021-04-04T23:43:52 | 354,123,409 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,244 | java | package dz.hichsali.controller;
import dz.hichsali.model.Hotel;
import dz.hichsali.sevice.HotelService;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.data.repository.query.Param;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.websocket.server.PathParam;
import java.util.Collection;
@RestController
@RequestMapping("/api")
public class HotelController {
@Autowired
@Qualifier(value = "hotelService")
HotelService hs;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@GetMapping("/hotels")
public Collection<Hotel> getAll(){
logger.debug("get All Hotels...........");
return hs.getAllHotels();
}
@GetMapping("/hotel/{id_hotel}")
public Hotel getHotel(@PathVariable(value = "id_hotel") String id){
logger.debug("get Hotel...........");
return hs.getHotel(id);
}
}
| [
"[email protected]"
] | |
3c30d6009809769e5e197af4376445c34a250b61 | 7ac70cb23eb69d16c1477b9ba1ded4c38517f639 | /Codigo/src/View/CompScreen.java | fbf3de11220310111b7a6b308d055a69a40f7102 | [] | no_license | ProMistakesMkr/Cuento-interactivo-Eros-y-Psique | e504de63f9ed8f9286bf97820aa35e77642aa92e | e19a635ff8006a595d6c6bbbb87313ecc1565bce | refs/heads/main | 2023-04-11T12:19:48.874329 | 2021-04-15T03:07:13 | 2021-04-15T03:07:13 | 352,477,617 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,046 | java | package View;
import Controller.Controller;
import processing.core.PApplet;
import processing.core.PImage;
public class CompScreen {
PApplet app;
PImage composition;
public Controller control;
public CompScreen (PApplet app) {
this.app = app;
control = new Controller(app);
composition = app.loadImage("../resources/CompositionFix.png");
}
public void paintComposition() {
app.image(composition,639.5f,359.5f);
}
public void paintPsique() {
control.paintPsique();
}
public void dragPsique() {
control.dragPsique();
}
public void paintKey() {
control.paintKey();
}
public void keyInteraction() {
control.keyInteraction();
}
public void paintNAF() {
control.paintNAF();
}
public void nafInteraction() {
control.nafInteraction();
}
public void paintEros() {
control.paintEros();
}
public void erosInteraction() {
control.erosInteraction();
}
public void paintOilDrop() {
control.paintOilDrop();
}
public void dragOilDrop() {
control.dragOilDrop();
}
}
| [
"[email protected]"
] | |
1c8f0070491043942532adb9cd7461bd623f794f | 5598faaaaa6b3d1d8502cbdaca903f9037d99600 | /code_changes/Apache_projects/MAPREDUCE-3345/7db30f8428ef341cc39b2758d3bd6dcccc25b080/FifoScheduler.java | ea5841b417de16bf19808c85af0e0fabf25b692f | [] | no_license | SPEAR-SE/LogInBugReportsEmpirical_Data | 94d1178346b4624ebe90cf515702fac86f8e2672 | ab9603c66899b48b0b86bdf63ae7f7a604212b29 | refs/heads/master | 2022-12-18T02:07:18.084659 | 2020-09-09T16:49:34 | 2020-09-09T16:49:34 | 286,338,252 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 29,560 | java | /**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.hadoop.yarn.server.resourcemanager.scheduler.fifo;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.hadoop.classification.InterfaceAudience.LimitedPrivate;
import org.apache.hadoop.classification.InterfaceAudience.Private;
import org.apache.hadoop.classification.InterfaceStability.Evolving;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.net.NetUtils;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authorize.AccessControlList;
import org.apache.hadoop.yarn.Lock;
import org.apache.hadoop.yarn.api.records.ApplicationAttemptId;
import org.apache.hadoop.yarn.api.records.Container;
import org.apache.hadoop.yarn.api.records.ContainerId;
import org.apache.hadoop.yarn.api.records.ContainerStatus;
import org.apache.hadoop.yarn.api.records.ContainerToken;
import org.apache.hadoop.yarn.api.records.NodeId;
import org.apache.hadoop.yarn.api.records.Priority;
import org.apache.hadoop.yarn.api.records.QueueACL;
import org.apache.hadoop.yarn.api.records.QueueInfo;
import org.apache.hadoop.yarn.api.records.QueueState;
import org.apache.hadoop.yarn.api.records.QueueUserACLInfo;
import org.apache.hadoop.yarn.api.records.Resource;
import org.apache.hadoop.yarn.api.records.ResourceRequest;
import org.apache.hadoop.yarn.factories.RecordFactory;
import org.apache.hadoop.yarn.factory.providers.RecordFactoryProvider;
import org.apache.hadoop.yarn.security.ContainerTokenIdentifier;
import org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger;
import org.apache.hadoop.yarn.server.resourcemanager.RMAuditLogger.AuditConstants;
import org.apache.hadoop.yarn.server.resourcemanager.RMContext;
import org.apache.hadoop.yarn.server.resourcemanager.recovery.Store.RMState;
import org.apache.hadoop.yarn.server.resourcemanager.resource.Resources;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEvent;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptEventType;
import org.apache.hadoop.yarn.server.resourcemanager.rmapp.attempt.RMAppAttemptState;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainer;
import org.apache.hadoop.yarn.server.resourcemanager.rmcontainer.RMContainerEventType;
import org.apache.hadoop.yarn.server.resourcemanager.rmnode.RMNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Allocation;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.NodeType;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.Queue;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.QueueMetrics;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.ResourceScheduler;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerApp;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerAppReport;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNode;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerNodeReport;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.SchedulerUtils;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppAddedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.AppRemovedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.ContainerExpiredSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeAddedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeRemovedSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.NodeUpdateSchedulerEvent;
import org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEvent;
import org.apache.hadoop.yarn.server.security.ContainerTokenSecretManager;
import org.apache.hadoop.yarn.util.BuilderUtils;
@LimitedPrivate("yarn")
@Evolving
public class FifoScheduler implements ResourceScheduler {
private static final Log LOG = LogFactory.getLog(FifoScheduler.class);
private static final RecordFactory recordFactory =
RecordFactoryProvider.getRecordFactory(null);
Configuration conf;
private ContainerTokenSecretManager containerTokenSecretManager;
private final static Container[] EMPTY_CONTAINER_ARRAY = new Container[] {};
private final static List<Container> EMPTY_CONTAINER_LIST = Arrays.asList(EMPTY_CONTAINER_ARRAY);
private RMContext rmContext;
private Map<NodeId, SchedulerNode> nodes = new ConcurrentHashMap<NodeId, SchedulerNode>();
private static final int MINIMUM_MEMORY = 1024;
private static final String FIFO_PREFIX = "yarn.scheduler.fifo.";
@Private
public static final String MINIMUM_ALLOCATION =
FIFO_PREFIX + "minimum-allocation-mb";
private static final int MAXIMUM_MEMORY = 10240;
@Private
public static final String MAXIMUM_ALLOCATION =
FIFO_PREFIX + "maximum-allocation-mb";
private boolean initialized;
private Resource minimumAllocation;
private Resource maximumAllocation;
private Map<ApplicationAttemptId, SchedulerApp> applications
= new TreeMap<ApplicationAttemptId, SchedulerApp>();
private static final String DEFAULT_QUEUE_NAME = "default";
private final QueueMetrics metrics =
QueueMetrics.forQueue(DEFAULT_QUEUE_NAME, null, false);
private final Queue DEFAULT_QUEUE = new Queue() {
@Override
public String getQueueName() {
return DEFAULT_QUEUE_NAME;
}
@Override
public QueueMetrics getMetrics() {
return metrics;
}
@Override
public QueueInfo getQueueInfo(
boolean includeChildQueues, boolean recursive) {
QueueInfo queueInfo = recordFactory.newRecordInstance(QueueInfo.class);
queueInfo.setQueueName(DEFAULT_QUEUE.getQueueName());
queueInfo.setCapacity(100.0f);
queueInfo.setMaximumCapacity(100.0f);
queueInfo.setChildQueues(new ArrayList<QueueInfo>());
queueInfo.setQueueState(QueueState.RUNNING);
return queueInfo;
}
@Override
public Map<QueueACL, AccessControlList> getQueueAcls() {
Map<QueueACL, AccessControlList> acls =
new HashMap<QueueACL, AccessControlList>();
for (QueueACL acl : QueueACL.values()) {
acls.put(acl, new AccessControlList("*"));
}
return acls;
}
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo(
UserGroupInformation unused) {
QueueUserACLInfo queueUserAclInfo =
recordFactory.newRecordInstance(QueueUserACLInfo.class);
queueUserAclInfo.setQueueName(DEFAULT_QUEUE_NAME);
queueUserAclInfo.setUserAcls(Arrays.asList(QueueACL.values()));
return Collections.singletonList(queueUserAclInfo);
}
};
@Override
public Resource getMinimumResourceCapability() {
return minimumAllocation;
}
@Override
public Resource getMaximumResourceCapability() {
return maximumAllocation;
}
@Override
public synchronized void reinitialize(Configuration conf,
ContainerTokenSecretManager containerTokenSecretManager,
RMContext rmContext)
throws IOException
{
if (!this.initialized) {
this.conf = conf;
this.containerTokenSecretManager = containerTokenSecretManager;
this.rmContext = rmContext;
this.minimumAllocation =
Resources.createResource(conf.getInt(MINIMUM_ALLOCATION, MINIMUM_MEMORY));
this.maximumAllocation =
Resources.createResource(conf.getInt(MAXIMUM_ALLOCATION, MAXIMUM_MEMORY));
this.initialized = true;
} else {
this.conf = conf;
}
}
private static final Allocation EMPTY_ALLOCATION =
new Allocation(EMPTY_CONTAINER_LIST, Resources.createResource(0));
@Override
public Allocation allocate(
ApplicationAttemptId applicationAttemptId, List<ResourceRequest> ask,
List<ContainerId> release) {
SchedulerApp application = getApplication(applicationAttemptId);
if (application == null) {
LOG.error("Calling allocate on removed " +
"or non existant application " + applicationAttemptId);
return EMPTY_ALLOCATION;
}
// Sanity check
SchedulerUtils.normalizeRequests(ask, MINIMUM_MEMORY);
// Release containers
for (ContainerId releasedContainer : release) {
RMContainer rmContainer = getRMContainer(releasedContainer);
if (rmContainer == null) {
RMAuditLogger.logFailure(application.getUser(),
AuditConstants.RELEASE_CONTAINER,
"Unauthorized access or invalid container", "FifoScheduler",
"Trying to release container not owned by app or with invalid id",
application.getApplicationId(), releasedContainer);
}
containerCompleted(rmContainer,
SchedulerUtils.createAbnormalContainerStatus(
releasedContainer,
SchedulerUtils.RELEASED_CONTAINER),
RMContainerEventType.RELEASED);
}
synchronized (application) {
if (!ask.isEmpty()) {
LOG.debug("allocate: pre-update" +
" applicationId=" + applicationAttemptId +
" application=" + application);
application.showRequests();
// Update application requests
application.updateResourceRequests(ask);
LOG.debug("allocate: post-update" +
" applicationId=" + applicationAttemptId +
" application=" + application);
application.showRequests();
LOG.debug("allocate:" +
" applicationId=" + applicationAttemptId +
" #ask=" + ask.size());
}
return new Allocation(
application.pullNewlyAllocatedContainers(),
application.getHeadroom());
}
}
private SchedulerApp getApplication(
ApplicationAttemptId applicationAttemptId) {
return applications.get(applicationAttemptId);
}
@Override
public SchedulerAppReport getSchedulerAppInfo(
ApplicationAttemptId applicationAttemptId) {
SchedulerApp app = getApplication(applicationAttemptId);
return app == null ? null : new SchedulerAppReport(app);
}
private SchedulerNode getNode(NodeId nodeId) {
return nodes.get(nodeId);
}
@SuppressWarnings("unchecked")
private synchronized void addApplication(ApplicationAttemptId appAttemptId,
String user) {
// TODO: Fix store
SchedulerApp schedulerApp =
new SchedulerApp(appAttemptId, user, DEFAULT_QUEUE,
this.rmContext, null);
applications.put(appAttemptId, schedulerApp);
metrics.submitApp(user);
LOG.info("Application Submission: " + appAttemptId.getApplicationId() +
" from " + user + ", currently active: " + applications.size());
rmContext.getDispatcher().getEventHandler().handle(
new RMAppAttemptEvent(appAttemptId,
RMAppAttemptEventType.APP_ACCEPTED));
}
private synchronized void doneApplication(
ApplicationAttemptId applicationAttemptId,
RMAppAttemptState rmAppAttemptFinalState)
throws IOException {
SchedulerApp application = getApplication(applicationAttemptId);
if (application == null) {
throw new IOException("Unknown application " + applicationAttemptId +
" has completed!");
}
// Kill all 'live' containers
for (RMContainer container : application.getLiveContainers()) {
containerCompleted(container,
SchedulerUtils.createAbnormalContainerStatus(
container.getContainerId(),
SchedulerUtils.COMPLETED_APPLICATION),
RMContainerEventType.KILL);
}
// Clean up pending requests, metrics etc.
application.stop(rmAppAttemptFinalState);
// Remove the application
applications.remove(applicationAttemptId);
}
/**
* Heart of the scheduler...
*
* @param node node on which resources are available to be allocated
*/
private void assignContainers(SchedulerNode node) {
LOG.debug("assignContainers:" +
" node=" + node.getRMNode().getNodeAddress() +
" #applications=" + applications.size());
// Try to assign containers to applications in fifo order
for (Map.Entry<ApplicationAttemptId, SchedulerApp> e : applications
.entrySet()) {
SchedulerApp application = e.getValue();
LOG.debug("pre-assignContainers");
application.showRequests();
synchronized (application) {
for (Priority priority : application.getPriorities()) {
int maxContainers =
getMaxAllocatableContainers(application, priority, node,
NodeType.OFF_SWITCH);
// Ensure the application needs containers of this priority
if (maxContainers > 0) {
int assignedContainers =
assignContainersOnNode(node, application, priority);
// Do not assign out of order w.r.t priorities
if (assignedContainers == 0) {
break;
}
}
}
}
application.setAvailableResourceLimit(clusterResource);
LOG.debug("post-assignContainers");
application.showRequests();
// Done
if (Resources.lessThan(node.getAvailableResource(), minimumAllocation)) {
return;
}
}
}
private int getMaxAllocatableContainers(SchedulerApp application,
Priority priority, SchedulerNode node, NodeType type) {
ResourceRequest offSwitchRequest =
application.getResourceRequest(priority, SchedulerNode.ANY);
int maxContainers = offSwitchRequest.getNumContainers();
if (type == NodeType.OFF_SWITCH) {
return maxContainers;
}
if (type == NodeType.RACK_LOCAL) {
ResourceRequest rackLocalRequest =
application.getResourceRequest(priority, node.getRMNode().getRackName());
if (rackLocalRequest == null) {
return maxContainers;
}
maxContainers = Math.min(maxContainers, rackLocalRequest.getNumContainers());
}
if (type == NodeType.NODE_LOCAL) {
ResourceRequest nodeLocalRequest =
application.getResourceRequest(priority, node.getRMNode().getNodeAddress());
if (nodeLocalRequest != null) {
maxContainers = Math.min(maxContainers, nodeLocalRequest.getNumContainers());
}
}
return maxContainers;
}
private int assignContainersOnNode(SchedulerNode node,
SchedulerApp application, Priority priority
) {
// Data-local
int nodeLocalContainers =
assignNodeLocalContainers(node, application, priority);
// Rack-local
int rackLocalContainers =
assignRackLocalContainers(node, application, priority);
// Off-switch
int offSwitchContainers =
assignOffSwitchContainers(node, application, priority);
LOG.debug("assignContainersOnNode:" +
" node=" + node.getRMNode().getNodeAddress() +
" application=" + application.getApplicationId().getId() +
" priority=" + priority.getPriority() +
" #assigned=" +
(nodeLocalContainers + rackLocalContainers + offSwitchContainers));
return (nodeLocalContainers + rackLocalContainers + offSwitchContainers);
}
private int assignNodeLocalContainers(SchedulerNode node,
SchedulerApp application, Priority priority) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(priority, node.getRMNode().getNodeAddress());
if (request != null) {
// Don't allocate on this node if we don't need containers on this rack
ResourceRequest rackRequest =
application.getResourceRequest(priority,
node.getRMNode().getRackName());
if (rackRequest == null || rackRequest.getNumContainers() <= 0) {
return 0;
}
int assignableContainers =
Math.min(
getMaxAllocatableContainers(application, priority, node,
NodeType.NODE_LOCAL),
request.getNumContainers());
assignedContainers =
assignContainer(node, application, priority,
assignableContainers, request, NodeType.NODE_LOCAL);
}
return assignedContainers;
}
private int assignRackLocalContainers(SchedulerNode node,
SchedulerApp application, Priority priority) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(priority, node.getRMNode().getRackName());
if (request != null) {
// Don't allocate on this rack if the application doens't need containers
ResourceRequest offSwitchRequest =
application.getResourceRequest(priority, SchedulerNode.ANY);
if (offSwitchRequest.getNumContainers() <= 0) {
return 0;
}
int assignableContainers =
Math.min(
getMaxAllocatableContainers(application, priority, node,
NodeType.RACK_LOCAL),
request.getNumContainers());
assignedContainers =
assignContainer(node, application, priority,
assignableContainers, request, NodeType.RACK_LOCAL);
}
return assignedContainers;
}
private int assignOffSwitchContainers(SchedulerNode node,
SchedulerApp application, Priority priority) {
int assignedContainers = 0;
ResourceRequest request =
application.getResourceRequest(priority, SchedulerNode.ANY);
if (request != null) {
assignedContainers =
assignContainer(node, application, priority,
request.getNumContainers(), request, NodeType.OFF_SWITCH);
}
return assignedContainers;
}
private int assignContainer(SchedulerNode node, SchedulerApp application,
Priority priority, int assignableContainers,
ResourceRequest request, NodeType type) {
LOG.debug("assignContainers:" +
" node=" + node.getRMNode().getNodeAddress() +
" application=" + application.getApplicationId().getId() +
" priority=" + priority.getPriority() +
" assignableContainers=" + assignableContainers +
" request=" + request + " type=" + type);
Resource capability = request.getCapability();
int availableContainers =
node.getAvailableResource().getMemory() / capability.getMemory(); // TODO: A buggy
// application
// with this
// zero would
// crash the
// scheduler.
int assignedContainers =
Math.min(assignableContainers, availableContainers);
if (assignedContainers > 0) {
for (int i=0; i < assignedContainers; ++i) {
NodeId nodeId = node.getRMNode().getNodeID();
ContainerId containerId = BuilderUtils.newContainerId(application
.getApplicationAttemptId(), application.getNewContainerId());
ContainerToken containerToken = null;
// If security is enabled, send the container-tokens too.
if (UserGroupInformation.isSecurityEnabled()) {
ContainerTokenIdentifier tokenIdentifier = new ContainerTokenIdentifier(
containerId, nodeId.toString(), capability);
containerToken = BuilderUtils.newContainerToken(nodeId, ByteBuffer
.wrap(containerTokenSecretManager
.createPassword(tokenIdentifier)), tokenIdentifier);
}
// Create the container
Container container = BuilderUtils.newContainer(containerId, nodeId,
node.getRMNode().getHttpAddress(), capability, priority,
containerToken);
// Allocate!
// Inform the application
RMContainer rmContainer =
application.allocate(type, node, priority, request, container);
// Inform the node
node.allocateContainer(application.getApplicationId(),
rmContainer);
}
// Update total usage
Resources.addTo(usedResource,
Resources.multiply(capability, assignedContainers));
}
return assignedContainers;
}
private synchronized void nodeUpdate(RMNode rmNode,
List<ContainerStatus> newlyLaunchedContainers,
List<ContainerStatus> completedContainers) {
SchedulerNode node = getNode(rmNode.getNodeID());
// Processing the newly launched containers
for (ContainerStatus launchedContainer : newlyLaunchedContainers) {
containerLaunchedOnNode(launchedContainer.getContainerId(), node);
}
// Process completed containers
for (ContainerStatus completedContainer : completedContainers) {
ContainerId containerId = completedContainer.getContainerId();
LOG.debug("Container FINISHED: " + containerId);
containerCompleted(getRMContainer(containerId),
completedContainer, RMContainerEventType.FINISHED);
}
if (Resources.greaterThanOrEqual(node.getAvailableResource(),
minimumAllocation)) {
LOG.info("Node heartbeat " + rmNode.getNodeID() +
" available resource = " + node.getAvailableResource());
assignContainers(node);
LOG.info("Node after allocation " + rmNode.getNodeID() + " resource = "
+ node.getAvailableResource());
}
metrics.setAvailableResourcesToQueue(
Resources.subtract(clusterResource, usedResource));
}
@Override
public void handle(SchedulerEvent event) {
switch(event.getType()) {
case NODE_ADDED:
{
NodeAddedSchedulerEvent nodeAddedEvent = (NodeAddedSchedulerEvent)event;
addNode(nodeAddedEvent.getAddedRMNode());
}
break;
case NODE_REMOVED:
{
NodeRemovedSchedulerEvent nodeRemovedEvent = (NodeRemovedSchedulerEvent)event;
removeNode(nodeRemovedEvent.getRemovedRMNode());
}
break;
case NODE_UPDATE:
{
NodeUpdateSchedulerEvent nodeUpdatedEvent =
(NodeUpdateSchedulerEvent)event;
nodeUpdate(nodeUpdatedEvent.getRMNode(),
nodeUpdatedEvent.getNewlyLaunchedContainers(),
nodeUpdatedEvent.getCompletedContainers());
}
break;
case APP_ADDED:
{
AppAddedSchedulerEvent appAddedEvent = (AppAddedSchedulerEvent) event;
addApplication(appAddedEvent.getApplicationAttemptId(), appAddedEvent
.getUser());
}
break;
case APP_REMOVED:
{
AppRemovedSchedulerEvent appRemovedEvent = (AppRemovedSchedulerEvent)event;
try {
doneApplication(appRemovedEvent.getApplicationAttemptID(),
appRemovedEvent.getFinalAttemptState());
} catch(IOException ie) {
LOG.error("Unable to remove application "
+ appRemovedEvent.getApplicationAttemptID(), ie);
}
}
break;
case CONTAINER_EXPIRED:
{
ContainerExpiredSchedulerEvent containerExpiredEvent =
(ContainerExpiredSchedulerEvent) event;
ContainerId containerid = containerExpiredEvent.getContainerId();
containerCompleted(getRMContainer(containerid),
SchedulerUtils.createAbnormalContainerStatus(
containerid,
SchedulerUtils.EXPIRED_CONTAINER),
RMContainerEventType.EXPIRE);
}
break;
default:
LOG.error("Invalid eventtype " + event.getType() + ". Ignoring!");
}
}
private void containerLaunchedOnNode(ContainerId containerId, SchedulerNode node) {
// Get the application for the finished container
ApplicationAttemptId applicationAttemptId = containerId.getApplicationAttemptId();
SchedulerApp application = getApplication(applicationAttemptId);
if (application == null) {
LOG.info("Unknown application: " + applicationAttemptId +
" launched container " + containerId +
" on node: " + node);
return;
}
application.containerLaunchedOnNode(containerId);
}
@Lock(FifoScheduler.class)
private synchronized void containerCompleted(RMContainer rmContainer,
ContainerStatus containerStatus, RMContainerEventType event) {
if (rmContainer == null) {
LOG.info("Null container completed...");
return;
}
// Get the application for the finished container
Container container = rmContainer.getContainer();
ApplicationAttemptId applicationAttemptId = container.getId().getApplicationAttemptId();
SchedulerApp application = getApplication(applicationAttemptId);
// Get the node on which the container was allocated
SchedulerNode node = getNode(container.getNodeId());
if (application == null) {
LOG.info("Unknown application: " + applicationAttemptId +
" released container " + container.getId() +
" on node: " + node +
" with event: " + event);
return;
}
// Inform the application
application.containerCompleted(rmContainer, containerStatus, event);
// Inform the node
node.releaseContainer(container);
// Update total usage
Resources.subtractFrom(usedResource, container.getResource());
LOG.info("Application " + applicationAttemptId +
" released container " + container.getId() +
" on node: " + node +
" with event: " + event);
}
private Resource clusterResource = recordFactory.newRecordInstance(Resource.class);
private Resource usedResource = recordFactory.newRecordInstance(Resource.class);
private synchronized void removeNode(RMNode nodeInfo) {
SchedulerNode node = getNode(nodeInfo.getNodeID());
// Kill running containers
for(RMContainer container : node.getRunningContainers()) {
containerCompleted(container,
SchedulerUtils.createAbnormalContainerStatus(
container.getContainerId(),
SchedulerUtils.LOST_CONTAINER),
RMContainerEventType.KILL);
}
//Remove the node
this.nodes.remove(nodeInfo.getNodeID());
// Update cluster metrics
Resources.subtractFrom(clusterResource, nodeInfo.getTotalCapability());
}
@Override
public QueueInfo getQueueInfo(String queueName,
boolean includeChildQueues, boolean recursive) {
return DEFAULT_QUEUE.getQueueInfo(false, false);
}
@Override
public List<QueueUserACLInfo> getQueueUserAclInfo() {
return DEFAULT_QUEUE.getQueueUserAclInfo(null);
}
private synchronized void addNode(RMNode nodeManager) {
this.nodes.put(nodeManager.getNodeID(), new SchedulerNode(nodeManager));
Resources.addTo(clusterResource, nodeManager.getTotalCapability());
}
@Override
public void recover(RMState state) {
// TODO fix recovery
// for (Map.Entry<ApplicationId, ApplicationInfo> entry: state.getStoredApplications().entrySet()) {
// ApplicationId appId = entry.getKey();
// ApplicationInfo appInfo = entry.getValue();
// SchedulerApp app = applications.get(appId);
// app.allocate(appInfo.getContainers());
// }
}
@Override
public synchronized SchedulerNodeReport getNodeReport(NodeId nodeId) {
SchedulerNode node = getNode(nodeId);
return node == null ? null : new SchedulerNodeReport(node);
}
private RMContainer getRMContainer(ContainerId containerId) {
SchedulerApp application =
getApplication(containerId.getApplicationAttemptId());
return (application == null) ? null : application.getRMContainer(containerId);
}
@Override
public QueueMetrics getRootQueueMetrics() {
return DEFAULT_QUEUE.getMetrics();
}
}
| [
"[email protected]"
] | |
fedefb9b608a6351a63e12cf8f94dc62d60c7754 | 795e565abdcdddf1a80a4ad6b08f737cc407971b | /UltimateTicTacToe/webapp/test/terd/web/RegistrarJugador.java | 039fed9c61d5023490ca2a4de1a801574e2f8737 | [] | no_license | ruben11291/iso_rmi | a49fb20b3260a5e922e1e1d0035d92b160d3fdc2 | f787844ae513c5bfcae1dca66030f3fda96996ca | refs/heads/master | 2021-01-20T01:57:21.567733 | 2014-06-03T12:04:46 | 2014-06-03T12:04:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,068 | java | package terd.web;
import com.thoughtworks.selenium.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.regex.Pattern;
public class RegistrarJugador {
private Selenium selenium;
@Before
public void setUp() throws Exception {
FuncionesAuxiliaresTests.borrarBD();
selenium = new DefaultSelenium("localhost", 4444, "*chrome", "http://127.0.0.1:8888/");
selenium.start();
}
@Test
public void testRegistrarJugador() throws Exception {
selenium.open("/UltimateTicTacToeWeb.html");
selenium.type("css=#emailRegistro > input.gwt-TextBox", "macario2");
selenium.type("css=#passwordRegistro > input.gwt-PasswordTextBox", "macario2");
selenium.type("css=#repPasswordRegistro > input.gwt-PasswordTextBox", "macario2");
selenium.click("css=#registerButton > button.myButton");
Thread.sleep(30000);
assertEquals("Usuario registrado", selenium.getAlert());
}
@After
public void tearDown() throws Exception {
selenium.stop();
FuncionesAuxiliaresTests.borrarBD();
}
}
| [
"[email protected]"
] | |
f4727a87f0a9010510980bf503e412a9dba2cae1 | 57717c95aa1951a3844beb4f0814ce2e99ff8d71 | /src/main/Example12.java | 30e6ca3239b399ab8e43f17a7b4a89418596de83 | [] | no_license | happymff/ExampleSwing | 536eb81d5e96d7b04288a3163f5325373aac894f | 4116db61fa4823aaa479fcd437be056e843d3f39 | refs/heads/master | 2021-08-07T16:15:35.071975 | 2017-11-08T14:24:20 | 2017-11-08T14:24:20 | 109,925,677 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,417 | java | package main;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Created by mengfeifei on 2017/11/8.
*/
public class Example12 extends JFrame {
private JCheckBox italic;
private JCheckBox bold;
private JLabel label;
public Example12(){
label = new JLabel("Welcome!!!",JLabel.CENTER);
label.setFont(new Font("宋体", Font.PLAIN,20));
this.add(label);
JPanel panel = new JPanel();
italic = new JCheckBox("ITALIC");
bold = new JCheckBox("BOLD");
ActionListener listener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
int mode = 0;
if (bold.isSelected()){
mode += Font.BOLD;
}
if (italic.isSelected()){
mode +=Font.ITALIC;
}
label.setFont(new Font("宋体",mode,20));
}
};
italic.addActionListener(listener);
bold.addActionListener(listener);
panel.add(italic);
panel.add(bold);
this.add(panel,BorderLayout.SOUTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(300,300);
this.setVisible(true);
}
public static void main(String [] args){
new Example12();
}
}
| [
"[email protected]"
] | |
e4a90c2d7ae9034184818e0ce35c1af17c1da4db | f157376f27283708fa7be8004e1fdb3c487ae4ef | /src/test/java/com/spring/demon/AppTest.java | 56306c40ddce35809c5010f9d6f77b569bf211c1 | [] | no_license | neokhub/Demon | a6ce1065a67bd001dd4cba1baf7f7ab94b961348 | 95ade23155b5ed6dd34954cd8fc75c8733b63992 | refs/heads/master | 2020-03-24T18:12:29.757020 | 2018-07-30T15:07:12 | 2018-07-30T15:07:12 | 142,886,391 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 644 | java | package com.spring.demon;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
| [
"neok"
] | neok |
dbf723747158b4d45e8b3e179d8a4bbe51a96dac | 4efd04835eda5a73953e389781b9c23bed5c0a9e | /trunk/src/lff/jtxt2pdf/GUIMain.java | 5e5c37d929a959493f70a9fc1c3afcd3ef4c315d | [] | no_license | BackupTheBerlios/jtxt2pdf-svn | 3a08f21c0540f0c3aca571d6035a6063606d7dd4 | 66d782b8a64ce721018fd1f1fb2601c89d9bc998 | refs/heads/master | 2021-03-12T20:07:29.143863 | 2009-12-30T07:26:57 | 2009-12-30T07:26:57 | 40,824,389 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 926 | java | package lff.jtxt2pdf;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import com.jgoodies.looks.plastic.PlasticLookAndFeel;
import lff.jtxt2pdf.gui.MainDialog;
public class GUIMain {
/**
* @param args
*/
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(new PlasticLookAndFeel());
} catch (UnsupportedLookAndFeelException e) {
e.printStackTrace();
}
MainDialog md = new MainDialog();
center(md);
md.setModal(true);
md.setResizable(false);
md.setVisible(true);
}
private static void center(MainDialog md) {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int width = screenSize.width;
int height = screenSize.height;
md.setLocation(width / 2 - md.getWidth() /2 , height / 2 - md.getHeight() / 2);
}
}
| [
"lff0305@c0d01664-9066-0410-b033-ce0f998aba7b"
] | lff0305@c0d01664-9066-0410-b033-ce0f998aba7b |
e7b35d19833d445744a11801c05f3339834289f3 | 2e871f255bcf4f03af16400341b3a284af60d2bd | /src/com/smit/web/LanguageSelectAction.java | c6f6426c447d7655484ac33f2a2c2b81370301b5 | [] | no_license | RyanFu/cmsserver | 67b6ea4eaf2f70c57a2161d9c0a479f03ea5c7a8 | 957cd1e739a1a184d625150889e3ff16ee0873e1 | refs/heads/master | 2020-12-25T08:50:35.874902 | 2011-12-29T05:31:05 | 2011-12-29T05:31:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,551 | java | package com.smit.web;
import java.util.Locale;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.Globals;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
public class LanguageSelectAction extends DispatchAction {
public ActionForward chinese(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, Locale.SIMPLIFIED_CHINESE);
return mapping.findForward("success");
}
public ActionForward english(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, Locale.ENGLISH);
return mapping.findForward("success");
}
public ActionForward german(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, Locale.GERMAN);
return mapping.findForward("success");
}
public ActionForward france(ActionMapping mapping,ActionForm form,
HttpServletRequest request,HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, Locale.FRANCE);
return mapping.findForward("success");
}
}
| [
"USER@.(none)"
] | USER@.(none) |
76353aebca40067c3df55822cf8110ec8c0be1dc | ddea8d9baada2df6073bc32322d4806226d95f81 | /UDEMY_102_INTERFACE_V2/src/Buty.java | bcdca3f4f1f3cfeec488fd1aff05c2c38be5274d | [] | no_license | elhose/Java-8-Tutorial-by-Tim-Buchalka | b2f754132154bdc08c398e764b408f4a34aca6af | 40d2be222641699e26aedb79f7a82896e8b60fca | refs/heads/master | 2020-05-27T15:49:27.136045 | 2019-05-26T17:04:22 | 2019-05-26T17:04:22 | 188,686,988 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 634 | java | import java.util.ArrayList;
import java.util.List;
public class Buty implements ISaveable {
private List<String> listaButow = new ArrayList();
private String kolor;
private int rozmiar;
private String firma;
public Buty() {
}
@Override
public List getFiles() {
return null;
}
@Override
public void saveFiles(List lista) {
}
@Override
public String toString() {
String buty=null;
for (int i=0;i<listaButow.size();i++){
buty = buty + " , " +listaButow.get(i);
}
return buty;
}
}
| [
"[email protected]"
] | |
43170d1cfbad339cdfc540b32f58996f7f9eefe9 | fa8485189924403644e4192f6a64704c13aec565 | /weixinCourse/src/org/xiaowu/course/message/req/LocationMessage.java | f1436ed031fd31afef03dfb40935558d6015c30d | [] | no_license | xiaowu135/weixin | 886e381eeee9b1cd10d40d20d3ea941d6b1fc273 | e4ed731f2ad8137f61b5fd156252481f90c7103c | refs/heads/master | 2021-07-10T01:20:06.089852 | 2017-10-10T13:02:44 | 2017-10-10T13:02:44 | 106,417,508 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 775 | java | package org.xiaowu.course.message.req;
public class LocationMessage extends BaseMessage {
// 地理位置维度
private String Location_X;
// 地理位置经度
private String Location_Y;
// 地图缩放大小
private String Scale;
// 地理位置信息
private String Label;
public String getLocation_X() {
return Location_X;
}
public void setLocation_X(String location_X) {
Location_X = location_X;
}
public String getLocation_Y() {
return Location_Y;
}
public void setLocation_Y(String location_Y) {
Location_Y = location_Y;
}
public String getScale() {
return Scale;
}
public void setScale(String scale) {
Scale = scale;
}
public String getLabel() {
return Label;
}
public void setLabel(String label) {
Label = label;
}
}
| [
"[email protected]"
] | |
02e6a0f4907440adeac5ce72b288889c652c9153 | a3f3dbb751fc2915ab864b15c845ea78a9120974 | /src/main/java/com/xust/controller/JudgeController.java | 120e5552cfbb7befcb1330f5a7b1308d3b5be0e8 | [] | no_license | lihaoqiang001/xust-coal-minesafety | 75b54384d5f99d04f2e7b981bd60f66cf594a311 | ab7d777d029276b6585711327393da385799dfaa | refs/heads/master | 2020-03-27T09:14:56.529794 | 2018-08-29T10:43:56 | 2018-08-29T10:43:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,426 | java | package com.xust.controller;
import com.xust.po.ConfigurationPo;
import com.xust.service.JudgeService;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.converter.json.MappingJacksonValue;
import org.springframework.web.bind.annotation.*;
/**
* Created by 10045 on 2018/5/27.
*/
@RestController
@RequestMapping(value = "/judge")
@MapperScan(basePackages = "com.xust.dao")
public class JudgeController {
@Autowired
private JudgeService judgeService;
@GetMapping(value = "/info")
public Object getInfo(String callback){
ConfigurationPo configurationPo = judgeService.getinfo();
configurationPo.setCallback(callback);
MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(configurationPo);
mappingJacksonValue.setJsonpFunction(callback);
System.out.println("success11");
return mappingJacksonValue;
}
/**
*智能评判四大功能
*/
@GetMapping(value = "/info1")
public Object updateInfo(ConfigurationPo configurationPo){
judgeService.updateInfo(configurationPo);
MappingJacksonValue mappingJacksonValue = new MappingJacksonValue(configurationPo);
mappingJacksonValue.setJsonpFunction(configurationPo.getCallback());
System.out.println("success11");
return mappingJacksonValue;
}
}
| [
"[email protected]"
] | |
a13f5a88d433664da650a205d83813e261083ec9 | ba15434ee43824b7f7933f507bd9829ed840d3a6 | /sucursales-ventabook/src/java/modelo/Venta.java | d0801698e45d5f6c541a798a65e2d5a36e37eac8 | [] | no_license | stngarcia8/EjercicioIntegracionDePlataformas | 14fc61478fba00d96a51f1abd69013da22c096b5 | d69d1db168cf31371ddfb96ea0a3cf19ec60bcf9 | refs/heads/master | 2022-11-27T20:00:15.161220 | 2020-08-07T17:38:17 | 2020-08-07T17:38:17 | 285,887,441 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,490 | java | package modelo;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
/**
* @author asathor
*/
@Entity
@Table(name = "VENTA", catalog = "", schema = "VENTABOOK_USR")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Venta.findAll", query = "SELECT v FROM Venta v")
, @NamedQuery(name = "Venta.findByIdVenta", query = "SELECT v FROM Venta v WHERE v.idVenta = :idVenta")
, @NamedQuery(name = "Venta.findByFechaVenta", query = "SELECT v FROM Venta v WHERE v.fechaVenta = :fechaVenta")
, @NamedQuery(name = "Venta.findByRutcliente", query = "SELECT v FROM Venta v WHERE v.rutcliente = :rutcliente")
, @NamedQuery(name = "Venta.findByNombrecliente", query = "SELECT v FROM Venta v WHERE v.nombrecliente = :nombrecliente")
, @NamedQuery(name = "Venta.findByRazonsocialFactura", query = "SELECT v FROM Venta v WHERE v.razonsocialFactura = :razonsocialFactura")
, @NamedQuery(name = "Venta.findByRutFactura", query = "SELECT v FROM Venta v WHERE v.rutFactura = :rutFactura")
, @NamedQuery(name = "Venta.findByDireccionFactura", query = "SELECT v FROM Venta v WHERE v.direccionFactura = :direccionFactura")
, @NamedQuery(name = "Venta.findByGiroFactura", query = "SELECT v FROM Venta v WHERE v.giroFactura = :giroFactura")
, @NamedQuery(name = "Venta.findByContactoFactura", query = "SELECT v FROM Venta v WHERE v.contactoFactura = :contactoFactura")
, @NamedQuery(name = "Venta.findByCiudadFactura", query = "SELECT v FROM Venta v WHERE v.ciudadFactura = :ciudadFactura")})
public class Venta implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@Size(min = 1, max = 36)
@Column(name = "ID_VENTA", nullable = false, length = 36)
private String idVenta;
@Basic(optional = false)
@NotNull
@Column(name = "FECHA_VENTA", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date fechaVenta;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(name = "RUTCLIENTE", nullable = false, length = 10)
private String rutcliente;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "NOMBRECLIENTE", nullable = false, length = 50)
private String nombrecliente;
@Size(max = 80)
@Column(name = "RAZONSOCIAL_FACTURA", length = 80)
private String razonsocialFactura;
@Size(max = 10)
@Column(name = "RUT_FACTURA", length = 10)
private String rutFactura;
@Size(max = 100)
@Column(name = "DIRECCION_FACTURA", length = 100)
private String direccionFactura;
@Size(max = 50)
@Column(name = "GIRO_FACTURA", length = 50)
private String giroFactura;
@Size(max = 50)
@Column(name = "CONTACTO_FACTURA", length = 50)
private String contactoFactura;
@Size(max = 20)
@Column(name = "CIUDAD_FACTURA", length = 20)
private String ciudadFactura;
@JoinColumn(name = "ID_TIPO_DOC", referencedColumnName = "ID_TIPO_DOC", nullable = false)
@ManyToOne(optional = false)
private TipoDoc idTipoDoc;
@JoinColumn(name = "ID_USUARIO", referencedColumnName = "ID_USUARIO", nullable = false)
@ManyToOne(optional = false)
private Usuario idUsuario;
@OneToMany(cascade = CascadeType.ALL, mappedBy = "venta")
private List<DetVenta> detVentaList;
public Venta() {
this.idVenta = UUID.randomUUID().toString();
this.fechaVenta = new Date();
this.limpiarDatosFacturacion();
this.detVentaList = new ArrayList<>();
}
public Venta(String idVenta) {
this.idVenta = idVenta;
}
public Venta(String idVenta, Date fechaVenta, String rutcliente, String nombrecliente) {
this.idVenta = idVenta;
this.fechaVenta = fechaVenta;
this.rutcliente = rutcliente;
this.nombrecliente = nombrecliente;
}
public String getIdVenta() {
return idVenta;
}
public void setIdVenta(String idVenta) {
this.idVenta = idVenta;
}
public Date getFechaVenta() {
return fechaVenta;
}
public void setFechaVenta(Date fechaVenta) {
this.fechaVenta = fechaVenta;
}
public String getRutcliente() {
return rutcliente;
}
public void setRutcliente(String rutcliente) {
this.rutcliente = rutcliente;
}
public String getNombrecliente() {
return nombrecliente;
}
public void setNombrecliente(String nombrecliente) {
this.nombrecliente = nombrecliente;
}
public String getRazonsocialFactura() {
return razonsocialFactura;
}
public void setRazonsocialFactura(String razonsocialFactura) {
this.razonsocialFactura = razonsocialFactura;
}
public String getRutFactura() {
return rutFactura;
}
public void setRutFactura(String rutFactura) {
this.rutFactura = rutFactura;
}
public String getDireccionFactura() {
return direccionFactura;
}
public void setDireccionFactura(String direccionFactura) {
this.direccionFactura = direccionFactura;
}
public String getGiroFactura() {
return giroFactura;
}
public void setGiroFactura(String giroFactura) {
this.giroFactura = giroFactura;
}
public String getContactoFactura() {
return contactoFactura;
}
public void setContactoFactura(String contactoFactura) {
this.contactoFactura = contactoFactura;
}
public String getCiudadFactura() {
return ciudadFactura;
}
public void setCiudadFactura(String ciudadFactura) {
this.ciudadFactura = ciudadFactura;
}
public TipoDoc getIdTipoDoc() {
return idTipoDoc;
}
public void setIdTipoDoc(TipoDoc idTipoDoc) {
this.idTipoDoc = idTipoDoc;
}
public Usuario getIdUsuario() {
return idUsuario;
}
public void setIdUsuario(Usuario idUsuario) {
this.idUsuario = idUsuario;
}
@XmlTransient
public List<DetVenta> getDetVentaList() {
return detVentaList;
}
public void setDetVentaList(List<DetVenta> detVentaList) {
this.detVentaList = detVentaList;
}
@Override
public int hashCode() {
int hash = 0;
hash += (idVenta != null ? idVenta.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof Venta)) {
return false;
}
Venta other = (Venta) object;
if ((this.idVenta == null && other.idVenta != null) || (this.idVenta != null && !this.idVenta.equals(other.idVenta))) {
return false;
}
return true;
}
public void agregarDetalle(DetVenta miDetalle) {
this.detVentaList.add(miDetalle);
}
public void removerDetalle(DetVenta miDetalle) {
this.detVentaList.remove(miDetalle);
}
public void limpiarDetalles() {
this.detVentaList.clear();
}
public void limpiarDatosFacturacion() {
this.razonsocialFactura = "";
this.rutFactura = "";
this.direccionFactura = "";
this.giroFactura = "";
this.contactoFactura = "";
this.ciudadFactura = "";
}
@Override
public String toString() {
return "modelo.Venta[ idVenta=" + idVenta + " ]";
}
}
| [
"[email protected]"
] | |
88916487f5fa6c36a149b8ac67a1e3d5720dd4ce | d457364f912cbb7ca83a196c4581dcb0f2de2747 | /app/src/main/java/com/diting/pingxingren/custom/PopWinSubmenu.java | b877ed8b5f6b1552da31ced512ca29b724568ffa | [] | no_license | 767954322/PXR | 748ad1fb729f1a923e6cd55ff81a60b51a82f3be | e1da0bafda03d24e0625e85a2efb1a41714196f3 | refs/heads/master | 2020-03-12T22:54:25.328313 | 2018-04-24T13:06:48 | 2018-04-24T13:06:48 | 130,855,762 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,306 | java | package com.diting.pingxingren.custom;
import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import com.diting.pingxingren.R;
import com.diting.pingxingren.activity.QRCodeActivity;
public class PopWinSubmenu extends PopupWindow implements View.OnClickListener {
private View mainView;
private LinearLayout layout_robot;
private LinearLayout layout_concern;
private LinearLayout layout_knowledge;
private LinearLayout layout_mime;
private LinearLayout layout_mail;
private Activity activity;
public PopWinSubmenu(Activity paramActivity, int paramInt1, int paramInt2) {
super(paramActivity);
this.activity = paramActivity;
//窗口布局
mainView = LayoutInflater.from(paramActivity).inflate(R.layout.popwin_submenu, null);
//平行人布局
layout_robot = ((LinearLayout) mainView.findViewById(R.id.layout_robot));
//关注布局
layout_concern = ((LinearLayout) mainView.findViewById(R.id.layout_concern));
//知识库布局
layout_knowledge = (LinearLayout) mainView.findViewById(R.id.layout_knowledge);
//个人中心布局
layout_mime = (LinearLayout) mainView.findViewById(R.id.layout_mime);
//站内消息布局
layout_mail = (LinearLayout) mainView.findViewById(R.id.layout_mail);
layout_robot.setOnClickListener(this);
//设置每个子布局的事件监听器
setContentView(mainView);
//设置宽度
setWidth(paramInt1);
//设置高度
setHeight(paramInt2);
//设置显示隐藏动画
setAnimationStyle(R.style.AnimTools);
//设置背景透明
setBackgroundDrawable(new ColorDrawable(0));
}
@Override
public void onClick(View v) {
switch (v.getId()){
case R.id.layout_robot:
dismiss();
activity.startActivity(new Intent(activity, QRCodeActivity.class));
break;
default:
break;
}
}
} | [
"[email protected]"
] | |
eb5a5a17897a29d77fb7ea419ae36ea9eacb2519 | 322dbd717d6262cfea913747f12807cee61cbebb | /src/database/DatabaseHandler.java | 76f3d84c237c5d36d3c598c689c90a338239a9ce | [] | no_license | sumanxrtha/NLIFD | 410f44874d3fb23d3ffc0d01896f4d7459cc5bd0 | 649e573f072df455bb744d449d8e888ad52b1a6c | refs/heads/master | 2023-05-04T07:29:51.224584 | 2021-05-17T09:14:09 | 2021-05-17T09:14:09 | 368,123,222 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,687 | java | package database;
import javafx.scene.control.Alert;
import java.sql.*;
public class DatabaseHandler {
// public static final String LOGIN_USER_CHECK_QUERY = "select *from registeredUser where user = ? and pass = ?";
public static Connection GetDatabaseConnection() {
Connection connection = null;
// Connection connection;
try {
// driver setup for database
// Class.forName("com.mysql.jdbc.Driver");
Class.forName(Util.DB_DRIVER);
connection = DriverManager.getConnection(Util.DB_URL, Util.DB_USER, Util.DB_PASS);
// System.out.println("connection successful");
} catch (ClassNotFoundException e) {
// e.getLocalizedMessage();
e.printStackTrace();
e.getMessage();
} catch (SQLException e) {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Database Connection Error");
alert.setHeaderText("Database cannot connection in your system");
alert.setContentText("Error in database connection");
alert.show();
e.printStackTrace();
// e.getLocalizedMessage();
}
return connection;
}
// close database connection
// always close database connecton after connecting sessions
public static void CloseConnection(Connection con) {
try {
if (con!=null) {
con.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
// is the use is valid or not checking valid user on database
public static boolean CheckLoginUser(String uname, String pass) {
Connection connection = GetDatabaseConnection();
// String checkQuery = "select * from registeredUser where user = ' "+uname+" ' and pass = ' "+pass+" ' ";
final String checkQuery = "select *from " +Util.USER_TABLE + " where " +Util.USERNAME + " = ? and " +Util.PASSWORD + " = ?";
PreparedStatement preparedStatement;
boolean status = false; //initially false
try {
preparedStatement = connection.prepareStatement(checkQuery);
preparedStatement.setString(1, uname); // dynamically sending username
preparedStatement.setString(2, pass); // sending password to checkquery statement
ResultSet resultSet = preparedStatement.executeQuery();
/* while (resultSet.next()) {
return status;
} */
status = resultSet.next();
preparedStatement.close();
return status;
// DatabaseHandler.CloseConnection(connection);
} catch (SQLException e) {
// e.getLocalizedMessage();
e.printStackTrace();
}
return status;
// closing db connection here
// connection.close();
}
public static boolean registerAccount(String username, String password) {
Connection connection = GetDatabaseConnection();
PreparedStatement ps = null;
boolean status = false;
try {
// database table name should be validuser
ps = connection.prepareStatement("INSERT into validuser(user, pass) VALUES(?,?);");
ps.setString(1, username);
ps.setString(2, password);
// status = ps.execute();
int i = ps.executeUpdate();
if (i == 1) {
status = true;
}
ps.close();
// System.out.println(ps);
} catch (Exception e) {
System.out.println(e.getMessage());
}
return status;
}
}
| [
"[email protected]"
] | |
26a4056d37ea75d993eb8d87ac095b3c7b5df8ba | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/2/2_5153855f8108f94605738e7b82e239ddc5f828e3/DataTableGrouping/2_5153855f8108f94605738e7b82e239ddc5f828e3_DataTableGrouping_s.java | f39f2776cc24ce72b946d030560c5ae48113fade | [] | 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 | 4,388 | java | /*
* Copyright 2004-2012 ICEsoft Technologies Canada Corp.
*
* 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.icefaces.samples.showcase.example.ace.dataTable;
import org.icefaces.ace.component.datatable.DataTable;
import org.icefaces.samples.showcase.dataGenerators.utilityClasses.DataTableData;
import org.icefaces.samples.showcase.example.compat.dataTable.Car;
import org.icefaces.samples.showcase.metadata.annotation.ComponentExample;
import org.icefaces.samples.showcase.metadata.annotation.ExampleResource;
import org.icefaces.samples.showcase.metadata.annotation.ExampleResources;
import org.icefaces.samples.showcase.metadata.annotation.ResourceType;
import org.icefaces.samples.showcase.metadata.context.ComponentExampleImpl;
import javax.faces.application.Application;
import javax.faces.bean.CustomScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@ComponentExample(
parent = DataTableBean.BEAN_NAME,
title = "example.ace.dataTable.grouping.title",
description = "example.ace.dataTable.grouping.description",
example = "/resources/examples/ace/dataTable/dataTableGrouping.xhtml"
)
@ExampleResources(
resources ={
// xhtml
@ExampleResource(type = ResourceType.xhtml,
title="dataTableGrouping.xhtml",
resource = "/resources/examples/ace/dataTable/dataTableGrouping.xhtml"),
// Java Source
@ExampleResource(type = ResourceType.java,
title="DataTableGrouping.java",
resource = "/WEB-INF/classes/org/icefaces/samples/showcase"+
"/example/ace/dataTable/DataTableGrouping.java")
}
)
@ManagedBean(name= DataTableGrouping.BEAN_NAME)
@CustomScoped(value = "#{window}")
public class DataTableGrouping extends ComponentExampleImpl<DataTableGrouping> implements Serializable {
public static final String BEAN_NAME = "dataTableGrouping";
private DataTable table;
private List<Car> carsData;
/////////////---- CONSTRUCTOR BEGIN
public DataTableGrouping() {
super(DataTableGrouping.class);
carsData = new ArrayList<Car>(DataTableData.getDefaultData());
}
/////////////---- GETTERS & SETTERS BEGIN
public List<Car> getCarsData() { return carsData; }
public void setCarsData(List<Car> carsData) { this.carsData = carsData; }
public DataTable getTable() { return table; }
public void setTable(DataTable table) { this.table = table; }
/////////////---- METHOD INVOCATION VIA VIEW EL
public double groupTotal(String groupProperty, String valueProperty, Object i) {
// Fix for bugged method invocation in early TC7 releases
int index = (Integer) i;
double total = 0;
boolean nextRowInGroup = false;
FacesContext context = FacesContext.getCurrentInstance();
Application application = context.getApplication();
int currentIndex = table.getRowIndex();
table.setRowIndex(index);
Object groupValue = application.evaluateExpressionGet(context, "#{"+groupProperty+"}", Object.class);
do {
total += application.evaluateExpressionGet(context, "#{"+valueProperty+"}", Double.class);
table.setRowIndex(--index);
Object obj = application.evaluateExpressionGet(context, "#{"+groupProperty+"}", Object.class);
if (table.isRowAvailable() && groupValue.equals(obj))
nextRowInGroup = true;
else
nextRowInGroup = false;
} while (nextRowInGroup);
table.setRowIndex(currentIndex);
return 0.0;
}
}
| [
"[email protected]"
] | |
4a84a502b9a798796a4b6780bb8ab59dba210a84 | 3ea7ed3c1146df10479d1c1e3190e57932074e56 | /engine/src/main/java/org/apache/hop/trans/steps/fixedinput/FixedFileInputField.java | bab28f925816e5e9b6f40cb903bbc51e0774b0df | [
"Apache-2.0"
] | permissive | rhaces/hop | 66cc557f8317062dfc0f5b55a16a56ba38a74f32 | d6a189d5815020db325ecf08297cf42f5079f8d1 | refs/heads/master | 2020-12-09T13:01:10.778159 | 2020-01-10T16:14:36 | 2020-01-10T16:14:36 | 233,311,945 | 0 | 0 | null | 2020-01-11T23:33:40 | 2020-01-11T23:33:39 | null | UTF-8 | Java | false | false | 14,823 | java | /*! ******************************************************************************
*
* Pentaho Data Integration
*
* Copyright (C) 2002-2017 by Hitachi Vantara : http://www.pentaho.com
*
*******************************************************************************
*
* 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.apache.hop.trans.steps.fixedinput;
import org.apache.hop.core.Const;
import org.apache.hop.core.row.ValueMetaInterface;
import org.apache.hop.core.row.value.ValueMetaFactory;
import org.apache.hop.core.row.value.ValueMetaString;
import org.apache.hop.core.xml.XMLHandler;
import org.apache.hop.core.xml.XMLInterface;
import org.w3c.dom.Node;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
public class FixedFileInputField implements Cloneable, XMLInterface {
public static final String XML_TAG = "field";
private static final String[] date_formats = new String[] {
"yyyy/MM/dd HH:mm:ss.SSS", "yyyy/MM/dd HH:mm:ss", "dd/MM/yyyy", "dd-MM-yyyy", "yyyy/MM/dd", "yyyy-MM-dd",
"yyyyMMdd", "ddMMyyyy", "d-M-yyyy", "d/M/yyyy", "d-M-yy", "d/M/yy", };
private static final String[] number_formats = new String[] {
"", "#", Const.DEFAULT_NUMBER_FORMAT, "0.00", "0000000000000", "###,###,###.#######",
"###############.###############", "#####.###############%", };
private String name;
private int type;
private int width;
private int length;
private int precision;
private String format;
private int trimType;
private String decimal;
private String grouping;
private String currency;
private String[] samples;
public FixedFileInputField( Node fnode ) {
name = XMLHandler.getTagValue( fnode, "name" );
type = ValueMetaFactory.getIdForValueMeta( XMLHandler.getTagValue( fnode, "type" ) );
format = XMLHandler.getTagValue( fnode, "format" );
trimType = ValueMetaString.getTrimTypeByCode( XMLHandler.getTagValue( fnode, "trim_type" ) );
currency = XMLHandler.getTagValue( fnode, "currency" );
decimal = XMLHandler.getTagValue( fnode, "decimal" );
grouping = XMLHandler.getTagValue( fnode, "group" );
width = Const.toInt( XMLHandler.getTagValue( fnode, "width" ), -1 );
length = Const.toInt( XMLHandler.getTagValue( fnode, "length" ), -1 );
precision = Const.toInt( XMLHandler.getTagValue( fnode, "precision" ), -1 );
}
public FixedFileInputField() {
type = ValueMetaInterface.TYPE_STRING;
length = -1;
precision = -1;
trimType = ValueMetaInterface.TRIM_TYPE_NONE;
}
/**
* For testing only.
*/
protected FixedFileInputField( String name ) {
this();
this.name = name;
}
@Override
public boolean equals( Object obj ) {
return name.equalsIgnoreCase( ( (FixedFileInputField) obj ).name );
}
@Override
public int hashCode() {
return Objects.hashCode( name );
}
public String getXML() {
StringBuilder retval = new StringBuilder( 300 );
retval.append( " " ).append( XMLHandler.openTag( XML_TAG ) ).append( Const.CR );
retval.append( " " ).append( XMLHandler.addTagValue( "name", name ) );
retval.append( " " ).append( XMLHandler.addTagValue( "type",
ValueMetaFactory.getValueMetaName( type ) ) );
retval.append( " " ).append( XMLHandler.addTagValue( "format", format ) );
retval.append( " " ).append(
XMLHandler.addTagValue( "trim_type", ValueMetaString.getTrimTypeCode( trimType ) ) );
retval.append( " " ).append( XMLHandler.addTagValue( "currency", currency ) );
retval.append( " " ).append( XMLHandler.addTagValue( "decimal", decimal ) );
retval.append( " " ).append( XMLHandler.addTagValue( "group", grouping ) );
retval.append( " " ).append( XMLHandler.addTagValue( "width", width ) );
retval.append( " " ).append( XMLHandler.addTagValue( "length", length ) );
retval.append( " " ).append( XMLHandler.addTagValue( "precision", precision ) );
retval.append( " " ).append( XMLHandler.closeTag( XML_TAG ) ).append( Const.CR );
return retval.toString();
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName( String name ) {
this.name = name;
}
/**
* @return the type
*/
public int getType() {
return type;
}
/**
* @param type the type to set
*/
public void setType( int type ) {
this.type = type;
}
/**
* @return the width
*/
public int getWidth() {
return width;
}
/**
* @param width the width to set
*/
public void setWidth( int width ) {
this.width = width;
}
/**
* @return the length
*/
public int getLength() {
return length;
}
/**
* @param length the length to set
*/
public void setLength( int length ) {
this.length = length;
}
/**
* @return the precision
*/
public int getPrecision() {
return precision;
}
/**
* @param precision the precision to set
*/
public void setPrecision( int precision ) {
this.precision = precision;
}
/**
* @return the format
*/
public String getFormat() {
return format;
}
/**
* @param format the format to set
*/
public void setFormat( String format ) {
this.format = format;
}
/**
* @return the decimal
*/
public String getDecimal() {
return decimal;
}
/**
* @param decimal the decimal to set
*/
public void setDecimal( String decimal ) {
this.decimal = decimal;
}
/**
* @return the grouping
*/
public String getGrouping() {
return grouping;
}
/**
* @param grouping the grouping to set
*/
public void setGrouping( String grouping ) {
this.grouping = grouping;
}
/**
* @return the currency
*/
public String getCurrency() {
return currency;
}
/**
* @param currency the currency to set
*/
public void setCurrency( String currency ) {
this.currency = currency;
}
public void setSamples( String[] samples ) {
this.samples = samples;
}
/**
* @return the samples
*/
public String[] getSamples() {
return samples;
}
public void guess() {
guessType();
}
public void guessType() {
NumberFormat nf = NumberFormat.getInstance();
DecimalFormat df = (DecimalFormat) nf;
DecimalFormatSymbols dfs = new DecimalFormatSymbols();
SimpleDateFormat daf = new SimpleDateFormat();
daf.setLenient( false );
// Start with a string...
type = ValueMetaInterface.TYPE_STRING;
// If we have no samples, we assume a String...
if ( samples == null ) {
return;
}
// ////////////////////////////
// DATES
// ////////////////////////////
// See if all samples can be transformed into a date...
int datefmt_cnt = date_formats.length;
boolean[] datefmt = new boolean[ date_formats.length ];
for ( int i = 0; i < date_formats.length; i++ ) {
datefmt[ i ] = true;
}
int datenul = 0;
for ( int i = 0; i < samples.length; i++ ) {
for ( int x = 0; x < date_formats.length; x++ ) {
if ( samples[ i ] == null || Const.onlySpaces( samples[ i ] ) || samples[ i ].length() == 0 ) {
datefmt[ x ] = false;
datefmt_cnt--;
}
if ( datefmt[ x ] ) {
try {
daf.applyPattern( date_formats[ x ] );
Date date = daf.parse( samples[ i ] );
Calendar cal = Calendar.getInstance();
cal.setTime( date );
int year = cal.get( Calendar.YEAR );
if ( year < 1800 || year > 2200 ) {
datefmt[ x ] = false; // Don't try it again in the future.
datefmt_cnt--; // One less that works..
}
} catch ( Exception e ) {
datefmt[ x ] = false; // Don't try it again in the future.
datefmt_cnt--; // One less that works..
}
}
}
}
// If it is a date, copy info over to the format etc. Then return with the info.
// If all samples where NULL values, we can't really decide what the type is.
// So we're certainly not going to take a date, just take a string in that case.
if ( datefmt_cnt > 0 && datenul != samples.length ) {
int first = -1;
for ( int i = 0; i < date_formats.length && first < 0; i++ ) {
if ( datefmt[ i ] ) {
first = i;
}
}
type = ValueMetaInterface.TYPE_DATE;
format = date_formats[ first ];
return;
}
// ////////////////////////////
// NUMBERS
// ////////////////////////////
boolean isnumber = true;
// Set decimal symbols to default
decimal = "" + dfs.getDecimalSeparator();
grouping = "" + dfs.getGroupingSeparator();
boolean[] numfmt = new boolean[ number_formats.length ];
int[] maxprecision = new int[ number_formats.length ];
for ( int i = 0; i < numfmt.length; i++ ) {
numfmt[ i ] = true;
maxprecision[ i ] = -1;
}
int numfmt_cnt = number_formats.length;
int numnul = 0;
for ( int i = 0; i < samples.length && isnumber; i++ ) {
boolean contains_dot = false;
boolean contains_comma = false;
String field = samples[ i ];
for ( int x = 0; x < field.length() && isnumber; x++ ) {
char ch = field.charAt( x );
if ( !Character.isDigit( ch )
&& ch != '.' && ch != ',' && ( ch != '-' || x > 0 ) && ch != 'E' && ch != 'e' // exponential
) {
isnumber = false;
numfmt_cnt = 0;
} else {
if ( ch == '.' ) {
contains_dot = true;
// containsDot = true;
}
if ( ch == ',' ) {
contains_comma = true;
// containsComma = true;
}
}
}
// If it's still a number, try to parse it as a double
if ( isnumber ) {
if ( contains_dot && !contains_comma ) {
// American style 174.5
dfs.setDecimalSeparator( '.' );
decimal = ".";
dfs.setGroupingSeparator( ',' );
grouping = ",";
} else if ( !contains_dot && contains_comma ) {
// European style 174,5
dfs.setDecimalSeparator( ',' );
decimal = ",";
dfs.setGroupingSeparator( '.' );
grouping = ".";
} else if ( contains_dot && contains_comma ) {
// Both appear!
// What's the last occurance: decimal point!
int idx_dot = field.indexOf( '.' );
int idx_com = field.indexOf( ',' );
if ( idx_dot > idx_com ) {
dfs.setDecimalSeparator( '.' );
decimal = ".";
dfs.setGroupingSeparator( ',' );
grouping = ",";
} else {
dfs.setDecimalSeparator( ',' );
decimal = ",";
dfs.setGroupingSeparator( '.' );
grouping = ".";
}
}
// Try the remaining possible number formats!
for ( int x = 0; x < number_formats.length; x++ ) {
if ( numfmt[ x ] ) {
boolean islong = true;
try {
int prec = -1;
// Try long integers first....
if ( !contains_dot && !contains_comma ) {
try {
Long.parseLong( field );
prec = 0;
} catch ( Exception e ) {
islong = false;
}
}
if ( !islong ) {
// Try the double
df.setDecimalFormatSymbols( dfs );
df.applyPattern( number_formats[ x ] );
double d = df.parse( field ).doubleValue();
prec = guessPrecision( d );
}
if ( prec > maxprecision[ x ] ) {
maxprecision[ x ] = prec;
}
} catch ( Exception e ) {
numfmt[ x ] = false; // Don't try it again in the future.
numfmt_cnt--; // One less that works..
}
}
}
}
}
// Still a number? Grab the result and return.
// If all sample strings are empty or represent NULL values we can't take a number as type.
if ( numfmt_cnt > 0 && numnul != samples.length ) {
int first = -1;
for ( int i = 0; i < number_formats.length && first < 0; i++ ) {
if ( numfmt[ i ] ) {
first = i;
}
}
type = ValueMetaInterface.TYPE_NUMBER;
format = number_formats[ first ];
precision = maxprecision[ first ];
// Wait a minute!!! What about Integers?
// OK, only if the precision is 0 and the length <19 (java long integer)
/*
* if (length<19 && precision==0 && !containsDot && !containsComma) { type=ValueMetaInterface.TYPE_INTEGER;
* decimalSymbol=""; groupSymbol=""; }
*/
return;
}
//
// Assume it's a string...
//
type = ValueMetaInterface.TYPE_STRING;
format = "";
precision = -1;
decimal = "";
grouping = "";
currency = "";
}
public static final int guessPrecision( double d ) {
int maxprec = 4;
double maxdiff = 0.00005;
// Make sure that 7.99995 == 8.00000
// This is usually a rounding error!
double diff = Math.abs( Math.floor( d ) - d );
if ( diff < maxdiff ) {
return 0; // nothing behind decimal point...
}
// System.out.println("d="+d+", diff="+diff);
// remainder: 12.345678 --> 0.345678
for ( int i = 1; i < maxprec; i++ ) { // cap off precision at a reasonable maximum
double factor = Math.pow( 10.0, i );
diff = Math.abs( Math.floor( d * factor ) - ( d * factor ) );
if ( diff < maxdiff ) {
return i;
}
// System.out.println("d="+d+", diff="+diff+", factor="+factor);
factor *= 10;
}
// Unknown length!
return -1;
}
public int getTrimType() {
return trimType;
}
public void setTrimType( int trimType ) {
this.trimType = trimType;
}
}
| [
"[email protected]"
] | |
d95fbd5d8ed7ff003c225f50c03389c70ca29e8c | d81d3b8ef37dc4ba0b4aa5de0c8dc61a21b356ee | /gmall-ums-interface/src/main/java/com/atguigu/gmall/ums/entity/MemberStatisticsInfoEntity.java | ce0c25c72710b4e44c7a3d5dff00203320bb72be | [
"Apache-2.0"
] | permissive | liangbin243533/gmall | 542f2830a40bef7598068b3eaf48b1b0a2ceef5f | c5ff7c039520efa5e20f50b7d73242ade19976e2 | refs/heads/master | 2023-06-10T13:02:57.755652 | 2021-07-05T07:49:02 | 2021-07-05T07:49:02 | 375,559,785 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,574 | java | package com.atguigu.gmall.ums.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.math.BigDecimal;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* 会员统计信息
*
* @author lixianfeng
* @email [email protected]
* @date 2021-06-11 18:31:45
*/
@ApiModel
@Data
@TableName("ums_member_statistics_info")
public class MemberStatisticsInfoEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
@TableId
@ApiModelProperty(name = "id",value = "id")
private Long id;
/**
* 会员id
*/
@ApiModelProperty(name = "memberId",value = "会员id")
private Long memberId;
/**
* 累计消费金额
*/
@ApiModelProperty(name = "consumeAmount",value = "累计消费金额")
private BigDecimal consumeAmount;
/**
* 累计优惠金额
*/
@ApiModelProperty(name = "couponAmount",value = "累计优惠金额")
private BigDecimal couponAmount;
/**
* 订单数量
*/
@ApiModelProperty(name = "orderCount",value = "订单数量")
private Integer orderCount;
/**
* 优惠券数量
*/
@ApiModelProperty(name = "couponCount",value = "优惠券数量")
private Integer couponCount;
/**
* 评价数
*/
@ApiModelProperty(name = "commentCount",value = "评价数")
private Integer commentCount;
/**
* 退货数量
*/
@ApiModelProperty(name = "returnOrderCount",value = "退货数量")
private Integer returnOrderCount;
/**
* 登录次数
*/
@ApiModelProperty(name = "loginCount",value = "登录次数")
private Integer loginCount;
/**
* 关注数量
*/
@ApiModelProperty(name = "attendCount",value = "关注数量")
private Integer attendCount;
/**
* 粉丝数量
*/
@ApiModelProperty(name = "fansCount",value = "粉丝数量")
private Integer fansCount;
/**
* 收藏的商品数量
*/
@ApiModelProperty(name = "collectProductCount",value = "收藏的商品数量")
private Integer collectProductCount;
/**
* 收藏的专题活动数量
*/
@ApiModelProperty(name = "collectSubjectCount",value = "收藏的专题活动数量")
private Integer collectSubjectCount;
/**
* 收藏的评论数量
*/
@ApiModelProperty(name = "collectCommentCount",value = "收藏的评论数量")
private Integer collectCommentCount;
/**
* 邀请的朋友数量
*/
@ApiModelProperty(name = "inviteFriendCount",value = "邀请的朋友数量")
private Integer inviteFriendCount;
}
| [
"[email protected]"
] | |
b9f0c3189ca9cbdd7df7d437ac64f63ce1e3f023 | 9f4682a1063bc1f3fd15489404e29dae1da21d3f | /src/main/java/com/sort/MergeSorting.java | 87ba250325d114655581033497da466e3ba4c86d | [] | no_license | V-trigger/Algorithm | 1c77b94f0932c75761cb6cd6c6b5957975d34b15 | 4777a9b53604588d8a193025f94542fbdca49391 | refs/heads/master | 2023-04-24T05:23:30.291405 | 2020-09-29T16:03:35 | 2020-09-29T16:03:35 | 285,323,961 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,594 | java | package com.sort;
import java.util.Arrays;
import java.util.logging.Level;
public class MergeSorting {
public static void main(String[] args) {
int arr[] = new int[10000000];
for (int i = 0; i < 10000000; i++) {
arr[i] = (int) (Math.random() * 10000000);
}
int arr1[] = arr.clone();
System.out.println("迭代");
long l = System.currentTimeMillis();
mergeSort(arr);
System.out.println(System.currentTimeMillis() - l );
System.out.println(ToolSort.isSort(arr));
System.out.println("递归");
l = System.currentTimeMillis();
mergeSort1(arr1, 0, arr1.length-1);
System.out.println(System.currentTimeMillis() - l );
System.out.println(ToolSort.isSort(arr));
}
//合并两个有序序列
public static void merge(int arr[], int left, int mid, int right){
/**
* left左边序列开始索引, mid右边序列开始索引, right序列最后
*
* 思路:
* 创建一个临时数组
* 将left, mid对应的值中较小(大)的一个放到临时数组中
* 并将小(大)的一个值的索引后移
* 直到left移过最初mid的位置,说明左边元素已经全部放到了临时数组中
* 将此时mid到right的元素依次放到临时数组中
* 或者mid移过right, 说明右边元素已经全部放到了临时数组中
* 将left到最初mid的值依次放入临时数组中
* 此时两个有序序列就合并成了一个有序序列,并放到了临时数组中
* 将临时数组中的值放到最初left到right的位置,归并完成
*
*/
int temp[] = new int[right-left+1];
int l = left;
int m = mid++;
int index = 0;
while (index < temp.length){
if(mid > right){
//右边放完 把左边剩下的依次放入临时数组后面
temp[index] = arr[left++];
} else if(left > m){
//左边放完 把右边剩下的依次放入临时数组后面
temp[index] = arr[mid++];
} else {
//两边都没放完, 把小的依次放入临时数组后面
if(arr[left] <= arr[mid]){
temp[index] = arr[left++];
} else {
temp[index] = arr[mid++];
}
}
index++;
}
for (int i = l; i <= right; i++) {
arr[i] = temp[i-l];
}
}
//归并排序, 迭代
public static void mergeSort(int arr[]){
/**
*
* 思路:
* 将数组分成i个序列,i从1开始
* 将每两个序列当做一组进行归并
* 第一组为left = 0, mid = left+i-1, right = mid + i
* 第二组为left = 前一组的right+1, mid = left+i-1, right = mid + i
* 第三组 ...
* 归并完成后,数组就为两两有序的
* (如果right超出数组,right就为数组最后一个元素的索引)
*
* 将i规模扩大一倍再进行归并,数组变成四四有序
* ....
* 直到最后第一组right为整个序列的长度,再进行一次归并,序列变为全部有序
*
*
*/
int left, mid, right;
int len = arr.length;
for (int i = 1; i < len; i *= 2) {
left = 0;
while (left + i < len) {
mid = left + i - 1;
right = mid + i < len ? mid + i : len - 1;
merge(arr, left, mid, right);
left = right + 1;
}
}
}
//归并排序 递归
public static void mergeSort1(int arr[], int left, int right){
/**
*
* 思路:
* 将序列不断拆分成两个部分,分别归并
* 从left, mid, right(left从0开始, mid从(length + 0) / 2开始, right从序列最后一个索引开始)开始拆
* 拆成 (left, (mid + left) / 2, mid), (mid, (right+mid)/2, right)两组进行归并排序
* 直到最后left = right 说明序列已经拆分成了一个一个的,此时就进行归并
*/
if(left == right) return;
int mid = (left + right) / 2;
mergeSort1(arr, left, mid);
mergeSort1(arr, mid+1, right);
merge(arr, left, mid, right);
}
}
| [
"[email protected]"
] | |
5a7795365437cdb781abcc8d5d3f2d8705fa661c | 811d2f8bee008c7a00fff0fc23a0d60766645f12 | /src/main/java/org/rover/sdk/responses/effects/EffectResponse.java | 2c27b97f35ab51e603fdf125e1b5578a09656747 | [
"Apache-2.0"
] | permissive | hukumsingh87/rover-java-sdk | a7ad52b5a425d97596318dae964e9bcac686ce03 | 6cac7d0c8af00662062d47869cfa6d5931b917a0 | refs/heads/master | 2020-03-19T10:02:10.769018 | 2018-06-04T05:15:25 | 2018-06-04T05:15:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,427 | java | package org.rover.sdk.responses.effects;
import com.google.gson.annotations.SerializedName;
import org.rover.sdk.KeyPair;
import org.rover.sdk.responses.Link;
import org.rover.sdk.responses.Response;
/**
* Abstract class for effect responses.
* @see <a href="https://www.rover.network/developers/orbit/reference/resources/effect.html" target="_blank">Effect documentation</a>
* @see org.rover.sdk.requests.EffectsRequestBuilder
* @see org.rover.sdk.Server#effects()
*/
public abstract class EffectResponse extends Response {
@SerializedName("id")
protected String id;
@SerializedName("account")
protected KeyPair account;
@SerializedName("type")
protected String type;
@SerializedName("paging_token")
protected String pagingToken;
@SerializedName("_links")
private Links links;
public String getId() {
return id;
}
public KeyPair getAccount() {
return account;
}
/**
* <p>Returns effect type. Possible types:</p>
* <ul>
* <li>account_created</li>
* <li>account_removed</li>
* <li>account_credited</li>
* <li>account_debited</li>
* <li>account_thresholds_updated</li>
* <li>account_home_domain_updated</li>
* <li>account_flags_updated</li>
* <li>signer_created</li>
* <li>signer_removed</li>
* <li>signer_updated</li>
* <li>trustline_created</li>
* <li>trustline_removed</li>
* <li>trustline_updated</li>
* <li>trustline_authorized</li>
* <li>trustline_deauthorized</li>
* <li>offer_created</li>
* <li>offer_removed</li>
* <li>offer_updated</li>
* <li>trade</li>
* </ul>
*/
public String getType() {
return type;
}
public String getPagingToken() {
return pagingToken;
}
public Links getLinks() {
return links;
}
/**
* Represents effect links.
*/
public static class Links {
@SerializedName("operation")
private final Link operation;
@SerializedName("precedes")
private final Link precedes;
@SerializedName("succeeds")
private final Link succeeds;
public Links(Link operation, Link precedes, Link succeeds) {
this.operation = operation;
this.precedes = precedes;
this.succeeds = succeeds;
}
public Link getOperation() {
return operation;
}
public Link getPrecedes() {
return precedes;
}
public Link getSucceeds() {
return succeeds;
}
}
}
| [
"[email protected]"
] | |
979f56246010a7fbedf22ac3081508c676925e16 | e4261e43bdae9dbf64b64042e087c3836d1c2bc2 | /src/main/java/com/spark/sql/CrimeDataAnalytics.java | 0ffa75bbb0863b9a27dc9153320a7340a64f0857 | [] | no_license | ragnar-lothbrok/spark-demo | 173c50672c6cce02951345f0f4ab89c4a9801d9d | aded56213060ae5e908de268a0227b1a616a1462 | refs/heads/master | 2020-05-22T08:18:03.137861 | 2016-10-23T18:32:14 | 2016-10-23T18:32:14 | 64,554,087 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,208 | java | package com.spark.sql;
import java.util.function.ToDoubleFunction;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaSparkContext;
import org.apache.spark.api.java.function.Function;
import org.apache.spark.sql.DataFrame;
import org.apache.spark.sql.Row;
import org.apache.spark.sql.SQLContext;
//https://acadgild.com/blog/analyzing-new-york-crime-data-using-sparksql/
public class CrimeDataAnalytics {
public static void main(String[] args) {
SparkConf sparkConf = new SparkConf().setMaster("local[2]").setAppName("Crime Applciation");
JavaSparkContext javaSparkContext = new JavaSparkContext(sparkConf);
SQLContext sqlContext = new SQLContext(javaSparkContext);
DataFrame crimeDataFrame = sqlContext.read().format("com.databricks.spark.csv").option("inferSchema", "true").option("header", "false")
.load("/home/raghunandangupta/gitPro/spark-demo/inputfiles/Crime_dataset.csv");
crimeDataFrame.registerTempTable("crimes");
DataFrame crimesUnderFBI = sqlContext.sql("select C14,count(C14) from crimes group by C14");
crimesUnderFBI.show();
crimesUnderFBI = sqlContext.sql("select count(*) as count from crimes where C5 ='NARCOTICS' and C17 = 2015 ");
crimesUnderFBI.show();
crimesUnderFBI = sqlContext.sql("select C11 ,count(*) as count from crimes where C5 ='THEFT' and arrest = 'true' group by C11 ");
crimesUnderFBI.show();
double[] data = crimeDataFrame.select("C0").javaRDD().map(new Function<Row, Double>() {
@Override
public Double call(Row v1) throws Exception {
return ((double)v1.getInt(0));
}
}).collect().stream().mapToDouble(new ToDoubleFunction<Double>() {
@Override
public double applyAsDouble(Double value) {
return value;
}
}).toArray();
DescriptiveStatistics DescriptiveStatistics = new DescriptiveStatistics(data);
double meanQ1 = DescriptiveStatistics.getPercentile(25);
double mean = DescriptiveStatistics.getPercentile(50);
double meanQ3 = DescriptiveStatistics.getPercentile(75);
double meanQ2 = meanQ3 - meanQ1;
System.out.println(meanQ1+" "+meanQ2+" "+meanQ3+" "+mean);
System.out.println();
}
}
| [
"[email protected]"
] | |
9bc1c940ad3e9425221e897f4ee656db6dc9900c | 63f4e87dce0f44168a90f16de186f84662f46510 | /src/com/baotoan/dev/controller/CallbackServlet.java | 20846805899b2d777d74065582194c6c40859d00 | [] | no_license | clickyman1142/PerfumeStore | c8fd938a4ce2426311ebac4e1712e41f317cdf72 | 50f1bdebe369fc9d5270991b5d95ce9fabf1026f | refs/heads/master | 2021-06-08T01:59:17.192727 | 2016-11-24T11:09:29 | 2016-11-24T11:09:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,891 | java | package com.baotoan.dev.controller;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;
import com.baotoan.dev.dao.UserDAO;
import com.baotoan.dev.entity.User;
import com.baotoan.dev.service.UserDAOImpl;
@WebServlet("/CallbackServlet")
public class CallbackServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private UserDAO userDAO = new UserDAOImpl();
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
String code = request.getParameter("code");
String state = request.getParameter("state");
if (code != null && state != null) {
if (state.equals("123456789")) {
// Let's prepare our HTTP GET Request
String endPoint = "/v2.4/oauth/access_token";
Map<String, String> parameters = new HashMap<>();
parameters.put("client_id", "1527867264204402");
parameters.put("client_secret", "51ca05422c6a1f5a5dad77ddd70fab19");
parameters.put("redirect_uri", "http://localhost:8080/PerfumeStore/CallbackServlet");
parameters.put("code", code);
String result = HttpRequestHandler.execute(endPoint,
parameters, "GET");
if (result != null) {
// Let's extract the access token
try {
JSONParser parser = new JSONParser();
JSONObject jsonToken = (JSONObject) parser
.parse(result);
String accessToken = (String) jsonToken
.get("access_token");
// Long expires = (Long)jsonToken.get("expires_in");
// we now have a valid access and short-lived access
// token.
// let's use it to get some data from the user account:
endPoint = "/me";
parameters.clear();
parameters.put("fields", "id,first_name,last_name,gender,email");
parameters.put("access_token", accessToken);
result = HttpRequestHandler.execute(endPoint, parameters, "GET");
JSONObject jsonUserData = (JSONObject) parser.parse(result);
String id = (String) jsonUserData.get("id");
String firstName = (String) jsonUserData.get("first_name");
String lastName = (String) jsonUserData.get("last_name");
// String gender = (String) jsonUserData.get("gender");
String email = (String) jsonUserData.get("email");
// System.out.println(jsonUserData);
User user = new User();
user.setEmail(email);
user.setUsername("user_" + id);
user.setName(firstName + " " + lastName);
user.setStatus("actived");
user.setRegistryDate(new Date());
user.setRole(1);
user.setFBAcc(true);
HttpSession session = request.getSession();
if(userDAO.checkLogin(user.getUsername(), null, "facebook").equalsIgnoreCase("ok")) {
session.setAttribute("user", user);
response.sendRedirect("home.html");
} else {
if(userDAO.addUser(user)) {
session.setAttribute("user", user);
response.sendRedirect("home.html");
} else {
response.sendRedirect("registry.html");
}
}
} catch (ParseException e) {
e.printStackTrace();
}
} else {// There problem has occurred when processing the
// request
}
} else {// A third party has interfered into the login process
out.println("Something went wrong: The authorization process cannot continue...");
}
} else {
out.println("Something is going wrong...");
}
}
} | [
"[email protected]"
] | |
c83419dd9aab8fa34215317d251e421d8e644101 | bd1c198c0fcc44d64127d7fbf41135a5d9ba6b30 | /crocodile-main/src/main/java/cn/silently9527/crocodile/repository/databases/mapper/UserRoleMapper.java | 8efc19a0216c141415e1f98f28b585b6bf071925 | [
"Apache-2.0"
] | permissive | silently9527/crocodile-mini | 448fcbaedee3d9b0bd326c73b5a281c02611f8c8 | 7e062cd358263300352392a0be3a2e0ca69e7681 | refs/heads/master | 2023-07-19T06:59:50.547948 | 2021-09-06T16:03:28 | 2021-09-06T16:03:28 | 403,252,956 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 372 | java | package cn.silently9527.crocodile.repository.databases.mapper;
import cn.silently9527.crocodile.repository.databases.entity.UserRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* 系统用户角色关联表 Mapper 接口
* </p>
*
* @author starblues
* @since 2020-12-31
*/
public interface UserRoleMapper extends BaseMapper<UserRole> {
}
| [
"[email protected]"
] | |
66e79c475602eab258fb7eb6f5b108a47b904c59 | cc0d656aa9c228909182e640eed64926b1abbafe | /src/org/morph/bukget/commands/BukGetCommandResult.java | e6fd62689221295da61bc898b82ed2f6dc7f2ba9 | [] | no_license | NetMax/bukkit-plugin | 9005f591a276fb69ef61c2596f1f46234cce9a28 | a197aa15bc4f3d5208320cd12ed93a03b1f78443 | refs/heads/master | 2016-09-06T15:35:28.720044 | 2013-01-14T12:44:31 | 2013-01-14T12:44:31 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 276 | java | package org.morph.bukget.commands;
/**
* Every command returns a BukGetCommandResult after execution
* @author Morphesus
*/
public enum BukGetCommandResult {
SUCCESS,
INSUFFICIENT_ARGUMENTS,
ILLEGAL_ARGUMENT,
NO_PERMISSION,
FATAL_ERROR;
}
| [
"[email protected]"
] | |
2977fad794d236cd202f6eda33e090c4bf83634f | 45b93100a3d7de19c631deb301a97c48846880a2 | /Pong_Game/src/main/java/gui/GamePoints.java | b13e24aa6b06493e3d7e47e558f49fbddb1c951d | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | jgm1986/Pong_Game | dce2b184b2011245003f6c01bd2246ee91b7f25d | 078e10ff1d7b70e1b2f7280d626890cde6f0928a | refs/heads/master | 2016-08-10T17:49:14.263606 | 2015-12-07T11:32:23 | 2015-12-07T11:32:23 | 44,240,967 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,149 | java | /**
* Copyright 2015 Javier Gusano Martinez.
*
* 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 gui;
import java.awt.FlowLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
/**
* Panel points counter
* @author <a href="mailto:[email protected]">Javier Gusano Martinez</a>
*/
public final class GamePoints extends JPanel{
private int leftPoints;
private int rightPoints;
private final JLabel leftLabel;
private final JLabel rightLabel;
private final JButton rstPoints;
/**
* Default class constructor.
*/
public GamePoints(){
leftLabel = new JLabel(String.valueOf(leftPoints));
rightLabel = new JLabel(String.valueOf(rightPoints));
setLayout(new FlowLayout());
resetPoints();
// New Game Button
rstPoints = new JButton("Reset Marker");
rstPoints.setFocusable(false);
rstPoints.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent me) {
resetPoints();
}
@Override
public void mousePressed(MouseEvent me) {
// Nothing to do
}
@Override
public void mouseReleased(MouseEvent me) {
// Nothing to do
}
@Override
public void mouseEntered(MouseEvent me) {
// Nothing to do
}
@Override
public void mouseExited(MouseEvent me) {
// Nothing to do
}
});
// Add elements to the panel
add(new JLabel("Current points: "));
add(leftLabel);
add(new JLabel(" | "));
add(rightLabel);
add(new JLabel(" "));
add(rstPoints);
}
/**
* Set the marker points to zero.
*/
public void resetPoints(){
leftPoints = 0;
rightPoints = 0;
updateLabels();
}
/**
* Increase in one unit the points of left player.
*/
public void leftPoint(){
leftPoints++;
updateLabels();
}
/**
* Increase in one unit the points of left player.
*/
public void rightPoint(){
rightPoints++;
updateLabels();
}
/**
* Method used to update text labels on screen
*/
private void updateLabels(){
leftLabel.setText(String.valueOf(leftPoints));
rightLabel.setText(String.valueOf(rightPoints));
}
}
| [
"[email protected]"
] | |
201d37f51d06907f784e47c7bed96c58f24ff0fa | c7080f170e9a61b4a3052a54120d2c5ef3878acf | /domi-manager/domi-manager-service/src/main/java/com/domi/manager/service/ContentService.java | adfb4feef0a206c9e6e1e93a5408b6d18f395f55 | [] | no_license | kakajing/domi2.0 | 8f5757d9e784c982c3f21ed3287447cf2f541b76 | 10b6c253220a6dfdd5b4bee74180db9f5976dcab | refs/heads/master | 2021-01-04T02:41:40.303848 | 2017-02-17T16:23:07 | 2017-02-17T16:23:07 | 76,050,418 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 949 | java | package com.domi.manager.service;
import com.domi.common.bean.EasyUIResult;
import com.domi.manager.mapper.ContentMapper;
import com.domi.manager.pojo.Content;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* Author 卡卡
* Created by jing on 2016/12/22.
*/
@Service
public class ContentService extends BaseService<Content> {
@Autowired
private ContentMapper contentMapper;
public EasyUIResult queryListByCategoryId(Long categoryId, Integer page, Integer rows) {
PageHelper.startPage(page, rows);
List<Content> contents = this.contentMapper.queryListByCategoryId(categoryId, page, rows);
PageInfo<Content> pageInfo = new PageInfo<Content>(contents);
return new EasyUIResult(pageInfo.getTotal(), pageInfo.getList());
}
}
| [
"[email protected]"
] | |
db0d33c6fc29e0ead1788691bf3ad0cbf2db536c | 7c7b372820964545d29c2cb5d8a0f4e2b71d37b0 | /springcloud-library-product/src/main/java/com/spring/springcloudlibraryproduct/Config/WebSocketConfig.java | bd4e5f2ad4ef890e69cd20a136254897a6597437 | [] | no_license | lurkerhhh/library | 2724020900b2b026b52091cad12bf60d1cb01b88 | 99edcb1073da00de799292788d7e9f43b2f88c69 | refs/heads/master | 2022-06-21T02:19:35.670361 | 2019-06-25T06:12:39 | 2019-06-25T06:12:39 | 190,322,044 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,437 | java | package com.spring.springcloudlibraryproduct.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.web.socket.config.annotation.EnableWebSocketMessageBroker;
import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurer;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* WebSocket配置
*/
@EnableWebSocketMessageBroker //启动STOMP协议
@Configuration
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
@Bean
public ServerEndpointExporter serverEndpointExporter(){
return new ServerEndpointExporter();
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
// 增加一个聊天服务端点
registry.addEndpoint("/socket").withSockJS();
// 增加一个用户服务端点
registry.addEndpoint("/wsuser").withSockJS();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
// 客户端订阅路径前缀
registry.enableSimpleBroker("/sub","/queue");
// 服务端点请求前缀
registry.setApplicationDestinationPrefixes("/request");
}
}
| [
"[email protected]"
] | |
b6914fd3f3523b974d6bc60f17551df307a22126 | e7ee311e20b40c87bf6d23a53a1d7b11fd29d2c3 | /src/chosun/ciis/ss/sls/brsup/rec/SS_S_SHFT_CLAM_INITPARTLISTRecord.java | ff361db3cc5b4cee96b0be0ecb6550947c0441f5 | [] | no_license | nosmoon/misdevteam | 4e3695ef7bbdcd231bb84d7d8d7df54a23ff0a60 | 1829d5bd489eb6dd307ca244f0e183a31a1de773 | refs/heads/master | 2020-04-15T15:57:05.480056 | 2019-01-10T01:12:01 | 2019-01-10T01:12:01 | 164,812,547 | 1 | 0 | null | null | null | null | UHC | Java | false | false | 1,283 | java | /***************************************************************************************************
* 파일명 : .java
* 기능 : *지국업무지원-자동이체-청구-초기화면
* 작성일자 : 2009-04-14
* 작성자 : 김세웅
***************************************************************************************************/
package chosun.ciis.ss.sls.brsup.rec;
import java.sql.*;
import chosun.ciis.ss.sls.brsup.dm.*;
import chosun.ciis.ss.sls.brsup.ds.*;
/**
* 지국업무지원-자동이체-청구-초기화면
*/
public class SS_S_SHFT_CLAM_INITPARTLISTRecord extends java.lang.Object implements java.io.Serializable{
public String dept_cd;
public String dept_nm;
public String supr_dept_cd;
public SS_S_SHFT_CLAM_INITPARTLISTRecord(){}
public void setDept_cd(String dept_cd){
this.dept_cd = dept_cd;
}
public void setDept_nm(String dept_nm){
this.dept_nm = dept_nm;
}
public void setSupr_dept_cd(String supr_dept_cd){
this.supr_dept_cd = supr_dept_cd;
}
public String getDept_cd(){
return this.dept_cd;
}
public String getDept_nm(){
return this.dept_nm;
}
public String getSupr_dept_cd(){
return this.supr_dept_cd;
}
}
/* 작성시간 : Tue Apr 14 14:49:12 KST 2009 */ | [
"[email protected]"
] | |
a061436a18aa7bf714f43f021d22e58fe1fbcaac | 42e05905f071746e614cdd87ebff68918f929b3e | /backend/src/main/java/com/swimmingsprite/ems/authentication/exception/AccessDeniedException.java | 7b43659a6dc1640be501d8fb0d99b034a6b2be87 | [] | no_license | swimmingsprite/swisp-ems | 24c00d5df9e0cb52ec73f8d95e2c39a8ded1b9d1 | 8d09746b894c08ef49ec5e0336591dfab8b1906a | refs/heads/master | 2023-03-18T13:40:31.004861 | 2021-03-11T23:40:20 | 2021-03-11T23:40:20 | 307,520,847 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package com.swimmingsprite.ems.authentication.exception;
public class AccessDeniedException extends RuntimeException {
public AccessDeniedException(String message) {
super(message);
}
}
| [
"[email protected]"
] | |
f4ed4452147459b0948464baf598637dc88d0ec0 | d563be06ea35ab8b1e7faba68eedc283d6911d6c | /src/csg/transactions/UpdateSchedItem_Transaction.java | 8b5eb93773e7fc97dfc184b37b6794dd2aa14b4d | [] | no_license | iflam/CourseSiteGenerator | 9d551336aa247ca6074b76e74c033d6a952aba97 | 8f271a0e77a2fa2439d2403b51c337651ab2e1ef | refs/heads/master | 2021-09-03T11:19:29.456697 | 2018-01-08T16:49:15 | 2018-01-08T16:49:15 | 116,701,659 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,107 | 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 csg.transactions;
import csg.data.ScheduleData;
import csg.data.ScheduleItem;
import jtps.jTPS_Transaction;
/**
*
* @author Itai
*/
public class UpdateSchedItem_Transaction implements jTPS_Transaction{
public final String viewType = "scheduleTab";
ScheduleData sData;
ScheduleItem newSItem;
ScheduleItem ogSItem;
public UpdateSchedItem_Transaction(ScheduleData initData, ScheduleItem oldS, ScheduleItem newS){
sData = initData;
newSItem = newS;
ogSItem = oldS;
}
@Override
public String getViewType() {
return viewType;
}
@Override
public void doTransaction() {
sData.getItems().remove(ogSItem);
sData.addItem(newSItem);
}
@Override
public void undoTransaction() {
sData.getItems().remove(newSItem);
sData.addItem(ogSItem);
}
}
| [
"Itai@Itai"
] | Itai@Itai |
3d7cce1d6bfa90639d92f4b54c88ab38979b7d30 | af40d32d7a4155a5a6e77773fbd65d5ba976c074 | /kaoshisan/src/main/java/text/bwei/com/kaoshisan/view/bean/News.java | 0b7c6248202c6c6541c8cadf842ba755e66860b5 | [] | no_license | wuzijingwu/Lian | aaf38a01adbbb30084cb9a1867f031248685bed2 | d8c0a6526958b0b70c5c185bf992714003dfa8eb | refs/heads/master | 2021-05-08T03:55:32.366789 | 2017-11-18T09:25:00 | 2017-11-18T09:25:00 | 108,269,726 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,900 | java | package text.bwei.com.kaoshisan.view.bean;
import java.util.List;
/**
* Created by dell on 2017/11/18.
*/
public class News {
/**
* code : 200
* data : [{"content":"习近平举行仪式欢迎加蓬总统访华","id":10000,"image_url":"http://pic32.nipic.com/20130817/9745430_101836881000_2.jpg","title":"今日头条","type":1,"vedio_url":"http://2449.vod.myqcloud.com/2449_bfbbfa3cea8f11e5aac3db03cda99974.f20.mp4"},{"content":"习近平举行仪式欢迎加蓬总统访华","id":10001,"image_url":"http://pic15.nipic.com/20110630/6322714_105943746342_2.jpg","title":"往期故事","type":2,"vedio_url":"https://wdl.wallstreetcn.com/41aae4d2-390a-48ff-9230-ee865552e72d"},{"content":"这个市的书记市长双双被约谈 引发震动","id":10002,"image_url":"http://pic48.nipic.com/file/20140916/2531170_195153248000_2.jpg","title":"讨论天下","type":3,"vedio_url":"http://video.jiecao.fm/5/1/%E8%87%AA%E5%8F%96%E5%85%B6%E8%BE%B1.mp4"},{"content":"\u201c乔丹\u201d商标是否侵权 4年官司迎最高法判决 调查","id":10003,"image_url":"http://img.taopic.com/uploads/allimg/140626/240469-1406261S24553.jpg","title":"我的珍爱","type":4,"vedio_url":"http://2449.vod.myqcloud.com/2449_bfbbfa3cea8f11e5aac3db03cda99974.f20.mp4"},{"content":"黑龙江稻农收入暴涨组团进城买房 有人买十多套","id":10004,"image_url":"http://pic77.nipic.com/file/20150911/21721561_155058651000_2.jpg","title":"我的未来","type":5,"vedio_url":"http://video.jiecao.fm/5/1/%E8%87%AA%E5%8F%96%E5%85%B6%E8%BE%B1.mp4"},{"content":"印尼6.4级地震致97死 专家称当地防震意识差","id":10005,"image_url":"http://img4.duitang.com/uploads/item/201603/18/20160318103156_cziuY.jpeg","title":"东芝","type":6,"vedio_url":"http://ips.ifeng.com/video19.ifeng.com/video09/2014/06/16/1989823-102-086-0009.mp4"}]
* msg : 成功
*/
private int code;
private String msg;
private List<DataBean> data;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public List<DataBean> getData() {
return data;
}
public void setData(List<DataBean> data) {
this.data = data;
}
public static class DataBean {
/**
* content : 习近平举行仪式欢迎加蓬总统访华
* id : 10000
* image_url : http://pic32.nipic.com/20130817/9745430_101836881000_2.jpg
* title : 今日头条
* type : 1
* vedio_url : http://2449.vod.myqcloud.com/2449_bfbbfa3cea8f11e5aac3db03cda99974.f20.mp4
*/
private String content;
private int id;
private String image_url;
private String title;
private int type;
private String vedio_url;
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getImage_url() {
return image_url;
}
public void setImage_url(String image_url) {
this.image_url = image_url;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public int getType() {
return type;
}
public void setType(int type) {
this.type = type;
}
public String getVedio_url() {
return vedio_url;
}
public void setVedio_url(String vedio_url) {
this.vedio_url = vedio_url;
}
}
}
| [
"[email protected]"
] | |
00c3fe0f8870afe284b88765ad02a36d321fb68c | f55d4a74e648c8d169a59812668456ba4e947a2b | /src/main/java/security/build/pdp/client/PDPInterceptor.java | aeeaeb9cda4d48b9a9ce0ccd271169836a58aea0 | [
"Apache-2.0"
] | permissive | aravind-viswanathan/opa-java-spring-client | 7f466544cac4c47a1be710ecb0b81dd5e8534a9c | 52f1fb7aaf505d6956d369bb8ba58fc6360b621f | refs/heads/main | 2023-06-07T18:27:37.442542 | 2021-06-28T06:06:53 | 2021-06-28T06:06:53 | 380,923,127 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,574 | java | package security.build.pdp.client;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@Component
public class PDPInterceptor extends HandlerInterceptorAdapter {
@Value("${pdp.enable:true}")
private boolean enable;
@Autowired
private PDPEnforcer pdpEnforcer;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws IOException {
if (!enable) {
return true;
}
HandlerMethod method = (HandlerMethod) handler;
Class<Authorize> authorizeClass = Authorize.class;
Authorize annotation = method.getMethodAnnotation(authorizeClass);
String[] requirements = annotation != null ? annotation.resources() : new String[0];
Boolean result = pdpEnforcer.AuthorizeRequest(request, requirements);
if (result) {
return true;
}
response.sendError(HttpServletResponse.SC_FORBIDDEN, "Forbidden");
return false;
}
public boolean getEnable() {
return enable;
}
public void setEnable(boolean enable) {
this.enable = enable;
}
}
| [
"[email protected]"
] | |
aad3fe93fc1021d824c3c3d95c27d196257291a4 | 954bbe2a36db8778d7cce09375cadd9704e67872 | /src/main/java/cn/gdcp/service/impl/GoodServiceImpl.java | 05dbb764ed7eb9c90cfc66158f062474af549b89 | [] | no_license | lcz-sys/grill | 21d279dac1b7fefd1f1e62dfe22307870acc41f0 | 852c0342d19420a3d6c6b9cdb1042fb7f7fa738b | refs/heads/master | 2023-04-04T11:37:02.373746 | 2021-04-17T07:36:29 | 2021-04-17T07:36:29 | 358,815,762 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,195 | java | package cn.gdcp.service.impl;
import cn.gdcp.domain.Good;
import cn.gdcp.mapper.GoodMapper;
import cn.gdcp.mapper.TopMapper;
import cn.gdcp.mapper.TypeMapper;
import cn.gdcp.service.GoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service("goodService")
public class GoodServiceImpl implements GoodService {
@Autowired
private GoodMapper goodMapper;
@Autowired
private TopMapper topMapper;
@Autowired
private TypeMapper typeMapper;
/*封装商品*/
private List<Good> packGood(List<Good> list) {
for (Good good:list) {
good=packGood(good);
}
return list;
}
/*封装商品 */
private Good packGood(Good good){
if (good !=null){
good.setType(typeMapper.get(good.getTypeId()));//类目信息
good.setTop(topMapper.selectByGoodId(good.getId()));
}
return good;
}
/*获取最新的商品*/
public List<Good> getList(int begin, int size) {
return packGood(goodMapper.selectList(begin,size));
}
@Override
public List<Good> searchGoods(String name) {
return goodMapper.selectGoodByName(name);
}
@Override
public List<Good> findAllGoods() {
return goodMapper.findAllGoods();
}
@Override
public Good get(int id) {
return goodMapper.get(id);
}
@Override
public boolean updateGood(Good good) {
return goodMapper.updateGood(good);
}
@Override
public boolean addGood(Good good) {
return goodMapper.addGood(good);
}
@Override
public int deleteGood(int id) {
return goodMapper.deleteGood(id);
}
@Override
public int deleteSelectGood(int[] ids) {
int count = 0;
for (int id :
ids) {
int num = goodMapper.deleteGood(id);
count += num;
}
return count;
}
@Override
public int upGood(int id) {
return topMapper.upGood(id);
}
@Override
public int downGood(int id) {
return topMapper.downGood(id);
}
@Override
public List<Good> getListByTop(int begin, int size) {
return packGood(goodMapper.getListByTop(begin,size));
}
@Override
public List<Good> getListByTop() {
return packGood(goodMapper.getListByTops());
}
@Override
public List<Good> getListOrderSale(int begin, int size) {
return packGood(goodMapper.getListOrderSale(begin,size));
}
@Override
public List<Good> getListOrderSales() {
return packGood(goodMapper.getListOrderSales());
}
@Override
public List<Good> getListByType(int typeId, int begin, int size) {
return typeId > 0 ? packGood(goodMapper.getListByType(typeId,
begin,size)) : this.getList(begin,size);
}
@Override
public List<Good> getListByType(int typeId) {
return packGood(goodMapper.selectListByType(typeId));
}
@Override
public List<Good> getNewGoods() {
return goodMapper.getNewGoods();
}
}
| [
"[email protected]"
] | |
9e42e4be3349a8ed0f295350a2139dc9c873f87c | 402ea45f2fc5a9599e4a4ba7079adf284e5ab6ae | /src/main/java/nl/novi/eindopdracht/model/Order.java | 1c41e536ce167940bb4fef0e00b5c6857559f5f8 | [] | no_license | voidz8/eindopdracht | 80426d15c16fd09de00c3fb9ee015ac96a91c634 | 418d0b480faef80f13386b720e857941b609d7ff | refs/heads/master | 2023-03-11T10:01:41.347591 | 2021-02-28T20:30:16 | 2021-02-28T20:30:16 | 333,182,258 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,913 | java | package nl.novi.eindopdracht.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.jpa.repository.Temporal;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.HashSet;
import java.util.Set;
@Table(name = "orders")
@Entity
public class Order implements Serializable {
@Id
@Getter
@Setter
@Column(name = "order_number", nullable = false, unique = true)
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long orderNumber;
@Getter
@Setter
@JsonIgnore
@ManyToOne
@JoinColumn(name = "companyName")
private Client client;
@Getter
@Setter
@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
@JoinTable(name = "order_product",
joinColumns = @JoinColumn(name = "order_number"),
inverseJoinColumns = @JoinColumn(name = "drawing_number"))
private Set<Product> products = new HashSet<>();
@Getter
@Setter
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "order_machine",
joinColumns = @JoinColumn(name = "order_number"),
inverseJoinColumns = @JoinColumn(name = "machine_id"))
private Set<Machine> operations = new HashSet<>();
@Getter
@Setter
@Column(name = "production_date")
private LocalDate productionDate;
@Getter
@Setter
@Column(name = "delivery_date")
private LocalDate deliveryDate;
@Getter
@Setter
@ManyToOne(cascade = CascadeType.PERSIST)
@JoinColumn(name = "order_id")
private Planning planning;
public void addProduct(Product product){this.products.add(product);}
public Order() {
}
public Order(Client client, long orderNumber, LocalDate productionDate, LocalDate deliveryDate) {
this.client = client;
this.orderNumber = orderNumber;
this.productionDate = productionDate;
this.deliveryDate = deliveryDate;
}
@Override
public String toString() {
return "Order{" +
"orderNumber=" + orderNumber +
", client=" + client +
", products=" + products +
", operations=" + operations +
", productionDate=" + productionDate +
", deliveryDate=" + deliveryDate +
'}';
}
} | [
"[email protected]"
] | |
719dda99b16c47d2ca0aa6b90292a0f647abbcde | 68c2af4fb8ba166004865ab1d3bb0ebe3e4753bc | /WEB-INF/classes/UpdateCustomerOrder.java | 96e3442d87ba624af3fbf8efe6bb46f611c11dc7 | [] | no_license | priyankaagit/BestDeal | 771e2b661197a0c189e390cca14ded373a5566ac | a6a4a7d1f97654e4cde6254d61a5e01e03d846d2 | refs/heads/master | 2021-01-12T09:04:18.802972 | 2016-12-17T23:28:46 | 2016-12-17T23:28:46 | 76,752,564 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 13,206 | java | import java.util.Date;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class UpdateCustomerOrder extends HttpServlet {
MySqlDataStoreUtilities s = null;
HashMap<String,CustomerOrder> co = null;
ArrayList <OrderItem> or = null;
public void init() {
s = new MySqlDataStoreUtilities();
co = new HashMap<String,CustomerOrder>();
or = new ArrayList<OrderItem>();
}
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
HttpSession session = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String user1 = (String)session.getValue("userid");
//String usertype = request.getParameter("usertype");
String user = (String)session.getValue("userid");
String usertype = (String)session.getValue("usertype");
String orderid = request.getParameter("orderid");
out.println("<!doctype html>\n"+
"<html>\n" +
"<head>\n" +
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n" +
"<title>spigot - Free CSS Template by ZyPOP</title>\n" +
"<link rel=\"stylesheet\" href=\"styles.css\" type=\"text/css\"\n" +
"</head>\n" +
"<body>\n" +
"<div id=\"container\">\n" +
"<header> \n" +
"<h1><a href=\"/\">Best<span>Deal</span></a></h1>\n" +
"<h2>Shopping Online Made Easy</h2>\n" );
if(user!=null){
out.println("<h3 style=\"text-align:right\">");
out.println("Welcome " + user);
out.println("<a href=\"/bestdeal/TrackOrder\">Track Order</a>\n");
out.println("</h3>");
}
out.println("</header> \n" +
"<nav>\n" +
"<ul>\n" );
if(user==null)
out.println("<li class=\"start selected\"><a href=\"http://localhost/bestdeal/Home\">Home</a></li> \n");
else
out.println(
"<li class=\"start selected\"><a href=\"\">Home</a></li> \n");
out.println("<li class=\"\"><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop\">Laptop</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television\">TV</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet\">Tablet</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile\">Smart Phone</a></li>\n");
//out.println("<li><a href=\"Login.html\">Login</a></li>\n" +
// "<li><a href=\"Signup.html\">SignUp</a></li>\n");
out.println("<li class=\"text\">\n" +
"<form method=\"get\" class=\"searchform\" action=\"#\" >\n" +
"<p> \n" +
" <input type=\"text\" name=\"search\" placeholder=\"Search\" size=\"30\" style=\"height:25px\" value=\"\" name=\"s\" class=\"s\" /> \n" +
"</p> \n" +
" </form> \n" +
"</li> \n");
if(user==null)
out.println("<li><a href=\"Login.html\">Login</a></li>\n" +
"<li><a href=\"Signup.html\">SignUp</a></li> \n" );
else{
out.println("<li><a href=\"\">Account</a></li>\n" );
out.println("<li><a href=\"LogoutServlet\">Logout</a></li>\n" );
//out.println("<li style=\"float:right\" class=\"end\"><a>Cart</li>\n");
}
out.println("<li class=\"end\"><a>cart</li>\n" +
"</ul>\n" +
"</nav>\n");
out.println("<div id=\"body\">\n" +
" <section id=\"content\"> \n");
co = s.selecttrackOrder(orderid);
for (String orderid1: co.keySet()) {
CustomerOrder c = co.get(orderid1);
out.println(" <form method=\"post\" action=\"/bestdeal/UpdateOrder\">\n" +
" <div align=\"center\"> \n");
out.println("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
"<TR BGCOLOR=\"#FFAD00\">\n");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "OrderId\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"OrderId\"\n" + " SIZE=10 VALUE=\"" + c.getOrderId() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "OrderDate\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"OrderDate\"\n" + " SIZE=10 VALUE=\"" + c.getOrderDate() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "DeliveryDate\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"DeliveryDate\"\n" + " SIZE=10 VALUE=\"" + c.getDeliveryDate() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "TotalPrice\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"TotalPrice\"\n" + " SIZE=10 VALUE=\"" + c.getTotalPrice() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
or = c.getOrderItem();
for(OrderItem i: or){
out.println(" <form method=\"post\" action=\"/bestdeal/UpdateOrder\">\n" +
" <div align=\"center\"> \n");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "ProductName\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"ProductName\"\n" + " SIZE=10 VALUE=\"" + i.getProductName() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "ProductPrice\n" );
out.println("</td> \n");
out.println( "<td>\n ");
out.println( "<INPUT TYPE=\"TEXT\" NAME=\"ProductPrice\"\n" + " SIZE=10 VALUE=\"" + i.getProductPrice() + "\">\n" +"<SMALL>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("<tr>\n");
out.println( "<td>\n ");
out.println( "<center><input type=\"submit\" value=\"UpdateOrder\" /></center>\n");
out.println("</td> \n");
out.println("</tr>");
out.println("</form>\n");
}
out.println("</table>");
out.println( "</div>\n"+
"</form>\n");
}
out.println("</section>\n");
out.println ("<aside class=\"sidebar\"> \n" +
"<ul> \n" +
"<li> \n" +
"<h4>Laptop</h4>\n" +
"<ul>\n" +
"<li id=\"first\"><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop&maker=Samsung\">Samsung</a></li> \n" +
" <li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop&maker=Lenovo\">Lenovo</a></li> \n" +
" <li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop&maker=dell\">Dell</a></li> \n" +
" <li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop&maker=HP\">HP</a></li> \n" +
" <li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Laptop&maker=asus\">ASUS</a></li> \n" +
"</ul> \n" +
"</li> \n" +
"<li> \n" +
"<h4>Tablets</h4> \n" +
"<ul> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet&maker=samsung\">Samsung</a></li>\n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet&maker=lenovo\">Lenovo</a></li>\n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet&maker=apple\">Apple</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet&maker=nexus\">Nexus</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Tablet&maker=asus\">ASUS</a></li>\n" +
"</ul> \n" +
"</li> \n" +
"<li> \n" +
"<h4>SmartPhone</h4>\n" +
"<ul> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile&maker=samsung\">Samsung</a></li>\n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile&maker=apple\">Apple</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile&maker=htc\">HTC</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile&maker=acer\">Acer</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Mobile&maker=sony\">Sony</a></li> \n" +
"</ul> \n" +
"<li> \n" +
"<h4>TV</h4>\n" +
"<ul> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television&maker=samsung\">Samsung</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television&maker=apple\">Apple</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television&maker=lg\">LG</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television&maker=philips\">Philips</a></li> \n" +
"<li><a href=\"http://localhost/bestdeal/ProductServlet?prodType=Television&maker=sony\">Sony</a></li> \n" +
"</ul> \n" +
"<li> \n" +
//"<h4>DataAnalytics</h4>\n" +
"<ul> \n");
if (user != null){
if (usertype.equals("StoreManager")){
out.println("<li><a href=\"http://localhost/bestdeal/TelevisionServlet?maker=samsung\">Data Analytics</a></li> \n" );
out.println("<li><a href=\"/bestdeal/Trending\">Trending</a></li> \n" +
"</ul> \n" );
}
else {
out.println("<li><a href=\"/bestdeal/Trending\">Trending</a></li> \n" +
"</ul> \n" );
}
}
else {
out.println("<li><a href=\"/bestdeal/Trending\">Trending</a></li> \n" +
"</ul> \n" );
}
out.println("</li> \n" +
"</aside> \n" +
"<div class=\"clear\"></div> \n" +
"<footer>\n" +
"<div class=\"footer-content\"> \n" +
"<ul> \n" +
"<li><h4>About us</h4></li> \n" +
"<li><a href=\"#\">About Best Deal</a></li> \n" +
"</ul> \n" +
"<ul> \n" +
"<li><h4>Accounts</h4></li> \n" +
"<li><a href=\"#\">your account</a></li> \n" +
"<li><a href=\"#\">your orders</a></li> \n" +
"</ul> \n" +
"<ul class=\"endfooter\"> \n" +
"<li><h4>Contact Us</h4></li> \n" +
"<li><h4> 1-800-100-009<h4></li> \n" +
"</ul> \n" +
"<div class=\"clear\"></div>\n" +
"</div> \n" +
"<div class=\"footer-bottom\"> \n" +
"<p>© Copyright © BestDeal.com \n" +
"</div> \n" +
"</footer> \n" +
"</div> \n" +
"</body>\n" +
"</html>");
//session.invalidate();
// RequestDispatcher view = request.getRequestDispatcher("/Home");
// view.forward(request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
/** Handles the HTTP <code>POST</code> method.
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, java.io.IOException {
processRequest(request, response);
}
}
| [
"[email protected]"
] | |
8c4ad808f179fdabe3c6d1d5a25bbc257f3355aa | 05ac8dcd195e7c89ab6fbd456e1074532f27085e | /Bankbot/Java/android/support/v7/widget/ActionMenuView.java | 17771cf08e68febc7dfab23aa10feeef68fd65d3 | [] | no_license | AppAnalysis-BGSU/DecompiledApks | f3f913d45e04f256620270d4906ddaea7d4c33a0 | a9fe58e890928e14b65b174d3c5dd4a8af1b604e | refs/heads/master | 2021-04-26T22:03:56.343340 | 2018-03-11T00:10:25 | 2018-03-11T00:10:25 | 124,018,768 | 0 | 0 | null | 2018-03-06T04:06:41 | 2018-03-06T04:06:41 | null | UTF-8 | Java | false | false | 27,539 | java | package android.support.v7.widget;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.support.v7.view.menu.ActionMenuItemView;
import android.support.v7.view.menu.MenuBuilder;
import android.support.v7.view.menu.MenuBuilder.ItemInvoker;
import android.support.v7.view.menu.MenuItemImpl;
import android.support.v7.view.menu.MenuPresenter.Callback;
import android.support.v7.view.menu.MenuView;
import android.util.AttributeSet;
import android.view.ContextThemeWrapper;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewDebug.ExportedProperty;
import android.view.accessibility.AccessibilityEvent;
public class ActionMenuView extends LinearLayoutCompat implements ItemInvoker, MenuView {
static final int GENERATED_ITEM_PADDING = 4;
static final int MIN_CELL_SIZE = 56;
private static final String TAG = "ActionMenuView";
private Callback mActionMenuPresenterCallback;
private boolean mFormatItems;
private int mFormatItemsWidth;
private int mGeneratedItemPadding;
private MenuBuilder mMenu;
private MenuBuilder.Callback mMenuBuilderCallback;
private int mMinCellSize;
private OnMenuItemClickListener mOnMenuItemClickListener;
private Context mPopupContext;
private int mPopupTheme;
private ActionMenuPresenter mPresenter;
private boolean mReserveOverflow;
public interface ActionMenuChildView {
boolean needsDividerAfter();
boolean needsDividerBefore();
}
class ActionMenuPresenterCallback implements Callback {
private ActionMenuPresenterCallback() {
}
public void onCloseMenu(MenuBuilder menuBuilder, boolean z) {
}
public boolean onOpenSubMenu(MenuBuilder menuBuilder) {
return false;
}
}
public class LayoutParams extends android.support.v7.widget.LinearLayoutCompat.LayoutParams {
@ExportedProperty
public int cellsUsed;
@ExportedProperty
public boolean expandable;
boolean expanded;
@ExportedProperty
public int extraPixels;
@ExportedProperty
public boolean isOverflowButton;
@ExportedProperty
public boolean preventEdgeOffset;
public LayoutParams(int i, int i2) {
super(i, i2);
this.isOverflowButton = false;
}
LayoutParams(int i, int i2, boolean z) {
super(i, i2);
this.isOverflowButton = z;
}
public LayoutParams(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
}
public LayoutParams(LayoutParams layoutParams) {
super((android.view.ViewGroup.LayoutParams) layoutParams);
this.isOverflowButton = layoutParams.isOverflowButton;
}
public LayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
super(layoutParams);
}
}
class MenuBuilderCallback implements MenuBuilder.Callback {
private MenuBuilderCallback() {
}
public boolean onMenuItemSelected(MenuBuilder menuBuilder, MenuItem menuItem) {
return ActionMenuView.this.mOnMenuItemClickListener != null && ActionMenuView.this.mOnMenuItemClickListener.onMenuItemClick(menuItem);
}
public void onMenuModeChange(MenuBuilder menuBuilder) {
if (ActionMenuView.this.mMenuBuilderCallback != null) {
ActionMenuView.this.mMenuBuilderCallback.onMenuModeChange(menuBuilder);
}
}
}
public interface OnMenuItemClickListener {
boolean onMenuItemClick(MenuItem menuItem);
}
public ActionMenuView(Context context) {
this(context, null);
}
public ActionMenuView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
setBaselineAligned(false);
float f = context.getResources().getDisplayMetrics().density;
this.mMinCellSize = (int) (56.0f * f);
this.mGeneratedItemPadding = (int) (f * 4.0f);
this.mPopupContext = context;
this.mPopupTheme = 0;
}
static int measureChildForCells(View view, int i, int i2, int i3, int i4) {
int i5;
boolean z = false;
LayoutParams layoutParams = (LayoutParams) view.getLayoutParams();
int makeMeasureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(i3) - i4, MeasureSpec.getMode(i3));
ActionMenuItemView actionMenuItemView = view instanceof ActionMenuItemView ? (ActionMenuItemView) view : null;
boolean z2 = actionMenuItemView != null && actionMenuItemView.hasText();
if (i2 <= 0 || (z2 && i2 < 2)) {
i5 = 0;
} else {
view.measure(MeasureSpec.makeMeasureSpec(i * i2, Integer.MIN_VALUE), makeMeasureSpec);
int measuredWidth = view.getMeasuredWidth();
i5 = measuredWidth / i;
if (measuredWidth % i != 0) {
i5++;
}
if (z2 && r1 < 2) {
i5 = 2;
}
}
if (!layoutParams.isOverflowButton && z2) {
z = true;
}
layoutParams.expandable = z;
layoutParams.cellsUsed = i5;
view.measure(MeasureSpec.makeMeasureSpec(i5 * i, 1073741824), makeMeasureSpec);
return i5;
}
private void onMeasureExactFormat(int i, int i2) {
int mode = MeasureSpec.getMode(i2);
int size = MeasureSpec.getSize(i);
int size2 = MeasureSpec.getSize(i2);
int paddingLeft = getPaddingLeft() + getPaddingRight();
int paddingTop = getPaddingTop() + getPaddingBottom();
int childMeasureSpec = getChildMeasureSpec(i2, paddingTop, -2);
int i3 = size - paddingLeft;
int i4 = i3 / this.mMinCellSize;
size = i3 % this.mMinCellSize;
if (i4 == 0) {
setMeasuredDimension(i3, 0);
return;
}
int i5;
Object obj;
int i6 = this.mMinCellSize + (size / i4);
int i7 = 0;
int i8 = 0;
int i9 = 0;
paddingLeft = 0;
Object obj2 = null;
long j = 0;
int childCount = getChildCount();
int i10 = 0;
while (i10 < childCount) {
int i11;
long j2;
int i12;
int i13;
View childAt = getChildAt(i10);
if (childAt.getVisibility() == 8) {
i11 = paddingLeft;
j2 = j;
i12 = i7;
i13 = i4;
i4 = i8;
} else {
boolean z = childAt instanceof ActionMenuItemView;
i5 = paddingLeft + 1;
if (z) {
childAt.setPadding(this.mGeneratedItemPadding, 0, this.mGeneratedItemPadding, 0);
}
LayoutParams layoutParams = (LayoutParams) childAt.getLayoutParams();
layoutParams.expanded = false;
layoutParams.extraPixels = 0;
layoutParams.cellsUsed = 0;
layoutParams.expandable = false;
layoutParams.leftMargin = 0;
layoutParams.rightMargin = 0;
boolean z2 = z && ((ActionMenuItemView) childAt).hasText();
layoutParams.preventEdgeOffset = z2;
int measureChildForCells = measureChildForCells(childAt, i6, layoutParams.isOverflowButton ? 1 : i4, childMeasureSpec, paddingTop);
i8 = Math.max(i8, measureChildForCells);
paddingLeft = layoutParams.expandable ? i9 + 1 : i9;
obj = layoutParams.isOverflowButton ? 1 : obj2;
int i14 = i4 - measureChildForCells;
i9 = Math.max(i7, childAt.getMeasuredHeight());
if (measureChildForCells == 1) {
long j3 = ((long) (1 << i10)) | j;
i12 = i9;
i13 = i14;
i9 = paddingLeft;
obj2 = obj;
j2 = j3;
i4 = i8;
i11 = i5;
} else {
i11 = i5;
i4 = i8;
long j4 = j;
i12 = i9;
i13 = i14;
obj2 = obj;
i9 = paddingLeft;
j2 = j4;
}
}
i10++;
i8 = i4;
i7 = i12;
i4 = i13;
j = j2;
paddingLeft = i11;
}
Object obj3 = (obj2 == null || paddingLeft != 2) ? null : 1;
Object obj4 = null;
long j5 = j;
paddingTop = i4;
while (i9 > 0 && paddingTop > 0) {
i5 = ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED;
j = 0;
i4 = 0;
int i15 = 0;
while (i15 < childCount) {
layoutParams = (LayoutParams) getChildAt(i15).getLayoutParams();
if (!layoutParams.expandable) {
size = i4;
i4 = i5;
} else if (layoutParams.cellsUsed < i5) {
i4 = layoutParams.cellsUsed;
j = (long) (1 << i15);
size = 1;
} else if (layoutParams.cellsUsed == i5) {
j |= (long) (1 << i15);
size = i4 + 1;
i4 = i5;
} else {
size = i4;
i4 = i5;
}
i15++;
i5 = i4;
i4 = size;
}
j5 |= j;
if (i4 > paddingTop) {
j = j5;
break;
}
i15 = i5 + 1;
i5 = 0;
i4 = paddingTop;
long j6 = j5;
while (i5 < childCount) {
View childAt2 = getChildAt(i5);
layoutParams = (LayoutParams) childAt2.getLayoutParams();
if ((((long) (1 << i5)) & j) != 0) {
if (obj3 != null && layoutParams.preventEdgeOffset && i4 == 1) {
childAt2.setPadding(this.mGeneratedItemPadding + i6, 0, this.mGeneratedItemPadding, 0);
}
layoutParams.cellsUsed++;
layoutParams.expanded = true;
size = i4 - 1;
} else if (layoutParams.cellsUsed == i15) {
j6 |= (long) (1 << i5);
size = i4;
} else {
size = i4;
}
i5++;
i4 = size;
}
j5 = j6;
i10 = 1;
paddingTop = i4;
}
j = j5;
obj = (obj2 == null && paddingLeft == 1) ? 1 : null;
if (paddingTop <= 0 || j == 0 || (paddingTop >= paddingLeft - 1 && obj == null && i8 <= 1)) {
obj3 = obj4;
} else {
float f;
View childAt3;
float bitCount = (float) Long.bitCount(j);
if (obj == null) {
if (!((1 & j) == 0 || ((LayoutParams) getChildAt(0).getLayoutParams()).preventEdgeOffset)) {
bitCount -= 0.5f;
}
if (!((((long) (1 << (childCount - 1))) & j) == 0 || ((LayoutParams) getChildAt(childCount - 1).getLayoutParams()).preventEdgeOffset)) {
f = bitCount - 0.5f;
paddingLeft = f <= 0.0f ? (int) (((float) (paddingTop * i6)) / f) : 0;
i4 = 0;
obj3 = obj4;
while (i4 < childCount) {
if ((((long) (1 << i4)) & j) != 0) {
obj = obj3;
} else {
childAt3 = getChildAt(i4);
layoutParams = (LayoutParams) childAt3.getLayoutParams();
if (childAt3 instanceof ActionMenuItemView) {
layoutParams.extraPixels = paddingLeft;
layoutParams.expanded = true;
if (i4 == 0 && !layoutParams.preventEdgeOffset) {
layoutParams.leftMargin = (-paddingLeft) / 2;
}
obj = 1;
} else if (layoutParams.isOverflowButton) {
if (i4 != 0) {
layoutParams.leftMargin = paddingLeft / 2;
}
if (i4 != childCount - 1) {
layoutParams.rightMargin = paddingLeft / 2;
}
obj = obj3;
} else {
layoutParams.extraPixels = paddingLeft;
layoutParams.expanded = true;
layoutParams.rightMargin = (-paddingLeft) / 2;
obj = 1;
}
}
i4++;
obj3 = obj;
}
}
}
f = bitCount;
if (f <= 0.0f) {
}
i4 = 0;
obj3 = obj4;
while (i4 < childCount) {
if ((((long) (1 << i4)) & j) != 0) {
childAt3 = getChildAt(i4);
layoutParams = (LayoutParams) childAt3.getLayoutParams();
if (childAt3 instanceof ActionMenuItemView) {
layoutParams.extraPixels = paddingLeft;
layoutParams.expanded = true;
layoutParams.leftMargin = (-paddingLeft) / 2;
obj = 1;
} else if (layoutParams.isOverflowButton) {
if (i4 != 0) {
layoutParams.leftMargin = paddingLeft / 2;
}
if (i4 != childCount - 1) {
layoutParams.rightMargin = paddingLeft / 2;
}
obj = obj3;
} else {
layoutParams.extraPixels = paddingLeft;
layoutParams.expanded = true;
layoutParams.rightMargin = (-paddingLeft) / 2;
obj = 1;
}
} else {
obj = obj3;
}
i4++;
obj3 = obj;
}
}
if (obj3 != null) {
for (paddingLeft = 0; paddingLeft < childCount; paddingLeft++) {
childAt = getChildAt(paddingLeft);
layoutParams = (LayoutParams) childAt.getLayoutParams();
if (layoutParams.expanded) {
childAt.measure(MeasureSpec.makeMeasureSpec(layoutParams.extraPixels + (layoutParams.cellsUsed * i6), 1073741824), childMeasureSpec);
}
}
}
if (mode == 1073741824) {
i7 = size2;
}
setMeasuredDimension(i3, i7);
}
protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
return layoutParams != null && (layoutParams instanceof LayoutParams);
}
public void dismissPopupMenus() {
if (this.mPresenter != null) {
this.mPresenter.dismissPopupMenus();
}
}
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
return false;
}
protected LayoutParams generateDefaultLayoutParams() {
LayoutParams layoutParams = new LayoutParams(-2, -2);
layoutParams.gravity = 16;
return layoutParams;
}
public LayoutParams generateLayoutParams(AttributeSet attributeSet) {
return new LayoutParams(getContext(), attributeSet);
}
protected LayoutParams generateLayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
if (layoutParams == null) {
return generateDefaultLayoutParams();
}
LayoutParams layoutParams2 = layoutParams instanceof LayoutParams ? new LayoutParams((LayoutParams) layoutParams) : new LayoutParams(layoutParams);
if (layoutParams2.gravity > 0) {
return layoutParams2;
}
layoutParams2.gravity = 16;
return layoutParams2;
}
public LayoutParams generateOverflowButtonLayoutParams() {
LayoutParams generateDefaultLayoutParams = generateDefaultLayoutParams();
generateDefaultLayoutParams.isOverflowButton = true;
return generateDefaultLayoutParams;
}
public Menu getMenu() {
if (this.mMenu == null) {
Context context = getContext();
this.mMenu = new MenuBuilder(context);
this.mMenu.setCallback(new MenuBuilderCallback());
this.mPresenter = new ActionMenuPresenter(context);
this.mPresenter.setReserveOverflow(true);
this.mPresenter.setCallback(this.mActionMenuPresenterCallback != null ? this.mActionMenuPresenterCallback : new ActionMenuPresenterCallback());
this.mMenu.addMenuPresenter(this.mPresenter, this.mPopupContext);
this.mPresenter.setMenuView(this);
}
return this.mMenu;
}
public Drawable getOverflowIcon() {
getMenu();
return this.mPresenter.getOverflowIcon();
}
public int getPopupTheme() {
return this.mPopupTheme;
}
public int getWindowAnimations() {
return 0;
}
protected boolean hasSupportDividerBeforeChildAt(int i) {
boolean z = false;
if (i == 0) {
return false;
}
View childAt = getChildAt(i - 1);
View childAt2 = getChildAt(i);
if (i < getChildCount() && (childAt instanceof ActionMenuChildView)) {
z = 0 | ((ActionMenuChildView) childAt).needsDividerAfter();
}
return (i <= 0 || !(childAt2 instanceof ActionMenuChildView)) ? z : ((ActionMenuChildView) childAt2).needsDividerBefore() | z;
}
public boolean hideOverflowMenu() {
return this.mPresenter != null && this.mPresenter.hideOverflowMenu();
}
public void initialize(MenuBuilder menuBuilder) {
this.mMenu = menuBuilder;
}
public boolean invokeItem(MenuItemImpl menuItemImpl) {
return this.mMenu.performItemAction(menuItemImpl, 0);
}
public boolean isOverflowMenuShowPending() {
return this.mPresenter != null && this.mPresenter.isOverflowMenuShowPending();
}
public boolean isOverflowMenuShowing() {
return this.mPresenter != null && this.mPresenter.isOverflowMenuShowing();
}
public boolean isOverflowReserved() {
return this.mReserveOverflow;
}
public void onConfigurationChanged(Configuration configuration) {
if (VERSION.SDK_INT >= 8) {
super.onConfigurationChanged(configuration);
}
if (this.mPresenter != null) {
this.mPresenter.updateMenuView(false);
if (this.mPresenter.isOverflowMenuShowing()) {
this.mPresenter.hideOverflowMenu();
this.mPresenter.showOverflowMenu();
}
}
}
public void onDetachedFromWindow() {
super.onDetachedFromWindow();
dismissPopupMenus();
}
protected void onLayout(boolean z, int i, int i2, int i3, int i4) {
if (this.mFormatItems) {
int i5;
int i6;
LayoutParams layoutParams;
int paddingLeft;
int childCount = getChildCount();
int i7 = (i4 - i2) / 2;
int dividerWidth = getDividerWidth();
int i8 = 0;
int i9 = 0;
int paddingRight = ((i3 - i) - getPaddingRight()) - getPaddingLeft();
Object obj = null;
boolean isLayoutRtl = ViewUtils.isLayoutRtl(this);
int i10 = 0;
while (i10 < childCount) {
Object obj2;
View childAt = getChildAt(i10);
if (childAt.getVisibility() == 8) {
obj2 = obj;
i5 = i9;
i6 = paddingRight;
paddingRight = i8;
} else {
layoutParams = (LayoutParams) childAt.getLayoutParams();
if (layoutParams.isOverflowButton) {
i6 = childAt.getMeasuredWidth();
if (hasSupportDividerBeforeChildAt(i10)) {
i6 += dividerWidth;
}
int measuredHeight = childAt.getMeasuredHeight();
if (isLayoutRtl) {
paddingLeft = layoutParams.leftMargin + getPaddingLeft();
i5 = paddingLeft + i6;
} else {
i5 = (getWidth() - getPaddingRight()) - layoutParams.rightMargin;
paddingLeft = i5 - i6;
}
int i11 = i7 - (measuredHeight / 2);
childAt.layout(paddingLeft, i11, i5, measuredHeight + i11);
i6 = paddingRight - i6;
obj2 = 1;
i5 = i9;
paddingRight = i8;
} else {
i5 = (childAt.getMeasuredWidth() + layoutParams.leftMargin) + layoutParams.rightMargin;
paddingLeft = i8 + i5;
i5 = paddingRight - i5;
if (hasSupportDividerBeforeChildAt(i10)) {
paddingLeft += dividerWidth;
}
Object obj3 = obj;
i6 = i5;
i5 = i9 + 1;
paddingRight = paddingLeft;
obj2 = obj3;
}
}
i10++;
i8 = paddingRight;
paddingRight = i6;
i9 = i5;
obj = obj2;
}
if (childCount == 1 && obj == null) {
View childAt2 = getChildAt(0);
i6 = childAt2.getMeasuredWidth();
i5 = childAt2.getMeasuredHeight();
paddingRight = ((i3 - i) / 2) - (i6 / 2);
i9 = i7 - (i5 / 2);
childAt2.layout(paddingRight, i9, i6 + paddingRight, i5 + i9);
return;
}
paddingLeft = i9 - (obj != null ? 0 : 1);
paddingRight = Math.max(0, paddingLeft > 0 ? paddingRight / paddingLeft : 0);
View childAt3;
if (isLayoutRtl) {
i6 = getWidth() - getPaddingRight();
i5 = 0;
while (i5 < childCount) {
childAt3 = getChildAt(i5);
layoutParams = (LayoutParams) childAt3.getLayoutParams();
if (childAt3.getVisibility() == 8) {
paddingLeft = i6;
} else if (layoutParams.isOverflowButton) {
paddingLeft = i6;
} else {
i6 -= layoutParams.rightMargin;
i8 = childAt3.getMeasuredWidth();
i10 = childAt3.getMeasuredHeight();
dividerWidth = i7 - (i10 / 2);
childAt3.layout(i6 - i8, dividerWidth, i6, i10 + dividerWidth);
paddingLeft = i6 - ((layoutParams.leftMargin + i8) + paddingRight);
}
i5++;
i6 = paddingLeft;
}
return;
}
i6 = getPaddingLeft();
i5 = 0;
while (i5 < childCount) {
childAt3 = getChildAt(i5);
layoutParams = (LayoutParams) childAt3.getLayoutParams();
if (childAt3.getVisibility() == 8) {
paddingLeft = i6;
} else if (layoutParams.isOverflowButton) {
paddingLeft = i6;
} else {
i6 += layoutParams.leftMargin;
i8 = childAt3.getMeasuredWidth();
i10 = childAt3.getMeasuredHeight();
dividerWidth = i7 - (i10 / 2);
childAt3.layout(i6, dividerWidth, i6 + i8, i10 + dividerWidth);
paddingLeft = ((layoutParams.rightMargin + i8) + paddingRight) + i6;
}
i5++;
i6 = paddingLeft;
}
return;
}
super.onLayout(z, i, i2, i3, i4);
}
protected void onMeasure(int i, int i2) {
boolean z = this.mFormatItems;
this.mFormatItems = MeasureSpec.getMode(i) == 1073741824;
if (z != this.mFormatItems) {
this.mFormatItemsWidth = 0;
}
int size = MeasureSpec.getSize(i);
if (!(!this.mFormatItems || this.mMenu == null || size == this.mFormatItemsWidth)) {
this.mFormatItemsWidth = size;
this.mMenu.onItemsChanged(true);
}
int childCount = getChildCount();
if (!this.mFormatItems || childCount <= 0) {
for (int i3 = 0; i3 < childCount; i3++) {
LayoutParams layoutParams = (LayoutParams) getChildAt(i3).getLayoutParams();
layoutParams.rightMargin = 0;
layoutParams.leftMargin = 0;
}
super.onMeasure(i, i2);
return;
}
onMeasureExactFormat(i, i2);
}
public MenuBuilder peekMenu() {
return this.mMenu;
}
public void setExpandedActionViewsExclusive(boolean z) {
this.mPresenter.setExpandedActionViewsExclusive(z);
}
public void setMenuCallbacks(Callback callback, MenuBuilder.Callback callback2) {
this.mActionMenuPresenterCallback = callback;
this.mMenuBuilderCallback = callback2;
}
public void setOnMenuItemClickListener(OnMenuItemClickListener onMenuItemClickListener) {
this.mOnMenuItemClickListener = onMenuItemClickListener;
}
public void setOverflowIcon(Drawable drawable) {
getMenu();
this.mPresenter.setOverflowIcon(drawable);
}
public void setOverflowReserved(boolean z) {
this.mReserveOverflow = z;
}
public void setPopupTheme(int i) {
if (this.mPopupTheme != i) {
this.mPopupTheme = i;
if (i == 0) {
this.mPopupContext = getContext();
} else {
this.mPopupContext = new ContextThemeWrapper(getContext(), i);
}
}
}
public void setPresenter(ActionMenuPresenter actionMenuPresenter) {
this.mPresenter = actionMenuPresenter;
this.mPresenter.setMenuView(this);
}
public boolean showOverflowMenu() {
return this.mPresenter != null && this.mPresenter.showOverflowMenu();
}
}
| [
"[email protected]"
] | |
effbdf67cfeee112abcbd7680385c10ec958fddb | 2134ec7e8bb40e47f0878bb8c686ad24f0c2fb5c | /src/main/java/edu/pasha/cursova/controller/api/CustomersAPIController.java | f1b6608e8a2c2050aafcd2012fdd0365da73b37f | [] | no_license | pashasemenov/cursova | 4a3054db702ec10bdc9a9cf11d6f0fbf72898cfa | 3eba9e461699ec3afd0868bab349c215556e30b8 | refs/heads/master | 2022-11-05T10:45:40.968659 | 2020-06-24T12:18:01 | 2020-06-24T12:18:01 | 266,119,444 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 609 | java | package edu.pasha.cursova.controller.api;
import edu.pasha.cursova.model.Customers;
import edu.pasha.cursova.service.customers.Impls.CustomersServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@RequestMapping("/api/customers")
public class CustomersAPIController{
@Autowired
CustomersServiceImpl service;
@RequestMapping("/list")
List<Customers> getAll() {
return service.getAll();
}
}
| [
"[email protected]"
] | |
996954e8b612c6098aabeb90f2464497622ff0bc | ae08b25cf865339ae48d8b0facf80254fa8fad61 | /src/main/java/com/naive/phase/Item/ItemColliculus/ModelColliculus.java | e11f31cca786d424fb690694305e9d9a8f032366 | [] | no_license | Prunoideae/PhasePotion | fd4ca0abc060976f61cbefb364a8c94d2d32967e | 42b27720787efd869402115ff8e0ffb8153461a6 | refs/heads/master | 2022-08-28T09:46:44.832670 | 2020-05-18T05:36:43 | 2020-05-18T05:36:43 | 261,695,815 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,514 | java | package com.naive.phase.Item.ItemColliculus;
import com.naive.phase.Auxiliary.Helper.NBTHelper;
import com.naive.phase.Base.Render.ModelArmor;
import com.naive.phase.Base.Render.RecolorableModels;
import net.minecraft.client.model.ModelBox;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.items.CapabilityItemHandler;
import net.minecraftforge.items.IItemHandler;
import java.awt.*;
public class ModelColliculus extends ModelArmor {
private final RecolorableModels framePart;
private final ModelRenderer fix1;
private final ModelRenderer fix2;
private final ModelRenderer fix3;
private final ModelRenderer fix4;
private final RecolorableModels rightLight;
private final RecolorableModels leftLight2;
private final RecolorableModels leftLight1;
private final RecolorableModels matrix;
private final RecolorableModels rightGlassPart;
private final RecolorableModels leftGlassPart;
private final ModelRenderer helmAnchor;
public ModelColliculus() {
super(EntityEquipmentSlot.HEAD);
textureWidth = 64;
textureHeight = 64;
framePart = new RecolorableModels(this);
framePart.setRotationPoint(0.0F, 24.0F, 0.0F);
framePart.cubeList.add(new ModelBox(framePart, 0, 0, -5.0F, -28.5F, -4.21F, 10, 2, 9, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 12, 15, -0.02F, -29.5F, -5.01F, 5, 1, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 14, 19, -0.51F, -29.0F, -5.061F, 1, 2, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 10, 17, 1.01F, -26.5F, -5.01F, 4, 1, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 0, 15, -4.98F, -29.5F, -5.01F, 5, 1, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 0, 17, -5.01F, -26.5F, -5.01F, 4, 1, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 10, 19, -4.99F, -29.25F, -5.02F, 1, 3, 1, 0.0F, false));
framePart.cubeList.add(new ModelBox(framePart, 6, 19, 3.99F, -29.25F, -5.02F, 1, 3, 1, 0.0F, false));
fix2 = new ModelRenderer(this);
fix2.setRotationPoint(-1.01F, -26.0F, -4.51F);
framePart.addChild(fix2);
setRotationAngle(fix2, 0.0F, 0.0F, -0.7854F);
fix2.cubeList.add(new ModelBox(fix2, 0, 19, -0.3394F, -0.6323F, -0.54F, 2, 1, 1, 0.0F, false));
fix3 = new ModelRenderer(this);
fix3.setRotationPoint(0.99F, -26.0F, -4.51F);
framePart.addChild(fix3);
setRotationAngle(fix3, 0.0F, 0.0F, 0.7854F);
fix3.cubeList.add(new ModelBox(fix3, 0, 6, -1.6464F, -0.6464F, -0.548F, 2, 1, 1, 0.0F, false));
rightLight = new RecolorableModels(this);
rightLight.setRotationPoint(4.25F, -4.6F, -5.1F);
rightLight.cubeList.add(new ModelBox(rightLight, 5, 5, -1.0F, -1.0F, 0.07F, 1, 1, 1, 0.0F, false));
leftLight2 = new RecolorableModels(this);
leftLight2.setRotationPoint(0.0F, 24.0F, 0.0F);
leftLight2.cubeList.add(new ModelBox(leftLight2, 5, 1, -3.0F, -29.6F, -5.03F, 1, 1, 1, 0.0F, false));
leftLight1 = new RecolorableModels(this);
leftLight1.setRotationPoint(0.0F, 24.0F, 0.0F);
leftLight1.cubeList.add(new ModelBox(leftLight1, 5, 3, -4.25F, -29.6F, -5.03F, 1, 1, 1, 0.0F, false));
matrix = new RecolorableModels(this);
matrix.setRotationPoint(0.0F, 24.0F, 0.0F);
matrix.cubeList.add(new ModelBox(matrix, 0, 0, -1.0F, -29.4F, -5.1F, 2, 1, 1, 0.0F, false));
rightGlassPart = new RecolorableModels(this);
rightGlassPart.setRotationPoint(1.49F, -2.5F, -4.51F);
rightGlassPart.cubeList.add(new ModelBox(rightGlassPart, 0, 11, -1.0F, -2.5F, -0.53F, 4, 3, 1, 0.0F, false));
leftGlassPart = new RecolorableModels(this);
leftGlassPart.setRotationPoint(-3.5F, -1.0F, -9.0F);
leftGlassPart.cubeList.add(new ModelBox(leftGlassPart, 10, 11, -1.01F, -4.0F, 3.96F, 4, 3, 1, 0.0F, false));
fix1 = new ModelRenderer(this);
fix1.setRotationPoint(1.99F, -1.5F, 4.49F);
leftGlassPart.addChild(fix1);
setRotationAngle(fix1, 0.0F, 0.0F, -0.7854F);
fix1.cubeList.add(new ModelBox(fix1, 0, 4, -0.3395F, -0.6323F, -0.55F, 2, 1, 1, 0.0F, false));
fix4 = new ModelRenderer(this);
fix4.setRotationPoint(0.0F, 0.0F, 0.0F);
rightGlassPart.addChild(fix4);
setRotationAngle(fix4, 0.0F, 0.0F, 0.7854F);
fix4.cubeList.add(new ModelBox(fix4, 0, 2, -1.6463F, -0.6464F, -0.549F, 2, 1, 1, 0.0F, false));
helmAnchor = new ModelRenderer(this);
helmAnchor.addBox(-1.0f, -2.0f, 0.0f, 2, 2, 2);
helmAnchor.setRotationPoint(0f, 0f, 0f);
helmAnchor.addChild(framePart);
helmAnchor.addChild(rightLight);
helmAnchor.addChild(leftLight1);
helmAnchor.addChild(leftLight2);
helmAnchor.addChild(rightGlassPart);
helmAnchor.addChild(leftGlassPart);
helmAnchor.addChild(matrix);
;
}
@Override
public void render(Entity entityIn, float limbSwing, float limbSwingAmount, float ageInTicks, float netHeadYaw, float headPitch, float scale) {
//Try to set models color
if (entityIn instanceof EntityLivingBase) {
//Recolor the part
ItemStack colliculusStack = ((EntityLivingBase) entityIn).getItemStackFromSlot(EntityEquipmentSlot.HEAD);
NBTTagCompound tag = colliculusStack.getTagCompound();
NBTTagCompound colorTag = NBTHelper.getSafe(tag, "color");
Color color = Color.getHSBColor(
NBTHelper.getOrDefault(colorTag, "h", 0f),
NBTHelper.getOrDefault(colorTag, "s", 0f),
NBTHelper.getOrDefault(colorTag, "b", 0f));
framePart.setColor(color.getRed() / 255.f, color.getGreen() / 255.f, color.getBlue() / 255.f, 1);
IItemHandler itemCap = colliculusStack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null);
if (itemCap != null) {
ItemStack battery = itemCap.getStackInSlot(0);
ItemStack lensLeft = itemCap.getStackInSlot(1);
ItemStack lensRight = itemCap.getStackInSlot(2);
ItemStack matrix = itemCap.getStackInSlot(3);
if (!lensLeft.isEmpty()) {
leftGlassPart.showModel = true;
} else leftGlassPart.showModel = false;
if (!lensRight.isEmpty()) {
rightGlassPart.showModel = true;
} else rightGlassPart.showModel = false;
if (!matrix.isEmpty()) {
;
}
}
}
bipedHeadwear.showModel = false;
helmAnchor.showModel = true;
//leftGlassPart.setColor(color.getRed() / 255.f, color.getGreen() / 255.f, color.getBlue() / 255.f, 1);
bipedHead = helmAnchor;
super.render(entityIn, limbSwing, limbSwingAmount, ageInTicks, netHeadYaw, headPitch, scale);
}
public void setRotationAngle(ModelRenderer modelRenderer, float x, float y, float z) {
modelRenderer.rotateAngleX = x;
modelRenderer.rotateAngleY = y;
modelRenderer.rotateAngleZ = z;
}
}
| [
"[email protected]"
] | |
66198f2b95f5b45b97b37790bddb02ba48011075 | f9e705d82962c672c8485354a39c82a63ad8c9be | /src/main/java/com/ccycloud/aws/statsd/StatsdClient.java | a759a795b912434d7133b43a90eb614dbaaa044a | [] | no_license | jeremy-cc/statsd-java | 83b3e3ea482bb980739a8fa7b846ecd72a206119 | 545e0b2eac2fe7e5f4614086629209fb1d06b127 | refs/heads/master | 2021-01-18T23:10:11.664735 | 2017-04-20T14:01:48 | 2017-04-20T14:01:48 | 18,606,943 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 5,456 | java | package com.ccycloud.aws.statsd;
import com.ccycloud.aws.statsd.impl.config.Configuration;
import com.ccycloud.aws.statsd.impl.config.MissingConfigurationException;
import com.ccycloud.aws.statsd.impl.logging.SystemLogger;
import com.ccycloud.aws.statsd.impl.transport.UdpConnection;
import java.net.SocketException;
import java.net.UnknownHostException;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
/**
* Base class for the statsd package. Supports configuration; retrieval of the actual messaging interface
* and any and sundry functions
* <p/>
* Created by jeremyb on 03/04/2014.
*/
public class StatsdClient implements StatsdClientInterface {
private static volatile StatsdClient instance = null;
private Map<String, String> configuration = null;
private UdpConnection connection = null;
private com.ccycloud.aws.statsd.impl.StatsdClient client = null;
private AtomicBoolean configured = new AtomicBoolean(false);
private AtomicBoolean connected = new AtomicBoolean(false);
public static final String version = "1.0.15";
/**
* Get an instance of the statsd object, configured with the passed config hash
*
* @param configuration a Map of string key / value pairs configuring the instance
* @throws com.ccycloud.aws.statsd.impl.config.MissingConfigurationException if mandatory keys are not provided
*/
public static StatsdClient get(Map<String, String> configuration) throws MissingConfigurationException, UnknownHostException {
if(null == instance) {
synchronized (com.ccycloud.aws.statsd.impl.StatsdClient.class) {
if (null == instance) {
instance = new StatsdClient();
SystemLogger.info(String.format("Configuring connection to statsd server; client version: %s", version));
instance.configureWith(instance.validateMandatoryConfiguration(configuration));
instance.restart();
}
}
}
return instance;
}
@Override
public void incrementCounter(String prefix, String bucket, Map<String,String> tags, int count) {
client.incrementCounter(prefix, bucket, tags, count);
}
@Override
public void incrementSampleCounter(String prefix, String bucket, Map<String,String> tags, int count, double sampleRate) {
client.incrementSampleCounter(prefix, bucket, tags, count, sampleRate);
}
@Override
public void gaugeReading(String prefix, String bucket, Map<String,String> tags, int count) {
client.gaugeReading(prefix, bucket, tags, count);
}
@Override
public void timedEvent(String prefix, String bucket, Map<String,String> tags, int eventDurationInMs) {
client.timedEvent(prefix, bucket, tags, eventDurationInMs);
}
@Override
public void incrementUniqueCounter(String prefix, String bucket, Map<String,String> tags, int count) {
client.incrementUniqueCounter(prefix, bucket, tags, count);
}
public boolean isConfigured() {
return configured.get();
}
public boolean isConnected() {
return connected.get();
}
public com.ccycloud.aws.statsd.impl.StatsdClient buildClient(UdpConnection connection) {
return new com.ccycloud.aws.statsd.impl.StatsdClient(connection);
}
public void disconnect() {
if(null != connection && connection.isConnected()) {
if(null != client) {
// ensure we spool any queued data
client.finishMeasurements();
}
connection.disconnect();
}
}
/**
* close and recycle any UDP connections underlying this statsd object, create a new connection, and bind to the remote host
*/
private void restart() throws UnknownHostException{
if(null != connection && connection.isConnected()) {
if(null != client) {
// ensure we spool any queued data
client.finishMeasurements();
}
connection.disconnect();
connected.compareAndSet(true, false);
}
String host = configuration.get(Configuration.CONFIG_HOST);
int port = Integer.parseInt(configuration.get(Configuration.CONFIG_PORT));
connection = new UdpConnection(host, port);
client = buildClient(connection);
try {
connection.connect();
if(connection.isConnected()) {
connected.compareAndSet(false, true);
client.startMeasurements();
}
} catch(SocketException se) {
SystemLogger.error("Unable to connect to remote host", se);
}
}
// private methods
private void configureWith(Map<String, String> configuration) {
this.configuration = configuration;
this.configured.compareAndSet(false, true);
}
private Map<String, String> validateMandatoryConfiguration(Map<String, String> proposedConfiguration) throws MissingConfigurationException {
for (String s : Configuration.getMandatoryConfigKeys()) {
if (!proposedConfiguration.containsKey(s)) {
throw new MissingConfigurationException("Error: mandatory configuration value " + s + " was not specified.");
}
}
return proposedConfiguration;
}
private StatsdClient() {
super();
}
}
| [
"[email protected]"
] | |
e64a16b17eb7bfc7eee1025ad4d9e9b2fc41e281 | f284c32d86bcae5d466cf7361063e31fc9ac5a90 | /src/csdn/shimiso/eim/activity/ActivitySupport.java | 8cf84086a29f925fe171f51e3c5391a61c3b6b2d | [] | no_license | linuxjava/EIM | 7e8809653d8ef72ec0f76a6435b6ab15bae76e4c | 1737212d6ecd948b7fab312447da745d7a92a833 | refs/heads/master | 2016-09-06T14:45:34.399430 | 2014-05-23T11:21:03 | 2014-05-23T11:21:03 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,112 | java | package csdn.shimiso.eim.activity;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Notification;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.LocationManager;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Environment;
import android.provider.Settings;
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;
import csdn.shimiso.eim.R;
import csdn.shimiso.eim.comm.Constant;
import csdn.shimiso.eim.model.LoginConfig;
import csdn.shimiso.eim.service.IMChatService;
import csdn.shimiso.eim.service.IMContactService;
import csdn.shimiso.eim.service.IMSystemMsgService;
import csdn.shimiso.eim.service.ReConnectService;
/**
* Actity 工具支持类
*
* @author shimiso
*
*/
public class ActivitySupport extends Activity implements IActivitySupport {
protected Context context = null;
protected SharedPreferences preferences;
protected EimApplication eimApplication;
protected ProgressDialog pg = null;
protected NotificationManager notificationManager;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
context = this;
preferences = getSharedPreferences(Constant.LOGIN_SET, 0);
notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
pg = new ProgressDialog(context);
eimApplication = (EimApplication) getApplication();
eimApplication.addActivity(this);
}
@Override
protected void onStart() {
super.onStart();
}
@Override
protected void onResume() {
super.onResume();
}
@Override
protected void onPause() {
super.onPause();
}
@Override
protected void onStop() {
super.onStop();
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public ProgressDialog getProgressDialog() {
return pg;
}
@Override
public void startService() {
// 好友联系人服务
Intent server = new Intent(context, IMContactService.class);
context.startService(server);
// 聊天服务
Intent chatServer = new Intent(context, IMChatService.class);
context.startService(chatServer);
// 自动恢复连接服务
Intent reConnectService = new Intent(context, ReConnectService.class);
context.startService(reConnectService);
// 系统消息连接服务
Intent imSystemMsgService = new Intent(context,
IMSystemMsgService.class);
context.startService(imSystemMsgService);
}
/**
*
* 销毁服务.
*
* @author shimiso
* @update 2012-5-16 下午12:16:08
*/
@Override
public void stopService() {
// 好友联系人服务
Intent server = new Intent(context, IMContactService.class);
context.stopService(server);
// 聊天服务
Intent chatServer = new Intent(context, IMChatService.class);
context.stopService(chatServer);
// 自动恢复连接服务
Intent reConnectService = new Intent(context, ReConnectService.class);
context.stopService(reConnectService);
// 系统消息连接服务
Intent imSystemMsgService = new Intent(context,
IMSystemMsgService.class);
context.stopService(imSystemMsgService);
}
@Override
public void isExit() {
new AlertDialog.Builder(context).setTitle("确定退出吗?")
.setNeutralButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
stopService();
eimApplication.exit();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}).show();
}
@Override
public boolean hasInternetConnected() {
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(context.CONNECTIVITY_SERVICE);
if (manager != null) {
NetworkInfo network = manager.getActiveNetworkInfo();
if (network != null && network.isConnectedOrConnecting()) {
return true;
}
}
return false;
}
@Override
public boolean validateInternet() {
ConnectivityManager manager = (ConnectivityManager) context
.getSystemService(context.CONNECTIVITY_SERVICE);
if (manager == null) {
openWirelessSet();
return false;
} else {
NetworkInfo[] info = manager.getAllNetworkInfo();
if (info != null) {
for (int i = 0; i < info.length; i++) {
if (info[i].getState() == NetworkInfo.State.CONNECTED) {
return true;
}
}
}
}
openWirelessSet();
return false;
}
@Override
public boolean hasLocationGPS() {
LocationManager manager = (LocationManager) context
.getSystemService(context.LOCATION_SERVICE);
if (manager
.isProviderEnabled(android.location.LocationManager.GPS_PROVIDER)) {
return true;
} else {
return false;
}
}
@Override
public boolean hasLocationNetWork() {
LocationManager manager = (LocationManager) context
.getSystemService(context.LOCATION_SERVICE);
if (manager
.isProviderEnabled(android.location.LocationManager.NETWORK_PROVIDER)) {
return true;
} else {
return false;
}
}
@Override
public void checkMemoryCard() {
if (!Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
new AlertDialog.Builder(context)
.setTitle(R.string.prompt)
.setMessage("请检查内存卡")
.setPositiveButton(R.string.menu_settings,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
Intent intent = new Intent(
Settings.ACTION_SETTINGS);
context.startActivity(intent);
}
})
.setNegativeButton("退出",
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
eimApplication.exit();
}
}).create().show();
}
}
public void openWirelessSet() {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(context);
dialogBuilder
.setTitle(R.string.prompt)
.setMessage(context.getString(R.string.check_connection))
.setPositiveButton(R.string.menu_settings,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
dialog.cancel();
Intent intent = new Intent(
Settings.ACTION_WIRELESS_SETTINGS);
context.startActivity(intent);
}
})
.setNegativeButton(R.string.close,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int whichButton) {
dialog.cancel();
}
});
dialogBuilder.show();
}
/**
*
* 显示toast
*
* @param text
* @param longint
* @author shimiso
* @update 2012-6-28 下午3:46:18
*/
public void showToast(String text, int longint) {
Toast.makeText(context, text, longint).show();
}
@Override
public void showToast(String text) {
Toast.makeText(context, text, Toast.LENGTH_SHORT).show();
}
/**
*
* 关闭键盘事件
*
* @author shimiso
* @update 2012-7-4 下午2:34:34
*/
public void closeInput() {
InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (inputMethodManager != null && this.getCurrentFocus() != null) {
inputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus()
.getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
}
}
/**
*
* 发出Notification的method.
*
* @param iconId
* 图标
* @param contentTitle
* 标题
* @param contentText
* 你内容
* @param activity
* @author shimiso
* @update 2012-5-14 下午12:01:55
*/
public void setNotiType(int iconId, String contentTitle,
String contentText, Class activity, String from) {
/*
* 创建新的Intent,作为点击Notification留言条时, 会运行的Activity
*/
Intent notifyIntent = new Intent(this, activity);
notifyIntent.putExtra("to", from);
// notifyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
/* 创建PendingIntent作为设置递延运行的Activity */
PendingIntent appIntent = PendingIntent.getActivity(this, 0,
notifyIntent, 0);
/* 创建Notication,并设置相关参数 */
Notification myNoti = new Notification();
// 点击自动消失
myNoti.flags = Notification.FLAG_AUTO_CANCEL;
/* 设置statusbar显示的icon */
myNoti.icon = iconId;
/* 设置statusbar显示的文字信息 */
myNoti.tickerText = contentTitle;
/* 设置notification发生时同时发出默认声音 */
myNoti.defaults = Notification.DEFAULT_SOUND;
/* 设置Notification留言条的参数 */
myNoti.setLatestEventInfo(this, contentTitle, contentText, appIntent);
/* 送出Notification */
notificationManager.notify(0, myNoti);
}
@Override
public Context getContext() {
return context;
}
@Override
public SharedPreferences getLoginUserSharedPre() {
return preferences;
}
@Override
public void saveLoginConfig(LoginConfig loginConfig) {
preferences.edit()
.putString(Constant.XMPP_HOST, loginConfig.getXmppHost())
.commit();
preferences.edit()
.putInt(Constant.XMPP_PORT, loginConfig.getXmppPort()).commit();
preferences
.edit()
.putString(Constant.XMPP_SEIVICE_NAME,
loginConfig.getXmppServiceName()).commit();
preferences.edit()
.putString(Constant.USERNAME, loginConfig.getUsername())
.commit();
preferences.edit()
.putString(Constant.PASSWORD, loginConfig.getPassword())
.commit();
preferences.edit()
.putBoolean(Constant.IS_AUTOLOGIN, loginConfig.isAutoLogin())
.commit();
preferences.edit()
.putBoolean(Constant.IS_NOVISIBLE, loginConfig.isNovisible())
.commit();
preferences.edit()
.putBoolean(Constant.IS_REMEMBER, loginConfig.isRemember())
.commit();
preferences.edit()
.putBoolean(Constant.IS_ONLINE, loginConfig.isOnline())
.commit();
preferences.edit()
.putBoolean(Constant.IS_FIRSTSTART, loginConfig.isFirstStart())
.commit();
}
@Override
public LoginConfig getLoginConfig() {
LoginConfig loginConfig = new LoginConfig();
String a = preferences.getString(Constant.XMPP_HOST, null);
String b = getResources().getString(R.string.xmpp_host);
loginConfig.setXmppHost(preferences.getString(Constant.XMPP_HOST,
getResources().getString(R.string.xmpp_host)));
loginConfig.setXmppPort(preferences.getInt(Constant.XMPP_PORT,
getResources().getInteger(R.integer.xmpp_port)));
loginConfig.setUsername(preferences.getString(Constant.USERNAME, null));
loginConfig.setPassword(preferences.getString(Constant.PASSWORD, null));
loginConfig.setXmppServiceName(preferences.getString(
Constant.XMPP_SEIVICE_NAME,
getResources().getString(R.string.xmpp_service_name)));
loginConfig.setAutoLogin(preferences.getBoolean(Constant.IS_AUTOLOGIN,
getResources().getBoolean(R.bool.is_autologin)));
loginConfig.setNovisible(preferences.getBoolean(Constant.IS_NOVISIBLE,
getResources().getBoolean(R.bool.is_novisible)));
loginConfig.setRemember(preferences.getBoolean(Constant.IS_REMEMBER,
getResources().getBoolean(R.bool.is_remember)));
loginConfig.setFirstStart(preferences.getBoolean(
Constant.IS_FIRSTSTART, true));
return loginConfig;
}
@Override
public boolean getUserOnlineState() {
// preferences = getSharedPreferences(Constant.LOGIN_SET,0);
return preferences.getBoolean(Constant.IS_ONLINE, true);
}
@Override
public void setUserOnlineState(boolean isOnline) {
// preferences = getSharedPreferences(Constant.LOGIN_SET,0);
preferences.edit().putBoolean(Constant.IS_ONLINE, isOnline).commit();
}
@Override
public EimApplication getEimApplication() {
return eimApplication;
}
}
| [
"[email protected]"
] | |
330e4c67416c4784657586d3a8b4e118ac9349a8 | 46cf558ea4a9ddc16ee9597892f51b848eba1057 | /spring-batch-core/src/test/java/org/springframework/batch/core/repository/dao/JdbcStepExecutionDaoTests.java | 36123929ebe4198d1a14bae154fec50124017cd8 | [
"Apache-2.0"
] | permissive | mdeinum/spring-batch | ee064f01b3e8bf4ecd3129d5ddbb6a0e59039d18 | b0f7e3d6fed66459da0a247074d787787aa9c06b | refs/heads/master | 2023-06-10T05:52:45.949601 | 2023-05-17T14:15:55 | 2023-05-17T14:15:55 | 14,581,007 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,427 | java | /*
* Copyright 2008-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.batch.core.repository.dao;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.Test;
import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import org.springframework.transaction.annotation.Transactional;
@SpringJUnitConfig(locations = "sql-dao-test.xml")
class JdbcStepExecutionDaoTests extends AbstractStepExecutionDaoTests {
@Override
protected StepExecutionDao getStepExecutionDao() {
return (StepExecutionDao) applicationContext.getBean("stepExecutionDao");
}
@Override
protected JobRepository getJobRepository() {
deleteFromTables("BATCH_JOB_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION_CONTEXT", "BATCH_STEP_EXECUTION",
"BATCH_JOB_EXECUTION_PARAMS", "BATCH_JOB_EXECUTION", "BATCH_JOB_INSTANCE");
return (JobRepository) applicationContext.getBean("jobRepository");
}
/**
* Long exit descriptions are truncated on both save and update.
*/
@Transactional
@Test
void testTruncateExitDescription() {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 100; i++) {
sb.append("too long exit description");
}
String longDescription = sb.toString();
ExitStatus exitStatus = ExitStatus.FAILED.addExitDescription(longDescription);
stepExecution.setExitStatus(exitStatus);
((JdbcStepExecutionDao) dao).setExitMessageLength(250);
dao.saveStepExecution(stepExecution);
StepExecution retrievedAfterSave = dao.getStepExecution(jobExecution, stepExecution.getId());
assertTrue(retrievedAfterSave.getExitStatus().getExitDescription().length() < stepExecution.getExitStatus()
.getExitDescription().length(), "Exit description should be truncated");
dao.updateStepExecution(stepExecution);
StepExecution retrievedAfterUpdate = dao.getStepExecution(jobExecution, stepExecution.getId());
assertTrue(retrievedAfterUpdate.getExitStatus().getExitDescription().length() < stepExecution.getExitStatus()
.getExitDescription().length(), "Exit description should be truncated");
}
@Transactional
@Test
void testCountStepExecutions() {
// Given
dao.saveStepExecution(stepExecution);
// When
long result = dao.countStepExecutions(jobInstance, stepExecution.getStepName());
// Then
assertEquals(1, result);
}
@Transactional
@Test
void testDeleteStepExecution() {
// Given
dao.saveStepExecution(stepExecution);
// When
dao.deleteStepExecution(stepExecution);
// Then
assertNull(dao.getStepExecution(jobExecution, stepExecution.getId()));
}
}
| [
"[email protected]"
] | |
de8401422fbe4998a66610223cdbb1317259d905 | 3df46c46ce2cec2b8367c97264917dfa17f01da4 | /src/main/java/com/usa/g1rentcar/service/MessageService.java | ae83fd1491dc57398ede238e3ba93aa48dc30056 | [] | no_license | Charlies22/G1rentcar | 050b2273deedf9aff2bbc1b3a084da2000bdd8d1 | 4b26c86bb99a591aaecfde5c5c4770d42176eb0a | refs/heads/master | 2023-08-31T20:11:50.251504 | 2021-10-30T03:45:12 | 2021-10-30T03:45:12 | 422,775,517 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,803 | java | package com.usa.g1rentcar.service;
import com.usa.g1rentcar.model.Message;
import com.usa.g1rentcar.repository.MessageRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class MessageService {
@Autowired
private MessageRepository messageRepository;
public List<Message> getAll(){
return messageRepository.getAll();
}
public Optional<Message> getMessage(int messageId) {
return messageRepository.getMessage(messageId);
}
public Message save(Message message){
if(message.getIdMessage()==null){
return messageRepository.save(message);
}else{
Optional<Message> e= messageRepository.getMessage(message.getIdMessage());
if(e.isEmpty()){
return messageRepository.save(message);
}else{
return message;
}
}
}
public Message update(Message message){
if(message.getIdMessage()!=null){
Optional<Message> e= messageRepository.getMessage(message.getIdMessage());
if(!e.isEmpty()){
if(message.getMessageText()!=null){
e.get().setMessageText(message.getMessageText());
}
messageRepository.save(e.get());
return e.get();
}else{
return message;
}
}else{
return message;
}
}
public boolean deleteMessage(int messageId) {
Boolean aBoolean = getMessage(messageId).map(message -> {
messageRepository.delete(message);
return true;
}).orElse(false);
return aBoolean;
}
}
| [
"[email protected]"
] | |
9f0f05d08db710dc996e5c457fa1f83dbc15a581 | da178862ec39352bf9c9ef7372da1b7c14223d2c | /backend/src/main/java/com/example/himanshu/y/myapplication/backend/MyServlet.java | 31b227210ff537c646a9d1e27dcc439f8b887ecb | [] | no_license | himanshuyadav146/TwilioAppTest | edcfdf93feb0d438e8bc3d2d86ab93464d6c0447 | 6b233b0d0cf83940b61cd252f986a919a95ba27f | refs/heads/master | 2021-01-24T10:31:09.523717 | 2016-10-01T12:32:25 | 2016-10-01T12:32:25 | 69,734,626 | 0 | 1 | null | 2019-03-27T10:20:24 | 2016-10-01T11:19:19 | Java | UTF-8 | Java | false | false | 1,035 | java | /*
For step-by-step instructions on connecting your Android application to this backend module,
see "App Engine Java Servlet Module" template documentation at
https://github.com/GoogleCloudPlatform/gradle-appengine-templates/tree/master/HelloWorld
*/
package com.example.himanshu.y.myapplication.backend;
import java.io.IOException;
import javax.servlet.http.*;
public class MyServlet extends HttpServlet {
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/plain");
resp.getWriter().println("Please use the form to POST to this url");
}
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String name = req.getParameter("name");
resp.setContentType("text/plain");
if (name == null) {
resp.getWriter().println("Please enter a name");
}
resp.getWriter().println("Hello " + name);
}
}
| [
"[email protected]"
] | |
2af33ad17d156a459c7faf1683aabe4ef75df6ac | 583a5e0b5fb358d47475daddcdcbd70c3300a953 | /DS_Day3/Palindrome.java | c1203e9b0712c07c08bc19645db26f4fb8156e89 | [] | no_license | hardik-singhal/Assignments | 294d86388291d60dafd83bc93fcee84a60debece | f4cb4ab1fba0152bab22cddaa2504a2143257572 | refs/heads/master | 2020-03-26T21:51:54.594184 | 2018-10-22T08:56:54 | 2018-10-22T08:56:54 | 145,413,304 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,705 | java | import java.util.Scanner;
class Node
{
int data;
Node next;
}
public class Palindrome
{
Node head;
public void create(int n)
{
Scanner s = new Scanner(System.in);
Node tmp = null;
while(n > 0)
{
n--;
System.out.println("Enter the data to insert");
int d = s.nextInt();
Node newnode = new Node();
newnode.data = d;
if(head == null)
{
head = newnode;
tmp = newnode;
}
else
{
tmp.next = newnode;
tmp = tmp.next;
}
}
}
public void display()
{
Node tmp = head;
while(tmp != null)
{
System.out.println(tmp.data + " ");
tmp = tmp.next;
}
}
public void reverse()
{
Node cur = head, prev = null, next = null;
while(cur != null)
{
next = cur.next;
cur.next = prev;
prev = cur;
cur = next;
}
head = prev;
}
public void copy(Palindrome o)
{
Node tmp = o.head, ptr = null;
while(tmp != null)
{
if(head == null)
{
head = tmp;
ptr = tmp;
tmp = tmp.next;
}
else
{
ptr.next = tmp;
ptr = ptr.next;
tmp = tmp.next;
}
}
}
public boolean palin(Palindrome o)
{
Node tmp = o.head,ptr = head;
while(tmp != null)
{
if(tmp.data != ptr.data) return false;
tmp = tmp.next;
ptr = ptr.next;
}
return true;
}
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the size of list");
int n = sc.nextInt();
Palindrome obj = new Palindrome();
obj.create(n);
System.out.println("original linklist is");
//obj.display();
Palindrome o = new Palindrome();
o.copy(obj);
o.reverse();
if(o.palin(obj)) System.out.println("Yes palindrome");
else System.out.println("Not palindrome");
}
} | [
"[email protected]"
] | |
5c2812951b80020577cbad80ab22dabe456ae4bc | e0e9c1938fafcea8f26d1b76d76529cc9f44665a | /HoloDesign-ver.3/Sofbus24/src/bg/znestorov/sofbus24/entity/NotificationEntity.java | feb452456f02021beb08246ee914f9026da2d3d0 | [] | no_license | zdravko-nestorov/Sofbus-24 | 46c67dba692f64eb3fbe9b898d0a2cab2875be7c | c8922be49fb3209399084dfea1d1166758cf3c4d | refs/heads/master | 2023-09-03T16:36:24.270045 | 2023-08-22T08:17:43 | 2023-08-22T08:17:43 | 32,795,928 | 1 | 1 | null | 2022-12-16T05:44:49 | 2015-03-24T12:03:34 | Java | UTF-8 | Java | false | false | 2,952 | java | package bg.znestorov.sofbus24.entity;
import android.content.SharedPreferences;
import android.os.Bundle;
import bg.znestorov.sofbus24.utils.Constants;
import bg.znestorov.sofbus24.utils.Utils;
/**
* Contains the information received from the GCM service via a notification
*
* @author Zdravko Nestorov
* @version 1.0
*/
public class NotificationEntity {
private String date;
private NotificationTypeEnum type;
private String data;
/**
* Constructor used to retrieve the received notification from GCM service
*
* @param extras the received Bundle object
*/
public NotificationEntity(Bundle extras) {
if (extras != null && !extras.isEmpty()) {
this.date = extras
.getString(Constants.GCM_NOTIFICATION_RESPONSE_DATE_KEY);
try {
this.type = NotificationTypeEnum
.valueOf(extras
.getString(Constants.GCM_NOTIFICATION_RESPONSE_TYPE_KEY));
} catch (Exception e) {
this.type = NotificationTypeEnum.NONE;
}
this.data = extras
.getString(Constants.GCM_NOTIFICATION_RESPONSE_DATA_KEY);
}
}
/**
* Constructor used to retrieve the notification data from the
* SharedPreferences file
*
* @param sharedPreferences the GCM SharedPreferences file
*/
public NotificationEntity(SharedPreferences sharedPreferences) {
this.date = sharedPreferences.getString(
Constants.GCM_PREFERENCES_NOTIFICATION_DATE, "");
try {
this.type = NotificationTypeEnum
.valueOf(sharedPreferences.getString(
Constants.GCM_PREFERENCES_NOTIFICATION_TYPE, ""));
} catch (Exception e) {
this.type = null;
}
this.data = sharedPreferences.getString(
Constants.GCM_PREFERENCES_NOTIFICATION_DATA, "");
}
public String getDate() {
return date;
}
public void setDate(String date) {
this.date = date;
}
public NotificationTypeEnum getType() {
return type;
}
public void setType(NotificationTypeEnum type) {
this.type = type;
}
public String getData() {
return data;
}
public void setData(String data) {
this.data = data;
}
/**
* Indicates if the notification params are correctly set
*
* @return if the send notification is correct
*/
public boolean isValid() {
return !Utils.isEmpty(date) && type != null && !Utils.isEmpty(data);
}
@Override
public String toString() {
return getClass().getName() + " {\n\tdate: " + date + "\n\ttype: "
+ type + "\n\tdata: " + data + "\n}";
}
} | [
"[email protected]"
] | |
975027566fa818774f6f606820d0fb6eb2d7d2d3 | 831c497faf19b7f726f292bc999c6c24cc514e37 | /app/src/main/java/com/example/b_safe/ui/slideshow/SlideshowViewModel.java | 45f9399b59dd3814afa51692605f61b8b4322bd8 | [] | no_license | Preetojha08/Prototype-of-BSAFE-Android-Application | 81be5d2f0595c975a413315975074a33d91a773f | 5d4be17a1266d79acaa6fa35a73885aea50a5c2d | refs/heads/master | 2023-04-28T15:40:08.716820 | 2021-05-09T18:57:51 | 2021-05-09T18:57:51 | 365,826,455 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 461 | java | package com.example.b_safe.ui.slideshow;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;
public class SlideshowViewModel extends ViewModel {
private MutableLiveData<String> mText;
public SlideshowViewModel() {
mText = new MutableLiveData<>();
mText.setValue("This is slideshow fragment");
}
public LiveData<String> getText() {
return mText;
}
} | [
"[email protected]"
] | |
41e8f04a7c0363f63e171cc0d3eb6725e7903f60 | 0112881f0b99ec405b6a0cd0ca29ab67089b2006 | /src/proyectofinaloracle/Conecciones/Jtree/JTreePopup.java | 143472ffc44f3a257f1bf3170feeba41e1d5e03e | [] | no_license | iancpcc/FinalOracle | 5b07d9af3e45a7d774a1a54d7bae8f603414dc55 | 478e7a3a33b39df6f7286725f65a896af84b710e | refs/heads/master | 2023-02-22T20:41:32.632377 | 2021-01-28T16:40:02 | 2021-01-28T16:40:02 | 328,193,163 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,145 | 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 proyectofinaloracle.Conecciones.Jtree;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPopupMenu;
import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE;
import proyectofinaloracle.Conecciones.Conexion;
import proyectofinaloracle.Conecciones.Consultas;
import proyectofinaloracle.UIGestor;
import proyectofinaloracle.UIRol;
import proyectofinaloracle.UIUsuarios;
/**
*
* @author chris
*/
public class JTreePopup extends JPopupMenu {
public JTreePopup(Object obj) {
JMenuItem menuItemAdd = new JMenuItem("Crear Usuario");
JMenuItem menuItemUpdate = new JMenuItem("Editar usuario");
JMenuItem menuItemDelete = new JMenuItem("Eliminar usuario");
JMenuItem menuItemRol = new JMenuItem("Crear Roles");
add(menuItemUpdate);
addSeparator();
add(menuItemAdd);
add(menuItemRol);
addSeparator();
add(menuItemDelete);
menuItemAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
UIUsuarios uiUser = new UIUsuarios();
uiUser.setVisible(true);
}
});
menuItemUpdate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
UIUsuarios.accion = "editar";
UIUsuarios.nomUsuario = obj.toString();
UIUsuarios uiUser = new UIUsuarios();
UIUsuarios.txtUsuario.setEnabled(false);
UIUsuarios.BtnCrear.setText("Actualizar");
uiUser.setVisible(true);
// uiUser.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
}
});
menuItemRol.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
UIRol rol = new UIRol();
rol.setVisible(true);
}
});
menuItemDelete.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int res = JOptionPane.showConfirmDialog(null, "Aviso");
if (res == 0) {
Consultas query = new Consultas();
JArbol tree = new JArbol();
try {
int rs = query.eliminarUsuario(obj.toString());
if (rs == 0) {
JOptionPane.showMessageDialog(null, "Usuario Elimininado", "SQL", JOptionPane.INFORMATION_MESSAGE);
UIGestor.Arbol.setModel(tree.crearNodosxNombre(Conexion.or));
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, ex.toString(), "SQL", JOptionPane.INFORMATION_MESSAGE);
}
}
}
});
}
}
| [
"[email protected]"
] | |
903c42bd1fb67a8077d97410904235b9894d477b | 793df459501d0113d6acdd41faf590122a242796 | /confu-master/benchmarks/xalan/original_source_from_jdcore/org/apache/wml/dom/WMLMetaElementImpl.java | 19105544a9f7bac6a832b46bd02d265e07040792 | [
"Apache-2.0"
] | permissive | tsmart-date/nasac-2017-demo | fc9c927eb6cc88e090066fc351b58c74a79d936e | 07f2d3107f1b40984ffda9e054fa744becd8c8a3 | refs/heads/master | 2021-07-15T21:29:42.245245 | 2017-10-24T14:28:14 | 2017-10-24T14:28:14 | 105,340,725 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,607 | java | package org.apache.wml.dom;
import org.apache.wml.WMLMetaElement;
import org.apache.xerces.dom.ElementImpl;
public class WMLMetaElementImpl
extends WMLElementImpl
implements WMLMetaElement
{
private static final long serialVersionUID = -2791663042188681846L;
public WMLMetaElementImpl(WMLDocumentImpl paramWMLDocumentImpl, String paramString)
{
super(paramWMLDocumentImpl, paramString);
}
public void setForua(boolean paramBoolean)
{
setAttribute("forua", paramBoolean);
}
public boolean getForua()
{
return getAttribute("forua", false);
}
public void setScheme(String paramString)
{
setAttribute("scheme", paramString);
}
public String getScheme()
{
return getAttribute("scheme");
}
public void setClassName(String paramString)
{
setAttribute("class", paramString);
}
public String getClassName()
{
return getAttribute("class");
}
public void setHttpEquiv(String paramString)
{
setAttribute("http-equiv", paramString);
}
public String getHttpEquiv()
{
return getAttribute("http-equiv");
}
public void setId(String paramString)
{
setAttribute("id", paramString);
}
public String getId()
{
return getAttribute("id");
}
public void setContent(String paramString)
{
setAttribute("content", paramString);
}
public String getContent()
{
return getAttribute("content");
}
public void setName(String paramString)
{
setAttribute("name", paramString);
}
public String getName()
{
return getAttribute("name");
}
}
| [
"[email protected]"
] | |
c6fb7374d9cc01a8929d7ee1ab668727ac93c50e | 300aefc3ada2c9f2c41e8aa01ba31971c87feb5b | /criacionais/builder/src/com/builder/builder/impl/CarBuilder.java | 655fc49ca5f8a7ee43a1b016fb7b7dff12e80bb2 | [] | no_license | rafaelcaetano/mergulheNosPadroesDeProjeto | 886796546991eb350c939d3fb8c40dd114b0c339 | 5b372eab20bac4f4453b2a21d899e22c3d6bd43e | refs/heads/master | 2023-04-08T19:35:35.092723 | 2021-04-19T01:23:26 | 2021-04-19T01:23:26 | 346,550,008 | 0 | 0 | null | 2021-04-19T01:23:26 | 2021-03-11T02:09:05 | Java | UTF-8 | Java | false | false | 1,022 | java | package com.builder.builder.impl;
import com.builder.builder.Builder;
import com.builder.engine.Engine;
import com.builder.product.Car;
public class CarBuilder implements Builder {
private Car car;
public CarBuilder() {
this.reset();
}
@Override
public void reset() {
this.car = new Car();
}
@Override
public void setSeats(int numSeats) {
System.out.println("Numeros de assentos no carro: " + numSeats);
}
@Override
public void setEngine(Engine engine) {
System.out.println("Tipo de motor" + engine.getName());
}
@Override
public void setTripComputer(boolean hasTripComputer) {
System.out.println("Tem computador de bordo: " + (hasTripComputer ? "sim" : "nao") );
}
@Override
public void setGPS(boolean hasGPS) {
System.out.println("Tem GPS: " + (hasGPS ? "sim" : "nao"));
}
public Car getProduct() {
Car product = this.car;
this.reset();
return product;
}
}
| [
"[email protected]"
] | |
3715f969f64d48d5463eb9e79269cfa025379615 | a8b5525231d52928ff9779b75dd2fc71ad10f609 | /src/learn/DecodeWays91.java | 3a6307dbbd720d76066adcfd6ce56f339c7dd836 | [] | no_license | Gurudattapai/ds-algo | d053f3f8ca4496454b7ddb5b8fc84150fb3a0442 | 76a7995a9e5b34aabbaaa7e288d1ec90c7bf9926 | refs/heads/master | 2020-09-23T04:18:31.121529 | 2020-04-12T10:21:34 | 2020-04-12T10:21:34 | 225,399,585 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 595 | java | package learn;
public class DecodeWays91 {
public static int numDecodings(String s) {
int [] dp = new int [s.length() + 1];
dp[0] = 1;
dp[1] = s.charAt(0) == '0' ? 0 : 1;
for (int i = 2; i <= s.length(); i++) {
int last = Integer.parseInt(s.substring(i-1, i));
int lastTwo = Integer.parseInt(s.substring(i-2, i));
if (last >= 1) {
dp[i] += dp[i-1];
}
if (lastTwo >= 10 && lastTwo <= 26) {
dp[i] += dp[i-2];
}
}
return dp[dp.length - 1];
}
public static void main(String [] args) {
System.out.println(numDecodings("226"));
}
}
| [
"[email protected]"
] | |
b7ea3051e21427769df62b8255734b88df5565cd | 059d3e11abf6566435e63d94f0d0c9427b6d10af | /src/Test/t229/t1.java | bac6b68a73ba3e5074ac95a1a700c28547a1b717 | [] | no_license | shuxin233/Algorithm_JAVA | 160392567607295503b6e42f7c93c66dd3ae6bea | 50936c7f2da91c5169a86a921034fa3aec92c614 | refs/heads/master | 2023-03-09T22:27:21.692154 | 2021-02-25T09:12:27 | 2021-02-25T09:12:27 | 328,362,555 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 791 | java | package Test.t229;
public class t1 {
public static void main(String[] args) {
}
public String mergeAlternately(String word1, String word2) {
String ans="";
int len1=word1.length();
int len2=word2.length();
if(len1<len2){
for (int k = 0; k <len1; k++) {
ans+=word1.charAt(k);
ans+=word2.charAt(k);
}
for (int k = len1; k <len2 ; k++) {
ans+=word2.charAt(k);
}
}else {
for (int k = 0; k <len2; k++) {
ans+=word1.charAt(k);
ans+=word2.charAt(k);
}
for (int k = len2; k <len1 ; k++) {
ans+=word1.charAt(k);
}
}
return ans;
}
}
| [
"[email protected]"
] | |
aa42c4670fa4c037a3b48c5265b59950acb3d91c | 54f7c6e7d11a5a5d39986994256cc348c151ba78 | /src/com/d3/d3xmpp/d3View/MyListView.java | 13b3dd183f5e93ef78b805181708c1085b65028f | [] | no_license | maclala/D3Xmpp_v2 | fbf6898cdc9e0d146dc81f2ccd6a4bba0f55c1f7 | 0380712995d96e1aa30c06b65abe00aa1368d96d | refs/heads/master | 2021-01-23T12:16:45.824623 | 2015-08-06T08:27:53 | 2015-08-06T08:27:53 | 40,288,231 | 3 | 0 | null | null | null | null | GB18030 | Java | false | false | 11,923 | java | package com.d3.d3xmpp.d3View;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.ProgressBar;
import android.widget.TextView;
import com.d3.d3xmpp.R;
import com.nostra13.universalimageloader.core.ImageLoader;
public class MyListView extends ListView implements OnScrollListener {
private final String TAG = "listview";
private final int RELEASE_To_REFRESH = 0;
private final int PULL_To_REFRESH = 1;
private final int REFRESHING = 2;
private final int DONE = 3;
private final int LOADING = 4;
// 实际的padding的距离与界面上偏移距离的比例
private final int RATIO = 5;
private LayoutInflater inflater;
private LinearLayout headView;
private TextView tipsTextview;
private TextView lastUpdatedTextView;
private ImageView arrowImageView;
private ProgressBar progressBar;
private RotateAnimation animation;
private RotateAnimation reverseAnimation;
// 用于保证startY的值在一个完整的touch事件中只被记录一次
private boolean isRecored;
private int headContentWidth;
private int headContentHeight;
private int startY;
public int firstItemIndex;
private int state;
private boolean isBack;
private OnRefreshListener refreshListener;
private boolean isRefreshable;
private DateFormat ymdt;
private boolean pauseOnScroll = true;
private boolean pauseOnFling = true;
public MyListView(Context context) {
super(context);
init(context);
}
public MyListView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);
}
private void init(Context context) {
setCacheColorHint(context.getResources().getColor(R.color.white));
inflater = LayoutInflater.from(context);
headView = (LinearLayout) inflater.inflate(R.layout.head, null);
arrowImageView = (ImageView) headView
.findViewById(R.id.head_arrowImageView);
// arrowImageView.setMinimumWidth(70);
arrowImageView.setMinimumHeight(50);
progressBar = (ProgressBar) headView
.findViewById(R.id.head_progressBar);
tipsTextview = (TextView) headView.findViewById(R.id.head_tipsTextView);
lastUpdatedTextView = (TextView) headView
.findViewById(R.id.head_lastUpdatedTextView);
measureView(headView);
headContentHeight = headView.getMeasuredHeight();
headContentWidth = headView.getMeasuredWidth();
// headView.setPadding(0, 0, 0, 0);
headView.setPadding(0, -1 * headContentHeight, 0, 0);
headView.invalidate();
Log.v("size", "width:" + headContentWidth + " height:"
+ headContentHeight);
addHeaderView(headView, null, false);
setOnScrollListener(this);
animation = new RotateAnimation(0, -180,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
animation.setInterpolator(new LinearInterpolator());
animation.setDuration(250);
animation.setFillAfter(true);
reverseAnimation = new RotateAnimation(-180, 0,
RotateAnimation.RELATIVE_TO_SELF, 0.5f,
RotateAnimation.RELATIVE_TO_SELF, 0.5f);
reverseAnimation.setInterpolator(new LinearInterpolator());
reverseAnimation.setDuration(200);
reverseAnimation.setFillAfter(true);
state = DONE;
isRefreshable = false;
ymdt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
}
public void onScroll(AbsListView arg0, int firstVisiableItem, int arg2,
int arg3) {
firstItemIndex = firstVisiableItem;
}
public void onScrollStateChanged(AbsListView arg0, int scrollState) {
switch (scrollState) {
case OnScrollListener.SCROLL_STATE_IDLE:
// ImageLoader.getInstance().resume();
break;
case OnScrollListener.SCROLL_STATE_TOUCH_SCROLL:
if (pauseOnScroll) {
// ImageLoader.getInstance().pause();
}
break;
case OnScrollListener.SCROLL_STATE_FLING:
if (pauseOnFling) {
// ImageLoader.getInstance().pause();
}
break;
}
}
/**
* 默认true
* @param pauseOnScroll
* @param pauseOnFling
*/
public void setOnScrollLoading(boolean pauseOnScroll,boolean pauseOnFling){
this.pauseOnScroll = pauseOnScroll;
this.pauseOnFling = pauseOnFling;
}
public boolean onTouchEvent(MotionEvent event) {
if (isRefreshable) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
if (firstItemIndex == 0 && !isRecored) {
isRecored = true;
startY = (int) event.getY();
Log.v(TAG, "在down时候记录当前位置");
}
break;
case MotionEvent.ACTION_UP:
if (state != REFRESHING && state != LOADING) {
if (state == DONE) {
// 什么都不做
}
if (state == PULL_To_REFRESH) {
state = DONE;
changeHeaderViewByState();
Log.v(TAG, "由下拉刷新状态,到done状态");
}
if (state == RELEASE_To_REFRESH) {
state = REFRESHING;
changeHeaderViewByState();
onRefresh();
Log.v(TAG, "由松开刷新状态,到done状态");
}
}
isRecored = false;
isBack = false;
break;
case MotionEvent.ACTION_MOVE:
int tempY = (int) event.getY();
if (!isRecored && firstItemIndex == 0) {
Log.v(TAG, "在move时候记录下位置");
isRecored = true;
startY = tempY;
}
if (state != REFRESHING && isRecored && state != LOADING) {
// 保证在设置padding的过程中,当前的位置一直是在head,否则如果当列表超出屏幕的话,当在上推的时候,列表会同时进行滚动
// 可以松手去刷新了
if (state == RELEASE_To_REFRESH) {
setSelection(0);
// 往上推了,推到了屏幕足够掩盖head的程度,但是还没有推到全部掩盖的地步
if (((tempY - startY) / RATIO < headContentHeight)
&& (tempY - startY) > 0) {
state = PULL_To_REFRESH;
changeHeaderViewByState();
Log.v(TAG, "由松开刷新状态转变到下拉刷新状态");
}
// 一下子推到顶了
else if (tempY - startY <= 0) {
state = DONE;
changeHeaderViewByState();
Log.v(TAG, "由松开刷新状态转变到done状态");
}
// 往下拉了,或者还没有上推到屏幕顶部掩盖head的地步
else {
// 不用进行特别的操作,只用更新paddingTop的值就行了
}
}
// 还没有到达显示松开刷新的时候,DONE或者是PULL_To_REFRESH状态
if (state == PULL_To_REFRESH) {
setSelection(0);
// 下拉到可以进入RELEASE_TO_REFRESH的状态
if ((tempY - startY) / RATIO >= headContentHeight) {
state = RELEASE_To_REFRESH;
isBack = true;
changeHeaderViewByState();
Log.v(TAG, "由done或者下拉刷新状态转变到松开刷新");
}
// 上推到顶了
else if (tempY - startY <= 0) {
state = DONE;
changeHeaderViewByState();
Log.v(TAG, "由DOne或者下拉刷新状态转变到done状态");
}
}
// done状态下
if (state == DONE) {
if (tempY - startY > 0) {
state = PULL_To_REFRESH;
changeHeaderViewByState();
}
}
// 更新headView的size
if (state == PULL_To_REFRESH) {
headView.setPadding(0, -1 * headContentHeight
+ (tempY - startY) / RATIO, 0, 0);
}
// 更新headView的paddingTop
if (state == RELEASE_To_REFRESH) {
headView.setPadding(0, (tempY - startY) / RATIO
- headContentHeight, 0, 0);
}
}
break;
}
}
return super.onTouchEvent(event);
}
// 当状态改变时候,调用该方法,以更新界面
private void changeHeaderViewByState() {
switch (state) {
case RELEASE_To_REFRESH:
arrowImageView.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
tipsTextview.setVisibility(View.VISIBLE);
lastUpdatedTextView.setVisibility(View.VISIBLE);
arrowImageView.clearAnimation();
arrowImageView.startAnimation(animation);
tipsTextview.setText("松开刷新");
Log.v(TAG, "当前状态,松开刷新");
break;
case PULL_To_REFRESH:
progressBar.setVisibility(View.GONE);
tipsTextview.setVisibility(View.VISIBLE);
lastUpdatedTextView.setVisibility(View.VISIBLE);
arrowImageView.clearAnimation();
arrowImageView.setVisibility(View.VISIBLE);
// 是由RELEASE_To_REFRESH状态转变来的
if (isBack) {
isBack = false;
arrowImageView.clearAnimation();
arrowImageView.startAnimation(reverseAnimation);
tipsTextview.setText("下拉刷新");
} else {
tipsTextview.setText("下拉刷新");
}
Log.v(TAG, "当前状态,下拉刷新");
break;
case REFRESHING:
headView.setPadding(0, 0, 0, 0);
progressBar.setVisibility(View.VISIBLE);
arrowImageView.clearAnimation();
arrowImageView.setVisibility(View.GONE);
tipsTextview.setText("正在刷新...");
lastUpdatedTextView.setVisibility(View.VISIBLE);
Log.v(TAG, "当前状态,正在刷新...");
break;
case DONE:
headView.setPadding(0, -1 * headContentHeight, 0, 0);
progressBar.setVisibility(View.GONE);
arrowImageView.clearAnimation();
arrowImageView.setImageResource(R.drawable.wb_refresh_arrow);
tipsTextview.setText("下拉刷新");
lastUpdatedTextView.setVisibility(View.VISIBLE);
Log.v(TAG, "当前状态,done");
break;
}
}
public void setonRefreshListener(OnRefreshListener refreshListener) {
this.refreshListener = refreshListener;
isRefreshable = true;
}
public interface OnRefreshListener {
public void onRefresh();
}
public void onRefreshComplete() {
state = DONE;
lastUpdatedTextView.setText("最近更新:" + ymdt.format(new Date()));
changeHeaderViewByState();
}
private void onRefresh() {
if (refreshListener != null) {
refreshListener.onRefresh();
}
}
public void showRefreshing(){
state = REFRESHING;
changeHeaderViewByState();
onRefresh();
}
// 此方法直接照搬自网络上的一个下拉刷新的demo,此处是“估计”headView的width以及height
private void measureView(View child) {
ViewGroup.LayoutParams p = child.getLayoutParams();
if (p == null) {
p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
int lpHeight = p.height;
int childHeightSpec;
if (lpHeight > 0) {
childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,
MeasureSpec.EXACTLY);
} else {
childHeightSpec = MeasureSpec.makeMeasureSpec(0,
MeasureSpec.UNSPECIFIED);
}
child.measure(childWidthSpec, childHeightSpec);
}
public void setAdapter(BaseAdapter adapter) {
lastUpdatedTextView.setText("最近更新:" + ymdt.format(new Date()));
super.setAdapter(adapter);
}
public void setBackgroundColor(String color,String textColor){
headView.setBackgroundColor(Color.parseColor(color));
tipsTextview.setBackgroundColor(Color.parseColor(textColor));
lastUpdatedTextView.setBackgroundColor(Color.parseColor(textColor));
}
}
| [
"[email protected]"
] | |
9a4a86b0628135b4239dd5fc7797876e89737cca | d74e9d6f02b3f0f83e92667ef95ca4773e8f2692 | /beacon/src/demo/com/beacon/demo/dao/UserDao.java | 534f391472b48222107d738ea4c6ef51da077e71 | [] | no_license | shenlj/dream | 99f9e0ce5278c2c935eb20e9e7fb4f6f8214e33d | 1429c548d90a01b6fc92067f689502c3568a4313 | refs/heads/master | 2021-01-02T09:19:50.318289 | 2014-08-16T01:22:21 | 2014-08-16T01:24:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 165 | java | package com.beacon.demo.dao;
import com.beacon.demo.entity.User;
import com.wholetech.commons.dao.BaseDao;
public interface UserDao extends BaseDao<User> {
} | [
"[email protected]"
] | |
2164c16d00d4ac4f1a4a7614b86a110337d54c68 | 6cef8e64ff119221a755125f55efe3134ff7b0b0 | /app/src/main/java/com/margarita/vk_app/ui/holder/attachment/ImageAttachmentHolder.java | 47608a0ee5889a3c79ca01c3d46c61b95ebf80e6 | [] | no_license | margarita-v/VkApp | 57bdc43019489a400371fbb518211bdf6a6a2121 | 9a8de8e57e2272ec59f33914021b945d35e12a71 | refs/heads/master | 2021-09-03T09:00:29.327993 | 2018-01-07T20:50:52 | 2018-01-07T20:50:52 | 109,434,064 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,390 | java | package com.margarita.vk_app.ui.holder.attachment;
import android.view.View;
import android.widget.ImageView;
import com.margarita.vk_app.R;
import com.margarita.vk_app.VkApplication;
import com.margarita.vk_app.common.manager.VkFragmentManager;
import com.margarita.vk_app.models.view.attachment.ImageAttachment;
import com.margarita.vk_app.ui.fragment.attachment.ImageFragment;
import javax.inject.Inject;
import butterknife.BindView;
import butterknife.ButterKnife;
public class ImageAttachmentHolder extends BaseAttachmentHolder<ImageAttachment> {
@BindView(R.id.ivAttachmentImage)
ImageView ivAttachmentImage;
@Inject
VkFragmentManager fragmentManager;
public ImageAttachmentHolder(View itemView) {
super(itemView);
ButterKnife.bind(this, itemView);
VkApplication.getApplicationComponent().inject(this);
}
@Override
public void bindViewHolder(ImageAttachment imageAttachment) {
if (imageAttachment.isNeedClick()) {
// Load image in web view with zoom functions
addFragmentOnClick(fragmentManager,
ImageFragment.newInstance(imageAttachment.getUrl()));
}
loadImage(imageAttachment.getUrl(), ivAttachmentImage);
}
@Override
public void unbindViewHolder() {
super.unbindViewHolder();
clearImageView(ivAttachmentImage);
}
}
| [
"[email protected]"
] | |
7f89e6c6829574e565f4c9e803dfade68f597968 | 128596448c86f351876a0a0f130397244708b153 | /src/main/java/io/github/furuewl/springboot/sell/vo/ProductVo.java | 28da1c9ba69a5afc6fa546acffe3180d5a7aecd9 | [] | no_license | Gitsifu/spring-boot-sell | a26a4130bbca21e81a4e6db91cc0fd6c1800188f | 38c0053fd9227d158e31c94968da569266af548c | refs/heads/master | 2021-08-07T23:59:02.543941 | 2017-11-09T06:35:34 | 2017-11-09T06:35:34 | 108,992,515 | 0 | 1 | null | 2017-11-09T06:35:35 | 2017-10-31T12:28:42 | Java | UTF-8 | Java | false | false | 457 | java | package io.github.furuewl.springboot.sell.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
/**
* 商品(包含类目)
*
* @author weilai
* 2017-10-14 14:35
*/
@Data
public class ProductVo {
@JsonProperty("name")
private String categoryName;
@JsonProperty("type")
private Integer categoryType;
@JsonProperty("foods")
private List<ProductInfoVo> productInfoVoList;
}
| [
"[email protected]"
] | |
9c34f1efaabcaafdb9e5d953732b6c2b34840b0f | 89955e9a7307314bc420418f4b7ebc31c346e8ad | /even.java | 961699d623453a3b9498272de0396364de8867a9 | [] | no_license | Nandhini48/efjlwefkjf- | d396c9c4e1c462bd26fea88a9459895250114a06 | 8e0c9f86c5ba70ec1b6d0ce0863c727d6329fdac | refs/heads/master | 2021-01-21T01:44:30.764513 | 2016-07-16T10:24:25 | 2016-07-16T10:24:25 | 63,474,025 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 425 | java | import java.util.Scanner;
public class EvenOrOdd{
public static void main(String[] args) {
int n;
System.out.println("enter the number to check");
Scanner a=new Scanner(System.in);
n=a.nextInt();
if(n%2==0){
System.out.println("even number");
}
else
System.out.println("odd number");
}
}
| [
"[email protected]"
] | |
fb0e149cc73b59c1c752393a035276d4d0d58ddb | 7935a62ed60a07dfcc5fa8965cab59c07ae1ab0b | /02-expressions-statements-code_blocks-methods-more/02-StatementsWhiteSpaceAndIndenting/src/com/bayrktlihn/Main.java | ed62f4ad0540930d94c110f6af483d948dd0f784 | [] | no_license | bayrktlihn/java | 67cc755906f7950ca7fdf0dc6400dbd073413601 | 50ac568b68f5764bb7deec5389144c81224eeed0 | refs/heads/master | 2021-02-18T09:40:48.093390 | 2020-03-10T03:53:10 | 2020-03-10T03:53:10 | 243,292,994 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 463 | java | package com.bayrktlihn;
public class Main {
public static void main(String[] args) {
int myVariable
=
50
;
if(myVariable == 50) {
System.out.println("Printed");
}
myVariable++;
myVariable--;
System.out.println("This is a test");
System.out.println("This is" +
" another" +
" still more.");
int anotherVariable = 50;myVariable--;System.out.println("This is another one");
}
}
| [
"[email protected]"
] | |
d0d844a2a8beaa239602ef8b2d127f54c9eb80aa | d5e336a49c4fa55906d7be2f406a787d759b3ec6 | /src/题目/_0028_KMP_有意思和30题思路类似_实现strStr/AnotherSolution.java | 364cdd8861eb9e7d24bcb53ba57f032d82b0955a | [] | no_license | chenxy1996/leetcode | 68853a77425041b9ec702f72630fac68e9835031 | 5204bd426a9e42bf8450704c42cd9179348bc676 | refs/heads/master | 2021-07-02T09:11:33.201710 | 2020-10-14T09:02:36 | 2020-10-14T09:02:36 | 179,980,417 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,528 | java | package 题目._0028_KMP_有意思和30题思路类似_实现strStr;
public class AnotherSolution {
public static int strStr(String haystack, String needle) {
if (haystack == null || needle == null || haystack.length() < needle.length()) {
return -1;
}
if (needle.length() == 0) {
return 0;
}
char[] hs = haystack.toCharArray();
char[] ns = needle.toCharArray();
long hash = 0;
long nHash = 0;
long module = 1L << 31;
for (char c : ns) {
nHash = nHash * 26 % module + (c - 'a');
}
long a = 1;
for (int i = 0; i < ns.length; i++) {
a = (a * 26) % module;
}
for (int i = 0; i < hs.length; i++) {
char c = hs[i];
if (i >= ns.length) {
char pc = hs[i - ns.length];
hash = (hash * 26 - (pc - 'a') * a + (c - 'a')) % module;
} else {
hash = (hash * 26 + (c - 'a')) % module;
}
if (i >= ns.length - 1 && hash == nHash) {
return i - ns.length + 1;
}
}
return -1;
}
public static void main(String[] args) {
String hayStack = "baabbaaaaaaabbaaaaabbabbababaabbabbbbbabbabbbbbbabababaabbbbbaaabbbbabaababababbbaabbbbaaabbaababbbaabaabbabbaaaabababaaabbabbababbabbaaabbbbabbbbabbabbaabbbaa";
String needle = "bbaaaababa";
System.out.println(strStr(hayStack, needle));
}
}
| [
"[email protected]"
] | |
3bb57d6a863c082a63277202e89e4fffea9efdf1 | 0d3ad59627de6b4910aa9c1a95dec0e1f5c0fe32 | /src/fr/adrienbrault/idea/symfony2plugin/stubs/indexes/ServicesDefinitionStubIndex.java | 9857f752f1708c5fafbcd91f39d43cd5f96b14b2 | [
"MIT"
] | permissive | slopjong/idea-php-symfony2-plugin | 720173aca9c3ab782f56b5d7966d50e974fd70ef | f93605839d1f03856a1f22784a4c06e9af56b062 | refs/heads/master | 2021-01-14T13:06:08.068650 | 2014-12-09T19:05:17 | 2014-12-09T19:05:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,179 | java | package fr.adrienbrault.idea.symfony2plugin.stubs.indexes;
import com.intellij.ide.highlighter.XmlFileType;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.indexing.*;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.EnumeratorStringDescriptor;
import com.intellij.util.io.KeyDescriptor;
import fr.adrienbrault.idea.symfony2plugin.Symfony2ProjectComponent;
import fr.adrienbrault.idea.symfony2plugin.config.xml.XmlHelper;
import fr.adrienbrault.idea.symfony2plugin.dic.ContainerService;
import fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper;
import gnu.trove.THashMap;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.yaml.YAMLFileType;
import org.jetbrains.yaml.psi.YAMLFile;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class ServicesDefinitionStubIndex extends FileBasedIndexExtension<String, String[]> {
private static int MAX_FILE_BYTE_SIZE = 5242880;
public static final ID<String, String[]> KEY = ID.create("fr.adrienbrault.idea.symfony2plugin.service_definition");
private final KeyDescriptor<String> myKeyDescriptor = new EnumeratorStringDescriptor();
@NotNull
@Override
public DataIndexer<String, String[], FileContent> getIndexer() {
return new DataIndexer<String, String[], FileContent>() {
@NotNull
@Override
public Map<String, String[]> map(FileContent inputData) {
Map<String, String[]> map = new THashMap<String, String[]>();
PsiFile psiFile = inputData.getPsiFile();
if(!Symfony2ProjectComponent.isEnabledForIndex(psiFile.getProject())) {
return map;
}
if (!isValidForIndex(inputData, psiFile)) {
return map;
}
if(psiFile instanceof YAMLFile) {
attachServiceMap(map, (YAMLFile) psiFile);
}
if(psiFile instanceof XmlFile) {
attachServiceMap(map, (XmlFile) psiFile);
}
return map;
}
private void attachServiceMap(Map<String, String[]> map, XmlFile psiFile) {
attachServiceMap(map, XmlHelper.getLocalServiceMap(psiFile));
}
private void attachServiceMap(Map<String, String[]> map, YAMLFile psiFile) {
attachServiceMap(map, YamlHelper.getLocalServiceMap(psiFile));
}
private void attachServiceMap(Map<String, String[]> map, Map<String, ContainerService> localServiceMap) {
if(localServiceMap.size() == 0) {
return;
}
for(Map.Entry<String, ContainerService> entry: localServiceMap.entrySet()) {
if(StringUtils.isNotBlank(entry.getKey())) {
addContainerService(map, entry);
}
}
}
private void addContainerService(Map<String, String[]> map, Map.Entry<String, ContainerService> entry) {
if(StringUtils.isBlank(entry.getKey())) {
return;
}
String className = entry.getValue().getClassName();
if(StringUtils.isBlank(className)) {
className = null;
}
String isPrivate = null;
if(entry.getValue().isPrivate()) {
isPrivate = "true";
}
map.put(entry.getKey(), new String[] {className, isPrivate});
}
};
}
@NotNull
@Override
public ID<String, String[]> getName() {
return KEY;
}
@Override
public KeyDescriptor<String> getKeyDescriptor() {
return this.myKeyDescriptor;
}
public DataExternalizer<String[]> getValueExternalizer() {
return new MySetDataExternalizer();
}
@Override
public FileBasedIndex.InputFilter getInputFilter() {
return new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(VirtualFile file) {
return file.getFileType() == XmlFileType.INSTANCE || file.getFileType() == YAMLFileType.YML;
}
};
}
@Override
public boolean dependsOnFileContent() {
return true;
}
@Override
public int getVersion() {
return 3;
}
/**
* com.jetbrains.php.lang.psi.stubs.indexes.PhpTraitUsageIndex
*/
public static class MySetDataExternalizer implements DataExternalizer<String[]> {
private final EnumeratorStringDescriptor myStringEnumerator = new EnumeratorStringDescriptor();
public synchronized void save(DataOutput out, String[] values) throws IOException {
out.writeInt(values.length);
for(String value: values) {
this.myStringEnumerator.save(out, value != null ? value : "");
}
}
public synchronized String[] read(DataInput in) throws IOException {
List<String> list = new ArrayList<String>();
int r = in.readInt();
while (r > 0) {
list.add(this.myStringEnumerator.read(in));
r--;
}
return list.toArray(new String[list.size()]);
}
}
public static boolean isValidForIndex(FileContent inputData, PsiFile psiFile) {
String fileName = psiFile.getName();
if(fileName.startsWith(".") || fileName.contains("Test")) {
return false;
}
// container file need to be xml file, eg xsd filetypes are not valid
String extension = inputData.getFile().getExtension();
if(extension == null || !(extension.equalsIgnoreCase("xml") || extension.equalsIgnoreCase("yml"))) {
return false;
}
// possible fixture or test file
// to support also library paths, only filter them on project files
String relativePath = VfsUtil.getRelativePath(inputData.getFile(), psiFile.getProject().getBaseDir(), '/');
if(relativePath != null && (relativePath.contains("/Test/") || relativePath.contains("/Fixture/") || relativePath.contains("/Fixtures/"))) {
return false;
}
// dont add configured service paths
List<File> settingsServiceFiles = psiFile.getProject().getComponent(Symfony2ProjectComponent.class).getContainerFiles();
for(File file: settingsServiceFiles) {
if(VfsUtil.isAncestor(VfsUtil.virtualToIoFile(inputData.getFile()), file, false)) {
return false;
}
}
// dont index files larger then files; use 5 MB here
if(inputData.getFile().getLength() > MAX_FILE_BYTE_SIZE) {
return false;
}
return true;
}
}
| [
"[email protected]"
] | |
684ae82cd6fc23e0bd8f7ae3f158fd69c7e0cfe2 | 66004cd429348a121c2f874578a15133559f1fa2 | /app/src/main/java/com/example/android/poppex/PostedQuestionTouchHelperCallback.java | 080bbec16973821a75ecbfaf6774e7309c925d52 | [] | no_license | ElonaZharri/PoppeX | 67d26795ba3361c0a4da0875840a5393cbc7af25 | b8446ff2c857b6c118daab0ea7c4751020f5bab5 | refs/heads/master | 2020-05-16T15:14:27.827251 | 2017-03-31T20:37:11 | 2017-03-31T20:37:11 | 183,127,412 | 1 | 0 | null | 2019-04-24T02:00:32 | 2019-04-24T02:00:30 | null | UTF-8 | Java | false | false | 1,738 | java | package com.example.android.poppex;
import android.graphics.Canvas;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.helper.ItemTouchHelper;
public class PostedQuestionTouchHelperCallback extends ItemTouchHelper.SimpleCallback {
private static final float ALPHA_FULL = 1.0f;
private DeletionListener listener;
@SuppressWarnings("unused")
private PostedQuestionTouchHelperCallback(int dragDirs, int swipeDirs) {
super(dragDirs, swipeDirs);
}
public PostedQuestionTouchHelperCallback(int dragDirection, int swipeDirection, DeletionListener listener) {
super(dragDirection,swipeDirection);
this.listener = listener;
}
@Override
public boolean onMove(RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, RecyclerView.ViewHolder target) {
return false;
}
@Override
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) {
if (listener != null) {
listener.itemRemoved(viewHolder.getAdapterPosition());
}
}
@Override
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
if (actionState == ItemTouchHelper.ACTION_STATE_SWIPE) {
// Fade out the view as it is swiped out of the parent's bounds
final float alpha = ALPHA_FULL - Math.abs(dX) / (float) viewHolder.itemView.getWidth();
viewHolder.itemView.setAlpha(alpha);
viewHolder.itemView.setTranslationX(dX);
} else {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
}
}
}
| [
"[email protected]"
] | |
1afb955291b9a9983383449f31c98037650c28b4 | 67747759cb87cafc7b4eeec3c9c7264806331af6 | /src/main/java/sda/backend/server/service/AccountService.java | ed58fe21a4ebc863b770ae2c6242c167c4c7d72d | [] | no_license | MariusTarnaru/Website-for-Microblogging-Backend | d53cc40b6b0deaef92e35c2883308cd08ae3a90d | 96cf193fb1aa32460f621cc114ca236d56291a01 | refs/heads/main | 2023-05-15T04:01:00.240125 | 2021-06-11T17:25:57 | 2021-06-11T17:25:57 | 376,077,907 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,776 | java | package sda.backend.server.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import sda.backend.server.dto.DTOAccount;
import sda.backend.server.exception.Message;
import sda.backend.server.model.Account;
import sda.backend.server.model.Avatar;
import sda.backend.server.repository.AccountRepository;
import sda.backend.server.repository.AvatarRepository;
import sda.backend.server.util.AccountMapper;
import java.time.LocalDateTime;
@Service
public class AccountService {
private final AccountRepository accountRepository;
private final AvatarRepository avatarRepository;
private final AccountMapper accountMapper;
@Autowired
public AccountService(AccountRepository accountRepository, AvatarRepository avatarRepository, AccountMapper accountMapper) {
this.accountRepository = accountRepository;
this.avatarRepository = avatarRepository;
this.accountMapper = accountMapper;
}
private DTOAccount accountToDTOAccount(Account account) {
return DTOAccount.builder()
.accountId(account.getAccountId())
.email(account.getEmail())
.password(account.getPassword())
.username(account.getUsername())
.displayName(account.getDisplayName())
.avatar(account.getAvatar())
.accountStatus(account.getAccountStatus())
.accountType(account.getAccountType())
.createdAccount(account.getCreatedAccount())
.build();
}
private Account DTOAccountToAccount(DTOAccount dtoAccount) {
return Account.builder()
.accountId(dtoAccount.getAccountId())
.email(dtoAccount.getEmail())
.password(dtoAccount.getPassword())
.username(dtoAccount.getUsername())
.displayName(dtoAccount.getDisplayName())
.avatar(dtoAccount.getAvatar())
.accountStatus(dtoAccount.getAccountStatus())
.accountType(dtoAccount.getAccountType())
.createdAccount(dtoAccount.getCreatedAccount())
.build();
}
public ResponseEntity<?> saveAccount(DTOAccount account) {
if (emailExist(account.getEmail())) {
return ResponseEntity.status(HttpStatus.CONFLICT)
.body(new Message("Email already exists!"));
}
if (usernameExists(account.getUsername())) {
return ResponseEntity.status(HttpStatus.CONFLICT)
.body(new Message("Username already exists!"));
}
Account newAccount = DTOAccountToAccount(account);
newAccount.setCreatedAccount(LocalDateTime.now());
Avatar avatar = new Avatar();
avatar.setPath(account.getAvatar().getPath());
account.setAvatar(avatar);
accountRepository.save(newAccount);
return ResponseEntity.status(HttpStatus.CREATED)
.body(new Message("Account saved successfully!"));
}
public ResponseEntity<?> login(DTOAccount account) {
if (!emailExist(account.getEmail())) {
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Message("Email not found!"));
}
boolean isAccountValid = accountRepository.findByEmailAndPassword(account.getEmail(), account.getPassword()).isPresent();
if (!isAccountValid) {
return ResponseEntity.status(HttpStatus.UNAUTHORIZED)
.body(new Message("Wrong email or password!"));
}
return ResponseEntity.accepted()
.body(new Message("You have login successfully!"));
}
public ResponseEntity<?> getAccountById(Long id) {
if (idExists(id)) {
DTOAccount account = accountToDTOAccount(accountRepository.findById(id).get());
return new ResponseEntity<>(account, HttpStatus.ACCEPTED);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Message("Account not found"));
}
public ResponseEntity<?> getAccountByUsername(String username) {
if (usernameExists(username)) {
DTOAccount account = accountToDTOAccount(accountRepository.findByUsername(username).get());
return new ResponseEntity<>(account, HttpStatus.ACCEPTED);
}
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Message("Username not found"));
}
public ResponseEntity<?> updateUserById(DTOAccount dtoAccount, Long id) {
if (idExists(id)) {
Account account = accountRepository.findById(id).get();
accountMapper.updateAccount(dtoAccount, account);
accountRepository.save(account);
return ResponseEntity.status(HttpStatus.NO_CONTENT).build();
}
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Message("Account not found"));
}
public ResponseEntity<?> deleteUserById(Long id) {
if (idExists(id)) {
accountRepository.deleteById(id);
return ResponseEntity.status(HttpStatus.ACCEPTED).build();
}
return ResponseEntity.status(HttpStatus.NOT_FOUND)
.body(new Message("Account not found"));
}
public boolean idExists(Long id) {
return accountRepository.existsById(id);
}
private boolean emailExist(String email) {
return accountRepository.existsByEmail(email);
}
public boolean usernameExists(String username) {
return accountRepository.existsByUsername(username);
}
}
| [
"[email protected]"
] | |
35e1dd22a39b4e446c794f9710ca179479113def | 31ccffb779896b6887bddb4c9f661d4c6a1389c6 | /src/main/java/ua/pb/dao/factory/ConnectionFactory.java | d885beae331c9f96131680897ba84f616ffd1341 | [] | no_license | bardas-oleksandr/exchanger | e6a41d1098ebe5c073ba357268abe1a1ff3cb83b | ca4faae6a285dbcc4f25295fd0f1a6506590c06e | refs/heads/master | 2020-04-10T21:05:17.059785 | 2018-12-11T06:30:02 | 2018-12-11T06:30:02 | 161,286,952 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,019 | java | package ua.pb.dao.factory;
import org.apache.commons.pool2.BasePooledObjectFactory;
import org.apache.commons.pool2.PooledObject;
import org.apache.commons.pool2.impl.DefaultPooledObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.sql.DataSource;
import java.sql.Connection;
@Component("connectionFactory")
public class ConnectionFactory extends BasePooledObjectFactory<Connection> {
@Autowired
private DataSource dataSource;
@Override
public Connection create() throws Exception {
return dataSource.getConnection();
}
@Override
public PooledObject<Connection> wrap(Connection connection) {
return new DefaultPooledObject<Connection>(connection);
}
@Override
public void destroyObject(PooledObject<Connection> connectionWrapper) throws Exception {
if (!connectionWrapper.getObject().isClosed()) {
connectionWrapper.getObject().close();
}
}
}
| [
"[email protected]"
] | |
6bc93b61f7d92aacee6c271df47f5ec6ed7a87c1 | f5e2df67f2298899d20c1fb402627307e913cf8a | /demo/src/com/netease/nim/weyouchats/session/viewholder/MsgViewHolderRTS.java | e99c08ad194e1ecb6828d23d59936ede097ce15d | [] | no_license | morgantony/nim_1 | 8b863b9ce6514cda8ebabb4a5940a6facca4c3b2 | ff3e98342ac105660cc52838e64a852e9c109be0 | refs/heads/master | 2020-07-12T19:04:34.081670 | 2019-09-18T03:19:28 | 2019-09-18T03:19:28 | 204,882,874 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 973 | java | package com.netease.nim.weyouchats.session.viewholder;
import android.widget.TextView;
import com.netease.nim.weyouchats.R;
import com.netease.nim.weyouchats.session.extension.RTSAttachment;
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
public class MsgViewHolderRTS extends MsgViewHolderBase {
private TextView textView;
public MsgViewHolderRTS(BaseMultiItemFetchLoadAdapter adapter) {
super(adapter);
}
@Override
protected int getContentResId() {
return R.layout.nim_message_item_rts;
}
@Override
protected void inflateContentView() {
textView = (TextView) view.findViewById(R.id.rts_text);
}
@Override
protected void bindContentView() {
RTSAttachment attachment = (RTSAttachment) message.getAttachment();
textView.setText(attachment.getContent());
}
}
| [
"[email protected]"
] | |
03a1e925d8a3a0af5a70087829b023b046248dc6 | 214d656612d0fc1c28326832859c269721b0a1e3 | /cupdata-auth/src/main/java/com/cupdata/auth/controller/AuthController.java | 96b91614e8d2f66a11e0fd4e3efdaf8c4bc86298 | [
"Apache-2.0"
] | permissive | heyok123/G-Store | 5cae7c10c6f77a9b59739403612fb5a209f724e8 | 6d317ef8acbb2f1459b7647e29553d23906ea852 | refs/heads/main | 2023-03-20T20:58:28.430372 | 2021-03-12T02:10:51 | 2021-03-12T02:10:51 | 321,398,207 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,378 | java | package com.cupdata.auth.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cupdata.auth.util.ConstantUtils;
import com.cupdata.auth.util.VerCodeUtil;
import com.cupdata.common.bean.ResponseVo;
import com.cupdata.common.exception.MyException;
import com.cupdata.ums.entity.UserEntity;
import com.cupdata.ums.service.UserService;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.subject.SimplePrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.Map;
/**
* @Description: 认证中心接口
* Created by Wsork on 2021/1/22 17:29.
**/
@RestController
@RequestMapping
public class AuthController {
@Autowired
private UserService userService;
/**
* @Description: verCode
* @Author: Wsork
* @Date: 2021/1/22 17:50
* @param: [request, response]
* @return: com.cupdata.helloworld.core.ResponseVo
*/
@GetMapping("/verCode")
public ResponseVo verCode(HttpServletRequest request, HttpServletResponse response){
response.setHeader("Content-Type","image/png");
Map<String, Object> map = VerCodeUtil.getCheckCodePic();
String code = (String) map.get("code");
HttpSession session = request.getSession();
session.setAttribute(ConstantUtils.VER_CODE,code);
System.out.println(code);
return ResponseVo.ok(code);
}
/**
* @Description: login
* @Author: Wsork
* @Date: 2021/1/22 17:32
* @param: [user, session]
* @return: com.cupdata.helloworld.core.ResponseVo
*/
@PostMapping("/login")
public ResponseVo<UserEntity> login(@RequestBody UserEntity user, HttpSession session){
if (user == null){
throw new MyException("参数校验失败!");
}
// 验证码校验
String code = (String) session.getAttribute(ConstantUtils.VER_CODE);
if (StringUtils.isEmpty(code) || !code.equalsIgnoreCase(user.getVerCode())) {
session.removeAttribute(ConstantUtils.VER_CODE);
throw new MyException("验证码填写错误!");
}
session.removeAttribute(ConstantUtils.VER_CODE);
// 账号校验
UserEntity userReal = this.userService.getOne(new QueryWrapper<UserEntity>().eq("username",user.getUsername()));
if (userReal == null) {
throw new MyException("用户名或密码错误!");
}
// 用户状态校验
if ("0".equals(userReal.getStatus())) {
throw new MyException("账号已被禁用!");
}
// 用户登录错误次数校验
// if (UserVo.USER_LOGIN_ERROR_NUM_MAX.equals(user.getErrorNum())) {
// throw new MyException("账号登录错误次数超过3次,已被禁用!");
// }
// 密码校验
if (StringUtils.isEmpty(user.getPassword()) || !userReal.getPassword().equals(user.getPassword())) {
throw new MyException("用户名或密码错误!");
}
// shiro登录
UsernamePasswordToken token = new UsernamePasswordToken(user.getUsername(), user.getPassword());
Subject subject = SecurityUtils.getSubject();
subject.login(token);
// 用户信息
UserEntity userInfo = (UserEntity) subject.getPrincipal();
String shiroSessionId = (String) subject.getSession().getId();
// 存储token
userInfo.setToken(shiroSessionId);
SimplePrincipalCollection collection = new SimplePrincipalCollection(userInfo, userInfo.getUsername());
subject.runAs(collection);
UserEntity userData = new UserEntity();
BeanUtils.copyProperties(userInfo,userData);
return ResponseVo.ok(userData);
}
/**
* @Description: 登出
* @Author: Wsork
* @Date: 2021/1/22 18:19
* @param: []
* @return: com.cupdata.helloworld.core.ResponseVo
*/
@GetMapping("/logout")
public ResponseVo logout(){
SecurityUtils.getSubject().logout();
return ResponseVo.ok();
}
/**
* @Description: 返回登录用户信息
* @Author: Wsork
* @Date: 2021/1/22 18:14
* @param: []
* @return: com.cupdata.helloworld.core.ResponseVo
*/
@GetMapping("/getLoginUser")
public ResponseVo getUserInfo(){
UserEntity user = (UserEntity) SecurityUtils.getSubject().getPrincipal();
UserEntity userRole = new UserEntity();
// list<UserRole>
// list<Role>
// user.setRoleName()
return ResponseVo.ok(user);
}
/**
* @Description: 返回登录用户权限信息
* @Author: Wsork
* @Date: 2021/1/22 18:18
* @param: []
* @return: com.cupdata.helloworld.core.ResponseVo
*/
@GetMapping("/getUserPerms")
public ResponseVo getUserPerms(){
UserEntity user = (UserEntity) SecurityUtils.getSubject().getPrincipal();
// list<userRole>
// list<role>
return ResponseVo.ok();
}
}
| [
"[email protected]"
] | |
46ed27a9a99afaaddec352e6f1fb2a74f0a24187 | 9414f42007592bef00e1b11486b1fa835773e2b8 | /src/main/java/com/teammu/giftrandompicker/config/DefaultProfileUtil.java | 3203ab2265fb0dffbb28af77ba48dab98154805d | [] | no_license | gregnebu/GiftRandomPicker | e8881d49f6e5393be26146b1d170e3ca48187067 | ed9d0bd6e35d095b88f0fb8581eac8afb7dae94c | refs/heads/master | 2022-12-22T10:29:52.202764 | 2019-12-14T10:26:51 | 2019-12-14T10:26:51 | 228,000,649 | 0 | 0 | null | 2022-12-16T04:42:18 | 2019-12-14T09:55:56 | Java | UTF-8 | Java | false | false | 1,254 | java | package com.teammu.giftrandompicker.config;
import io.github.jhipster.config.JHipsterConstants;
import org.springframework.boot.SpringApplication;
import java.util.*;
/**
* Utility class to load a Spring profile to be used as default
* when there is no {@code spring.profiles.active} set in the environment or as command line argument.
* If the value is not available in {@code application.yml} then {@code dev} profile will be used as default.
*/
public final class DefaultProfileUtil {
private static final String SPRING_PROFILE_DEFAULT = "spring.profiles.default";
private DefaultProfileUtil() {
}
/**
* Set a default to use when no profile is configured.
*
* @param app the Spring application.
*/
public static void addDefaultProfile(SpringApplication app) {
Map<String, Object> defProperties = new HashMap<>();
/*
* The default profile to use when no other profiles are defined
* This cannot be set in the application.yml file.
* See https://github.com/spring-projects/spring-boot/issues/1219
*/
defProperties.put(SPRING_PROFILE_DEFAULT, JHipsterConstants.SPRING_PROFILE_DEVELOPMENT);
app.setDefaultProperties(defProperties);
}
}
| [
"[email protected]"
] | |
70a111ecda7dd18d55f5dd474542e4c6f480294f | 5db1fb79645f9ce049c6aa7a32cd53e6e58d7a87 | /bukkit/src/com/khorn/terraincontrol/bukkit/commands/ReplaceBiomeCommand.java | e09d3059f25269ce6d1db59f6c1094fbcae0a584 | [] | no_license | zakiton/TerrainControl | 3c925f106d067eaf7ecbaa6af20ed6f8f38b5215 | de044da8815ff1473520bd1517f1ff6eb90a9ec7 | refs/heads/master | 2021-01-17T07:08:18.908400 | 2013-07-06T13:09:15 | 2013-07-06T13:09:15 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,043 | java | package com.khorn.terraincontrol.bukkit.commands;
import com.khorn.terraincontrol.bukkit.BiomeReplace;
import com.khorn.terraincontrol.bukkit.TCPerm;
import com.khorn.terraincontrol.bukkit.TCPlugin;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.craftbukkit.v1_6_R1.CraftWorld;
import org.bukkit.entity.Player;
import java.util.List;
public class ReplaceBiomeCommand extends BaseCommand
{
public ReplaceBiomeCommand(TCPlugin _plugin)
{
super(_plugin);
name = "replace";
perm = TCPerm.CMD_REPLACE.node;
usage = "replace biomeIDFrom biomeIdTo [World]";
workOnConsole = true;
}
@Override
public boolean onCommand(CommandSender sender, List<String> args)
{
CraftWorld world = null;
if (args.size() == 3)
{
world = (CraftWorld) Bukkit.getWorld(args.get(0));
args.remove(0);
if (world == null)
{
sender.sendMessage(ERROR_COLOR + "You need to select world");
return true;
}
}
if (world == null)
{
if (sender instanceof ConsoleCommandSender)
{
sender.sendMessage(ERROR_COLOR + "You need to select world");
return true;
}
world = (CraftWorld) ((Player) sender).getWorld();
}
int biomeIdFrom;
int biomeIdTo;
try
{
biomeIdFrom = Integer.parseInt(args.get(0));
biomeIdTo = Integer.parseInt(args.get(1));
args.remove(0);
args.remove(0);
} catch (Exception e)
{
sender.sendMessage(ERROR_COLOR + "Wrong biome ids ");
return true;
}
BiomeReplace replace = new BiomeReplace(world, biomeIdFrom, biomeIdTo, sender);
this.plugin.getServer().getScheduler().runTaskAsynchronously(this.plugin, replace);
return true;
}
}
| [
"[email protected]"
] | |
8e77b777b6bcc6378397c86076ad75d730cbc4a8 | c382b31d1d7b8ed7bcd0bc24a217a057dd01a13b | /android/app/src/main/java/com/stone/pile/activity/MainActivity3.java | 5df7c7360a03852830c8e06172d65af0d70c6e78 | [] | no_license | HantaoShu/2017-dachuang | edbeb4ac19b12a11fa3ad9ba88b06e88b90df76a | caf273b47e39afef9b36a443bf02c38ff29ef965 | refs/heads/master | 2021-10-09T22:07:54.933804 | 2019-01-04T03:33:25 | 2019-01-04T03:33:25 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 20,569 | java |
package com.stone.pile.activity;
import android.Manifest;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.media.Image;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Message;
import android.provider.Settings;
import android.support.annotation.NonNull;
import android.support.annotation.StringRes;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.util.TimeUtils;
import android.support.v7.app.ActionBar;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.system.Os;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.Toast;
import com.google.android.cameraview.AspectRatio;
import com.google.android.cameraview.CameraView;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;
import com.special.ResideMenu.ResideMenu;
import com.special.ResideMenu.ResideMenuItem;
import com.stone.pile.R;
import com.tbruyelle.rxpermissions.Permission;
import com.tbruyelle.rxpermissions.RxPermissions;
import org.w3c.dom.Text;
/**
* This demo app saves the taken picture to a constant file.
* $ adb pull /sdcard/Android/data/com.google.android.cameraview.demo/files/Pictures/picture.jpg
*/
public class MainActivity3 extends AppCompatActivity implements
ActivityCompat.OnRequestPermissionsResultCallback,
AspectRatioFragment.Listener {
private ArrayList<String> namelist = new ArrayList<>();
private static final String TAG = "MainActivity";
private static final int REQUEST_CAMERA_PERMISSION = 1;
private int index = 0;
private static final String FRAGMENT_DIALOG = "dialog";
private ResideMenu resideMenu;
private static final int[] FLASH_OPTIONS = {
CameraView.FLASH_AUTO,
CameraView.FLASH_OFF,
CameraView.FLASH_ON,
};
private static final int[] FLASH_ICONS = {
R.drawable.ic_flash_auto,
R.drawable.ic_flash_off,
R.drawable.ic_flash_on,
};
private static final int[] FLASH_TITLES = {
R.string.flash_auto,
R.string.flash_off,
R.string.flash_on,
};
private int mCurrentFlash;
private CameraView mCameraView;
private Handler mBackgroundHandler;
private TextView numberOfPic;
private View.OnClickListener mOnClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.take_picture:
if (mCameraView != null) {
index+=1;
numberOfPic.setText("alread take "+index+" picture(s)");
mCameraView.takePicture();
}
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
mCameraView = (CameraView) findViewById(R.id.camera);
if (mCameraView != null) {
mCameraView.addCallback(mCallback);
}
numberOfPic = (TextView) findViewById(R.id.numberOfPic);
numberOfPic.setText("alread take 0 picture");
ImageButton fab = (ImageButton) findViewById(R.id.take_picture);
if (fab != null) {
fab.setOnClickListener(mOnClickListener);
}
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayShowTitleEnabled(false);
}
final ImageButton getresButton = (ImageButton) findViewById(R.id.getresult);
getresButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getresButton.setVisibility(View.INVISIBLE);
Toast.makeText(MainActivity3.this, "please wait for a moment", Toast.LENGTH_SHORT).show();
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0:
//完成主界面更新,拿到数据
HashMap<String,jsonbean> res = (HashMap<String,jsonbean>)msg.obj;
System.out.println("msg"+res.values());
SerializableHashMap data = new SerializableHashMap();
data.setMap((HashMap<String, jsonbean>) msg.obj);
System.out.println("msg2"+data.getMap().values());
Intent intent = new Intent(MainActivity3.this,MainActivity.class);
intent.putExtra("type","album");
intent.putExtra("data",data);
startActivity(intent);
break;
default:
break;
}
}
};
HttpUtil h = new HttpUtil(mHandler);
h.processdata(namelist);
}
});
resideMenu = new ResideMenu(this);
resideMenu.setBackground(R.drawable.menu_background);
resideMenu.attachToActivity(this);
// create menu items;
String titles[] = { "Album", "Take_Photo","Find Result" };
int icon[] = { R.drawable.album, R.drawable.camera, R.drawable.find_res};
final Class cls[] = {MainActivity2.class,MainActivity3.class,MainActivity.class};
for (int i = 0; i < titles.length; i++) {
ResideMenuItem item = new ResideMenuItem(this, icon[i], titles[i]);
final int index = i;
item.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (index == 1) {
RxPermissions rxPermissions = new RxPermissions(MainActivity3.this);
rxPermissions.requestEach(Manifest.permission.CAMERA).subscribe(new DefaultSubscriber<Permission>() {
@Override
public void onNext(Permission permission) {
if (permission.granted) {
startActivity(new Intent(MainActivity3.this, MainActivity3.class));
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(this.context);
builder.setMessage("您未授权相机权限,将无法拍照,请在权限管理中开启相机权限")
.setTitle("提示").setPositiveButton("确认", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Uri packageURI = Uri.parse("package:" + getPackageName());
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageURI);
startActivity(intent);
}
}).setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
});
builder.create().show();
}
}
});
}
else if(index==2){
getresButton.setVisibility(View.INVISIBLE);
Toast.makeText(MainActivity3.this, "please wait for a moment", Toast.LENGTH_SHORT).show();
Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 0:
//完成主界面更新,拿到数据
HashMap<String,jsonbean> res = (HashMap<String,jsonbean>)msg.obj;
System.out.println("msg"+res.values());
SerializableHashMap data = new SerializableHashMap();
data.setMap((HashMap<String, jsonbean>) msg.obj);
System.out.println("msg2"+data.getMap().values());
Intent intent = new Intent(MainActivity3.this,MainActivity.class);
intent.putExtra("type","album");
intent.putExtra("data",data);
startActivity(intent);
break;
default:
break;
}
}
};
HttpUtil h = new HttpUtil(mHandler);
h.processdata(namelist);
}
else
startActivity(new Intent(MainActivity3.this, cls[index]));
}
});
resideMenu.addMenuItem(item, ResideMenu.DIRECTION_LEFT); // or ResideMenu.DIRECTION_RIGHT
}
resideMenu.setSwipeDirectionDisable(ResideMenu.DIRECTION_LEFT);
resideMenu.setSwipeDirectionDisable(ResideMenu.DIRECTION_RIGHT);
Button MenuButton = (Button) findViewById(R.id.menuButton3);
MenuButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
resideMenu.openMenu(ResideMenu.DIRECTION_LEFT);
}
});
}
@Override
protected void onResume() {
super.onResume();
if (ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED) {
mCameraView.start();
} else if (ActivityCompat.shouldShowRequestPermissionRationale(this,
Manifest.permission.CAMERA)) {
ConfirmationDialogFragment
.newInstance(R.string.camera_permission_confirmation,
new String[]{Manifest.permission.CAMERA},
REQUEST_CAMERA_PERMISSION,
R.string.camera_permission_not_granted)
.show(getSupportFragmentManager(), FRAGMENT_DIALOG);
} else {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
REQUEST_CAMERA_PERMISSION);
}
final Set<AspectRatio> ratios = mCameraView.getSupportedAspectRatios();
AspectRatio curr=null;
for(AspectRatio ratio : ratios){
if(ratio.toString().equals("16:9")){
curr = ratio;
}
}
mCameraView.setAspectRatio(curr);
}
@Override
protected void onPause() {
mCameraView.stop();
super.onPause();
}
@Override
protected void onDestroy() {
super.onDestroy();
if (mBackgroundHandler != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
mBackgroundHandler.getLooper().quitSafely();
} else {
mBackgroundHandler.getLooper().quit();
}
mBackgroundHandler = null;
}
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions,
@NonNull int[] grantResults) {
switch (requestCode) {
case REQUEST_CAMERA_PERMISSION:
if (permissions.length != 1 || grantResults.length != 1) {
throw new RuntimeException("Error on requesting camera permission.");
}
if (grantResults[0] != PackageManager.PERMISSION_GRANTED) {
Toast.makeText(this, R.string.camera_permission_not_granted,
Toast.LENGTH_SHORT).show();
}
// No need to start camera here; it is handled by onResume
break;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.aspect_ratio:
FragmentManager fragmentManager = getSupportFragmentManager();
if (mCameraView != null
&& fragmentManager.findFragmentByTag(FRAGMENT_DIALOG) == null) {
final Set<AspectRatio> ratios = mCameraView.getSupportedAspectRatios();
final AspectRatio currentRatio = mCameraView.getAspectRatio();
AspectRatioFragment.newInstance(ratios, currentRatio)
.show(fragmentManager, FRAGMENT_DIALOG);
}
return true;
case R.id.switch_flash:
if (mCameraView != null) {
mCurrentFlash = (mCurrentFlash + 1) % FLASH_OPTIONS.length;
item.setTitle(FLASH_TITLES[mCurrentFlash]);
item.setIcon(FLASH_ICONS[mCurrentFlash]);
mCameraView.setFlash(FLASH_OPTIONS[mCurrentFlash]);
}
return true;
case R.id.switch_camera:
if (mCameraView != null) {
int facing = mCameraView.getFacing();
mCameraView.setFacing(facing == CameraView.FACING_FRONT ?
CameraView.FACING_BACK : CameraView.FACING_FRONT);
}
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
public void onAspectRatioSelected(@NonNull AspectRatio ratio) {
if (mCameraView != null) {
Toast.makeText(this, ratio.toString(), Toast.LENGTH_SHORT).show();
mCameraView.setAspectRatio(ratio);
}
}
private Handler getBackgroundHandler() {
if (mBackgroundHandler == null) {
HandlerThread thread = new HandlerThread("background");
thread.start();
mBackgroundHandler = new Handler(thread.getLooper());
}
return mBackgroundHandler;
}
private CameraView.Callback mCallback
= new CameraView.Callback() {
@Override
public void onCameraOpened(CameraView cameraView) {
Log.d(TAG, "onCameraOpened");
}
@Override
public void onCameraClosed(CameraView cameraView) {
Log.d(TAG, "onCameraClosed");
}
@Override
public void onPictureTaken(CameraView cameraView, final byte[] data) {
Log.d(TAG, "onPictureTaken " + data.length);
Toast.makeText(cameraView.getContext(), R.string.picture_taken, Toast.LENGTH_SHORT)
.show();
getBackgroundHandler().post(new Runnable() {
@Override
public void run() {
File appDir = new File(Environment.getExternalStorageDirectory(), "Res");
if (!appDir.exists()) {
appDir.mkdir();
}
String fileName = (System.currentTimeMillis()) + ".jpg";
File file = new File(appDir, fileName);
OutputStream os = null;
try {
os = new FileOutputStream(file);
os.write(data);
os.close();
namelist.add(file.getAbsolutePath());
} catch (IOException e) {
Log.w(TAG, "Cannot write to " + file, e);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException e) {
// Ignore
}
}
}
}
});
}
};
public static class ConfirmationDialogFragment extends DialogFragment {
private static final String ARG_MESSAGE = "message";
private static final String ARG_PERMISSIONS = "permissions";
private static final String ARG_REQUEST_CODE = "request_code";
private static final String ARG_NOT_GRANTED_MESSAGE = "not_granted_message";
public static ConfirmationDialogFragment newInstance(@StringRes int message,
String[] permissions, int requestCode, @StringRes int notGrantedMessage) {
ConfirmationDialogFragment fragment = new ConfirmationDialogFragment();
Bundle args = new Bundle();
args.putInt(ARG_MESSAGE, message);
args.putStringArray(ARG_PERMISSIONS, permissions);
args.putInt(ARG_REQUEST_CODE, requestCode);
args.putInt(ARG_NOT_GRANTED_MESSAGE, notGrantedMessage);
fragment.setArguments(args);
return fragment;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
return new AlertDialog.Builder(getActivity())
.setMessage(args.getInt(ARG_MESSAGE))
.setPositiveButton(android.R.string.ok,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String[] permissions = args.getStringArray(ARG_PERMISSIONS);
if (permissions == null) {
throw new IllegalArgumentException();
}
ActivityCompat.requestPermissions(getActivity(),
permissions, args.getInt(ARG_REQUEST_CODE));
}
})
.setNegativeButton(android.R.string.cancel,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getActivity(),
args.getInt(ARG_NOT_GRANTED_MESSAGE),
Toast.LENGTH_SHORT).show();
}
})
.create();
}
}
public void onBackPressed() {
super.onBackPressed();
}
}
| [
"[email protected]"
] | |
8d9c051fa40aa85f4b494575ab9f44df39616a41 | 2f3a982b0db693ddb052c5238193532d2ffd47f4 | /Creator.java | 3ef47642f839b9a69f5ded8b48d76182ef36baa1 | [] | no_license | anton-kachur/JAVA_LAB_1_NEW | 2c2792a38b0326174ef01ce1279c054fea9f1bfc | a4387b616187a691f33aef01c8e7ba41a005ff25 | refs/heads/main | 2023-01-05T20:53:39.970049 | 2020-11-04T13:31:05 | 2020-11-04T13:31:05 | 309,929,415 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | public static abstract class Creator
{
Random random = new Random();
protected abstract void createMap(MapCreator builder);
protected abstract void createMap(MapCreator builder, Scale user_scale);
}
| [
"[email protected]"
] | |
5f518678a0cac1da5ce14044ba6f88ff6fb2dfd0 | 48999a571a5cf5d6ebee8465776508c88df6ca4a | /src/main/java/dao/PessoaDAO.java | de8a247085cea578de455457550d132c069f0f8b | [] | no_license | walliots/ProjetoBancoJpa | b1a3d7ef26778f263d157c6f00cd9516dac05afb | a64fae3ea95aab3b28b44a92a960590d1b929b04 | refs/heads/master | 2023-07-31T20:34:51.359691 | 2021-09-15T05:10:06 | 2021-09-15T05:10:06 | 403,416,672 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 321 | java | package dao;
import java.util.List;
import model.Pessoa;
/**
* Interface da Classe Pessoa
*/
public interface PessoaDAO {
public void salvar(Pessoa pessoa);
public void alterar(Pessoa pessoa);
public void remover(String numero);
public Pessoa pesquisar(String numero);
public List<Pessoa> ListarTodos();
}
| [
"[email protected]"
] | |
f12b58d12c637501d793cae5db8c580e87131e63 | 323796028d71e4f861224a9d44393fc6c1d988fa | /src/org/mapdb/BTreeKeySerializer.java | aa2443e51eb2110b88d7a1ccd61eb9c595188553 | [] | no_license | zarkopopovski/NewsAggregator | 9daeb461ddf1d14a8a5db3780201dc9850f3a99e | 002bf8ab56bea2483ccc3c1d90feb71ae7a843c8 | refs/heads/master | 2021-01-10T01:43:07.620678 | 2015-10-08T10:28:06 | 2015-10-08T10:28:06 | 43,880,946 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 29,680 | java | package org.mapdb;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Comparator;
/**
* Custom serializer for BTreeMap keys which enables <a href='https://en.wikipedia.org/wiki/Delta_encoding'>Delta encoding</a>.
* <p/>
* Keys in BTree Nodes are sorted, this enables number of tricks to save disk space.
* For example for numbers we may store only difference between subsequent numbers, for string we can only take suffix, etc...
*
* @param <K> type of key
*/
public abstract class BTreeKeySerializer<K>{
/**
* Serialize keys from single BTree Node.
*
* @param out output stream where to put ata
* @param start where data start in array. Before this index all keys are null
* @param end where data ends in array (exclusive). From this index all keys are null
* @param keys array of keys for single BTree Node
*
* @throws IOException
*/
public abstract void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException;
/**
* Deserializes keys for single BTree Node. To
*
* @param in input stream to read data from
* @param start where data start in array. Before this index all keys are null
* @param end where data ends in array (exclusive). From this index all keys are null
* @param size size of array which should be returned
* @return array of keys for single BTree Node
*
* @throws IOException
*/
public abstract Object[] deserialize(DataInput in, int start, int end, int size) throws IOException;
/**
* Some key serializers may only work with they own comparators.
* For example delta-packing stores increments between numbers and requires ascending order.
* So Key Serializer may provide its own comparator.
*
* @return comparator which must be used with this method. `null` if comparator is not strictly required.
*/
public abstract Comparator<K> getComparator();
public static final BTreeKeySerializer BASIC = new BTreeKeySerializer.BasicKeySerializer(Serializer.BASIC);
/**
* Basic Key Serializer which just writes data without applying any compression.
* Is used by default if no other Key Serializer is specified.
*/
public static final class BasicKeySerializer extends BTreeKeySerializer<Object> implements Serializable {
protected final Serializer defaultSerializer;
public BasicKeySerializer(Serializer defaultSerializer) {
this.defaultSerializer = defaultSerializer;
}
/** used for deserialization*/
protected BasicKeySerializer(SerializerBase serializerBase, DataInput is, SerializerBase.FastArrayList<Object> objectStack) throws IOException {
objectStack.add(this);
defaultSerializer = (Serializer) serializerBase.deserialize(is,objectStack);
}
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
for(int i = start;i<end;i++){
defaultSerializer.serialize(out,keys[i]);
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException{
Object[] ret = new Object[size];
for(int i=start; i<end; i++){
ret[i] = defaultSerializer.deserialize(in,-1);
}
return ret;
}
@Override
public Comparator<Object> getComparator() {
return null;
}
}
/**
* Applies delta packing on {@code java.lang.Long}. All keys must be non negative.
* Difference between consequential numbers is also packed itself, so for small diffs it takes only single byte per
* number.
*/
public static final BTreeKeySerializer<Long> ZERO_OR_POSITIVE_LONG = new BTreeKeySerializer<Long>() {
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
if(start>=end) return;
// System.out.println(start+" - "+end+" - "+Arrays.toString(keys));
long prev = (Long)keys[start];
Utils.packLong(out,prev);
for(int i=start+1;i<end;i++){
long curr = (Long)keys[i];
Utils.packLong(out, curr-prev);
prev = curr;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Long[size];
long prev = 0 ;
for(int i = start; i<end; i++){
ret[i] = prev = prev + Utils.unpackLong(in);
}
return ret;
}
@Override
public Comparator<Long> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
};
/**
* Applies delta packing on {@code java.lang.Integer}. All keys must be non negative.
* Difference between consequential numbers is also packed itself, so for small diffs it takes only single byte per
* number.
*/
public static final BTreeKeySerializer<Integer> ZERO_OR_POSITIVE_INT = new BTreeKeySerializer<Integer>() {
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
if(start>=end) return;
// System.out.println(start+" - "+end+" - "+Arrays.toString(keys));
int prev = (Integer)keys[start];
Utils.packLong(out,prev);
for(int i=start+1;i<end;i++){
int curr = (Integer)keys[i];
Utils.packInt(out, curr-prev);
prev = curr;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Integer[size];
int prev = 0 ;
for(int i = start; i<end; i++){
ret[i] = prev = prev + Utils.unpackInt(in);
}
return ret;
}
@Override
public Comparator<Integer> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
};
/**
* Applies delta packing on {@code java.lang.String}. This serializer splits consequent strings
* to two parts: shared prefix and different suffix. Only suffix is than stored.
*/
public static final BTreeKeySerializer<String> STRING = new BTreeKeySerializer<String>() {
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
byte[] previous = null;
for (int i = start; i < end; i++) {
byte[] b = ((String) keys[i]).getBytes(Utils.UTF8_CHARSET);
leadingValuePackWrite(out, b, previous, 0);
previous = b;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Object[size];
byte[] previous = null;
for (int i = start; i < end; i++) {
byte[] b = leadingValuePackRead(in, previous, 0);
if (b == null) continue;
ret[i] = new String(b,Utils.UTF8_CHARSET);
previous = b;
}
return ret;
}
@Override
public Comparator<String> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
};
/**
* Read previously written data from {@code leadingValuePackWrite()} method.
*
* @author Kevin Day
*/
public static byte[] leadingValuePackRead(DataInput in, byte[] previous, int ignoreLeadingCount) throws IOException {
int len = Utils.unpackInt(in) - 1; // 0 indicates null
if (len == -1)
return null;
int actualCommon = Utils.unpackInt(in);
byte[] buf = new byte[len];
if (previous == null) {
actualCommon = 0;
}
if (actualCommon > 0) {
in.readFully(buf, 0, ignoreLeadingCount);
System.arraycopy(previous, ignoreLeadingCount, buf, ignoreLeadingCount, actualCommon - ignoreLeadingCount);
}
in.readFully(buf, actualCommon, len - actualCommon);
return buf;
}
/**
* This method is used for delta compression for keys.
* Writes the contents of buf to the DataOutput out, with special encoding if
* there are common leading bytes in the previous group stored by this compressor.
*
* @author Kevin Day
*/
public static void leadingValuePackWrite(DataOutput out, byte[] buf, byte[] previous, int ignoreLeadingCount) throws IOException {
if (buf == null) {
Utils.packInt(out, 0);
return;
}
int actualCommon = ignoreLeadingCount;
if (previous != null) {
int maxCommon = buf.length > previous.length ? previous.length : buf.length;
if (maxCommon > Short.MAX_VALUE) maxCommon = Short.MAX_VALUE;
for (; actualCommon < maxCommon; actualCommon++) {
if (buf[actualCommon] != previous[actualCommon])
break;
}
}
// there are enough common bytes to justify compression
Utils.packInt(out, buf.length + 1);// store as +1, 0 indicates null
Utils.packInt(out, actualCommon);
out.write(buf, 0, ignoreLeadingCount);
out.write(buf, actualCommon, buf.length - actualCommon);
}
/**
* Tuple2 Serializer which uses Default Serializer from DB and expect values to implement {@code Comparable} interface.
*/
public static final Tuple2KeySerializer TUPLE2 = new Tuple2KeySerializer(null, null, null);
/**
* Applies delta compression on array of tuple. First tuple value may be shared between consequentive tuples, so only
* first occurrence is serialized. An example:
*
* <pre>
* Value Serialized as
* -------------------------
* Tuple(1, 1) 1, 1
* Tuple(1, 2) 2
* Tuple(1, 3) 3
* Tuple(1, 4) 4
* </pre>
*
* @param <A> first tuple value
* @param <B> second tuple value
*/
public final static class Tuple2KeySerializer<A,B> extends BTreeKeySerializer<Fun.Tuple2<A,B>> implements Serializable {
protected final Comparator<A> aComparator;
protected final Serializer<A> aSerializer;
protected final Serializer<B> bSerializer;
/**
* Construct new Tuple2 Key Serializer. You may pass null for some value,
* In that case 'default' value will be used, Comparable comparator and Default Serializer from DB.
*
* @param aComparator comparator used for first tuple value
* @param aSerializer serializer used for first tuple value
* @param bSerializer serializer used for second tuple value
*/
public Tuple2KeySerializer(Comparator<A> aComparator,Serializer aSerializer, Serializer bSerializer){
this.aComparator = aComparator;
this.aSerializer = aSerializer;
this.bSerializer = bSerializer;
}
/** used for deserialization, `extra` is to avoid argument collision */
Tuple2KeySerializer(SerializerBase serializerBase, DataInput is, SerializerBase.FastArrayList<Object> objectStack, int extra) throws IOException {
objectStack.add(this);
aComparator = (Comparator<A>) serializerBase.deserialize(is,objectStack);
aSerializer = (Serializer<A>) serializerBase.deserialize(is,objectStack);
bSerializer = (Serializer<B>) serializerBase.deserialize(is,objectStack);
}
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
int acount=0;
for(int i=start;i<end;i++){
Fun.Tuple2<A,B> t = (Fun.Tuple2<A, B>) keys[i];
if(acount==0){
//write new A
aSerializer.serialize(out,t.a);
//count how many A are following
acount=1;
while(i+acount<end && aComparator.compare(t.a, ((Fun.Tuple2<A, B>) keys[i+acount]).a)==0){
acount++;
}
Utils.packInt(out,acount);
}
bSerializer.serialize(out,t.b);
acount--;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Object[size];
A a = null;
int acount = 0;
for(int i=start;i<end;i++){
if(acount==0){
//read new A
a = aSerializer.deserialize(in,-1);
acount = Utils.unpackInt(in);
}
B b = bSerializer.deserialize(in,-1);
ret[i]= Fun.t2(a,b);
acount--;
}
if(acount!=0) throw new InternalError();
return ret;
}
@Override
public Comparator<Fun.Tuple2<A,B>> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tuple2KeySerializer that = (Tuple2KeySerializer) o;
if (aComparator != null ? !aComparator.equals(that.aComparator) : that.aComparator != null) return false;
if (aSerializer != null ? !aSerializer.equals(that.aSerializer) : that.aSerializer != null) return false;
if (bSerializer != null ? !bSerializer.equals(that.bSerializer) : that.bSerializer != null) return false;
return true;
}
@Override
public int hashCode() {
int result = aComparator != null ? aComparator.hashCode() : 0;
result = 31 * result + (aSerializer != null ? aSerializer.hashCode() : 0);
result = 31 * result + (bSerializer != null ? bSerializer.hashCode() : 0);
return result;
}
}
/**
* Tuple3 Serializer which uses Default Serializer from DB and expect values to implement {@code Comparable} interface.
*/
public static final Tuple3KeySerializer TUPLE3 = new Tuple3KeySerializer(null, null, null, null, null);
/**
* Applies delta compression on array of tuple. First and second tuple value may be shared between consequentive tuples, so only
* first occurrence is serialized. An example:
*
* <pre>
* Value Serialized as
* ----------------------------
* Tuple(1, 2, 1) 1, 2, 1
* Tuple(1, 2, 2) 2
* Tuple(1, 3, 3) 3, 3
* Tuple(1, 3, 4) 4
* </pre>
*
* @param <A> first tuple value
* @param <B> second tuple value
* @param <C> third tuple value
*/
public static class Tuple3KeySerializer<A,B,C> extends BTreeKeySerializer<Fun.Tuple3<A,B,C>> implements Serializable {
protected final Comparator<A> aComparator;
protected final Comparator<B> bComparator;
protected final Serializer<A> aSerializer;
protected final Serializer<B> bSerializer;
protected final Serializer<C> cSerializer;
/**
* Construct new Tuple3 Key Serializer. You may pass null for some value,
* In that case 'default' value will be used, Comparable comparator and Default Serializer from DB.
*
* @param aComparator comparator used for first tuple value
* @param bComparator comparator used for second tuple value
* @param aSerializer serializer used for first tuple value
* @param bSerializer serializer used for second tuple value
* @param cSerializer serializer used for third tuple value
*/
public Tuple3KeySerializer(Comparator<A> aComparator, Comparator<B> bComparator, Serializer aSerializer,
Serializer bSerializer, Serializer cSerializer){
this.aComparator = aComparator;
this.bComparator = bComparator;
this.aSerializer = aSerializer;
this.bSerializer = bSerializer;
this.cSerializer = cSerializer;
}
/** used for deserialization */
Tuple3KeySerializer(SerializerBase serializerBase, DataInput is, SerializerBase.FastArrayList<Object> objectStack) throws IOException {
objectStack.add(this);
aComparator = (Comparator<A>) serializerBase.deserialize(is,objectStack);
bComparator = (Comparator<B>) serializerBase.deserialize(is,objectStack);
aSerializer = (Serializer<A>) serializerBase.deserialize(is,objectStack);
bSerializer = (Serializer<B>) serializerBase.deserialize(is,objectStack);
cSerializer = (Serializer<C>) serializerBase.deserialize(is,objectStack);
}
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
int acount=0;
int bcount=0;
for(int i=start;i<end;i++){
Fun.Tuple3<A,B,C> t = (Fun.Tuple3<A, B,C>) keys[i];
if(acount==0){
//write new A
aSerializer.serialize(out,t.a);
//count how many A are following
acount=1;
while(i+acount<end && aComparator.compare(t.a, ((Fun.Tuple3<A, B, C>) keys[i+acount]).a)==0){
acount++;
}
Utils.packInt(out,acount);
}
if(bcount==0){
//write new B
bSerializer.serialize(out,t.b);
//count how many B are following
bcount=1;
while(i+bcount<end && bComparator.compare(t.b, ((Fun.Tuple3<A, B,C>) keys[i+bcount]).b)==0){
bcount++;
}
Utils.packInt(out,bcount);
}
cSerializer.serialize(out,t.c);
acount--;
bcount--;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Object[size];
A a = null;
int acount = 0;
B b = null;
int bcount = 0;
for(int i=start;i<end;i++){
if(acount==0){
//read new A
a = aSerializer.deserialize(in,-1);
acount = Utils.unpackInt(in);
}
if(bcount==0){
//read new B
b = bSerializer.deserialize(in,-1);
bcount = Utils.unpackInt(in);
}
C c = cSerializer.deserialize(in,-1);
ret[i]= Fun.t3(a, b, c);
acount--;
bcount--;
}
if(acount!=0) throw new InternalError();
if(bcount!=0) throw new InternalError();
return ret;
}
@Override
public Comparator<Fun.Tuple3<A,B,C>> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tuple3KeySerializer that = (Tuple3KeySerializer) o;
if (aComparator != null ? !aComparator.equals(that.aComparator) : that.aComparator != null) return false;
if (aSerializer != null ? !aSerializer.equals(that.aSerializer) : that.aSerializer != null) return false;
if (bComparator != null ? !bComparator.equals(that.bComparator) : that.bComparator != null) return false;
if (bSerializer != null ? !bSerializer.equals(that.bSerializer) : that.bSerializer != null) return false;
if (cSerializer != null ? !cSerializer.equals(that.cSerializer) : that.cSerializer != null) return false;
return true;
}
@Override
public int hashCode() {
int result = aComparator != null ? aComparator.hashCode() : 0;
result = 31 * result + (bComparator != null ? bComparator.hashCode() : 0);
result = 31 * result + (aSerializer != null ? aSerializer.hashCode() : 0);
result = 31 * result + (bSerializer != null ? bSerializer.hashCode() : 0);
result = 31 * result + (cSerializer != null ? cSerializer.hashCode() : 0);
return result;
}
}
/**
* Tuple4 Serializer which uses Default Serializer from DB and expect values to implement {@code Comparable} interface.
*/
public static final Tuple4KeySerializer TUPLE4 = new Tuple4KeySerializer(null, null, null, null, null, null, null);
/**
* Applies delta compression on array of tuple. First, second and third tuple value may be shared between consequential tuples,
* so only first occurrence is serialized. An example:
*
* <pre>
* Value Serialized as
* ----------------------------------
* Tuple(1, 2, 1, 1) 1, 2, 1, 1
* Tuple(1, 2, 1, 2) 2
* Tuple(1, 3, 3, 3) 3, 3, 3
* Tuple(1, 3, 4, 4) 4, 4
* </pre>
*
* @param <A> first tuple value
* @param <B> second tuple value
* @param <C> third tuple value
*/
public static class Tuple4KeySerializer<A,B,C,D> extends BTreeKeySerializer<Fun.Tuple4<A,B,C,D>> implements Serializable {
protected final Comparator<A> aComparator;
protected final Comparator<B> bComparator;
protected final Comparator<C> cComparator;
protected final Serializer<A> aSerializer;
protected final Serializer<B> bSerializer;
protected final Serializer<C> cSerializer;
protected final Serializer<D> dSerializer;
/**
* Construct new Tuple4 Key Serializer. You may pass null for some value,
* In that case 'default' value will be used, Comparable comparator and Default Serializer from DB.
*
* @param aComparator comparator used for first tuple value
* @param bComparator comparator used for second tuple value
* @param cComparator comparator used for third tuple value*
* @param aSerializer serializer used for first tuple value
* @param bSerializer serializer used for second tuple value
* @param cSerializer serializer used for third tuple value
* @param dSerializer serializer used for fourth tuple value
*/
public Tuple4KeySerializer(Comparator<A> aComparator, Comparator<B> bComparator, Comparator<C> cComparator,
Serializer aSerializer, Serializer bSerializer, Serializer cSerializer, Serializer dSerializer){
this.aComparator = aComparator;
this.bComparator = bComparator;
this.cComparator = cComparator;
this.aSerializer = aSerializer;
this.bSerializer = bSerializer;
this.cSerializer = cSerializer;
this.dSerializer = dSerializer;
}
/** used for deserialization */
Tuple4KeySerializer(SerializerBase serializerBase, DataInput is, SerializerBase.FastArrayList<Object> objectStack) throws IOException {
objectStack.add(this);
aComparator = (Comparator<A>) serializerBase.deserialize(is,objectStack);
bComparator = (Comparator<B>) serializerBase.deserialize(is,objectStack);
cComparator = (Comparator<C>) serializerBase.deserialize(is,objectStack);
aSerializer = (Serializer<A>) serializerBase.deserialize(is,objectStack);
bSerializer = (Serializer<B>) serializerBase.deserialize(is,objectStack);
cSerializer = (Serializer<C>) serializerBase.deserialize(is,objectStack);
dSerializer = (Serializer<D>) serializerBase.deserialize(is,objectStack);
}
@Override
public void serialize(DataOutput out, int start, int end, Object[] keys) throws IOException {
int acount=0;
int bcount=0;
int ccount=0;
for(int i=start;i<end;i++){
Fun.Tuple4<A,B,C,D> t = (Fun.Tuple4<A, B,C,D>) keys[i];
if(acount==0){
//write new A
aSerializer.serialize(out,t.a);
//count how many A are following
acount=1;
while(i+acount<end && aComparator.compare(t.a, ((Fun.Tuple4<A, B, C,D>) keys[i+acount]).a)==0){
acount++;
}
Utils.packInt(out,acount);
}
if(bcount==0){
//write new B
bSerializer.serialize(out,t.b);
//count how many B are following
bcount=1;
while(i+bcount<end && bComparator.compare(t.b, ((Fun.Tuple4<A, B,C,D>) keys[i+bcount]).b)==0){
bcount++;
}
Utils.packInt(out,bcount);
}
if(ccount==0){
//write new C
cSerializer.serialize(out,t.c);
//count how many C are following
ccount=1;
while(i+ccount<end && cComparator.compare(t.c, ((Fun.Tuple4<A, B,C,D>) keys[i+ccount]).c)==0){
ccount++;
}
Utils.packInt(out,ccount);
}
dSerializer.serialize(out,t.d);
acount--;
bcount--;
ccount--;
}
}
@Override
public Object[] deserialize(DataInput in, int start, int end, int size) throws IOException {
Object[] ret = new Object[size];
A a = null;
int acount = 0;
B b = null;
int bcount = 0;
C c = null;
int ccount = 0;
for(int i=start;i<end;i++){
if(acount==0){
//read new A
a = aSerializer.deserialize(in,-1);
acount = Utils.unpackInt(in);
}
if(bcount==0){
//read new B
b = bSerializer.deserialize(in,-1);
bcount = Utils.unpackInt(in);
}
if(ccount==0){
//read new C
c = cSerializer.deserialize(in,-1);
ccount = Utils.unpackInt(in);
}
D d = dSerializer.deserialize(in,-1);
ret[i]= Fun.t4(a, b, c, d);
acount--;
bcount--;
ccount--;
}
if(acount!=0) throw new InternalError();
if(bcount!=0) throw new InternalError();
if(ccount!=0) throw new InternalError();
return ret;
}
@Override
public Comparator<Fun.Tuple4<A,B,C,D>> getComparator() {
return Utils.COMPARABLE_COMPARATOR;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Tuple4KeySerializer that = (Tuple4KeySerializer) o;
if (aComparator != null ? !aComparator.equals(that.aComparator) : that.aComparator != null) return false;
if (aSerializer != null ? !aSerializer.equals(that.aSerializer) : that.aSerializer != null) return false;
if (bComparator != null ? !bComparator.equals(that.bComparator) : that.bComparator != null) return false;
if (bSerializer != null ? !bSerializer.equals(that.bSerializer) : that.bSerializer != null) return false;
if (cComparator != null ? !cComparator.equals(that.cComparator) : that.cComparator != null) return false;
if (cSerializer != null ? !cSerializer.equals(that.cSerializer) : that.cSerializer != null) return false;
if (dSerializer != null ? !dSerializer.equals(that.dSerializer) : that.dSerializer != null) return false;
return true;
}
@Override
public int hashCode() {
int result = aComparator != null ? aComparator.hashCode() : 0;
result = 31 * result + (bComparator != null ? bComparator.hashCode() : 0);
result = 31 * result + (cComparator != null ? cComparator.hashCode() : 0);
result = 31 * result + (aSerializer != null ? aSerializer.hashCode() : 0);
result = 31 * result + (bSerializer != null ? bSerializer.hashCode() : 0);
result = 31 * result + (cSerializer != null ? cSerializer.hashCode() : 0);
result = 31 * result + (dSerializer != null ? dSerializer.hashCode() : 0);
return result;
}
}
} | [
"[email protected]"
] | |
975ea42b5e5bfb69392ff4fd8dee30087dab3bf2 | f525deacb5c97e139ae2d73a4c1304affb7ea197 | /gitv/src/main/java/com/gala/video/app/epg/ui/setting/ui/SettingAboutForLauncherActivity.java | db72b2e2ff71722c9ad4985e01af3d71b73ab795 | [] | no_license | AgnitumuS/gitv | 93b2359e1bf9f2b6c945298c61c5c6dbfeea49b3 | 242c9a10a0aeb41b9589de9f254e6ce9f57bd77a | refs/heads/master | 2021-08-08T00:50:10.630301 | 2017-11-09T08:10:33 | 2017-11-09T08:10:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,240 | java | package com.gala.video.app.epg.ui.setting.ui;
import android.os.Bundle;
import android.text.TextUtils.TruncateAt;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import com.gala.tvapi.vrs.CDNHelper;
import com.gala.tvapi.vrs.IVrsCallback;
import com.gala.tvapi.vrs.result.ApiResultF4v;
import com.gala.video.api.ApiException;
import com.gala.video.app.epg.R;
import com.gala.video.app.epg.ui.setting.interactor.impl.SettingAboutInteractorImpl;
import com.gala.video.lib.framework.core.utils.ListUtils;
import com.gala.video.lib.framework.core.utils.LogUtils;
import com.gala.video.lib.framework.core.utils.StringUtils;
import com.gala.video.lib.framework.core.utils.ThreadUtils;
import com.gala.video.lib.share.common.activity.QMultiScreenActivity;
import com.gala.video.lib.share.system.preference.setting.SettingSharepreference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SettingAboutForLauncherActivity extends QMultiScreenActivity {
private static final String CUSTOM_KEY = "custom";
private static final int MAX_SHOW_SIZE = 10;
private static final String PATTERN = "([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}";
private static final String TAG = "SettingAboutForLauncherActivity";
private Map<String, String> mData;
private SettingAboutInteractorImpl mInteractorImpl;
private LinearLayout mLlyt;
private TextView mTvDeviceName;
private Map<String, View> mViews = new HashMap();
static class Order {
String mKey;
int mNameId;
String mValue;
public Order(String key, String value) {
this.mKey = key;
this.mValue = value;
}
public Order(String key, int nameId) {
this.mKey = key;
this.mNameId = nameId;
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.epg_fragment_setting_about_for_launcher);
this.mLlyt = (LinearLayout) findViewById(R.id.epg_about_main_layout);
this.mTvDeviceName = (TextView) findViewById(R.id.epg_about_device_name);
initData();
fillData();
getDNS();
initCDNIPData();
}
protected View getBackgroundContainer() {
return findViewById(R.id.epg_setting_about_content);
}
private void initData() {
String deviceName = SettingSharepreference.getDeviceName(this);
if (StringUtils.isEmpty((CharSequence) deviceName)) {
deviceName = "客厅的电视";
}
this.mTvDeviceName.setText(getString(R.string.setting_about_devicename, new Object[]{deviceName}));
this.mInteractorImpl = new SettingAboutInteractorImpl(this);
this.mData = this.mInteractorImpl.getSystemData();
}
public List<Order> getShowOrder() {
String[] keys = new String[]{SettingAboutInteractorImpl.SYSTEM_VERSION, SettingAboutInteractorImpl.SOFTWARE_VERSION, SettingAboutInteractorImpl.PRIVATE_IP, SettingAboutInteractorImpl.PUBLIC_IP, SettingAboutInteractorImpl.DNS, SettingAboutInteractorImpl.CABLE_MAC, SettingAboutInteractorImpl.WIRELESS_MAC};
int[] nameId = new int[]{R.string.setting_about_sysversion, R.string.setting_about_softversion, R.string.setting_about_ip_private, R.string.setting_about_ip_public, R.string.setting_about_dns_launcher, R.string.setting_about_netcard_wired, R.string.setting_about_netcard_wireless};
List<Order> orderList = new ArrayList();
int length = Math.min(keys.length, nameId.length);
for (int i = 0; i < length; i++) {
orderList.add(new Order(keys[i], nameId[i]));
}
return orderList;
}
private void fillData() {
int size = 10;
this.mLlyt.removeAllViews();
List<Order> orders = formatData();
if (orders.size() <= 10) {
size = orders.size();
}
int i = 0;
while (i < size) {
Order order = (Order) orders.get(i);
if (order != null) {
buildItem(order.mKey, order.mValue);
i++;
} else {
return;
}
}
}
private List<Order> formatData() {
List<Order> data = new ArrayList();
for (Order order : getShowOrder()) {
if (!StringUtils.isEmpty((String) this.mData.get(order.mKey)) || order.mKey.equals(SettingAboutInteractorImpl.DNS)) {
LogUtils.i(TAG, order.mValue);
order.mValue = getString(order.mNameId, new Object[]{value});
data.add(order);
}
}
data.addAll(getCustomData());
return data;
}
private List<Order> getCustomData() {
List customData = this.mInteractorImpl.getCustomData();
List<Order> result = new ArrayList();
if (!ListUtils.isEmpty(customData)) {
for (int i = 0; i < customData.size(); i++) {
result.add(new Order(CUSTOM_KEY + i, (String) customData.get(i)));
}
}
return result;
}
private TextView createView(String string) {
TextView view = new TextView(this);
view.setText(string);
view.setSingleLine(true);
view.setEllipsize(TruncateAt.valueOf("END"));
view.setTextSize(0, getResources().getDimension(R.dimen.dimen_23sp));
view.setTextColor(getResources().getColor(R.color.setting_white));
view.setIncludeFontPadding(false);
LayoutParams params = new LayoutParams(-2, getDimen(R.dimen.dimen_40dp));
params.leftMargin = getDimen(R.dimen.dimen_16dp);
params.gravity |= 16;
view.setLayoutParams(params);
return view;
}
protected int getDimen(int id) {
return (int) getResources().getDimension(id);
}
private void initCDNIPData() {
CDNHelper.testStress.call(new IVrsCallback<ApiResultF4v>() {
public void onSuccess(ApiResultF4v result) {
SettingAboutForLauncherActivity.this.onSuccessResult(result);
}
public void onException(ApiException e) {
LogUtils.e(SettingAboutForLauncherActivity.TAG, "initCDNIPData() e" + e);
SettingAboutForLauncherActivity.this.refreshPublicIP(SettingAboutForLauncherActivity.this.getPublicIP());
}
}, "");
}
private void onSuccessResult(ApiResultF4v result) {
LogUtils.d(TAG, "onSuccessResult() -> ip:" + result);
String publicIP = getPublicIP();
if (!(result == null || StringUtils.isEmpty(result.t))) {
CharSequence ip = getMatchingIP(result.t);
if (!StringUtils.isEmpty(ip)) {
publicIP = ip;
savePublicIp(publicIP);
}
}
refreshPublicIP(publicIP);
}
private void savePublicIp(String ip) {
this.mInteractorImpl.savePublicIP(ip);
}
private String getPublicIP() {
return this.mInteractorImpl.getPublicIP();
}
private String getMatchingIP(String address) {
Matcher m = Pattern.compile(PATTERN).matcher(address);
if (m.find()) {
return m.group();
}
return "";
}
private void getDNS() {
ThreadUtils.execute(new Runnable() {
public void run() {
SettingAboutForLauncherActivity.this.refreshDNS(SettingAboutForLauncherActivity.this.mInteractorImpl.getDNS());
}
});
}
private void refreshPublicIP(final String ip) {
runOnUiThread(new Runnable() {
public void run() {
SettingAboutForLauncherActivity.this.buildItem(SettingAboutInteractorImpl.PUBLIC_IP, SettingAboutForLauncherActivity.this.getString(R.string.setting_about_ip_public, new Object[]{ip}));
}
});
}
private void refreshDNS(final String dns) {
runOnUiThread(new Runnable() {
public void run() {
if (StringUtils.isEmpty(dns)) {
TextView tv = (TextView) SettingAboutForLauncherActivity.this.mViews.get(SettingAboutInteractorImpl.DNS);
if (tv != null) {
SettingAboutForLauncherActivity.this.mLlyt.removeView(tv);
SettingAboutForLauncherActivity.this.mViews.remove(tv);
return;
}
return;
}
SettingAboutForLauncherActivity.this.buildItem(SettingAboutInteractorImpl.DNS, SettingAboutForLauncherActivity.this.getString(R.string.setting_about_dns_launcher, new Object[]{dns}));
}
});
}
private void buildItem(String key, String value) {
TextView tv = (TextView) this.mViews.get(key);
if (tv == null) {
tv = createView(value);
this.mLlyt.addView(tv);
this.mViews.put(key, tv);
return;
}
tv.setText(value);
}
}
| [
"[email protected]"
] | |
27f20d9babc1717671295b6ab32a064592ec4da5 | 32d46ca6cc3c319b3eb1463f40639e922dc9f203 | /src/main/java/cz/codecamp/logger/loggers/MultiLogger.java | 2fd8c9cc498307e159abb7409ca8f6fce7b673e8 | [] | no_license | vkorecky/cc16-java-intro | 352d230bd912f6cbeb2fd332048f0e3418e2fe6d | f5e1dbbc1a383959403c68693ac788e83ca790a9 | refs/heads/master | 2020-05-30T07:11:09.883968 | 2016-10-09T16:08:25 | 2016-10-09T16:08:25 | 70,084,580 | 0 | 1 | null | 2016-10-09T16:08:25 | 2016-10-05T17:49:36 | Java | UTF-8 | Java | false | false | 1,040 | java | package cz.codecamp.logger.loggers;
import cz.codecamp.logger.FormatterInterface;
import cz.codecamp.logger.LogLevelEnum;
import cz.codecamp.logger.LoggerInterface;
import java.util.List;
/**
* Created by vkorecky on 4.10.16.
*/
public class MultiLogger extends AbstractLogger {
private List<LoggerInterface> loggers;
public MultiLogger(List<LoggerInterface> loggers) {
super();
this.loggers = loggers;
}
/**
* Logger with custom formatter
*
* @param formatter
*/
public MultiLogger(FormatterInterface formatter, List<LoggerInterface> loggers) {
super(formatter);
this.loggers = loggers;
}
@Override
public void internalLog(LogLevelEnum level, String message, String callersClassName, String callersMethodName, int callersLineNumber) {
// Varinata 1
// for (LoggerInterface logger : loggers) {
// logger.log(level, message);
// }
//Varianta 2
loggers.forEach((l) -> l.log(level, message));
}
}
| [
"[email protected]"
] | |
bdb8514e6494cbbeab9c61bc399ac41c429f1856 | 8432e2b761a86bb74ae281612c113112528e8a82 | /com.skratchdot.electribe.model.esx.editor/src/com/skratchdot/electribe/model/esx/editor/handlers/SelectionHandlerSamples.java | 09d8f03b1f40a797988b859a81c608eaa30925a6 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | todofueunmalentendido/open-electribe-editor | 92a288e5b2a6e89f4a3f42600ec21793f4d31295 | 49368372f85e8da22c6d9665b51d2c863eef3145 | refs/heads/master | 2020-12-26T00:26:27.044496 | 2013-04-13T13:51:27 | 2013-04-13T13:51:27 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,427 | java | package com.skratchdot.electribe.model.esx.editor.handlers;
import java.util.ArrayList;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.StructuredSelection;
import com.skratchdot.electribe.model.esx.EsxFile;
import com.skratchdot.electribe.model.esx.EsxPackage;
import com.skratchdot.electribe.model.esx.Sample;
import com.skratchdot.electribe.model.esx.presentation.EsxEditorPartSamples;
import com.skratchdot.electribe.model.esx.util.EsxUtil;
public class SelectionHandlerSamples extends SelectionHandler {
public static final String NONE = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesNone";
public static final String ALL = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesAll";
public static final String ALL_EMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesAllEmpty";
public static final String ALL_NONEMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesAllNonEmpty";
public static final String ALL_FIRST = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesAllFirst";
public static final String MONO = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesMono";
public static final String MONO_EMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesMonoEmpty";
public static final String MONO_NONEMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesMonoNonEmpty";
public static final String MONO_FIRST = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesMonoFirst";
public static final String STEREO = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesStereo";
public static final String STEREO_EMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesStereoEmpty";
public static final String STEREO_NONEMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesStereoNonEmpty";
public static final String STEREO_FIRST = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesStereoFirst";
public static final String NEXT_EMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesNextEmpty";
public static final String NEXT_NONEMPTY = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesNextNonEmpty";
public static final String IN_PATTERN = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesInPattern";
public static final String NOT_IN_PATTERN = "com.skratchdot.electribe.model.esx.editor.commands.selectionSamplesNotInPattern";
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
setTableViewer(event, EsxEditorPartSamples.PAGE_INDEX);
if (tableViewer != null) {
if (event.getCommand().getId().equals(NONE)) {
tableViewer.setSelection(null);
} else if (event.getCommand().getId().equals(ALL)) {
select(true, true, true, true);
} else if (event.getCommand().getId().equals(ALL_EMPTY)) {
select(true, true, true, false);
} else if (event.getCommand().getId().equals(ALL_NONEMPTY)) {
select(true, true, false, true);
} else if (event.getCommand().getId().equals(ALL_FIRST)) {
selectFirst(false);
} else if (event.getCommand().getId().equals(MONO)) {
select(true, false, true, true);
} else if (event.getCommand().getId().equals(MONO_EMPTY)) {
select(true, false, true, false);
} else if (event.getCommand().getId().equals(MONO_NONEMPTY)) {
select(true, false, false, true);
} else if (event.getCommand().getId().equals(MONO_FIRST)) {
selectFirst(false);
} else if (event.getCommand().getId().equals(STEREO)) {
select(false, true, true, true);
} else if (event.getCommand().getId().equals(STEREO_EMPTY)) {
select(false, true, true, false);
} else if (event.getCommand().getId().equals(STEREO_NONEMPTY)) {
select(false, true, false, true);
} else if (event.getCommand().getId().equals(STEREO_FIRST)) {
selectFirst(true);
} else if (event.getCommand().getId().equals(NEXT_EMPTY)) {
selectNext(true);
} else if (event.getCommand().getId().equals(NEXT_NONEMPTY)) {
selectNext(false);
} else if (event.getCommand().getId().equals(IN_PATTERN)) {
selectPatternUsage(true);
} else if (event.getCommand().getId().equals(NOT_IN_PATTERN)) {
selectPatternUsage(false);
}
revealFirstSelected();
}
return null;
}
private void select(boolean isMono, boolean isStereo, boolean isEmpty,
boolean isNonEmpty) {
ArrayList<Object> items = new ArrayList<Object>();
for (int i = 0; i < tableViewer.getTable().getItemCount(); i++) {
Sample sample = (Sample) tableViewer.getElementAt(i);
if (isMono && isEmpty && !sample.isStereoCurrent()
&& sample.isEmpty()) {
items.add(sample);
} else if (isMono && isNonEmpty && !sample.isStereoCurrent()
&& !sample.isEmpty()) {
items.add(sample);
} else if (isStereo && isEmpty && sample.isStereoCurrent()
&& sample.isEmpty()) {
items.add(sample);
} else if (isStereo && isNonEmpty && sample.isStereoCurrent()
&& !sample.isEmpty()) {
items.add(sample);
}
}
tableViewer.setSelection(new StructuredSelection(items));
}
private void selectFirst(boolean isStereo) {
tableViewer.setSelection(new StructuredSelection(tableViewer
.getElementAt(isStereo ? EsxUtil.NUM_SAMPLES_MONO : 0)));
}
private void selectNext(boolean isEmpty) {
int currentIndex = tableViewer.getTable().getSelectionIndex();
ArrayList<Integer> skipIndices = new ArrayList<Integer>(1);
skipIndices.add(currentIndex);
int nextIndex = EsxUtil.findFirstIndex(
((EsxFile) tableViewer.getInput()).getSamples(),
currentIndex >= 0 ? currentIndex : 0, skipIndices,
EsxPackage.Literals.SAMPLE__EMPTY, isEmpty, true);
tableViewer.setSelection(new StructuredSelection(tableViewer
.getElementAt(nextIndex)));
}
private void selectPatternUsage(boolean isUsed) {
ArrayList<Object> items = new ArrayList<Object>();
for (int i = 0; i < tableViewer.getTable().getItemCount(); i++) {
Sample sample = (Sample) tableViewer.getElementAt(i);
if (isUsed && sample.getPatternCount() > 0) {
items.add(sample);
} else if (!isUsed && sample.getPatternCount() == 0) {
items.add(sample);
}
}
tableViewer.setSelection(new StructuredSelection(items));
}
}
| [
"[email protected]"
] | |
1774049aa9b7f68a4161598675c8316bc05b06a9 | e73025430f98612b4bce8faa13abdee1243bb9cd | /module04-examples/module04-question04/module04-question04-my-autoconfiguration/src/main/java/com/spring/professional/exam/tutorial/module04/question04/my/autoconfiguration/DataSourceAutoConfiguration.java | 26ff31ba2757a88414141ddde7edfda7dc894a9a | [] | no_license | a2ankitrai/spring-cert-code-examples | 938ddb647518e735c0ddba3b3809f95ea58750b3 | 491718751129bb0c09cb7bc2608934f7aedb2e81 | refs/heads/master | 2023-03-29T22:16:25.459200 | 2021-03-31T06:32:13 | 2021-03-31T06:32:13 | 331,714,577 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 793 | java | package com.spring.professional.exam.tutorial.module04.question04.my.autoconfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableTransactionManagement
@ConditionalOnClass(name = "org.hsqldb.Database")
public class DataSourceAutoConfiguration {
@Bean
public DataSource dataSource() {
return new EmbeddedDatabaseBuilder()
.generateUniqueName(true)
.build();
}
}
| [
"[email protected]"
] | |
460a342eb298df3963580a02958cba2dae9ec230 | 551fb8be252726b265b928326b099f39b8094b14 | /src/main/java/helpers/TimeoutConstants.java | ae33f0dad956d2872a82a4eab69b4bd154bb9a2b | [] | no_license | ToffeeKinderita/RestApiRepo | aa540071596d9365ae5da529b3dfe3371b23bd90 | 43f69581b6f88714478cbbfa25822108473b7471 | refs/heads/master | 2020-03-21T11:34:54.153260 | 2018-06-24T20:23:33 | 2018-06-24T20:23:33 | 138,512,704 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 217 | java | package helpers;
public class TimeoutConstants {
public static final int MEDIUM_TIMEOUT = 15_000;
public static final int SHORT_TIMEOUT = 10_000;
public static final int LONG_TIMEOUT = 20_000;
}
| [
"[email protected]"
] | |
00da7a2d635cc662c4a5d5621115ac10da9d17d2 | 28b6869556a6a118b9867d17dddd1391720c21a8 | /MS_Java_MCQs/src/AbstractTest.java | e49c1f3c0e782cfbd9b2f7ec1dd9c71dc9cdd31a | [] | no_license | adityaKPandey/Interview-2021 | 7584ecddd8fe720502bdcd1e4a71bbf7001b717f | 4bdce91dacccd79dc59b0929feb0ee1e77e32f29 | refs/heads/master | 2023-08-27T09:46:30.514899 | 2021-11-05T09:59:38 | 2021-11-05T09:59:38 | 424,883,578 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 466 | java |
public abstract class AbstractTest {
public int getNum() {
return 45;
}
public abstract class Bar{
public int getNum() {
return 38;
}
}
public static void main(String[] args) {
AbstractTest t = new AbstractTest() {
public int getNum() {
return 22;
}
};
AbstractTest.Bar f = t.new Bar() {
public int getNum() {
return 57;
}
};
System.out.println(f.getNum() + " " + t.getNum());
}
}
| [
"[email protected]"
] | |
97928c73c0daaf738680d757036f2a0d873e79f9 | f4f2f3f44149cdd741436fe10ab80adcd8c20706 | /src/main/java/com/pizza/domain/PizzaBase.java | b4c371ec43ab03c4899c695b1acc3e44ffcb8e4a | [
"MIT"
] | permissive | adrijardi/create-your-pizza | bdda887e1cc0fed9f64c27edeace2442639878bd | b3b20e5357dc17d1e6ec33882814c2ba2530a49a | refs/heads/master | 2021-01-20T21:52:27.860516 | 2014-09-11T16:33:08 | 2014-09-11T16:33:08 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,048 | java | package com.pizza.domain;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Entity
public class PizzaBase implements Priced, PricedSupport {
@Id
@GeneratedValue
private Long id;
@NotNull
private String name;
@NotNull
private String description;
private boolean active = true;
@NotNull
private BigDecimal price;
protected PizzaBase() {
}
public PizzaBase(String name, String description) {
this.name = name;
this.description = description;
}
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;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public BigDecimal getPrice() {
return price;
}
public void setPrice(BigDecimal price) {
this.price = price;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Topping)) return false;
Topping topping = (Topping) o;
if (getDescription() != null ? !getDescription().equals(topping.getDescription()) : topping.getDescription() != null) return false;
if (getName() != null ? !getName().equals(topping.getName()) : topping.getName() != null) return false;
return true;
}
@Override
public int hashCode() {
int result = getName() != null ? getName().hashCode() : 0;
result = 31 * result + (getDescription() != null ? getDescription().hashCode() : 0);
return result;
}
}
| [
"[email protected]"
] | |
6c32a10038fef5c025f7ea5571eb98959e3609e9 | b327a374de29f80d9b2b3841db73f3a6a30e5f0d | /out/host/linux-x86/obj/EXECUTABLES/vm-tests_intermediates/main_files/dot/junit/opcodes/iget/Main_testE2.java | 7def2c218acd45313dca5b8883801bb45da0416c | [] | no_license | nikoltu/aosp | 6409c386ed6d94c15d985dd5be2c522fefea6267 | f99d40c9d13bda30231fb1ac03258b6b6267c496 | refs/heads/master | 2021-01-22T09:26:24.152070 | 2011-09-27T15:10:30 | 2011-09-27T15:10:30 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 469 | java | //autogenerated by util.build.BuildDalvikSuite, do not change
package dot.junit.opcodes.iget;
import dot.junit.opcodes.iget.d.*;
import dot.junit.*;
public class Main_testE2 extends DxAbstractMain {
public static void main(String[] args) throws Exception {
T_iget_9 t = new T_iget_9();
try {
t.run();
fail("expected NullPointerException");
} catch (NullPointerException e) {
// expected
}
}
}
| [
"[email protected]"
] | |
c9239fc9a62cb862dcabf3b34bb1749aa5617be6 | 4f8e80a26489fdcb6a3ba2f9c382ae80d38374b1 | /src/com/minibot/api/method/ChatboxListener.java | 7ab2743950bed5ef3839c56941a1a8f7ef11fff0 | [] | no_license | SwipeX/minibot | 248bf0a930ec1e3d2347617b4a532524d99e4248 | 0dd34be737ea89f77330be7044996d7e15e93736 | refs/heads/master | 2023-03-04T01:04:56.384567 | 2018-03-16T14:58:00 | 2018-03-16T14:58:00 | 338,429,972 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package com.minibot.api.method;
/**
* @author Tyler Sedlar
* @since 6/28/2015
*/
public interface ChatboxListener {
void messageReceived(int type, String sender, String message, String clan);
}
| [
"[email protected]"
] | |
d90a655ce0aed2828badaebed679a4d908406e4c | 26696cda64a29ff0f3fb1b6ee5b2233d813c1077 | /EA/src/olseng/ea/fitness/SingleFitnessComparator.java | a46cd24659006e3840eccd410971cd1ec42ba3d0 | [
"Apache-2.0"
] | permissive | OlavOlseng/seed | 82e3d434f14c48e06320300e6859e63f098b962a | fb779ac1c82a280a44e3257c774527d32dafcdda | refs/heads/master | 2021-09-14T03:44:22.291394 | 2018-05-07T20:26:06 | 2018-05-07T20:26:06 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 643 | java | package olseng.ea.fitness;
import olseng.ea.genetics.Phenotype;
import java.util.Comparator;
/**
* Created by Olav on 22.01.2016.
*/
public class SingleFitnessComparator implements Comparator<Phenotype>{
private int fitnessIndex;
public SingleFitnessComparator(int fitnessIndex) {
this.fitnessIndex = fitnessIndex;
}
@Override
public int compare(Phenotype o1, Phenotype o2) {
float val = o1.getFitnessValue(fitnessIndex) - o2.getFitnessValue(fitnessIndex);
if(val < 0) {
return 1;
}
else if (val == 0) {
return 0;
}
return -1;
}
}
| [
"[email protected]"
] | |
aede703dd5deedfc1534e7574429e1b5ff47fcb9 | 7f8b69dd466101bfdfb4d80d78302f2013fb8573 | /src/main/java/com/museum/controller/ProceduresController.java | 9401ce34177b113409d1e07eb0096f68e5241e9b | [] | no_license | zhongchenghong/Gathering | 31bc8a986b144d835d595d6c4f50c16fd26bcc6b | 01889cbae0e16374e317c5f281bb7156cfef8bc3 | refs/heads/master | 2023-07-04T17:31:03.525333 | 2021-09-05T09:46:10 | 2021-09-05T09:46:10 | 402,288,477 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,785 | java | package com.museum.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.museum.domain.Account;
import com.museum.service.IAccountService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.*;
import com.museum.service.IProceduresService;
import com.museum.domain.Procedures;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.RestController;
/**
* <p>
* 前端控制器
* </p>
*
* @author lsj
* @since 2021-07-20
*/
@Api(tags = {"通用功能----我的流程"})
@RestController
@RequestMapping("/procedures")
public class ProceduresController {
private Logger log = LoggerFactory.getLogger(getClass());
@Resource
private IProceduresService proceduresService;
@Resource
private IAccountService accountService;
@ApiOperation(value = "新增")
@PostMapping()
public int add(@RequestBody Procedures procedures){
return proceduresService.add(procedures);
}
@ApiOperation(value = "删除")
@DeleteMapping("{id}")
public int delete(@PathVariable("id") Long id){
return proceduresService.delete(id);
}
@ApiOperation(value = "更新")
@PutMapping()
public int update(@RequestBody Procedures procedures){
return proceduresService.updateData(procedures);
}
@ApiOperation(value = "查询分页数据")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码"),
@ApiImplicitParam(name = "pageCount", value = "每页条数")
})
@GetMapping()
public IPage<Procedures> findListByPage(@RequestParam Integer page,
@RequestParam Integer pageCount, int state, String name, HttpServletRequest req){
Account ac=accountService.findAccount(req);
QueryWrapper queryWrappers = new QueryWrapper();
if(name!=null&&!"".equals(name)){
queryWrappers.like("apply_type",name);
}
if(state==3){
}else{
queryWrappers.eq("state",state);
}
queryWrappers.eq("uid",ac.getId());
queryWrappers.select().orderByDesc("apply_time");
return proceduresService.page(proceduresService.findListByPage(page, pageCount),queryWrappers);
}
@ApiOperation(value = "id查询")
@GetMapping("/findById")
public Procedures findById(@PathVariable Long id){
return proceduresService.findById(id);
}
}
| [
"[email protected]"
] | |
bfb7c002a21e8656dc6c3d2ee1e545322f7a6530 | 66abd544a073de7769271ddf9129c00e5ed1e520 | /src/main/java/com/eventstore/scheduling/domain/doctorday/command/ScheduleSlot.java | 60b0aa857bb42912772006bea26c0bfd51132306 | [] | no_license | lexasa/training-advanced-java | 6553b8a268b0424d86cd9b150a74fd438478ef34 | 5ee740c5af57718db1ae74f5d4626564ca937089 | refs/heads/master | 2023-01-29T16:14:25.420097 | 2020-12-11T20:41:53 | 2020-12-11T20:41:53 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 517 | java | package com.eventstore.scheduling.domain.doctorday.command;
import com.eventstore.scheduling.domain.doctorday.DayId;
import com.eventstore.scheduling.domain.doctorday.DoctorId;
import com.eventstore.scheduling.eventsourcing.Command;
import lombok.Data;
import lombok.NonNull;
import java.time.Duration;
import java.time.LocalTime;
@Data
public class ScheduleSlot implements Command {
private final @NonNull DayId dayId;
private final @NonNull LocalTime startTime;
private final @NonNull Duration duration;
}
| [
"[email protected]"
] | |
b03c434a72244782d67a877d75c8f79164ac9577 | be73270af6be0a811bca4f1710dc6a038e4a8fd2 | /crash-reproduction-moho/results/XWIKI-14122-34-4-PESA_II-WeightedSum:TestLen:CallDiversity/org/xwiki/extension/handler/internal/DefaultExtensionHandlerManager_ESTest_scaffolding.java | 9e60760eda48f0d148060f9c365a1589d955fbf5 | [] | no_license | STAMP-project/Botsing-multi-objectivization-using-helper-objectives-application | cf118b23ecb87a8bf59643e42f7556b521d1f754 | 3bb39683f9c343b8ec94890a00b8f260d158dfe3 | refs/heads/master | 2022-07-29T14:44:00.774547 | 2020-08-10T15:14:49 | 2020-08-10T15:14:49 | 285,804,495 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 471 | java | /**
* Scaffolding file used to store all the setups needed to run
* tests automatically generated by EvoSuite
* Sat Apr 04 11:37:29 UTC 2020
*/
package org.xwiki.extension.handler.internal;
import org.evosuite.runtime.annotation.EvoSuiteClassExclude;
import org.junit.BeforeClass;
import org.junit.Before;
import org.junit.After;
@EvoSuiteClassExclude
public class DefaultExtensionHandlerManager_ESTest_scaffolding {
// Empty scaffolding for empty test suite
}
| [
"[email protected]"
] | |
3883b5c0d3c48dd5f4a30a2eb244a47f5697fa7a | 649ddcbecbdeb64645b16896683207da6dc2c262 | /service/story-service-account/src/main/java/com/duan/story/service/LinkService.java | e5f9bf741ee91897a1b6ddf6d615d738471fde45 | [] | no_license | DuanJiaNing/story | 797a623fe9b086a91c33ecaf63ec179caa8b49ac | 9941bf3f7aa28aa302afaf8984f8b5bcd5eaa69c | refs/heads/master | 2023-07-25T01:20:24.275000 | 2019-07-28T15:08:35 | 2019-07-28T15:08:35 | 196,806,549 | 0 | 0 | null | 2023-07-22T10:48:16 | 2019-07-14T07:23:31 | Java | UTF-8 | Java | false | false | 1,545 | java | package com.duan.story.service;
import com.duan.story.common.PageResult;
import com.duan.story.common.ResultModel;
import com.duan.story.common.dto.LinkDTO;
/**
* Created on 2017/12/18.
*
* @author DuanJiaNing
*/
public interface LinkService {
/**
* 获取友情链接,自动按优先级从高到底排序
*
* @param writerId id
* @return 查询结果
*/
ResultModel<PageResult<LinkDTO>> listLink(Integer writerId, Integer pageNum, Integer pageSize);
/**
* 新增友情链接
*
* @param writerId id
* @param icon 图标
* @param title 名字
* @param url url
* @param bewrite 描述
* @return 新纪录id
*/
Integer insertLink(Integer writerId, String icon, String title, String url, String bewrite);
/**
* 删除链接
*
* @param linkId 链接id
* @return 删除成功为true
*/
boolean deleteLink(Integer linkId);
/**
* 更新链接
*
* @param linkId 链接id
* @param newIcon 新的图片,不改变传 null
* @param newTitle 新的标题,不改变传 null
* @param newUrl 新的url,不改变传 null
* @param newBewrite 新的描述,不改变传 null
* @return 更新失败为false
*/
boolean updateLink(Integer linkId, String newIcon, String newTitle, String newUrl, String newBewrite);
/**
* 获取链接
*
* @param linkId 链接id
* @return 结果
*/
LinkDTO getLink(Integer linkId);
}
| [
"[email protected]"
] | |
b5847b2a89a8331bf692fa40aa88e251fdb08371 | 9cd1326d33c89de5e651430bce0abbf25141ffb5 | /xDada/src/com/saurabh/dada/iq/impl/java8/LambdaExpressionsAndFunctionalInterfaces.java | 13bcc9c526cfc33b85b0137c5a7dd42784104720 | [] | no_license | shagg2010/XplorationNew2019 | 3a2b86a948d7aaeaebbd477055be2ee78fba00f4 | aec7c600e2a9513fb1afd65b95cad87ce3c926cc | refs/heads/master | 2023-04-22T22:53:20.437295 | 2021-05-08T04:34:02 | 2021-05-08T04:34:02 | 365,418,056 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 926 | java | package com.saurabh.dada.iq.impl.java8;
import java.util.ArrayList;
import java.util.List;
public class LambdaExpressionsAndFunctionalInterfaces {
public static void main(String[] args) {
List<Integer> list = new ArrayList<Integer>();
list.add(1);list.add(2);list.add(3);list.add(4);list.add(5);
list.forEach(n -> {System.out.print(n+" ");});
//using anonymous class - prior to Java 8
WorkerExecutor executor = new WorkerExecutor();
executor.execute(new WorkerInterface() {
@Override
public void doWork() {
System.out.println("\nDoing work using anonymous class.");
}
});
//using Lambda expressions
executor.execute(()->{System.out.println("Doing work using lambda expression.");});
}
}
@FunctionalInterface
interface WorkerInterface{
abstract void doWork();
}
class WorkerExecutor{
public void execute(WorkerInterface workerInterface){
workerInterface.doWork();
}
} | [
"[email protected]"
] | |
7b58c3d2714170df1f5575749fdb94ccd65b343b | 9c1b38069ca1f2179c9aba576f0e33541621e2d9 | /cloud-esclient/src/test/java/com/barry/cloud/platform/es/base/BaseESTest.java | 92322f6cb0ae904a3621b22d5d97999becccc713 | [] | no_license | BarryHan363136/cloud-service | 277f5738fb850771ee2b798ae7b0a4dc964501f2 | 57d0247b81583a738ca64cb99e8ab0e0e5ebfcf0 | refs/heads/master | 2022-12-01T17:19:40.742195 | 2020-11-23T09:36:35 | 2020-11-23T09:36:35 | 144,134,541 | 1 | 1 | null | 2022-11-16T12:22:11 | 2018-08-09T09:59:17 | Java | UTF-8 | Java | false | false | 568 | java | package com.barry.cloud.platform.es.base;
import com.barry.cloud.platform.es.ElasticStarter;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = ElasticStarter.class)
@WebAppConfiguration
public class BaseESTest {
@Ignore
@Test
public void baseTest(){
}
} | [
"[email protected]"
] | |
dd3cda0cc5b154916c0801f3f21cf4545411abd9 | cffeac0f97653783be247f1b68f649d6b7e4d97a | /src/main/java/kg/easyit/sellservice/services/impl/CodeServiceImpl.java | 099a6f434b9c20f8bdf5004947dfceb6ca7b0909 | [] | no_license | doorbiy/sell-service | 7c7a31b3a76cf509526a2de21ca67235a909c6b8 | f70f4420b6a72daf1f9814f5aa53a4a5c3e032fa | refs/heads/master | 2023-08-30T06:57:47.292823 | 2021-11-11T16:32:52 | 2021-11-11T16:32:52 | 416,742,132 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,371 | java | package kg.easyit.sellservice.services.impl;
import kg.easyit.sellservice.dao.CodeRepo;
import kg.easyit.sellservice.mappers.CodeMapper;
import kg.easyit.sellservice.mappers.UserMapper;
import kg.easyit.sellservice.models.dtos.CodeDto;
import kg.easyit.sellservice.models.dtos.UserDto;
import kg.easyit.sellservice.models.entities.Code;
import kg.easyit.sellservice.models.enums.CodeStatus;
import kg.easyit.sellservice.services.CodeService;
import kg.easyit.sellservice.services.SendSimpleMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service;
import java.util.Calendar;
import java.util.Objects;
@Service
public class CodeServiceImpl implements CodeService {
@Autowired
private CodeRepo codeRepo;
@Autowired
private SendSimpleMessage sendMessage;
@Override
public void saveCode(CodeDto codeDto) {
codeRepo.save(CodeMapper.INSTANCE.mapToCode(codeDto));
}
@Override
public Code findLastCode(UserDto userDto) {
return codeRepo.findByUserAndCodeStatus(UserMapper.INSTANCE.mapToUser(userDto), CodeStatus.NEW);
}
@Override
public void sendCode(UserDto userDto) {
Code lastCode =
codeRepo.findByUserAndCodeStatus(UserMapper.INSTANCE.mapToUser(userDto), CodeStatus.NEW);
if (Objects.nonNull(lastCode)) {
lastCode.setCodeStatus(CodeStatus.CANCELED);
codeRepo.save(lastCode);
}
int code = (int) ((Math.random() * 9000) + 1000);
String hashedCode =
BCrypt
.hashpw(
Integer
.toString(code)
, BCrypt.gensalt());
Calendar endOfCodeAction = Calendar.getInstance();
endOfCodeAction.add(Calendar.MINUTE, 3);
Code saveCode = new Code();
saveCode.setCode(hashedCode);
saveCode.setEndDate(endOfCodeAction.getTime());
saveCode.setCodeStatus(CodeStatus.NEW);
saveCode.setUser(UserMapper.INSTANCE.mapToUser(userDto));
codeRepo.save(saveCode);
sendMessage
.sendSimpleMessage(
userDto.getEmail()
, Integer.toString(code));
}
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.