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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
b20fd1e80e3def351015e04823e51aff7d2db411 | ee7edac442498050a0530352cbbf5e8d8fd61452 | /src/main/java/org/shunya/punter/test/UserAuthPubKey.java | 3addf7443fc7dd0af2497833af58358cba78f8f9 | [] | no_license | cancerian0684/Punter | 9f87f44beb182e4f31ec1de390080dc63309eb47 | a970127c26e8499f1774672062ebecf2531f4a33 | refs/heads/master | 2022-12-27T09:10:23.909911 | 2019-07-30T15:18:13 | 2019-07-30T15:18:13 | 2,099,613 | 0 | 0 | null | 2022-12-16T05:46:44 | 2011-07-25T06:06:31 | Java | UTF-8 | Java | false | false | 5,169 | java | package org.shunya.punter.test;/* -*-mode:java; c-basic-offset:2; indent-tabs-mode:nil -*- */
/**
* This program will demonstrate the user authentification by public key.
* $ CLASSPATH=.:../build javac UserAuthPubKey.java
* $ CLASSPATH=.:../build java UserAuthPubKey
* You will be asked username, hostname, privatekey(id_dsa) and passphrase.
* If everything works fine, you will get the shell prompt
*
*/
import com.jcraft.jsch.*;
import javax.swing.*;
import java.awt.*;
public class UserAuthPubKey{
public static void main(String[] arg){
try{
JSch jsch=new JSch();
JFileChooser chooser = new JFileChooser();
chooser.setDialogTitle("Choose your privatekey(ex. ~/.ssh/id_dsa)");
chooser.setFileHidingEnabled(false);
int returnVal = chooser.showOpenDialog(null);
if(returnVal == JFileChooser.APPROVE_OPTION) {
System.out.println("You chose "+
chooser.getSelectedFile().getAbsolutePath()+".");
jsch.addIdentity(chooser.getSelectedFile().getAbsolutePath()
// , "passphrase"
);
}
String host=null;
if(arg.length>0){
host=arg[0];
}
else{
host=JOptionPane.showInputDialog("Enter username@hostname",
System.getProperty("user.name")+
"@103.235.104.171");
}
String user=host.substring(0, host.indexOf('@'));
host=host.substring(host.indexOf('@')+1);
Session session=jsch.getSession(user, host, 6354);
// username and passphrase will be given via UserInfo interface.
UserInfo ui=new MyUserInfo();
session.setUserInfo(ui);
session.connect();
Channel channel=session.openChannel("shell");
channel.setInputStream(System.in);
channel.setOutputStream(System.out);
channel.connect();
}
catch(Exception e){
System.out.println(e);
}
}
public static class MyUserInfo implements UserInfo, UIKeyboardInteractive{
public String getPassword(){ return null; }
public boolean promptYesNo(String str){
Object[] options={ "yes", "no" };
int foo=JOptionPane.showOptionDialog(null,
str,
"Warning",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null, options, options[0]);
return foo==0;
}
String passphrase;
JTextField passphraseField=(JTextField)new JPasswordField(20);
public String getPassphrase(){ return passphrase; }
public boolean promptPassphrase(String message){
Object[] ob={passphraseField};
int result=
JOptionPane.showConfirmDialog(null, ob, message,
JOptionPane.OK_CANCEL_OPTION);
if(result==JOptionPane.OK_OPTION){
passphrase=passphraseField.getText();
return true;
}
else{ return false; }
}
public boolean promptPassword(String message){ return true; }
public void showMessage(String message){
JOptionPane.showMessageDialog(null, message);
}
final GridBagConstraints gbc =
new GridBagConstraints(0,0,1,1,1,1,
GridBagConstraints.NORTHWEST,
GridBagConstraints.NONE,
new Insets(0,0,0,0),0,0);
private Container panel;
public String[] promptKeyboardInteractive(String destination,
String name,
String instruction,
String[] prompt,
boolean[] echo){
panel = new JPanel();
panel.setLayout(new GridBagLayout());
gbc.weightx = 1.0;
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.gridx = 0;
panel.add(new JLabel(instruction), gbc);
gbc.gridy++;
gbc.gridwidth = GridBagConstraints.RELATIVE;
JTextField[] texts=new JTextField[prompt.length];
for(int i=0; i<prompt.length; i++){
gbc.fill = GridBagConstraints.NONE;
gbc.gridx = 0;
gbc.weightx = 1;
panel.add(new JLabel(prompt[i]),gbc);
gbc.gridx = 1;
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.weighty = 1;
if(echo[i]){
texts[i]=new JTextField(20);
}
else{
texts[i]=new JPasswordField(20);
}
panel.add(texts[i], gbc);
gbc.gridy++;
}
if(JOptionPane.showConfirmDialog(null, panel,
destination+": "+name,
JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE)
==JOptionPane.OK_OPTION){
String[] response=new String[prompt.length];
for(int i=0; i<prompt.length; i++){
response[i]=texts[i].getText();
}
return response;
}
else{
return null; // cancel
}
}
}
}
| [
"[email protected]"
] | |
cda5549f071ada0b685fc157ee1687ec1fe42f16 | c3dbaf8d6a9e539cdf836c5c9fbcf244e387f2d8 | /app/src/test/java/com/test/svg/ExampleUnitTest.java | 658867749e1c31403e5f2b83a3b4e878c4da917b | [] | no_license | BigFaceCatMhc/SvgAnimDemo | 89ba78d7f0e0675b8fc5848874f4cff54442d1b7 | ada07253b5aad89b4a2a8cde9d2af68ddf0ec2f3 | refs/heads/master | 2020-07-02T14:41:39.995759 | 2019-08-10T01:06:18 | 2019-08-10T01:06:18 | 201,429,037 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 373 | java | package com.test.svg;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
6a5ddfd3d78c1613dd55ee022ed4d4ca0edd7cf1 | 1f963af51acdae11068eaeec98264a472aa9ad4b | /src/main/java/alexanderc/es/plugin/kas/Response/ErrorResponse.java | 549d3c9f288feef81dc3a310faaa9765dac2b0cc | [] | no_license | AlexanderC/elasticsearch-key-aware-search | 50bc94ffe57ea61803f95a47d8bef3bd6dd64667 | 88dfb04b07f8f3b28da010836c6b80dd8d33ec24 | refs/heads/master | 2021-01-01T18:02:07.973719 | 2015-04-06T12:15:40 | 2015-04-06T12:15:40 | 25,857,399 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 2,230 | java | package alexanderc.es.plugin.kas.Response;
import org.elasticsearch.common.text.StringAndBytesText;
import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.rest.*;
/**
* Created by AlexanderC on 10/28/14.
*/
public class ErrorResponse extends BaseResponse {
public ErrorResponse(final String message, RestStatus status) {
StringBuilder sb = new StringBuilder();
String codePrefix = "2";
if (500 <= status.getStatus() && status.getStatus() <= 599) {
codePrefix = "3";
} else if (400 <= status.getStatus() && status.getStatus() <= 499) {
codePrefix = "4";
}
sb.append("{");
sb.append("\"error\":true,");
sb.append("\"message\":\"%1\",".replace("%1", message.replace("\"", "\\\"").replace("\n", "\\n")));
sb.append("\"code\":").append(codePrefix).append(status.getStatus());
sb.append("}");
StringAndBytesText responseObject = new StringAndBytesText(sb.toString());
this.setBytes(responseObject.bytes());
this.setStatus(status);
}
public static ErrorResponse fromThrowable(Throwable throwable, Boolean debug) {
StringBuilder error = new StringBuilder();
if(debug) {
error.append(throwable.toString());
error.append('\n');
for (StackTraceElement traceElement : throwable.getStackTrace()) {
error.append('\n');
error.append("[");
error.append(traceElement.getFileName());
error.append(":");
error.append(traceElement.getLineNumber());
error.append("] ");
error.append(traceElement.getClassName());
error.append(".");
error.append(traceElement.getMethodName());
error.append("()");
}
} else {
error.append(throwable.getMessage());
}
RestStatus restStatus = RestStatus.INTERNAL_SERVER_ERROR;
if(throwable instanceof ElasticsearchException) {
restStatus = ((ElasticsearchException) throwable).status();
}
return new ErrorResponse(error.toString(), restStatus);
}
}
| [
"[email protected]"
] | |
451281b20f4715accca46ac940ad4c17e27e9163 | 70daf318d027f371ada3abeaaa31dd47651640d7 | /src/action/ind/INDStockBatchAction.java | 14cdc366856f4750daf83b84450fc2a79fad8bdf | [] | no_license | wangqing123654/web | 00613f6db653562e2e8edc14327649dc18b2aae6 | bd447877400291d3f35715ca9c7c7b1e79653531 | refs/heads/master | 2023-04-07T15:23:34.705954 | 2020-11-02T10:10:57 | 2020-11-02T10:10:57 | 309,329,277 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,094 | java | package action.ind;
import com.dongyang.action.TAction;
import com.dongyang.data.TParm;
import com.dongyang.db.TConnection;
import jdo.ind.INDTool;
/**
* <p>
* Title: ๆฅ็ป่ฟๅธ็ฎก็
* </p>
*
* <p>
* Description: ๆฅ็ป่ฟๅธ็ฎก็
* </p>
*
* <p>
* Copyright: Copyright (c) 2009
* </p>
*
* <p>
* Company: JavaHis
* </p>
*
* @author zhangy 2009.09.02
* @version 1.0
*/
public class INDStockBatchAction extends TAction {
public INDStockBatchAction() {
}
/**
* ๆๅฎ้จ้จ่ฏๅๅบๅญๆๅจๆฅ็ปๆนๆฌกไฝไธ
* @param parm TParm
* @return TParm
*/
public TParm onIndStockBatch(TParm parm) {
TConnection conn = getConnection();
TParm result = new TParm();
result = INDTool.getInstance().onIndStockBatchByOrgCode(parm, conn);
if (result.getErrCode() < 0) {
err("ERR:" + result.getErrCode() + result.getErrText()
+ result.getErrName());
conn.close();
return result;
}
conn.commit();
conn.close();
return result;
}
}
| [
"[email protected]"
] | |
2743864d43b0e57d2b897477b68f7f3fa6ec53bf | 36d14c92d0db82b59cf59c38c89b350aef0d7fa2 | /calculation-coordinates/src/main/java/by/mchs/CalculateCoordinateApplication.java | 610294ff6346d39d460120882b7e8e736e85c653 | [] | no_license | vadim1504/mchs-system | 1927e7ca04ee2542edaa5e55762de5baa4c0f59d | 7ae75a74d64e5c6894a45e857a6bfa38535518ab | refs/heads/master | 2021-07-10T20:46:11.134914 | 2017-10-12T20:05:49 | 2017-10-12T20:05:49 | 106,290,712 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 421 | java | package by.mchs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.scheduling.annotation.EnableScheduling;
@EnableScheduling
@SpringBootApplication
public class CalculateCoordinateApplication{
public static void main(String[] args) {
SpringApplication.run(CalculateCoordinateApplication.class, args);
}
}
| [
"[email protected]"
] | |
2c8716d27e1cf1c514a4b0b42bebbac54801a0b5 | b8919595220b4d98e3e6b3dc36ac9c37d43f5dee | /src/main/java/hello/MessageBean.java | 0e107589d7ad29580d557be9d152c4429092bb3e | [] | no_license | bnbelizario/tarefa1-dac | 0aa2a714d4205083d55c4f15c1f83a803ee78408 | 53de4fb7f7578f53a4dbefb9751844847d7b81c2 | refs/heads/master | 2023-06-14T17:39:27.092755 | 2021-07-07T16:09:55 | 2021-07-07T16:09:55 | 383,848,642 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,000 | java | package hello;
/*
* 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.
*/
import java.beans.*;
import java.io.Serializable;
/**
*
* @author viter
*/
public class MessageBean implements Serializable {
private String msg;
public MessageBean() {
}
public String getMsg() {
return msg;
}
public void setMsg(String value) {
switch (value){
case "pt":
msg = "Alรด";
break;
case "en":
msg = "Hello";
break;
case "de":
msg = "Hallo";
break;
case "fr":
msg = "Bonjour";
break;
case "it":
msg = "Ciao";
break;
case "es":
msg = "Hola";
break;
}
}
}
| [
"[email protected]"
] | |
00ac6fef60ae1a980fc857263dbfc15ebb190137 | 1d5bf8e505c30bbbe4ab09facc511cba2edf20f0 | /src/it/java2wsdl/src/main/java/org/codehaus/mojo/axistools/test/java2wsdl/Request.java | a9425ba9edb9259f596142b634de1c2594045cfc | [] | no_license | mojohaus/axistools-maven-plugin | 077e1b360e3338fe933726442485d41e3af5237f | 86d48377dd3c4e886a8d600f4e9c6d78d26a1c5c | refs/heads/master | 2023-09-04T06:44:25.016236 | 2022-07-01T22:17:31 | 2023-01-17T23:28:58 | 39,062,787 | 5 | 2 | null | 2023-01-17T23:29:00 | 2015-07-14T08:18:08 | Java | UTF-8 | Java | false | false | 79 | java | package org.codehaus.mojo.axistools.test.java2wsdl;
public class Request
{
}
| [
"[email protected]"
] | |
cbd279be000979042917b3bf42557f2112be347c | 377c8137175969acbe45be15f683bff2a17e3bef | /src/br/util/Email/SendEmail.java | 85575d3e5d0a5f06b03b0b8eae5d164e2555f42a | [] | no_license | frankalmeida/compreagora | 3ebba302538207f87af7abdbd30d81d82020888c | 51fcaade432b24fd8f19f2f68e52422969d0640c | refs/heads/master | 2022-10-17T18:12:07.898769 | 2014-10-01T13:13:40 | 2014-10-01T13:13:40 | 22,381,879 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,207 | java | package br.util.Email;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import java.util.Properties;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
import javax.mail.Authenticator;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
/**
* Created by IntelliJ IDEA. User: Marcio Ballem Date: 15/02/2011 Time: 10:32:17
* To change this template use File | Settings | File Templates.
*/
public class SendEmail {
// cria as propriedades necessarias para o envio de email
public void senderMail(final EmailConfing mail)
throws UnsupportedEncodingException, MessagingException {
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.host", mail.getSmtpHostMail());
props.setProperty("mail.smtp.auth", mail.getSmtpAuth());
props.setProperty("mail.smtp.starttls.enable", mail.getSmtpStarttls());
props.setProperty("mail.smtp.port", mail.getSmtpPortMail());
props.setProperty("mail.mime.charset", mail.getCharsetMail());
// nao usar props.setProperty("mail.smtp.ssl.enable", "true"); // rola a
// exception:
// trying to connect to host "smtp.gmail.com", port 587, isSSL true
// javax.mail.MessagingException: Could not connect to SMTP host:
// smtp.gmail.com, port: 587;
// nested exception is: javax.net.ssl.SSLException: Unrecognized SSL
// message, plaintext connection?
// classe anonima que realiza a autenticacao do usuario no servidor de
// email.
Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mail.getUserMail(),
mail.getPassMail());
}
};
// Cria a sessao passando as propriedades e a autenticacao
Session session = Session.getDefaultInstance(props, auth);
// Gera um log no console referente ao processo de envio
session.setDebug(true);
// cria a mensagem setando o remetente e seus destinatarios
Message msg = new MimeMessage(session);
try {
// aqui seta o remetente
msg.setFrom(new InternetAddress(mail.getUserMail(), mail
.getFromNameMail()));
boolean first = true;
for (Map.Entry<String, String> map : mail.getToMailsUsers()
.entrySet()) {
if (first) {
// setamos o 1 destinatario
msg.addRecipient(Message.RecipientType.TO,
new InternetAddress(map.getKey(), map.getValue()));
first = false;
} else {
// setamos os demais destinatarios
msg.addRecipient(Message.RecipientType.CC,
new InternetAddress(map.getKey(), map.getValue()));
}
}
// Adiciona um Assunto a Mensagem
msg.setSubject(mail.getSubjectMail());
// Cria o objeto que recebe o texto do corpo do email
MimeBodyPart textPart = new MimeBodyPart();
textPart.setContent(mail.getBodyMail(), mail.getTypeTextMail());
// Monta a mensagem SMTP inserindo o conteudo, texto e anexos
Multipart mps = new MimeMultipart();
if (mail.getFileMails() != null) {
for (int index = 0; index < mail.getFileMails().size(); index++) {
// Abre e anexa o arquivo
MimeBodyPart attachFilePart = new MimeBodyPart();
FileDataSource fds = new FileDataSource(mail.getFileMails()
.get(index));
attachFilePart.setDataHandler(new DataHandler(fds));
attachFilePart.setFileName(fds.getName());
// adiciona os anexos da mensagem
mps.addBodyPart(attachFilePart, index);
}
}
// adiciona o corpo texto da mensagem
mps.addBodyPart(textPart);
// adiciona a mensagem o conteudo texto e anexo
msg.setContent(mps);
// Envia a Mensagem
Transport.send(msg);
} catch (MessagingException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
97900996e515a009869ec4c9f7f1781a61f8118e | 6f23e681f48434b3c8dd596fc0cc9a4134056ecb | /isportal/src/com/hansol/isportal/dbservice/dao/DbSvcDAO.java | 4d5764c4b59fb0eb55d788da24481783621f68ea | [] | no_license | frjufvjn/isportal | db082501078b25a188396a3e3f868a9efeee367a | 2aaa23a3228fd877a7803824bddacce04b5ff120 | refs/heads/master | 2023-03-13T23:57:54.999747 | 2022-12-30T22:35:16 | 2022-12-30T22:35:16 | 52,587,844 | 1 | 0 | null | 2023-02-22T08:07:19 | 2016-02-26T07:49:00 | JavaScript | UTF-8 | Java | false | false | 1,554 | java | package com.hansol.isportal.dbservice.dao;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import com.hansol.isportal.dbservice.sqlprovider.DbSvcGetSQL;
public abstract interface DbSvcDAO {
String SQL_GET_SQL = "select sql_desc from tp_db_svc_memory where db_svc_no = #{db_svc_no}";
/*
* 1. Annotation์ ํ์ฉํ ๋ฐฉ๋ฒ
String SQL_SELECT_TEST = "select * from tp_cm_service";
@Select(SQL_SELECT_TEST)
public abstract List<Map<String,Object>> getListTest() throws Exception;*/
/**
* 2. SQL์ ๊ฐ์ ธ์์ ํ์ฉํ๋ ๋ฐฉ๋ฒ
* @return
* @throws Exception
*/
@Select(SQL_GET_SQL)
public abstract String getSqlBySvcNo(Map paramMap) throws Exception;
@SelectProvider(type = DbSvcGetSQL.class, method="getSql")
public abstract List<Map<String,Object>> getListParam(Map paramMap) throws Exception;
@UpdateProvider(type = DbSvcGetSQL.class, method="getSql")
public abstract void doUpdateList(Map paramMap) throws Exception;
@InsertProvider(type = DbSvcGetSQL.class, method="getSql")
public abstract void doInsertList(Map<String,Object> paramMap) throws Exception;
@SelectProvider(type = DbSvcGetSQL.class, method="getSql")
public abstract Map<String,Object> doProcedure(Map<String,Object> paramMap) throws Exception;
}
| [
"PJW@PJW-PC"
] | PJW@PJW-PC |
654340ee5c2caeb4cf98defefe72ae2b1788e169 | 1ee296f2911be31165c76de2a32429ada9049ba5 | /src/main/java/test/poc/demostore/management/CheckoutManagement.java | 17eba6c8a669c19c667c99139d7d66d90de0d073 | [] | no_license | Maxcp/demo-store | 7bf61fd3839ebec690d7efab4dc992ce92fb8654 | 1e7859d5d9f04d500e41de7715ef27f64dbbcc6b | refs/heads/master | 2020-07-09T01:35:53.533021 | 2019-08-23T15:49:19 | 2019-08-23T15:49:19 | 203,837,841 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,850 | java | package test.poc.demostore.management;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import test.poc.demostore.exception.DemoStoreException;
import test.poc.demostore.model.Checkout;
import test.poc.demostore.model.Discount;
import test.poc.demostore.model.ProductItem;
import test.poc.demostore.model.request.CheckoutRequest;
import test.poc.demostore.model.request.Item;
import test.poc.demostore.service.DiscountService;
import test.poc.demostore.service.ProductService;
import java.math.BigDecimal;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
@Component
public class CheckoutManagement {
private Logger logger = LoggerFactory.getLogger(CheckoutManagement.class);
@Autowired
DiscountService discountService;
@Autowired
ProductService productService;
public Checkout doCheckout(CheckoutRequest checkoutRequest) throws DemoStoreException {
logger.info("Initializing checkout");
checkoutRequest.setItems(aggregateItemsByProductId(checkoutRequest.getItems()));
Checkout checkout = new Checkout();
checkout.setProductItems(setProductItems(checkoutRequest));
checkout.setDiscount(applyDiscounts(checkoutRequest));
logger.info("Checkout finished");
return checkout;
}
private BigDecimal applyDiscounts(CheckoutRequest checkoutRequest) {
logger.info("Applying discounts");
List<Discount> discounts = discountService.getDiscounts();
AtomicReference<BigDecimal> discountPool = new AtomicReference<>(new BigDecimal(0L));
discounts.forEach( d ->
discountPool.updateAndGet(v -> v.add (Objects.requireNonNull(applyDiscounts(d , checkoutRequest.getItems()))))
);
discountPool.get();
logger.info("Discounts applied");
return discountPool.get();
}
private BigDecimal applyDiscounts(Discount discount, List<Item> items) {
AtomicReference<BigDecimal> totalDiscount = new AtomicReference<>(new BigDecimal(0L));
items.forEach( item -> {
if(item.getProductId().equals(discount.getProduct().getId())) {
totalDiscount.updateAndGet(v -> v.add(discount.apply(item.getQuantity())));
}
});
return totalDiscount.get();
}
/**
* Fetch the productItem while validating if it exists
*
* @param checkoutRequest
* @return List of ProductItem
* @throws DemoStoreException
*/
private List<ProductItem> setProductItems(CheckoutRequest checkoutRequest) throws DemoStoreException {
List<ProductItem> productItems = new ArrayList<>();
for (Item item : checkoutRequest.getItems()) {
ProductItem productItem = new ProductItem();
productItem.setProduct(productService.getProductById(item.getProductId()));
productItem.setQuantity(item.getQuantity());
productItems.add(productItem);
}
return productItems;
}
/**
*
* If there are duplicated products in the list it will merge.
* This method must be called before apply the discount.
*
* @param items
* @return List of Item
*/
List<Item> aggregateItemsByProductId(List<Item> items) {
Map<Long,Item> productList = new HashMap<>();
for (Item item : items ){
if (!productList.containsKey(item.getProductId())){
productList.put(item.getProductId(),item);
} else {
productList.get(item.getProductId()).setQuantity( productList.get(item.getProductId()).getQuantity() + item.getQuantity() );
}
}
return new ArrayList<>(productList.values());
}
}
| [
"[email protected]"
] | |
85d4ead46e138686f129ded4a2f8e103788f1698 | 1b15fe5acedc014df2e0ae108a4c929dccf0911d | /src/main/java/com/turk/clusters/slave/SlaveActive.java | cd69bc3b24a30ff1dcf885c9a52cd62f8082b2a0 | [] | no_license | feinzaghi/Capricorn | 9fb9593828e4447a9735079bad6b440014f322b3 | e1fca2926b1842577941b070a826a2448739a2e8 | refs/heads/master | 2020-06-14T11:43:29.627233 | 2017-01-24T03:19:28 | 2017-01-24T03:19:28 | 75,029,435 | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 3,333 | java | package com.turk.clusters.slave;
import net.sf.json.JSONObject;
import org.apache.log4j.Logger;
import com.turk.clusters.model.Register;
import com.turk.config.SystemConfig;
import com.turk.socket.Client;
import com.turk.util.LogMgr;
import com.turk.util.ThreadPool;
/**
* ่็นๆฅๆดป
* 1ๅ้ๆฅๅไธๆฌก
* @author Administrator
*
*/
public class SlaveActive implements Runnable{
private static SlaveActive instance;
private boolean stopFlag = false;
private Logger logger = LogMgr.getInstance().getAppLogger("slave");
private Thread thread = new Thread(this, toString());
public static synchronized SlaveActive getInstance()
{
if (instance == null)
{
instance = new SlaveActive();
}
return instance;
}
public void start()
{
this.thread.start();
}
@Override
public void run() {
// TODO Auto-generated method stub
while (!isStop())
{
try
{
Register reg = new Register();
reg.setMsgID(1002); //ๆฅๆดปๅๆญฅๆถๆฏ
reg.setServer(SlaveConfig.getInstance().getSlaveServer());
reg.setPort(SlaveConfig.getInstance().getSlavePort());
reg.setCurrentCltCount(ThreadPool.getInstance().ActiveTaskCount());
reg.setMaxActiveTask(SystemConfig.getInstance().getMaxCltCount());
reg.setMaxCltCount(SystemConfig.getInstance().getMaxThread());
reg.setFlag(SlaveConfig.getInstance().getSlaveFlag());
JSONObject jsonObject = JSONObject.fromObject(reg);
//System.out.println(jsonObject);
logger.debug("1002-MSG๏ผ" + jsonObject.toString());
Client clt = new Client(SlaveConfig.getInstance().getMasterServer(),
SlaveConfig.getInstance().getMasterPort());
String Result = clt.SendMsgNetty(jsonObject.toString());
if(Result.equals("Done"))
{
logger.debug("1002-MSG-["+reg.getServer()+"] send success!");
}
Thread.sleep(5*1000L); //5sๆฅๅไธๆฌก
}
catch (InterruptedException ie)
{
this.logger.warn("ๅค็ๅผบ่กไธญๆญ.");
this.stopFlag = true;
break;
}
catch (Exception e)
{
this.logger.error(this + ": ๅผๅธธ.ๅๅ :", e);
break;
}
}
this.logger.debug("่็น่ชๅจๆฅๆดปๆซๆ็บฟๆ");
}
public synchronized boolean isStop()
{
return this.stopFlag;
}
public synchronized boolean Stop()
{
this.stopFlag = true;
Register reg = new Register();
reg.setMsgID(1003); //ๆฅๆดปๅๆญฅๆถๆฏ
reg.setServer(SlaveConfig.getInstance().getSlaveServer());
reg.setPort(SlaveConfig.getInstance().getSlavePort());
reg.setCurrentCltCount(ThreadPool.getInstance().ActiveTaskCount());
reg.setMaxActiveTask(SystemConfig.getInstance().getMaxCltCount());
reg.setMaxCltCount(SystemConfig.getInstance().getMaxThread());
reg.setFlag(3);
JSONObject jsonObject = JSONObject.fromObject(reg);
//System.out.println(jsonObject);
logger.debug("1003-MSG๏ผ" + jsonObject.toString());
Client clt = new Client(SlaveConfig.getInstance().getMasterServer(),
SlaveConfig.getInstance().getMasterPort());
String Result = clt.SendMsg(jsonObject.toString());
if(Result.equals("Done"))
{
logger.debug("1003-MSG-["+reg.getServer()+"] send success!");
return true;
}
return false;
}
}
| [
"[email protected]"
] | |
dfd4785d6a3ae1fd900513b768005043a0bef8ed | 14cb2ff4a8126363cfea38b833f2ddeb97ec2656 | /app/src/main/java/com/nbs/app/latihan_sql_lite/BuatBiodata.java | 2b4855951d5943c13ecff3b053f7170a3f1bc110 | [] | no_license | mohamaddenisjs/Prak_Mobile_programming_tugas4 | f3b84ce1953fe597612fe9538e51705283cf0fc8 | 82feb970f0a4eda792cb05c186c2484629df81f4 | refs/heads/master | 2021-01-19T00:41:02.924128 | 2016-11-08T02:31:45 | 2016-11-08T02:31:45 | 73,141,253 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,519 | java | package com.nbs.app.latihan_sql_lite;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class BuatBiodata extends AppCompatActivity {
protected Cursor cursor;
DataHelper dbHelper;
Button ton1, ton2;
EditText text1, text2, text3, text4, text5, text6, text7;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_buat_biodata);
dbHelper = new DataHelper(this);
text1 = (EditText) findViewById(R.id.editText1);
text2 = (EditText) findViewById(R.id.editText2);
text3 = (EditText) findViewById(R.id.editText3);
text4 = (EditText) findViewById(R.id.editText4);
text5 = (EditText) findViewById(R.id.editText5);
text6 = (EditText) findViewById(R.id.editText6);
text7 = (EditText) findViewById(R.id.editText7);
ton1 = (Button) findViewById(R.id.button1);
ton2 = (Button) findViewById(R.id.button2);
ton1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
SQLiteDatabase db = dbHelper.getWritableDatabase();
db.execSQL("insert into biodata(nim, nama, tgl, jk, alamat, angkatan, jurusan) values('" +
text1.getText().toString()+"','"+
text2.getText().toString() +"','" +
text3.getText().toString()+"','"+
text4.getText().toString() +"','" +
text5.getText().toString() +"','" +
text6.getText().toString() +"','" +
text7.getText().toString() + "')");
Toast.makeText(getApplicationContext(), "Berhasil",
Toast.LENGTH_LONG).show();
MainActivity.ma.RefreshList();
finish();
}
});
ton2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
}
| [
"[email protected]"
] | |
6f973fc612d3c0ac9a05ea0fa8dd7838a944affb | d206ef7f2d6682525a07edb41c9d53aaa06be3bd | /src/application/Adoption.java | b38c0d206ce8e9e675031d295d690b889e87655c | [] | no_license | PeterBurton/Animal-Shelter-JavaFX | 489161724bc38b15aaf9b8c119bbe5d0d38a3c00 | 50575557c270b28a3b68c6a8dc17a2581f3326b7 | refs/heads/master | 2020-12-14T07:28:46.654171 | 2017-06-15T20:58:22 | 2017-06-15T20:58:22 | 68,367,763 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,532 | java | package application;
import java.time.LocalDate;
public class Adoption extends Category implements java.io.Serializable{
private static final long serialVersionUID = 8762978795694638193L;
private boolean neutered;
private boolean chipped;
private boolean vaccinated;
private String status;
private boolean reserved;
public Adoption(LocalDate date, boolean neutered, boolean chipped, boolean vaccinated, String status, boolean reserved)
{
super(date);
this.neutered=neutered;
this.chipped=chipped;
this.vaccinated=vaccinated;
this.status=status;
this.reserved=reserved;
}
public Adoption(){}
public LocalDate getDate()
{
return super.getDate();
}
public void setDate(LocalDate date)
{
super.setDate(date);
}
public Person getContact()
{
return super.getContact();
}
public void setContact(Person contact)
{
super.setContact(contact);
}
public boolean getReserved() {
return reserved;
}
public void setReserved(boolean reserved) {
this.reserved = reserved;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public boolean getVaccinated() {
return vaccinated;
}
public void setVaccinated(boolean vaccinated) {
this.vaccinated = vaccinated;
}
public boolean getChipped() {
return chipped;
}
public void setChipped(boolean chipped) {
this.chipped = chipped;
}
public boolean getNeutered() {
return neutered;
}
public void setNeutered(boolean neutered) {
this.neutered = neutered;
}
}
| [
"[email protected]"
] | |
442693a615522d2442ccec3105101ef7ec6c24dd | 7a2f7a99b05d37c21e5b50954a793886aefba3fd | /src/main/java/com/his/server/GetOutpMrDiagDescResponse.java | 3e651211730b25d3a0098ccdfc767f6de8076ca9 | [] | no_license | 2430546168/HisCloud | 9b2bf6bbb4294f6ca6150bac9834f9d13a42c4a1 | 20ada9b607e37f5fdcdbdae654fc0137d8d2658d | refs/heads/master | 2022-12-22T15:13:27.512402 | 2020-03-30T13:48:38 | 2020-03-30T13:48:38 | 226,229,622 | 1 | 1 | null | 2022-12-16T07:47:10 | 2019-12-06T02:28:57 | Java | GB18030 | Java | false | false | 1,408 | java |
package com.his.server;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>getOutpMrDiagDescResponse complex type็ Java ็ฑปใ
*
* <p>ไปฅไธๆจกๅผ็ๆฎตๆๅฎๅ
ๅซๅจๆญค็ฑปไธญ็้ขๆๅ
ๅฎนใ
*
* <pre>
* <complexType name="getOutpMrDiagDescResponse">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "getOutpMrDiagDescResponse", propOrder = {
"_return"
})
public class GetOutpMrDiagDescResponse {
@XmlElement(name = "return")
protected String _return;
/**
* ่ทๅreturnๅฑๆง็ๅผใ
*
* @return
* possible object is
* {@link String }
*
*/
public String getReturn() {
return _return;
}
/**
* ่ฎพ็ฝฎreturnๅฑๆง็ๅผใ
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setReturn(String value) {
this._return = value;
}
}
| [
"[email protected]"
] | |
21ccb94feebc1a9aaa8b1a285e6a11b7a8f91d2e | 425d3e258c60f222d944c3096002b5e08d21252b | /4_Cinema-JSP/Polytech-Cinema-Web/src/main/java/fr/polytech/cinema/forms/CharacterForm.java | 453d7a2e3d4cfe549b9ff447a6ed1677fc843223 | [
"Apache-2.0"
] | permissive | LoicDelorme/Polytech-Cinema | ec6e9483359accaf3ae07979d06262a9d990e2d6 | 2ae3cc0346cae9e9f08e036725a797450c7ba124 | refs/heads/master | 2021-07-23T19:48:55.445601 | 2017-11-03T18:41:36 | 2017-11-03T18:41:36 | 106,658,364 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 558 | java | package fr.polytech.cinema.forms;
public class CharacterForm {
private Integer movieId;
private Integer actorId;
private String name;
public Integer getMovieId() {
return movieId;
}
public void setMovieId(final Integer movieId) {
this.movieId = movieId;
}
public Integer getActorId() {
return actorId;
}
public void setActorId(final Integer actorId) {
this.actorId = actorId;
}
public String getName() {
return name;
}
public void setName(final String name) {
this.name = name == null || name.isEmpty() ? null : name;
}
} | [
"[email protected]"
] | |
c1aab32e5cc7dcd6a0dc657771f6b55dce6eb81e | b79ea2495047f564cf74d571074428701a82bd1d | /pro_3/src/ChangeWord.java | db049ed04250f600b9fd6b9f85b7f6048f67becb | [] | no_license | oyfkr/daily_ps | b08f66af37a9937cee3e1d5c6301583d479086e7 | 3cbdb06742c5a8f52822873d81d612705c516b99 | refs/heads/master | 2023-09-02T17:16:37.170409 | 2021-11-03T06:33:06 | 2021-11-03T06:33:06 | 299,524,585 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,217 | java | public class ChangeWord {
public static void main(String[] args) {
String begin = "hit";
String target = "cog";
String words[] = {"hot","dot","dog","lot","log","cog"};
ChangeWord c = new ChangeWord();
System.out.println(c.solution(begin,target,words));
}
static String tar;
static boolean[] check;
static int answer;
public int solution(String begin, String target, String[] words){
answer = 51;
check = new boolean[words.length];
tar = target;
dfs(begin,0,words);
if(answer == 51){
return 0;
}
return answer;
}
public void dfs(String begin,int cnt,String[] words){
if(begin.equals(tar)){
answer = Math.min(answer,cnt);
}
for(int i = 0; i< words.length;i++){
int dif = 0;
for(int j = 0; j<words[0].length();j++){
if(begin.charAt(j) != words[i].charAt(j)){
dif++;
}
}
if(dif == 1 && !check[i]){
check[i] = true;
dfs(words[i],cnt+1,words);
check[i] = false;
}
}
}
}
| [
"[email protected]"
] | |
48141a6d970522e6a60cda4f8fabd72965698b39 | bfabe2276dab1958d5fac10038cf21925bac2c98 | /src/main/java/seedu/task/model/TaskBook.java | 6a9383374fc82a1d36011f248da9f58bb46c85c8 | [
"MIT"
] | permissive | sunset1215/supertasker | 094c374ae5deed84114fa5758ed67a906f9b5d8b | 1b2f586296c4988b555531fd4596687f9a75f126 | refs/heads/master | 2021-06-08T01:20:49.786533 | 2016-11-11T14:29:18 | 2016-11-11T14:29:18 | 70,045,526 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 12,294 | java | //@@author A0153658W
package seedu.task.model;
import javafx.collections.ObservableList;
import seedu.task.model.task.DeadlineTask;
import seedu.task.model.task.EventTask;
import seedu.task.model.task.ReadOnlyTask;
import seedu.task.model.task.Task;
import seedu.task.model.task.UniqueTaskList;
import seedu.task.model.task.UniqueTaskList.DuplicateTaskException;
import seedu.task.model.task.UniqueTaskList.TaskNotFoundException;
import seedu.task.model.task.UniqueTaskList.TaskAlreadyCompletedException;
import seedu.task.model.task.UniqueTaskList.NoCompletedTasksFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Wraps all data at the task-book level Duplicates are not allowed (by .equals
* comparison)
*/
public class TaskBook implements ReadOnlyTaskBook {
private UniqueTaskList tasks;
private UndoTaskStack undoTaskStack;
private static final String UNDO_ADD_COMMAND = "add";
private static final String UNDO_DELETE_COMMAND = "delete";
private static final String UNDO_EDIT_COMMAND = "edit";
private static final String UNDO_COMPLETE_COMMAND = "complete";
private static final String UNDO_CLEAR_COMMAND = "clear";
private static final String UNDO_CLEAR_ALL_COMMAND = "clear all";
private static final int UNDO_FILLER_INDEX = -1;
{
tasks = new UniqueTaskList();
undoTaskStack = new UndoTaskStack();
}
public TaskBook() {
}
// @@author
/**
* Tasks are copied into this task book
*/
public TaskBook(ReadOnlyTaskBook toBeCopied) {
this(toBeCopied.getUniqueTaskList());
}
/**
* Tasks are copied into this task book
*/
public TaskBook(UniqueTaskList tasks) {
this.tasks = copyUniqueTaskList(tasks);
// the line of code below is the original code
// I used the above method to copy the lists
// because the original code changes all the tasks that is read from
// the storage into tasks, instead of keeping them as event task or
// deadline task or task.
// resetData(tasks.getInternalList(), tags.getInternalList());
}
public static ReadOnlyTaskBook getEmptyTaskBook() {
return new TaskBook();
}
//// list overwrite operations
/*
* Returns a copy of the given unique task list
*/
private UniqueTaskList copyUniqueTaskList(UniqueTaskList tasks) {
UniqueTaskList newList = new UniqueTaskList();
for (int i = 0; i < tasks.size(); i++) {
try {
newList.add(tasks.getTaskFromIndex(i));
} catch (DuplicateTaskException e) {
// this should not happen since we're just copying items over to
// a new list
}
}
return newList;
}
// @@author A0153658W-reused
public ObservableList<Task> getTasks() {
return tasks.getInternalList();
}
public void setTasks(List<Task> tasks) {
this.tasks.getInternalList().setAll(tasks);
}
public void resetData(Collection<? extends ReadOnlyTask> newTasks) {
System.out.println(newTasks.toString());
setTasks(newTasks.stream().map(Task::new).collect(Collectors.toList()));
}
public void resetData(ReadOnlyTaskBook newData) {
resetData(newData.getTaskList());
}
// @@author A0153658W
//// task-level operations
/**
* Adds a task to the task book.
*
* @throws UniqueTaskList.DuplicateTaskException
* if an equivalent task already exists.
*/
public void addTask(Task task) throws UniqueTaskList.DuplicateTaskException {
tasks.add(task);
undoTaskStack.pushAddToUndoStack(UNDO_ADD_COMMAND, task, UNDO_FILLER_INDEX);
}
/**
* Adds a task to the task list at a given index.
*
* @throws UniqueTaskList.DuplicateTaskException
* if an equivalent task already exists.
*/
public void addTask(int taskIndex, Task task) throws UniqueTaskList.DuplicateTaskException {
tasks.add(taskIndex, task);
}
public boolean removeTask(ReadOnlyTask key, String callingCommand) throws UniqueTaskList.TaskNotFoundException {
int targetIndex = tasks.getIndex(key);
if (tasks.remove(key)) {
undoTaskStack.pushDeleteToUndoStack(key, callingCommand, targetIndex);
return true;
} else {
throw new TaskNotFoundException();
}
}
/**
* Edits a task to the task at a given index.
*
* @throws UniqueTaskList.DuplicateTaskException
* if an equivalent task already exists.
* @throws TaskNotFoundException
*/
public void editTask(int taskIndex, Task taskToEdit, Task resultTask)
throws UniqueTaskList.DuplicateTaskException, TaskNotFoundException {
undoTaskStack.pushEditToUndoStack(UNDO_EDIT_COMMAND, taskToEdit, taskIndex);
try {
tasks.edit(taskIndex, resultTask);
} catch (TaskNotFoundException e) {
throw new TaskNotFoundException();
}
}
// @@author A0138704E
/**
* Completes a task in the task book.
*
* @param target
* task to be completed
* @throws TaskNotFoundException
* if target task cannot be found
* @throws TaskAlreadyCompletedException
* if target task is already marked as complete
*/
public void completeTask(ReadOnlyTask target) throws TaskNotFoundException, TaskAlreadyCompletedException {
int targetIndex = tasks.getIndex(target);
Task taskToComplete = tasks.getTaskFromIndex(targetIndex);
if (taskToComplete.isComplete()) {
throw new TaskAlreadyCompletedException();
}
taskToComplete.setComplete();
undoTaskStack.pushCompleteToUndoStack(taskToComplete, UNDO_COMPLETE_COMMAND, targetIndex);
}
// @@author A0153658W
public int getIndex(ReadOnlyTask key) throws UniqueTaskList.TaskNotFoundException {
return tasks.getIndex(key);
}
/**
* Clears completed tasks from the task book
*
* @throws NoCompletedTasksFoundException
* if no completed tasks were found
* @throws TaskNotFoundException
*/
public void clearCompletedTasks() throws NoCompletedTasksFoundException, TaskNotFoundException {
UniqueTaskList copyTasks = copyUniqueTaskList(tasks);
List<Task> clearedTasks = new ArrayList<Task>();
List<Integer> clearedTasksIndices = new ArrayList<Integer>();
List<String> clearedStatus = new ArrayList<String>();
prepareClearedTasksForUndo(copyTasks, clearedTasks, clearedTasksIndices, clearedStatus, true);
// remove the completed tasks
for (Task readTask : copyTasks) {
if (readTask.isComplete()) {
try {
tasks.remove(readTask);
} catch (TaskNotFoundException e) {
throw new TaskNotFoundException();
}
}
}
if (copyTasks.size() == tasks.size()) {
throw new NoCompletedTasksFoundException();
}
undoTaskStack.pushClearCompletedToUndoStack(clearedTasks, clearedTasksIndices, UNDO_CLEAR_COMMAND);
}
/**
* Clears all tasks from the task book
*
* @throws TaskNotFoundException
*/
public void clearAllTasks() throws TaskNotFoundException {
UniqueTaskList copyTasks = copyUniqueTaskList(tasks);
List<Task> clearedTasks = new ArrayList<Task>();
List<Integer> clearedTasksIndices = new ArrayList<Integer>();
List<String> clearedStatus = new ArrayList<String>();
prepareClearedTasksForUndo(copyTasks, clearedTasks, clearedTasksIndices, clearedStatus, false);
// remove the completed tasks
for (Task readTask : copyTasks) {
try {
tasks.remove(readTask);
} catch (TaskNotFoundException e) {
throw new TaskNotFoundException();
}
}
undoTaskStack.pushClearAllToUndoStack(clearedTasks, clearedTasksIndices, clearedStatus, UNDO_CLEAR_ALL_COMMAND);
}
/**
* Helper method to compile set of tasks and indices for clearing all tasks
* to prepare for undo stack
*
* @param copyTasks,
* clearedTasks, clearedTaskIndices, clearedStatus,
* isClearCompleteOnly
*
* -copyTasks is the set of tasks currently in the task book
* -clearedTasks is the list that maintains the cleared tasks
* -clearedTaskIndices is the list that maintains indices of
* -cleared tasks clearedStatus is the list that maintains the
* status of cleared tasks
* -isClearCompleteOnly is a boolean that determines whether
* this method was called for clear complete only or clear all
*/
private void prepareClearedTasksForUndo(UniqueTaskList copyTasks, List<Task> clearedTasks,
List<Integer> clearedTasksIndices, List<String> clearedStatus, boolean isClearCompleteOnly)
throws TaskNotFoundException {
// compile set of tasks and indices being cleared to prepare for undo
for (Task readTask : copyTasks) {
try {
clearedTasksIndices.add(tasks.getIndex(readTask));
clearedStatus.add(readTask.getStatus().toString());
Class<? extends ReadOnlyTask> clearedTask = readTask.getClass();
if (clearedTask.equals(DeadlineTask.class)) {
DeadlineTask cleared = new DeadlineTask(readTask.getName(), readTask.getEnd());
clearedTasks.add(cleared);
} else if (clearedTask.equals(EventTask.class)) {
EventTask cleared = new EventTask(readTask.getName(), readTask.getStart(), readTask.getEnd());
clearedTasks.add(cleared);
} else {
// cleared task must be a floating task
Task cleared = new Task(readTask.getName());
clearedTasks.add(cleared);
}
} catch (TaskNotFoundException e) {
throw new TaskNotFoundException();
}
}
// if this method was called to clear only completed, then remove the
// pending tasks
if (isClearCompleteOnly) {
for (int i = 0; i < clearedTasks.size(); i++) {
// if the task is pending, remove it
if (clearedStatus.get(i).equals("Pending")) {
clearedTasks.remove(i);
clearedTasksIndices.remove(i);
clearedStatus.remove(i);
}
}
} else {
// keep all the pending and completed tasks in the list to push to
// undo stack
}
}
public void undoTask() {
undoTaskStack.undo(tasks);
}
public String getUndoInformation() {
return undoTaskStack.getUndoInformation();
}
// @@author
/** Sorts the task book order by end date, then name */
public void sort() {
tasks.sort();
}
//// util methods
@Override
public String toString() {
return tasks.getInternalList().size() + " tasks";
// TODO: refine later
}
@Override
public List<ReadOnlyTask> getTaskList() {
return Collections.unmodifiableList(tasks.getInternalList());
}
@Override
public UniqueTaskList getUniqueTaskList() {
return this.tasks;
}
@Override
public boolean equals(Object other) {
return other == this // short circuit if same object
|| (other instanceof TaskBook // instanceof handles nulls
&& this.tasks.equals(((TaskBook) other).tasks));
}
@Override
public int hashCode() {
// use this method for custom fields hashing instead of implementing
// your own
return Objects.hash(tasks);
}
}
| [
"[email protected]"
] | |
9d81490d1b5853d4f691d451c4e761eed38ab432 | b62265852762c638febca899d63f38853a2ea677 | /src/main/java/com/example/fingerprint/fragment/FingerprintSetFragment.java | e1dc43cb1c93c6323d04b06adabe53e210709c4e | [] | no_license | 45088648/demo-module | 6e221cef467b8d19f13b523bd3c14bc46991d0dc | 95b085d5bac60e99dfa3f964b8df5f4a25756cd8 | refs/heads/master | 2020-04-11T01:26:39.297029 | 2018-12-12T01:28:18 | 2018-12-12T01:28:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,592 | java | package com.example.fingerprint.fragment;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import com.example.fingerprint.MainActivity;
import com.example.fingerprint.R;
import com.example.fingerprint.tools.StringUtils;
import com.example.fingerprint.tools.UIHelper;
import com.lidroid.xutils.ViewUtils;
import com.lidroid.xutils.view.annotation.ViewInject;
import com.lidroid.xutils.view.annotation.event.OnClick;
/**
* A simple {@link Fragment} subclass.
*/
public class FingerprintSetFragment extends Fragment {
private static final String TAG = "FingerprintSetFragment";
private MainActivity mContext;
@ViewInject(R.id.btnSetThreshold)
Button btnSetThreshold;
@ViewInject(R.id.btnGetThreshold)
Button btnGetThreshold;
@ViewInject(R.id.btnSetPacketSize)
Button btnSetPacketSize;
@ViewInject(R.id.btnGetPacketSize)
Button btnGetPacketSize;
@ViewInject(R.id.btnGetBaud)
Button btnGetBaud;
@ViewInject(R.id.btnSetBaud)
Button btnSetBaud;
@ViewInject(R.id.btnReInit)
Button btnReInit;
@ViewInject(R.id.spThreshold)
Spinner spThreshold;
@ViewInject(R.id.spPacketSize)
Spinner spPacketSize;
@ViewInject(R.id.spBaud)
Spinner spBaud;
@ViewInject(R.id.etPSW)
EditText etPSW;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_fingerprint_set,
container, false);
ViewUtils.inject(this, v);
return v;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mContext = (MainActivity) getActivity();
}
@OnClick(R.id.btnSetThreshold)
public void btnSetThreshold_onClick(View v) {
if (mContext.mFingerprint.setReg(5, spThreshold.getSelectedItemPosition() + 1)) {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_threshold_succ);
} else {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_threshold_fail);
}
}
@OnClick(R.id.btnSetPacketSize)
public void btnSetPacketSize_onClick(View v) {
if (mContext.mFingerprint.setReg(6, spPacketSize.getSelectedItemPosition())) {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_PacketSize_succ);
} else {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_PacketSize_fail);
}
}
@OnClick(R.id.btnSetBaud)
public void btnSetBaud_onClick(View v) {
int baudrate = StringUtils.toInt(spBaud.getSelectedItem().toString(), -1);
if (mContext.mFingerprint.setReg(4, baudrate / 9600)) {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_Baudrate_succ);
mContext.freeFingerprint();
mContext.initFingerprint(baudrate);
} else {
UIHelper.ToastMessage(mContext,
R.string.fingerprint_msg_set_Baudrate_fail);
}
}
@OnClick(R.id.btnReInit)
public void btnReInit_onClick(View v) {
int baudrate = StringUtils.toInt(spBaud.getSelectedItem().toString(), -1);
mContext.freeFingerprint();
mContext.initFingerprint(baudrate);
}
@OnClick(R.id.btnGetThreshold)
public void btnGetThreshold_onClick(View v) {
}
@OnClick(R.id.btnGetPacketSize)
public void btnGetPacketSize_onClick(View v) {
}
@OnClick(R.id.btnSetPSW)
public void btnSetPSW_onClick(View v) {
String strPWD = etPSW.getText().toString().trim();
if (!StringUtils.isNotEmpty(strPWD)) {
UIHelper.ToastMessage(mContext, R.string.rfid_mgs_error_nopwd);
return;
}
if (!mContext.vailHexInput(strPWD)) {
UIHelper.ToastMessage(mContext,
R.string.rfid_mgs_error_nohex);
return;
}
// if (mContext.mFingerprint.setPSW(strPWD)) {
//
// UIHelper.ToastMessage(mContext,
// R.string.fingerprint_msg_set_PSW_succ);
// } else {
// UIHelper.ToastMessage(mContext,
// R.string.fingerprint_msg_set_PSW_fail);
// }
}
@OnClick(R.id.btnVfyPSW)
public void btnVfyPSW_onClick(View v) {
String strPWD = etPSW.getText().toString().trim();
if (!StringUtils.isNotEmpty(strPWD)) {
UIHelper.ToastMessage(mContext, R.string.rfid_mgs_error_nopwd);
return;
}
if (strPWD.length() != 8) {
UIHelper.ToastMessage(mContext,
R.string.uhf_msg_addr_must_len8);
return;
}
if (!mContext.vailHexInput(strPWD)) {
UIHelper.ToastMessage(mContext,
R.string.rfid_mgs_error_nohex);
return;
}
// if (mContext.mFingerprint.vfyPSW(strPWD)) {
//
// UIHelper.ToastMessage(mContext,
// R.string.fingerprint_msg_verify_PSW_succ);
// } else {
// UIHelper.ToastMessage(mContext,
// R.string.fingerprint_msg_verify_PSW_fail);
// }
}
}
| [
"zcs640410"
] | zcs640410 |
66c478a02fdcf97b19307dc8e195a2bafdf98ab8 | c4623aa95fb8cdd0ee1bc68962711c33af44604e | /src/android/support/v4/widget/t.java | 5d4e13d4cdb8091bc08d9f17cded47ac1b09230d | [] | no_license | reverseengineeringer/com.yelp.android | 48f7f2c830a3a1714112649a6a0a3110f7bdc2b1 | b0ac8d4f6cd5fc5543f0d8de399b6d7b3a2184c8 | refs/heads/master | 2021-01-19T02:07:25.997811 | 2016-07-19T16:37:24 | 2016-07-19T16:37:24 | 38,555,675 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 442 | java | package android.support.v4.widget;
import android.view.View;
import android.widget.PopupWindow;
class t
{
public static void a(PopupWindow paramPopupWindow, View paramView, int paramInt1, int paramInt2, int paramInt3)
{
paramPopupWindow.showAsDropDown(paramView, paramInt1, paramInt2, paramInt3);
}
}
/* Location:
* Qualified Name: android.support.v4.widget.t
* Java Class Version: 6 (50.0)
* JD-Core Version: 0.7.1
*/ | [
"[email protected]"
] | |
c66ed2fdbbf6f53e3b73891e5b9412d7ab9a7c3e | 58f6e72aa09c952bc18e23e12d45c335da478ac5 | /app/src/androidTest/java/com/example/mymusicandroid/ExampleInstrumentedTest.java | 32efac68fb8efc93aeaddfa9da1764907ca1cc57 | [] | no_license | mawei150/myMusic | 1551655cd84de971a2657a0f00099ae5a4a573d7 | a53440b964b78dcc742ef7d3f98f03e23162f8ad | refs/heads/master | 2022-12-31T19:28:41.774649 | 2020-10-19T13:48:07 | 2020-10-19T13:48:07 | 286,508,669 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 736 | java | package com.example.mymusicandroid;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.mymusicandroid", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
ac36c4dc814661f10b062b006bb033153df75c2c | d3e47ffaf435eef07614120147deb204fe9e1acc | /src/JavaTechnoStudy/day44/staticFieldInheritance/B.java | 27f35d00eca764d24257b9e6afc4e6efe5ac63fa | [] | no_license | Aykurt24/aykurtsProjects | 94d08fe13d23f403e95309937db043a69d44a6c0 | 130e6c0adf7e6d321df7bf415947829bd8fe82a3 | refs/heads/master | 2022-10-24T18:20:58.562719 | 2020-06-16T15:00:17 | 2020-06-16T15:00:17 | 263,530,839 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 134 | java | package JavaTechnoStudy.day44.staticFieldInheritance;
public class B extends A {
public B() {
text = "Hello B";
}
}
| [
"[email protected]"
] | |
b216948c32e48f9863c6370a2ac59171d3a85fdf | 8b2cea97c681b073b6a48a4baaf24e64a7bdbb89 | /app/src/main/java/com/shady/moviesdirectory/Model/Movie.java | 9f4d54e6d0db0e5832f6435f96597b0c269672e2 | [] | no_license | imshahidmahmood/MoviesDirectory | d5a5842e0f7d1220b5dfa02615d5feec945e1f58 | da295f8e8d6e0bd82cff406f6ba5a25d24ea0d81 | refs/heads/master | 2022-05-21T10:02:01.642459 | 2020-04-24T20:04:33 | 2020-04-24T20:04:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,182 | java | package com.shady.moviesdirectory.Model;
import java.io.Serializable;
public class Movie implements Serializable{
private static final long id = 1L;
private String title;
private String director;
private String year;
private String runTime;
private String imdbId;
private String poster;
private String genre;
private String writer;
private String actors;
private String plot;
private String rating;
private String dvdRelease;
private String productionCompany;
private String country;
private String awards;
private String tvRated;
private String movieType;
public Movie() {
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDirector() {
return director;
}
public void setDirector(String director) {
this.director = director;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public String getRunTime() {
return runTime;
}
public void setRunTime(String runTime) {
this.runTime = runTime;
}
public String getImdbId() {
return imdbId;
}
public void setImdbId(String imdbId) {
this.imdbId = imdbId;
}
public String getPoster() {
return poster;
}
public void setPoster(String poster) {
this.poster = poster;
}
public String getGenre() {
return genre;
}
public void setGenre(String genre) {
this.genre = genre;
}
public String getWriter() {
return writer;
}
public void setWriter(String writer) {
this.writer = writer;
}
public String getActors() {
return actors;
}
public void setActors(String actors) {
this.actors = actors;
}
public String getPlot() {
return plot;
}
public void setPlot(String plot) {
this.plot = plot;
}
public String getRating() {
return rating;
}
public void setRating(String rating) {
this.rating = rating;
}
public String getDvdRelease() {
return dvdRelease;
}
public void setDvdRelease(String dvdRelease) {
this.dvdRelease = dvdRelease;
}
public String getProductionCompany() {
return productionCompany;
}
public void setProductionCompany(String productionCompany) {
this.productionCompany = productionCompany;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getAwards() {
return awards;
}
public void setAwards(String awards) {
this.awards = awards;
}
public String getTvRated() {
return tvRated;
}
public void setTvRated(String tvRated) {
this.tvRated = tvRated;
}
public String getMovieType() {
return movieType;
}
public void setMovieType(String movieType) {
this.movieType = movieType;
}
}
| [
"[email protected]"
] | |
cbdf1a51a2485668a0d3da28067b6c6e4ecf56a1 | 621dfac43a3214de493c32a139ead3b88d37b059 | /notificationapp/src/androidTest/java/ru/mirea/bushina/notificationapp/ExampleInstrumentedTest.java | dffc084e790015310017174c765b11ffd2ad9bed | [] | no_license | JulianaBushina/PracticeTwo | 1c44f376f0d80bfefe7c4ff0ed6b8f39c48debb3 | 441a62e23e911a3cbfe08fcf2120b5cddb3c5997 | refs/heads/master | 2023-08-11T23:17:41.158093 | 2021-10-14T19:14:51 | 2021-10-14T19:14:51 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 778 | java | package ru.mirea.bushina.notificationapp;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("ru.mirea.bushina.notificationapp", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
ad956a9d9948ef53f70d08b3b0963264e9264a29 | 21cb8fe6dd9c217f6185865c129d1c58165bc71e | /src/main/java/com/sonihr/aop/AspectJExpressionPointcutAdvisor.java | f7d2d5a8c8c711ce5246887aff3850efa3dde6df | [] | no_license | HuangtianyuCN/SonihrSpring | 8fcf5d13d196fc5a0712ef07010934304cf69822 | 858ecdd52c6930e782bcf4661672834d28624504 | refs/heads/master | 2021-07-04T20:38:40.248757 | 2019-05-27T14:18:54 | 2019-05-27T14:18:54 | 187,324,488 | 3 | 0 | null | 2020-10-13T13:18:29 | 2019-05-18T06:50:36 | Java | UTF-8 | Java | false | false | 643 | java | package com.sonihr.aop;
import org.aopalliance.aop.Advice;
/**
* @author [email protected]
*/
public class AspectJExpressionPointcutAdvisor implements PointcutAdvisor {
private AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
private Advice advice;
private String expression;
public void setAdvice(Advice advice) {
this.advice = advice;
}
public void setExpression(String expression) {
this.pointcut.setExpression(expression);
}
@Override
public Advice getAdvice() {
return advice;
}
@Override
public Pointcut getPointcut() {
return pointcut;
}
}
| [
"[email protected]"
] | |
ace68cb6696496fa66f51ee755fbbde0c083e2ca | 73539ea58e84e17207f54e04bb4ac604b4e6d1bd | /nasaclimate/src/test/java/com/ada/api/nasaclimate/DemoApplicationTests.java | 6a4e7e5ec2d8789de10a229ead7250eff44e53b7 | [] | no_license | Primave/NasaClimate | 240ea509c3abfb31974a411e98b157e3d939b6f5 | 66b42f4f721816a2c2839025c0776aa98e69b8d6 | refs/heads/master | 2022-11-25T19:11:55.888064 | 2020-08-03T16:26:43 | 2020-08-03T16:26:43 | 276,902,149 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 213 | java | package com.ada.api.nasaclimate;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DemoApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
59656db7a0a23000a9915158039b50af27c94341 | 6331d7b7d57799a8eb584672ff33d50cac489143 | /source/zookeeper-learning/zookeeper-learning-web/src/main/java/com/soul/alg/sword/OddNumberMoveFront.java | 5d240c1cfc138d7083805af7713af8516efec207 | [] | no_license | wangkunSE/notes | 9f7def0d91353eb3f42904e5f7a2f52cb2815ba2 | a204010706977a1cc334515e7e40266cdbc34f50 | refs/heads/master | 2022-12-22T08:59:46.438186 | 2020-12-17T02:41:08 | 2020-12-17T02:41:08 | 89,057,798 | 0 | 1 | null | 2022-12-16T10:31:48 | 2017-04-22T09:10:25 | Java | UTF-8 | Java | false | false | 905 | java | package com.soul.alg.sword;
/**
* @author wangkun1
* @version 2018/4/17
*/
public class OddNumberMoveFront {
public static void main(String[] args) {
int[] arr = {-1, -3, 4, 2, -5, -7};
new OddNumberMoveFront().arrayMove(arr);
for (int i : arr) {
System.out.print(i + "\t");
}
}
private void arrayMove(int[] arr) {
if (arr.length <= 0) {
return;
}
int low = 0;
int high = arr.length - 1;
while (low < high) {
while (arr[low] % 2 != 0 && low < high) {
low++;
}
while (arr[high] % 2 == 0 && low < high) {
high--;
}
swap(arr, low, high);
}
}
private void swap(int[] arr, int low, int high) {
int temp = arr[low];
arr[low] = arr[high];
arr[high] = temp;
}
}
| [
"[email protected]"
] | |
16aa97a36eb00c0fc14ce0418f351317d2a55502 | 95b93c921adf5c09793c41a7f0104374201212ab | /ws-Client/src/main/java/demo/spring/service_large/SayHi26Response.java | e77ed2ba9b9bc7409e1779f0265ba668a39deac2 | [] | no_license | yhjhoo/WS-CXF-AuthTest | d6ad62bdf95af7f4832f16ffa242785fc0a93eb8 | ded10abaefdc2e8b3b32becdc6f5781471acf27f | refs/heads/master | 2020-06-15T02:21:42.204025 | 2015-04-08T00:05:02 | 2015-04-08T00:05:02 | 33,409,007 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,431 | java |
package demo.spring.service_large;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for sayHi26Response complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* <complexType name="sayHi26Response">
* <complexContent>
* <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* <sequence>
* <element name="return" type="{http://www.w3.org/2001/XMLSchema}string" minOccurs="0"/>
* </sequence>
* </restriction>
* </complexContent>
* </complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "sayHi26Response", propOrder = {
"_return"
})
public class SayHi26Response {
@XmlElement(name = "return")
protected String _return;
/**
* Gets the value of the return property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getReturn() {
return _return;
}
/**
* Sets the value of the return property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setReturn(String value) {
this._return = value;
}
}
| [
"[email protected]"
] | |
e894c406f59e9cb1167dc8989b794b1f3aea5369 | 85d165ac867401335a01656a94191cfa8583b41b | /TestNG_DEMO/src/UniqloTest.java | 993b92fc1085fdefc9fe23b8171d6e709b87a252 | [] | no_license | Sriti15/MyGitRepo | 342480e02ef9119f3bfa50903717acb3ebdc74a8 | 8e3bfdac42763fcbf9d4aa9a4cfe91d2cb3fb352 | refs/heads/master | 2022-07-17T09:45:48.239333 | 2019-10-08T14:30:44 | 2019-10-08T14:30:44 | 198,456,874 | 0 | 0 | null | 2022-06-29T17:31:46 | 2019-07-23T15:21:11 | HTML | UTF-8 | Java | false | false | 917 | java |
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class UniqloTest {
WebDriver driver;
@ BeforeMethod
public void open(){
System.setProperty("webdriver.chrome.driver", "C:\\Users\\PSQA\\Desktop\\chromedriver.exe");
driver = new ChromeDriver();
driver.get("https://www.uniqlo.com");
}
@Test(priority=2)
public void LogoTest() throws InterruptedException{
String Test=driver.getTitle();
System.out.println(Test);
Thread.sleep(3000);
}
@Test(priority=1)
public void searchTest() throws InterruptedException{
driver.findElement(By.id("q")).sendKeys("Shirt");
Thread.sleep(3000);
}
@AfterMethod
public void CloseBrowser(){
driver.close();
}
} | [
"[email protected]"
] | |
b47f545cd56e395e945ba0f72bbc1d92d4410e65 | 5808048e42d442297c9e328f16e5e3388be1424b | /src/BonusExercises/Dyno.java | 038ba582bd9156d42787c1408051787342bd9361 | [
"MIT"
] | permissive | azurite/AuD-Practice | 3f596eb16bc27c77b48cc8c7a15163aa7b3c564b | 84ca09e2e4f87daf4e4326ff2597570be9ae60ed | refs/heads/master | 2022-02-18T05:57:47.211223 | 2018-02-07T14:15:49 | 2018-02-07T14:15:49 | 117,349,252 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,713 | java | package BonusExercises;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
public class Dyno {
private static int indexOf(int[] arr, int elem) {
int lo = 0, hi = arr.length - 1;
while(lo <= hi) {
int mid = lo + (hi - lo) / 2;
if(arr[mid] > elem) {
hi = mid - 1;
}
else if(arr[mid] < elem) {
lo = mid + 1;
}
else {
return mid;
}
}
return -1;
}
private static boolean has(int[] arr, int elem) {
return indexOf(arr, elem) != - 1;
}
public static int solve(final int L, final int D, final int C, final int[] cacti) {
int[] DP = new int[L];
for(int i = 1; i < L; i++) {
if((DP[i - 1] == i - 1 || (i >= D && DP[i - D] == i - D)) && !has(cacti, i)) {
DP[i] = i;
}
else {
DP[i] = DP[i - 1];
}
}
return DP[L - 1];
}
public static void read_and_solve(InputStream in, PrintStream out) {
Scanner scanner = new Scanner(in);
int ntestcases = scanner.nextInt();
for(int testno=0; testno<ntestcases; testno++)
{
int L = scanner.nextInt();
int D = scanner.nextInt();
int C = scanner.nextInt();
int[] cacti = new int[C];
for(int j=0; j<C; j++)
cacti[j] = scanner.nextInt();
out.println(solve(L, D, C, cacti));
}
scanner.close();
}
public static void main(String[] args) {
read_and_solve(System.in, System.out);
}
}
| [
"[email protected]"
] | |
c9d9b04d40febc7722984f73208d7ae485068f7c | 17ae052bcfb108575d1719e7833dd3b12f19c3e5 | /src/main/java/com/practica/aeropuerto/Vehiculo.java | 66026d944d697c8160463d2cb74928a37b347b6a | [] | no_license | jnaranjoDev/practicas | e55755a235aecb689a965e286defc2a8b96853ae | 7d006afc8656ddc08892a63553dd0637c18ec56c | refs/heads/master | 2023-07-18T08:58:37.680530 | 2021-08-31T07:39:22 | 2021-08-31T07:39:22 | 399,464,016 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,609 | java | package com.practica.aeropuerto;
import java.io.Serializable;
/**
* Clase que modela los datos de un vehiculo
* La carga maxima permitida se asigna en kg
*
* @author begonaolea
* @version 1.0.0
*/
public class Vehiculo implements Serializable {
private static final long serialVersionUID = 1L;
//variables de clase - 1 para toda la aplicacion
public static final double CARGA_MAXIMA_DEFECTO = 1000.0;
// atributos - variables de instancia (objeto)
private String matricula;
private double cargaMaxima;
private double cargaActual;
private int numCajas;
//constructores
public Vehiculo(double cargaMaxima, String matricula) {
super();
this.cargaMaxima = cargaMaxima;
this.matricula = matricula;
this.cargaActual = 0;
this.numCajas = 0;
}
//mรฉtodos getters y setters
public double getCargaMaxima() {
return cargaMaxima;
}
public void setCargaMaxima(double cargaMaxima) {
this.cargaMaxima = cargaMaxima;
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public double getCargaActual() {
return cargaActual;
}
public void setCargaActual(double cargaActual) {
this.cargaActual = cargaActual;
}
public int getNumCajas() {
return numCajas;
}
@Override
public String toString() {
return "Vehiculo [matricula=" + matricula + ", cargaMaxima=" + cargaMaxima + ", cargaActual=" + cargaActual
+ ", numCajas=" + numCajas + "]";
}
public void calcularFuel() {
System.out.println("Calculando el fuel...");
System.out.println();
}
}
| [
"[email protected]"
] | |
bd8b34521d734ec2d080a1dc45fe51423ff9d8cd | 52aa959298224025a56c90617329067167e927a8 | /app/src/main/java/cn/bmob/imdemo/db/dao/NewFriendDao.java | 2077070b41ed2a322bd5ab19833dae200e64a343 | [] | no_license | Loading1997/NewIM | f36fb3ed3ade43dc8510c1b88c56084755ed5c70 | 842197298c0d5525f2d3e7ba07f44deac2da4d95 | refs/heads/master | 2022-12-10T22:55:49.826619 | 2020-08-10T23:56:22 | 2020-08-10T23:56:22 | 286,602,593 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,593 | java | package cn.bmob.imdemo.db.dao;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteStatement;
import cn.bmob.imdemo.db.NewFriend;
import de.greenrobot.dao.AbstractDao;
import de.greenrobot.dao.Property;
import de.greenrobot.dao.internal.DaoConfig;
// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/**
* DAO for table "newfriend".
*/
public class NewFriendDao extends AbstractDao<NewFriend, Long> {
public static final String TABLENAME = "newfriend";
/**
* Properties of entity NewFriend.<br/>
* Can be used for QueryBuilder and for referencing column names.
*/
public static class Properties {
public final static Property Id = new Property(0, Long.class, "id", true, "_id");
public final static Property Uid = new Property(1, String.class, "uid", false, "UID");
public final static Property Msg = new Property(2, String.class, "msg", false, "MSG");
public final static Property Name = new Property(3, String.class, "name", false, "NAME");
public final static Property Avatar = new Property(4, String.class, "avatar", false, "AVATAR");
public final static Property Status = new Property(5, Integer.class, "status", false, "STATUS");
public final static Property Time = new Property(6, Long.class, "time", false, "TIME");
};
public NewFriendDao(DaoConfig config) {
super(config);
}
public NewFriendDao(DaoConfig config, DaoSession daoSession) {
super(config, daoSession);
}
/** Creates the underlying database table. */
public static void createTable(SQLiteDatabase db, boolean ifNotExists) {
String constraint = ifNotExists? "IF NOT EXISTS ": "";
db.execSQL("CREATE TABLE " + constraint + "\"newfriend\" (" + //
"\"_id\" INTEGER PRIMARY KEY AUTOINCREMENT ," + // 0: id
"\"UID\" TEXT," + // 1: uid
"\"MSG\" TEXT," + // 2: msg
"\"NAME\" TEXT," + // 3: name
"\"AVATAR\" TEXT," + // 4: avatar
"\"STATUS\" INTEGER," + // 5: status
"\"TIME\" INTEGER);"); // 6: time
}
/** Drops the underlying database table. */
public static void dropTable(SQLiteDatabase db, boolean ifExists) {
String sql = "DROP TABLE " + (ifExists ? "IF EXISTS " : "") + "\"newfriend\"";
db.execSQL(sql);
}
/** @inheritdoc */
@Override
protected void bindValues(SQLiteStatement stmt, NewFriend entity) {
stmt.clearBindings();
Long id = entity.getId();
if (id != null) {
stmt.bindLong(1, id);
}
String uid = entity.getUid();
if (uid != null) {
stmt.bindString(2, uid);
}
String msg = entity.getMsg();
if (msg != null) {
stmt.bindString(3, msg);
}
String name = entity.getName();
if (name != null) {
stmt.bindString(4, name);
}
String avatar = entity.getAvatar();
if (avatar != null) {
stmt.bindString(5, avatar);
}
Integer status = entity.getStatus();
if (status != null) {
stmt.bindLong(6, status);
}
Long time = entity.getTime();
if (time != null) {
stmt.bindLong(7, time);
}
}
/** @inheritdoc */
@Override
public Long readKey(Cursor cursor, int offset) {
return cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0);
}
/** @inheritdoc */
@Override
public NewFriend readEntity(Cursor cursor, int offset) {
NewFriend entity = new NewFriend( //
cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0), // id
cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1), // uid
cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2), // msg
cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3), // name
cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4), // avatar
cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5), // status
cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6) // time
);
return entity;
}
/** @inheritdoc */
@Override
public void readEntity(Cursor cursor, NewFriend entity, int offset) {
entity.setId(cursor.isNull(offset + 0) ? null : cursor.getLong(offset + 0));
entity.setUid(cursor.isNull(offset + 1) ? null : cursor.getString(offset + 1));
entity.setMsg(cursor.isNull(offset + 2) ? null : cursor.getString(offset + 2));
entity.setName(cursor.isNull(offset + 3) ? null : cursor.getString(offset + 3));
entity.setAvatar(cursor.isNull(offset + 4) ? null : cursor.getString(offset + 4));
entity.setStatus(cursor.isNull(offset + 5) ? null : cursor.getInt(offset + 5));
entity.setTime(cursor.isNull(offset + 6) ? null : cursor.getLong(offset + 6));
}
/** @inheritdoc */
@Override
protected Long updateKeyAfterInsert(NewFriend entity, long rowId) {
entity.setId(rowId);
return rowId;
}
/** @inheritdoc */
@Override
public Long getKey(NewFriend entity) {
if(entity != null) {
return entity.getId();
} else {
return null;
}
}
/** @inheritdoc */
@Override
protected boolean isEntityUpdateable() {
return true;
}
}
| [
"[email protected]"
] | |
dcb350409b9139ec811ae0b61a2b946ca498bf66 | fa91450deb625cda070e82d5c31770be5ca1dec6 | /Diff-Raw-Data/26/26_35149db31bcd4364b647ec61fecf26eb082c6da6/Cursor/26_35149db31bcd4364b647ec61fecf26eb082c6da6_Cursor_t.java | d7fbdff4200f3c966048c5e4a5554eb0ed971a13 | [] | 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 | 12,598 | java | /**
* Copyright (c) 2009-2013, Lukas Eder, [email protected]
* All rights reserved.
*
* This software is licensed to you under the Apache License, Version 2.0
* (the "License"); You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* . Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* . Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* . Neither the name "jOOQ" nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package org.jooq;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Iterator;
import java.util.List;
import org.jooq.conf.Settings;
import org.jooq.exception.DataAccessException;
import org.jooq.exception.MappingException;
/**
* Cursors allow for lazy, sequential access to an underlying JDBC
* {@link ResultSet}. Unlike {@link Result}, data can only be accessed
* sequentially, using an {@link Iterator}, or the cursor's {@link #hasNext()}
* and {@link #fetch()} methods.
* <p>
* Client code must close this {@link Cursor} in order to close the underlying
* {@link PreparedStatement} and {@link ResultSet}
* <p>
* Note: Unlike usual implementations of {@link Iterable}, a <code>Cursor</code>
* can only provide one {@link Iterator}!
*
* @param <R> The cursor's record type
* @author Lukas Eder
*/
public interface Cursor<R extends Record> extends Iterable<R> {
/**
* Get this cursor's fields as a {@link Row}.
*/
Row fieldsRow();
/**
* Get a specific field from this Cursor.
*
* @see Row#field(Field)
*/
<T> Field<T> field(Field<T> field);
/**
* Get a specific field from this Cursor.
*
* @see Row#field(String)
*/
Field<?> field(String name);
/**
* Get a specific field from this Cursor.
*
* @see Row#field(int)
*/
Field<?> field(int index);
/**
* Get all fields from this Cursor.
*
* @see Row#fields()
*/
Field<?>[] fields();
/**
* Check whether this cursor has a next record.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
*
* @throws DataAccessException if something went wrong executing the query
*/
boolean hasNext() throws DataAccessException;
/**
* Fetch all remaining records as a result.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
* <p>
* The result and its contained records are attached to the original
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
* to override this behaviour.
*
* @throws DataAccessException if something went wrong executing the query
*/
Result<R> fetch() throws DataAccessException;
/**
* Fetch the next couple of records from the cursor.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
* <p>
* The result and its contained records are attached to the original
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
* to override this behaviour.
*
* @param number The number of records to fetch. If this is <code>0</code>
* or negative an empty list is returned, the cursor is
* untouched. If this is greater than the number of remaining
* records, then all remaining records are returned.
* @throws DataAccessException if something went wrong executing the query
*/
Result<R> fetch(int number) throws DataAccessException;
/**
* Fetch the next record from the cursor.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
* <p>
* The resulting record is attached to the original {@link Configuration} by
* default. Use {@link Settings#isAttachRecords()} to override this
* behaviour.
*
* @return The next record from the cursor, or <code>null</code> if there is
* no next record.
* @throws DataAccessException if something went wrong executing the query
*/
R fetchOne() throws DataAccessException;
/**
* Fetch the next record into a custom handler callback.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
* <p>
* The resulting record is attached to the original {@link Configuration} by
* default. Use {@link Settings#isAttachRecords()} to override this
* behaviour.
*
* @param handler The handler callback
* @return Convenience result, returning the parameter handler itself
* @throws DataAccessException if something went wrong executing the query
*/
<H extends RecordHandler<? super R>> H fetchOneInto(H handler) throws DataAccessException;
/**
* Fetch results into a custom handler callback.
* <p>
* The resulting records are attached to the original {@link Configuration}
* by default. Use {@link Settings#isAttachRecords()} to override this
* behaviour.
*
* @param handler The handler callback
* @return Convenience result, returning the parameter handler itself
* @throws DataAccessException if something went wrong executing the query
*/
<H extends RecordHandler<? super R>> H fetchInto(H handler) throws DataAccessException;
/**
* Fetch the next record into a custom mapper callback.
* <p>
* This will conveniently close the <code>Cursor</code>, after the last
* <code>Record</code> was fetched.
*
* @param mapper The mapper callback
* @return The custom mapped record
* @throws DataAccessException if something went wrong executing the query
*/
<E> E fetchOne(RecordMapper<? super R, E> mapper) throws DataAccessException;
/**
* Fetch results into a custom mapper callback.
*
* @param mapper The mapper callback
* @return The custom mapped records
* @throws DataAccessException if something went wrong executing the query
*/
<E> List<E> fetch(RecordMapper<? super R, E> mapper) throws DataAccessException;
/**
* Map the next resulting record onto a custom type.
* <p>
* This is the same as calling <code>fetchOne().into(type)</code>. See
* {@link Record#into(Class)} for more details
*
* @param <E> The generic entity type.
* @param type The entity type.
* @see Record#into(Class)
* @see Result#into(Class)
* @throws DataAccessException if something went wrong executing the query
* @throws MappingException wrapping any reflection or data type conversion
* exception that might have occurred while mapping records
*/
<E> E fetchOneInto(Class<? extends E> type) throws DataAccessException, MappingException;
/**
* Map resulting records onto a custom type.
* <p>
* This is the same as calling <code>fetch().into(type)</code>. See
* {@link Record#into(Class)} for more details
*
* @param <E> The generic entity type.
* @param type The entity type.
* @see Record#into(Class)
* @see Result#into(Class)
* @throws DataAccessException if something went wrong executing the query
* @throws MappingException wrapping any reflection or data type conversion
* exception that might have occurred while mapping records
*/
<E> List<E> fetchInto(Class<? extends E> type) throws DataAccessException, MappingException;
/**
* Map the next resulting record onto a custom record.
* <p>
* This is the same as calling <code>fetchOne().into(table)</code>. See
* {@link Record#into(Class)} for more details
* <p>
* The resulting record is attached to the original {@link Configuration} by
* default. Use {@link Settings#isAttachRecords()} to override this
* behaviour.
*
* @param <Z> The generic table record type.
* @param table The table type.
* @see Record#into(Class)
* @see Result#into(Class)
* @throws DataAccessException if something went wrong executing the query
* @throws MappingException wrapping any reflection or data type conversion
* exception that might have occurred while mapping records
*/
<Z extends Record> Z fetchOneInto(Table<Z> table) throws DataAccessException, MappingException;
/**
* Map resulting records onto a custom record.
* <p>
* This is the same as calling <code>fetch().into(table)</code>. See
* {@link Record#into(Class)} for more details
* <p>
* The result and its contained records are attached to the original
* {@link Configuration} by default. Use {@link Settings#isAttachRecords()}
* to override this behaviour.
*
* @param <Z> The generic table record type.
* @param table The table type.
* @see Record#into(Class)
* @see Result#into(Class)
* @throws DataAccessException if something went wrong executing the query
* @throws MappingException wrapping any reflection or data type conversion
* exception that might have occurred while mapping records
*/
<Z extends Record> Result<Z> fetchInto(Table<Z> table) throws DataAccessException, MappingException;
/**
* Explicitly close the underlying {@link PreparedStatement} and
* {@link ResultSet}.
* <p>
* If you fetch all records from the underlying {@link ResultSet}, jOOQ
* <code>Cursor</code> implementations will close themselves for you.
* Calling <code>close()</code> again will have no effect.
*
* @throws DataAccessException if something went wrong executing the query
*/
void close() throws DataAccessException;
/**
* Check whether this <code>Cursor</code> has been explicitly or
* "conveniently" closed.
* <p>
* Explicit closing can be achieved by calling {@link #close()} from client
* code. "Convenient" closing is done by any of the other methods, when the
* last record was fetched.
*/
boolean isClosed();
/**
* Get the <code>Cursor</code>'s underlying {@link ResultSet}.
* <p>
* If you modify the underlying <code>ResultSet</code>, the
* <code>Cursor</code> may be affected and in some cases, rendered unusable.
*
* @return The underlying <code>ResultSet</code>. May be <code>null</code>,
* for instance when the <code>Cursor</code> is closed.
*/
ResultSet resultSet();
}
| [
"[email protected]"
] | |
17e55d6e33e0a63b889adb30a497a547625a303d | 90552f7cfac2eaed7a830a471bb28164e4ac2e73 | /่ๆกฅๆฏ/ไน็งฏๆๅคง.java | 3d416b0d34b209523742cb48629654895d814ca9 | [] | no_license | TNT-df/java | 7b20f8f0d684a87c49ac8608bb62e0d9baf97a97 | 065eb36c55c0e0a0d067c38afb8545fb8b1aaf12 | refs/heads/master | 2023-04-09T21:38:31.920761 | 2021-04-24T13:40:17 | 2021-04-24T13:40:17 | 290,117,379 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,573 | java | ็ปๅฎ N ไธชๆดๆฐ A1,A2,โฆANใ
่ฏทไฝ ไปไธญ้ๅบ K ไธชๆฐ๏ผไฝฟๅ
ถไน็งฏๆๅคงใ
่ฏทไฝ ๆฑๅบๆๅคง็ไน็งฏ๏ผ็ฑไบไน็งฏๅฏ่ฝ่ถ
ๅบๆดๅ่ๅด๏ผไฝ ๅช้่พๅบไน็งฏ้คไปฅ 1000000009 ็ไฝๆฐใ
ๆณจๆ๏ผๅฆๆ X<0๏ผ ๆไปฌๅฎไน X ้คไปฅ 1000000009 ็ไฝๆฐๆฏ่ด(โX)้คไปฅ 1000000009 ็ไฝๆฐ๏ผๅณ๏ผ0โ((0โx)%1000000009)
่พๅ
ฅๆ ผๅผ
็ฌฌไธ่กๅ
ๅซไธคไธชๆดๆฐ N ๅ Kใ
ไปฅไธ N ่กๆฏ่กไธไธชๆดๆฐ Aiใ
่พๅบๆ ผๅผ
่พๅบไธไธชๆดๆฐ๏ผ่กจ็คบ็ญๆกใ
ๆฐๆฎ่ๅด
1โคKโคNโค105,
โ105โคAiโค105
่พๅ
ฅๆ ทไพ1๏ผ
5 3
-100000
-10000
2
100000
10000
่พๅบๆ ทไพ1๏ผ
999100009
่พๅ
ฅๆ ทไพ2๏ผ
5 3
-100000
-100000
-2
-100000
-100000
่พๅบๆ ทไพ2๏ผ
-999999829
/*
1. ๅ
ๅฐๆฐ็ป่ฟ่กๆๅบใ
2.ๅคๆญๆฐ็ปไธญๆฏๅฆไธบๅ
จ่ดๆฐใ
2.1 ่ฅkไธบๅฅๆฐ๏ผๅ็ปๆไธบ่ดๆฐ๏ผๅบไปๅๅๅๅๆๅคง
2.2 ่ฅkไธบๅถๆฐ๏ผๅ็ปๆไธบๅถๆฐ๏ผๅบไปๅๅๅๅๆๅคง
3.่ฅๆขๆ่ดๆฐไนๆๆญฃๆฐ
3.1 ่ฅkไธบๅฅๆฐ๏ผๅ resๅ
ๅญๅจๆๅคงๅผ๏ผๆ็
ง ๅถๆฐๅค็
3.2 ่ฅkไธบๅถๆฐ๏ผๅๅๅซๆฏ่พไธค็ซฏ,่ฎฒๅคง็็ปๆๆพๅ
ฅไนres๏ผk-2๏ผ็ดๅฐkไธบ0๏ผ
*/
import java.util.*;
public class Main{
static final long mod = 1000000009;
public static void main(String[] args){
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
long f[] = new long[n];
for(int i = 0;i < n;i++)
f[i] = in.nextLong();
Arrays.sort(f);
long res = 1;
boolean flag = false;
if(f[n - 1] < 0)
flag = false;
else flag = true;
if(!flag){
if((k & 1) == 1){
for(int i = n-1,j = 0;j < k;i--,j++){
res = (res * f[i]) %mod;
}
}else{
for(int i = 0;i<k;i++){
res = (res *f[i]) %mod;
}
}
}else{
int l = 0, r = n -1;
if((k & 1) == 1){
res = f[r--];
k--;
}
while(k > 0){
long temp = f[l] * f[l + 1];
long temp1 = f[r] * f[r - 1];
if(temp > temp1){
res = (res * (temp % mod)) % mod;
l +=2;
}else{
res = (res * (temp1% mod)) %mod;
r -=2;
}
k -= 2;
}
}
System.out.println(res);
}
} | [
"[email protected]"
] | |
5cdac81c7358625447cb1606d8ff0d35b2102113 | a8b883ecf94bf64f48fa62e3e2dff786a0fda695 | /src/main/java/hello/Application.java | 64bf196c0a6c23fef3b956c825aa196e7d625cda | [] | no_license | NetCoder99/SpringGreeting | ba26f0ba28d16c008033f9b337f039028f302de3 | a101b47edcbdf35cce4b15ee9515513ea13ca9c6 | refs/heads/master | 2020-12-07T12:00:07.785215 | 2020-01-09T03:47:11 | 2020-01-09T03:47:11 | 232,716,873 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 615 | java | package hello;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication
public class Application extends SpringBootServletInitializer{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(Application.class);
}
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
| [
"[email protected]"
] | |
0693812afa5abcfbea89468807f9743d2e97241d | f77b350dba464b591dc1c193d9378ba912e1d986 | /app/src/main/java/com/groobak/customer/utils/SettingPreference.java | 1da79c59df0dd507a513b39e3eee0241c53a1ba0 | [] | no_license | insoft-developers/groobak_customer | 61b2f9d0440172a1bf9820006f5a450d1a7f19ea | 199f833bbab016b82f9e9f30e2c62c939b083102 | refs/heads/master | 2023-06-17T20:13:16.904662 | 2021-07-16T13:30:21 | 2021-07-16T13:30:21 | 362,054,964 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,372 | java | package com.groobak.customer.utils;
import android.content.Context;
import android.content.SharedPreferences;
import com.groobak.customer.constants.Constants;
import com.groobak.customer.json.MobilePulsaHealthBPJSResponseModel;
import com.groobak.customer.models.TopUpPlnHistoryModel;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
public class SettingPreference {
private static String CURRENCY = "Rp";
private static String ABOUTUS = "ABOUTUS";
private static String EMAIL = "EMAIL";
private static String PHONE = "PHONE";
private static String WEBSITE = "WEBSITE";
private static String MPSTATUS = "MPSTATUS";
private static String MPACTIVE = "MPACTIVE";
private static String MOBILEPULSAUSERNAME = "MOBILEPULSAUSERNAME";
private static String MOBILEPULSAAPIKEY = "MOBILEPULSAAPIKEY";
private static String CURRENCYTEXT = "CURRENCYTEXT";
private static String PLN_LIST_PAID_SUCCESS ="SUCCESSPAIDLIST";
private static String BPJS_LIST_PAID_SUCCESS = "SUCCESSBPJS";
private static String HARGAPULSA = "HARGAPULSA";
private SharedPreferences pref;
private SharedPreferences.Editor editor;
public SettingPreference(Context context) {
pref = context.getSharedPreferences(Constants.PREF_NAME, Context.MODE_PRIVATE);
}
public void updateCurrency(String string) {
editor = pref.edit();
editor.putString(CURRENCY, string);
editor.commit();
}
public void updateabout(String string) {
editor = pref.edit();
editor.putString(ABOUTUS, string);
editor.commit();
}
public void updateemail(String string) {
editor = pref.edit();
editor.putString(EMAIL, string);
editor.commit();
}
public void updatephone(String string) {
editor = pref.edit();
editor.putString(PHONE, string);
editor.commit();
}
public void updateweb(String string) {
editor = pref.edit();
editor.putString(WEBSITE, string);
editor.commit();
}
public void updatempstatus(String string) {
editor = pref.edit();
editor.putString(MPSTATUS, string);
editor.commit();
}
public void updatempactive(String string) {
editor = pref.edit();
editor.putString(MPACTIVE, string);
editor.commit();
}
public void updateMobilepulsausername(String string) {
editor = pref.edit();
editor.putString(MOBILEPULSAUSERNAME, string);
editor.apply();
}
public void updateMobilepulsaapikey(String string) {
editor = pref.edit();
editor.putString(MOBILEPULSAAPIKEY, string);
editor.apply();
}
public void updatecurrencytext(String string) {
editor = pref.edit();
editor.putString(CURRENCYTEXT, string);
editor.commit();
}
public void updatehargapulsa(String value) {
editor = pref.edit();
editor.putString(HARGAPULSA, value);
editor.apply();
}
public void updatePlnList(TopUpPlnHistoryModel model) {
editor = pref.edit();
List<TopUpPlnHistoryModel> listModel = new ArrayList<>();
String previousStringModel = pref.getString(PLN_LIST_PAID_SUCCESS,"");
if (previousStringModel != null && !previousStringModel.isEmpty()) {
Type listOfMyClassObject = new TypeToken<ArrayList<TopUpPlnHistoryModel>>() {}.getType();
listModel.addAll(new Gson().fromJson(previousStringModel, listOfMyClassObject));
}
listModel.add(0,model);
editor.putString(PLN_LIST_PAID_SUCCESS, new Gson().toJson(listModel));
editor.apply();
}
public void updateBPJSList(MobilePulsaHealthBPJSResponseModel model) {
editor = pref.edit();
List<MobilePulsaHealthBPJSResponseModel> listModel = new ArrayList<>();
String previousStringModel = pref.getString(BPJS_LIST_PAID_SUCCESS,"");
if (!previousStringModel.isEmpty()) {
Type listOfMyClassObject = new TypeToken<ArrayList<MobilePulsaHealthBPJSResponseModel>>() {}.getType();
listModel.addAll(new Gson().fromJson(previousStringModel, listOfMyClassObject));
}
listModel.add(0,model);
String s = new Gson().toJson(listModel);
editor.putString(BPJS_LIST_PAID_SUCCESS, new Gson().toJson(listModel));
editor.apply();
}
public String[] getSetting() {
String[] settingan = new String[15];
settingan[0] = pref.getString(CURRENCY, "$");
settingan[1] = pref.getString(ABOUTUS, "");
settingan[2] = pref.getString(EMAIL, "");
settingan[3] = pref.getString(PHONE, "");
settingan[4] = pref.getString(WEBSITE, "");
settingan[5] = pref.getString(MPSTATUS, "1");
settingan[6] = pref.getString(MPACTIVE, "0");
settingan[7] = pref.getString(MOBILEPULSAUSERNAME, "123");
settingan[8] = pref.getString(MOBILEPULSAAPIKEY, "123");
settingan[9] = pref.getString(CURRENCYTEXT, "USD");
settingan[10] = pref.getString(PLN_LIST_PAID_SUCCESS, "");
settingan[11] = pref.getString(BPJS_LIST_PAID_SUCCESS, "");
settingan[12] = pref.getString(HARGAPULSA, "");
return settingan;
}
} | [
"[email protected]"
] | |
c4c157b8b9759f9bacb02f15bb568e2b91b61b32 | 166b8320b94dcf5932062b8ac4f90dc353767d39 | /cdi/extension/src/main/java/org/infinispan/cdi/util/annotatedtypebuilder/AnnotatedMethodImpl.java | 91063e6d441a7ef45b0134ebad3ea23085c1ea7e | [
"Apache-2.0"
] | permissive | Cotton-Ben/infinispan | 87e0caeeba2616dd7eb5a96b896b462ed9de5d67 | 2ba2d9992cd0018829d9ba0b0d4ba74bab49616b | refs/heads/master | 2020-12-31T02:22:26.654774 | 2014-07-11T16:48:15 | 2014-07-11T16:48:15 | 16,557,570 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 781 | java | package org.infinispan.cdi.util.annotatedtypebuilder;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
import java.util.Map;
import javax.enterprise.inject.spi.AnnotatedMethod;
import javax.enterprise.inject.spi.AnnotatedType;
/**
* @author Stuart Douglas
*/
class AnnotatedMethodImpl<X> extends AnnotatedCallableImpl<X, Method> implements AnnotatedMethod<X> {
AnnotatedMethodImpl(AnnotatedType<X> type, Method method, AnnotationStore annotations, Map<Integer, AnnotationStore> parameterAnnotations, Map<Integer, Type> parameterTypeOverrides) {
super(type, method, method.getReturnType(), method.getParameterTypes(), method.getGenericParameterTypes(), annotations, parameterAnnotations, method.getGenericReturnType(), parameterTypeOverrides);
}
}
| [
"[email protected]"
] | |
f8e71b9c8cd68988bdba61d731ab09e228146dea | 3d4349c88a96505992277c56311e73243130c290 | /Preparation/processed-dataset/god-class_3_1112/6.java | 2b794bedcb22a723f2e54f853be5a27be09993e9 | [] | no_license | D-a-r-e-k/Code-Smells-Detection | 5270233badf3fb8c2d6034ac4d780e9ce7a8276e | 079a02e5037d909114613aedceba1d5dea81c65d | refs/heads/master | 2020-05-20T00:03:08.191102 | 2019-05-15T11:51:51 | 2019-05-15T11:51:51 | 185,272,690 | 7 | 4 | null | null | null | null | UTF-8 | Java | false | false | 400 | java | private static int zzUnpackTrans(String packed, int offset, int[] result) {
int i = 0;
/* index in packed string */
int j = offset;
/* index in unpacked array */
int l = packed.length();
while (i < l) {
int count = packed.charAt(i++);
int value = packed.charAt(i++);
value--;
do result[j++] = value; while (--count > 0);
}
return j;
}
| [
"[email protected]"
] | |
f68b3a95464859c9188ff4d1b9ee7701cb7d346b | b9eab531ebbd77ebe785c7cd015cd06197274126 | /app/src/main/java/com/example/pomodoro/Task/Information.java | f7b6f88d7ecb5d41bb2ef758a4c2081050b1f775 | [] | no_license | HoangLong-212/PomodoroApp | d9328c053fcd9b685f8143c4b774f7aaf1e36b02 | 347d02c93a9623c8ed1620bf3836f4915013372c | refs/heads/master | 2023-06-17T23:35:40.683608 | 2021-05-15T05:39:47 | 2021-05-15T05:39:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 524 | java | package com.example.pomodoro.Task;
public class Information {
private String id;
private String subject;
// private int IconImage;
public Information(String id, String subject) {
this.id = id;
this.subject = subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public void setId(String id) {
this.id = id;
}
public String getSubject() {
return subject;
}
public String getId() {
return id;
}
}
| [
"[email protected]"
] | |
bff08432277985d382701cc92c1cf07aae2efed2 | f147d865c669debbcfc2bb3289040939ecb9ba20 | /MiddleWare/src/main/java/com/foxleezh/middleware/mvvm/BaseModel.java | 75ddb955bc646ad7ebfcf0d0683b4b34b15fa340 | [] | no_license | foxleezh/BlogApp | 9e8215e18a68f0bec75339c407dc5af85534f5a1 | 949de1f08bc655e72344c7414349f053ea336ae0 | refs/heads/master | 2021-07-05T06:22:20.611663 | 2017-09-24T16:08:41 | 2017-09-24T16:08:41 | 103,729,813 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 476 | java | package com.foxleezh.middleware.mvvm;
import android.os.Parcel;
import android.os.Parcelable;
/**
* Created by foxleezh on 2017/9/24.
* ๆฌ็ฑปไป็ป ๅบ็ฑปModel๏ผไฝไธบMVVMไธญM็็ถ็ฑป
*/
public class BaseModel implements Parcelable {
protected BaseModel(Parcel in) {
}
protected BaseModel() {
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel parcel, int i) {
}
}
| [
"[email protected]"
] | |
c8833df74c36b707d6515b4719fce5c889cc5a2d | 219a4c259c8fdafa25ddb93d872525c47f7206cd | /app/src/main/java/com/example/dependencyinjection/AnimalManager.java | 5d0771bb6bfbea117038c378111d22467db6d478 | [] | no_license | biplane1989/DependencyInjection | aaf13551b04c14962189aa6ae7036e7a75d385b7 | ef85efbf3062fe1d93466efc28d5e3e78415ae25 | refs/heads/master | 2022-07-14T22:51:33.152357 | 2020-05-12T15:53:36 | 2020-05-12T15:53:36 | 263,382,732 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 301 | java | package com.example.dependencyinjection;
import android.util.Log;
public class AnimalManager implements Manager {
Animal animal;
public AnimalManager(Animal animal) {
this.animal = animal;
}
@Override
public String AnimalSong() {
return animal.song();
}
}
| [
"[email protected]"
] | |
bd22ff10dac2838c32d89438673ad169da6a6ee8 | dfc0ef8c3017ebfe80fe8ee657b4f593330d3ef6 | /Reversed/framework/com/samsung/android/hardware/context/SemContextAutoBrightness.java | ccaf026ca9c9973f2e052fd2174683379ce07580 | [] | no_license | khomsn/SCoverRE | fe079b6006281112ee37b66c5d156bb959e15420 | 2374565740e4c7bfc653b3f05bd9be519e722e32 | refs/heads/master | 2020-04-13T15:36:19.925426 | 2017-06-01T07:31:37 | 2017-06-01T07:31:37 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,540 | java | package com.samsung.android.hardware.context;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcelable.Creator;
public class SemContextAutoBrightness extends SemContextEventContext {
public static final int CONFIG_DATA_DOWNLOADED = 1000;
public static final Creator<SemContextAutoBrightness> CREATOR = new C01441();
public static final int EBOOK_MODE = 1;
public static final int NORMAL_MODE = 0;
public static final int UPDATE_MODE = 2;
private Bundle mContext;
static class C01441 implements Creator<SemContextAutoBrightness> {
C01441() {
}
public SemContextAutoBrightness createFromParcel(Parcel parcel) {
return new SemContextAutoBrightness(parcel);
}
public SemContextAutoBrightness[] newArray(int i) {
return new SemContextAutoBrightness[i];
}
}
SemContextAutoBrightness() {
this.mContext = new Bundle();
}
SemContextAutoBrightness(Parcel parcel) {
readFromParcel(parcel);
}
private void readFromParcel(Parcel parcel) {
this.mContext = parcel.readBundle(getClass().getClassLoader());
}
public int getAmbientLux() {
return this.mContext.getInt("AmbientLux");
}
public int getCandela() {
return this.mContext.getInt("Candela");
}
public void setValues(Bundle bundle) {
this.mContext = bundle;
}
public void writeToParcel(Parcel parcel, int i) {
parcel.writeBundle(this.mContext);
}
}
| [
"[email protected]"
] | |
08fbb4db847344a850bb92b95beab60e922996e3 | 445615a3d5778cea29d8b049a8f65dc8854de89f | /DiceGame.java | 9c9c401492d3ef97fcfa15969dcad4552074b6df | [] | no_license | kairstenfay/yahtzee | a4331d7b0f08eb6f1356c862eb32b7dfcc998be1 | 0ff5419902448fb5cc4da2d4e3e579d382cfcdf1 | refs/heads/master | 2020-03-25T22:14:42.627215 | 2018-08-09T23:13:58 | 2018-08-09T23:13:58 | 144,212,248 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,052 | java | import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
// Allows the client to play a game with five 8-sided dice. Provides methods
// for:
// - scoring a given dice roll using a given scoring category (score())
// - suggesting scoring categories that provide the highest scores given a
// dice roll (suggestedCategories())
//
// Note that the indices of the static arrays are important because they are
// used in the construction of the scoring category objects. The categories
// stored in the arrays all have distinct patterns in their scoring logic.
// The major types of patterns are "SumOfX", "XOfAKind", and "Sraight".
// The other three categories are treated as special cases and are considered
// "miscellaneous".
public class DiceGame {
private static final String[] SUM_OF_X = new String[]{"Ones", "Twos", "Threes", "Fours",
"Fives", "Sixes", "Sevens", "Eights"};
private static final String[] X_OF_A_KIND = new String[]{"ThreeOfAKind", "FourOfAKind",
"AllOfAKind"};
private static final String[] STRAIGHT = new String[]{"SmallStraight", "LargeStraight"};
private static final String CHANCE = "Chance";
private static final String FULL_HOUSE = "FullHouse";
private static final String NONE_OF_A_KIND = "NoneOfAKind";
private Map<String, Category> categories; // stores the category and its related object
// Stores the names of the various scoring categories along with their
// object instantiations for future access.
public DiceGame() {
List<String> scoringCategories = new ArrayList<String>();
scoringCategories.addAll(Arrays.asList(SUM_OF_X));
scoringCategories.addAll(Arrays.asList(STRAIGHT));
scoringCategories.addAll(Arrays.asList(X_OF_A_KIND));
scoringCategories.add(CHANCE);
scoringCategories.add(FULL_HOUSE);
scoringCategories.add(NONE_OF_A_KIND);
categories = new HashMap<String, Category>();
for (String category : scoringCategories) {
categories.put(category, getCategory(category));
}
}
// With the given category, returns a new object of type Category that will
// be used for scoring a dice game. This method is index-aware for the
// scoring patterns (other than the "miscellaneous" categories).
// If the given category does not match a category in the set of allowed
// categories, then the method defaults to "Chance".
private Category getCategory(String category) {
// The "SumOfX" scoring pattern takes an index in the constructor that
// converts to the die face important in calculating a score.
for (int i = 0; i < SUM_OF_X.length; i++) {
if(SUM_OF_X[i].equals(category)) {
return new SumOfX(i + 1);
}
}
// The "XOfAKind" scoring pattern takes an index in the constructor that
// converts to the minimum frequency required of any one die face in
// calculating a score.
for (int i = 0; i < X_OF_A_KIND.length; i++) {
if(X_OF_A_KIND[i].equals(category)) {
return new XOfAKind(i + 3);
}
}
// The "Straight" scoring pattern takes an index in the constructor that
// converts to the minimum number of sequential (consecutive) dice in
// calculating a score.
for (int i = 0; i < STRAIGHT.length; i++) {
if (STRAIGHT[i].equals(category)) {
return new Straight(i + 4);
}
}
// The miscellaneous categories do not take parameters in their
// constructor and have their own, deterministic scoring methods.
if ("FullHouse".equals(category)) {
return new FullHouse();
} else if ("NoneOfAKind".equals(category)) {
return new NoneOfAKind();
} else {
return new Chance();
}
}
// Returns the score of a given dice roll according to the scoring rules and
// conditions relating to the given category.
public int score(String category, int[] roll) {
return categories.get(category).score(roll);
}
// Returns an array of suggested scoring categories that would result in the
// highest score, given a dice roll.
public String[] suggestedCategories(int[] roll) {
int maxScore = 0;
List<String> suggestedCategories = new ArrayList<String>();
for (String category : categories.keySet()) {
int score = categories.get(category).score(roll);
if (score == maxScore) {
suggestedCategories.add(category);
} else if (score > maxScore) { // empty list and start fresh
suggestedCategories.clear();
maxScore = score;
suggestedCategories.add(category);
}
}
return suggestedCategories.toArray(new String[suggestedCategories.size()]);
}
} | [
"[email protected]"
] | |
47c67b0f0dd35ba99e7bebd6ccccf7323f6db922 | 285691cba03e9a452405c01fc9d29ed8e7181ae4 | /src/test/java/com/mycompany/api/ebankingPortal/configuration/CucumberSpringContextConfiguration.java | 8473af65878980247dbde38750aba1221b3fc3d9 | [] | no_license | goeld/ebankingPortal | e8a8bfb9782908d405f01a8c071523a7a4c08044 | 29cd39351fd1795ee67f8fa91223b58438511fe1 | refs/heads/main | 2023-06-07T19:52:10.976002 | 2021-07-01T10:05:18 | 2021-07-01T10:05:18 | 374,670,303 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 440 | java | package com.mycompany.api.ebankingPortal.configuration;
import io.cucumber.spring.CucumberContextConfiguration;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
@CucumberContextConfiguration
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@AutoConfigureMockMvc
public class CucumberSpringContextConfiguration {
} | [
"[email protected]"
] | |
6caf86a3e715dcfa5910eaf304a7a386494669d8 | 503400de066a94a7d755a7668edb877ab03c41f9 | /src/lesson16/networking/WebSiteReader2.java | f1d4f981ba2387ec5a049adc340bbaef642acd4e | [] | no_license | temo1993/YakovFain | 4e45572f45b18ac2c14751aa657bd935cdb6f3df | 3526230338c2288b8a56851a4f6138213e8462f7 | refs/heads/master | 2021-01-10T02:58:10.426734 | 2016-02-23T08:41:26 | 2016-02-23T08:41:26 | 51,118,682 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,245 | java | package lesson16.networking;
import java.net.*;
import java.io.*;
public class WebSiteReader2 {
public static void main(String args[]){
String nextLine;
URL url = null;
URLConnection urlConn = null;
InputStreamReader inStream = null;
BufferedReader buff = null;
try{
// index.html is a default URL's file name
url = new URL("http://finance.yahoo.com/q?s=MOT" );
urlConn = url.openConnection();
inStream = new InputStreamReader(
urlConn.getInputStream());
buff = new BufferedReader(inStream);
// Read the entire trading information about Motorolla
// into a String variable
String theWholePage=null;
String currentLine;
while ((currentLine=buff.readLine()) !=null){
theWholePage+=currentLine;
}
System.out.println(theWholePage);
} catch(MalformedURLException e){
System.out.println("Please check the URL:" +
e.toString() );
} catch(IOException e1){
System.out.println("Can't read from the Internet: "+
e1.toString() );
}
}
}
| [
"[email protected]"
] | |
43ad88811f703813accb8aaad0c9af8046957e8c | 8fccdb027e3268313974a1871738d12f9b4a4f04 | /demo02/src/main/java/com/kgc/zjh/pojo/StandardExample.java | 7d13f3dec4f929a7b6a1fcb474467cb67db12bc9 | [
"Apache-2.0"
] | permissive | GL525/GitHub077-StuSystem | 59422b829361c81d6ebc62f2fb5dc3dbad60b674 | c8f3fc902b690727711fa805f4297f330c26e40e | refs/heads/main | 2022-12-30T12:48:57.723662 | 2020-10-12T13:00:22 | 2020-10-12T13:00:22 | 302,935,031 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 24,509 | java | package com.kgc.zjh.pojo;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
public class StandardExample {
protected String orderByClause;
protected boolean distinct;
protected List<Criteria> oredCriteria;
public StandardExample() {
oredCriteria = new ArrayList<Criteria>();
}
public void setOrderByClause(String orderByClause) {
this.orderByClause = orderByClause;
}
public String getOrderByClause() {
return orderByClause;
}
public void setDistinct(boolean distinct) {
this.distinct = distinct;
}
public boolean isDistinct() {
return distinct;
}
public List<Criteria> getOredCriteria() {
return oredCriteria;
}
public void or(Criteria criteria) {
oredCriteria.add(criteria);
}
public Criteria or() {
Criteria criteria = createCriteriaInternal();
oredCriteria.add(criteria);
return criteria;
}
public Criteria createCriteria() {
Criteria criteria = createCriteriaInternal();
if (oredCriteria.size() == 0) {
oredCriteria.add(criteria);
}
return criteria;
}
protected Criteria createCriteriaInternal() {
Criteria criteria = new Criteria();
return criteria;
}
public void clear() {
oredCriteria.clear();
orderByClause = null;
distinct = false;
}
protected abstract static class GeneratedCriteria {
protected List<Criterion> criteria;
protected GeneratedCriteria() {
super();
criteria = new ArrayList<Criterion>();
}
public boolean isValid() {
return criteria.size() > 0;
}
public List<Criterion> getAllCriteria() {
return criteria;
}
public List<Criterion> getCriteria() {
return criteria;
}
protected void addCriterion(String condition) {
if (condition == null) {
throw new RuntimeException("Value for condition cannot be null");
}
criteria.add(new Criterion(condition));
}
protected void addCriterion(String condition, Object value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value));
}
protected void addCriterion(String condition, Object value1, Object value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
criteria.add(new Criterion(condition, value1, value2));
}
protected void addCriterionForJDBCDate(String condition, Date value, String property) {
if (value == null) {
throw new RuntimeException("Value for " + property + " cannot be null");
}
addCriterion(condition, new java.sql.Date(value.getTime()), property);
}
protected void addCriterionForJDBCDate(String condition, List<Date> values, String property) {
if (values == null || values.size() == 0) {
throw new RuntimeException("Value list for " + property + " cannot be null or empty");
}
List<java.sql.Date> dateList = new ArrayList<java.sql.Date>();
Iterator<Date> iter = values.iterator();
while (iter.hasNext()) {
dateList.add(new java.sql.Date(iter.next().getTime()));
}
addCriterion(condition, dateList, property);
}
protected void addCriterionForJDBCDate(String condition, Date value1, Date value2, String property) {
if (value1 == null || value2 == null) {
throw new RuntimeException("Between values for " + property + " cannot be null");
}
addCriterion(condition, new java.sql.Date(value1.getTime()), new java.sql.Date(value2.getTime()), property);
}
public Criteria andIdIsNull() {
addCriterion("id is null");
return (Criteria) this;
}
public Criteria andIdIsNotNull() {
addCriterion("id is not null");
return (Criteria) this;
}
public Criteria andIdEqualTo(Integer value) {
addCriterion("id =", value, "id");
return (Criteria) this;
}
public Criteria andIdNotEqualTo(Integer value) {
addCriterion("id <>", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThan(Integer value) {
addCriterion("id >", value, "id");
return (Criteria) this;
}
public Criteria andIdGreaterThanOrEqualTo(Integer value) {
addCriterion("id >=", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThan(Integer value) {
addCriterion("id <", value, "id");
return (Criteria) this;
}
public Criteria andIdLessThanOrEqualTo(Integer value) {
addCriterion("id <=", value, "id");
return (Criteria) this;
}
public Criteria andIdIn(List<Integer> values) {
addCriterion("id in", values, "id");
return (Criteria) this;
}
public Criteria andIdNotIn(List<Integer> values) {
addCriterion("id not in", values, "id");
return (Criteria) this;
}
public Criteria andIdBetween(Integer value1, Integer value2) {
addCriterion("id between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andIdNotBetween(Integer value1, Integer value2) {
addCriterion("id not between", value1, value2, "id");
return (Criteria) this;
}
public Criteria andStdNumIsNull() {
addCriterion("std_num is null");
return (Criteria) this;
}
public Criteria andStdNumIsNotNull() {
addCriterion("std_num is not null");
return (Criteria) this;
}
public Criteria andStdNumEqualTo(String value) {
addCriterion("std_num =", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumNotEqualTo(String value) {
addCriterion("std_num <>", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumGreaterThan(String value) {
addCriterion("std_num >", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumGreaterThanOrEqualTo(String value) {
addCriterion("std_num >=", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumLessThan(String value) {
addCriterion("std_num <", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumLessThanOrEqualTo(String value) {
addCriterion("std_num <=", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumLike(String value) {
addCriterion("std_num like", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumNotLike(String value) {
addCriterion("std_num not like", value, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumIn(List<String> values) {
addCriterion("std_num in", values, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumNotIn(List<String> values) {
addCriterion("std_num not in", values, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumBetween(String value1, String value2) {
addCriterion("std_num between", value1, value2, "stdNum");
return (Criteria) this;
}
public Criteria andStdNumNotBetween(String value1, String value2) {
addCriterion("std_num not between", value1, value2, "stdNum");
return (Criteria) this;
}
public Criteria andZhnameIsNull() {
addCriterion("zhname is null");
return (Criteria) this;
}
public Criteria andZhnameIsNotNull() {
addCriterion("zhname is not null");
return (Criteria) this;
}
public Criteria andZhnameEqualTo(String value) {
addCriterion("zhname =", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameNotEqualTo(String value) {
addCriterion("zhname <>", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameGreaterThan(String value) {
addCriterion("zhname >", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameGreaterThanOrEqualTo(String value) {
addCriterion("zhname >=", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameLessThan(String value) {
addCriterion("zhname <", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameLessThanOrEqualTo(String value) {
addCriterion("zhname <=", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameLike(String value) {
addCriterion("zhname like", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameNotLike(String value) {
addCriterion("zhname not like", value, "zhname");
return (Criteria) this;
}
public Criteria andZhnameIn(List<String> values) {
addCriterion("zhname in", values, "zhname");
return (Criteria) this;
}
public Criteria andZhnameNotIn(List<String> values) {
addCriterion("zhname not in", values, "zhname");
return (Criteria) this;
}
public Criteria andZhnameBetween(String value1, String value2) {
addCriterion("zhname between", value1, value2, "zhname");
return (Criteria) this;
}
public Criteria andZhnameNotBetween(String value1, String value2) {
addCriterion("zhname not between", value1, value2, "zhname");
return (Criteria) this;
}
public Criteria andVersionIsNull() {
addCriterion("version is null");
return (Criteria) this;
}
public Criteria andVersionIsNotNull() {
addCriterion("version is not null");
return (Criteria) this;
}
public Criteria andVersionEqualTo(String value) {
addCriterion("version =", value, "version");
return (Criteria) this;
}
public Criteria andVersionNotEqualTo(String value) {
addCriterion("version <>", value, "version");
return (Criteria) this;
}
public Criteria andVersionGreaterThan(String value) {
addCriterion("version >", value, "version");
return (Criteria) this;
}
public Criteria andVersionGreaterThanOrEqualTo(String value) {
addCriterion("version >=", value, "version");
return (Criteria) this;
}
public Criteria andVersionLessThan(String value) {
addCriterion("version <", value, "version");
return (Criteria) this;
}
public Criteria andVersionLessThanOrEqualTo(String value) {
addCriterion("version <=", value, "version");
return (Criteria) this;
}
public Criteria andVersionLike(String value) {
addCriterion("version like", value, "version");
return (Criteria) this;
}
public Criteria andVersionNotLike(String value) {
addCriterion("version not like", value, "version");
return (Criteria) this;
}
public Criteria andVersionIn(List<String> values) {
addCriterion("version in", values, "version");
return (Criteria) this;
}
public Criteria andVersionNotIn(List<String> values) {
addCriterion("version not in", values, "version");
return (Criteria) this;
}
public Criteria andVersionBetween(String value1, String value2) {
addCriterion("version between", value1, value2, "version");
return (Criteria) this;
}
public Criteria andVersionNotBetween(String value1, String value2) {
addCriterion("version not between", value1, value2, "version");
return (Criteria) this;
}
public Criteria andKeyssIsNull() {
addCriterion("keyss is null");
return (Criteria) this;
}
public Criteria andKeyssIsNotNull() {
addCriterion("keyss is not null");
return (Criteria) this;
}
public Criteria andKeyssEqualTo(String value) {
addCriterion("keyss =", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssNotEqualTo(String value) {
addCriterion("keyss <>", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssGreaterThan(String value) {
addCriterion("keyss >", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssGreaterThanOrEqualTo(String value) {
addCriterion("keyss >=", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssLessThan(String value) {
addCriterion("keyss <", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssLessThanOrEqualTo(String value) {
addCriterion("keyss <=", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssLike(String value) {
addCriterion("keyss like", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssNotLike(String value) {
addCriterion("keyss not like", value, "keyss");
return (Criteria) this;
}
public Criteria andKeyssIn(List<String> values) {
addCriterion("keyss in", values, "keyss");
return (Criteria) this;
}
public Criteria andKeyssNotIn(List<String> values) {
addCriterion("keyss not in", values, "keyss");
return (Criteria) this;
}
public Criteria andKeyssBetween(String value1, String value2) {
addCriterion("keyss between", value1, value2, "keyss");
return (Criteria) this;
}
public Criteria andKeyssNotBetween(String value1, String value2) {
addCriterion("keyss not between", value1, value2, "keyss");
return (Criteria) this;
}
public Criteria andReleaseDateIsNull() {
addCriterion("release_date is null");
return (Criteria) this;
}
public Criteria andReleaseDateIsNotNull() {
addCriterion("release_date is not null");
return (Criteria) this;
}
public Criteria andReleaseDateEqualTo(Date value) {
addCriterionForJDBCDate("release_date =", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateNotEqualTo(Date value) {
addCriterionForJDBCDate("release_date <>", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateGreaterThan(Date value) {
addCriterionForJDBCDate("release_date >", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateGreaterThanOrEqualTo(Date value) {
addCriterionForJDBCDate("release_date >=", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateLessThan(Date value) {
addCriterionForJDBCDate("release_date <", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateLessThanOrEqualTo(Date value) {
addCriterionForJDBCDate("release_date <=", value, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateIn(List<Date> values) {
addCriterionForJDBCDate("release_date in", values, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateNotIn(List<Date> values) {
addCriterionForJDBCDate("release_date not in", values, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateBetween(Date value1, Date value2) {
addCriterionForJDBCDate("release_date between", value1, value2, "releaseDate");
return (Criteria) this;
}
public Criteria andReleaseDateNotBetween(Date value1, Date value2) {
addCriterionForJDBCDate("release_date not between", value1, value2, "releaseDate");
return (Criteria) this;
}
public Criteria andImplDateIsNull() {
addCriterion("impl_date is null");
return (Criteria) this;
}
public Criteria andImplDateIsNotNull() {
addCriterion("impl_date is not null");
return (Criteria) this;
}
public Criteria andImplDateEqualTo(Date value) {
addCriterionForJDBCDate("impl_date =", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateNotEqualTo(Date value) {
addCriterionForJDBCDate("impl_date <>", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateGreaterThan(Date value) {
addCriterionForJDBCDate("impl_date >", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateGreaterThanOrEqualTo(Date value) {
addCriterionForJDBCDate("impl_date >=", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateLessThan(Date value) {
addCriterionForJDBCDate("impl_date <", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateLessThanOrEqualTo(Date value) {
addCriterionForJDBCDate("impl_date <=", value, "implDate");
return (Criteria) this;
}
public Criteria andImplDateIn(List<Date> values) {
addCriterionForJDBCDate("impl_date in", values, "implDate");
return (Criteria) this;
}
public Criteria andImplDateNotIn(List<Date> values) {
addCriterionForJDBCDate("impl_date not in", values, "implDate");
return (Criteria) this;
}
public Criteria andImplDateBetween(Date value1, Date value2) {
addCriterionForJDBCDate("impl_date between", value1, value2, "implDate");
return (Criteria) this;
}
public Criteria andImplDateNotBetween(Date value1, Date value2) {
addCriterionForJDBCDate("impl_date not between", value1, value2, "implDate");
return (Criteria) this;
}
public Criteria andPackagePathIsNull() {
addCriterion("package_path is null");
return (Criteria) this;
}
public Criteria andPackagePathIsNotNull() {
addCriterion("package_path is not null");
return (Criteria) this;
}
public Criteria andPackagePathEqualTo(String value) {
addCriterion("package_path =", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathNotEqualTo(String value) {
addCriterion("package_path <>", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathGreaterThan(String value) {
addCriterion("package_path >", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathGreaterThanOrEqualTo(String value) {
addCriterion("package_path >=", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathLessThan(String value) {
addCriterion("package_path <", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathLessThanOrEqualTo(String value) {
addCriterion("package_path <=", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathLike(String value) {
addCriterion("package_path like", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathNotLike(String value) {
addCriterion("package_path not like", value, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathIn(List<String> values) {
addCriterion("package_path in", values, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathNotIn(List<String> values) {
addCriterion("package_path not in", values, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathBetween(String value1, String value2) {
addCriterion("package_path between", value1, value2, "packagePath");
return (Criteria) this;
}
public Criteria andPackagePathNotBetween(String value1, String value2) {
addCriterion("package_path not between", value1, value2, "packagePath");
return (Criteria) this;
}
}
public static class Criteria extends GeneratedCriteria {
protected Criteria() {
super();
}
}
public static class Criterion {
private String condition;
private Object value;
private Object secondValue;
private boolean noValue;
private boolean singleValue;
private boolean betweenValue;
private boolean listValue;
private String typeHandler;
public String getCondition() {
return condition;
}
public Object getValue() {
return value;
}
public Object getSecondValue() {
return secondValue;
}
public boolean isNoValue() {
return noValue;
}
public boolean isSingleValue() {
return singleValue;
}
public boolean isBetweenValue() {
return betweenValue;
}
public boolean isListValue() {
return listValue;
}
public String getTypeHandler() {
return typeHandler;
}
protected Criterion(String condition) {
super();
this.condition = condition;
this.typeHandler = null;
this.noValue = true;
}
protected Criterion(String condition, Object value, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.typeHandler = typeHandler;
if (value instanceof List<?>) {
this.listValue = true;
} else {
this.singleValue = true;
}
}
protected Criterion(String condition, Object value) {
this(condition, value, null);
}
protected Criterion(String condition, Object value, Object secondValue, String typeHandler) {
super();
this.condition = condition;
this.value = value;
this.secondValue = secondValue;
this.typeHandler = typeHandler;
this.betweenValue = true;
}
protected Criterion(String condition, Object value, Object secondValue) {
this(condition, value, secondValue, null);
}
}
} | [
"[email protected]"
] | |
cc99c4f036224beebf3bd42a8b2ff2a5d4f8ee45 | 32f18f9d9dbc92a553a9051d672b3b593cf932f3 | /src/com/chongwu/activity/Fragment/CommonViewPageFragment.java | c79f44abbdd6cab9bd8487c6b299f413001888d7 | [] | no_license | zhaozw/ChongWu | 50afcc806d541613b43848fb76c1ee6bf86892c3 | 99a59aaab1844971e5204a4fc986504533287b2c | refs/heads/master | 2021-01-17T23:04:07.580043 | 2014-10-12T05:34:18 | 2014-10-12T05:34:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,745 | java | package com.chongwu.activity.Fragment;
import com.chongwu.R;
import com.chongwu.adapter.CommonFragmentPagerAdapter;
import com.chongwu.widget.common.InsideViewPager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.ViewPager.OnPageChangeListener;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;
/**
* ่ตๅพ็ๆฎต
*
* @author Kaka
*
*/
public abstract class CommonViewPageFragment extends Fragment implements
OnPageChangeListener, android.widget.RadioGroup.OnCheckedChangeListener {
private InsideViewPager viewPager;
private FragmentActivity parentActivity;
private FragmentManager fragmentManager;
private RadioGroup radioGroup;
private View view;
private int[] btns;
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
parentActivity = getActivity();
fragmentManager = parentActivity.getSupportFragmentManager();
btns = getBtns();
}
/**
* ้ๅๆญคๆนๆณๆฅๅฎไนFragment็viewๅ
ๅฎน
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (view != null) {
ViewGroup viewGroup = (ViewGroup) view.getParent();
if (viewGroup != null) {
viewGroup.removeView(view);
}
return view;
} else {
view = inflater.inflate(R.layout.common_viewpage, container, false);
//
viewPager = (InsideViewPager) view.findViewById(R.id.viewPager);
viewPager.removeAllViewsInLayout();
viewPager.setViewParent(viewPager.getParent());
viewPager.setOffscreenPageLimit(btns.length);
// ่ฎพ็ฝฎviewPagerๅ
ๅฎน
viewPager.setAdapter(getAdapter());
viewPager.setOnPageChangeListener(this);
radioGroup = (RadioGroup) view.findViewById(R.id.radiogroup);
radioGroup.setOnCheckedChangeListener(this);
return view;
}
}
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
for (int i = 0; i < btns.length; i++) {
if (radioGroup.getCheckedRadioButtonId() == btns[i]) {
viewPager.setCurrentItem(i);
}
}
}
@Override
public void onPageScrollStateChanged(int arg0) {
}
@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}
@Override
public void onPageSelected(int arg0) {
radioGroup.check(btns[arg0]);
}
public abstract CommonFragmentPagerAdapter getAdapter();
/**
* ่ทๅbtnๅ่กจ
*
* @return
*/
public abstract int[] getBtns();
}
| [
"[email protected]"
] | |
8e1e76f710eaa2bb1cf6a0fa55702653cb18036e | cc4655ae8846321314c1de5637df7ef6953c8523 | /src/main/java/com/viching/fastdfs/conn/ConnectionPoolConfig.java | 8e7ec1fef4ce925049169a1e00af29fd3373f81b | [] | no_license | viching/spring-boot-starter-fastdfs | f44e58613f8a98c14affdf9acf4615d0948ee433 | 24616bd0970ccff0ef1ef8d616fc7bbd36dd12ff | refs/heads/master | 2020-03-31T07:14:43.728406 | 2019-04-10T07:10:06 | 2019-04-10T07:10:06 | 152,014,009 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,252 | java | package com.viching.fastdfs.conn;
import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
/**
* ่ฟๆฅๆฑ ้
็ฝฎ
*
* @author luhuiguo
*
*/
public class ConnectionPoolConfig extends GenericKeyedObjectPoolConfig {
/** ไปๆฑ ไธญๅๅบ็ๅฏน่ฑก็ๆๅคงๆฐ็ฎ */
public static final int FDFS_MAX_TOTAL = 50;
/** ๅจ็ฉบ้ฒๆถๆฃๆฅๆๆๆง, ้ป่ฎคfalse */
public static final boolean FDFS_TEST_WHILE_IDLE = true;
/**
* ่ฟๆฅ่ๅฐฝๆถๆฏๅฆ้ปๅก(้ป่ฎคtrue)
* falseๆฅๅผๅธธ,ture้ปๅก็ดๅฐ่ถ
ๆถ
*/
public static final boolean FDFS_BLOCK_WHEN_EXHAUSTED = true;
/**
* ่ทๅ่ฟๆฅๆถ็ๆๅคง็ญๅพ
ๆฏซ็งๆฐ(ๅฆๆ่ฎพ็ฝฎไธบ้ปๅกๆถBlockWhenExhausted)
* ๅฆๆ่ถ
ๆถๅฐฑๆๅผๅธธ,ๅฐไบ้ถ:้ปๅกไธ็กฎๅฎ็ๆถ้ด,้ป่ฎค-1
*/
public static final long FDFS_MAX_WAIT_MILLIS = 100;
public static final long FDFS_MIN_EVICTABLE_IDLETIME_MILLIS = 180000;
/**
* ้ๅบๆซๆ็ๆถ้ด้ด้(ๆฏซ็ง) ๆฏ่ฟ60็ง่ฟ่กไธๆฌกๅๅฐๅฏน่ฑกๆธ
็็่กๅจ
* ๅฆๆไธบ่ดๆฐ,ๅไธ่ฟ่ก้ๅบ็บฟ็จ, ้ป่ฎค-1
*/
public static final long FDFS_TIME_BETWEEN_EVICTION_RUNS_MILLIS = 60000;
/**
* ๆฏๆฌก้ๅบๆฃๆฅๆถ ้ๅบ็ๆๅคงๆฐ็ฎ ๅฆๆไธบ่ดๆฐๅฐฑๆฏ : 1/abs(n), ้ป่ฎค3
* ๏ผ1่กจ็คบๆธ
็ๆถๆฃๆฅๆๆ็บฟ็จ
*/
public static final int FDFS_NUM_TESTS_PEREVICTION_RUN = -1;
public ConnectionPoolConfig() {
// ไปๆฑ ไธญๅๅบ็ๅฏน่ฑก็ๆๅคงๆฐ็ฎ
setMaxTotal(FDFS_MAX_TOTAL);
// ๅจ็ฉบ้ฒๆถๆฃๆฅๆๆๆง
setTestWhileIdle(FDFS_TEST_WHILE_IDLE);
// ่ฟๆฅ่ๅฐฝๆถๆฏๅฆ้ปๅก(้ป่ฎคtrue)
setBlockWhenExhausted(FDFS_BLOCK_WHEN_EXHAUSTED);
// ่ทๅ่ฟๆฅๆถ็ๆๅคง็ญๅพ
ๆฏซ็งๆฐ100
setMaxWaitMillis(FDFS_MAX_WAIT_MILLIS);
// ่งไผ็ ๆถ้ด่ถ
่ฟไบ180็ง็ๅฏน่ฑกไธบ่ฟๆ
setMinEvictableIdleTimeMillis(FDFS_MIN_EVICTABLE_IDLETIME_MILLIS);
// ๆฏ่ฟ60็ง่ฟ่กไธๆฌกๅๅฐๅฏน่ฑกๆธ
็็่กๅจ
setTimeBetweenEvictionRunsMillis(FDFS_TIME_BETWEEN_EVICTION_RUNS_MILLIS);
// ๆธ
็ๆถๅๆฃๆฅๆๆ็บฟ็จ
setNumTestsPerEvictionRun(FDFS_NUM_TESTS_PEREVICTION_RUN);
setJmxEnabled(false);
}
} | [
"[email protected]"
] | |
05d2fddf5d98973d899350672129a2de6331f20a | 7dd8b7ecba67031df4f4ecdbc6939c893ec356a1 | /src/main/java/com/corporate/delivery/dao/OrderStatusDao.java | 494bd36b8d1d07fe3bde56e1b350e48d0238eb3b | [] | no_license | aceexpressdelivery/delivery-core | 014e330ecabbd0850a2dec24d9461448d41359b6 | 99e6c00865670b1121fe970ed87668581365af90 | refs/heads/master | 2020-03-26T22:38:42.371852 | 2018-10-31T09:17:21 | 2018-10-31T09:17:21 | 145,476,378 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 374 | java | package com.corporate.delivery.dao;
import java.util.List;
import com.corporate.delivery.model.order.OrderStatus;
public interface OrderStatusDao {
public List<OrderStatus> getOrderStatus(int userId);
public void insert(OrderStatus orderStatus) ;
public void updateOrderStatus(OrderStatus orderStatus);
public void deleteOrderStatus(OrderStatus orderStatus);
}
| [
"[email protected]"
] | |
6c8a3489b552c0dad6ff51713227771eadf8ecf0 | 8258dd82dece76adbffc1d3429ca63aebf1a2600 | /app/src/main/java/com/mac/runtu/javabean/PropertyCommiteInfo.java | 40b5e0c0e898188d66f1b2bdc140602a9c246fbe | [] | no_license | wuyue0829/Runtu-master02 | 155750550c601e05afe3c5a76140bb92df14fe77 | cc76dde1bf017d2649f5b51a7bf45afc2891df4e | refs/heads/master | 2020-04-11T06:44:44.682500 | 2018-12-13T05:51:04 | 2018-12-13T05:51:04 | 161,590,380 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,098 | java | package com.mac.runtu.javabean;
import java.io.Serializable;
/**
* Description: ไบงๆๆต่ฝฌไฟกๆฏๅๅธ
* Copyright : Copyright (c) 2016
* Company :
* Author : ็ๅฉๆฅ
* Date : 2016/10/31 0031 ไธๅ 8:41
*/
public class PropertyCommiteInfo implements Serializable{
/*userUuid๏ผkind๏ผ็ง็ฑป๏ผ๏ผtitle๏ผcontent๏ผcontacts๏ผphone๏ผcity๏ผcounty๏ผtown๏ผvillage
๏ผarea๏ผไบฉ๏ผ๏ผprice๏ผไปทๆ ผ๏ผ๏ผyears๏ผๅนด้๏ผ๏ผexchange(ๆต่ฝฌๆนๅผ1ไธบ่ฝฌ่ฎฉ๏ผ2ไธบ่ฝฌๅ
๏ผ3ไธบไบๆข๏ผ4ไธบๅ
ฅ่ก๏ผ5ไธบๅบ็ง) uuid
(ๅ็ฌ่ทๅพ็ฌฌuuid)*/
public String userUuid;
public String kind;
public String title;
public String content;
public String contacts;
public String phone;
public String publisher = "";
public String province ="";
public String city;
public String county = "";
public String town = "";
public String village = "";
public String uuid = "";
public String area;
public String price;
public String years;
public String exchange;
}
| [
"[email protected]"
] | |
ece1ea1923f29385b5338afeb3fc2a8c4a52e811 | b8b6b9a3176775ae17eb29bf0f9ed9b8451dea80 | /leetcode/src/DynamicProgramming/HouseRobberThree.java | 02c60aa7b7aaec4da045ea3441a01b0f503b5252 | [] | no_license | qingxian666/ceshi | 2028cb2cdce118ffd60ca55dab9f53318f171820 | eebabbbe641bc6cbe1d0a7cbf77933f1677041f2 | refs/heads/master | 2020-04-20T07:33:18.150438 | 2019-05-02T03:01:48 | 2019-05-02T03:01:48 | 168,713,965 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 491 | java | package DynamicProgramming;
public class HouseRobberThree {
public int rob(TreeNode root) {
return dfs(root)[0];
}
public static int[] dfs(TreeNode root){
int [] dp = new int [] {0,0};
if(root!=null){
int [] dpL=dfs(root.left);
int [] dpR=dfs(root.right);
dp[1]=dpL[0]+dpR[0];
dp[0]=Math.max(dp[1],dpL[1]+dpR[1]+root.val);
}
return dp;
}
}
| [
"[email protected]"
] | |
8cf6468a6051129e16f1df5c3d20b1c298c1a296 | e1aa7bcf7461d63a710f06d33c01415045187f68 | /AssignmentCustomerProducerApp-61/src/main/java/in/nit/model/Customer.java | d598f3e889519fdae6be90974945149e39f9eee2 | [] | no_license | maheswarareddy529/Webservice | b48982ea7efa9d42a99cf393b13abee7fcd63276 | 2c9d229b5d7d442e356dc7d39b440e72d541f334 | refs/heads/master | 2023-02-27T00:05:38.879670 | 2021-02-02T07:10:18 | 2021-02-02T07:10:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 289 | java | package in.nit.model;
import java.util.List;
import java.util.Map;
import lombok.Data;
@Data
public class Customer {
private Integer custid;
private String custname;
private Map<String,Integer> items;
private Map<String,Integer> card;;
private List<Integer> discount;
}
| [
"[email protected]"
] | |
f5c78a40858aa260592f944db1689c3a6dfc7faf | a6938a0468a09bdc9686ce7181df54dfdabc375a | /tdyth/src/main/java/cas/iie/nsp/controller/UserController.java | 9cb71ac6232b5e52b09826e9707e01b6789149f4 | [] | no_license | xidian-Merlin/webDemo | e3e5c8d55d8b03a6b558c3b754669282a0196cbf | 4892e075d464f22c7315b2a1eeb00294e35ba7f0 | refs/heads/master | 2021-05-05T05:53:07.770323 | 2018-03-10T13:07:08 | 2018-03-10T13:07:08 | 118,754,123 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,631 | java | package cas.iie.nsp.controller;
import java.util.HashMap;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import cas.iie.nsp.exception.UserException;
import cas.iie.nsp.model.User;
import cas.iie.nsp.service.IIndexService;
import cas.iie.nsp.service.IUserService;
import cas.iie.nsp.service.impl.IndexServiceImpl;
import cas.iie.nsp.service.impl.UserServiceImpl;
@Controller
@RequestMapping(value="/user")
public class UserController {
private static Logger logger = Logger.getLogger(UserController.class);
// @Autowired
// private UserServiceImpl userService;
@Autowired
private IIndexService indexService;
@Autowired
private IUserService userService;
@RequestMapping(value="/login", method=RequestMethod.POST)
public @ResponseBody Map<String,Object> login(HttpServletRequest request ){
String userName =request.getParameter("username");
String passWord =request.getParameter("password");
Map<String,Object> map=new HashMap<String,Object>();
logger.info("userName====>"+userName);
if (null == userName || "".equals(userName.trim())) {
throw new UserException("็จๆทๅไธ่ฝไธบ็ฉบ");
}
// User user = userService.getUserByUsername(userName);
//map= indexService.findUserByName(userName);
//logger.info("map===========>"+map.toString());
/*User user=new User();
user.setUsername((String)map.get("userName"));
user.setPassword((String)map.get("password"));
if (null == user) {
throw new UserException("็จๆทๅไธๅญๅจ");
}
if (!user.getPassword().equals(passWord)) {
throw new UserException("ๅฏ็ ไธๆญฃ็กฎ");
}*/
if(userName.equals("admin")){
map.put("result", true);
map.put("message", "็ป้ๆๅ๏ผ");
}else{
map.put("result", false);
map.put("message", "็จๆทๅๆๅฏ็ ้่ฏฏ๏ผ");
}
return map;
}
@RequestMapping(value="/button")
public String button(HttpServletRequest request ){
logger.info("userName====>");
return "user/button";
}
} | [
"[email protected]"
] | |
8e740bae2e5dd65ff831b26a842411a11bd708de | b30004c4cb8b546ed394a620d700e36012654ae4 | /filters/src/main/java/org/servlet/filters/SessionAttributeFilter.java | 4772c5619ccc52a929553765fd6d10b6a01ffac2 | [
"MIT"
] | permissive | shastrisaurabh/Servlet-Filters | 892139a0b74540710691ebe2a13a5064971d049f | de6e0b6bc487bc7060968f98de28dba0a432160a | refs/heads/master | 2020-04-24T19:14:50.319997 | 2014-09-12T01:35:26 | 2014-09-12T01:35:26 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,817 | java | package org.servlet.filters;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* <code>SessionAttributeFilter</code> is a filter which can be used to redirect
* requests based on attributes found in the session.
*
* @author shivam
*/
public final class SessionAttributeFilter implements Filter {
/** Init param for setting requireAttribute. */
public static final String REQUIRE_ATTRIBUTE = "requireAttribute";
/** Log for this class. */
private static final Log LOG = LogFactory
.getLog(SessionAttributeFilter.class);
/** Whether attributes are required to exist by this filter. */
private boolean requireAttribute;
/** Used to forward requests. */
private ServletContext context;
/** Session attribute names and values. */
private Map<String, Pattern> attributes = new HashMap<String, Pattern>();
/** Redirect URL for each session attribute. */
private Map<String, String> redirects = new HashMap<String, String>();
/**
* Initialize this filter.
*
* @param config
* <code>FilterConfig</code>
*/
public void init(final FilterConfig config) {
this.context = config.getServletContext();
this.requireAttribute = Boolean.valueOf(
config.getInitParameter(REQUIRE_ATTRIBUTE)).booleanValue();
if (LOG.isDebugEnabled()) {
LOG.debug("requireAttribute = " + this.requireAttribute);
}
final Enumeration<?> e = config.getInitParameterNames();
while (e.hasMoreElements()) {
final String name = (String) e.nextElement();
if (!name.equals(REQUIRE_ATTRIBUTE)) {
final String value = config.getInitParameter(name);
if (LOG.isDebugEnabled()) {
LOG.debug("Loaded attribute name:value " + name + ":"
+ value);
}
final StringTokenizer st = new StringTokenizer(name);
final String attrName = st.nextToken();
final String attrValue = st.nextToken();
this.attributes.put(attrName, Pattern.compile(attrValue));
this.redirects.put(attrName, value);
if (LOG.isDebugEnabled()) {
LOG.debug("Stored attribute " + attrName + " for pattern "
+ attrValue + " with redirect of " + value);
}
}
}
}
/**
* Handle all requests sent to this filter.
*
* @param request
* <code>ServletRequest</code>
* @param response
* <code>ServletResponse</code>
* @param chain
* <code>FilterChain</code>
*
* @throws ServletException
* if an error occurs
* @throws IOException
* if an error occurs
*/
public void doFilter(final ServletRequest request,
final ServletResponse response, final FilterChain chain)
throws IOException, ServletException {
boolean success = false;
String redirect = null;
if (request instanceof HttpServletRequest) {
final HttpSession session = ((HttpServletRequest) request)
.getSession(true);
final Iterator<String> i = this.attributes.keySet().iterator();
boolean loop = true;
while (i.hasNext() && loop) {
final String name = i.next();
final Pattern pattern = this.attributes.get(name);
final Object sessionAttr = session.getAttribute(name);
if (sessionAttr != null) {
final String value = String.valueOf(sessionAttr);
if (pattern.matcher(value).matches()) {
if (LOG.isDebugEnabled()) {
LOG.debug(value + " matches " + pattern.pattern());
}
success = true;
} else {
if (LOG.isDebugEnabled()) {
LOG.debug(value + " does not match "
+ pattern.pattern());
}
redirect = this.redirects.get(name);
success = false;
loop = false;
}
} else {
if (LOG.isDebugEnabled()) {
LOG.debug("No session attribute found for " + name);
}
if (this.requireAttribute) {
redirect = this.redirects.get(name);
success = false;
loop = false;
} else {
success = true;
}
}
}
}
if (!success) {
if (redirect != null && !"".equals(redirect)) {
final StringBuffer url = new StringBuffer(redirect);
if (((HttpServletRequest) request).getRequestURI() != null) {
url.append("?url=").append(
URLEncoder.encode(((HttpServletRequest) request)
.getRequestURI(), "UTF-8"));
if (((HttpServletRequest) request).getQueryString() != null) {
url.append(URLEncoder.encode("?", "UTF-8")).append(
URLEncoder.encode(
((HttpServletRequest) request)
.getQueryString(), "UTF-8"));
}
}
if (LOG.isDebugEnabled()) {
LOG.debug("Forwarding request to " + url.toString());
}
this.context.getRequestDispatcher(url.toString()).forward(
request, response);
return;
} else {
if (response instanceof HttpServletResponse) {
((HttpServletResponse) response)
.sendError(HttpServletResponse.SC_FORBIDDEN,
"Request blocked by filter, unable to perform redirect");
return;
} else {
throw new ServletException(
"Request blocked by filter, unable to perform redirect");
}
}
}
chain.doFilter(request, response);
}
/**
* Called by the web container to indicate to a filter that it is being
* taken out of service.
*/
public void destroy() {
}
} | [
"[email protected]"
] | |
d6c17f9d4fa265fbd1069a2b19410a5fcc2891ed | 55819832e8f7c3e6674e79748e8032533a9ca74c | /src/main/kotlin/application/model/LRUCache.java | bd73f7fb22d4fd7709a647df76b0e02c4b0f5bd7 | [] | no_license | jedlimlx/Cellular-Automaton-Viewer | bd0edaefe7189093c025bc1c85aa1ccc0bb0153a | 92b0b63c3689b5846ed1709e39c91384d05f8b21 | refs/heads/master | 2021-12-07T20:48:21.163455 | 2021-12-04T03:51:02 | 2021-12-04T03:51:02 | 254,280,126 | 12 | 1 | null | null | null | null | UTF-8 | Java | false | false | 3,531 | java | package application.model;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import java.util.function.BiConsumer;
import java.util.function.Function;
/**
* Implements a least recently used cache with a hashmap and queue
* @param <K> The key of the LRU cache
* @param <V> The values to be stored in the cache
*/
public class LRUCache<K, V> implements Iterable<K>, Iterator<K> {
private int capacity;
private Function<V, Boolean> checkValid;
private BiConsumer<K, V> deleteFunc;
private final Queue<K> keyQueue;
private final HashMap<K, V> hashMap;
/**
* Constructs an LRU cache with the specified capacity
* @param capacity The capacity of the LRU cache
*/
public LRUCache(int capacity) {
this.capacity = capacity;
keyQueue = new LinkedList<>();
hashMap = new HashMap<>();
}
/**
* Sets the a value in the LRU cache
* @param key Key to associate value with
* @param value Value to be set
*/
public void put(K key, V value) {
keyQueue.add(key);
hashMap.put(key, value);
if (hashMap.size() > capacity && capacity != -1) {
K keyToDelete = keyQueue.poll();
if (checkValid != null) {
while (hashMap.get(keyToDelete) == null || !checkValid.apply(hashMap.get(keyToDelete))) {
hashMap.remove(keyToDelete);
keyToDelete = keyQueue.poll();
}
}
if (deleteFunc != null)
deleteFunc.accept(keyToDelete, hashMap.get(keyToDelete));
hashMap.remove(keyToDelete);
}
}
/**
* Removes the a value from the LRU cache
* O(N) removal by the way
* @param key Key to associated with the value
*/
public void remove(K key) {
//keyQueue.remove(key);
hashMap.remove(key);
}
/**
* Gets a value associated with a key
* @param key The key that the value is associated with
* @return Returns the value
*/
public V get(K key) {
return hashMap.get(key);
}
/**
* Checks if the key can be found in the cache
* @param key The key to search for
* @return Returns true if the key is found, false otherwise
*/
public boolean containsKey(K key) {
return hashMap.containsKey(key);
}
/**
* Size of the LRU cache
* @return Returns the size of the LRU cache
*/
public int size() {
return hashMap.size();
}
/**
* Sets the function that should run when a value is deleted
* @param deleteFunc The function to run
*/
public void setDeleteFunc(BiConsumer<K, V> deleteFunc) {
this.deleteFunc = deleteFunc;
}
/**
* Checks if a given value is valid in the LRU cache
* @param checkValid The function to run
*/
public void setCheckValid(Function<V, Boolean> checkValid) {
this.checkValid = checkValid;
}
/**
* Sets the capacity of the LRU cache
* @param capacity Capacity of the LRU cache
*/
public void setCapacity(int capacity) {
this.capacity = capacity;
}
@Override
public Iterator<K> iterator() {
return hashMap.keySet().iterator();
}
@Override
public boolean hasNext() {
return hashMap.keySet().iterator().hasNext();
}
@Override
public K next() {
return hashMap.keySet().iterator().next();
}
} | [
"[email protected]"
] | |
e651f9eca31b65549cd4eab555653f396d25e4ad | e9978986deaea6ae9f89c100dfdbb84f152a6f8d | /src/com/company/Person.java | 5d6faf9d2a510a99ca768778d87bfcc92bd62dc2 | [] | no_license | JThorumP/Fitness_Recap | dbb70795a315e345fc34f93795614bf9dcbf3de9 | 7ccd1b96cb995004281c3334040c923ade9661d4 | refs/heads/master | 2020-07-17T11:05:53.008638 | 2019-09-03T06:57:45 | 2019-09-03T06:57:45 | 206,008,104 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,201 | java | package com.company;
public class Person {
private String name;
private String CPR;
private int hours;
private int salary;
private String membership;
public Person(){
}
public Person(String name, String CPR, int hours, int salary){
this.name = name;
this.CPR = CPR;
this.hours = hours;
this.salary = salary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCPR() {
return CPR;
}
public void setCPR(String CPR) {
this.CPR = CPR;
}
public int getHours() {
return hours;
}
public void setHours(int hours) {
this.hours = hours;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public String getMembership() {
return membership;
}
public void setMembership(String membership) {
this.membership = membership;
}
public String toString(){
return this.name + "\t" + this.CPR + "\t" + this.hours + "\t\t" +this.salary;
}
} | [
"[email protected]"
] | |
b7cdaca23e8426568fce6db3244228da82f6e1b9 | 2a9c9885a528dcfeebf43fcf91f7623154ae0252 | /src/adminAnduserUI/CreateGUIAccountUserView.java | 150023b92a8fda31dfad600909e2648d623d7c90 | [] | no_license | wongkaho2626/PurchaseOrder | 5d676a5d99fda7379fc31a0be47550644bbb5d6c | 1f1f72828d6ed83b703ab7797dec4cf534b6a6ab | refs/heads/master | 2021-10-09T23:18:15.418725 | 2019-01-04T11:33:54 | 2019-01-04T11:33:54 | 106,903,516 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,571 | java | package adminAnduserUI;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.security.NoSuchAlgorithmException;
import java.sql.SQLException;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import domain.IRBS;
import domain.MD5;
public class CreateGUIAccountUserView {
private String userID;
private String password;
private String currentPassword;
private JLabel accountLabel;
private JPasswordField currentPasswordField;
private JPasswordField passwordField1;
private JPasswordField passwordField2;
private JButton accountButton;
private JPanel errorPanel;
private JPanel accountPanel;
public CreateGUIAccountUserView(String userID){
this.userID = userID;
initUI();
}
private void initUI() {
setUP();
}
private void setUP() {
accountPanel = new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
// ************************* accountPanel UI SetUP
// *************************
// ========================= accountPanel Level One UI Create
// =========================
accountLabel = new JLabel("Change your password (User)");
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.ipadx = 200;
gbc.ipady = 30;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.insets = new Insets(5, 5, 5, 5);
accountPanel.add(accountLabel, gbc);
accountLabel = new JLabel("Staff: ");
gbc.gridx = 0;
gbc.gridy = 1;
accountPanel.add(accountLabel, gbc);
accountLabel = new JLabel(userID);
gbc.gridx = 1;
gbc.gridy = 1;
accountPanel.add(accountLabel, gbc);
accountLabel = new JLabel("Current Password: ");
gbc.ipady = 10;
gbc.gridx = 0;
gbc.gridy = 2;
accountPanel.add(accountLabel, gbc);
currentPasswordField = new JPasswordField();
gbc.gridx = 1;
gbc.gridy = 2;
accountPanel.add(currentPasswordField, gbc);
accountLabel = new JLabel("New Password: ");
gbc.ipady = 10;
gbc.gridx = 0;
gbc.gridy = 3;
accountPanel.add(accountLabel, gbc);
passwordField1 = new JPasswordField();
gbc.gridx = 1;
gbc.gridy = 3;
accountPanel.add(passwordField1, gbc);
accountLabel = new JLabel("Reconfirm new Password: ");
gbc.gridx = 0;
gbc.gridy = 4;
accountPanel.add(accountLabel, gbc);
passwordField2 = new JPasswordField();
gbc.gridx = 1;
gbc.gridy = 4;
accountPanel.add(passwordField2, gbc);
accountLabel = new JLabel();
gbc.gridx = 0;
gbc.gridy = 5;
accountPanel.add(accountLabel, gbc);
accountButton = new JButton("Save");
gbc.gridx = 1;
gbc.gridy = 6;
accountPanel.add(accountButton, gbc);
//change account password
accountButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
password = passwordField1.getText();
currentPassword = currentPasswordField.getText();
if(passwordField1.getText().equals("") || passwordField2.getText().equals("")){
JOptionPane
.showMessageDialog(
errorPanel,
"Error: Password field cannot be null, Please try again.",
"Error", JOptionPane.ERROR_MESSAGE);
}else{
IRBS irbs = new IRBS();
MD5 md5 = new MD5();
try{
if(irbs.loginUser(userID, md5.getMD5(currentPassword))){
if(passwordField1.getText().equals(passwordField2.getText())){
irbs.setUserPasswordData(userID, md5.getMD5(password));
JOptionPane
.showMessageDialog(
null,
"Success change the password",
"Success", JOptionPane.INFORMATION_MESSAGE);
}else{
JOptionPane
.showMessageDialog(
errorPanel,
"Error: New Password are not the same, Please try again.",
"Error", JOptionPane.ERROR_MESSAGE);
}
}else{
JOptionPane
.showMessageDialog(
errorPanel,
"Error: Current password is wrong, Please try again.",
"Error", JOptionPane.ERROR_MESSAGE);
}
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
} finally {
try {
irbs.getCon().close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
currentPasswordField.setText(null);
passwordField1.setText(null);
passwordField2.setText(null);
}
});
}
public JPanel viewPane(){
return accountPanel;
}
}
| [
"[email protected]"
] | |
216ee6386a4cfe5095d70e7f6f43d627a01e9a0f | 416868a35408036de87d580c9d4949808dcbcdfa | /Week9/Inventory.java | a0b8e0421abb90f6340c0ccd26201a332cec7d34 | [] | no_license | mattcosta5651/CSCI362-OpSystems | 1dc7c9132d05e4afdb4a85a938ab076100fad45b | 78163d36d32bc6873b7047673e851941b35f629e | refs/heads/master | 2021-01-11T15:59:25.491297 | 2017-04-27T02:51:46 | 2017-04-27T02:51:46 | 79,973,267 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java | import java.util.*;
import java.util.concurrent.*;
public class Inventory{
private final Semaphore paper = new Semaphore(0, true);
private final Semaphore matches = new Semaphore(0, true);
private final Semaphore tobacco = new Semaphore(0, true);
private final Semaphore supplier = new Semaphore(0, true);
private final Semaphore smoker = new Semaphore(0, true);
public void producePaper(){
paper.release();
}
public void produceMatches(){
matches.release();
}
public void produceTobacco(){
tobacco.release();
}
public void consumePaper(){
try{
paper.acquire();
}
catch(Exception e){
e.printStackTrace();
}
}
public void consumeMatches(){
try{
matches.acquire();
}
catch(Exception e){
e.printStackTrace();
}
}
public void consumeTobacco(){
try{
tobacco.acquire();
}
catch(Exception e){
e.printStackTrace();
}
}
public synchronized boolean matchesPermitsAvailable(){return matches.availablePermits() > 0;}
public synchronized boolean paperPermitsAvailable(){return paper.availablePermits() > 0;}
public synchronized boolean tobaccoPermitsAvailable(){return tobacco.availablePermits() > 0;}
public void readyForSmoker(){
}
public void readyForSupplies(){
supplier.release();
}
public void waitForSmoker(){
try{
supplier.acquire();
}
catch(Exception e){
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
02f0a2b34d4893c54a7473f97994ff3d8d9ed5c7 | 79a5f92571fa60b509bf174d44496ea8f45bca28 | /src/main/java/com/pqpo/utils/redis/datasource/RedisOperations.java | 2d60c0cc20debc6dc19f18f101b912e2d85f85f8 | [] | no_license | pqpo/utils.redis | ad28dc7f7c8730f2560044225ba363908712d7aa | 3a8f40cd87aa6de958a3b6792ca46f5657f82180 | refs/heads/master | 2021-01-10T04:39:57.170085 | 2015-12-23T02:01:01 | 2015-12-23T02:01:01 | 45,235,905 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 316 | java | package com.pqpo.utils.redis.datasource;
public interface RedisOperations<K, V> {
public void set(K key,V value);
public V get(K key);
public boolean setnx(K key,V value);
public long incr(K key,long step);
public long derc(K key,long step);
public long del(K keys);
public void disconnect();
}
| [
"[email protected]"
] | |
cfd42f5543e78bda8993c6737df914387efff307 | 7e8b0282421afe025ebff538ed34a4eebd1a4672 | /android/app/src/main/java/com/opcaoapp/MainApplication.java | e68ceb2313894f0a42c17e5978de6f51c65c360a | [] | no_license | lumnidev/OpcaoApp | 46d41388cc3118e64c4d2f796a158cb1fd8d7a7c | 5eb279888b733a79523e84c4c6fa0bcadfcc390d | refs/heads/master | 2020-04-26T15:00:06.179666 | 2019-03-19T15:27:12 | 2019-03-19T15:27:12 | 173,633,471 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,243 | java | package com.opcaoapp;
import android.app.Application;
import com.facebook.react.ReactApplication;
import com.oblador.vectoricons.VectorIconsPackage;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
import com.facebook.soloader.SoLoader;
import java.util.Arrays;
import java.util.List;
public class MainApplication extends Application implements ReactApplication {
private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
}
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new VectorIconsPackage(),
new RNGestureHandlerPackage()
);
}
@Override
protected String getJSMainModuleName() {
return "index";
}
};
@Override
public ReactNativeHost getReactNativeHost() {
return mReactNativeHost;
}
@Override
public void onCreate() {
super.onCreate();
SoLoader.init(this, /* native exopackage */ false);
}
}
| [
"[email protected]"
] | |
3bbcd33f9e7e004778f061de9398fbdf1509b474 | 2c98ad03fbc147f50d348740b9e54ca5cad82ab7 | /src/Beings/Imp.java | ff68934995e288fe22b1de139b8ee2ca40a0046f | [] | no_license | rcooper3307/Overseer | 3c1b561dfdce176760c7f1b3ee7cc726fc8f9944 | e003e80c94fb38198d8ffdc878c1d24735ea0c15 | refs/heads/master | 2020-04-09T20:25:03.273309 | 2018-12-13T13:41:26 | 2018-12-13T13:41:26 | 160,572,837 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 146 | java | package Beings;
public class Imp extends Being {
public Imp(String title,int xLoc, int yLoc)
{
super(title,xLoc,yLoc);
}
}
| [
"[email protected]"
] | |
43da7568710069bfb9d8177957ff0a618edc0efc | dafcf609f7d98e0dd698a64ef150657150394668 | /Assignment 5/src/test/java/com/gamebuilder/sprite/ActionButtonListnerTest.java | 6ccd7f82bba01c0fcca3acae17851e70c70b5925 | [] | no_license | PulkitMathur/Object-Oriented-Software-Development | ff620060ff846318b588a9fb5660401a485a5f15 | e32ea46ea05a32706b1e51b911de6039f04ec782 | refs/heads/master | 2021-08-23T01:00:52.298123 | 2017-12-02T01:29:30 | 2017-12-02T01:29:30 | 103,326,941 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 896 | java | //package com.gamebuilder.sprite;
//public class ActionButtonListnerTest {
//}
package com.gamebuilder.sprite;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.*;
import com.gamebuilder.helpers.ActionButtonListener;
import com.gamebuilder.model.SpritePanelModel;
import com.gamebuilder.sprite.GameSprite;
public class ActionButtonListnerTest {
private ActionButtonListener actionButtonListner;
private SpritePanelModel spritePanelModel;
@Before
public void setUp(){
spritePanelModel = new SpritePanelModel();
actionButtonListner = mock(ActionButtonListener.class);
when(actionButtonListner.getSpritePanelModel()).thenReturn(spritePanelModel);
}
@Test
public void testAction(){
assertEquals(actionButtonListner.getSpritePanelModel(),spritePanelModel);
}
} | [
"[email protected]"
] | |
6133e37af50d7f6dfb176c038cc99a66f1c83d2c | cf17d74dacb300d93f0f77f3ab4124c09e185287 | /src/main/java/com/example/demo/model/Role.java | 15c7ef6809496a489f748defb46db600f3fbb770 | [] | no_license | yoolbinum/LostFound | 234b45d40c0063fd645ee1921f2eb067c3efe5de | df6ccd156c91f0ba22b702d4b85865bb79bd8567 | refs/heads/master | 2021-01-25T13:08:04.000820 | 2018-03-07T00:40:22 | 2018-03-07T00:40:22 | 123,534,742 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 792 | java | package com.example.demo.model;
import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;
@Entity
public class Role {
@Id
@GeneratedValue(strategy= GenerationType.AUTO)
public long id;
@Column(unique=true)
private String role;
@ManyToMany(mappedBy="roles")
private List<User> users;
public Role() {
this.users = new ArrayList<>();
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
} | [
"[email protected]"
] | |
db8febeb6ce8ca7d95bf1ada2ea2806abc4483af | 54556275ca0ad0fb4850b92e5921725da73e3473 | /src/mikera/arrayz/Arrayz.java | ba103d3077cd57ac873f8dfca1797ef8bae0328f | [] | no_license | xSke/CoreServer | f7ea539617c08e4bd2206f8fa3c13c58dfb76d30 | d3655412008da22b58f031f4e7f08a6f6940bf46 | refs/heads/master | 2020-03-19T02:33:15.256865 | 2018-05-31T22:00:17 | 2018-05-31T22:00:17 | 135,638,686 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,544 | java | /*
* Decompiled with CFR 0_129.
*/
package mikera.arrayz;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import mikera.arrayz.Array;
import mikera.arrayz.INDArray;
import mikera.arrayz.NDArray;
import mikera.arrayz.impl.SliceArray;
import mikera.arrayz.impl.ZeroArray;
import mikera.matrixx.Matrix;
import mikera.matrixx.Matrixx;
import mikera.matrixx.impl.StridedMatrix;
import mikera.matrixx.impl.ZeroMatrix;
import mikera.vectorz.AScalar;
import mikera.vectorz.AVector;
import mikera.vectorz.Scalar;
import mikera.vectorz.Vector;
import mikera.vectorz.Vectorz;
import mikera.vectorz.impl.ArrayIndexScalar;
import mikera.vectorz.impl.ArraySubVector;
import mikera.vectorz.impl.ImmutableScalar;
import mikera.vectorz.impl.SparseIndexedVector;
import mikera.vectorz.impl.Vector0;
import mikera.vectorz.impl.ZeroVector;
import mikera.vectorz.util.ErrorMessages;
import mikera.vectorz.util.IntArrays;
import mikera.vectorz.util.VectorzException;
import us.bpsm.edn.parser.Parseable;
import us.bpsm.edn.parser.Parser;
import us.bpsm.edn.parser.Parsers;
public class Arrayz {
public static INDArray create(Object object) {
if (object instanceof INDArray) {
return Arrayz.create((INDArray)object);
}
if (object instanceof double[]) {
return Vector.of((double[])object);
}
if (object instanceof List) {
List list = (List)object;
int n = list.size();
if (n == 0) {
return Vector0.INSTANCE;
}
Object o1 = list.get(0);
if (o1 instanceof AScalar || o1 instanceof Number) {
return Vectorz.create((List)object);
}
if (o1 instanceof AVector) {
return Matrixx.create((List)object);
}
if (o1 instanceof INDArray) {
return SliceArray.create((List)object);
}
ArrayList<INDArray> al = new ArrayList<INDArray>(n);
for (Object o : list) {
al.add(Arrayz.create(o));
}
return Arrayz.create(al);
}
if (object instanceof Number) {
return Scalar.create(((Number)object).doubleValue());
}
if (object.getClass().isArray()) {
return Arrayz.create(Arrays.asList((Object[])object));
}
throw new VectorzException("Don't know how to create array from: " + object.getClass());
}
public static /* varargs */ INDArray newArray(int ... shape) {
int dims = shape.length;
switch (dims) {
case 0: {
return Scalar.create(0.0);
}
case 1: {
return Vector.createLength(shape[0]);
}
case 2: {
return Matrix.create(shape[0], shape[1]);
}
}
return Array.newArray(shape);
}
public static INDArray create(INDArray a) {
int dims = a.dimensionality();
switch (dims) {
case 0: {
return Scalar.create(a.get());
}
case 1: {
return Vector.wrap(a.toDoubleArray());
}
case 2: {
return Matrix.wrap(a.getShape(0), a.getShape(1), a.toDoubleArray());
}
}
return Array.wrap(a.toDoubleArray(), a.getShape());
}
public static /* varargs */ INDArray create(Object ... data) {
return Arrayz.create((Object)data);
}
public static INDArray wrap(double[] data, int[] shape) {
int dlength = data.length;
switch (shape.length) {
case 0: {
return ArrayIndexScalar.wrap(data, 0);
}
case 1: {
int n = shape[0];
if (dlength < n) {
throw new IllegalArgumentException(ErrorMessages.insufficientElements(dlength));
}
if (n == dlength) {
return Vector.wrap(data);
}
return ArraySubVector.wrap(data, 0, n);
}
case 2: {
int rc = shape[0];
int cc = shape[1];
int ec = rc * cc;
if (dlength < ec) {
throw new IllegalArgumentException(ErrorMessages.insufficientElements(dlength));
}
if (ec == dlength) {
return Matrix.wrap(rc, cc, data);
}
return StridedMatrix.wrap(data, shape[0], shape[1], 0, shape[1], 1);
}
}
long eec = IntArrays.arrayProduct(shape);
if ((long)dlength < eec) {
throw new IllegalArgumentException(ErrorMessages.insufficientElements(dlength));
}
if (eec == (long)dlength) {
return Array.wrap(data, shape);
}
return NDArray.wrap(data, shape);
}
public static /* varargs */ INDArray createFromVector(AVector a, int ... shape) {
int dims = shape.length;
if (dims == 0) {
return Scalar.createFromVector(a);
}
if (dims == 1) {
return Vector.createFromVector(a, shape[0]);
}
if (dims == 2) {
return Matrixx.createFromVector(a, shape[0], shape[1]);
}
return Array.createFromVector(a, shape);
}
public static INDArray load(Reader reader) {
Parseable pbr = Parsers.newParseable(reader);
Parser p = Parsers.newParser(Parsers.defaultConfiguration());
return Arrayz.create(p.nextValue(pbr));
}
public static INDArray parse(String ednString) {
return Arrayz.load(new StringReader(ednString));
}
public static INDArray wrapStrided(double[] data, int offset, int[] shape, int[] strides) {
int dims = shape.length;
if (dims == 0) {
return ArrayIndexScalar.wrap(data, offset);
}
if (dims == 1) {
return Vectorz.wrapStrided(data, offset, shape[0], strides[0]);
}
if (dims == 2) {
return Matrixx.wrapStrided(data, shape[0], shape[1], offset, strides[0], strides[1]);
}
if (Arrayz.isPackedLayout(data, offset, shape, strides)) {
return Array.wrap(data, shape);
}
return NDArray.wrapStrided(data, offset, shape, strides);
}
public static boolean isPackedLayout(double[] data, int offset, int[] shape, int[] strides) {
if (offset != 0) {
return false;
}
int dims = shape.length;
int st = 1;
for (int i = dims - 1; i >= 0; --i) {
if (strides[i] != st) {
return false;
}
st *= shape[i];
}
return st == data.length;
}
public static boolean isPackedStrides(int[] shape, int[] strides) {
int dims = shape.length;
int st = 1;
for (int i = dims - 1; i >= 0; --i) {
if (strides[i] != st) {
return false;
}
st *= shape[i];
}
return true;
}
public static INDArray createSparse(INDArray a) {
int dims = a.dimensionality();
if (dims == 0) {
return Scalar.create(a.get());
}
if (dims == 1) {
return Vectorz.createSparse(a.asVector());
}
if (dims == 2) {
return Matrixx.createSparse(Matrixx.toMatrix(a));
}
int n = a.sliceCount();
List<INDArray> slices = a.getSliceViews();
for (int i = 0; i < n; ++i) {
slices.set(i, slices.get(i).sparseClone());
}
return SliceArray.create(slices);
}
public static /* varargs */ INDArray createZeroArray(int ... shape) {
switch (shape.length) {
case 0: {
return ImmutableScalar.ZERO;
}
case 1: {
return ZeroVector.create(shape[0]);
}
case 2: {
return ZeroMatrix.create(shape[0], shape[1]);
}
}
return ZeroArray.create(shape);
}
public static /* varargs */ INDArray createSparseArray(int ... shape) {
switch (shape.length) {
case 0: {
return Scalar.create(0.0);
}
case 1: {
return SparseIndexedVector.createLength(shape[0]);
}
case 2: {
return Matrixx.createSparse(shape[0], shape[1]);
}
}
int sliceCount = shape[0];
int[] subshape = IntArrays.tailArray(shape);
ArrayList<INDArray> slices = new ArrayList<INDArray>(sliceCount);
INDArray sa = Arrayz.createSparseArray(subshape);
slices.add(sa);
for (int i = 1; i < sliceCount; ++i) {
slices.add(sa.sparseClone());
}
SliceArray<INDArray> m = SliceArray.create(slices);
return m;
}
public static void fillRandom(INDArray a, long seed) {
Vectorz.fillRandom(a.asVector(), seed);
}
public static void fillRandom(INDArray a, Random random) {
Vectorz.fillRandom(a.asVector(), random);
}
public static void fillNormal(INDArray a, long seed) {
Vectorz.fillNormal(a.asVector(), seed);
}
public static void fillNormal(INDArray a, Random random) {
Vectorz.fillNormal(a.asVector(), random);
}
}
| [
"[email protected]"
] | |
9ef28cb943f07828aca9d3439323b528086fff16 | ecde13c21233b0ab8dd48bc7c3a792a667b6b84a | /android/app/src/main/java/com/laureatetest/MainActivity.java | 1dddb3a79097ce1040fac09968d8c46ec767765c | [] | no_license | AJjandroZG/laureate-test | cf47e7e1e884d2c102b53cf4d061d4003b4523ef | 6a8f31c6673ead9231e1e2598c75a4f96adc14b6 | refs/heads/master | 2023-03-19T23:16:22.806422 | 2021-03-22T14:37:21 | 2021-03-22T14:37:21 | 350,373,781 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 352 | java | package com.laureatetest;
import com.facebook.react.ReactActivity;
public class MainActivity extends ReactActivity {
/**
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
@Override
protected String getMainComponentName() {
return "LaureateTest";
}
}
| [
"[email protected]"
] | |
7007a4c520d1873e9279563e478eebf117e47655 | 5cbddfc8f82670b0aec948090e968f2ccab1de6b | /core-services/src/com/free/coreservices/archiver/ArchiveJob.java | 96de91838cee70d0125bcbc5f9e86bae00c9736d | [] | no_license | thinkman1/miscellaneous | fe1fa4fc7e1b8479b2f13ef22f0d80d2c3b57a55 | 39eaa034cb62fa2e7adaa55e956059816b5c3053 | refs/heads/master | 2021-01-23T06:44:49.938590 | 2014-08-02T18:44:34 | 2014-08-02T18:44:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,760 | java | package com.free.coreservices.archiver;
import java.util.concurrent.TimeUnit;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.omg.CORBA.SystemException;
public class ArchiveJob extends ScheduledJob {
private static final Log LOG = LogFactory.getLog(ArchiveJob.class);
private ArchiveKickoffJob archiveKickoffJob;
private String targetQueue;
private LockManager lockManager;
private String baseDir;
public ArchiveJob() {
setLockDuration(30);
setLockDurationUnit(TimeUnit.SECONDS);
}
@Override
public String getName() {
return "ArchiveJob";
}
public void setLock(LockManager lockManager) {
this.lockManager=lockManager;
}
@Override
public void executeService(ExecutionContext arg0) throws SystemException {
boolean yesLock=lockManager.acquire("ARCHIVE "+baseDir , 2, TimeUnit.MINUTES);
if (yesLock){
try {
LOG.info("start archive publishing");
archiveKickoffJob.publishArchiveMessages(targetQueue);
LOG.info("hang out, we're done with publishing");
// if this runs too fast the other process can get a lock as soon as we're done
TimeUnit.SECONDS.sleep(30);
LOG.info("end archive publish");
} catch (Exception e){
throw new SystemException(e);
} finally {
lockManager.release("ARCHIVE "+baseDir);
}
} else {
LOG.info("could not acquire ARCHIVE "+baseDir );
}
}
public void setArchiveKickoffJob(ArchiveKickoffJob archiveKickoffJob) {
this.archiveKickoffJob = archiveKickoffJob;
}
public void setTargetQueue(String targetQueue) {
this.targetQueue = targetQueue;
}
public void setBaseDir(String baseDir) {
this.baseDir = baseDir;
}
}
| [
"[email protected]"
] | |
09008adcac7b18a789da962521693845a10bfa34 | ce29ae639da37c571cbbeac622b5d4ec67fcc58c | /fe/generated-sources/gen-java/com/cloudera/impala/thrift/TLogLevel.java | e3db30a917f72323a3a4d3f5fd1803bcf1d461e9 | [
"Apache-2.0"
] | permissive | dayutianfei/impala-Q | 703de4a0f6581401734b27b1f947ac1db718cb2e | 46af5ff8bf3e80999620db7bf0c9ffc93c8e5950 | refs/heads/master | 2021-01-10T11:54:57.584647 | 2016-02-17T15:39:09 | 2016-02-17T15:39:09 | 48,152,335 | 0 | 1 | null | 2016-03-09T17:02:07 | 2015-12-17T04:29:58 | C++ | UTF-8 | Java | false | true | 1,135 | java | /**
* Autogenerated by Thrift Compiler (0.9.0)
*
* DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
* @generated
*/
package com.cloudera.impala.thrift;
import java.util.Map;
import java.util.HashMap;
import org.apache.thrift.TEnum;
public enum TLogLevel implements org.apache.thrift.TEnum {
VLOG_3(0),
VLOG_2(1),
VLOG(2),
INFO(3),
WARN(4),
ERROR(5),
FATAL(6);
private final int value;
private TLogLevel(int value) {
this.value = value;
}
/**
* Get the integer value of this enum value, as defined in the Thrift IDL.
*/
public int getValue() {
return value;
}
/**
* Find a the enum type by its integer value, as defined in the Thrift IDL.
* @return null if the value is not found.
*/
public static TLogLevel findByValue(int value) {
switch (value) {
case 0:
return VLOG_3;
case 1:
return VLOG_2;
case 2:
return VLOG;
case 3:
return INFO;
case 4:
return WARN;
case 5:
return ERROR;
case 6:
return FATAL;
default:
return null;
}
}
}
| [
"[email protected]"
] | |
3b43f4527316d479c0e0dc29973100c2e447f750 | 42505f4c48c56ef0160f9e6316495ec232aeecb8 | /InventoryBillingSystem/src/fbp/model/Login.java | 1f90be0cfadc69304a91411280c3c87566ee7332 | [] | no_license | ankithmjain/Inventory-Billing-System | dc40bdd94d1b3b9cdbe3896b897aa6574a9250b2 | 21c5153dd353e688aac8ba49d39277fba12a6253 | refs/heads/master | 2021-01-10T13:54:53.851297 | 2016-10-26T22:06:51 | 2016-10-26T22:06:51 | 48,592,624 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 676 | java | package fbp.model;
public class Login {
private String username; //UserName at the login page
private String password; //password at the login page
//Empty Default constructor
public Login() {
}
//Fully parameterized constructor
public Login(String username, String password) {
this.username = username;
this.password = password;
}
//Getter Setter methods for each attribute of the class
public String getUserName() {
return username;
}
public void setUserName(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
}
| [
"[email protected]"
] | |
246f12cb10e26a475bffdddacb558c76e18c8a7d | 2c3d63c58a011a111927672c22e998559c4232bb | /largest.java | 41dd46b4c1ae2e94f4da0cee3a1ba3d58e1df392 | [] | no_license | VidyaJeyapaul/javachallenges | 34e7d957d65b085bfdcce928c99a862dca1ef90c | 84f23d375400bd2f2250533a687530ad893430b4 | refs/heads/master | 2021-01-21T22:53:22.430072 | 2017-09-23T15:47:19 | 2017-09-23T15:47:19 | 102,175,551 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 360 | java | package guvi;
import java.util.*;
/**
*
* @author vidya
*/
public class largest {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
int b=sc.nextInt();
int c=sc.nextInt();
int d=c>(a>b?a:b)?c:((a>b)?a:b);
System.out.print(d);
}
}
| [
"[email protected]"
] | |
aa2274299a2e839e440d0ce50b26ee72adb5bceb | aa7806b5543a35be5a59cc386194503a30c682e0 | /app/src/main/java/com/umanets/xylaritytestapp/util/DialogFactory.java | 118fecff69ca6aa873f5fb2acfd7b887aaf0c1e0 | [] | no_license | ko3ak1990/xylarityTestApp | 9c5c02387e85f8691f7744df80db001499dab836 | 54cd4c973d07570eb069dcea3dbb0c2a9ce14c2b | refs/heads/master | 2020-12-02T16:14:46.691879 | 2017-07-07T10:54:15 | 2017-07-07T10:54:15 | 96,430,966 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,121 | java | package com.umanets.xylaritytestapp.util;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Context;
import android.support.annotation.StringRes;
import android.support.v7.app.AlertDialog;
import com.umanets.xylaritytestapp.R;
public final class DialogFactory {
public static Dialog createSimpleOkErrorDialog(Context context, String title, String message) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context)
.setTitle(title)
.setMessage(message)
.setNeutralButton(R.string.dialog_action_ok, null);
return alertDialog.create();
}
public static Dialog createSimpleOkErrorDialog(Context context,
@StringRes int titleResource,
@StringRes int messageResource) {
return createSimpleOkErrorDialog(context,
context.getString(titleResource),
context.getString(messageResource));
}
public static Dialog createGenericErrorDialog(Context context, String message) {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(context)
.setTitle(context.getString(R.string.dialog_error_title))
.setMessage(message)
.setNeutralButton(R.string.dialog_action_ok, null);
return alertDialog.create();
}
public static Dialog createGenericErrorDialog(Context context, @StringRes int messageResource) {
return createGenericErrorDialog(context, context.getString(messageResource));
}
public static ProgressDialog createProgressDialog(Context context, String message) {
ProgressDialog progressDialog = new ProgressDialog(context);
progressDialog.setMessage(message);
return progressDialog;
}
public static ProgressDialog createProgressDialog(Context context,
@StringRes int messageResource) {
return createProgressDialog(context, context.getString(messageResource));
}
}
| [
"[email protected]"
] | |
e1f1a9dbcc0b9b005e4f2924924754dd881006ff | 44432868b36ba44ed9bd392e9f1a3aa49453ac73 | /AndroidJSONParsing/gen/com/androidhive/jsonparsing/R.java | 5bfe30b037eccf8d3e14122be6f491b266a7b2ab | [] | no_license | MayurKJParekh/Android_Apps_Example | 1539f256cff5c0a55504b8bb0d12681daa4929ef | 15d735b1a8dfb75b76c2ef425855191d890439cd | refs/heads/master | 2020-12-28T22:53:41.387120 | 2013-12-12T16:38:36 | 2013-12-12T16:38:36 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 893 | java | /* AUTO-GENERATED FILE. DO NOT MODIFY.
*
* This class was automatically generated by the
* aapt tool from the resource data it found. It
* should not be modified by hand.
*/
package com.androidhive.jsonparsing;
public final class R {
public static final class attr {
}
public static final class drawable {
public static final int ic_launcher=0x7f020000;
}
public static final class id {
public static final int name=0x7f050000;
public static final int name_label=0x7f050001;
}
public static final class layout {
public static final int list_item=0x7f030000;
public static final int main=0x7f030001;
public static final int single_list_item=0x7f030002;
}
public static final class string {
public static final int app_name=0x7f040001;
public static final int hello=0x7f040000;
}
}
| [
"[email protected]"
] | |
1b5a968544090d5616920dd4f81126e2efa0709d | 38753e78cb22e380986223442ca0e92997a91108 | /chapter_001/src/test/java/ru/job4j/calculate/CalcTest.java | c8664bfdb3a10a386958ec0377985456d279f3c8 | [
"Apache-2.0"
] | permissive | andrewnnov/job4j | 7f057abcc56d0089f260eb94d19e0088d9dc12f0 | 084acf540450f1daed0d502d4f26c0c4f2b70058 | refs/heads/master | 2021-06-18T00:00:11.784282 | 2021-02-18T19:56:03 | 2021-02-18T19:56:03 | 178,114,626 | 0 | 0 | Apache-2.0 | 2020-10-13T12:37:37 | 2019-03-28T02:55:26 | Java | UTF-8 | Java | false | false | 1,064 | java | package ru.job4j.calculate;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
public class CalcTest {
@Test
public void when2And2Equal4() {
Calc calc = new Calc();
double expectedRes = 4d;
double actualRes = calc.add(2d, 2d);
assertThat(actualRes, is(expectedRes));
}
@Test
public void when2And2And2Equal6() {
Calc calc = new Calc();
double expectedRes = 6d;
double actualRes = calc.add(2d, 2d, 2d);
assertThat(actualRes, is(expectedRes));
}
@Test
public void when5And5And5Equal15() {
Calc calc = new Calc();
double expectedRes = 15d;
double actualRes = calc.add(5d, 5d, 5d);
assertThat(actualRes, is(expectedRes));
}
@Test
public void when4x4ThenEqual16() {
Calc calc = new Calc();
double expectedRes = 16d;
double actualRes = calc.add(4d, 4d, 4d, 4d);
assertThat(actualRes, is(expectedRes));
}
}
| [
"[email protected]"
] | |
305ea564b23942577faaf78bd9f25fa081c89dc2 | aad06dc10d9f086dd8d38d85287234572295c50d | /src/main/java/org/onedatashare/server/model/filesystem/operations/OperationBase.java | 482ddbfe6cb42d0a4c448a89203b42315c0547e9 | [
"Apache-2.0"
] | permissive | didclab/onedatashare | 7611f3944b4cedd145e9de983631f4a387b2bf02 | de44a5bc1a6e829e017b1dd94655690dc6580208 | refs/heads/integration | 2023-08-31T08:45:12.361316 | 2023-08-17T02:35:07 | 2023-08-17T02:35:07 | 149,328,812 | 15 | 10 | Apache-2.0 | 2023-08-29T10:23:38 | 2018-09-18T17:42:24 | Java | UTF-8 | Java | false | false | 307 | java | package org.onedatashare.server.model.filesystem.operations;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class OperationBase {
protected String credId;
protected String path;
protected String id;
}
| [
"[email protected]"
] | |
acf7042e7a453796ce6f3b66310381e43d1e1b69 | 250080a05f719b0c6bfffa01a74e2b84beb80ecb | /src/main/java/org/cch/napa/entity/impl/LazyResultSetIterableImpl.java | 5adcde6f17b18059a66d39446e8e360f86e9fc05 | [] | no_license | CChampagne/napa | f23d43f2b2e04f8751563a3fe82eb4e911d661d7 | 8e1d86e8062d6c73af7cb82f214b8ee6a4c5a131 | refs/heads/master | 2023-05-24T18:12:19.434033 | 2020-12-21T01:22:38 | 2020-12-21T01:22:38 | 96,152,663 | 1 | 0 | null | 2023-05-23T20:13:44 | 2017-07-03T21:42:13 | Java | UTF-8 | Java | false | false | 2,945 | java | package org.cch.napa.entity.impl;
import org.cch.napa.entity.LazyResultSetIterable;
import org.cch.napa.exceptions.PersistenceException;
import org.cch.napa.exceptions.RuntimePersistenceException;
import org.cch.napa.mapper.RecordMapper;
import java.io.Closeable;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.NoSuchElementException;
/**
*
* @param <T> The Object type
*/
class LazyResultSetIterableImpl<T> implements LazyResultSetIterable<T> {
private LazyResultSetIterator<T> iterator;
public LazyResultSetIterableImpl(PreparedStatement preparedStatement, RecordMapper<T> mapper) throws org.cch.napa.exceptions.SQLException {
iterator = new LazyResultSetIterator<T>(preparedStatement, mapper);
}
public Iterator<T> iterator() {
return iterator;
}
public void close() throws IOException {
iterator.close();
}
private class LazyResultSetIterator<T> implements Iterator<T>, Closeable {
private ResultSet resultSet;
private RecordMapper<T> mapper;
private PreparedStatement preparedStatement;
private Boolean hasNext;
private boolean isClosed;
public LazyResultSetIterator(PreparedStatement preparedStatement, RecordMapper<T> mapper) throws org.cch.napa.exceptions.SQLException {
this.preparedStatement = preparedStatement;
try {
this.resultSet = preparedStatement.executeQuery();
} catch (SQLException ex) {
throw new org.cch.napa.exceptions.SQLException("Failed to execute query", ex);
}
this.mapper = mapper;
}
public boolean hasNext() {
if (hasNext != null) return hasNext;
try {
hasNext = resultSet.next();
if(!hasNext && !isClosed) {
isClosed = true;
preparedStatement.close();
}
return hasNext;
} catch (SQLException ex) {
ex.printStackTrace();
return hasNext = false;
}
}
public T next() {
T item = null;
if (hasNext == null) {
hasNext();
}
if(!hasNext) {
throw new NoSuchElementException();
}
hasNext = null;
try {
item = mapper.map(resultSet);
} catch (SQLException ex) {
throw new RuntimePersistenceException(ex);
} catch (PersistenceException ex) {
throw new RuntimePersistenceException(ex);
}
return item;
}
public void remove() {
throw new UnsupportedOperationException();
}
public void close() throws IOException {
}
}
}
| [
"[email protected]"
] | |
a605d415a2c3881f2a7f59dd1cc876f5727410f9 | 86cfd4ca1c06bb1b9ae83414ae6c1d6347216cd2 | /Collections/src/TestCollection/in/LinkList.java | 8733f329c586f3822db97c751e9758ddf3ae9d1e | [] | no_license | michaeljaan/Assignment | 02da56d0bd6089765c4827abadf874bf0fa277e8 | 5560fdc3cc510f55b06b84ca1ac2bd99e8366deb | refs/heads/master | 2020-03-23T19:56:00.858878 | 2018-08-03T12:47:21 | 2018-08-03T12:47:21 | 142,010,924 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,865 | java | package TestCollection.in;
import java.util.LinkedList;//Import all the packages
import java.util.List;
import in.com.cg.Car;
import in.com.cg.Cellphone;
import in.com.cg.Laptop;
import in.com.cg.School;
import in.com.cg.Television;
import java.util.*;
//Main function storing the array list
public class LinkList {
public static void main(String[] args)
{
List list=new LinkedList();//linked list declaration
list.add(new Car("Porsche","Cayman",2008,3000000));//Create a new Object of class Car and initialize the member instance
list.add(new Car("Audi","A8",2018,70000000));
list.add(new Car("Mahindra","Scorpio",2006,2000000));
list.add(new Laptop("Dell",3386,"DOS","i5"));//Create a new object of class Laptop and initialize the instance member
list.add(new Laptop("HP",786,"WINDOWS","i7"));
list.add(new Laptop("Apple",243,"MACOS","IOS"));
list.add(new Television("Panasonic","LCD","Yes",20000));//create a new object of class Television and initialize the instance member
list.add(new Television("Sony","LED","No",40000));
list.add(new Television("LG","Plasma","Yes",60000));
list.add(new Cellphone("Xiomi","Redmi Note5 Pro", "Leading mobile", "MIUI 10",15000));//create a new object of class cellPhone and initialize instance member
list.add(new Cellphone("Apple","iPhone X", "Best in industry", "IOS 12",75000));
list.add(new Cellphone("Huwaei","Honor 9 lite", "Budget mobile", "android",16000));
list.add(new School("SVN","Bengaluru","Bengaluru",1));//create a new object of class School and initialize the instance member
list.add(new School("VVS","Mysuru","Mandya",4));
list.add(new School("VVSSP","Mengaluru","Bengaluru",2));
list.stream().forEach((list1)->System.out.println(list1));//output all the data collected
}
}
| [
"[email protected]"
] | |
f2205b60a5f34fbf08e5f5314a1321b63dc4989c | 3efa417c5668b2e7d1c377c41d976ed31fd26fdc | /src/br/com/mind5/paymentPartner/partnerMoip/orderMoip/info/OrdmoipMergerVisiPayordem.java | d5268f29e07742bc0f586aa459a983d0c8d145b8 | [] | no_license | grazianiborcai/Agenda_WS | 4b2656716cc49a413636933665d6ad8b821394ef | e8815a951f76d498eb3379394a54d2aa1655f779 | refs/heads/master | 2023-05-24T19:39:22.215816 | 2023-05-15T15:15:15 | 2023-05-15T15:15:15 | 109,902,084 | 0 | 0 | null | 2022-06-29T19:44:56 | 2017-11-07T23:14:21 | Java | UTF-8 | Java | false | false | 878 | java | package br.com.mind5.paymentPartner.partnerMoip.orderMoip.info;
import java.util.ArrayList;
import java.util.List;
import br.com.mind5.info.InfoMergerVisitorTemplate;
import br.com.mind5.payment.payOrderItem.info.PayordemInfo;
final class OrdmoipMergerVisiPayordem extends InfoMergerVisitorTemplate<OrdmoipInfo, PayordemInfo> {
@Override public boolean shouldMerge(OrdmoipInfo baseInfo, PayordemInfo selectedInfo) {
return (baseInfo.codOwner == selectedInfo.codOwner &&
baseInfo.codPayOrder == selectedInfo.codPayOrder &&
baseInfo.codPayOrderItem == selectedInfo.codPayOrderItem );
}
@Override public List<OrdmoipInfo> merge(OrdmoipInfo baseInfo, PayordemInfo selectedInfo) {
List<OrdmoipInfo> results = new ArrayList<>();
baseInfo.payordemData = selectedInfo;
results.add(baseInfo);
return results;
}
}
| [
"[email protected]"
] | |
2d376b39a90e07fe280e4d2bed398e1da18befb4 | f0ee3224df8d0423789492f792a8c725e4d76e4d | /TestServlet/src/com/test/config/InitialisationDaoFactory.java | 35940e6a0b81c35e904d59229a2f377a5e1ed75c | [] | no_license | john26-creator/JavaProject | 69f646e5ea63f11ae4d8cf60efc2172c1b949bc1 | 63ba291422b9b294c217ec23e31c78470d80383f | refs/heads/master | 2020-12-08T19:24:42.490021 | 2020-01-10T15:51:02 | 2020-01-10T15:51:02 | 233,073,386 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 977 | java | package com.test.config;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import com.test.dao.DaoFactory;
public class InitialisationDaoFactory implements ServletContextListener {
private static final String ATT_DAO_FACTORY = "daofactory";
private DaoFactory daoFactory;
@Override
public void contextInitialized( ServletContextEvent event ) {
/* Rรฉcupรฉration du ServletContext lors du chargement de l'application */
ServletContext servletContext = event.getServletContext();
/* Instanciation de notre DAOFactory */
this.daoFactory = DaoFactory.getInstance();
/* Enregistrement dans un attribut ayant pour portรฉe toute l'application */
servletContext.setAttribute( ATT_DAO_FACTORY, this.daoFactory );
}
@Override
public void contextDestroyed( ServletContextEvent event ) {
/* Rien ร rรฉaliser lors de la fermeture de l'application... */
}
}
| [
"[email protected]"
] | |
b11dbb1c61e91a930cce4d63d14cd0dc30a020d3 | 13ea5da0b7b8d4ba87d622a5f733dcf6b4c5f1e3 | /crash-reproduction-ws/results/MATH-51b-1-28-Single_Objective_GGA-WeightedSum/org/apache/commons/math/analysis/solvers/BaseAbstractUnivariateRealSolver_ESTest.java | c1e8e3b5a5a17c6e17217e8703540fe318826d48 | [
"MIT",
"CC-BY-4.0"
] | permissive | STAMP-project/Botsing-basic-block-coverage-application | 6c1095c6be945adc0be2b63bbec44f0014972793 | 80ea9e7a740bf4b1f9d2d06fe3dcc72323b848da | refs/heads/master | 2022-07-28T23:05:55.253779 | 2022-04-20T13:54:11 | 2022-04-20T13:54:11 | 285,771,370 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 821 | java | /*
* This file was automatically generated by EvoSuite
* Fri Jan 17 22:50:36 UTC 2020
*/
package org.apache.commons.math.analysis.solvers;
import org.junit.Test;
import static org.junit.Assert.*;
import static org.evosuite.runtime.EvoAssertions.*;
import org.apache.commons.math.analysis.solvers.NewtonSolver;
import org.evosuite.runtime.EvoRunner;
import org.evosuite.runtime.EvoRunnerParameters;
import org.junit.runner.RunWith;
@RunWith(EvoRunner.class) @EvoRunnerParameters(useVFS = true, useJEE = true)
public class BaseAbstractUnivariateRealSolver_ESTest extends BaseAbstractUnivariateRealSolver_ESTest_scaffolding {
@Test(timeout = 4000)
public void test0() throws Throwable {
NewtonSolver newtonSolver0 = new NewtonSolver();
// Undeclared exception!
newtonSolver0.doSolve();
}
}
| [
"[email protected]"
] | |
edab458159952e67fff2cf939c3ddccf86f5ee45 | b2840fb25fa4b4a72ded285ecf89cbb4faf55dd7 | /src/main/java/com/yangk/selflearn/designpattern/proxy/Subject.java | 54421ba0be5e973bbdcee04ccbaff96c32156483 | [] | no_license | beimingyouyu666/self-learn | f77c95f35dd97c9e2c6fcde8f24f86f44a8d1ae7 | d20b47f034be110316be627f7031105e84b1d923 | refs/heads/master | 2023-06-29T20:11:39.421310 | 2022-04-06T14:13:51 | 2022-04-06T14:13:51 | 219,266,868 | 0 | 0 | null | 2023-06-14T22:26:04 | 2019-11-03T07:36:51 | Java | UTF-8 | Java | false | false | 232 | java | package com.yangk.selflearn.designpattern.proxy;
/**
* @Description ไปฃ็็ฑปๆฅๅฃ
* @Author yangkun
* @Date 2019/10/17
* @Version 1.0
* @blame yangkun
*/
public interface Subject {
void doSomething();
}
| [
"[email protected]"
] | |
21968bce9755e4c86a519ec491eb7d7177622c5e | dc5459ac2dfd8647cdbed41b2f41607f7007e660 | /app/src/main/java/com/vvm/sh/repositorios/ImagemRepositorio.java | 38c469bfc243c0181a51593340bfd2542644ca2e | [] | no_license | ArtemisSoftware/VVM-SH | 5961540712193620291ecf3427181579bb6229b9 | d433a6821bcd4c4f9a41ab25f664e72251b83d63 | refs/heads/master | 2021-07-05T06:57:05.535395 | 2021-02-22T15:53:14 | 2021-02-22T15:54:10 | 237,837,228 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,107 | java | package com.vvm.sh.repositorios;
import androidx.annotation.NonNull;
import com.vvm.sh.baseDados.dao.ImagemDao;
import com.vvm.sh.baseDados.dao.ResultadoDao;
import com.vvm.sh.baseDados.entidades.ImagemResultado;
import com.vvm.sh.ui.imagens.modelos.ImagemRegisto;
import com.vvm.sh.util.constantes.Identificadores;
import com.vvm.sh.util.constantes.TiposConstantes;
import java.util.List;
import io.reactivex.Completable;
import io.reactivex.Observable;
import io.reactivex.Single;
public class ImagemRepositorio implements Repositorio<ImagemResultado>{
private final ImagemDao imagemDao;
public final ResultadoDao resultadoDao;
public ImagemRepositorio(@NonNull ImagemDao imagemDao, @NonNull ResultadoDao resultadoDao) {
this.imagemDao = imagemDao;
this.resultadoDao = resultadoDao;
}
public Observable<List<ImagemRegisto>> obterImagemLevantamento(int idLevantamento) {
return imagemDao.obterImagemLevantamento(idLevantamento);
}
public Observable<List<ImagemRegisto>> obterGaleria(int id, int origem) {
return imagemDao.obterGaleria(id, origem);
}
public Observable<List<ImagemRegisto>> obterCapasRelatorio(int idTarefa) {
return imagemDao.obterGaleria(idTarefa);
}
public Completable fixarCapaRelatorio(int idTarefa, int idImagem){
Completable removerCapaRelatorio = imagemDao.removerCapaRelatorio(idTarefa);
Completable inserirCapaRelatorio = imagemDao.fixarCapaRelatorio(idImagem);
Completable completable = Completable.concatArray(removerCapaRelatorio, inserirCapaRelatorio);
return completable;
}
public Completable removerCapaRelatorio(int idTarefa){
return imagemDao.removerCapaRelatorio(idTarefa);
}
@Override
public Single<Long> inserir(ImagemResultado item) {
return imagemDao.inserir(item);
}
@Override
public Single<Integer> atualizar(ImagemResultado item) {
return null;
}
@Override
public Single<Integer> remover(ImagemResultado item) {
return imagemDao.remover(item);
}
}
| [
"[email protected]"
] | |
a89382b52848bfbafa12f73d60a9422bd2ea4546 | 6847009063cfa9a08511a4772515eaf3c9e10921 | /huoxin/daimeng_android/daimengLive/src/main/java/com/daimeng/live/widget/CircleImageView.java | 5bf02f9be70e0e796c28406ff0647f90634db08f | [] | no_license | P79N6A/huoxin | 80a92564b34bd9f3afba2042ff8a747d6d3f70dc | 649219a5d15d17dcbc78e900cc44201befc8e321 | refs/heads/master | 2020-05-24T07:26:52.563938 | 2019-05-17T06:18:43 | 2019-05-17T06:18:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,479 | java | package com.daimeng.live.widget;
import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.RectF;
import android.graphics.Shader;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import com.daimeng.live.utils.ImageUtils;
import com.daimeng.live.R;
/**
* ้ฆๅ่ฐImageView็ผๅชๆฌข
*
*/
public class CircleImageView extends ImageView {
private static final ScaleType SCALE_TYPE = ScaleType.CENTER_CROP;
private static final Bitmap.Config BITMAP_CONFIG = Bitmap.Config.ARGB_8888;
private static final int COLORDRAWABLE_DIMENSION = 1;
private static final int DEFAULT_BORDER_WIDTH = 0;
private static final int DEFAULT_BORDER_COLOR = Color.BLACK;
private final RectF mDrawableRect = new RectF();
private final RectF mBorderRect = new RectF();
private final Matrix mShaderMatrix = new Matrix();
private final Paint mBitmapPaint = new Paint();
private final Paint mBorderPaint = new Paint();
private int mBorderColor = DEFAULT_BORDER_COLOR;
private int mBorderWidth = DEFAULT_BORDER_WIDTH;
private Bitmap mBitmap;
private BitmapShader mBitmapShader;
private int mBitmapWidth;
private int mBitmapHeight;
private float mDrawableRadius;
private float mBorderRadius;
private boolean mReady;
private boolean mSetupPending;
//็ๆ็ฃ
private int mCorner = 0;
//ๆฆๆจฟ๎
ป้ๅงใ้ฆๅ่ฐ
private boolean isDisplayCircle = true;
private Bitmap mCornerBitmap;
public CircleImageView(Context context) {
this(context, null);
}
public CircleImageView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CircleImageView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
super.setScaleType(SCALE_TYPE);
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CircleImageView, defStyle, 0);
mBorderWidth = a.getDimensionPixelSize(R.styleable.CircleImageView_border_width, DEFAULT_BORDER_WIDTH);
mBorderColor = a.getColor(R.styleable.CircleImageView_border_color, DEFAULT_BORDER_COLOR);
a.recycle();
mReady = true;
if (mSetupPending) {
setup();
mSetupPending = false;
}
}
@Override
public ScaleType getScaleType() {
return SCALE_TYPE;
}
@Override
public void setScaleType(ScaleType scaleType) {
if (scaleType != SCALE_TYPE) {
throw new IllegalArgumentException(String.format("ScaleType %s not supported.", scaleType));
}
}
@Override
protected void onDraw(Canvas canvas) {
if(!isDisplayCircle) {
super.onDraw(canvas);
return;
}
if (getDrawable() == null) {
return;
}
canvas.drawCircle(getWidth() / 2, getHeight() / 2, mDrawableRadius, mBitmapPaint);
if(mBorderWidth != 0){
canvas.drawCircle(getWidth() / 2, getHeight() / 2, mBorderRadius, mBorderPaint);
}
//็ๅง็็ๆ็ฃ
if(mCorner != 0){
canvas.save();
Resources res = getResources();
Bitmap bmp = BitmapFactory.decodeResource(res, mCorner);
// ๅฏฐๆฅๅ้ๆฎๆฎ้ฅๅงๅข
Bitmap newbm = ImageUtils.scaleBitmap(bmp,40,40);
canvas.drawBitmap(newbm,getMeasuredWidth()-40,getMeasuredHeight()-40,mBitmapPaint);
canvas.restore();
}
if(mCornerBitmap != null){
canvas.save();
// ๅฏฐๆฅๅ้ๆฎๆฎ้ฅๅงๅข
Bitmap newbm = ImageUtils.scaleBitmap(mCornerBitmap,40,40);
canvas.drawBitmap(newbm,getMeasuredWidth()-40,getMeasuredHeight()-40,mBitmapPaint);
canvas.restore();
}
}
public void setCorner(int img){
mCorner = img;
}
public void setCorner(Bitmap bitmap){
mCornerBitmap = bitmap;
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
setup();
}
public void setDisplayCircle(boolean isDisplayCircle) {
this.isDisplayCircle = isDisplayCircle;
}
public int getBorderColor() {
return mBorderColor;
}
public void setBorderColor(int borderColor) {
if (borderColor == mBorderColor) {
return;
}
mBorderColor = borderColor;
mBorderPaint.setColor(mBorderColor);
invalidate();
}
public int getBorderWidth() {
return mBorderWidth;
}
public void setBorderWidth(int borderWidth) {
if (borderWidth == mBorderWidth) {
return;
}
mBorderWidth = borderWidth;
setup();
}
@Override
public void setImageBitmap(Bitmap bm) {
super.setImageBitmap(bm);
mBitmap = bm;
setup();
}
@Override
public void setImageDrawable(Drawable drawable) {
super.setImageDrawable(drawable);
mBitmap = getBitmapFromDrawable(drawable);
setup();
}
@Override
public void setImageResource(int resId) {
super.setImageResource(resId);
mBitmap = getBitmapFromDrawable(getDrawable());
setup();
}
private Bitmap getBitmapFromDrawable(Drawable drawable) {
if (drawable == null) {
return null;
}
if (drawable instanceof BitmapDrawable) {
return ((BitmapDrawable) drawable).getBitmap();
}
try {
Bitmap bitmap;
if (drawable instanceof ColorDrawable) {
bitmap = Bitmap.createBitmap(COLORDRAWABLE_DIMENSION, COLORDRAWABLE_DIMENSION, BITMAP_CONFIG);
} else {
bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(), BITMAP_CONFIG);
}
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);
return bitmap;
} catch (OutOfMemoryError e) {
return null;
}
}
private void setup() {
if (!mReady) {
mSetupPending = true;
return;
}
if (mBitmap == null) {
return;
}
mBitmapShader = new BitmapShader(mBitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
mBitmapPaint.setAntiAlias(true);
mBitmapPaint.setShader(mBitmapShader);
mBorderPaint.setStyle(Paint.Style.STROKE);
mBorderPaint.setAntiAlias(true);
mBorderPaint.setColor(mBorderColor);
mBorderPaint.setStrokeWidth(mBorderWidth);
mBitmapHeight = mBitmap.getHeight();
mBitmapWidth = mBitmap.getWidth();
mBorderRect.set(0, 0, getWidth(), getHeight());
mBorderRadius = Math.min((mBorderRect.height() - mBorderWidth) / 2, (mBorderRect.width() - mBorderWidth) / 2);
mDrawableRect.set(mBorderWidth, mBorderWidth, mBorderRect.width() - mBorderWidth, mBorderRect.height() - mBorderWidth);
mDrawableRadius = Math.min(mDrawableRect.height() / 2, mDrawableRect.width() / 2);
updateShaderMatrix();
invalidate();
}
private void updateShaderMatrix() {
float scale;
float dx = 0;
float dy = 0;
mShaderMatrix.set(null);
if (mBitmapWidth * mDrawableRect.height() > mDrawableRect.width() * mBitmapHeight) {
scale = mDrawableRect.height() / (float) mBitmapHeight;
dx = (mDrawableRect.width() - mBitmapWidth * scale) * 0.5f;
} else {
scale = mDrawableRect.width() / (float) mBitmapWidth;
dy = (mDrawableRect.height() - mBitmapHeight * scale) * 0.5f;
}
mShaderMatrix.setScale(scale, scale);
mShaderMatrix.postTranslate((int) (dx + 0.5f) + mBorderWidth, (int) (dy + 0.5f) + mBorderWidth);
mBitmapShader.setLocalMatrix(mShaderMatrix);
}
} | [
"[email protected]"
] | |
f6237e930c7d2927ec08077a9afbe996143c32e9 | fb3bfebe89b1725b849caaa2fa173012e106269a | /operators/Bitwise.java | 33203229cf64cd9e1b08b2055942c15d7c51e740 | [] | no_license | Asheshs/Javas | 33474df59d8b489ec1974e79a1af8359229cd633 | 591d89f7ce09c8ceb5750fe1bee761ada83c6493 | refs/heads/master | 2020-04-12T17:45:44.003939 | 2019-02-01T09:11:57 | 2019-02-01T09:11:57 | 162,656,229 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 244 | java | class Bitwise
{
public static void main(String[]args)
{
int a=50;
int b=60;
a = a ^ b;
b = a ^ b;
a = a ^ b;
System.out.println(a);
System.out.println(b);
}
} | [
"[email protected]"
] | |
1dd29ee648667403f6dd71aa29d3abccfa8ede4f | f124fd4b4f17ca1fde168b9060b33b4d8536cf30 | /blogpessoal-api/src/main/java/org/blogPessoal/blogPessoalapi/model/UsuarioLogin.java | f2348fa9823051fe088c33165f436d2bda2f708b | [] | no_license | witermendonca/BlogPessoal-Back-End-Java | 6bd95d76ae7ba8beb40580c645246d82e66a7c51 | a1c13aad6166fa09bea971431d242748ecfba64a | refs/heads/main | 2023-03-23T18:51:18.837576 | 2021-03-16T22:33:47 | 2021-03-16T22:33:47 | 348,510,051 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 995 | java | package org.blogPessoal.blogPessoalapi.model;
public class UsuarioLogin {
private long id;
private String nome;
private String usuario;
private String senha;
private String token;
private String foto;
private String tipo;
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public String getUsuario() {
return usuario;
}
public void setUsuario(String usuario) {
this.usuario = usuario;
}
public String getSenha() {
return senha;
}
public void setSenha(String senha) {
this.senha = senha;
}
public String getToken() {
return token;
}
public void setToken(String token) {
this.token = token;
}
public String getFoto() {
return foto;
}
public void setFoto(String foto) {
this.foto = foto;
}
public String getTipo() {
return tipo;
}
public void setTipo(String tipo) {
this.tipo = tipo;
}
} | [
"[email protected]"
] | |
aef2d5d93b80b68b2bd6c8a573737e25e6b5d13d | 36155fc6d1b1cd36edb4b80cb2fc2653be933ebd | /lc/src/LC/SOL/Heaters.java | 705972353fab2580f76380c0a93471d721b56942 | [] | no_license | Delon88/leetcode | c9d46a6e29749f7a2c240b22e8577952300f2b0f | 84d17ee935f8e64caa7949772f20301ff94b9829 | refs/heads/master | 2021-08-11T05:52:28.972895 | 2021-08-09T03:12:46 | 2021-08-09T03:12:46 | 96,177,512 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 706 | java | package LC.SOL;
import java.util.Arrays;
public class Heaters {
public class Solution {
public int findRadius(int[] houses, int[] heaters) {
Arrays.sort(houses);
Arrays.sort(heaters);
int i = 0, j = 0;
int ret = 0;
while ( i < houses.length ) {
// find nearest heater
while ( j < heaters.length - 1 && Math.abs( houses[i] - heaters[j] ) >=
Math.abs(houses[i] - heaters[j + 1])) {
j++;
}
ret = Math.max( ret , Math.abs(houses[i] - heaters[j]));
i++;
}
return ret;
}
}
}
| [
"[email protected]"
] | |
02e31934f57a6277a1726e6cf1916111738015ed | 99090fab5893eabd84631c754ad8bdb8e12992af | /app/src/main/java/com/projects/cactus/maskn/navdrawer/AboutAppFragment.java | f606b031629bffb1081b9dce3aa456419be67ff4 | [] | no_license | BishoyAbd/Semsar | d54f7d729b6b9d37f9423c68db6b17cc9da34559 | aaf73a7a635dbb646e868642c692e59e6008069a | refs/heads/master | 2021-05-14T09:00:50.875923 | 2018-01-05T00:20:49 | 2018-01-05T00:20:49 | 116,316,981 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 890 | java | package com.projects.cactus.maskn.navdrawer;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.projects.cactus.maskn.R;
/**
* Created by bisho on 11/18/2017.
*/
public class AboutAppFragment extends Fragment {
public static final String TAG = "about_app_fragment";
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.about_app_fragment, container, false);
return view;
}
}
| [
"[email protected]"
] | |
32f058ea9a2cf4d726f3621a5ad5ad359c903320 | 9d7e6fe4cf61160d7e8576bfd19cb518fd6837c0 | /app/src/main/java/com/tangchaoke/yiyoubangjiao/adapter/FindTeacherInPopAdapter.java | ad45b82df461d8a797b9902358e711e8713c59bd | [] | no_license | 2403102119/YiYouBangJiao | 445eb88c03b2b743b54e462aa0696322969c21e4 | 979d5991dc4e689b142845fd1561ae90e9683449 | refs/heads/master | 2020-06-07T01:52:09.020023 | 2019-06-20T09:55:22 | 2019-06-20T09:55:22 | 192,895,027 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,689 | java | package com.tangchaoke.yiyoubangjiao.adapter;
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.LinearLayout;
import android.widget.TextView;
import com.tangchaoke.yiyoubangjiao.R;
import com.tangchaoke.yiyoubangjiao.hg.HGTool;
import java.util.List;
/**
* Created by Administrator on 2018/3/10.
*/
public class FindTeacherInPopAdapter extends RecyclerView.Adapter<FindTeacherInPopAdapter.MyViewHold> {
private LayoutInflater mLayoutInflater;
private Context mContext;
List<String> mGradeList;
private OnItemClickListener mOnItemClickListener;
private int mSelectedPos = -1;//ไฟๅญๅฝๅ้ไธญ็position ้็น!
public void setOnItemCilckLisener(OnItemClickListener mOnItemClickListener) {
this.mOnItemClickListener = mOnItemClickListener;
}
public FindTeacherInPopAdapter(int mSelectedPos, Context mContext, List<String> mGradeList, OnItemClickListener mOnItemClickListener) {
this.mSelectedPos = mSelectedPos;
this.mContext = mContext;
this.mGradeList = mGradeList;
this.mOnItemClickListener = mOnItemClickListener;
this.mLayoutInflater = LayoutInflater.from(mContext);
}
@Override
public MyViewHold onCreateViewHolder(ViewGroup parent, int viewType) {
return new MyViewHold(mLayoutInflater.inflate(R.layout.item_find_teacher_pop, parent, false));
}
@Override
public void onBindViewHolder(MyViewHold holder, int position) {
}
@Override
public void onBindViewHolder(MyViewHold holder, int position, List<Object> payloads) {
super.onBindViewHolder(holder, position, payloads);
if (payloads.isEmpty()) {
//payloadsๅณๆๆ่ด่ฝฝ๏ผ
// ๅฝ้ฆๆฌกๅ ่ฝฝๆ่ฐ็จnotifyDatasetChanged() ,
// notifyItemChange(int position)่ฟ่กๅทๆฐๆถ๏ผ
// payloadsไธบempty ๅณ็ฉบ
holder.mLlOnclick.setBackgroundResource(R.drawable.shape_light_gray_fillet_5);
holder.mTvReleaseGrade.setTextColor(mContext.getResources().getColor(R.color.color666666));
} else {
//ๅฝ่ฐ็จnotifyItemChange(int position, Object payload)่ฟ่กๅธๅฑๅทๆฐๆถ๏ผ
// payloadsไธไผempty ๏ผ
// ๆไปฅ็ๆญฃ็ๅธๅฑๅทๆฐๅบ่ฏฅๅจ่ฟ้ๅฎ็ฐ ้็น๏ผ
holder.mLlOnclick.setBackgroundResource(R.drawable.shape_light_gray_fillet_5);
holder.mTvReleaseGrade.setTextColor(mContext.getResources().getColor(R.color.color666666));
}
if (!HGTool.isEmpty(mGradeList.get(position))) {
holder.mTvReleaseGrade.setText(mGradeList.get(position));
}
}
@Override
public int getItemCount() {
return mGradeList.size();
}
public class MyViewHold extends RecyclerView.ViewHolder implements View.OnClickListener {
LinearLayout mLlOnclick;
TextView mTvReleaseGrade;
public MyViewHold(View itemView) {
super(itemView);
mLlOnclick = itemView.findViewById(R.id.ll_onclick);
mLlOnclick.setOnClickListener(this);
mTvReleaseGrade = itemView.findViewById(R.id.tv_release_grade);
}
@Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.ll_onclick:
mOnItemClickListener.onItemClick(getLayoutPosition(), view);
break;
}
}
}
public interface OnItemClickListener {
public void onItemClick(int position, View view);
}
} | [
"[email protected]"
] | |
345b27820d1e28e4f57a776401a146cc9ed7fb7e | 6592455ae6b2902db48cee095952906159bf3416 | /CU009_JavaIniciacion/src/edu/masterjava/javainiciacion/tarea06/DiscoDuro.java | ca9a431e58aa793bcf56db4b71489282fb8f3500 | [] | no_license | charques/master-java-elite | 1352f7730feda2e226966dd768cf63a774b54294 | 5a979461a5a6b5c4e39147a7848b0da2e07f5918 | refs/heads/master | 2021-01-25T05:21:33.381086 | 2013-10-01T20:38:15 | 2013-10-01T20:38:15 | 13,224,627 | 1 | 0 | null | null | null | null | MacCentralEurope | Java | false | false | 1,972 | java | package edu.masterjava.javainiciacion.tarea06;
/**
*
* Clase que representa un disco duro.
*
* @author carloshernandezarques
*
*/
public class DiscoDuro {
/**
* Nรบmero de cilindros.
*/
private int cilindros;
/**
* Nรบmero de pistas por cilindro.
*/
private int pistas;
/**
* Nรบmero de sectores por pista.
*/
private int sectores;
/**
* Nรบmero de bytes por sector.
*/
private int bytes;
/**
* Constructor.
*/
public DiscoDuro(int pCilindros, int pPistas, int pSectores, int pBytes) {
this.cilindros = pCilindros;
this.pistas = pPistas;
this.sectores = pSectores;
this.bytes = pBytes;
}
/**
* Capacidad del disco en Bytes.
*
* @return
*/
public double capacidadB() {
return cilindros * pistas * sectores * bytes;
}
/**
* Capacidad del disco en KB.
*
* @return
*/
public double capacidadKB() {
return capacidadB() / 1024;
}
/**
* Capacidad del disco en MB.
*
* @return
*/
public double capacidadMB() {
return capacidadKB() / 1024;
}
/**
* Capacidad del disco en GB.
*
* @return
*/
public double capacidadGB() {
return capacidadMB() / 1024;
}
/**
* @return the cilindros
*/
public int getCilindros() {
return cilindros;
}
/**
* @param cilindros the cilindros to set
*/
public void setCilindros(int cilindros) {
this.cilindros = cilindros;
}
/**
* @return the pistas
*/
public int getPistas() {
return pistas;
}
/**
* @param pistas the pistas to set
*/
public void setPistas(int pistas) {
this.pistas = pistas;
}
/**
* @return the sectores
*/
public int getSectores() {
return sectores;
}
/**
* @param sectores the sectores to set
*/
public void setSectores(int sectores) {
this.sectores = sectores;
}
/**
* @return the bytes
*/
public int getBytes() {
return bytes;
}
/**
* @param bytes the bytes to set
*/
public void setBytes(int bytes) {
this.bytes = bytes;
}
}
| [
"[email protected]"
] | |
0d61ace9dc8dc4bc46e8f088aaf412e33f398f5c | aac6d48cb2456386495ff707d2c9e7731db78b29 | /app/src/main/java/com/udacity/and/popularmovies/models/Movie.java | f75b87ed57ef664589ec053e89558738a3428856 | [] | no_license | GGcNeaR/and-popular-movies-part1 | 2acefdfdc755024a72539d896eb3eff4ba6173d9 | c4b151bc293a83a12bb42e3650d18d6ec28bca2e | refs/heads/master | 2021-01-24T16:14:35.299630 | 2018-02-28T20:13:19 | 2018-02-28T20:13:19 | 123,177,392 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,895 | java | package com.udacity.and.popularmovies.models;
import android.os.Parcel;
import android.os.Parcelable;
public class Movie implements Parcelable {
public static final String MOVIE_EXTRA = "MOVIE_EXTRA";
private int id;
private String title;
private String overview;
private String posterPath;
private String releaseDate;
private String originalLanguage;
private String originalTitle;
private int[] genreIds;
private int voteCount;
private double voteAverage;
private double popularity;
private String backdropPath;
private boolean isAdult;
public Movie(int id, String title, String overview, String posterPath, String releaseDate,
String originalLanguage, String originalTitle, int[] genreIds,
int voteCount, double voteAverage, double popularity,
String backdropPath, boolean isAdult) {
this.id = id;
this.title = title;
this.overview = overview;
this.posterPath = posterPath;
this.releaseDate = releaseDate;
this.originalLanguage = originalLanguage;
this.originalTitle = originalTitle;
this.genreIds = genreIds;
this.voteCount = voteCount;
this.voteAverage = voteAverage;
this.popularity = popularity;
this.backdropPath = backdropPath;
this.isAdult = isAdult;
}
public int getId() {
return id;
}
public String getTitle() {
return title;
}
public String getOverview() {
return overview;
}
public String getPosterPath() {
return posterPath;
}
public String getReleaseDate() {
return releaseDate;
}
public String getOriginalLanguage() {
return originalLanguage;
}
public String getOriginalTitle() {
return originalTitle;
}
public int[] getGenreIds() {
return genreIds;
}
public int getVoteCount() {
return voteCount;
}
public double getVoteAverage() {
return voteAverage;
}
public double getPopularity() {
return popularity;
}
public String getBackdropPath() {
return backdropPath;
}
public boolean isAdult() {
return isAdult;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(id);
dest.writeString(title);
dest.writeString(overview);
dest.writeString(posterPath);
dest.writeString(releaseDate);
dest.writeString(originalLanguage);
dest.writeString(originalTitle);
dest.writeInt(genreIds.length);
dest.writeIntArray(genreIds);
dest.writeInt(voteCount);
dest.writeDouble(voteAverage);
dest.writeDouble(popularity);
dest.writeString(backdropPath);
dest.writeByte((byte)(isAdult ? 1 : 0));
}
public static final Parcelable.Creator<Movie> CREATOR
= new Parcelable.Creator<Movie>() {
public Movie createFromParcel(Parcel in) {
return new Movie(in);
}
public Movie[] newArray(int size) {
return new Movie[size];
}
};
private Movie(Parcel in) {
this.id = in.readInt();
this.title = in.readString();
this.overview = in.readString();
this.posterPath = in.readString();
this.releaseDate = in.readString();
this.originalLanguage = in.readString();
this.originalTitle = in.readString();
this.genreIds = new int[in.readInt()];
in.readIntArray(this.genreIds);
this.voteCount = in.readInt();
this.voteAverage = in.readDouble();
this.popularity = in.readDouble();
this.backdropPath = in.readString();
this.isAdult = in.readByte() != 0;
}
}
| [
"[email protected]"
] | |
93178741690c99ecd135d64435fdb9c718123445 | 1147e74b85f97bd94446db577af45525cf2a69e0 | /src/main/java/ru/gbax/messaging/controller/UserController.java | 9852754ef1e39673a6fa1090b035e188e85e3d4b | [] | no_license | gbax/messaging-rest-service | b52429766097d53040b0d38aa9d75723be98f6f5 | 6d7907264859974a4f353e4cee4e83746dc5c646 | refs/heads/master | 2021-01-25T12:14:05.503475 | 2015-07-26T14:59:23 | 2015-07-26T14:59:23 | 39,728,116 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,608 | java | package ru.gbax.messaging.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.web.authentication.WebAuthenticationDetails;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import ru.gbax.messaging.entity.User;
import ru.gbax.messaging.entity.model.ChangePasswordModel;
import ru.gbax.messaging.entity.model.CheckModel;
import ru.gbax.messaging.entity.model.RegistrationDataModel;
import ru.gbax.messaging.entity.model.UserModel;
import ru.gbax.messaging.exceptions.ServiceErrorException;
import ru.gbax.messaging.utils.AuthenticationProvider;
import ru.gbax.messaging.services.UserService;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
/**
* ะะพะฝััะพะปะปะตั ะดะปั ัะฐะฑะพัั ั ะฟะพะปัะทะพะฒะฐัะตะปัะผะธ
*/
@Controller
@RequestMapping(value = "/user")
public class UserController {
private static final Logger logger = LoggerFactory.getLogger(UserController.class);
@Autowired
private UserService userService;
@Autowired
private AuthenticationProvider authenticationProvider;
/**
* ะะฑัะฐะฑะพัะบะฐ ะพัะธะฑะบะธ ะฝะฐ ัะตัะฒะตัะต
*
* @param e ะธัะบะปััะตะฝะธะต ServiceErrorException
* @param writer ะฟะพัะพะบ ะดะปั ะฒัะฒะพะดะฐ ัะพะพะฑัะตะฝะธั
* @throws IOException
*/
@ExceptionHandler(ServiceErrorException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody
public void handleException(final ServiceErrorException e, Writer writer) throws IOException {
logger.error(e.getMessage(), e);
writer.write(String.format("{\"error\":\"%s\"}", e.getMessage()));
}
@RequestMapping(value = "/checkDuplicate/{login}", method = RequestMethod.GET)
@ResponseBody
public CheckModel checkDuplicate(@PathVariable("login") String login) {
final List<User> usersByLogin = userService.getUsersByLogin(login);
return new CheckModel(usersByLogin.size() > 0);
}
@RequestMapping(value = "/getUsers", method = RequestMethod.GET)
@ResponseBody
public List<UserModel> getUsers() {
return userService.getUsers();
}
@RequestMapping(value = "/getUsersNotInList", method = RequestMethod.GET)
@ResponseBody
public List<UserModel> getUsersNotInList() {
return userService.getUsersNotInList();
}
@RequestMapping(value = "/addNew/{id}", method = RequestMethod.GET)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public void addNew(@PathVariable("id")Long id) {
userService.addNew(id);
}
@RequestMapping(value = "/deleteFromList/{id}", method = RequestMethod.DELETE)
@ResponseBody
@ResponseStatus(HttpStatus.OK)
public void deleteFromList(@PathVariable("id") Long id) {
userService.deleteFromList(id);
}
@RequestMapping(value = "/register", method = RequestMethod.POST)
@ResponseBody
public CheckModel register(@RequestBody RegistrationDataModel dataModel, HttpServletRequest request) throws ServiceErrorException {
userService.createUser(dataModel);
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(dataModel.getLogin(), dataModel.getPassword());
token.setDetails(new WebAuthenticationDetails(request));
Authentication authentication = this.authenticationProvider.authenticate(token);
logger.debug("Logging in with [{}]", authentication.getPrincipal());
SecurityContextHolder.getContext().setAuthentication(authentication);
return new CheckModel(true);
}
@RequestMapping(value = "/registerFromAdmin", method = RequestMethod.POST)
@ResponseBody
public CheckModel registerFromAdmin(@RequestBody RegistrationDataModel dataModel) throws ServiceErrorException {
userService.createUser(dataModel);
return new CheckModel(true);
}
@RequestMapping(value = "/changePassword", method = RequestMethod.POST)
@ResponseBody
public CheckModel changePassword(@RequestBody ChangePasswordModel changePasswordModel) throws ServiceErrorException {
return userService.changePassword(changePasswordModel);
}
}
| [
"[email protected]"
] | |
cbd7ea5c52b2d601b65464a208c4ab78efd5892f | 01af2d00bb54f91d3b44d2d4d0b77fe234f1e119 | /recommendation-service/src/main/java/se/magnus/microservices/core/recommendation/services/RecommendationServiceImpl.java | a06c6aebde9b697448c349e3f4cf8dfcaac93bfc | [] | no_license | cirovladimir/microservices-book | 20b3892007b82ca9243beed663c04d9e791fa30b | b7098352254718b5b65b6dbe441963628e825f74 | refs/heads/main | 2023-05-14T18:47:23.503842 | 2021-06-03T05:23:49 | 2021-06-03T05:23:49 | 363,213,302 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,991 | java | package se.magnus.microservices.core.recommendation.services;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import se.magnus.microservices.api.recommendation.Recommendation;
import se.magnus.microservices.api.recommendation.RecommendationService;
import se.magnus.microservices.core.recommendation.persistence.RecommendationEntity;
import se.magnus.microservices.core.recommendation.persistence.RecommendationRepository;
import se.magnus.microservices.util.http.ServiceUtil;
@RestController
public class RecommendationServiceImpl implements RecommendationService {
private final ServiceUtil serviceUtil;
private final RecommendationRepository recommendationRepository;
private final RecommendationMapper recommendationMapper;
public RecommendationServiceImpl(ServiceUtil serviceUtil, RecommendationRepository recommendationRepository,
RecommendationMapper recommendationMapper) {
this.serviceUtil = serviceUtil;
this.recommendationRepository = recommendationRepository;
this.recommendationMapper = recommendationMapper;
}
@Override
public Flux<Recommendation> getRecommendations(int productId) {
return recommendationRepository.findByProductId(productId)
.log()
.map(e->recommendationMapper.toApi(e))
.map(e->{
e.setServiceAddress(serviceUtil.getServiceAddress());
return e;
});
}
@Override
public Recommendation createRecommendation(Recommendation body) {
RecommendationEntity entity = recommendationMapper.toEntity(body);
return recommendationRepository.save(entity)
.log()
.map(e->recommendationMapper.toApi(e))
.toProcessor()
.block();
}
@Override
public void deleteRecommendations(int productId) {
recommendationRepository.deleteAll(recommendationRepository.findByProductId(productId)).toProcessor().block();
}
} | [
"[email protected]"
] | |
2e47988898ef68a28c6e4a5be2cc442a4004487f | 26dcf8b7189b608af966cfbc696a5b7b80f25c16 | /core/src/main/java/org/helpj/core/FullPrunedBlockChain.java | a4830b9f7ab7dcf5b05a98c707c3f62099d91dbf | [
"Apache-2.0"
] | permissive | GoHelpFund/helpj | e1d36e4cb24ae90e91b0793ba621006adb978eb3 | 90026e78853254b54caa3a20351939454c84bd10 | refs/heads/master | 2022-10-16T09:14:04.719335 | 2019-09-26T10:00:33 | 2019-09-26T10:00:33 | 210,832,057 | 0 | 0 | Apache-2.0 | 2022-10-05T03:31:42 | 2019-09-25T11:49:33 | Java | UTF-8 | Java | false | false | 27,696 | java | /*
* Copyright 2012 Matt Corallo.
* Copyright 2014 Andreas Schildbach
*
* 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.helpj.core;
import org.helpj.governance.Superblock;
import org.helpj.script.Script;
import org.helpj.script.Script.VerifyFlag;
import org.helpj.store.BlockStoreException;
import org.helpj.store.FullPrunedBlockStore;
import org.helpj.utils.*;
import org.helpj.wallet.Wallet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.concurrent.*;
import static com.google.common.base.Preconditions.checkState;
/**
* <p>A FullPrunedBlockChain works in conjunction with a {@link FullPrunedBlockStore} to verify all the rules of the
* Bitcoin system, with the downside being a large cost in system resources. Fully verifying means all unspent
* transaction outputs are stored. Once a transaction output is spent and that spend is buried deep enough, the data
* related to it is deleted to ensure disk space usage doesn't grow forever. For this reason a pruning node cannot
* serve the full block chain to other clients, but it nevertheless provides the same security guarantees as Bitcoin
* Core does.</p>
*/
public class FullPrunedBlockChain extends AbstractBlockChain {
private static final Logger log = LoggerFactory.getLogger(FullPrunedBlockChain.class);
/**
* Keeps a map of block hashes to StoredBlocks.
*/
protected final FullPrunedBlockStore blockStore;
// Whether or not to execute scriptPubKeys before accepting a transaction (i.e. check signatures).
private boolean runScripts = true;
/**
* Constructs a block chain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}
*/
public FullPrunedBlockChain(Context context, Wallet wallet, FullPrunedBlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
addWallet(wallet);
}
/**
* Constructs a block chain connected to the given wallet and store. To obtain a {@link Wallet} you can construct
* one from scratch, or you can deserialize a saved wallet from disk using
* {@link Wallet#loadFromFile(java.io.File, WalletExtension...)}
*/
public FullPrunedBlockChain(NetworkParameters params, Wallet wallet, FullPrunedBlockStore blockStore) throws BlockStoreException {
this(Context.getOrCreate(params), wallet, blockStore);
}
/**
* Constructs a block chain connected to the given store.
*/
public FullPrunedBlockChain(Context context, FullPrunedBlockStore blockStore) throws BlockStoreException {
this(context, new ArrayList<Wallet>(), blockStore);
}
/**
* See {@link #FullPrunedBlockChain(Context, Wallet, FullPrunedBlockStore)}
*/
public FullPrunedBlockChain(NetworkParameters params, FullPrunedBlockStore blockStore) throws BlockStoreException {
this(Context.getOrCreate(params), blockStore);
}
/**
* Constructs a block chain connected to the given list of wallets and a store.
*/
public FullPrunedBlockChain(Context context, List<Wallet> listeners, FullPrunedBlockStore blockStore) throws BlockStoreException {
super(context, listeners, blockStore);
this.blockStore = blockStore;
// Ignore upgrading for now
this.chainHead = blockStore.getVerifiedChainHead();
}
/**
* See {@link #FullPrunedBlockChain(Context, List, FullPrunedBlockStore)}
*/
public FullPrunedBlockChain(NetworkParameters params, List<Wallet> listeners,
FullPrunedBlockStore blockStore) throws BlockStoreException {
this(Context.getOrCreate(params), listeners, blockStore);
}
@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block header, TransactionOutputChanges txOutChanges)
throws BlockStoreException, VerificationException {
StoredBlock newBlock = storedPrev.build(header);
blockStore.put(newBlock, new StoredUndoableBlock(newBlock.getHeader().getHash(), txOutChanges));
return newBlock;
}
@Override
protected StoredBlock addToBlockStore(StoredBlock storedPrev, Block block)
throws BlockStoreException, VerificationException {
StoredBlock newBlock = storedPrev.build(block);
blockStore.put(newBlock, new StoredUndoableBlock(newBlock.getHeader().getHash(), block.transactions));
return newBlock;
}
@Override
protected void rollbackBlockStore(int height) throws BlockStoreException {
throw new BlockStoreException("Unsupported");
}
@Override
protected boolean shouldVerifyTransactions() {
return true;
}
/**
* Whether or not to run scripts whilst accepting blocks (i.e. checking signatures, for most transactions).
* If you're accepting data from an untrusted node, such as one found via the P2P network, this should be set
* to true (which is the default). If you're downloading a chain from a node you control, script execution
* is redundant because you know the connected node won't relay bad data to you. In that case it's safe to set
* this to false and obtain a significant speedup.
*/
public void setRunScripts(boolean value) {
this.runScripts = value;
}
// TODO: Remove lots of duplicated code in the two connectTransactions
// TODO: execute in order of largest transaction (by input count) first
ExecutorService scriptVerificationExecutor = Executors.newFixedThreadPool(
Runtime.getRuntime().availableProcessors(), new ContextPropagatingThreadFactory("Script verification"));
/**
* A job submitted to the executor which verifies signatures.
*/
private static class Verifier implements Callable<VerificationException> {
final Transaction tx;
final List<Script> prevOutScripts;
final Set<VerifyFlag> verifyFlags;
public Verifier(final Transaction tx, final List<Script> prevOutScripts, final Set<VerifyFlag> verifyFlags) {
this.tx = tx;
this.prevOutScripts = prevOutScripts;
this.verifyFlags = verifyFlags;
}
@Nullable
@Override
public VerificationException call() throws Exception {
try {
ListIterator<Script> prevOutIt = prevOutScripts.listIterator();
for (int index = 0; index < tx.getInputs().size(); index++) {
tx.getInputs().get(index).getScriptSig().correctlySpends(tx, index, prevOutIt.next(), verifyFlags);
}
} catch (VerificationException e) {
return e;
}
return null;
}
}
/**
* Get the {@link Script} from the script bytes or return Script of empty byte array.
*/
private Script getScript(byte[] scriptBytes) {
try {
return new Script(scriptBytes);
} catch (Exception e) {
return new Script(new byte[0]);
}
}
/**
* Get the address from the {@link Script} if it exists otherwise return empty string "".
*
* @param script The script.
* @return The address.
*/
private String getScriptAddress(@Nullable Script script) {
String address = "";
try {
if (script != null) {
address = script.getToAddress(params, true).toString();
}
} catch (Exception e) {
}
return address;
}
@Override
protected TransactionOutputChanges connectTransactions(int height, Block block, StoredBlock storedPrev)
throws VerificationException, BlockStoreException {
checkState(lock.isHeldByCurrentThread());
if (block.transactions == null)
throw new RuntimeException("connectTransactions called with Block that didn't have transactions!");
if (!params.passesCheckpoint(height, block.getHash()))
throw new VerificationException("Block failed checkpoint lockin at " + height);
blockStore.beginDatabaseBatchWrite();
LinkedList<UTXO> txOutsSpent = new LinkedList<UTXO>();
LinkedList<UTXO> txOutsCreated = new LinkedList<UTXO>();
long sigOps = 0;
if (scriptVerificationExecutor.isShutdown())
scriptVerificationExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<Future<VerificationException>>(block.transactions.size());
try {
if (!params.isCheckpoint(height)) {
// BIP30 violator blocks are ones that contain a duplicated transaction. They are all in the
// checkpoints list and we therefore only check non-checkpoints for duplicated transactions here. See the
// BIP30 document for more details on this: https://github.com/bitcoin/bips/blob/master/bip-0030.mediawiki
for (Transaction tx : block.transactions) {
final Set<VerifyFlag> verifyFlags = params.getTransactionVerificationFlags(block, tx, getVersionTally(), height);
Sha256Hash hash = tx.getHash();
// If we already have unspent outputs for this hash, we saw the tx already. Either the block is
// being added twice (bug) or the block is a BIP30 violator.
if (blockStore.hasUnspentOutputs(hash, tx.getOutputs().size()))
throw new VerificationException("Block failed BIP30 test!");
if (verifyFlags.contains(VerifyFlag.P2SH)) // We already check non-BIP16 sigops in Block.verifyTransactions(true)
sigOps += tx.getSigOpCount();
}
}
Coin totalFees = Coin.ZERO;
Coin coinbaseValue = null;
for (final Transaction tx : block.transactions) {
boolean isCoinBase = tx.isCoinBase();
Coin valueIn = Coin.ZERO;
Coin valueOut = Coin.ZERO;
final List<Script> prevOutScripts = new LinkedList<Script>();
final Set<VerifyFlag> verifyFlags = params.getTransactionVerificationFlags(block, tx, getVersionTally(), height);
if (!isCoinBase) {
// For each input of the transaction remove the corresponding output from the set of unspent
// outputs.
for (int index = 0; index < tx.getInputs().size(); index++) {
TransactionInput in = tx.getInputs().get(index);
UTXO prevOut = blockStore.getTransactionOutput(in.getOutpoint().getHash(),
in.getOutpoint().getIndex());
if (prevOut == null)
throw new VerificationException("Attempted to spend a non-existent or already spent output!");
// Coinbases can't be spent until they mature, to avoid re-orgs destroying entire transaction
// chains. The assumption is there will ~never be re-orgs deeper than the spendable coinbase
// chain depth.
if (prevOut.isCoinbase()) {
if (height - prevOut.getHeight() < params.getSpendableCoinbaseDepth()) {
throw new VerificationException("Tried to spend coinbase at depth " + (height - prevOut.getHeight()));
}
}
// TODO: Check we're not spending the genesis transaction here. Bitcoin Core won't allow it.
valueIn = valueIn.add(prevOut.getValue());
if (verifyFlags.contains(VerifyFlag.P2SH)) {
if (prevOut.getScript().isPayToScriptHash())
sigOps += Script.getP2SHSigOpCount(in.getScriptBytes());
if (sigOps > (height >= params.getDIP0001BlockHeight() ? Block.MAX_BLOCK_SIGOPS_DIP00001 :Block.MAX_BLOCK_SIGOPS))
throw new VerificationException("Too many P2SH SigOps in block");
}
prevOutScripts.add(prevOut.getScript());
blockStore.removeUnspentTransactionOutput(prevOut);
txOutsSpent.add(prevOut);
}
}
Sha256Hash hash = tx.getHash();
for (TransactionOutput out : tx.getOutputs()) {
valueOut = valueOut.add(out.getValue());
// For each output, add it to the set of unspent outputs so it can be consumed in future.
Script script = getScript(out.getScriptBytes());
UTXO newOut = new UTXO(hash,
out.getIndex(),
out.getValue(),
height, isCoinBase,
script,
getScriptAddress(script));
blockStore.addUnspentTransactionOutput(newOut);
txOutsCreated.add(newOut);
}
// All values were already checked for being non-negative (as it is verified in Transaction.verify())
// but we check again here just for defence in depth. Transactions with zero output value are OK.
if (valueOut.signum() < 0 || valueOut.compareTo(params.getMaxMoney()) > 0)
throw new VerificationException("Transaction output value out of range");
if (isCoinBase) {
coinbaseValue = valueOut;
} else {
if (valueIn.compareTo(valueOut) < 0 || valueIn.compareTo(params.getMaxMoney()) > 0)
throw new VerificationException("Transaction input value out of range");
totalFees = totalFees.add(valueIn.subtract(valueOut));
}
if (!isCoinBase && runScripts) {
// Because correctlySpends modifies transactions, this must come after we are done with tx
FutureTask<VerificationException> future = new FutureTask<VerificationException>(new Verifier(tx, prevOutScripts, verifyFlags));
scriptVerificationExecutor.execute(future);
listScriptVerificationResults.add(future);
}
}
boolean feesDontMatch = block.getBlockInflation(height, storedPrev.getHeader().getDifficultyTarget(), false).add(totalFees).compareTo(coinbaseValue) < 0;
if (totalFees.compareTo(params.getMaxMoney()) > 0 || feesDontMatch) {
if(feesDontMatch && !Superblock.isValidBudgetBlockHeight(params, height))
throw new VerificationException("Transaction fees out of range");
}
for (Future<VerificationException> future : listScriptVerificationResults) {
VerificationException e;
try {
e = future.get();
} catch (InterruptedException thrownE) {
throw new RuntimeException(thrownE); // Shouldn't happen
} catch (ExecutionException thrownE) {
log.error("Script.correctlySpends threw a non-normal exception: " + thrownE.getCause());
throw new VerificationException("Bug in Script.correctlySpends, likely script malformed in some new and interesting way.", thrownE);
}
if (e != null)
throw e;
}
} catch (VerificationException e) {
scriptVerificationExecutor.shutdownNow();
blockStore.abortDatabaseBatchWrite();
throw e;
} catch (BlockStoreException e) {
scriptVerificationExecutor.shutdownNow();
blockStore.abortDatabaseBatchWrite();
throw e;
}
return new TransactionOutputChanges(txOutsCreated, txOutsSpent);
}
/**
* Used during reorgs to connect a block previously on a fork
*/
@Override
protected synchronized TransactionOutputChanges connectTransactions(StoredBlock newBlock, StoredBlock storedPrev)
throws VerificationException, BlockStoreException, PrunedException {
checkState(lock.isHeldByCurrentThread());
if (!params.passesCheckpoint(newBlock.getHeight(), newBlock.getHeader().getHash()))
throw new VerificationException("Block failed checkpoint lockin at " + newBlock.getHeight());
blockStore.beginDatabaseBatchWrite();
StoredUndoableBlock block = blockStore.getUndoBlock(newBlock.getHeader().getHash());
if (block == null) {
// We're trying to re-org too deep and the data needed has been deleted.
blockStore.abortDatabaseBatchWrite();
throw new PrunedException(newBlock.getHeader().getHash());
}
TransactionOutputChanges txOutChanges;
try {
List<Transaction> transactions = block.getTransactions();
if (transactions != null) {
LinkedList<UTXO> txOutsSpent = new LinkedList<UTXO>();
LinkedList<UTXO> txOutsCreated = new LinkedList<UTXO>();
long sigOps = 0;
if (!params.isCheckpoint(newBlock.getHeight())) {
for (Transaction tx : transactions) {
Sha256Hash hash = tx.getHash();
if (blockStore.hasUnspentOutputs(hash, tx.getOutputs().size()))
throw new VerificationException("Block failed BIP30 test!");
}
}
Coin totalFees = Coin.ZERO;
Coin coinbaseValue = null;
if (scriptVerificationExecutor.isShutdown())
scriptVerificationExecutor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
List<Future<VerificationException>> listScriptVerificationResults = new ArrayList<Future<VerificationException>>(transactions.size());
for (final Transaction tx : transactions) {
final Set<VerifyFlag> verifyFlags =
params.getTransactionVerificationFlags(newBlock.getHeader(), tx, getVersionTally(), Integer.SIZE);
boolean isCoinBase = tx.isCoinBase();
Coin valueIn = Coin.ZERO;
Coin valueOut = Coin.ZERO;
final List<Script> prevOutScripts = new LinkedList<Script>();
if (!isCoinBase) {
for (int index = 0; index < tx.getInputs().size(); index++) {
final TransactionInput in = tx.getInputs().get(index);
final UTXO prevOut = blockStore.getTransactionOutput(in.getOutpoint().getHash(),
in.getOutpoint().getIndex());
if (prevOut == null)
throw new VerificationException("Attempted spend of a non-existent or already spent output!");
if (prevOut.isCoinbase() && newBlock.getHeight() - prevOut.getHeight() < params.getSpendableCoinbaseDepth())
throw new VerificationException("Tried to spend coinbase at depth " + (newBlock.getHeight() - prevOut.getHeight()));
valueIn = valueIn.add(prevOut.getValue());
if (verifyFlags.contains(VerifyFlag.P2SH)) {
if (prevOut.getScript().isPayToScriptHash())
sigOps += Script.getP2SHSigOpCount(in.getScriptBytes());
if (sigOps > (newBlock.getHeight() >= params.getDIP0001BlockHeight() ? Block.MAX_BLOCK_SIGOPS_DIP00001 :Block.MAX_BLOCK_SIGOPS))
throw new VerificationException("Too many P2SH SigOps in block");
}
// TODO: Enforce DER signature format
prevOutScripts.add(prevOut.getScript());
blockStore.removeUnspentTransactionOutput(prevOut);
txOutsSpent.add(prevOut);
}
}
Sha256Hash hash = tx.getHash();
for (TransactionOutput out : tx.getOutputs()) {
valueOut = valueOut.add(out.getValue());
Script script = getScript(out.getScriptBytes());
UTXO newOut = new UTXO(hash,
out.getIndex(),
out.getValue(),
newBlock.getHeight(),
isCoinBase,
script,
getScriptAddress(script));
blockStore.addUnspentTransactionOutput(newOut);
txOutsCreated.add(newOut);
}
// All values were already checked for being non-negative (as it is verified in Transaction.verify())
// but we check again here just for defence in depth. Transactions with zero output value are OK.
if (valueOut.signum() < 0 || valueOut.compareTo(params.getMaxMoney()) > 0)
throw new VerificationException("Transaction output value out of range");
if (isCoinBase) {
coinbaseValue = valueOut;
} else {
if (valueIn.compareTo(valueOut) < 0 || valueIn.compareTo(params.getMaxMoney()) > 0)
throw new VerificationException("Transaction input value out of range");
totalFees = totalFees.add(valueIn.subtract(valueOut));
}
if (!isCoinBase) {
// Because correctlySpends modifies transactions, this must come after we are done with tx
FutureTask<VerificationException> future = new FutureTask<VerificationException>(new Verifier(tx, prevOutScripts, verifyFlags));
scriptVerificationExecutor.execute(future);
listScriptVerificationResults.add(future);
}
}
boolean feesDontMatch = newBlock.getHeader().getBlockInflation(newBlock.getHeight(), storedPrev.getHeader().getDifficultyTarget(), false).add(totalFees).compareTo(coinbaseValue) < 0;
if (totalFees.compareTo(params.getMaxMoney()) > 0 || feesDontMatch) {
if(feesDontMatch && !Superblock.isValidBudgetBlockHeight(params, newBlock.getHeight()))
throw new VerificationException("Transaction fees out of range");
}
txOutChanges = new TransactionOutputChanges(txOutsCreated, txOutsSpent);
for (Future<VerificationException> future : listScriptVerificationResults) {
VerificationException e;
try {
e = future.get();
} catch (InterruptedException thrownE) {
throw new RuntimeException(thrownE); // Shouldn't happen
} catch (ExecutionException thrownE) {
log.error("Script.correctlySpends threw a non-normal exception: " + thrownE.getCause());
throw new VerificationException("Bug in Script.correctlySpends, likely script malformed in some new and interesting way.", thrownE);
}
if (e != null)
throw e;
}
} else {
txOutChanges = block.getTxOutChanges();
if (!params.isCheckpoint(newBlock.getHeight()))
for (UTXO out : txOutChanges.txOutsCreated) {
Sha256Hash hash = out.getHash();
if (blockStore.getTransactionOutput(hash, out.getIndex()) != null)
throw new VerificationException("Block failed BIP30 test!");
}
for (UTXO out : txOutChanges.txOutsCreated)
blockStore.addUnspentTransactionOutput(out);
for (UTXO out : txOutChanges.txOutsSpent)
blockStore.removeUnspentTransactionOutput(out);
}
} catch (VerificationException e) {
scriptVerificationExecutor.shutdownNow();
blockStore.abortDatabaseBatchWrite();
throw e;
} catch (BlockStoreException e) {
scriptVerificationExecutor.shutdownNow();
blockStore.abortDatabaseBatchWrite();
throw e;
}
return txOutChanges;
}
/**
* This is broken for blocks that do not pass BIP30, so all BIP30-failing blocks which are allowed to fail BIP30
* must be checkpointed.
*/
@Override
protected void disconnectTransactions(StoredBlock oldBlock) throws PrunedException, BlockStoreException {
checkState(lock.isHeldByCurrentThread());
blockStore.beginDatabaseBatchWrite();
try {
StoredUndoableBlock undoBlock = blockStore.getUndoBlock(oldBlock.getHeader().getHash());
if (undoBlock == null) throw new PrunedException(oldBlock.getHeader().getHash());
TransactionOutputChanges txOutChanges = undoBlock.getTxOutChanges();
for (UTXO out : txOutChanges.txOutsSpent)
blockStore.addUnspentTransactionOutput(out);
for (UTXO out : txOutChanges.txOutsCreated)
blockStore.removeUnspentTransactionOutput(out);
} catch (PrunedException e) {
blockStore.abortDatabaseBatchWrite();
throw e;
} catch (BlockStoreException e) {
blockStore.abortDatabaseBatchWrite();
throw e;
}
}
@Override
protected void doSetChainHead(StoredBlock chainHead) throws BlockStoreException {
checkState(lock.isHeldByCurrentThread());
blockStore.setVerifiedChainHead(chainHead);
blockStore.commitDatabaseBatchWrite();
}
@Override
protected void notSettingChainHead() throws BlockStoreException {
blockStore.abortDatabaseBatchWrite();
}
@Override
protected StoredBlock getStoredBlockInCurrentScope(Sha256Hash hash) throws BlockStoreException {
checkState(lock.isHeldByCurrentThread());
return blockStore.getOnceUndoableStoredBlock(hash);
}
}
| [
"[email protected]"
] | |
b0ab90e50bfa61f44ff4082f27d26afa76de9be3 | 1b5d6d0f4830ad26d9099532e06a7a942909c6d1 | /src/uebung_3/TopLevelDemo_v2.java | ba3536a30c9c5c8c33b1e84e44444459ac0490a2 | [] | no_license | matzekFloyd/EPRO3_3 | f48da25341bdae9a7ad16bcc9f2b1e5fef7d8f47 | 8dc53de2b70226b45e7dab490fab6be83099945e | refs/heads/master | 2021-06-09T04:58:25.828351 | 2016-11-25T21:38:43 | 2016-11-25T21:38:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,538 | java | package uebung_3;
/*
* Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of Oracle or the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import static javax.swing.JFrame.EXIT_ON_CLOSE;
/* TopLevelDemo.java requires no other files. */
public class TopLevelDemo_v2 extends JPanel implements ActionListener {
public String bla;
//Deklaration der Instanzvariablen
JLabel yellowLabel = new JLabel();
GeoPainterEK ge;
GraphicsGenerator gg;
int depthcounter = 0;
//Konstruktor
TopLevelDemo_v2() {
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(248, 213, 131));
//yellowLabel.setPreferredSize(new Dimension(200, 180));
yellowLabel.setPreferredSize(new Dimension(500, 500));
//Hinzufuegen des Labels
add(yellowLabel);
ge = new GeoPainterEK();
gg = new GraphicsGenerator(ge.shapesToPaint);
}
public JMenuBar createMenuBar() {
//Create the menu bar. Make it have a green background.
JMenuBar greenMenuBar = new JMenuBar();
greenMenuBar.setOpaque(true);
greenMenuBar.setBackground(new Color(154, 165, 127));
greenMenuBar.setPreferredSize(new Dimension(200, 20));
//Menupunkt hinzufuegen
JMenu menu_file = new JMenu("Farbe");
JMenu menu_file_shape = new JMenu("Form");
greenMenuBar.add(menu_file);
greenMenuBar.add(menu_file_shape);
//Menueeintraege hinzufuegen
JMenuItem item_rot = new JMenuItem("Rot");
JMenuItem item_gruen = new JMenuItem("Gruen");
JMenuItem item_blau = new JMenuItem("Blau");
JMenuItem item_kreis = new JMenuItem("Kreis");
JMenuItem item_rechteck = new JMenuItem("Rechteck");
//1. ActionListener fuer Open anh๏ฟฝngen
item_rot.addActionListener(this);
item_gruen.addActionListener(this);
item_blau.addActionListener(this);
item_kreis.addActionListener(this);
item_rechteck.addActionListener(this);
menu_file.add(item_rot);
menu_file.add(item_gruen);
menu_file.add(item_blau);
menu_file_shape.add(item_kreis);
menu_file_shape.add(item_rechteck);
// JMenuBar grrenMenuBar zur๏ฟฝckgeben
return greenMenuBar;
}
/**
* Create the GUI and show it. For thread safety, this method should be
* invoked from the event-dispatching thread. Problem: Das muss eine
* statische Methode sein, um thread-save aufgerufen werden zu koennen
* (siehe Methode main()). Allerdings, eine statische Methode kann nicht mit
* den Instanzvariablen der Klasse interagieren. Wir umgehen das, indem wir
* von JPanel erben, und dieses als ContentPane in unseren Frame geben.
*/
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("TopLevelDemo Version 2");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
/* JPanel MiniPhotoShop als ContentPane, this nicht m๏ฟฝgloch, umweg */
TopLevelDemo_v2 ourTopLevelDemo = new TopLevelDemo_v2();
//Damit k๏ฟฝnnen wir jede Komponente in unserer Hauptklasse adden!
Container pane = frame.getContentPane();
pane.add(ourTopLevelDemo.ge.lp);
frame.setTitle("Simple example");
frame.setSize(1000, 1000);
frame.setLocationRelativeTo(null);
frame.setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setJMenuBar(ourTopLevelDemo.createMenuBar());
//Display the window.
//frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
@Override
public void actionPerformed(ActionEvent e) {
JMenuItem itemClicked;
//Falls es ein MenuItem ist
if (e.getSource() instanceof JMenuItem) {
itemClicked = (JMenuItem) e.getSource();
//Falls es das Item "Rot" war
if (itemClicked.getText() == "Rot") {
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(255, 0, 0));
//Wenn Hintergrundfarbe gewechselt wird, lรถsche alle im Moment
//gezeichneten Formen
gg.shapesToPaint.clear();
}
if (itemClicked.getText() == "Gruen") {
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(0, 255, 0));
//Wenn Hintergrundfarbe gewechselt wird, lรถsche alle im Moment
//gezeichneten Formen
gg.shapesToPaint.clear();
}
if (itemClicked.getText() == "Blau") {
yellowLabel.setOpaque(true);
yellowLabel.setBackground(new Color(0, 0, 255));
//Wenn Hintergrundfarbe gewechselt wird, lรถsche alle im Moment
//gezeichneten Formen
gg.shapesToPaint.clear();
}
if (itemClicked.getText() == "Kreis") {
ge.addCircle(ge.randomPosition(), ge.randomSize(), ge.randomColor(), depthcounter);
//ge.addRandomCircle();
//System.out.println(newCircle.toString());
gg.paintComponent(getGraphics());
depthcounter = depthcounter + 1;
}
if (itemClicked.getText() == "Rechteck") {
ge.addRectangle(ge.randomPosition(), ge.randomPosition(), ge.randomColor(),depthcounter);
//ge.addRandomRectangle();
//System.out.println(newCircle.toString());
gg.paintComponent(getGraphics());
depthcounter = depthcounter + 1;
}
}
}
}
| [
"[email protected]"
] | |
e798175b24cbff0bba130e5ad5f77fee339d8858 | 78eb7d860647c853518d6c1af5b40a7c4c3e5b89 | /src/main/java/avatar/manager/EconomyManager.java | d99b42d8eced9a590b0d1ca5d395d31f394a99a8 | [
"MIT"
] | permissive | Jimmeh94/AvatarSpigot | 4ed4d153d4cdf6745c639f00d62d25a803e10dd6 | 704f4f219963bd3de124beee2c25a4dd29ce52e0 | refs/heads/master | 2021-03-27T15:34:27.025856 | 2017-02-25T06:46:06 | 2017-02-25T06:46:06 | 80,318,957 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 444 | java | package avatar.manager;
import avatar.game.user.Account;
import avatar.game.user.UserPlayer;
import java.util.Optional;
public class EconomyManager extends Manager<Account> {
public Optional<Account> findAccount(UserPlayer userPlayer){
for(Account account: objects){
if(account.getOwner() == userPlayer){
return Optional.of(account);
}
}
return Optional.empty();
}
}
| [
"[email protected]"
] | |
7f9a4388681c8ac28e15a08f1a1ca313e53f1b03 | 6d1c004063749837ec176d8c9dc32262d208b382 | /src/com/virid/ViridDirectory/ViridDirectoryActivity.java | 47ed675a6283b7aa47e81e13da8f50a5ff9e8771 | [] | no_license | rahulyhg/Directory-4 | 3b664b199562102ced6a66a9a4611daf3e5ff3fc | f5f58004b114f1bda28400d7aaea8980f60e8a8c | refs/heads/master | 2021-01-19T20:57:09.042768 | 2012-04-20T18:34:58 | 2012-04-20T18:34:58 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,761 | java | package com.virid.ViridDirectory;
import android.app.Dialog;
import android.app.ListActivity;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Handler;
import android.text.Html;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.SimpleCursorAdapter;
import android.widget.TextView;
import android.widget.Toast;
public class ViridDirectoryActivity extends ListActivity {
private static final int MENU_NEW_CONTACT = 0;
private static final int MENU_HELP = 1;
private static final int MENU_WIPEDB = 2;
protected EditText searchText;
protected SQLiteDatabase db;
protected Cursor cursor;
protected ListAdapter adapter;
protected Dialog mSplashDialog;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();
if (data != null) {
// Show splash screen if still loading
if (data.showSplashScreen) {
// showSplashScreen();
}
setContentView(R.layout.main);
searchText = (EditText) findViewById(R.id.searchText);
db = (new DatabaseHelper(this)).getWritableDatabase();
// Rebuild your UI with your saved state here
} else {
showSplashScreen();
setContentView(R.layout.main);
searchText = (EditText) findViewById(R.id.searchText);
db = (new DatabaseHelper(this)).getWritableDatabase();
// Do your heavy loading here on a background thread
}
}
// MENUING OPTIONS --------------
@Override
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_NEW_CONTACT, 0, "New Contact").setIcon(R.drawable.add);
menu.add(0, MENU_HELP, 1, "Help").setIcon(R.drawable.help);
menu.add(0, MENU_WIPEDB, 2, "Clear Database");
return true;
}
public boolean onOptionsItemSelected(MenuItem item) {
Intent intent;
switch (item.getItemId()) {
case MENU_NEW_CONTACT:
intent = new Intent(this, NewContact.class);
startActivity(intent);
break;
// case MENU_HELP:
// intent = new Intent(this, Help.class);
// startActivity(intent);
// break;
case MENU_WIPEDB:
wipeDatabase();
break;
}
return false;
}
// -------------------------------
public void onListItemClick(ListView parent, View view, int position,
long id) {
Intent intent = new Intent(this, EmployeeDetails.class);
Cursor cursor = (Cursor) adapter.getItem(position);
intent.putExtra("EMPLOYEE_ID",
cursor.getInt(cursor.getColumnIndex("_id")));
startActivity(intent);
}
public void search(View view) {
// || is the concatenation operation in SQLite
cursor = db
.rawQuery(
"SELECT _id, firstName, lastName, title, \" - \" || department as department FROM viridEmployee WHERE firstName || ' ' || lastName LIKE ?",
new String[] { "%" + searchText.getText().toString()
+ "%" });
adapter = new SimpleCursorAdapter(this, R.layout.employee_list_item,
cursor, new String[] { "firstName", "lastName", "title",
"department" }, new int[] { R.id.firstName,
R.id.lastName, R.id.title, R.id.department });
setListAdapter(adapter);
}
@Override
public Object onRetainNonConfigurationInstance() {
MyStateSaver data = new MyStateSaver();
// Save your important data here
if (mSplashDialog != null) {
data.showSplashScreen = true;
removeSplashScreen();
}
return data;
}
/**
* Removes the Dialog that displays the splash screen
*/
protected void removeSplashScreen() {
if (mSplashDialog != null) {
mSplashDialog.dismiss();
mSplashDialog = null;
}
}
/**
* Shows the splash screen over the full Activity
*/
protected void showSplashScreen() {
mSplashDialog = new Dialog(this, R.style.SplashScreen);
mSplashDialog.setContentView(R.layout.splash);
mSplashDialog.setCancelable(false);
mSplashDialog.show();
TextView splashText = (TextView) mSplashDialog
.findViewById(R.id.splashText);
splashText.setText(Html.fromHtml(getString(R.string.splashText)));
// Set Runnable to remove splash screen just in case
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
public void run() {
removeSplashScreen();
}
}, 3000);
}
/**
* Simple class for storing important data across config changes
*/
private class MyStateSaver {
public boolean showSplashScreen = false;
// Your other important fields here
}
private void wipeDatabase() {
db.delete("viridEmployee", null, null);
Toast.makeText(getApplicationContext(), "Database cleared.", Toast.LENGTH_LONG);
}
} | [
"[email protected]"
] | |
1e5ee16cb687d538f37d5d4e04450bd29c89d902 | 9e8f669d216211ed25cd7208d25f918d8031a335 | /CCMS/src/main/java/com/kh/ccms/community/model/exception/CommunityException.java | b4a33a8b56009f2dc3f7ee16780c5db3e28d98c2 | [] | no_license | CleverCodeMonkeys/ALLIT | d3ce6dfde79a975a09de1e1877b71ca177ca4e6b | 6aa7823e66b7409f8ed5bcc1f7f237600a21d585 | refs/heads/master | 2020-03-24T23:11:33.771249 | 2018-08-08T09:03:38 | 2018-08-08T09:03:38 | 143,122,443 | 0 | 0 | null | 2018-08-08T09:03:39 | 2018-08-01T07:50:20 | JavaScript | UTF-8 | Java | false | false | 299 | java | package com.kh.ccms.community.model.exception;
public class CommunityException extends RuntimeException
{
private static final long serialVersionUID = 155L;
public CommunityException() {}
public CommunityException(String msg)
{
super("๊ฒ์ํ ์๋ฌ ๋ฐ์" + msg);
}
}
| [
"user2@KH_H"
] | user2@KH_H |
6e3eab32ae973030147d7b719e52a11c2f93a76a | c691222c33bf8c2e2a7874a006de570cd7360111 | /src/modulo-05-java/lavanderia/src/main/java/br/com/cwi/crescer/controller/pedido/PedidoFinalizarController.java | ab77fde86870dd109a7e24fc0682afe2353578dd | [] | no_license | angelovianajr/crescer-2015-2 | a9edf0df61c242a40a68d830c9559c4bf289779e | 899f5803a150c2a2ddfe0fe58f2712232c8719eb | refs/heads/master | 2021-05-30T09:18:36.010742 | 2015-12-01T16:22:01 | 2015-12-01T16:22:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,015 | java | package br.com.cwi.crescer.controller.pedido;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import br.com.cwi.crescer.domain.Pedido.SituacaoPedido;
import br.com.cwi.crescer.dto.PedidoDTO;
import br.com.cwi.crescer.service.pedido.PedidoService;
@Controller
@RequestMapping("/pedidos")
public class PedidoFinalizarController {
private PedidoService pedidoService;
@Autowired
public PedidoFinalizarController(PedidoService pedidoService) {
this.pedidoService = pedidoService;
}
@PreAuthorize("hasRole('ADMIN')")
@RequestMapping(path = "/cancelar", method = RequestMethod.POST)
public ModelAndView cancelar(@ModelAttribute("pedido") PedidoDTO pedidoDTO,
final RedirectAttributes redirectAttributes){
pedidoService.cancelarPedido(pedidoDTO.getId());
redirectAttributes.addFlashAttribute("sucesso", "Pedido cancelado com sucesso");
return new ModelAndView("redirect:/pedidos");
}
@RequestMapping(path = "/encerrar", method = RequestMethod.POST)
public ModelAndView encerrar(@ModelAttribute("pedido") PedidoDTO pedidoDTO,
final RedirectAttributes redirectAttributes){
try {
pedidoService.retirarPedido(pedidoDTO.getId());
redirectAttributes.addFlashAttribute("sucesso", "Pedido encerrado com sucesso");
} catch (Exception e) {
redirectAttributes.addFlashAttribute("sucesso", "O Pedido precisa estar PROCESSADO para ser encerrado");
}
return new ModelAndView("redirect:/pedidos");
}
@ModelAttribute("situacoes")
public SituacaoPedido[] comboSituacoes() {
return SituacaoPedido.values();
}
}
| [
"[email protected]"
] | |
cab8be099c084b5ce6b6b416d685b6c2868a6c8e | 8cc95271928042194eb2d65838004471492f7bee | /java/neo/exception/PageException.java | 256d1032a71f5d4bdbe70aa7d4e599436f3d1a42 | [] | no_license | jagarian/public_html | 8cc6364bef711c980ee7fe8577a0878627343f76 | c013d95c626585118dd1913f6214183ec1381474 | refs/heads/master | 2016-08-05T16:19:02.016714 | 2013-06-20T13:29:25 | 2013-06-20T13:29:25 | null | 0 | 0 | null | null | null | null | UHC | Java | false | false | 1,374 | java | package neo.exception;
/**
* @Class Name : PageException.java
* @ํ์ผ์ค๋ช
:
* @Version : 1.0
* @Author : hoon09
* @Copyright : All Right Reserved
**********************************************************************************************
* ์์
์ผ ๋ฒ์ ผ ๊ตฌ๋ถ ์์
์ ๋ด์ฉ
* --------------------------------------------------------------------------------------------
* 2005-05-01 1.4 ์์ฑ hoon09 source create (์ผ์ฑ์ ๊ธฐ)
* 2006-11-23 1.4 ์์ hoon09 code convention apply (๋ฉํฐ์บ ํผ์ค)
* 2009-07-03 1.6 ์์ hoon09 code convention apply (๊ตญ๋ฏผ์ํ, ํํ์ํ๋ฆฌํฐ)
* 2009-09-23 1.7 ์์ hoon09 code valid check (ํธ๋ฅด๋ด์ฌ์๋ช
๋ณดํ,๋ฑ
๋ฑ
)
**********************************************************************************************
*/
public class PageException extends NeoException {
private static final long serialVersionUID = 1L;
public PageException() {
super();
}
public PageException(String msg) {
super(msg);
}
public PageException(String code, String msg) {
super(code, msg);
}
public PageException(String msg, Throwable rootCause) {
super(msg, rootCause);
}
public PageException(String code, String msg, Throwable rootCause) {
super(code, msg, rootCause);
}
public PageException(Throwable rootCause) {
super(rootCause);
}
}
| [
"[email protected]"
] | |
a50f26aea04180f59b7e46109049f367bc080105 | ae9efe033a18c3d4a0915bceda7be2b3b00ae571 | /jambeth/jambeth-test/src/test/java/com/koch/ambeth/query/isin/QueryIsInMassdataTest.java | 1423d6ffcf352c794561fcc7899fb64f6c0814b7 | [
"Apache-2.0"
] | permissive | Dennis-Koch/ambeth | 0902d321ccd15f6dc62ebb5e245e18187b913165 | 8552b210b8b37d3d8f66bdac2e094bf23c8b5fda | refs/heads/develop | 2022-11-10T00:40:00.744551 | 2017-10-27T05:35:20 | 2017-10-27T05:35:20 | 88,013,592 | 0 | 4 | Apache-2.0 | 2022-09-22T18:02:18 | 2017-04-12T05:36:00 | Java | UTF-8 | Java | false | false | 5,089 | java | package com.koch.ambeth.query.isin;
/*-
* #%L
* jambeth-test
* %%
* Copyright (C) 2017 Koch Softwaredevelopment
* %%
* 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.
* #L%
*/
// package com.koch.ambeth.query.isin;
//
// import org.junit.Assert;
// import org.junit.Test;
// import org.junit.experimental.categories.Category;
//
// import com.koch.ambeth.config.ServiceConfigurationConstants;
// import com.koch.ambeth.ioc.annotation.Autowired;
// import com.koch.ambeth.persistence.config.PersistenceConfigurationConstants;
// import com.koch.ambeth.testutil.AbstractInformationBusWithPersistenceTest;
// import com.koch.ambeth.testutil.SQLData;
// import com.koch.ambeth.testutil.SQLDataRebuild;
// import com.koch.ambeth.testutil.SQLStructure;
// import com.koch.ambeth.testutil.TestModule;
// import com.koch.ambeth.testutil.TestProperties;
// import com.koch.ambeth.testutil.TestPropertiesList;
// import com.koch.ambeth.testutil.category.PerformanceTests;
//
// @Category(PerformanceTests.class)
// @TestModule(QueryIsInMassdataTestModule.class)
// @SQLDataRebuild(false)
// @SQLData("QueryIsInMassdata_data.sql")
// @SQLStructure("QueryIsInMassdata_structure.sql")
// @TestPropertiesList({
// @TestProperties(name = PersistenceConfigurationConstants.AutoIndexForeignKeys, value = "false"),
// @TestProperties(name = PersistenceConfigurationConstants.DatabasePoolMaxUsed, value = "20"),
// @TestProperties(name = ServiceConfigurationConstants.mappingFile, value =
// "com/koch/ambeth/query/isin/QueryIsInMassdata_orm.xml"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.cache.DefaultPersistenceCacheRetriever",
// value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.filter.PagingQuery", value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.orm.XmlDatabaseMapper", value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.persistence.EntityLoader", value =
// "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.persistence.jdbc.JdbcTable", value =
// "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.persistence.jdbc.JDBCDatabaseWrapper",
// value = "INFO"),
// // @TestProperties(name =
// "ambeth.log.level.com.koch.ambeth.persistence.jdbc.connection.LogPreparedStatementInterceptor",
// value = "INFO"),
// @TestProperties(name =
// "ambeth.log.level.com.koch.ambeth.persistence.jdbc.connection.LogStatementInterceptor", value =
// "INFO"),
// @TestProperties(name =
// "ambeth.log.level.com.koch.ambeth.persistence.jdbc.database.JdbcTransaction", value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.proxy.AbstractCascadePostProcessor",
// value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.cache.CacheLocalDataChangeListener",
// value = "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.cache.FirstLevelCacheManager", value =
// "INFO"),
// @TestProperties(name = "ambeth.log.level.com.koch.ambeth.service.MergeService", value = "INFO")
// })
// public class QueryIsInMassdataTest extends AbstractInformationBusWithPersistenceTest
// {
// protected static long timeForEquals = 0;
//
// protected static long timeForIsIn = 0;
//
// @Autowired
// protected IChildService childService;
//
// @Test
// public void testTimeForEquals() throws Exception
// {
// long start = System.currentTimeMillis();
// for (int a = 100; a-- > 0;)
// {
// childService.searchForParentWithEquals(10001);
// }
// timeForEquals = System.currentTimeMillis() - start;
// checkTimes();
// }
//
// @Test
// public void testTimeForIsIn() throws Exception
// {
// long start = System.currentTimeMillis();
// for (int a = 100; a-- > 0;)
// {
// childService.getForParentWithIsIn(10002);
// }
// timeForIsIn = System.currentTimeMillis() - start;
// checkTimes();
// }
//
// @Test
// public void testTimeForIsInMoreThan4000() throws Exception
// {
// int[] parentIds = new int[4005]; // Force UNION > 4000
// for (int a = parentIds.length; a-- > 0;)
// {
// parentIds[a] = 10000 + a;
// }
// long start = System.currentTimeMillis();
// childService.getForParentWithIsIn(parentIds);
// timeForIsIn = System.currentTimeMillis() - start;
// checkTimes();
// }
//
// private void checkTimes()
// {
// if (timeForEquals > 0 && timeForIsIn > 0)
// {
// if (timeForEquals < 50)
// {
// Assert.fail("Difference not significant. Use a larger number of entities.");
// }
// if (timeForIsIn > timeForEquals * 1.5)
// {
// Assert.fail("IsIn is to slow: timeForEquals = " + timeForEquals + ", timeForIsIn = " +
// timeForIsIn);
// }
// }
// }
// }
| [
"[email protected]"
] | |
236ee00a404331c33c5ffa70d503d1aa717e3c61 | c23c798bfd5be722be72eaf609b6460428a44cf4 | /src/main/java/org/example/config/ConfigDB.java | 584d2dfa941db8364c9135d0f25ae1167ffc1e58 | [] | no_license | dianabartkow/Forum_project | 4b1ef5b884e1f621aa88fa2e07f5af8dd833ee51 | fad6d3ff096ebdb766306a410a065b438ec6f703 | refs/heads/master | 2023-06-03T22:12:09.043377 | 2021-06-29T12:10:49 | 2021-06-29T12:10:49 | 381,323,457 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,363 | java | package org.example.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.Properties;
@Configuration
@EnableJpaRepositories("org.example.repository")
@EnableTransactionManagement
public class ConfigDB {
@Bean
public EntityManager getEntityManager(final EntityManagerFactory emf) {
return emf.createEntityManager();
}
@Bean
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
final LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
entityManagerFactoryBean.setDataSource(dataSource());
entityManagerFactoryBean.setPackagesToScan("org.example.entity");
final HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
entityManagerFactoryBean.setJpaVendorAdapter(vendorAdapter);
entityManagerFactoryBean.setJpaProperties(additionalProperties());
return entityManagerFactoryBean;
}
final Properties additionalProperties() {
final Properties hibernateProperties = new Properties();
hibernateProperties.setProperty("hibernate.hbm2ddl.auto", "update");
hibernateProperties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQL8Dialect");
// hibernateProperties.setProperty("hibernate.cache.use_second_level_cache", "hibernate.cache.use_second_level_cache");
hibernateProperties.setProperty("hibernate.cache.use_query_cache", "hibernate.cache.use_query_cache");
hibernateProperties.setProperty("hibernate.show_sql", "true");
return hibernateProperties;
}
@Bean
public DataSource dataSource() {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.cj.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost/forum_db?serverTimezone=UTC");
dataSource.setUsername("root");
dataSource.setPassword("Kajak1111-");
return dataSource;
}
@Bean
public PlatformTransactionManager transactionManager(final EntityManagerFactory emf) {
final JpaTransactionManager transactionManager = new JpaTransactionManager();
transactionManager.setEntityManagerFactory(emf);
transactionManager.setDataSource(dataSource());
return transactionManager;
}
@Bean
public PersistenceExceptionTranslationPostProcessor exceptionTranslation() {
return new PersistenceExceptionTranslationPostProcessor();
}
}
| [
"[email protected]"
] | |
64e9f9f2063cfb34aed3decc42a49c5e340400bf | 77ef22afcc22a5b9978e39bd2845357abd575b78 | /Practice/src/practice02/PTra02_02.java | 493ef824547e76c51d3c6517179f3e1f8f2f26ec | [] | no_license | TakahiroKinebuchi/JavaBasic | 3e0fa88331b36f4a01f6cc1b4886c16a88e36298 | 7faaaedabd5d818e067ac4737bff1f5b6f32359c | refs/heads/master | 2021-01-24T03:38:11.833313 | 2018-03-20T08:45:28 | 2018-03-20T08:45:28 | 122,898,156 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 577 | java | package practice02;
/*
* PTra02_02.java
* ไฝๆ LIKEIT 2017
*------------------------------------------------------------
* Copyright(c) Rhizome Inc. All Rights Reserved.
*/
public class PTra02_02 {
public static void main(String[] args) {
int num = 10;
System.out.println(num);
// โ
ๅคๆฐnumใฎๅคใซ30่ถณใใๆฐใๅบๅใใฆใใ ใใ
System.out.println(num + 30);
// โ
ไปฅไธใฎใใญใฐใฉใ ใง40ใๅบๅใใใใใใซใใฆใใ ใใ
num*= 4;
System.out.println(num); // โปโป ใใฎ่กใฏไฟฎๆญฃใใชใใงใใ ใใ
}
}
| [
"[email protected]"
] | |
f7b509b2d39d886d37ba4da2e279e6735c22a7ac | 5a2209ad0ad6391ed535ecac24a02a95580803f6 | /Assignment 2/Coding/CompanyInfo.java | 3f9ee3f2208e5fae59d7c4d0ea665f80e63d59e7 | [] | no_license | Zulhasnan277834/A202-STIA1123 | f526b3b60d14fdba31a5e2268b90f374a6c330ad | ed318315701b96b40bcb7a9609b7fe911ba57846 | refs/heads/main | 2023-06-10T11:23:55.318423 | 2021-07-06T14:28:03 | 2021-07-06T14:28:03 | 352,245,661 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,035 | java | package Assignment01;
import java.util.Scanner;
public abstract class CompanyInfo { // 2.4 Abstaction
Scanner s = new Scanner(System.in);
private String name;
private String contact;
private String email;
private String location;
CompanyInfo(){
setName("Mystorage");
setContact("8582088");
setEmail("[email protected]");
setLocation("Kemaman,Terengganu");
}
//setter
public void setName(String name) { //2.3 Encapsulation (setter)
this.name = name;
}
public void setContact(String contact) {
this.contact = contact;
}
public void setEmail(String email) {
this.email = email;
}
public void setLocation(String location) {
this.location = location;
}
//getter
public String getName() { //2.3 Encapsulation (getter)
return name;
}
public String getContact() {
return contact;
}
public String getMail() {
return email;
}
public String getLocation() {
return location;
}
public abstract void printInfo();
}
| [
"[email protected]"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.