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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d08e098d65946f4c36d7e05e57d9e669a709130a | 3180cf74a320e83a57c088283388be17f0168e16 | /Work Space/Cueify/src/com/cueify/extension/LocalDragboard.java | fad11e49f2b0f2f69a823af3df77464651b2b7bb | [] | no_license | mikeg2/Cueify | 9b3aba80ebd391199c8a22eb021880974e828a29 | 333fb42b9c827776a0fec7008e5a33b8a6a76a3b | refs/heads/master | 2016-08-04T21:30:01.817281 | 2015-03-21T20:57:42 | 2015-03-21T20:57:42 | 32,649,716 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 982 | java | package com.cueify.extension;
import java.util.HashMap;
import java.util.Map;
public class LocalDragboard {
private final Map<Class<?>, Object> contents ;
private final static LocalDragboard instance = new LocalDragboard();
private LocalDragboard() {
this.contents = new HashMap<Class<?>, Object>();
}
public static LocalDragboard getInstance() {
return instance ;
}
public <T> void putValue(Class<? extends Object> class1, T t) {
contents.put(class1, class1.cast(t));
}
public <T> T getValue(Class<T> type) {
return type.cast(contents.get(type));
}
public boolean hasType(Class<?> type) {
return contents.keySet().contains(type);
}
public void clear(Class<?> type) {
contents.remove(type);
}
public void clearAll() {
contents.clear();
}
} | [
"[email protected]"
] | |
2a78b9c0593e808271dd4f494cb4458fc1a732ad | c15907f43a7831452493f42418fc8b2ecf067e22 | /lab2/src/PartTwoTestCases.java | ef92abca5be8e86a426ca5119b237f8d86722d69 | [] | no_license | TheCoolBoots/CPE203 | 6ccda748c50c281dca34d69a0da8ff96fafcb630 | a0f1281007b7b80b15c5d3687e0b39878cf037f3 | refs/heads/master | 2020-04-22T02:20:34.714269 | 2019-03-15T20:02:00 | 2019-03-15T20:02:00 | 170,045,089 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,330 | java | import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import org.junit.Test;
public class PartTwoTestCases
{
public static final double DELTA = 0.00001;
@Test
public void testCircleImplSpecifics()
throws NoSuchMethodException
{
final List<String> expectedMethodNames = Arrays.asList(
"getCenter", "getRadius", "perimeter");
final List<Class> expectedMethodReturns = Arrays.asList(
Point.class, double.class, double.class);
final List<Class[]> expectedMethodParameters = Arrays.asList(
new Class[0], new Class[0], new Class[0]);
verifyImplSpecifics(Circle.class, expectedMethodNames,
expectedMethodReturns, expectedMethodParameters);
}
@Test
public void testRectangleImplSpecifics()
throws NoSuchMethodException
{
final List<String> expectedMethodNames = Arrays.asList(
"getTopLeft", "getBottomRight", "perimeter");
final List<Class> expectedMethodReturns = Arrays.asList(
Point.class, Point.class, double.class);
final List<Class[]> expectedMethodParameters = Arrays.asList(
new Class[0], new Class[0], new Class[0]);
verifyImplSpecifics(Rectangle.class, expectedMethodNames,
expectedMethodReturns, expectedMethodParameters);
}
@Test
public void testPolygonImplSpecifics()
throws NoSuchMethodException
{
final List<String> expectedMethodNames = Arrays.asList(
"getPoints", "perimeter");
final List<Class> expectedMethodReturns = Arrays.asList(
List.class, double.class);
final List<Class[]> expectedMethodParameters = Arrays.asList(
new Class[0], new Class[0]);
verifyImplSpecifics(Polygon.class, expectedMethodNames,
expectedMethodReturns, expectedMethodParameters);
}
private static void verifyImplSpecifics(
final Class<?> clazz,
final List<String> expectedMethodNames,
final List<Class> expectedMethodReturns,
final List<Class[]> expectedMethodParameters)
throws NoSuchMethodException
{
assertEquals("Unexpected number of public fields",
0, Point.class.getFields().length);
final List<Method> publicMethods = Arrays.stream(
clazz.getDeclaredMethods())
.filter(m -> Modifier.isPublic(m.getModifiers()))
.collect(Collectors.toList());
assertEquals("Unexpected number of public methods",
expectedMethodNames.size(), publicMethods.size());
assertTrue("Invalid test configuration",
expectedMethodNames.size() == expectedMethodReturns.size());
assertTrue("Invalid test configuration",
expectedMethodNames.size() == expectedMethodParameters.size());
for (int i = 0; i < expectedMethodNames.size(); i++)
{
Method method = clazz.getDeclaredMethod(expectedMethodNames.get(i),
expectedMethodParameters.get(i));
assertEquals(expectedMethodReturns.get(i), method.getReturnType());
}
}
}
| [
"[email protected]"
] | |
78780e4b7cf98ddba5cf8407f2c25fdd2962ac15 | 5caf48b42defee4f40d0ef946dc8f92ba01063dc | /java/25/abstract_test/Salary.java | 105810211a7fdb90f16dfbc5dc65752aeb86e06d | [] | no_license | heianzhongdeshouhu/unix_network_programming | b2a5c7c1c1068159b2d6677391c37702ef9e30ef | d8bddcf6039620089025fc7bc38fa8418d70bc11 | refs/heads/master | 2021-01-10T10:40:48.141293 | 2017-04-28T10:13:08 | 2017-04-28T10:13:08 | 53,867,920 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 285 | java |
public class Salary extends Employee {
private double salary;
public double computePay() {
//System.out.println("Computing salary pay for " + getName());
System.out.println("Computing salary pay for " + " temporary usage.");
return salary/52;
}
}
| [
"xinkuaisuile@126com"
] | xinkuaisuile@126com |
f9e0d71c394e4d2b983d24ebd4ec66fc21431c86 | 708574dd0736e53008e6b357abaacf4cbc92fc7b | /src/main/java/com/example/ocr/Controller/OcrImageController.java | bc2fb8944273f06fd9a559bea7dc05389b39d6bd | [] | no_license | Nanthiny/OCR-SpringBoot_Backend | dd57ddbcf265b16fa33ead7c70e7689cce4ec69b | ef00af9c15f2332f0fd0b651dfff8416bf6681dd | refs/heads/master | 2020-12-09T05:21:57.959582 | 2020-01-11T09:12:02 | 2020-01-11T09:12:02 | 233,205,822 | 0 | 0 | null | 2020-01-11T09:17:44 | 2020-01-11T09:17:44 | null | UTF-8 | Java | false | false | 95 | java | package com.example.ocr.Controller;
import java.io.File;
public class OcrImageController {
}
| [
"[email protected]"
] | |
a8f08c9e4aaf246df92fc1451d6aaee918c78275 | e6356bebcc294ef7c8af2f828ebdbcf34fb1cf95 | /3 survey-handover_mhub@a7072cb1c04/api/src/main/java/com/mainlevel/monitoring/survey/api/exception/EvaluationQueryNotFoundException.java | b4f7678c4a1a370e2a2e28d4f12c417ad7e837eb | [] | no_license | kondwa/nape-backend | e7a0a9df042a8d2fe3c24ff65e7eb58ae276bb04 | 3d877a05707177081a0fb14ae0728363261cb74b | refs/heads/master | 2023-02-11T02:49:44.226746 | 2021-01-07T11:11:32 | 2021-01-07T11:11:32 | 327,583,710 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 823 | java | package com.mainlevel.monitoring.survey.api.exception;
import java.text.MessageFormat;
/**
* Raised when the evaluation query could not be found.
*/
@SuppressWarnings("serial")
public class EvaluationQueryNotFoundException extends RuntimeException {
private static final String MESSAGE = "Cypher query with name [{0}] not found.";
private String query;
/**
* Constructor for EvaluationQueryNotFoundException.
*
* @param query name of the missing query
*/
public EvaluationQueryNotFoundException(String query) {
super(MessageFormat.format(MESSAGE, query));
this.query = query;
}
/**
* Gets the query for EvaluationQueryNotFoundException.
*
* @return query the query name
*/
public String getQuery() {
return query;
}
}
| [
"[email protected]"
] | |
51c2fa35eeee5836d6419c5e22c3180a10c8edfe | 69bb76650dd536ad900bc59d349f62984f334051 | /mybatis-genertor/src/main/java/com/issac/ssm/mapper/UsersMapper.java | e0df12c7a7fb3bb6dfb39d45c30029d421dfbc59 | [] | no_license | IssacYoung2013/pratice | 932fbadc060c8a9327655393b8802fe148dbd4ff | 9636d070a0b8dc8a72d8f949925f189ae241db14 | refs/heads/master | 2022-12-23T02:58:54.986926 | 2019-08-01T00:37:41 | 2019-08-01T00:37:41 | 191,263,461 | 0 | 0 | null | 2022-12-16T04:34:02 | 2019-06-11T00:15:38 | Java | UTF-8 | Java | false | false | 620 | java | package com.issac.mapper;
import com.issac.mvc.po.Users;
import com.issac.mvc.po.UsersExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface UsersMapper {
int countByExample(UsersExample example);
int deleteByExample(UsersExample example);
int insert(Users record);
int insertSelective(Users record);
List<Users> selectByExample(UsersExample example);
int updateByExampleSelective(@Param("record") Users record, @Param("example") UsersExample example);
int updateByExample(@Param("record") Users record, @Param("example") UsersExample example);
} | [
"[email protected]"
] | |
0df558437ca7b976bf8ad86256e0237ecc37b670 | 79540667d1a68861fcd53f99c6b58e48e91ffef0 | /app/src/main/java/vn/poly/apptruyen/ui/ThemNguoiDungActivity.java | 26c06a287e1101f7f59c8520e537267ae2399cad | [] | no_license | trancutuad/Apptruyentranh | 8e52bd6d78f820814fb74da9c7486f76fe43d838 | 89df512e3b6f5c4f7f55156583f334edb74f46e7 | refs/heads/master | 2023-01-28T11:22:40.104579 | 2020-12-09T16:38:22 | 2020-12-09T16:38:22 | 320,016,268 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,182 | java | package vn.poly.apptruyen.ui;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import vn.poly.apptruyen.R;
import vn.poly.apptruyen.dao.NguoiDungDao;
import vn.poly.apptruyen.model.NguoiDung;
public class ThemNguoiDungActivity extends AppCompatActivity {
private EditText edUserName;
private EditText edfullname;
private EditText edtPassword;
private EditText edtPassword2;
private EditText edtphone;
private Button btnadduser;
NguoiDungDao nguoiDungDao;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_them_nguoi_dung);
setTitle("Thêm Người Dùng");
initView();
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
btnadduser.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
addUser();
}
});
}
private void initView() {
edUserName = (EditText) findViewById(R.id.edUserName);
edtPassword = (EditText) findViewById(R.id.edtPassword);
edtPassword2 = (EditText) findViewById(R.id.edtPassword2);
btnadduser = (Button) findViewById(R.id.btnadduser);
}
public void addUser() {
nguoiDungDao = new NguoiDungDao(ThemNguoiDungActivity.this);
NguoiDung user = new NguoiDung(edUserName.getText().toString(), edtPassword.getText().toString());
try {
if (validateForm()>0){
if (nguoiDungDao.insertNguoiDung(user)>0){
Toast.makeText(getApplicationContext(), "Thêm thành công", Toast.LENGTH_SHORT).show();
// Intent b = new Intent(ThemNguoiDungActivity.this, NguoidungActivity.class);
// startActivity(b);
}else {
Toast.makeText(getApplicationContext(), "Thêm thất bại", Toast.LENGTH_SHORT).show();
}
}
}catch (Exception e){
Log.e("Error",e.toString());
}
}
public int validateForm() {
int check = 1;
if (edUserName.getText().length() == 0 || edtPassword.getText().length() == 0
|| edtPassword2.getText().length() == 0) {
Toast.makeText(getApplicationContext(), "Bạn phải nhập đủ thông tin", Toast.LENGTH_SHORT).show();
check = -1;
} else {
String pass = edtPassword.getText().toString();
String rePass= edtPassword2.getText().toString();
if (pass.length()<6){
edtPassword.setError(getString(R.string.notify_length_pass));
check = -1;
}
if (!pass.equals(rePass)){
edtPassword2.setError("Mật khẩu phải trùng nhau");
check =-1;
}
}
return check;
}
}
| [
"[email protected]"
] | |
e299ed6ae0f97b9f18cd656e4bb28a104fcb60b2 | 640ef44fa574b497ef200dfd7b819a1ea63cfac1 | /service/resort/src/test/java/airbnski/resort/generated/model/WeatherTest.java | 63181a65895b446b95a86b4c871243e86a0a0646 | [] | no_license | airbnski/skiapp | 6fbd75dedd066e380035c41006c32a31285b3a2d | b911dc676010732e28f6f361d6d75467110cbd19 | refs/heads/develop | 2023-05-06T21:40:28.559951 | 2021-05-30T19:24:32 | 2021-05-30T19:24:32 | 354,271,296 | 1 | 1 | null | 2021-05-30T19:33:22 | 2021-04-03T11:14:06 | Java | UTF-8 | Java | false | false | 1,006 | java | package airbnski.resort.generated.model;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
public class WeatherTest {
@Test
public void testEquals() {
assertFalse((new Weather()).equals("42"));
assertFalse((new Weather()).equals(null));
}
@Test
public void testHashCode() {
assertEquals(961, (new Weather()).hashCode());
}
@Test
public void testConstructor() {
Weather actualWeather = new Weather();
actualWeather.outlook("Outlook");
actualWeather.setOutlook("Outlook");
actualWeather.setTemperature(10.0);
actualWeather.temperature(10.0);
assertEquals("Outlook", actualWeather.getOutlook());
assertEquals(10.0, actualWeather.getTemperature().doubleValue());
assertEquals("class Weather {\n temperature: 10.0\n outlook: Outlook\n}", actualWeather.toString());
}
}
| [
"[email protected]"
] | |
19c3cdc071b706377b3f049705f12e5c8d60d1ed | 616257d2f38ebec5c7bc9061cadcbd2997499ea3 | /src/ru/ifmo/base/testlesson/PrimitiveWrapper.java | 102c23ee50ff9105eface081d84f3c02a5221da2 | [] | no_license | mbarannikov/Lessons | 5cc6c40caa41107b0a3b5d65e6d95b51c688a1f5 | bb23dd485b2c8712d6f9bb28a4e5027f878facc1 | refs/heads/master | 2021-03-05T11:02:41.817625 | 2020-06-20T09:05:26 | 2020-06-20T09:05:26 | 246,117,405 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,243 | java | package ru.ifmo.base.testlesson;
public class PrimitiveWrapper {
public static void main(String[] args) {
// class Byte, Short, Integer, Long, Float, Double, Character, Boolean
// всегда нужно использовать примитивы, за исключением
// 1. когда использование примитивов не возможно и
// 2. когда необходимо воспользоваться методами классов - оберток
int count = 267;
// Integer age = new Integer(200);
Integer age = 200;
// автоупаковка и автораспаковка
Integer num = 12;
double price;
Double someDouble = 45.12;
price = someDouble;
byte one = 1;
num = (int) one;
Byte two = 2;
int num2 = num;
PrimitiveWrapper.int2(3);
// автоупаковка и распаковка не работает с массивами
double[] doubles = {2.16, 3.14, -9.99};
// double2Console(doubles);
num.intValue(); // вернет примитив
// parse возращает примитив, valueOf объект
System.out.println(Byte.parseByte("2")); // byte
System.out.println(Byte.valueOf("2")); // Byte
System.out.println(Integer.parseInt("34"));
System.out.println(Integer.valueOf("34"));
System.out.println(num.hashCode());
System.out.println(Long.TYPE);
Long first = 55L;
Long second = 55L;
System.out.println(Long.compare(first,second));
System.out.println(first==second);
Integer someInt = 12;
Integer someInt2 = 12;
System.out.println(someInt.compareTo(someInt2));
System.out.println(Integer.compare(someInt,someInt2));
System.out.println(second.equals(first));
System.out.println(Integer.BYTES);
}
private static void int2 (Integer someInt){
System.out.println("Квадрат значения="+someInt*someInt);
}
private static void double2Console (Double[] doubles){
for (Double d: doubles) {
System.out.println(" "+d);
}
}
}
| [
"[email protected]"
] | |
ce7f721f04dcbdba5933c27751c0f44fc1b47377 | eff8f7d148aaee5a2d6dc7106f2948e73e8f75b3 | /patching/rename/fragment.java | 5571a844fa15686919e38f1217fcbcedf01068ee | [] | no_license | mr-segfault/footpatch | 635d56e8137a45e2daf55320426e3fa330c2906b | 8b79c1964d89b833179aed7ed4fde0638a435782 | refs/heads/master | 2020-08-27T10:28:58.301625 | 2019-09-20T17:16:59 | 2019-09-20T17:16:59 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 27 | java | checkGuardedBy(n != null);
| [
"[email protected]"
] | |
670bc8078c97b188b63d1f3dc75e3e731234f902 | 94d91903819947c4fb2598af40cf53344304dbac | /wssmall_1.2.0/orderctn_server/src/main/java/com/ztesoft/net/mall/outter/inf/exe/ThreadExecuter.java | 6884687d9208b80d22627dcd99d088dbc11d0fe4 | [] | no_license | lichao20000/Union | 28175725ad19733aa92134ccbfb8c30570f4795a | a298de70065c5193c98982dacc7c2b3e2d4b5d86 | refs/heads/master | 2023-03-07T16:24:58.933965 | 2021-02-22T12:34:05 | 2021-02-22T12:34:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,642 | java | package com.ztesoft.net.mall.outter.inf.exe;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.ztesoft.net.framework.context.spring.SpringContextHolder;
import com.ztesoft.net.mall.outter.inf.iservice.IOrderSyncService;
import com.ztesoft.net.mall.outter.inf.iservice.IOutterECSTmplCtnManager;
import com.ztesoft.net.mall.outter.inf.model.OutterTmpl;
public class ThreadExecuter {
//newFixedThreadPool
//创建固定大小的线程池。每次提交一个任务就创建一个线程,直到线程达到线程池的最大大小。线程池的大小一旦达到最大值就会保持不变,如果某个线程因为执行异常而结束,那么线程池会补充一个新线程。
//newCachedThreadPool
//创建一个可缓存的线程池。如果线程池的大小超过了处理任务所需要的线程,
//那么就会回收部分空闲(60秒不执行任务)的线程,当任务数增加时,此线程池又可以智能的添加新线程来处理任务。此线程池不会对线程池大小做限制,线程池大小完全依赖于操作系统(或者说JVM)能够创建的最大线程大小。
//private ExecutorService orderExecutor = Executors.newCachedThreadPool();
/**
* 创建固定大小为5的线程池
*/
private static final ExecutorService orderExecutor = Executors.newFixedThreadPool(5);
public static void executeOrderTask(OrderSyncThread orderSync){
orderExecutor.execute(orderSync);
}
public static class OrderSyncThread implements Runnable {
private OutterTmpl tmpl;
protected IOutterECSTmplCtnManager outterECSTmplCtnManager;
public OrderSyncThread(OutterTmpl tmpl) {
this.tmpl = tmpl;
}
@Override
public void run() {
try{
outterECSTmplCtnManager = SpringContextHolder.getBean("outterECSTmplCtnManager");
IOrderSyncService service = SpringContextHolder.getBean("outerOrderSyncCtn");
service.perform(tmpl);
if(-1!=tmpl.getExecute_min().intValue())
outterECSTmplCtnManager.updateRunStatus("00A", tmpl.getTmpl_id());
}catch(Exception ex){
if(-1==tmpl.getExecute_min().intValue()){
outterECSTmplCtnManager.updateRunStatus("00A", "同步失败["+ex.getMessage()+"]",0, tmpl.getTmpl_id());
}else{
outterECSTmplCtnManager.updateRunStatus("00A", tmpl.getTmpl_id());
outterECSTmplCtnManager.updateTmplExecuteInfo(tmpl.getTmpl_id(), 0, 1, tmpl.getExecute_min(), null,"同步失败["+ex.getMessage()+"]");
}
ex.printStackTrace();
}
}
public OutterTmpl getTmpl() {
return tmpl;
}
public void setTmpl(OutterTmpl tmpl) {
this.tmpl = tmpl;
}
}
}
| [
"hxl971230.outlook.com"
] | hxl971230.outlook.com |
d1d985998095c83964ce48192b85997494a7acc6 | f2bcdc92a4efc9c0b012d4d8f540d6e4ea8ae005 | /src/main/java/com/l1sk1sh/vladikbot/data/entity/SentMeme.java | fa739ae32b7cda9b7ee64e92f4649d06d413c7eb | [
"Apache-2.0"
] | permissive | l1sk1sh/vladikbot | bd1de45ba430fbd789f3d5485dbb529d076fb3f9 | f0940d58d8b3301494da037051b2465dbb374f96 | refs/heads/master | 2023-07-21T08:51:58.624164 | 2023-06-28T11:43:07 | 2023-06-28T11:43:07 | 173,055,609 | 3 | 2 | Apache-2.0 | 2023-03-01T14:57:02 | 2019-02-28T06:34:50 | Java | UTF-8 | Java | false | false | 451 | java | package com.l1sk1sh.vladikbot.data.entity;
import lombok.*;
import javax.persistence.*;
/**
* @author l1sk1sh
*/
@Getter
@Setter
@RequiredArgsConstructor
@NoArgsConstructor
@ToString
@Entity
@Table(name = "sent_memes")
public class SentMeme {
@Setter(AccessLevel.NONE)
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
@Column(name = "meme_id", nullable = false)
@NonNull
private String memeId;
}
| [
""
] | |
69615c20ac1331181757a8562d07e2bbcb803f42 | b7239406d3ce3f71c232466700ba97373bf8a6e8 | /app/src/main/java/com/mobileia/contacts/example/CustomActivity.java | 722d9c73e74712d1aee4ecd8331f0b28782ea1d2 | [] | no_license | MobileIA/mia-contacts-android | d257733453bd3ad16a747e8228b6ea27f6f724f3 | 7f0ee5c61029c0a56866773166569fe3e98ddb72 | refs/heads/master | 2021-05-10T14:16:30.803387 | 2018-06-14T01:35:52 | 2018-06-14T01:35:52 | 118,510,040 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 346 | java | package com.mobileia.contacts.example;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class CustomActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_custom);
}
}
| [
"[email protected]"
] | |
479cfbe7b44dfd226c29f216256fffe73d610061 | 26b7f30c6640b8017a06786e4a2414ad8a4d71dd | /src/number_of_direct_superinterfaces/i11305.java | 5892b290e722f7b1c6633f3238937c1a3d9cc48b | [] | no_license | vincentclee/jvm-limits | b72a2f2dcc18caa458f1e77924221d585f23316b | 2fd1c26d1f7984ea8163bc103ad14b6d72282281 | refs/heads/master | 2020-05-18T11:18:41.711400 | 2014-09-14T04:25:18 | 2014-09-14T04:25:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 69 | java | package number_of_direct_superinterfaces;
public interface i11305 {} | [
"[email protected]"
] | |
74c5f688c8f998c8d7e1322d754849068458e595 | 762c199d96cc2a6dff3b14290103e33e9ecc39ed | /mogu_xo/src/main/java/com/moxi/mogublog/xo/utils/WebUtil.java | 8e80492b6d3600251a0be775e10152e48a5923cf | [
"Apache-2.0"
] | permissive | watson1101/mogu_blog_v2 | 8404d70f2c5ccde9b905f552665b645d1bbb3735 | 580b59fbca054343e1755dbf9ed78ec411577f06 | refs/heads/master | 2022-12-26T10:51:42.003512 | 2020-10-09T08:21:43 | 2020-10-09T08:24:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,207 | java | package com.moxi.mogublog.xo.utils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moxi.mogublog.commons.entity.SystemConfig;
import com.moxi.mogublog.utils.JsonUtils;
import com.moxi.mogublog.utils.RedisUtil;
import com.moxi.mogublog.xo.global.MessageConf;
import com.moxi.mogublog.xo.global.RedisConf;
import com.moxi.mogublog.xo.global.SQLConf;
import com.moxi.mogublog.xo.global.SysConf;
import com.moxi.mogublog.xo.service.SystemConfigService;
import com.moxi.mougblog.base.enums.EOpenStatus;
import com.moxi.mougblog.base.enums.EStatus;
import com.moxi.mougblog.base.exception.exceptionType.QueryException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* web有关的工具类
*
* @author 陌溪
* @date 2020年4月6日23:42:41
*/
@Slf4j
@Component
public class WebUtil {
@Autowired
private SystemConfigService systemConfigService;
@Autowired
private RedisUtil redisUtil;
/**
* 格式化数据获取图片列表
*
* @param result
* @return
*/
public List<String> getPicture(String result) {
String picturePriority = "";
String localPictureBaseUrl = "";
String qiNiuPictureBaseUrl = "";
// 从Redis中获取系统配置
String systemConfigJson = redisUtil.get(RedisConf.SYSTEM_CONFIG);
if (StringUtils.isEmpty(systemConfigJson)) {
QueryWrapper<SystemConfig> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
SystemConfig systemConfig = systemConfigService.getOne(queryWrapper);
if (systemConfig == null) {
throw new QueryException(MessageConf.SYSTEM_CONFIG_IS_NOT_EXIST);
} else {
// 将系统配置存入Redis中【设置过期时间24小时】
redisUtil.setEx(RedisConf.SYSTEM_CONFIG, JsonUtils.objectToJson(systemConfig), 24, TimeUnit.HOURS);
}
picturePriority = systemConfig.getPicturePriority();
localPictureBaseUrl = systemConfig.getLocalPictureBaseUrl();
qiNiuPictureBaseUrl = systemConfig.getQiNiuPictureBaseUrl();
} else {
SystemConfig systemConfig = JsonUtils.jsonToPojo(systemConfigJson, SystemConfig.class);
picturePriority = systemConfig.getPicturePriority();
localPictureBaseUrl = systemConfig.getLocalPictureBaseUrl();
qiNiuPictureBaseUrl = systemConfig.getQiNiuPictureBaseUrl();
}
List<String> picUrls = new ArrayList<>();
try {
Map<String, Object> picMap = (Map<String, Object>) JsonUtils.jsonToObject(result, Map.class);
if (SysConf.SUCCESS.equals(picMap.get(SysConf.CODE))) {
List<Map<String, Object>> picData = (List<Map<String, Object>>) picMap.get(SysConf.DATA);
if (picData.size() > 0) {
for (int i = 0; i < picData.size(); i++) {
if ("1".equals(picturePriority)) {
picUrls.add(qiNiuPictureBaseUrl + picData.get(i).get(SysConf.QI_NIU_URL));
} else {
picUrls.add(localPictureBaseUrl + picData.get(i).get(SysConf.URL));
}
}
}
}
} catch (Exception e) {
log.error("从Json中获取图片列表失败");
log.error(e.getMessage());
return picUrls;
}
return picUrls;
}
/**
* 获取图片,返回Map
*
* @param result
* @return
*/
public List<Map<String, Object>> getPictureMap(String result) {
String picturePriority = "";
String localPictureBaseUrl = "";
String qiNiuPictureBaseUrl = "";
// 从Redis中获取系统配置
String systemConfigJson = redisUtil.get(RedisConf.SYSTEM_CONFIG);
if (StringUtils.isEmpty(systemConfigJson)) {
QueryWrapper<SystemConfig> queryWrapper = new QueryWrapper<>();
queryWrapper.eq(SQLConf.STATUS, EStatus.ENABLE);
SystemConfig systemConfig = systemConfigService.getOne(queryWrapper);
if (systemConfig == null) {
throw new QueryException(MessageConf.SYSTEM_CONFIG_IS_NOT_EXIST);
} else {
// 将系统配置存入Redis中【设置过期时间24小时】
redisUtil.setEx(RedisConf.SYSTEM_CONFIG, JsonUtils.objectToJson(systemConfig), 24, TimeUnit.HOURS);
}
picturePriority = systemConfig.getPicturePriority();
localPictureBaseUrl = systemConfig.getLocalPictureBaseUrl();
qiNiuPictureBaseUrl = systemConfig.getQiNiuPictureBaseUrl();
} else {
SystemConfig systemConfig = JsonUtils.jsonToPojo(systemConfigJson, SystemConfig.class);
picturePriority = systemConfig.getPicturePriority();
localPictureBaseUrl = systemConfig.getLocalPictureBaseUrl();
qiNiuPictureBaseUrl = systemConfig.getQiNiuPictureBaseUrl();
}
List<Map<String, Object>> resultList = new ArrayList<>();
Map<String, Object> picMap = (Map<String, Object>) JsonUtils.jsonToObject(result, Map.class);
if (SysConf.SUCCESS.equals(picMap.get(SysConf.CODE))) {
List<Map<String, Object>> picData = (List<Map<String, Object>>) picMap.get(SysConf.DATA);
if (picData.size() > 0) {
for (int i = 0; i < picData.size(); i++) {
Map<String, Object> map = new HashMap<>();
if (StringUtils.isEmpty(picData.get(i).get(SysConf.URL)) || StringUtils.isEmpty(picData.get(i).get(SysConf.UID))) {
continue;
}
// 图片优先显示 七牛云 or 本地
if (EOpenStatus.OPEN.equals(picturePriority)) {
map.put(SysConf.URL, qiNiuPictureBaseUrl + picData.get(i).get(SysConf.QI_NIU_URL));
} else {
map.put(SysConf.URL, localPictureBaseUrl + picData.get(i).get(SysConf.URL));
}
map.put(SysConf.UID, picData.get(i).get(SysConf.UID));
resultList.add(map);
}
}
} else if (SysConf.ERROR.equals(picMap.get(SysConf.CODE))) {
log.error("获取图片失败,图片服务出现异常:{}", picMap.get(SysConf.MESSAGE));
} else {
log.error("获取图片失败");
}
return resultList;
}
/**
* 获取结果集的内容
*
* @param result
* @return
*/
public <T> T getData(String result, Class<T> beanType) {
if (com.moxi.mogublog.utils.StringUtils.isEmpty(result)) {
return null;
}
Map<String, Object> dataMap = (Map<String, Object>) JsonUtils.jsonToObject(result, Map.class);
if (SysConf.SUCCESS.equals(dataMap.get(SysConf.CODE))) {
Map<String, Object> data = (Map<String, Object>) dataMap.get(SysConf.CODE);
T t = JsonUtils.mapToPojo(data, beanType);
return t;
}
return null;
}
/**
* 获取结果集的内容 【带有分页信息】
*
* @param result
* @return
*/
public <T> List<T> getListByPage(String result, Class<T> beanType) {
if (StringUtils.isEmpty(result)) {
return null;
}
Map<String, Object> dataMap = (Map<String, Object>) JsonUtils.jsonToObject(result, Map.class);
List<T> resultList = new ArrayList<>();
if (SysConf.SUCCESS.equals(dataMap.get(SysConf.CODE))) {
Map<String, Object> data = (Map<String, Object>) dataMap.get(SysConf.DATA);
List<Map<String, Object>> list = (List<Map<String, Object>>) data.get(SysConf.RECORDS);
list.forEach(item -> {
resultList.add(JsonUtils.mapToPojo(item, beanType));
});
return resultList;
} else {
log.error((String) dataMap.get(SysConf.MESSAGE));
return resultList;
}
}
/**
* 获取结果集的内容
*
* @param result
* @return
*/
public <T> List<T> getList(String result, Class<T> beanType) {
Map<String, Object> dataMap = (Map<String, Object>) JsonUtils.jsonToObject(result, Map.class);
List<T> resultList = new ArrayList<>();
if (SysConf.SUCCESS.equals(dataMap.get(SysConf.CODE))) {
List<Map<String, Object>> data = (List<Map<String, Object>>) dataMap.get(SysConf.DATA);
data.forEach(item -> {
resultList.add(JsonUtils.mapToPojo(item, beanType));
});
return resultList;
} else {
log.error((String) dataMap.get(SysConf.MESSAGE));
return resultList;
}
}
} | [
"[email protected]"
] | |
1a04fdaa95b11b18438a482734156b06f4b84099 | 761a70096c30c7bedd53e0483bed1fd791bed11b | /src/test/java/org/apache/kafka/common/requests/ApiVersionsResponseTest.java | 8ec936a6452603cd951a9b640e55703453201239 | [] | no_license | yonghuazhang/enhance-kafka-client | 2ec8f10a73952e5c04839cf3ba7a975b227986e1 | dfd5c00cc8ac9c72fec8c7d88560576e824f497f | refs/heads/master | 2021-09-07T22:22:21.645302 | 2018-03-02T02:54:04 | 2018-03-02T02:54:04 | 119,821,895 | 2 | 2 | null | null | null | null | UTF-8 | Java | false | false | 4,462 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.kafka.common.requests;
import org.apache.kafka.common.protocol.ApiKeys;
import org.apache.kafka.common.record.RecordBatch;
import org.apache.kafka.common.utils.Utils;
import org.junit.Test;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static org.junit.Assert.*;
public class ApiVersionsResponseTest {
@Test
public void shouldCreateApiResponseOnlyWithKeysSupportedByMagicValue() {
final ApiVersionsResponse response = ApiVersionsResponse.apiVersionsResponse(10, RecordBatch.MAGIC_VALUE_V1);
verifyApiKeysForMagic(response, RecordBatch.MAGIC_VALUE_V1);
assertEquals(10, response.throttleTimeMs());
}
@Test
public void shouldCreateApiResponseThatHasAllApiKeysSupportedByBroker() {
assertEquals(apiKeysInResponse(ApiVersionsResponse.defaultApiVersionsResponse()), Utils.mkSet(ApiKeys.values()));
}
@Test
public void shouldReturnAllKeysWhenMagicIsCurrentValueAndThrottleMsIsDefaultThrottle() {
ApiVersionsResponse response = ApiVersionsResponse.apiVersionsResponse(AbstractResponse.DEFAULT_THROTTLE_TIME, RecordBatch.CURRENT_MAGIC_VALUE);
assertEquals(Utils.mkSet(ApiKeys.values()), apiKeysInResponse(response));
assertEquals(AbstractResponse.DEFAULT_THROTTLE_TIME, response.throttleTimeMs());
}
@Test
public void shouldHaveCorrectDefaultApiVersionsResponse() {
Collection<ApiVersionsResponse.ApiVersion> apiVersions = ApiVersionsResponse.defaultApiVersionsResponse().apiVersions();
assertEquals("API versions for all API keys must be maintained.", apiVersions.size(), ApiKeys.values().length);
for (ApiKeys key : ApiKeys.values()) {
ApiVersionsResponse.ApiVersion version = ApiVersionsResponse.defaultApiVersionsResponse().apiVersion(key.id);
assertNotNull("Could not find ApiVersion for API " + key.name, version);
assertEquals("Incorrect min version for Api " + key.name, version.minVersion, key.oldestVersion());
assertEquals("Incorrect max version for Api " + key.name, version.maxVersion, key.latestVersion());
// Check if versions less than min version are indeed set as null, i.e., deprecated.
for (int i = 0; i < version.minVersion; ++i) {
assertNull("Request version " + i + " for API " + version.apiKey + " must be null", key.requestSchemas[i]);
assertNull("Response version " + i + " for API " + version.apiKey + " must be null", key.responseSchemas[i]);
}
// Check if versions between min and max versions are non null, i.e., valid.
for (int i = version.minVersion; i <= version.maxVersion; ++i) {
assertNotNull("Request version " + i + " for API " + version.apiKey + " must not be null", key.requestSchemas[i]);
assertNotNull("Response version " + i + " for API " + version.apiKey + " must not be null", key.responseSchemas[i]);
}
}
}
private void verifyApiKeysForMagic(final ApiVersionsResponse response, final byte maxMagic) {
for (final ApiVersionsResponse.ApiVersion version : response.apiVersions()) {
assertTrue(ApiKeys.forId(version.apiKey).minRequiredInterBrokerMagic <= maxMagic);
}
}
private Set<ApiKeys> apiKeysInResponse(final ApiVersionsResponse apiVersions) {
final Set<ApiKeys> apiKeys = new HashSet<>();
for (final ApiVersionsResponse.ApiVersion version : apiVersions.apiVersions()) {
apiKeys.add(ApiKeys.forId(version.apiKey));
}
return apiKeys;
}
}
| [
"[email protected]"
] | |
e62ad3bcff9b84591b4f3cc9107f3545121071cd | 5741045375dcbbafcf7288d65a11c44de2e56484 | /reddit-decompilada/com/instabug/library/internal/storage/cache/Cache.java | 081c791940c834dae2431e93ce839490a8a3c1bc | [] | no_license | miarevalo10/ReporteReddit | 18dd19bcec46c42ff933bb330ba65280615c281c | a0db5538e85e9a081bf268cb1590f0eeb113ed77 | refs/heads/master | 2020-03-16T17:42:34.840154 | 2018-05-11T10:16:04 | 2018-05-11T10:16:04 | 132,843,706 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,985 | java | package com.instabug.library.internal.storage.cache;
import java.util.ArrayList;
import java.util.List;
public abstract class Cache<K, V> {
private int appVersion;
private String id;
private final List<CacheChangedListener<V>> listeners;
public abstract V delete(K k);
public abstract V get(K k);
public abstract List<V> getValues();
public abstract void invalidate();
public abstract V put(K k, V v);
public abstract long size();
public Cache(String str) {
this(str, 1);
}
protected Cache(String str, int i) {
this.appVersion = -1;
this.id = str;
this.appVersion = i;
this.listeners = new ArrayList();
}
public void notifyItemRemoved(V v) {
for (CacheChangedListener onCachedItemRemoved : this.listeners) {
onCachedItemRemoved.onCachedItemRemoved(v);
}
}
public void notifyItemAdded(V v) {
for (CacheChangedListener onCachedItemAdded : this.listeners) {
onCachedItemAdded.onCachedItemAdded(v);
}
}
public void notifyItemUpdated(V v, V v2) {
for (CacheChangedListener onCachedItemUpdated : this.listeners) {
onCachedItemUpdated.onCachedItemUpdated(v, v2);
}
}
public void notifyCacheInvalidated() {
for (CacheChangedListener onCacheInvalidated : this.listeners) {
onCacheInvalidated.onCacheInvalidated();
}
}
public String getId() {
return this.id;
}
public int getAppVersion() {
return this.appVersion;
}
public boolean addOnCacheChangedListener(CacheChangedListener<V> cacheChangedListener) {
return (this.listeners.contains(cacheChangedListener) || this.listeners.add(cacheChangedListener) == null) ? null : true;
}
public boolean removeOnCacheChangedListener(CacheChangedListener<V> cacheChangedListener) {
return this.listeners.remove(cacheChangedListener);
}
}
| [
"[email protected]"
] | |
31b640621445b3f48d00fa16c9ed4e1959dc4bce | 08324dac72ef79e7d03123700622a42ad2794e0b | /hrinfo-business/src/main/java/com/ha/entity/model/custom/AllowanceTypeDTO.java | 9763e7cd96141629a67990e1a168da03bd617f53 | [] | no_license | buddhini81/HRIS-Admin_Module | b4ab794b67c269d244ec79eb8bfb4a0b76ea8b0e | 1d0703b29a36d06fd3f85f30bfe8609df724e5cf | refs/heads/master | 2021-07-16T06:47:56.733462 | 2017-10-22T05:04:13 | 2017-10-22T05:04:13 | 107,838,754 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 669 | java | package com.ha.entity.model.custom;
import java.io.Serializable;
public class AllowanceTypeDTO implements Serializable {
private Long allowanceDid;
private String allowanceType;
private String description;
public Long getAllowanceDid() {
return allowanceDid;
}
public void setAllowanceDid(Long allowanceDid) {
this.allowanceDid = allowanceDid;
}
public String getAllowanceType() {
return allowanceType;
}
public void setAllowanceType(String allowanceType) {
this.allowanceType = allowanceType;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
| [
"[email protected]"
] | |
6e8c5c3521949a1c3f55c8c1499a33f48708e232 | 43087a8b47dc59b6f26e8905b85e855ca7d18560 | /src/main/java/br/rodrigo/comparators/ExampleStudent.java | 5895b5594b43ce3574e32b08df3a47ae69a72bb1 | [] | no_license | rochards/collections-java | 2823b7a753d12f94214bdb4fced9a35a4c46a9e4 | 2559612eea90a78a3466fddfbca209ecc4d0a61a | refs/heads/master | 2023-02-04T21:22:33.420252 | 2020-12-17T13:34:25 | 2020-12-17T13:34:25 | 322,303,435 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,045 | java | package br.rodrigo.comparators;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class ExampleStudent {
public static void main(String[] args) {
List<Student> students = new ArrayList<>();
students.add(new Student("Pedro", 19));
students.add(new Student("Carlos", 23));
students.add(new Student("Mariana", 21));
students.add(new Student("João", 18));
students.add(new Student("Thiago", 20));
students.add(new Student("George", 22));
students.add(new Student("Larissa", 21));
System.out.println("As inserted: " + students);
students.sort(Comparator.comparingInt(Student::getAge));
System.out.println("Sorted: " + students);
Collections.sort(students); // posso passar pq students extends comparable
System.out.println("Sorted: " + students);
Collections.sort(students, new StudentComparator());
System.out.println("Sorted: " + students);
}
}
| [
"[email protected]"
] | |
3596cee4d9a4d885507c30191b86855f20dd9ac1 | 8077ca00c7a9f52e69b7586aed2d99d0161ba946 | /src/version2/prototype/indices/ModisNBARV6/ModisNBARV6NDWI6.java | b2b0f34072eb565d732d8ed02c7a164b237f81eb | [] | no_license | Nash1409/EASTWeb-CodeDeploy | c7ba57857752a09e47d891db29fbe419c5abef85 | fd7d026a9c58c10e38a71afbb704c694237fc3ff | refs/heads/master | 2021-05-06T18:36:23.517949 | 2017-11-25T20:36:29 | 2017-11-25T20:36:29 | 112,022,464 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,026 | java | package version2.prototype.indices.ModisNBARV6;
import java.io.File;
import java.util.List;
import version2.prototype.indices.IndicesFramework;
/**
* uses the same logic for ndwi5 and ndwi6
* NDWI5 = (NIR-SWIR2)/(NIR+SWIR2)
* NDWI6 = (NIR-SWIR)/(NIR+SWIR)
* @author Isaiah Snell-Feikema
*/
/*
* 1: Band 1: Red
* 2: Band 2: NIR
* 3: Band 3: Blue
* 4: Band 4: Green
* 5: Band 5: SWIR 1
* 6: Band 6: SWIR 2
* 7: Band 7: SWIR 3
*/
public class ModisNBARV6NDWI6 extends IndicesFramework {
private final int NIR;
private final int SWIR;
public ModisNBARV6NDWI6(List<File> inputFiles, File outputFile, Integer noDataValue)
{
super(inputFiles, outputFile, noDataValue);
int tempNIR = -1;
int tempSWIR = -1;
for(int i=0; i < mInputFiles.length; i++)
{
if(mInputFiles[i].getName().toLowerCase().contains(new String("band2")))
{
tempNIR = i;
}
else if(mInputFiles[i].getName().toLowerCase().contains(new String("band6")))
{
tempSWIR = i;
}
if(tempNIR > -1 && tempSWIR > -1) {
break;
}
}
NIR = tempNIR;
SWIR = tempSWIR;
}
/**
* Valid input value range: 1 to 32766
* Valid output value range: -1 to 1
*/
@Override
protected double calculatePixelValue(double[] values) throws Exception {
if (values[NIR] > 32766 || values[NIR] < 1 || values[SWIR] > 32766 || values[SWIR] < 1 || values[NIR] == noDataValue || values[SWIR] == noDataValue) {
// return -3.40282346639e+038;
return noDataValue;
} else {
for(int i=0; i < values.length; i++) {
values[i] = values[i] / 10000;
}
return (values[NIR] - values[SWIR]) / (values[SWIR] + values[NIR]);
}
}
@Override
protected String className() {
return getClass().getName();
}
}
| [
"[email protected]"
] | |
edee1371781f0197cdb61c2497c2c4040961b220 | d8a1411d742ee2f25c8a45788424274f9439b223 | /src/main/java/com/app/gpa/servlets/SemesterServlet.java | 46f5178829ab8bd40fcf27850b73dab732725861 | [] | no_license | qaximalee/app-gpa | e23efb5c02de796e5ea024ee01a7b8f4a0235160 | 6fb049b8f66cb05e5db7f57992000cca377182ed | refs/heads/master | 2022-12-03T23:51:02.798260 | 2019-11-19T12:05:41 | 2019-11-19T12:05:41 | 220,459,281 | 0 | 0 | null | 2022-11-24T10:01:37 | 2019-11-08T12:08:09 | JavaScript | UTF-8 | Java | false | false | 3,239 | java | package com.app.gpa.servlets;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.ihsinformatics.gpaconvertor.hbentities.Semester;
import com.ihsinformatics.gpaconvertor.hbservices.SemesterDAO;
import com.ihsinformatics.gpaconvertor.interfaces.HCrudOperations;
/**
* Servlet implementation class SemesterServlet It will provide all Operations
* on Semester Entity
*/
public class SemesterServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
private static final String PATH = "jsp/semester_views/";
private static final String CREATED_SUCCESS = "from-create";
private static final String CREATED_UNSUCCESS = "from-create-error";
private static final String UPDATED_SUCCESS = "from-edit";
private static final String UPDATED_UNSUCCESS = "from-edit-error";
private static final String DELETED_SUCCESS = "from-delete";
private static final String DELETED_UNSUCCESS = "from-delete-error";
private HCrudOperations<Semester> semesterOprt;
/**
* @see HttpServlet#HttpServlet()
*/
public SemesterServlet() {
super();
semesterOprt = new SemesterDAO();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
if (request.getParameter("actionType").equals("delete"))
doDelete(request, response);
else {
int semesterId = Integer.parseInt(request.getParameter("semesterId"));
int semesterNo = Integer.parseInt(request.getParameter("semesterNo"));
Semester semester = new Semester(semesterId, semesterNo);
if (semesterOprt.update(semester))
response.sendRedirect(PATH + "view_semesters.jsp?from=" + UPDATED_SUCCESS);
else
response.sendRedirect(PATH + "view_semesters.jsp?from=" + UPDATED_UNSUCCESS);
}
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
int semesterNo = Integer.parseInt(request.getParameter("semesterNo"));
Semester semester = new Semester(0, semesterNo);
if (semesterOprt.save(semester))
response.sendRedirect(PATH + "view_semesters.jsp?from=" + CREATED_SUCCESS);
else
response.sendRedirect(PATH + "view_semesters.jsp?from=" + CREATED_UNSUCCESS);
}
@Override
protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
// TODO Auto-generated method stub
int semesterId = Integer.parseInt(req.getParameter("id"));
if (semesterOprt.delete(semesterId))
resp.sendRedirect(PATH + "view_semesters.jsp?from=" + DELETED_SUCCESS);
else
resp.sendRedirect(PATH + "view_semesters.jsp?from=" + DELETED_UNSUCCESS);
}
}
| [
"[email protected]"
] | |
291d99513b3826e5161d173920f1093695a2b397 | d938a598b7d557f1725976541153ed06be2623e6 | /scr/com/sham/pattern/visitor/TaxVisitor.java | aae90f2c8a87d8c22e7d13c8007d508881f6885c | [] | no_license | shammde/datastructure | 0726d1b3a8afe8334bd8acc43afc0ed4ffbd083e | d527900fec6a34aa150da83d0a22bf59dff4008f | refs/heads/master | 2021-06-02T01:40:43.681586 | 2019-05-15T17:15:15 | 2019-05-15T17:15:15 | 96,331,311 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 474 | java | package com.sham.pattern.visitor;
public class TaxVisitor implements Visitor {
@Override
public double visit(Necessity necessityItem) {
return necessityItem.getPrice() * 0 + necessityItem.getPrice();
}
@Override
public double visit(Tobacco tobaccoItem) {
return tobaccoItem.getPrice() * .25 + tobaccoItem.getPrice();
}
@Override
public double visit(Liquor liquorItem) {
return liquorItem.getPrice() * .20 + liquorItem.getPrice();
}
}
| [
"[email protected]"
] | |
c074392e5541fe47dda026f98ca63e20696f2b80 | c71821507307bf94c5c1fab861a067d091fd5679 | /lettuce/src/main/java/com/lemon/portti/lettuce/cache/demo/lettuce/LettuceConfig.java | 1cb7c6d8a91f59828d78e704bc89b9dcc308038d | [
"MIT"
] | permissive | leoeco2000/portti | 1c813fd3277f0b3e0b333f4e20fd8ed5d0284ca5 | 1252b428cbab4b854f9d46bbeac27cfaa801b552 | refs/heads/master | 2022-11-20T02:57:07.738321 | 2019-09-04T08:35:36 | 2019-09-04T08:35:36 | 203,085,151 | 0 | 0 | MIT | 2022-11-16T12:26:24 | 2019-08-19T02:36:39 | Java | UTF-8 | Java | false | false | 2,924 | java | package com.lemon.portti.lettuce.cache.demo.lettuce;
import io.lettuce.core.RedisClient;
import io.lettuce.core.RedisURI;
import io.lettuce.core.RedisURI.Builder;
import io.lettuce.core.api.StatefulRedisConnection;
import io.lettuce.core.resource.ClientResources;
import io.lettuce.core.resource.DefaultClientResources;
import java.nio.file.Files;
import java.nio.file.Paths;
import javax.annotation.PostConstruct;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
//@Primary
//@Configuration
public class LettuceConfig {
private static RedisURI redisUri;
private final Logger log = LoggerFactory.getLogger(getClass());
@Value("${redis.host:127.0.0.1}")
private String hostName;
@Value("${redis.domainsocket:}")
private String socket;
@Value("${redis.port:6379}")
private int port;
private int dbIndex = 2;
@Value(value = "${redis.pass:}")
private String password;
@Bean(destroyMethod = "shutdown")
ClientResources clientResources() {
return DefaultClientResources.create();
}
@Bean(destroyMethod = "close")
StatefulRedisConnection<String, String> redisConnection(RedisClient redisClient) {
return redisClient.connect();
}
private RedisURI createRedisURI() {
Builder builder = null;
// 判断是否有配置UDS信息,以及判断Redis是否有支持UDS连接方式,是则用UDS,否则用TCP
if (StringUtils.isNotBlank(socket) && Files.exists(Paths.get(socket))) {
builder = Builder.socket(socket);
System.out.println("connect with Redis by Unix domain Socket");
log.info("connect with Redis by Unix domain Socket");
} else {
builder = Builder.redis(hostName, port);
System.out.println("connect with Redis by TCP Socket");
log.info("connect with Redis by TCP Socket");
}
builder.withDatabase(dbIndex);
if (StringUtils.isNotBlank(password)) {
builder.withPassword(password);
}
return builder.build();
}
@PostConstruct
void init() {
redisUri = createRedisURI();
log.info("连接Redis成功!\n host:" + hostName + ":" + port + " pass:" + password + " dbIndex:" + dbIndex);
}
@Bean(destroyMethod = "shutdown")
RedisClient redisClient(ClientResources clientResources) {
return RedisClient.create(clientResources, redisUri);
}
public void setDbIndex(int dbIndex) {
this.dbIndex = dbIndex;
}
public void setHostName(String hostName) {
this.hostName = hostName;
}
public void setPassword(String password) {
this.password = password;
}
public void setPort(int port) {
this.port = port;
}
public void setSocket(String socket) {
this.socket = socket;
}
}
| [
"[email protected]"
] | |
69aa5b4799421d9c6cd6206879ca2d1f209b4aa0 | 656ce78b903ef3426f8f1ecdaee57217f9fbc40e | /src/org/spongycastle/i18n/filter/UntrustedInput.java | 27b268a067f326cd153753f16b8714dafe0ed901 | [] | no_license | zhuharev/periscope-android-source | 51bce2c1b0b356718be207789c0b84acf1e7e201 | 637ab941ed6352845900b9d465b8e302146b3f8f | refs/heads/master | 2021-01-10T01:47:19.177515 | 2015-12-25T16:51:27 | 2015-12-25T16:51:27 | 48,586,306 | 8 | 10 | null | null | null | null | UTF-8 | Java | false | false | 331 | java | // Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: braces fieldsfirst space lnc
package org.spongycastle.i18n.filter;
public class UntrustedInput
{
public String toString()
{
throw new NullPointerException();
}
}
| [
"[email protected]"
] | |
39d726f250130ce0376ab33f76679c19b86389bd | 4a485658a9c2f56fc50dec8425985a5623da70c6 | /pets/persistence-hibernate/src/main/java/pl/gov/coi/cleanarchitecture/example/spring/pets/persistence/hibernate/mapper/MetadataImpl.java | d81a3352186e559feac745ce02d7e806e4549a6d | [] | no_license | coi-gov-pl/spring-clean-architecture | e50c9353b64fdaf26e2d11d709e7c69c18339698 | 8a4e549a2767adc1ca524e49a54b2727d901c739 | refs/heads/develop | 2021-07-01T07:44:29.188466 | 2018-05-25T11:51:23 | 2018-05-25T11:51:23 | 76,885,918 | 143 | 36 | null | 2021-06-18T05:00:47 | 2016-12-19T18:15:46 | Java | UTF-8 | Java | false | false | 3,181 | java | package pl.gov.coi.cleanarchitecture.example.spring.pets.persistence.hibernate.mapper;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import pl.gov.coi.cleanarchitecture.example.spring.pets.domain.model.metadata.Created;
import pl.gov.coi.cleanarchitecture.example.spring.pets.domain.model.metadata.Metadata;
import pl.gov.coi.cleanarchitecture.example.spring.pets.domain.model.metadata.MetadataEntry;
import pl.gov.coi.cleanarchitecture.example.spring.pets.domain.model.metadata.Modified;
import pl.gov.coi.cleanarchitecture.example.spring.pets.domain.model.metadata.Reference;
import pl.gov.coi.cleanarchitecture.example.spring.pets.persistence.hibernate.entity.Record;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
/**
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
* @since 23.04.18
*/
@RequiredArgsConstructor
final class MetadataImpl<T> implements Metadata<T> {
private final Class<T> type;
private final Record record;
@Override
public <I, D extends MetadataEntry<I>> Optional<D> get(Class<D> metadataClass) {
MetadataEntryProvider<T, D> provider = new MetadataEntryProvider<>(type, record);
return provider.get(metadataClass);
}
@Override
public Class<T> type() {
return type;
}
@Getter(AccessLevel.PRIVATE)
@RequiredArgsConstructor
private static final class MetadataEntryProvider<T, D extends MetadataEntry<?>> {
private final Class<T> type;
private final Record record;
Optional<D> get(Class<D> dataClass) {
List<Optional<D>> out = new ArrayList<>();
out.add(processForReference(dataClass));
out.add(processForCreated(dataClass));
out.add(processForModified(dataClass));
return out.stream()
.reduce(this::accumulateOpts)
.orElse(Optional.empty());
}
@SuppressWarnings("OptionalUsedAsFieldOrParameterType")
private Optional<D> accumulateOpts(Optional<D> first, Optional<D> second) {
return first.isPresent() ? first : second;
}
private Optional<D> processForReference(Class<D> dataClass) {
if (dataClass.isAssignableFrom(Reference.class)) {
@SuppressWarnings("unchecked")
D ref = (D) new LongReference(record::getId);
return Optional.of(ref);
}
return Optional.empty();
}
private Optional<D> processForCreated(Class<D> dataClass) {
if (dataClass.isAssignableFrom(Created.class)) {
@SuppressWarnings("unchecked")
D ref = (D) new InstantCreated(this::getCreated);
return Optional.of(ref);
}
return Optional.empty();
}
private Optional<D> processForModified(Class<D> dataClass) {
if (dataClass.isAssignableFrom(Modified.class)) {
@SuppressWarnings("unchecked")
D ref = (D) new InstantModified(this::getModified);
return Optional.of(ref);
}
return Optional.empty();
}
private Instant getModified() {
return getRecord().getModified().toInstant();
}
private Instant getCreated() {
return getRecord().getCreated().toInstant();
}
}
}
| [
"[email protected]"
] | |
0d19e74a5c47f09d665616c478d600c67e9333f8 | 4abed3f67e2102791b264af553250e256210ed8f | /app/src/test/java/com/dji/MapDemo/GoogleMap/ExampleUnitTest.java | baa3d706f49948bf07bbe7c5ee7dd662a3dcda93 | [] | no_license | ybabs/MapSample | aa14b5a71179dcf1386780ed5e3fecea30f90e3e | cc61d9f4af5c4351f7533506bca771dcb9a01340 | refs/heads/master | 2021-09-03T13:56:45.219333 | 2018-01-09T15:07:49 | 2018-01-09T15:07:49 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 403 | java | package com.dji.MapDemo.GoogleMap;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
badfa233aaed1fb858224e90980c3c9962f02303 | b05fad1404fc7cf98129082d2037142f35c2daa5 | /Documents/workspace-sts-3.9.9.RELEASE/fundooNotes/src/main/java/com/bridgelab/fundunotes/service/UserServiceImpl.java | 580b788ae4ad927d2ad9adc8ad016f7ac8bd4783 | [] | no_license | Shriniwaspathak/spring | 1d8e6e492babdbbec4ad6e59b29188ef813812d7 | 2e747c7d36b9c4ab23e8ae44c271f1a63f89a391 | refs/heads/master | 2022-12-10T14:33:02.356107 | 2019-10-04T03:26:42 | 2019-10-04T03:26:42 | 205,387,329 | 0 | 0 | null | 2020-10-13T16:14:27 | 2019-08-30T13:25:33 | CSS | UTF-8 | Java | false | false | 3,939 | java | package com.bridgelab.fundunotes.service;
import java.util.ArrayList;
import java.util.List;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.stereotype.Service;
import com.bridgelab.fundunotes.dto.Resetpassword;
import com.bridgelab.fundunotes.dto.UserDto;
import com.bridgelab.fundunotes.dto.UserLogin;
import com.bridgelab.fundunotes.model.UserRegistration;
import com.bridgelab.fundunotes.repository.UserServiceRepository;
import com.bridgelab.fundunotes.util.TokenGeneration;
@Service
public class UserServiceImpl implements UserService {
@Autowired
private UserServiceRepository userdao;
@Autowired
private BCrypt bcryptEncoder;
@Autowired
private JavaMailSender emailSender;
@Autowired
private TokenGeneration tokens;
@Autowired
private ModelMapper modelmapper;
private String hashpassword(String plainTextPassword) {
String salt = bcryptEncoder.gensalt();
return bcryptEncoder.hashpw(plainTextPassword, salt);
}
@Override
public List<UserRegistration> retriveUserFromdatabase() {
List<UserDto> user = new ArrayList<UserDto>();
List<UserRegistration> details = new ArrayList<UserRegistration>();
details = userdao.retriveUserDetails();
return details;
}
@Override
public boolean deleteFromDatabase(Integer id) {
return (userdao.deleteFromdatabase(id)) ? true : false;
}
@Override
public int saveToDatabase(UserDto userDetails) throws MessagingException {
String password = userDetails.getPassword();
String mobileno=userDetails.getMobileNo();
UserRegistration register = modelmapper.map(userDetails, UserRegistration.class);
String url = "http://localhost:8080/user/verify/";
int check = userdao.setTodatabase(register);
if (check > 0) {
UserRegistration userinfo = userdao.getid(userDetails.getEmail());
String token = tokens.generateToken(userinfo.getUserid());
userDetails.setPassword(hashpassword(password));
sendEmail(url, token);
return 1;
}
return 0;
}
@Override
public boolean verifyUser(String token) {
int id = tokens.parseToken(token);
if (userdao.isvaliduser(id)) {
userdao.changeStatus(id);
return true;
}
return false;
}
@Override
public boolean dologin(UserLogin loginUser) {
UserRegistration register = modelmapper.map(loginUser, UserRegistration.class);
List<UserRegistration> registration = userdao.checkUser(register.getUserid());
for (UserRegistration registera : registration) {
if (registera.getEmail().equals(loginUser.getEmail())
&& (bcryptEncoder.checkpw(loginUser.getPassword(), registera.getPassword()))) {
return true;
}
}
return false;
}
@Override
public boolean isUserAvailable(Integer id) {
return userdao.isvaliduser(id);
}
@Override
public boolean forgetpassword(Integer id) throws MessagingException {
String genetaredToken = tokens.generateToken(id);
String url = "";
sendEmail(url, genetaredToken);
return true;
}
@Override
public void sendEmail(String url, String generatedToken) throws MessagingException {
MimeMessage message = emailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setTo("[email protected]");
helper.setSubject("Token");
helper.setText(url + generatedToken);
emailSender.send(message);
}
@Override
public int updateUser(String token, Resetpassword resetPassword) {
Integer result = tokens.parseToken(token);
String encodepassword = hashpassword(resetPassword.getPassword());
UserRegistration reset = modelmapper.map(resetPassword, UserRegistration.class);
return userdao.updatepassword(result, encodepassword);
}
}
| [
"[email protected]"
] | |
7b1d511fdd59dd1d7863d626770add82e976f6e4 | ea3b9ab73e44e84e42b7d756e660f8076f783dfd | /com.siteview.kernel.core/src/COM/dragonflow/SiteView/AlertReport.java | 7484fa30473fab32a973d2adf289724a7834db99 | [] | no_license | SiteView/NEWECC9.2 | b34cf894f9e6fc7136af7d539ebd99bae48ba116 | 86e95c40fc481c4aad5a2480ac6a08fe64df1cb1 | refs/heads/master | 2016-09-05T23:05:16.432869 | 2013-01-17T02:37:46 | 2013-01-17T02:37:46 | 5,685,712 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 13,411 | java | /*
*
* Created on 2005-2-15 10:43:09
*
* AlertReport.java
*
* History:
*
*/
package COM.dragonflow.SiteView;
/**
* Comment for <code>AlertReport</code>
*
* @author
* @version 0.0
*
*
*/
import java.io.File;
import java.io.PrintWriter;
import java.util.Date;
import java.util.Enumeration;
import jgl.Array;
import jgl.HashMap;
import jgl.Sorting;
import COM.dragonflow.Utils.TextUtils;
// Referenced classes of package COM.dragonflow.SiteView:
// AlertLogReader, Action, CompareSlot, Platform,
// SiteViewGroup
public class AlertReport {
public AlertReport() {
}
public static Array readAlertData(HashMap hashmap, Date date, Date date1,
String s, HashMap hashmap1) {
AlertLogReader alertlogreader = new AlertLogReader(new File(Platform
.getDirectoryPath("logs", s)
+ File.separator + "alert.log"));
Array array = alertlogreader.process(hashmap, date, date1, hashmap1);
SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
if (siteviewgroup.getSetting("_includeAlertLogOld").length() > 0) {
AlertLogReader alertlogreader1 = new AlertLogReader(new File(
Platform.getDirectoryPath("logs", s) + File.separator
+ "alert.log.old"));
Array array1 = alertlogreader1.process(hashmap, date, date1,
hashmap1);
for (int i = 0; i < array.size(); i++)
array1.add(array.at(i));
return array1;
} else {
return array;
}
}
public static void generateReport(PrintWriter printwriter, HashMap hashmap,
String s, boolean flag, Date date, Date date1, int i, String s1) {
String s2 = "";
String s3 = "";
String s4 = "";
SiteViewGroup siteviewgroup = SiteViewGroup.currentSiteView();
String s5 = siteviewgroup.getSetting("_reportTableHTML");
if (s5.length() > 0)
s4 = s5;
s5 = siteviewgroup.getSetting("_reportTableHeaderHTML");
if (s5.length() > 0)
s2 = s5;
s5 = siteviewgroup.getSetting("_reportTableDataHTML");
if (s5.length() > 0)
s3 = s5;
Array array = readAlertData(hashmap, date, date1, s1, null);
generateReport(array, printwriter, s, flag, date, date1, i, s4, s2, s3);
}
public static void generateXMLReport(Array array, PrintWriter printwriter,
Date date, Date date1, int i) {
printwriter.println("<alerts>");
if (date != null && date1 != null) {
Date date2 = date;
Date date3 = date1;
if (i != 0) {
date2 = new Date(date.getTime() + (long) (i * 1000));
date3 = new Date(date1.getTime() + (long) (i * 1000));
}
printwriter.println(TextUtils.escapeXML("startdate", TextUtils
.prettyDate(date2)));
printwriter.println(TextUtils.escapeXML("enddate", TextUtils
.prettyDate(date3)));
printwriter.println(TextUtils.escapeXML("timeoffset", Platform
.timeZoneName(i)));
}
for (int j = 0; j < array.size(); j++) {
HashMap hashmap = (HashMap) array.at(j);
Enumeration enumeration = hashmap.keys();
printwriter.print("<alert>");
while (enumeration.hasMoreElements()) {
String s = (String) enumeration.nextElement();
if (!s.startsWith("extra"))
if (s.equals("date")) {
Date date4 = (Date) hashmap.get(s);
if (i != 0)
date4 = new Date(date4.getTime()
+ (long) (i * 1000));
printwriter.println(TextUtils.escapeXML("date",
TextUtils.prettyDate(date4)));
} else {
printwriter.println(TextUtils.escapeXML(s, TextUtils
.getValue(hashmap, s)));
}
}
printwriter.println("</alert>");
}
printwriter.println("</alerts>");
}
/**
*
*
* @param array
* @param printwriter
* @param s
* @param flag
* @param date
* @param date1
* @param i
* @param s1
* @param s2
* @param s3
*/
public static void generateReport(Array array, PrintWriter printwriter,
String s, boolean flag, Date date, Date date1, int i, String s1,
String s2, String s3) {
Array array1 = new Array();
array1.add("date");
array1.add("alert-type");
array1.add("alert-message");
array1.add("alert-monitor");
String s4 = "Alerts";
if (date != null && date1 != null) {
Date date2 = date;
Date date3 = date1;
if (i != 0) {
date2 = new Date(date.getTime() + (long) (i * 1000));
date3 = new Date(date1.getTime() + (long) (i * 1000));
}
String s5 = TextUtils.prettyDate(date2) + " to "
+ TextUtils.prettyDate(date3);
if (i != 0)
s5 = s5 + ", " + Platform.timeZoneName(i);
s4 = s4 + " from " + s5;
}
printwriter
.print("<A name=alertReport></A><P>\n<TABLE WIDTH=\"100%\" "
+ s1
+ ">"
+ "<CAPTION><B>"
+ s4
+ "</B></CAPTION>"
+ "<TR "
+ s2
+ "><TH>Time</TH><TH>Type</TH><TH>Message</TH><TH>Monitor</TH>");
if (flag) {
printwriter.print("<TH>Group</TH>");
array1.add("alert-group");
}
printwriter.println("</TR>");
if (array.size() == 0) {
printwriter.println("<TR " + s3 + "><TD COLSPAN=" + array1.size()
+ " ALIGN=CENTER>No alerts found</TD></TR>");
} else {
for (int j = 0; j < array.size(); j++) {
HashMap hashmap = (HashMap) array.at(j);
Enumeration enumeration = array1.elements();
printwriter.print("<TR " + s3 + ">");
boolean flag1 = TextUtils.getValue(hashmap, "alert-failed")
.length() > 0;
boolean flag2 = TextUtils.getValue(hashmap, "alert-test")
.length() > 0;
while (enumeration.hasMoreElements()) {
String s6 = (String) enumeration.nextElement();
printwriter.print("<TD>");
if (s6.equals("date")) {
Date date4 = (Date) hashmap.get(s6);
if (i != 0)
date4 = new Date(date4.getTime()
+ (long) (i * 1000));
printwriter.print(TextUtils.prettyDate(date4));
} else {
String s7 = TextUtils.getValue(hashmap, s6);
if (s6.equals("alert-type")) {
if (flag2)
s7 = "Test " + s7;
if (flag1)
s7 = "<B>" + s7 + "</B>";
}
printwriter.print(s7);
}
}
boolean flag3 = s.equals("detail") || s.equals("detailonfail")
&& flag1;
if (!flag3)
continue;
printwriter.println("<TR><TD></TD><TD COLSPAN="
+ (array1.size() - 1) + ">");
String s8 = "1";
for (String s9 = (String) hashmap.get("extra" + s8); s9 != null; s9 = (String) hashmap
.get("extra" + s8)) {
String s10 = TextUtils.getValue(hashmap, s9);
printwriter.println("<PRE><B>" + s9 + "</B>: "
+ TextUtils.escapeHTML(s10) + "</PRE>");
s8 = TextUtils.increment(s8);
}
printwriter.println("</TR>");
}
}
printwriter.println("</TABLE>");
}
public static Action getActionOfClass(String s) {
Action action = (Action) actionCache.get(s);
if (action == null) {
action = Action.createActionObject(s);
if (action != null)
actionCache.add(s, action);
}
return action;
}
public static String[] createSummaryMessage(Array array, long l) {
StringBuffer stringbuffer = new StringBuffer();
StringBuffer stringbuffer1 = new StringBuffer();
HashMap hashmap = new HashMap();
Array array1 = new Array();
String s = "Alert Type";
int i = s.length();
if (array.size() == 0) {
stringbuffer.append("No alerts were triggered");
stringbuffer1.append("No alerts were triggered");
} else {
for (int j = 0; j < array.size(); j++) {
HashMap hashmap1 = (HashMap) array.at(j);
String s3 = TextUtils
.prettyDate((Date) hashmap1.get("date"), l);
TextUtils.appendStringRightJustify(stringbuffer1, TextUtils
.prettyDateTime(s3), 8);
TextUtils.appendStringRightJustify(stringbuffer1, TextUtils
.prettyDateDate(s3), 11);
String s4 = TextUtils.readStringFromEnd(TextUtils.getValue(
hashmap1, "alert-id"), ":");
if (s4.length() > 0) {
Action action = getActionOfClass(s4);
if (action != null) {
stringbuffer1.append(" ");
stringbuffer1.append(action
.alertLogEntrySummary(hashmap1));
HashMap hashmap3 = (HashMap) hashmap.get(s4);
if (hashmap3 == null) {
hashmap3 = new HashMap();
hashmap3.put("count", "0");
hashmap3.put("failed", "0");
String s7 = action.getClassPropertyString("title");
hashmap3.put("title", s7);
hashmap.put(s4, hashmap3);
array1.add(hashmap3);
if (s7.length() > i)
i = s7.length();
}
TextUtils.incrementEntry(hashmap3, "count");
if (TextUtils.getValue(hashmap1, "alert-failed")
.length() > 0)
TextUtils.incrementEntry(hashmap3, "failed");
}
}
stringbuffer1.append("\n");
}
String s1 = "# triggered";
String s2 = "# failed";
TextUtils.appendStringLeftJustify(stringbuffer, s, i);
stringbuffer.append(" ");
stringbuffer.append(s1);
stringbuffer.append(" ");
stringbuffer.append(s2);
stringbuffer.append("\n");
stringbuffer.append(TextUtils.filledString('-', i));
stringbuffer.append(" ");
stringbuffer.append(TextUtils.filledString('-', s1.length()));
stringbuffer.append(" ");
stringbuffer.append(TextUtils.filledString('-', s2.length()));
stringbuffer.append("\n");
Sorting
.sort(array1, new CompareSlot("count",
CompareSlot.DIRECTION_GREATER,
CompareSlot.NUMERIC_COMPARE));
for (Enumeration enumeration = array1.elements(); enumeration
.hasMoreElements(); stringbuffer.append("\n")) {
HashMap hashmap2 = (HashMap) enumeration.nextElement();
String s5 = TextUtils.getValue(hashmap2, "title");
String s6 = TextUtils.getValue(hashmap2, "count");
String s8 = TextUtils.getValue(hashmap2, "failed");
TextUtils.appendStringLeftJustify(stringbuffer, s5, i);
stringbuffer.append(" ");
TextUtils.appendStringRightJustify(stringbuffer, s6, s1
.length());
stringbuffer.append(" ");
TextUtils.appendStringRightJustify(stringbuffer, s8, s2
.length());
}
stringbuffer.append("\n");
}
String as[] = new String[2];
as[0] = stringbuffer.toString();
as[1] = stringbuffer1.toString();
return as;
}
public static HashMap actionCache = new HashMap();
}
| [
"[email protected]"
] | |
d48fac222ecbb27484b69e8426b773af5595f05d | ce64f60c0461f22c7a222c03250229ad6bbe00fc | /src/main/java/ru/itis/demo/controllers/ProfileController.java | c72c8aaf8186f22a5cc2f8f22074b2cf43594269 | [] | no_license | LegendaryZer0/SpringExamScrf24012021 | b1689a18deb1530d41138b51688f1756e27879e4 | b944634fbf9e7d47ee4e4376a1569727250ab922 | refs/heads/master | 2023-02-20T04:33:22.738543 | 2021-01-24T22:01:03 | 2021-01-24T22:01:03 | 332,565,027 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 718 | java | package ru.itis.demo.controllers;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import ru.itis.demo.model.Simple_user;
import ru.itis.demo.service.UserService;
import javax.servlet.http.HttpServletRequest;
@Slf4j
@Controller
public class ProfileController {
@Autowired
private UserService userService;
@PostMapping("/catchUser")
public String getUser(HttpServletRequest request){
Integer id = (Integer) request.getSession().getAttribute("id");
log.info(userService.catchUser(id).toString());
return "Joke";
}
}
| [
"[email protected]"
] | |
dbfb9134339812e997a1a141a28a992e9b3931b6 | 42f42f2ec45754c22c66cef93554711ccba5a834 | /src/main/java/me/xwang1024/sifResExplorer/data/ImagDao.java | 0ecec9c7680740aa071025095504302154e745b9 | [
"MIT"
] | permissive | xwang1024/SIF-Resource-Explorer | 0089208a567cf2ed50cbaf185465e306c6267cfe | 448ec713acc2c156dbfa5971c86e8efc46ee166e | refs/heads/master | 2021-01-10T01:22:22.863758 | 2017-09-04T04:45:20 | 2017-09-04T04:45:20 | 36,945,941 | 24 | 2 | null | 2017-09-04T04:45:21 | 2015-06-05T17:30:23 | Java | UTF-8 | Java | false | false | 480 | java | package me.xwang1024.sifResExplorer.data;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.List;
public interface ImagDao {
public BufferedImage getImage(String imagPath) throws IOException;
public BufferedImage getImageWithoutSplit(String texbPath) throws IOException;
public String getRefTextureFilePath(String imagPath) throws IOException;
public List<String> getImagList();
public List<String> getTexbList();
}
| [
"[email protected]"
] | |
edd0a7551211dec46a1327c3ef640faf94e45c92 | b4cc5e7fe61a380652c4e7c50c752e6adbc29e55 | /src/com/TimeManagement/TimeManagementDBMethods.java | 96761313c449b438a79a375683965c8d682b96e6 | [] | no_license | charles0071/jobportal | 0928b26b56ea0d168cdae61acb731fec3398b5a5 | 3882a90553c61b7216864ce20e34a4125aba210c | refs/heads/master | 2021-01-19T00:16:33.636715 | 2014-11-12T07:20:56 | 2014-11-12T07:20:56 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,541 | java | package com.TimeManagement;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import com.Employee.EmployeeDBObj;
import com.TimeManagement.EmpDailyAttendanceDBObj;
import com.TimeManagement.DateYearMonthDayDBObj;
public class TimeManagementDBMethods{
public String DBUser;
public String DBPswd;
public String DBUrl ;
public TimeManagementDBMethods(){ }
public TimeManagementDBMethods(String inDBUser, String inDBPswd, String inDBUrl ){
DBUser = inDBUser;
DBPswd = inDBPswd;
DBUrl = inDBUrl;
}
public DateYearMonthDayDBObj getCurDateYearMonthDayDBObj(){
DateYearMonthDayDBObj dateYearMonthDayDBObj = new DateYearMonthDayDBObj();
GregorianCalendar calendar = new GregorianCalendar();
String month = Integer.toString((calendar.get(Calendar.MONTH) + 1));
String day = Integer.toString(calendar.get(Calendar.DATE));
String year = Integer.toString(calendar.get(Calendar.YEAR));
if( month != null && month.length() < 2 ) month = "0"+month;
if( day != null && day.length() < 2 ) day = "0"+day;
String date = year+"-"+month+"-"+day;
dateYearMonthDayDBObj.today_date = date;
dateYearMonthDayDBObj.month = getMonth(calendar.get(Calendar.MONTH));
dateYearMonthDayDBObj.day = getDay(calendar.get(Calendar.DAY_OF_WEEK));
dateYearMonthDayDBObj.year = calendar.get(Calendar.YEAR);
System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
System.out.println("WEEK_OF_YEAR: " + calendar.get(Calendar.WEEK_OF_YEAR));
System.out.println("DATE: " + calendar.get(Calendar.DATE));
System.out.println("DAY_OF_WEEK: " + calendar.get(Calendar.DAY_OF_WEEK));
return dateYearMonthDayDBObj;
}
public String getDay( int day ){
String strDay= "";
if(day == 1) strDay = "SUN";
else if(day == 2) strDay = "MON";
else if(day == 3) strDay = "TUS";
else if(day == 4) strDay = "WED";
else if(day == 5) strDay = "THU";
else if(day == 6) strDay = "FRI";
else if(day == 7) strDay = "SAT";
return strDay;
}
public String getMonth( int month ){
String strMonth = "";
if(month == 0) strMonth = "JAN";
else if(month == 1) strMonth = "FEB";
else if(month == 2 ) strMonth = "MAR";
else if(month == 3) strMonth = "APR";
else if(month == 4) strMonth = "MAY";
else if(month == 5) strMonth = "JUN";
else if(month == 6) strMonth = "JUL";
else if(month == 7) strMonth = "AUG";
else if(month == 8) strMonth = "SEP";
else if(month == 9) strMonth = "OCT";
else if(month == 10) strMonth = "NOV";
else if(month == 11) strMonth = "DEC";
return strMonth;
}
public void initializeEmpDailyAttendanceDBObj(EmpDailyAttendanceDBObj inEmpDailyAttendanceDBObj ){
inEmpDailyAttendanceDBObj.emp_id = "";
inEmpDailyAttendanceDBObj.emp_name = "";
inEmpDailyAttendanceDBObj.today_date = "";
inEmpDailyAttendanceDBObj.month = "";
inEmpDailyAttendanceDBObj.day = "";
inEmpDailyAttendanceDBObj.year = 0;
inEmpDailyAttendanceDBObj.in_time = "";
inEmpDailyAttendanceDBObj.out_time = "";
inEmpDailyAttendanceDBObj.remark = "";
}
public EmpDailyAttendanceDBObj getRecordByPrimaryKey(String inEmpId, String inTodayDate){
EmpDailyAttendanceDBObj empDailyAttendanceDBObj = new EmpDailyAttendanceDBObj();
try{
System.out.println("DBUser=="+DBUser+",DBPswd=="+DBPswd+",DBUrl=="+DBUrl);
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn= DriverManager.getConnection(DBUrl,DBUser,DBPswd);
Statement stmt = conn.createStatement();
String lSqlString = "select * from EMPLOYEE_DAILY_ATTENDANCE ";
lSqlString = lSqlString + "where emp_id='"+inEmpId+"' ";
lSqlString = lSqlString + "and today_date='"+inTodayDate+"' ";
ResultSet rs = null;
rs = stmt.executeQuery(lSqlString);
System.out.println("lSqlString====trtrt==within getRecordByPrimaryKey== "+lSqlString);
if( rs.next()){
System.out.println("fffff==="+rs.getString("emp_id"));
empDailyAttendanceDBObj.emp_id = (String)rs.getString("emp_id");
empDailyAttendanceDBObj.emp_name = (String)rs.getString("emp_name");
empDailyAttendanceDBObj.today_date = (String)rs.getString("today_date");
empDailyAttendanceDBObj.month = (String)rs.getString("month");
empDailyAttendanceDBObj.day = (String)rs.getString("day");
empDailyAttendanceDBObj.year = rs.getLong("year");
String intime=rs.getString("in_time");
if(intime!=null)
empDailyAttendanceDBObj.in_time = intime.substring(11,16);
String outtime=rs.getString("out_time");
if(outtime!=null)
empDailyAttendanceDBObj.out_time = outtime.substring(11,16);
empDailyAttendanceDBObj.remark = (String)rs.getString("remark");
System.out.println("fffff==="+rs.getString("emp_id"));
}
else{
initializeEmpDailyAttendanceDBObj(empDailyAttendanceDBObj);
}
System.out.println("fffff====="+empDailyAttendanceDBObj.emp_id);
}
catch(SQLException ex){
ex.printStackTrace();
}
return empDailyAttendanceDBObj;
}
public ArrayList selectEmpDailyAttendanceByCriteria(String inCriteria){
ArrayList EmpDailyAttendanceList = new ArrayList();
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn= DriverManager.getConnection(DBUrl,DBUser,DBPswd);
Statement stmt = conn.createStatement();
String lSqlString = "select * from EMPLOYEE_DAILY_ATTENDANCE ";
if( inCriteria != null && inCriteria.length() > 0 ){
lSqlString = lSqlString +" "+inCriteria+"" ;
}
System.out.println("Criteria===== "+inCriteria+" and query="+lSqlString);
ResultSet rs = null;
rs = stmt.executeQuery(lSqlString);
while( rs.next()){
EmpDailyAttendanceDBObj empDailyAttendanceDBObj = new EmpDailyAttendanceDBObj();
empDailyAttendanceDBObj.emp_id = (String)rs.getString("emp_id");
empDailyAttendanceDBObj.emp_name = (String)rs.getString("emp_name");
empDailyAttendanceDBObj.today_date = (String)rs.getString("today_date");
empDailyAttendanceDBObj.month = (String)rs.getString("month");
empDailyAttendanceDBObj.day = (String)rs.getString("day");
empDailyAttendanceDBObj.year = rs.getLong("year");
String intime=rs.getString("in_time");
if(intime!=null)
empDailyAttendanceDBObj.in_time = intime.substring(11,16);
String outtime=rs.getString("out_time");
if(outtime!=null)
empDailyAttendanceDBObj.out_time = outtime.substring(11,16);
empDailyAttendanceDBObj.remark = (String)rs.getString("remark");
EmpDailyAttendanceList.add(empDailyAttendanceDBObj);
}
}
catch(SQLException ex){
ex.printStackTrace();
}
return EmpDailyAttendanceList;
}
public int updateEmpDailyAttendanceDBObjByPrimaryKey(EmpDailyAttendanceDBObj inEmpDailyAttendanceDBObj){
int recupd = 0;
String lQuery = "";
lQuery = lQuery +"update EMPLOYEE_DAILY_ATTENDANCE set emp_name='"+inEmpDailyAttendanceDBObj.emp_name+"' ";
lQuery = lQuery +" , month='"+inEmpDailyAttendanceDBObj.month+"' ";
lQuery = lQuery +" , day='"+inEmpDailyAttendanceDBObj.day+"' ";
lQuery = lQuery +" , year="+inEmpDailyAttendanceDBObj.year+" ";
lQuery = lQuery +" , in_time=to_date('"+inEmpDailyAttendanceDBObj.today_date+" "+inEmpDailyAttendanceDBObj.in_time+"','yyyy-mm-dd HH24:MI') ";
lQuery = lQuery +" , out_time=to_date('"+inEmpDailyAttendanceDBObj.today_date+" "+inEmpDailyAttendanceDBObj.out_time+"','yyyy-mm-dd HH24:MI') ";
lQuery = lQuery +" , remark='"+inEmpDailyAttendanceDBObj.remark+"' ";
lQuery = lQuery + "where emp_id='"+inEmpDailyAttendanceDBObj.emp_id+"' ";
lQuery = lQuery + "and today_date='"+inEmpDailyAttendanceDBObj.today_date+"' ";
System.out.println("lSqlString===:"+lQuery);
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn= DriverManager.getConnection(DBUrl,DBUser,DBPswd);
Statement stmt = conn.createStatement();
recupd = stmt.executeUpdate(lQuery);
}
catch(SQLException ex){
ex.printStackTrace();
}
return recupd;
}
public EmpDailyAttendanceDBObj populateEmpDailyAttendanceDBObjFromReq(HttpServletRequest inReq){
EmpDailyAttendanceDBObj empDailyAttendanceDBObj = new EmpDailyAttendanceDBObj();
empDailyAttendanceDBObj.emp_id = (String)inReq.getParameter("emp_id");
empDailyAttendanceDBObj.emp_name = (String)inReq.getParameter("emp_name");
empDailyAttendanceDBObj.today_date = (String)inReq.getParameter("today_date");
empDailyAttendanceDBObj.month = (String)inReq.getParameter("month");
empDailyAttendanceDBObj.day = (String)inReq.getParameter("day");
empDailyAttendanceDBObj.year = Long.parseLong((String)inReq.getParameter("year"));
empDailyAttendanceDBObj.in_time = (String)inReq.getParameter("in_time");
empDailyAttendanceDBObj.out_time = (String)inReq.getParameter("out_time");
empDailyAttendanceDBObj.remark = (String)inReq.getParameter("remark");
return empDailyAttendanceDBObj;
}
public int insertEmpDailyAttendanceDBObj(EmpDailyAttendanceDBObj inEmpDailyAttendanceDBObj){
int recupd = 0;
String lQuery = "";
lQuery = lQuery +"insert into EMPLOYEE_DAILY_ATTENDANCE values ( ";
lQuery = lQuery +" '"+inEmpDailyAttendanceDBObj.emp_id+"' ";
lQuery = lQuery +" , '"+inEmpDailyAttendanceDBObj.emp_name+"' ";
lQuery = lQuery +" , '"+inEmpDailyAttendanceDBObj.today_date+"' ";
lQuery = lQuery +" , '"+inEmpDailyAttendanceDBObj.month+"' ";
lQuery = lQuery +" , '"+inEmpDailyAttendanceDBObj.day+"' ";
lQuery = lQuery +" , "+inEmpDailyAttendanceDBObj.year+" ";
lQuery = lQuery +" , to_date('"+inEmpDailyAttendanceDBObj.today_date+" "+inEmpDailyAttendanceDBObj.in_time+"','yyyy-mm-dd HH24:MI') ";
lQuery = lQuery +" , to_date('"+inEmpDailyAttendanceDBObj.today_date+" "+inEmpDailyAttendanceDBObj.out_time+"','yyyy-mm-dd HH24:MI') ";
lQuery = lQuery +" , '"+inEmpDailyAttendanceDBObj.remark+"' ";
lQuery = lQuery + " )";
System.out.println("lSqlString===:"+lQuery);
try{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
Connection conn= DriverManager.getConnection(DBUrl,DBUser,DBPswd);
Statement stmt = conn.createStatement();
recupd = stmt.executeUpdate(lQuery);
}
catch(SQLException ex){
ex.printStackTrace();
}
return recupd;
}
} | [
"SKN@SKN-PC"
] | SKN@SKN-PC |
14b15f0fefb12b918d479ce50dce00cb2583f86d | ddecdc885af9c408af9a72e387a870669289e50f | /src/main/java/straitjacket/util/OrderedHashSet.java | 8ea15482d01b5dc30c11e227cbddbd9a02a8f529 | [] | no_license | mrpietsch/straitjacket | 9681644d781933475b276098aaf39187e2c745df | 23c69707ae0d8e4b594015f4f2eedcd88f2d76db | refs/heads/master | 2021-01-01T03:44:45.947646 | 2014-01-02T23:31:02 | 2014-01-02T23:31:02 | 59,507,693 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,763 | java | package straitjacket.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
/**
* Extends the ArrayList and add the feature that no multiple entries are allowed.
*
* @param <T>
*/
public class OrderedHashSet<T> extends ArrayList<T> {
private static final long serialVersionUID = 1L;
//TODO wir wollen alles doppelt speichern ! sicher?
/**
* We save all enties of the list in an HashSet
*/
private final HashSet<T> elementHash;
/**
* Constructs an empty list with an initial capacity of ten.
*/
public OrderedHashSet () {
super();
elementHash = new HashSet<T>();
}
/**
* Constructs a list containing the elements of the specified collection,
* in the order they are returned by the collection's iterator.
* The ArrayList instance has an initial capacity of 110% the size of the specified collection.
* @param c the collection whose elements are to be placed into this list.
* @throws NullPointerException - if the specified collection is null.
*/
public OrderedHashSet (Collection<? extends T> c) {
super(c);
elementHash = new HashSet<T>(c);
}
/**
* Constructs an empty list with the specified initial capacity.
* @param initialCapacity - the initial capacity of the list.
* @throws IllegalArgumentException - if the specified initial capacity is negative
*/
public OrderedHashSet (int initialCapacity) {
super(initialCapacity);
elementHash = new HashSet<T>(initialCapacity);
}
/**
* Inserts the specified element at the specified position in this list.
* Shifts the element currently at that position (if any) and any subsequent
* elements to the right (adds one to their indices).
* If the element is already in the list nothing will be done.
* @param index index at which the specified element is to be inserted.
* @param element element to be inserted.
* @throws IndexOutOfBoundsException - if index is out of range (index < 0 || index > size()).
*/
@Override
public void add(int index, T element) {
if (elementHash.contains(element)) return;
elementHash.add(element);
super.add(index, element);
}
/**
* Appends the specified element to the end of this list.
* If the element is already in the list nothing will be done.
* @param o element to be appended to this list.
* @return true (as per the general contract of Collection.add).
*/
@Override
public boolean add(T o) {
if (elementHash.contains(o)) return false;
elementHash.add(o);
return super.add(o);
}
/**
* Replaces the element at the specified position in this list with the specified element.
* If the element is already in the list nothing will be done.
*
* @param index index of element to replace.
* @param element element to be inserted.
* @return the element previously at the specified position.
* @throws IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).
*/
@Override
public T set(int index, T element) {
if (!elementHash.contains(element)) {
// remove the old index element from the Hashtable and add the new one
elementHash.remove(this.get(index));
elementHash.add(element);
return super.set(index, element);
} else return null;
}
/**
* Removes the element at the specified position in this list.
* Shifts any subsequent elements to the left (subtracts one from their indices).
* @param index the index of the element to removed.
* @return the element that was removed from the list.
* @throws IndexOutOfBoundsException - if index out of range (index < 0 || index >= size()).
*/
@Override
public T remove(int index) {
elementHash.remove(this.get(index));
return super.remove(index);
}
/**
* Removes the specified element from the list
* @param o to be removed from this list, if present.
* @return true if the collection contained the specified element.
*/
@Override
public boolean remove(Object o) {
elementHash.remove(o);
return super.remove(o);
}
/**
* Returns true if this list contains the specified element.
* @param elem element whose presence in this List is to be tested.
* @return true if the specified element is present; false otherwise.
*/
@Override
public boolean contains(Object elem) {
return elementHash.contains(elem);
}
/**
* Appends all of the elements in the specified Collection to the end of this list,
* in the order that they are returned by the specified Collection's Iterator.
* The behavior of this operation is undefined if the specified Collection is modified
* while the operation is in progress. (This implies that the behavior of this call is
* undefined if the specified Collection is this list, and this list is nonempty.)
* If an element of c is already in the list, false is return and nothing happens.
*
* @param c the elements to be inserted into this list.
* @return true if this list changed as a result of the call.
* @throws NullPointerException - if the specified collection is null.
*/
@Override
public boolean addAll(Collection<? extends T> c) {
for (T t : c) if (elementHash.contains(t)) return false;
elementHash.addAll(c);
return super.addAll(c);
}
/**
* Inserts all of the elements in the specified Collection into this list,
* starting at the specified position. Shifts the element currently at that position
* (if any) and any subsequent elements to the right (increases their indices).
* The new elements will appear in the list in the order that they are returned by
* the specified Collection's iterator.
* If an element of c is already in the list, false is return and nothing happens.
* @param index index at which to insert first element from the specified collection.
* @param c elements to be inserted into this list.
* @return true if this list changed as a result of the call.
* @throws IndexOutOfBoundsException - if index out of range (index < 0 || index > size()).
* @throws NullPointerException - if the specified Collection is null.
*/
@Override
public boolean addAll(int index, Collection<? extends T> c) {
for (T t : c) if (elementHash.contains(t)) return false;
elementHash.addAll(c);
return super.addAll(index, c);
}
/**
* Removes from this List all of the elements whose index is between fromIndex,
* inclusive and toIndex, exclusive. Shifts any succeeding elements to the left
* (reduces their index). This call shortens the list by (toIndex - fromIndex)
* elements. (If toIndex==fromIndex, this operation has no effect.)
* @param fromIndex index of first element to be removed.
* @param toIndex index after last element to be removed.
*/
@Override
protected void removeRange(int fromIndex, int toIndex) {
for (int i=fromIndex;i<toIndex;i++) elementHash.remove(this.get(i));
super.removeRange(fromIndex, toIndex);
}
/**
* Returns true if this list contains all of the elements of the specified collection.
* @param c collection to be checked for containment in this set.
* @return true if this set contains all of the elements of the specified collection.
* @throws ClassCastException - if the types of one or more elements in the specified collection are incompatible with this set (optional).
* @throws NullPointerException - if the specified collection contains one or more null elements and this set does not support null elements (optional).
* @throws NullPointerException - if the specified collection is null.
*
*/
@Override
public boolean containsAll(Collection<?> c) {
return elementHash.containsAll(c);
}
/**
* Removes from this list all of elements that are contained in the specified collection.
* @param c the elements to be removed
* @return true if this collection changed as a result of the call.
* @throws NullPointerException - if the specified collection is null.
*/
@Override
public boolean removeAll(Collection<?> c) {
elementHash.removeAll(c);
return super.removeAll(c);
}
/**
* Retains only the elements in this collection that are contained in the specified collection
* (optional operation). In other words, removes from this collection all of its elements that
* are not contained in the specified collection.
* @param c elements to be retained in this collection.
* @return true if this collection changed as a result of the call.
* @throws NullPointerException - if the specified collection is null.
*/
@Override
public boolean retainAll(Collection<?> c) {
elementHash.retainAll(c);
return super.retainAll(c);
}
}
| [
"[email protected]"
] | |
e8c79bbb3266fbef449452daa866a2377e404cf6 | e49ddf6e23535806c59ea175b2f7aa4f1fb7b585 | /tags/release-7.2.0/src/gov/nih/mipav/view/renderer/WildMagic/Poisson/Geometry/TriangleIndex.java | a69909dd4adb1dbb1a9cb84855078ae227c2d59d | [
"MIT"
] | permissive | svn2github/mipav | ebf07acb6096dff8c7eb4714cdfb7ba1dcace76f | eb76cf7dc633d10f92a62a595e4ba12a5023d922 | refs/heads/master | 2023-09-03T12:21:28.568695 | 2019-01-18T23:13:53 | 2019-01-18T23:13:53 | 130,295,718 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 133 | java | package gov.nih.mipav.view.renderer.WildMagic.Poisson.Geometry;
public class TriangleIndex {
public int[] idx = new int[3];
}
| [
"[email protected]@ba61647d-9d00-f842-95cd-605cb4296b96"
] | [email protected]@ba61647d-9d00-f842-95cd-605cb4296b96 |
47836efeadc5c74fb27bd39db12bb35ba52ce379 | ed4a304c72dd4a8ab1f90a5084d03085d79a8c2f | /retrieval/src/framework/base/snoic/base/ApplicationObjectManager.java | d1c984c9c826a448cecfe63edd938f8b9d4f1de1 | [] | no_license | 4lian/retrieval2014 | 44e024f04b495806e1347258b5f23bb9f74acf29 | a5620c1791bbef412b90307a5659c292283e38fd | refs/heads/master | 2021-01-18T05:10:09.899752 | 2014-01-23T16:35:39 | 2014-01-23T16:35:39 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,783 | java | /**
* Copyright 2010
*
* 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 framework.base.snoic.base;
import java.util.List;
import framework.base.snoic.base.pool.ObjectManager;
import framework.base.snoic.base.pool.ObjectPool;
import framework.base.snoic.system.interfaces.InitSystem;
import framework.base.snoic.system.interfaces.common.CommonObject;
/**
* 应用程序对象池,应用程序的对象池使用的时候应该继承这个类,并设置初始化类和对象池名称
* @author :
*
*/
public abstract class ApplicationObjectManager implements CommonObject{
protected ObjectManager objectManager=ObjectManager.getInstance();
protected String poolname;
protected InitSystem applicationInitialize=null;
protected IApplicationGetObject applicationGetObject=new ApplicationNoInitGetObject();
/**
* 设置对象池名称
* @param poolname The poolname to set.
*/
public void setPoolname(String poolname) {
this.poolname = poolname;
}
/**
* 设置初始化类
* @param applicationInitialize
*/
public synchronized void setApplicationInitialize(InitSystem applicationInitialize) {
this.applicationInitialize = applicationInitialize;
if(applicationInitialize!=null){
applicationGetObject=new ApplicationInitGetObject();
}
}
/**
* 创建对象池
*
*/
public void createPool(){
objectManager.createPool(poolname);
}
/**
* 创建对象池
* @param poolType 对象池类型
*
* 普通类型的对象池 ObjectPool.NORMAL_POOL
* 弱类型的对象池 ObjectPool.WEAK_POOL
*/
public void createPool(String poolType){
objectManager.createPool(poolname,poolType);
}
/**
* 清除对象池中的对象
*
*/
public void clearPool(){
objectManager.clearPool(poolname);
}
/**
* Security程序从对象池中取公共对象,如果没有取得对象,重新初始化系统
* @param objectname
* 对象名称
* @return Object
*/
public Object getObject(String objectname) {
Object object = applicationGetObject.getObject(objectManager, poolname, objectname, applicationInitialize);
return object;
}
/**
* 从对象池中取移除对象
*
* @param objectName
* 对象名称
* @return Object
*/
public Object checkOutObject(String objectName) {
Object object=objectManager.checkOutObject(poolname,objectName);
return object;
}
/**
* 往系统对象池中放入一个对象
* @param objectName
* @param object
*/
public void checkInObject(String objectName,Object object){
objectManager.checkInObject(poolname,objectName,object);
}
/**
* 获取对象池中所有对象名
* @return List
*/
public List getObjectNames(){
ObjectPool objectPool=objectManager.getObjectPool(poolname);
return objectPool.getObjectNames();
}
/**
* 获取对象池中所有对象
* @return List
*/
public List getObjects(){
ObjectPool objectPool=objectManager.getObjectPool(poolname);
return objectPool.getObjects();
}
/**
* 摧毁对象池
*
*/
public void destoryObjectPool(){
objectManager.removePool(poolname);
}
}
| [
"[email protected]"
] | |
b5303a6d0f0b055125af928445e1c2022226cdda | 2f766f9200e0293da0c8ec872894c00cc791bdad | /java/simpleTest/src/main/java/com/xubao/test/simpleTest/btraceTest/Timers.java | bd294302bd79772155bc30019a6298bcb7c1a2a3 | [] | no_license | vvxubaovv/MyTest | 86f9a38057f5bd5609c95c497d8dee0506cfe7cb | 5d21888db1378103dcf589bacf1baca9a89e0974 | refs/heads/master | 2022-12-20T04:25:28.469063 | 2019-09-23T13:07:12 | 2019-09-23T13:07:12 | 125,979,707 | 0 | 0 | null | 2022-12-16T12:00:27 | 2018-03-20T07:46:53 | Java | UTF-8 | Java | false | false | 1,856 | java | /*
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the Classpath exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package com.xubao.test.simpleTest.btraceTest;
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
/**
* Demonstrates multiple timer probes with different periods to fire.
*/
@BTrace
public class Timers {
// when starting print the target VM version and start time
static {
println("vm version " + Sys.VM.vmVersion());
println("vm starttime " + Sys.VM.vmStartTime());
}
@OnTimer(1000)
public static void f() {
println("1000 msec: " + Sys.VM.vmUptime());
}
@OnTimer(3000)
public static void f1() {
println("3000 msec: " + Time.millis());
}
}
| [
"[email protected]"
] | |
354df87807ad833073a06c72b99f7552a5fb8262 | 5836b23df3d50212ad13b2f70fd905dd49f1a2d4 | /src/java/model/Voluntario.java | 35288f97e8b234cd74606d0095d4203b93f85104 | [] | no_license | pedromcorreia/portal-voluntariado | 54fc131c4791a60a37f5738e48e71ca537d93535 | de5dc76305a86d310f90b1399d2382cce04b6879 | refs/heads/master | 2020-03-31T15:30:20.068993 | 2018-11-11T17:07:00 | 2018-11-11T17:07:00 | 152,340,105 | 0 | 1 | null | 2018-11-11T17:07:00 | 2018-10-10T00:41:14 | CSS | UTF-8 | Java | false | false | 1,401 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package model;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Ciro
*/
public class Voluntario extends Usuario implements Serializable {
private String cpf, comentario;
private int conquistas;
private List<Causa> causas;
private List<Habilidade> habilidades;
public Voluntario() {
}
public String getCpf() {
return cpf;
}
public void setCpf(String cpf) {
this.cpf = cpf;
}
public int getConquistas() {
return conquistas;
}
public void setConquistas(int conquistas) {
this.conquistas = conquistas;
}
public List<Causa> getCausas() {
return causas;
}
public void setCausas(List<Causa> causas) {
this.causas = causas;
}
public List<Habilidade> getHabilidades() {
return habilidades;
}
public void setHabilidades(List<Habilidade> habilidades) {
this.habilidades = habilidades;
}
public String getComentario() {
return comentario;
}
public void setComentario(String comentario) {
this.comentario = comentario;
}
}
| [
"[email protected]"
] | |
62d42a96685d9362f9a441672a36217545bac023 | 24d0968651638a011fe692057d068bc08d15c8fc | /src/javapack01/TocharArrayEx03WarmUp.java | cc51d0b7104edd11e449e762184db764754988a8 | [] | no_license | DanielSBLim/ssangyongSource | c1d203f54dff0d659d9bed01b123b4c04a1f06ad | 8fa3f440db83700096083b77a9eb337aa28bb932 | refs/heads/master | 2020-06-05T16:29:01.366425 | 2019-06-25T00:41:38 | 2019-06-25T00:41:38 | 192,483,914 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,788 | java | /*
* char jungDap[] = "1234432132";
* 입력된 학생값과 정답이 일치 하면 -> +10점
* char ox[] = new char[jungDamlength]
*
* [출력]
* 학생답 : x x x x
* 정 답 : 1 2 3 4
* ox판단: 0 X X 0
* ---------------
* 점수 :
*
*/
package javapack01;
import java.util.Scanner;
public class TocharArrayEx03WarmUp {
public static void main(String[] args) {
String varText;
Scanner scanObj = new Scanner(System.in);
System.out.println("학생 답안을 입력하세요 : [붙여서 10자리 입력]");
varText = scanObj.nextLine();
// 학생값 입력
char[] getchar;
getchar = varText.toCharArray();
intputNumberOverCheck(getchar);
numberlengthOverErrCheck(getchar);
// 문제 풀기
char[] jungDap;
char[] ox;
System.out.println("문제 답안을 입력하세요 : [붙여서 10자리 입력]");
Scanner scanObj2 = new Scanner(System.in);
jungDap = scanObj2.nextLine().toCharArray();
intputNumberOverCheck(jungDap);
numberlengthOverErrCheck(jungDap);
ox = judgment(getchar, jungDap);
printAll(getchar, jungDap, ox);
}
// 입력값 범위 검사
public static void intputNumberOverCheck(char[] intput) {
if (!(intput.length == 10)) {
System.out.println("입력 개수 오류");
System.exit(0);
}
}
// 한개의 범위가 1~4까지 범위검사
public static void numberlengthOverErrCheck(char[] getchar) {
for (int i = 0; i < getchar.length; i++) {
if (!(getchar[i] >= 49 && getchar[i] <= 52)) {
System.out.println("범위 입력 오류 확인 [ 1 ~ 4 사이의 답안 작성]");
System.exit(0);
}
}
}
// 판단 메소드
public static char[] judgment(char[] data, char[] answer) {
char[] cAnswer = new char[data.length];
for (int i = 0; i < data.length; i++) {
if (data[i] == answer[i]) {
cAnswer[i] = 'O';
} else {
cAnswer[i] = 'X';
}
}
return cAnswer;
}
// 출력 메소드
public static void printAll(char[] first, char[] second, char[] third) {
int jumsu = 0;
// 첫번째 배열 변수 출력
System.out.printf("학생값 : ");
for (int i = 0; i < first.length; i++) {
System.out.printf("%-2C", first[i]);
}
System.out.println();
// 두번째 배열 변수 출력
System.out.print("정 답 : ");
for (int i = 0; i < second.length; i++) {
System.out.printf("%-2C", second[i]);
}
System.out.println();
// 세번째 배열 변수 출력
for (int i = 0; i < third.length; i++) {
if (i == 0) {
System.out.printf("%10C ", third[i]);
} else {
System.out.printf("%-2C", third[i]);
}
if (third[i] == 'O') {
jumsu = jumsu + 10;
}
}
System.out.println();
System.out.println("-------------------------------------");
System.out.printf("점 수 : %d", jumsu);
}
}
| [
"[email protected]"
] | |
56e20f4b237c840c21e78e6852bf5bf8947a3be9 | 96e2d1bfbcaa606c8f67659f02f5d62f8701c253 | /src/main/java/com/wsheng/service/RedisLock.java | db0218f4dc0e7ef7606c56c0a6bd0f1990a53c79 | [] | no_license | wangsheng512/sell | af6972f1247e522fe824af841da1274ad6cd6635 | 38ea1002f7582a8c07d5ef6176f04eebfc67c1d8 | refs/heads/master | 2020-04-09T16:26:56.969419 | 2019-03-19T16:07:39 | 2019-03-19T16:07:39 | 160,453,594 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,776 | java | package com.wsheng.service;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;
/**
* Redis是单线程的
* @Auther: wsheng
* @Date: 2018/11/19 22:38
* @Description:
*/
@Component
@Slf4j
public class RedisLock {
@Autowired
private StringRedisTemplate redisTemplate;
/**ReadWriteLock
* 加锁
* @param key
* @param value 当前时间+超时时间
* @return
*/
public boolean lock(String key,String value){
if (redisTemplate.opsForValue().setIfAbsent(key,value)) {
//说明已经被锁定了
return true;
}
String currentValue = redisTemplate.opsForValue().get(key);
if (!StringUtils.isEmpty(currentValue) &&
Long.parseLong(currentValue) < System.currentTimeMillis()){
//获取上一个锁的是时间
String oldValue = redisTemplate.opsForValue().getAndSet(key,value);
if (!StringUtils.isEmpty(oldValue) && oldValue.equals(currentValue)){
return true;
}
}
return false;
}
/**
* 解锁
* @param key
* @param value
*/
public void unlock(String key ,String value){
try {
String currentValue = redisTemplate.opsForValue().get(key);
if (!StringUtils.isEmpty(currentValue)&& currentValue.equals(value)){
redisTemplate.opsForValue().getOperations().delete(key);
}
} catch (Exception e) {
log.error("【Redis分布式锁】 解锁异常, {}",e);
}
}
}
| [
"[email protected]"
] | |
9d4d9d2c727d733a861cd209bb67059185b1fff5 | 808381708bd04296c93766ad3ecddd5e89bd472b | /springboot-service-producto/src/test/java/com/formacionbdi/springboot/app/productos/SpringbootServiceProductoApplicationTests.java | e1b2524a1947e5abf9b631111ce875d95371bf97 | [] | no_license | imundo/Microservicios-con-Spring-Boot-2-Spring-Cloud-Eureka-Zuul-Ribbon-Hystrix-API-RESTful-JPA-OAu | 44a6137e3b5033ab79002de87f9e7ed8a57ee695 | 241ac33168ea75e7be9045cdf0d44cf2eab587e7 | refs/heads/master | 2022-09-14T19:10:20.405251 | 2020-05-27T16:03:39 | 2020-05-27T16:03:39 | 267,363,743 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 252 | java | package com.formacionbdi.springboot.app.productos;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class SpringbootServiceProductoApplicationTests {
@Test
void contextLoads() {
}
}
| [
"[email protected]"
] | |
d14834d6cd0c0e32dbc0cb6d39622f7309840ae4 | 1a850e6fa4aef73d5285e8ab210f7ef7e96a265c | /src/main/java/domain/Protocol.java | 417a6e3dca0824af4d4c56a79904b9c05033803c | [
"MIT"
] | permissive | GreyTeardrop/typeground | 135577fe1a60c58a74da4ab133a7515adac96d02 | 3f5ced57b7964c871971eeb6755a30a2abb47dd4 | refs/heads/master | 2020-05-24T15:31:54.635126 | 2013-10-20T17:54:01 | 2013-10-20T17:54:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,084 | java | package domain;
import java.util.HashSet;
import java.util.Set;
public class Protocol {
////////////////////////////////////////////////
// ATTRIBUTES
private String id;
private String text;
private Set<Selection> selections = new HashSet<Selection>();
private MetaProtocolInfo metaProtocolInfo = new MetaProtocolInfo();
////////////////////////////////////////////////
// GETTERS AND SETTERS
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}
public Set<Selection> getSelections() {
return selections;
}
public void setSelections(Set<Selection> selections) {
this.selections = selections;
}
public MetaProtocolInfo getMetaProtocolInfo() {
return metaProtocolInfo;
}
public void setMetaProtocolInfo(MetaProtocolInfo metaProtocolInfo) {
this.metaProtocolInfo = metaProtocolInfo;
}
}
| [
"[email protected]"
] | |
598d5eddb2104bcf44b48875351290f43ccdfdd0 | a36dce4b6042356475ae2e0f05475bd6aed4391b | /2005/julyarendaEJB/ejbModule/com/hps/july/arenda/sessionbean/_EJSRemoteStatelessLeaseArendaAgreementProcessor_03acdd81_Tie.java | 39c0d741ac49fdb6ce7177b0390d089db2917589 | [] | no_license | ildar66/WSAD_NRI | b21dbee82de5d119b0a507654d269832f19378bb | 2a352f164c513967acf04d5e74f36167e836054f | refs/heads/master | 2020-12-02T23:59:09.795209 | 2017-07-01T09:25:27 | 2017-07-01T09:25:27 | 95,954,234 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 9,601 | java | // Tie class generated by rmic, do not edit.
// Contents subject to change without notice.
package com.hps.july.arenda.sessionbean;
import java.io.Serializable;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.sql.Date;
import javax.ejb.EJBHome;
import javax.ejb.EJBObject;
import javax.ejb.Handle;
import javax.ejb.RemoveException;
import javax.rmi.CORBA.Util;
import org.omg.CORBA.BAD_OPERATION;
import org.omg.CORBA.SystemException;
import org.omg.CORBA.portable.UnknownException;
public class _EJSRemoteStatelessLeaseArendaAgreementProcessor_03acdd81_Tie extends org.omg.CORBA_2_3.portable.ObjectImpl implements javax.rmi.CORBA.Tie {
private EJSRemoteStatelessLeaseArendaAgreementProcessor_03acdd81 target = null;
private org.omg.CORBA.ORB orb = null;
private static final String[] _type_ids = {
"RMI:com.hps.july.arenda.sessionbean.LeaseArendaAgreementProcessor:0000000000000000",
"RMI:javax.ejb.EJBObject:0000000000000000",
"RMI:com.ibm.websphere.csi.CSIServant:0000000000000000",
"RMI:com.ibm.websphere.csi.TransactionalObject:0000000000000000"
};
public void setTarget(java.rmi.Remote target) {
this.target = (EJSRemoteStatelessLeaseArendaAgreementProcessor_03acdd81) target;
}
public java.rmi.Remote getTarget() {
return target;
}
public org.omg.CORBA.Object thisObject() {
return this;
}
public void deactivate() {
if (orb != null) {
orb.disconnect(this);
_set_delegate(null);
}
}
public org.omg.CORBA.ORB orb() {
return _orb();
}
public void orb(org.omg.CORBA.ORB orb) {
orb.connect(this);
}
public void _set_delegate(org.omg.CORBA.portable.Delegate del) {
super._set_delegate(del);
if (del != null)
orb = _orb();
else
orb = null;
}
public String[] _ids() {
return _type_ids;
}
public org.omg.CORBA.portable.OutputStream _invoke(String method, org.omg.CORBA.portable.InputStream _in, org.omg.CORBA.portable.ResponseHandler reply) throws org.omg.CORBA.SystemException {
try {
org.omg.CORBA_2_3.portable.InputStream in =
(org.omg.CORBA_2_3.portable.InputStream) _in;
switch (method.length()) {
case 6:
if (method.equals("remove")) {
return remove(in, reply);
}
case 11:
if (method.equals("_get_handle")) {
return _get_handle(in, reply);
} else if (method.equals("isIdentical")) {
return isIdentical(in, reply);
}
case 12:
if (method.equals("_get_EJBHome")) {
return _get_EJBHome(in, reply);
}
case 13:
if (method.equals("isChangeState")) {
return isChangeState(in, reply);
}
case 14:
if (method.equals("isInitialSaldo")) {
return isInitialSaldo(in, reply);
}
case 15:
if (method.equals("_get_primaryKey")) {
return _get_primaryKey(in, reply);
} else if (method.equals("checkOpenPeriod")) {
return checkOpenPeriod(in, reply);
} else if (method.equals("getBaseContract")) {
return getBaseContract(in, reply);
}
case 19:
if (method.equals("isChangeStateToEdit")) {
return isChangeStateToEdit(in, reply);
}
case 20:
if (method.equals("changeActiveDocument")) {
return changeActiveDocument(in, reply);
} else if (method.equals("getEndDateOfContract")) {
return getEndDateOfContract(in, reply);
}
}
throw new BAD_OPERATION();
} catch (SystemException ex) {
throw ex;
} catch (Throwable ex) {
throw new UnknownException(ex);
}
}
private org.omg.CORBA.portable.OutputStream _get_EJBHome(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
EJBHome result = target.getEJBHome();
org.omg.CORBA.portable.OutputStream out = reply.createReply();
Util.writeRemoteObject(out,result);
return out;
}
private org.omg.CORBA.portable.OutputStream _get_handle(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
Handle result = target.getHandle();
org.omg.CORBA.portable.OutputStream out = reply.createReply();
Util.writeAbstractObject(out,result);
return out;
}
private org.omg.CORBA.portable.OutputStream _get_primaryKey(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
Object result = target.getPrimaryKey();
org.omg.CORBA.portable.OutputStream out = reply.createReply();
Util.writeAny(out,result);
return out;
}
private org.omg.CORBA.portable.OutputStream isIdentical(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
EJBObject arg0 = (EJBObject) in.read_Object(EJBObject.class);
boolean result = target.isIdentical(arg0);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_boolean(result);
return out;
}
private org.omg.CORBA.portable.OutputStream remove(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
try {
target.remove();
} catch (RemoveException ex) {
String id = "IDL:javax/ejb/RemoveEx:1.0";
org.omg.CORBA_2_3.portable.OutputStream out =
(org.omg.CORBA_2_3.portable.OutputStream) reply.createExceptionReply();
out.write_string(id);
out.write_value(ex,RemoveException.class);
return out;
}
org.omg.CORBA.portable.OutputStream out = reply.createReply();
return out;
}
private org.omg.CORBA.portable.OutputStream changeActiveDocument(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
Integer arg0 = (Integer) in.read_value(Integer.class);
target.changeActiveDocument(arg0);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
return out;
}
private org.omg.CORBA.portable.OutputStream checkOpenPeriod(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
boolean result = target.checkOpenPeriod(arg0);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_boolean(result);
return out;
}
private org.omg.CORBA.portable.OutputStream getBaseContract(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
int result = target.getBaseContract(arg0);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_long(result);
return out;
}
private org.omg.CORBA.portable.OutputStream getEndDateOfContract(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
Date result = target.getEndDateOfContract(arg0);
org.omg.CORBA_2_3.portable.OutputStream out =
(org.omg.CORBA_2_3.portable.OutputStream) reply.createReply();
out.write_value(result,Date.class);
return out;
}
private org.omg.CORBA.portable.OutputStream isChangeState(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
boolean result = target.isChangeState(arg0);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_boolean(result);
return out;
}
private org.omg.CORBA.portable.OutputStream isChangeStateToEdit(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
boolean arg1 = in.read_boolean();
boolean result = target.isChangeStateToEdit(arg0, arg1);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_boolean(result);
return out;
}
private org.omg.CORBA.portable.OutputStream isInitialSaldo(org.omg.CORBA_2_3.portable.InputStream in , org.omg.CORBA.portable.ResponseHandler reply) throws Throwable {
int arg0 = in.read_long();
int arg1 = in.read_long();
Date arg2 = (Date) in.read_value(Date.class);
boolean result = target.isInitialSaldo(arg0, arg1, arg2);
org.omg.CORBA.portable.OutputStream out = reply.createReply();
out.write_boolean(result);
return out;
}
}
| [
"[email protected]"
] | |
1f2a7a0bfc6c17a9487082ab7dd3f9a1dc08a13e | 57c285215f314cba71c955dbad0b4c0221653823 | /app/src/main/java/yogiewisesa/jwork_android/RegisterActivity.java | 5471f80ad85f7978534b9047b534dcf673d91d26 | [] | no_license | yogie-wisesa/jwork-android | bbe6271622c5e3f6ada82cabcc28f7296de8c001 | bd42ed69572d33e10ab2b82034e1ee5f41b7edfe | refs/heads/main | 2023-05-31T11:29:51.515167 | 2021-06-27T14:40:00 | 2021-06-27T14:40:00 | 371,006,100 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,025 | java | /**
* @author Yogie Wisesa
* @version 26/6/21
*
* class register activity
* untuk menghandle view dan activity register
*/
package yogiewisesa.jwork_android;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.android.volley.RequestQueue;
import com.android.volley.Response;
import com.android.volley.toolbox.Volley;
import org.json.JSONException;
import org.json.JSONObject;
public class RegisterActivity extends AppCompatActivity {
/**
* method oncreate untuk pembuatan view
* @param savedInstanceState
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
ActionBar actionBar = getSupportActionBar();
actionBar.setDisplayHomeAsUpEnabled(true);
EditText etName = findViewById(R.id.etEmailReg);
EditText etEmail = findViewById(R.id.etEmailReg);
EditText etPassword = findViewById(R.id.etPasswordReg);
Button btnRegister = findViewById(R.id.btnRegister);
//listener tombol register
btnRegister.setOnClickListener(new View.OnClickListener() {
/**
* method pendengar ketika tombol register ditekan
* @param view
*/
@Override
public void onClick(View view) {
String name = etName.getText().toString();
String email = etEmail.getText().toString();
String password = etPassword.getText().toString();
Response.Listener<String> responseListener = new Response.Listener<String>(){
/**
* method pendengar response json dari jwork
* @param response
*/
@Override
public void onResponse(String response){
try{
JSONObject jsonObject = new JSONObject(response);
if (jsonObject != null) {
Toast.makeText(RegisterActivity.this, "Register Successful",
Toast.LENGTH_SHORT).show();
}
} catch (JSONException e){
Toast.makeText(RegisterActivity.this, "Register Failed",
Toast.LENGTH_SHORT).show();
System.out.println(e.getMessage());
}
}
};
RegisterRequest registerRequest = new RegisterRequest(name, email, password, responseListener);
RequestQueue queue = Volley.newRequestQueue(RegisterActivity.this);
queue.add(registerRequest);
}
});
}
} | [
"[email protected]"
] | |
c24039f41901d7cb6f245039175a3dba709986b1 | 4bfef92cbaf5c3cf322a26134f93df595ca462c2 | /Most-Wanted-MVC-master/src/main/java/mostwanted/repository/DistrictRepository.java | 2d9ab4709ae3fcefc774cfd887ded9047f682aa1 | [
"MIT"
] | permissive | mkasapov/mostWanted | c7e6fb954ebb962b544078be86eaa9bb1b049611 | 863c8cdfaf5d13fa2437a8f5c2de17aec698d820 | refs/heads/master | 2022-07-02T10:46:21.679925 | 2019-08-05T22:01:42 | 2019-08-05T22:01:42 | 198,082,972 | 0 | 0 | MIT | 2022-05-20T21:03:22 | 2019-07-21T17:00:18 | Java | UTF-8 | Java | false | false | 360 | java | package mostwanted.repository;
import mostwanted.domain.entities.District;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface DistrictRepository extends JpaRepository<District, Integer> {
Optional<District> findByName(String name);
}
| [
"[email protected]"
] | |
b0c25cf94fc0f221d33259f7b499c2d65c986ce8 | 57df237b7c987e7022db19c80b4c3f693c510fd1 | /HomeWork2/Q4.java | 144691e0c6633816e2b6d2f389f1b577d3e190f7 | [] | no_license | yunustzr/JavaTraining | f20592c271a863bf8848868724ca2922f179886f | 1e617aa561140df13107b78dbefc1bd742596d2e | refs/heads/master | 2022-08-28T07:35:44.838515 | 2020-05-29T20:34:01 | 2020-05-29T20:34:01 | 259,052,514 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 247 | java | package HomeWork2;
public class Q4 {
public static void main(String[] args) {
//Answer -C
//Veriable tanımlamalarında sayıyı ile değişken tanımlaması başlatılmaz.
/*
int blue$;
int _blue;
int 2blue;
int Blue;
*/
}
}
| [
"[email protected]"
] | |
3686679585108ae97d9c8db64f8c60e0205e47a6 | 8fabab4675f167352e1a6f4cb1f92cb662e097db | /app/src/main/java/zone/com/retrofitlisthelper/utils/GsonUtils.java | 9b9b427451bceae21afb931688611f96ba2298ee | [] | no_license | luhaoaimama1/ZAutoTurnPage | 119e4e63ba865ea01db14e6b09e0aa83ef23e90a | 43964e9356c836ec3875b1b7069cddb066ead617 | refs/heads/master | 2022-04-17T17:38:33.067837 | 2020-04-13T09:24:29 | 2020-04-13T09:24:29 | 255,272,814 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,703 | java | package zone.com.retrofitlisthelper.utils;
import com.google.gson.Gson;
import java.lang.reflect.Array;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.List;
/**
* Created by fuzhipeng on 16/9/23.
*/
public class GsonUtils {
static Gson gson=new Gson();
public static String toJson(Object obj) {
return gson.toJson(obj);
}
public static <T> T fromJson(String str, Class<T> t) {
try {
return gson.fromJson(str, t);
} catch (Exception e) {
return null;
}
}
/**
* 可以使用
* List<Person> ps = Arrays.asList(gson.fromJson(str, Person[].class));
* 但是还是提供了下此方法
* @param str
* @param t
* @return
*/
public static <T> T[] fromJsonToArray(String str, Class<T> t) {
try {
Class<? extends Object> cls = Array.newInstance(t, 0).getClass();
return gson.fromJson(str, (Type) cls);
} catch (Exception e) {
return null;
}
}
/**
* 或者用这两种种方式
* 1.List<Person> ps = gson.fromJson(str, new TypeToken<List<Person>>() {}.getType());
* 2.List<Person> ps = Arrays.asList
* (gson.fromJson(str, Person[].class));//不支持添加等操作!!!
* @param str
* @param t
* @return
*/
public static <T> List<T> fromJsonToList(String str, Class<T> t) {
try {
T[] temp = fromJsonToArray(str, t);
List<T> result=new ArrayList<>();
for (T t1 : temp)
result.add(t1);
return result;
} catch (Exception e) {
return null;
}
}
}
| [
"[email protected]"
] | |
29941489992a99424bc879cdb44a1dafe9d8fbf7 | 25d59da493ef31cf0736a846d2048a440de51f57 | /structures/src/main/java/huburt/structures/BinarySearchTree.java | b0fc145a399eb588aa00edf91c593d9ee22f8fe1 | [] | no_license | xing-tang/Huburt | 70b592463e979d985d67ab2d10e16458bf189ebe | b1a07695787776194b6d131eb37941ca0cbb8ddd | refs/heads/master | 2021-09-23T15:29:58.512330 | 2018-09-25T06:12:42 | 2018-09-25T06:12:42 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,470 | java | package huburt.structures;
/**
* Created by hubert on 2018/4/28.
* <p>
* 简版二叉树
*/
public class BinarySearchTree<T extends Comparable<? super T>> {
private Node<T> root;
public BinarySearchTree() {
root = null;
}
public void makeEmpty() {
root = null;
}
public boolean isEmpty() {
return root == null;
}
public boolean contains(T t) {
return contains(t, root);
}
public T findMin() {
if (isEmpty()) {
throw new IllegalStateException();
}
return findMin(root).element;
}
public T findMax() {
if (isEmpty()) {
throw new IllegalStateException();
}
return findMax(root).element;
}
public void insert(T t) {
root = insert(t, root);
}
public void remove(T t) {
root = remove(t, root);
}
public void printTree() {
if (isEmpty()) {
System.out.println("Empty Tree");
} else {
printTree(root);
}
}
private void printTree(Node<T> node) {
//中序遍历
if (root != null) {
printTree(node.left);
System.out.println(node.element);
printTree(node.right);
}
}
private boolean contains(T t, Node<T> node) {
if (node == null) {
return false;
}
int result = t.compareTo(node.element);
if (result < 0) {
return contains(t, node.left);
} else if (result > 0) {
return contains(t, node.right);
} else {
return true;
}
}
private Node<T> findMin(Node<T> node) {
//使用递归方式
if (node == null) {
return null;
} else if (node.left == null) {
return node;
} else {
return findMin(node.left);
}
}
private Node<T> findMax(Node<T> node) {
//使用循环方式
if (node != null) {
while (node.right != null) {
node = node.right;
}
}
return node;
}
private Node<T> insert(T t, Node<T> node) {
if (node == null) {
return new Node<>(t, null, null);
}
int result = t.compareTo(node.element);
if (result < 0) {
node.left = insert(t, node.left);
} else if (result > 0) {
node.right = insert(t, node.right);
} else {
;//重复,do nothing
}
return balance(node);
}
private Node<T> remove(T t, Node<T> node) {
if (node == null) {
return node;//item not found, do nothing
}
int i = t.compareTo(node.element);
if (i < 0) {
node.left = remove(t, node.left);
} else if (i > 0) {
node.right = remove(t, node.right);
} else if (node.left != null && node.right != null) {//two children
node.element = findMin(node.right).element;
node.right = remove(node.element, node.right);
} else {
node = node.left != null ? node.left : node.right;
}
return balance(node);
}
/**************************************AVL树支持*********************************************/
private static final int ALLOWED_IMBALANCE = 1;
private int height(Node<T> node) {
return node == null ? -1 : node.height;
}
private Node<T> balance(Node<T> node) {
if (node == null) {
return node;
}
if (height(node.left) - height(node.right) > ALLOWED_IMBALANCE) {
if (height(node.left.left) >= height(node.left.right)) {
node = rotateWithLeftChild(node);
} else {
node = doubleWithLeftChild(node);
}
} else if (height(node.right) - height(node.left) > ALLOWED_IMBALANCE) {
if (height(node.right.right) >= height(node.right.left)) {
node = rotateWithRightChild(node);
} else {
node = doubleWithRightChild(node);
}
}
node.height = Math.max(height(node.left), height(node.right)) + 1;
return node;
}
private Node<T> rotateWithLeftChild(Node<T> k2) {
Node<T> k1 = k2.left;
k2.left = k1.right;
k1.right = k2;
k2.height = Math.max(height(k2.left), height(k2.right)) + 1;
k1.height = Math.max(height(k1.left), k2.height) + 1;
return k1;
}
private Node<T> doubleWithLeftChild(Node<T> k3) {
k3.left = rotateWithRightChild(k3.left);
return rotateWithLeftChild(k3);
}
private Node<T> rotateWithRightChild(Node<T> k1) {
Node<T> k2 = k1.right;
k1.right = k2.left;
k2.left = k1;
k1.height = Math.max(height(k1.left), height(k2.right)) + 1;
k2.height = Math.max(k1.height, height(k1.right)) + 1;
return k2;
}
private Node<T> doubleWithRightChild(Node<T> k2) {
k2.right = rotateWithLeftChild(k2.right);
return rotateWithRightChild(k2);
}
private static class Node<T> {
T element;
Node<T> left;
Node<T> right;
int height;//节点高度,用于平衡树
Node(T element, Node<T> left, Node<T> right) {
this.element = element;
this.left = left;
this.right = right;
}
}
}
| [
"[email protected]"
] | |
cf87ff39e3fa53819e5a55ddeb361f5ccfe64082 | 315bc98df8e7590a20d80e8606f1e3c9150aeb40 | /test/net/sf/javadc/net/DownloadRequestStateTest.java | 55fc9cb999d776915581d50523cd7b8655bbc53e | [] | no_license | aeremenok/javadc4 | ea1c1acc0e7e64e99e49012e10a6e9c8dd086c7e | 4198e07cedf653fe22f12de28d91146df9f498a8 | refs/heads/master | 2016-09-05T09:19:06.478743 | 2009-01-10T10:12:36 | 2009-01-10T10:12:36 | 32,388,386 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,746 | java | /*
* Created on 20.7.2004
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
package net.sf.javadc.net;
import junit.framework.TestCase;
import net.sf.javadc.net.client.ConnectionState;
/**
* @author Timo Westk�mper
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/
public class DownloadRequestStateTest extends TestCase {
/**
* Constructor for DownloadRequestStateTest.
*
* @param arg0
*/
public DownloadRequestStateTest(String arg0) {
super(arg0);
}
/*
* @see TestCase#setUp()
*/
protected void setUp() throws Exception {
super.setUp();
}
private DownloadRequestState deriveActiveState(ConnectionState connState) {
return DownloadRequestState.deriveFromConnectionState(connState, true);
}
private DownloadRequestState derivePassiveState(ConnectionState connState) {
return DownloadRequestState.deriveFromConnectionState(connState, false);
}
/**
* tests the derivation for active requests
*/
public void testDownloadRequestStateDerivation_Active() {
assertEquals(deriveActiveState(ConnectionState.DOWNLOADING),
DownloadRequestState.DOWNLOADING);
assertEquals(deriveActiveState(ConnectionState.CONNECTING),
DownloadRequestState.CONNECTING);
assertEquals(deriveActiveState(ConnectionState.WAITING),
DownloadRequestState.WAITING);
assertEquals(deriveActiveState(ConnectionState.NOT_CONNECTED),
DownloadRequestState.OFFLINE);
assertEquals(deriveActiveState(ConnectionState.NO_DOWNLOAD_SLOTS),
DownloadRequestState.QUEUED);
assertEquals(deriveActiveState(ConnectionState.REMOTELY_QUEUED),
DownloadRequestState.REMOTELY_QUEUED);
}
/**
* tests the derivation for passive requests
*/
public void testDownloadRequestStateDerivation_Passive() {
assertEquals(derivePassiveState(ConnectionState.DOWNLOADING),
DownloadRequestState.QUEUED);
assertEquals(derivePassiveState(ConnectionState.CONNECTING),
DownloadRequestState.CONNECTING);
assertEquals(derivePassiveState(ConnectionState.NOT_CONNECTED),
DownloadRequestState.OFFLINE);
assertEquals(derivePassiveState(ConnectionState.NO_DOWNLOAD_SLOTS),
DownloadRequestState.QUEUED);
assertEquals(derivePassiveState(ConnectionState.REMOTELY_QUEUED),
DownloadRequestState.REMOTELY_QUEUED);
}
} | [
"eav1986@5e0f3e32-dcf7-11dd-bce9-bf72c0239d3a"
] | eav1986@5e0f3e32-dcf7-11dd-bce9-bf72c0239d3a |
0d667ccd174fe92e67072c76532adf98f39a3366 | 338d973f5c4e4e5119721e2604c302e62c72fee3 | /Leilao/src/leilao/Leilao.java | 82b4f7a7f2fd7ac2261cdaadb5029bb8c37c46d4 | [] | no_license | PabloFLPs/Programacao-Computadores-II | d156f29cb6f0f80e4129111009278c2477120ab5 | 574678aab97e1110ab58ae9e7ba539e15fef07d2 | refs/heads/master | 2023-03-22T16:46:45.584628 | 2021-03-21T05:01:13 | 2021-03-21T05:01:13 | 349,802,192 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,083 | java | package leilao;
public class Leilao {
private Lote_pablo[] leilao;
private String todosLotes="";
public Leilao(Lote_pablo[] leilao,String todosLotes){
this.leilao=leilao;
this.todosLotes=todosLotes;
}
public boolean adicionarLote(Lote_pablo lote){
for(int i=0;i<leilao.length;i++){
if(leilao[i]==null){
leilao[i]=lote;
return true;
}
}
return false;
}
public boolean recebeLance(Lance_pablo lance, String descricao){
for(int i=0;i<leilao.length;i++){
if(leilao[i].getDescricao().equals(descricao)){
return true;
}
}
return false;
}
public String imprimeLotes(){
for(int i=0;i<leilao.length;i++){
todosLotes=todosLotes+"Descricao do Lote: "+leilao[i].getDescricao()+" Lote vendido por: "+leilao[i].getMaiorLance()+"\n";
}
return todosLotes;
}
public String encerraLeilao(){
return "Leilao encerrado!";
}
} | [
"[email protected]"
] | |
e5fc255decb34bc362a43b5091f9f8439c266d8f | 5c6144b8da90767c95db5a64293bb94e8b43c4ff | /grass/src/com/gcrm/action/crm/BaseListAction.java | e6f7fef003d8d77ee880f7c3f9447b5daf9c64aa | [] | no_license | javajiao/grass | 92b6c9f7aa8862c2f6c6710b29f5970f974123a7 | f291ed508a631126628de9b8808d244005cda73a | refs/heads/master | 2021-01-21T07:57:06.699308 | 2014-10-11T08:46:29 | 2014-10-11T08:46:29 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 17,888 | java | /**
* Copyright (C) 2012 - 2013, Grass CRM Studio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gcrm.action.crm;
import java.io.File;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.struts2.ServletActionContext;
import com.gcrm.domain.Role;
import com.gcrm.domain.User;
import com.gcrm.exception.ServiceException;
import com.gcrm.util.CommonUtil;
import com.gcrm.util.Constant;
import com.gcrm.util.DateTimeUtil;
import com.gcrm.vo.SearchCondition;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
/**
* Base List Action for entity list
*/
public abstract class BaseListAction extends ActionSupport {
private static final long serialVersionUID = 5258442946380687955L;
/**
* How many rows we want to have into the grid - rowNum attribute in the
* grid
*/
private Integer rows = 0;
/** The requested page. By default grid sets this to 1. */
private Integer page = 0;
/** Sorting order - asc or desc. */
private String order = "asc";
/** Sort order - i.e. user click to sort. */
private String sort;
private String sidx;
private String sord;
private String filters;
private String _search;
private String filter_key;
private String filter_op;
private String filter_value;
private String createKey;
private String removeKey;
private String relationKey;
private String relationValue;
protected String seleteIDs = null;
protected Integer id;
private String q;
private String fileName;
private File upload;
private int successfulNum;
private int failedNum;
private int totalNum;
private Map<String, String> failedMsg;
@SuppressWarnings({ "serial" })
private static final Set<String> GRID_FIELD_SET = new HashSet<String>() {
{
add("sord");
add("page");
add("_search");
add("sidx");
add("rows");
add("nd");
add("filters");
}
};
/**
* Gets the search condition for EasyUI datagrid
*
* @return search condition
*/
protected SearchCondition getSearchCondition() throws Exception {
StringBuffer condition = new StringBuffer("");
if (!CommonUtil.isNullOrEmpty(q)) {
_search = Constant.BOOLEAN_TRUE;
filter_key = "name";
filter_op = Constant.FILTER_LIKE;
filter_value = q;
}
if (Constant.BOOLEAN_TRUE.equals(_search)) {
String op = filter_op;
String data = filter_value;
condition.append(filter_key).append(" ").append(op);
if (Constant.FILTER_LIKE.equals(op)) {
condition.append(" '%").append(data).append("%'");
} else {
condition.append(" ").append(data);
}
}
int pageNo = page;
int pageSize = rows;
if (CommonUtil.isNullOrEmpty(sort)) {
sort = "id";
order = "asc";
}
SearchCondition searchCondition = new SearchCondition(pageNo, pageSize,
sort, order, condition.toString());
return searchCondition;
}
/**
* Gets the search condition for Jquery UI datagrid
*
* @param fieldTypeMap
* field type map
* @param scope
* the flag to indicate to get all records or just the records of
* owner
* @param loginUser
* login user
* @return search condition
*/
@SuppressWarnings("rawtypes")
protected SearchCondition getSearchCondition(
Map<String, String> fieldTypeMap, int scope, User loginUser)
throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
StringBuilder condition = new StringBuilder("");
if (filters != null && filters.trim().length() > 0) {
advancedSearch(condition);
} else if (_search != null && "true".endsWith(_search)) {
HashMap parameters = (HashMap) request.getParameterMap();
Iterator iterator = parameters.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
if (!BaseListAction.GRID_FIELD_SET.contains(key)) {
String value = ((String[]) parameters.get(key))[0];
if (!fieldTypeMap.containsKey(key)) {
if (condition.length() != 0) {
condition.append(" AND ");
}
condition.append(key).append(" like '%").append(value)
.append("%'");
} else {
String fieldType = fieldTypeMap.get(key);
if (Constant.DATA_TYPE_DATETIME.equals(fieldType)) {
String dateScope = DateTimeUtil.getDateScope(key,
Integer.parseInt(value));
if (dateScope.length() > 0) {
if (condition.length() != 0) {
condition.append(" AND ");
}
condition.append(dateScope);
}
}
}
}
}
}
if (scope == Role.OWNER_OR_DISABLED) {
if (condition.length() != 0) {
condition.append(" AND ");
}
condition.append("owner = ").append(loginUser.getId());
}
int pageNo = page;
if (pageNo == 0) {
pageNo = 1;
}
int pageSize = rows;
if (pageSize == 0) {
pageSize = 1;
}
if (CommonUtil.isNullOrEmpty(sidx)) {
sidx = "id";
sord = "asc";
}
SearchCondition searchCondition = new SearchCondition(pageNo, pageSize,
sidx, sord, condition.toString());
return searchCondition;
}
/**
* Gets conditions for advanced search
*
* @param search
* condition
*/
@SuppressWarnings("serial")
public void advancedSearch(StringBuilder condition) throws Exception {
JSONObject json = JSONObject.fromObject(filters);
String groupOp = json.getString("groupOp");
String rules = json.getString("rules");
JSONArray array = JSONArray.fromObject(rules);
Map<String, String> opMap = new HashMap<String, String>() {
{
put("eq", "=");
put("ne", "<>");
put("lt", "<");
put("le", "<=");
put("gt", ">");
put("ge", ">=");
put("bw", "like");
put("bn", "not like");
put("in", "in");
put("ni", "not in");
put("ew", "like");
put("en", "not like");
put("cn", "like");
put("nc", "not like");
}
};
int size = array.size();
for (int i = 0; i < size; i++) {
JSONObject param = array.getJSONObject(i);
String field = param.getString("field");
String op = param.getString("op");
String data = param.getString("data");
if (condition.length() != 0) {
condition.append(" ").append(groupOp).append(" ");
}
condition.append(field).append(" ").append(opMap.get(op));
if ("bw".endsWith(op) || "bn".endsWith(op)) {
condition.append(" '").append(data).append("%'");
} else if ("in".endsWith(op) || "ni".endsWith(op)
|| "cn".endsWith(op) || "nc".endsWith(op)) {
condition.append(" '%").append(data).append("%'");
} else if ("ew".endsWith(op) || "en".endsWith(op)) {
condition.append(" '%").append(data).append("'");
} else {
condition.append(" '").append(data).append("'");
}
}
}
/**
* Sets filter expression and gets the list
*
* @return filtered list result
*/
public String filter() throws Exception {
this.set_search(Constant.BOOLEAN_TRUE);
this.setFilter_op("=");
this.setFilter_value(String.valueOf(id));
return this.list();
}
/**
* Abstract list method
*
* @return list result
*/
public abstract String list() throws Exception;
@SuppressWarnings({ "unchecked", "rawtypes" })
public String filterPage() throws Exception {
if (id == null) {
id = 0;
}
Map request = (Map) ActionContext.getContext().get("request");
String entityName = this.getEntityName();
request.put("entityName", entityName);
return SUCCESS;
}
protected abstract String getEntityName();
/**
* Gets Json header of list data
*
* @return Json header
*/
protected static String getJsonHeader(long totalRecords,
SearchCondition searchCondition, boolean isList) {
StringBuilder jsonBuilder = new StringBuilder("");
if (isList) {
long rowNumber = searchCondition.getPageSize();
long fullPageSize = 0;
if ((totalRecords % rowNumber) == 0) {
fullPageSize = totalRecords / rowNumber;
} else {
fullPageSize = totalRecords / rowNumber + 1;
}
String page = String.valueOf(searchCondition.getPageNo());
jsonBuilder.append("{\"total\": \"").append(fullPageSize)
.append("\", \"page\": \"").append(page)
.append("\", \"records\": \"").append(totalRecords)
.append("\", \"rows\": [");
} else {
jsonBuilder.append("{\"total\": ").append(totalRecords)
.append(",\"rows\": [");
}
String json = jsonBuilder.toString();
return json;
}
/**
* Goes to the select page
*
* @return SUCCESS result
*/
public String selectPage() throws ServiceException {
return SUCCESS;
}
public Integer getRows() {
return rows;
}
public void setRows(Integer rows) {
this.rows = rows;
}
public Integer getPage() {
return page;
}
public void setPage(Integer page) {
this.page = page;
}
public static long getSerialversionuid() {
return serialVersionUID;
}
public String getFilters() {
return filters;
}
public void setFilters(String filters) {
this.filters = filters;
}
public String get_search() {
return _search;
}
public void set_search(String _search) {
this._search = _search;
}
/**
* @return the order
*/
public String getOrder() {
return order;
}
/**
* @param order
* the order to set
*/
public void setOrder(String order) {
this.order = order;
}
/**
* @return the sort
*/
public String getSort() {
return sort;
}
/**
* @param sort
* the sort to set
*/
public void setSort(String sort) {
this.sort = sort;
}
/**
* @return the filter_key
*/
public String getFilter_key() {
return filter_key;
}
/**
* @param filter_key
* the filter_key to set
*/
public void setFilter_key(String filter_key) {
this.filter_key = filter_key;
}
/**
* @return the filter_op
*/
public String getFilter_op() {
return filter_op;
}
/**
* @param filter_op
* the filter_op to set
*/
public void setFilter_op(String filter_op) {
this.filter_op = filter_op;
}
/**
* @return the filter_value
*/
public String getFilter_value() {
return filter_value;
}
/**
* @param filter_value
* the filter_value to set
*/
public void setFilter_value(String filter_value) {
this.filter_value = filter_value;
}
/**
* @return the seleteIDs
*/
public String getSeleteIDs() {
return seleteIDs;
}
/**
* @param seleteIDs
* the seleteIDs to set
*/
public void setSeleteIDs(String seleteIDs) {
this.seleteIDs = seleteIDs;
}
/**
* @return the id
*/
public Integer getId() {
return id;
}
/**
* @param id
* the id to set
*/
public void setId(Integer id) {
this.id = id;
}
/**
* @return the q
*/
public String getQ() {
return q;
}
/**
* @param q
* the q to set
*/
public void setQ(String q) {
this.q = q;
}
/**
* @return the fileName
*/
public String getFileName() {
return fileName;
}
/**
* @param fileName
* the fileName to set
*/
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* @return the upload
*/
public File getUpload() {
return upload;
}
/**
* @param upload
* the upload to set
*/
public void setUpload(File upload) {
this.upload = upload;
}
/**
* @return the successfulNum
*/
public int getSuccessfulNum() {
return successfulNum;
}
/**
* @param successfulNum
* the successfulNum to set
*/
public void setSuccessfulNum(int successfulNum) {
this.successfulNum = successfulNum;
}
/**
* @return the failedNum
*/
public int getFailedNum() {
return failedNum;
}
/**
* @param failedNum
* the failedNum to set
*/
public void setFailedNum(int failedNum) {
this.failedNum = failedNum;
}
/**
* @return the totalNum
*/
public int getTotalNum() {
return totalNum;
}
/**
* @param totalNum
* the totalNum to set
*/
public void setTotalNum(int totalNum) {
this.totalNum = totalNum;
}
/**
* @return the failedMsg
*/
public Map<String, String> getFailedMsg() {
return failedMsg;
}
/**
* @param failedMsg
* the failedMsg to set
*/
public void setFailedMsg(Map<String, String> failedMsg) {
this.failedMsg = failedMsg;
}
/**
* @return the createKey
*/
public String getCreateKey() {
return createKey;
}
/**
* @param createKey
* the createKey to set
*/
public void setCreateKey(String createKey) {
this.createKey = createKey;
}
/**
* @return the removeKey
*/
public String getRemoveKey() {
return removeKey;
}
/**
* @param removeKey
* the removeKey to set
*/
public void setRemoveKey(String removeKey) {
this.removeKey = removeKey;
}
/**
* @return the relationKey
*/
public String getRelationKey() {
return relationKey;
}
/**
* @param relationKey
* the relationKey to set
*/
public void setRelationKey(String relationKey) {
this.relationKey = relationKey;
}
/**
* @return the relationValue
*/
public String getRelationValue() {
return relationValue;
}
/**
* @param relationValue
* the relationValue to set
*/
public void setRelationValue(String relationValue) {
this.relationValue = relationValue;
}
/**
* @return the sidx
*/
public String getSidx() {
return sidx;
}
/**
* @param sidx
* the sidx to set
*/
public void setSidx(String sidx) {
this.sidx = sidx;
}
/**
* @return the sord
*/
public String getSord() {
return sord;
}
/**
* @param sord
* the sord to set
*/
public void setSord(String sord) {
this.sord = sord;
}
}
| [
"[email protected]"
] | |
6ed27fb73a514c8b6acd546c6038413f69c75005 | f71f39e9922816bf3ee5ccdb3f85fdf8cf848b05 | /src/main/java/com/viraj/grabber/service/ThreadSyncService.java | 6db745c2ace8571aa2386ab50cee100f1611ea73 | [
"Apache-2.0"
] | permissive | virajajgaonkar/grabber | f9cead22a62fbcdff322a710f2e953c08e55a864 | 8035f728cce74ae855f93ebcb8d7f812e8c58d85 | refs/heads/master | 2020-03-22T02:06:07.963127 | 2018-07-04T19:37:53 | 2018-07-04T19:37:53 | 139,349,115 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 782 | java | package com.viraj.grabber.service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import java.lang.invoke.MethodHandles;
/**
* This class is used just to signal shutdown to all threads.
* Once the shutdown is detected using isShutdownDetected(), all threads are expected to finish current task & exit the threads.
*/
@Service
public class ThreadSyncService {
private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private boolean shutdownDetected = false;
public ThreadSyncService() {
}
public boolean isShutdownDetected() {
return shutdownDetected;
}
public void setShutdownDetected(boolean shutdownDetected) {
this.shutdownDetected = shutdownDetected;
}
} | [
"[email protected]"
] | |
6eed98e96daceebf8650c68ad693c2ef57873232 | bb8d975aed4cd7bcee7c5243a644dfdc746cbc76 | /src/com/rogerthat/app/AudioRecorder.java | bc1587824623c6eabcdc710df0d0528563cd66dd | [] | no_license | dexit/RogerThat | 0ee91a35e84d3be00a0b987e6600aa7e0fe54ade | 3f59cb8a030b8c42a873121a628a2ed66d577a99 | refs/heads/master | 2021-04-26T22:53:46.879663 | 2015-02-05T06:40:41 | 2015-02-05T06:40:41 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,917 | java | package com.rogerthat.app;
import android.content.*;
import android.media.*;
import java.text.*;
import java.util.*;
import android.os.*;
import java.io.*;
import android.widget.*;
import android.util.*;
public class AudioRecorder extends MediaRecorder implements MediaRecorder.OnErrorListener
{
Context context;
String TAG = "Audio Recorder";
private String curFilePath = null;
private String curFileName = null;
public AudioRecorder(Context ctx) {
super();
this.context = ctx;
}
public String createFilePath() throws IOException{
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
curFileName = "TEMP_"+timestamp+"_"+((MainActivity)context).getChannel()+"_"+".3gp";
File dir = context.getExternalFilesDir(null);
File temp = File.createTempFile("TEMP_"+timestamp+"_"+((MainActivity)context).getChannel()+"_", ".3gp",dir);
return temp.getAbsolutePath();
}
public void startRecording() throws IOException{
curFilePath = createFilePath();
setAudioSource(MediaRecorder.AudioSource.MIC);
setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
setOnErrorListener(this);
setOutputFile(curFilePath);
prepare();
start();
}
public void stopRecording(){
stop();
reset();
Intent i = new Intent(context, AudioSendService.class);
i.putExtra("filename",curFileName);
i.putExtra("filepath", curFilePath);
i.putExtra("channel",((MainActivity)context).getChannel());
// Service disabled PHP scripts not implemented yet
//context.startService(i);
}
@Override
public void onError(MediaRecorder p1, int p2, int p3)
{
Log.e(TAG,"OnError Callback Invoked");
Toast.makeText(context,"Audio capture failed! Try again.",Toast.LENGTH_LONG).show();
}
public String getCurFilePath(){
return curFilePath;
}
public String getCurFileName(){
return curFileName;
}
}
| [
"[email protected]"
] | |
4500764e9674afc71b013343543ff8db50e563d9 | 44c2c4610b05c64920038c6813f3db076957316f | /ParentLib/src/main/java/com/grass/parent/utils/SharePrefsUtils.java | 75d7ae1d90f7ab74cf394a1f2fe7697542f86267 | [] | no_license | xinkong/MyBaseLib | 9f73b96e1b3a3e0cb949cc84a9d055f63b6c04a4 | 8cd78cf130cf6a8f8e605e923cc6cd0553a49ba8 | refs/heads/master | 2020-09-16T09:23:35.689881 | 2019-12-03T06:26:28 | 2019-12-03T06:26:28 | 223,725,873 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,501 | java | package com.grass.parent.utils;
import android.content.Context;
import android.content.SharedPreferences;
import com.grass.parent.init.BaseModuleInit;
/**
* @author huchao
* @time 2017/7/3 17:35
* @explain: SharedPreferences工具类
*/
public class SharePrefsUtils {
private static SharedPreferences sp = null;
private static SharePrefsUtils spManager = null;
private static SharedPreferences.Editor editor = null;
/**
* Preference文件名
*/
private static final String SHARE_PREFREENCE_NAME = "pinpianyi.pre";
/**
* 初始化sp和edit
*/
private SharePrefsUtils() {
sp = BaseModuleInit.getApplication().getSharedPreferences(SHARE_PREFREENCE_NAME, Context.MODE_PRIVATE);
editor = sp.edit();
}
public static SharePrefsUtils getInstance() {
if (spManager == null || sp == null || editor == null) {
synchronized (SharePrefsUtils.class) {
if (spManager == null || sp == null || editor == null) {
spManager = new SharePrefsUtils();
}
}
}
return spManager;
}
public void putInt(String key, int value) {
editor.putInt(key, value);
editor.commit();
}
public int getInt(String key, int defaultValue) {
return sp.getInt(key, defaultValue);
}
public void putLong(String key, Long value) {
editor.putLong(key, value);
editor.commit();
}
public long getLong(String key, int defaultValue) {
return sp.getLong(key, defaultValue);
}
public void putString(String key, String value) {
editor.putString(key, value);
editor.commit();
}
public String getString(String key, String defaultValue) {
return sp.getString(key, defaultValue);
}
public void putFloat(String key, float value) {
editor.putFloat(key, value);
editor.commit();
}
public boolean isKeyExist(String key) {
return sp.contains(key);
}
public float getFloat(String key, float defaultValue) {
return sp.getFloat(key, defaultValue);
}
public void putBoolean(String key, boolean value) {
editor.putBoolean(key, value);
editor.commit();
}
public boolean getBoolean(String key, boolean defaultValue) {
return sp.getBoolean(key, defaultValue);
}
public void remove(String key) {
editor.remove(key);
editor.commit();
}
}
| [
"[email protected]"
] | |
b0b1942cff89b52da0943725f98912f0b6a0fe95 | e1699fc49fe4931d58fbcc8897a64d4163ee75ee | /src/com/changestuffs/shared/actions/GetOffersAction.java | 57764bb3c6bb64bec7a05f954ae45e3f31041cd0 | [] | no_license | jbescos/4xchangin | 75bf59071882c7323d9b7196ddad9f4930ecc1b5 | 589578f2d36dc58b07e43d0a450074c153e655e9 | refs/heads/master | 2021-01-10T19:14:26.916261 | 2014-01-26T18:45:33 | 2014-01-26T18:45:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 352 | java | package com.changestuffs.shared.actions;
import com.gwtplatform.dispatch.shared.Action;
public class GetOffersAction implements Action<GetOffersResult> {
public GetOffersAction() {
}
@Override
public String getServiceName() {
return Action.DEFAULT_SERVICE_NAME + "GetOffers";
}
@Override
public boolean isSecured() {
return false;
}
}
| [
"[email protected]"
] | |
24284faab18b8ca334e916c282b527414cf6f36d | 55c59928547add14af700992b3289092bc30124a | /src/java/controller/Add_form_update.java | b3e26f81834bca0600e1217d086f20d5f79bec22 | [] | no_license | cuongmanh1106/demo_Web | f2f1009e1024502e1158932b6fe29dce47bd7c05 | b2a5d03d65da330e24fd846927cb1410db14276c | refs/heads/master | 2021-01-23T19:15:28.188085 | 2017-09-08T03:25:16 | 2017-09-08T03:25:16 | 102,812,300 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,716 | java | /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;
import dbHelpers.ReadQuery;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
*
* @author TienDinh
*/
@WebServlet(name = "Add_form_update", urlPatterns = {"/update_form"})
public class Add_form_update extends HttpServlet {
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
try (PrintWriter out = response.getWriter()) {
/* TODO output your page here. You may use following sample code. */
out.println("<!DOCTYPE html>");
out.println("<html>");
out.println("<head>");
out.println("<title>Servlet Add_form_update</title>");
out.println("</head>");
out.println("<body>");
out.println("<h1>Servlet Add_form_update at " + request.getContextPath() + "</h1>");
out.println("</body>");
out.println("</html>");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//pass execution on to doPost
doPost(request,response);
}
/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
int ma_loai = Integer.parseInt(request.getParameter("ma_loai"));
ReadQuery rq = new ReadQuery();
ResultSet sp = rq.Doc_loai_san_pham_theo_ma_loai(ma_loai);
request.setAttribute("sp", sp);
String view = "views/v_sua_loai_san_pham.jsp";
request.setAttribute("view", view);
String url = "/sua_loai_san_pham.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
| [
"[email protected]"
] | |
8e0ea15d0c3359d74dde58a36d31af478313f68b | aaee2af102f7bf2d826d209a079b0d07e2d5719b | /src/main/java/com/github/gv2011/asn1/DERVideotexString.java | f0bfd7628d00768a62beaea2bd1c67aa975270fc | [
"MIT"
] | permissive | gv2011/asn1 | 9e3dd93ac493a061403948c7f43fc0f97260a576 | dbef170cb42d66caefd062af8820fb44b8a8b802 | refs/heads/master | 2021-08-15T19:23:20.972357 | 2021-01-25T21:40:46 | 2021-01-25T21:40:46 | 58,459,970 | 1 | 1 | null | 2017-11-12T00:44:43 | 2016-05-10T12:36:26 | Java | UTF-8 | Java | false | false | 4,029 | java | package com.github.gv2011.asn1;
/*-
* #%L
* Vinz ASN.1
* %%
* Copyright (C) 2016 - 2017 Vinz (https://github.com/gv2011)
* %%
* Please note this should be read in the same way as the MIT license. (https://www.bouncycastle.org/licence.html)
*
* Copyright (c) 2000-2015 The Legion of the Bouncy Castle Inc. (http://www.bouncycastle.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software
* and associated documentation files (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial
* portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
* #L%
*/
import com.github.gv2011.asn1.util.Strings;
import com.github.gv2011.util.bytes.Bytes;
public final class DERVideotexString extends ASN1PrimitiveBytes implements ASN1String{
/**
* return a Videotex String from the passed in object
*
* @param obj a DERVideotexString or an object that can be converted into one.
* @exception IllegalArgumentException if the object cannot be converted.
* @return a DERVideotexString instance, or null.
*/
public static DERVideotexString getInstance(
final Object obj)
{
if (obj == null || obj instanceof DERVideotexString)
{
return (DERVideotexString)obj;
}
if (obj instanceof Bytes)
{
try
{
return (DERVideotexString)fromBytes((Bytes)obj);
}
catch (final Exception e)
{
throw new IllegalArgumentException("encoding error in getInstance: " + e.toString());
}
}
throw new IllegalArgumentException("illegal object in getInstance: " + obj.getClass().getName());
}
/**
* return a Videotex String from a tagged object.
*
* @param obj the tagged object holding the object we want
* @param explicit true if the object is meant to be explicitly
* tagged false otherwise.
* @exception IllegalArgumentException if the tagged object cannot
* be converted.
* @return a DERVideotexString instance, or null.
*/
public static DERVideotexString getInstance(
final ASN1TaggedObject obj,
final boolean explicit)
{
final ASN1Primitive o = obj.getObject();
if (explicit || o instanceof DERVideotexString)
{
return getInstance(o);
}
else
{
return new DERVideotexString(((ASN1OctetString)o).getOctets());
}
}
/**
* basic constructor - with bytes.
* @param string the byte encoding of the characters making up the string.
*/
public DERVideotexString(final Bytes string){
super(string);
}
@Override
boolean isConstructed()
{
return false;
}
@Override
void encode(
final ASN1OutputStream out)
{
out.writeEncoded(BERTags.VIDEOTEX_STRING, string);
}
@Override
public String getString()
{
return Strings.fromByteArray(string);
}
}
| [
"[email protected]"
] | |
5b3dafc42112bbf2efd200416ddea63b21033808 | 5f64147fc965bc0263cb51b238d21cc8475d0f7f | /lab/lab03/SimpleMyDot/app/src/test/java/kmitl/lab03/bawonsak58070074/simplemydot/ExampleUnitTest.java | 1fa9445229faae00b2cf2d76c7f87b0dff006909 | [] | no_license | Kcomic/course-android-kmitl | b3d97ffad36c29cd7b777fcb2e29f46696362eb3 | 6ba917a4b0fb3dd567326e7017cd1e234b2d1b80 | refs/heads/master | 2021-01-16T00:56:38.575857 | 2017-11-17T15:28:04 | 2017-11-17T15:28:04 | 99,984,130 | 0 | 0 | null | 2017-08-11T02:38:44 | 2017-08-11T02:38:44 | null | UTF-8 | Java | false | false | 418 | java | package kmitl.lab03.bawonsak58070074.simplemydot;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
} | [
"[email protected]"
] | |
68c292843bf9a6cac56cad02e39161e7f7d57c41 | 3e32c6bd71577217b4b5db4890d314dfd17d6593 | /hcms-core/src/main/java/com/abminvestama/hcms/core/repository/T517XRepository.java | 4ef3d682bdb3d14d8c2f38c834d35c17d3ce4493 | [] | no_license | yauritux/hcms-api | d6e7fd3ac450a170c8065cda6c76224a4ce3c404 | 2e4538e9bc6f4dde70d894295197c00c9c82fe00 | refs/heads/master | 2021-01-10T01:15:00.935233 | 2016-02-03T07:09:54 | 2016-02-03T07:09:54 | 50,981,095 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 324 | java | package com.abminvestama.hcms.core.repository;
import org.springframework.data.repository.CrudRepository;
import com.abminvestama.hcms.core.model.entity.T517X;
/**
*
* @author yauri ([email protected])
* @version 1.0.0
* @since 1.0.0
*
*/
public interface T517XRepository extends CrudRepository<T517X, String> {
} | [
"[email protected]"
] | |
ee82fb78ac62e1fa838598980f743f265c42871b | 716fdc07a12936f985e416433e27861822373adc | /MovieCruiserService/src/main/java/com/stackroute/moviecruiserapp/exceptions/MovieNotFoundException.java | d4d5ca57d699d027d302ed0c877cc3d12f7d85c5 | [] | no_license | sandeepgangavali/MovieMyApp | 74c2a26418dc67ba690ac706b2a5a3c5d61ce27e | 53f6830bf4987c9b42e8af89166692bd47cf676e | refs/heads/master | 2021-05-20T03:19:40.523064 | 2020-04-01T12:16:42 | 2020-04-01T12:16:42 | 252,163,791 | 0 | 1 | null | 2020-10-13T20:49:43 | 2020-04-01T12:06:59 | Java | UTF-8 | Java | false | false | 294 | java | package com.stackroute.moviecruiserapp.exceptions;
public class MovieNotFoundException extends Exception {
public MovieNotFoundException(String title) {
super(title+" Movie not found");
}
public MovieNotFoundException(int id) {
super(id+" Movie not found");
}
} | [
"[email protected]"
] | |
04e8bb6c19655ae2a903b7b7fa9f6e069a25ba28 | acd6e70b32c65e571c23c902cc6fa077b1679ddd | /src/alver/SunApp/SunAppMain.java | 993609426d406a662dfb371d0d1397bd0941f088 | [] | no_license | mortenalver/SunApp | 818bf6e2ee4a57df137e91e91ae847240350a66b | 00d4d47d071cfd63db015a7c9a3d0e79d4320b24 | refs/heads/master | 2020-04-09T05:04:53.313025 | 2013-05-09T15:24:07 | 2013-05-09T15:24:07 | 9,961,863 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,812 | java | package alver.SunApp;
import android.app.Activity;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.provider.Settings;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class SunAppMain extends Activity implements View.OnClickListener {
private LocationListener locationListener;
public LocationManager locationManager;
private int count = 0;
public static final String LOGTAG = "SolMain";
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//TextView tv = new TextView(this);
//tv.setText("Welcome to Android world! by mirage");
//setContentView(tv);
Button b = (Button)findViewById(R.id.posBut);
b.setOnClickListener(this);
b = (Button)findViewById(R.id.tidBut);
b.setOnClickListener(new SolvinkelListener(this));
b = (Button)findViewById(R.id.getHorizon);
b.setOnClickListener(new GetHorizonData((TextView)findViewById(R.id.horizonText), this));
//ImageView iv = (ImageView)findViewById(R.id.imageView);
//iv.setImageResource(R.drawable.astg1);//Bitmap(BitmapFactory.decodeFile("/res/map/ASTGTM2_N66E014_num.tif"));
locationManager = (LocationManager)
getSystemService(Context.LOCATION_SERVICE);
}
@Override
public void onClick(View v) {
//Intent myIntent = new Intent(this, LocationChooser.class);
//startActivity(myIntent);
/*
TextView tv = (TextView)findViewById(R.id.textView);
boolean gpsOn = displayGpsStatus();
locationListener = new MyLocationListener();
locationManager.requestLocationUpdates(LocationManager
.GPS_PROVIDER, 5000, 10,locationListener);
Location loc = gpsOn ? locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) :
locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (loc != null) {
String longitude = "Longitude: " +loc.getLongitude();
String latitude = "Latitude: " +loc.getLatitude();
String s = longitude+"\n"+latitude;
tv.setText("GPS "+(gpsOn ? "on" : "off")+", "+longitude+" : "+latitude);
}
else tv.setText("GPS "+(gpsOn ? "on" : "off")+", no location available");
*/
}
public Location getLocation() {
boolean gpsOn = displayGpsStatus();
return gpsOn ? locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER) :
locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}
/*----Method to Check GPS is enable or disable ----- */
private Boolean displayGpsStatus() {
ContentResolver contentResolver = getBaseContext()
.getContentResolver();
boolean gpsStatus = Settings.Secure
.isLocationProviderEnabled(contentResolver,
LocationManager.GPS_PROVIDER);
if (gpsStatus) {
return true;
} else {
return false;
}
}
/*----------Listener class to get coordinates ------------- */
private class MyLocationListener implements LocationListener {
@Override
public void onLocationChanged(Location loc) {
TextView editLocation = (TextView)findViewById(R.id.textView);
editLocation.setText("");
//pb.setVisibility(View.INVISIBLE);
Toast.makeText(getBaseContext(), "Location changed : Lat: " +
loc.getLatitude() + " Lng: " + loc.getLongitude(),
Toast.LENGTH_SHORT).show();
String longitude = "Longitude: " +loc.getLongitude();
//Log.v(TAG, longitude);
String latitude = "Latitude: " +loc.getLatitude();
//Log.v(TAG, latitude);
String s = longitude+"\n"+latitude;
editLocation.setText((count++)+": "+s);
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider,
int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
}
| [
"[email protected]"
] | |
8349516aaa678b76a8b589b34cc3cad1c4a4ba90 | cba4cde39da02207ae7fa101c76e228cbf8d342f | /app/src/main/java/com/superdict/jingouxu/mysuperdict/utils/WordList.java | cafba4c9902cf59006beb54d90cc1def1cec42b8 | [] | no_license | xjoxjoxjo/neverforget | b62dccb4dd878877207257ef335b4998988d6e8c | 0f4bac5a1a7c123d55c29bf7019c5e01251d45c5 | refs/heads/master | 2021-01-10T19:55:41.612043 | 2014-09-29T00:51:01 | 2014-09-29T00:51:01 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,138 | java | package com.superdict.jingouxu.mysuperdict.utils;
import android.app.Activity;
import android.content.res.AssetManager;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
/**
* Created by jingouxu on 9/24/14.
*/
public class WordList {
private static WordList instance = null;
public static ArrayList<String> list = new ArrayList<String>(Constants.WORDS_LIST_LENGTH);
protected WordList(Activity activity) throws IOException {
AssetManager assetManager = activity.getAssets();
InputStream in = assetManager.open("words");
BufferedReader reader = new BufferedReader(new InputStreamReader(in));
int i = 0;
String line;
while ((line = reader.readLine()) != null){
list.add(line.trim());
i++;
}
in.close();
reader.close();
}
public static WordList getInstance(Activity activity) throws IOException {
if (instance == null){
instance = new WordList(activity);
}
return instance;
}
}
| [
"[email protected]"
] | |
91905ba29e0b72a5ee8b32dc0e027ebd3d4ce977 | 2f926130f2eb728401148e22791b4f9cfc704d67 | /models/Deliverer.java | 19561ca7f42424e2f84ad63a33cf3814f633d209 | [] | no_license | MiguelR-o/ProjetoOOP | 48f80c7d1e70d3e0c057b53a639d4858b9ace433 | e7f75abe0c1f23483721d78d4f684153e0e066d3 | refs/heads/master | 2023-02-16T11:36:56.257834 | 2021-01-18T23:34:52 | 2021-01-18T23:34:52 | 316,395,476 | 0 | 7 | null | 2022-08-28T18:21:14 | 2020-11-27T03:57:51 | Java | UTF-8 | Java | false | false | 850 | java | package models;
import java.util.HashMap;
public class Deliverer extends Employee {
private static final long serialVersionUID = 1L;
private HashMap<Integer, Deposit> deposits;
private HashMap<Integer, Delivery> deliveries;
public Deliverer(String name, int ID, String type) {
super(name, ID, type);
this.deposits = new HashMap<Integer,Deposit>();
this.deliveries = new HashMap<Integer,Delivery>();
}
public HashMap<Integer,Delivery> getDeliveries(){
return this.deliveries;
}
public HashMap<Integer,Deposit> getDeposits(){
return this.deposits;
}
public void addDelivery(Delivery delivery){
deliveries.put(delivery.getDeliveryID(),delivery);
}
public void addDeposit(Deposit deposit){
deposits.put(deposit.getDepositID(),deposit);
}
}
| [
"[email protected]"
] | |
d04013efa80517d2f64faee9cee8c037febff312 | 0eb26ba7a8f72c937243624ed1a01c4beab113a2 | /SendBean.java | 7b9dba61ff3d78819497c761723b8218df788ac7 | [] | no_license | VaibhaviRaut/MediSmart-Better-Health-with-IOT-Based-Smart-Med-Box | 954ec10c7493fde1a1560e806a5b8611681d3cda | 4ecb7f7a627c5e8b89addffa700d93f43178c579 | refs/heads/master | 2022-07-27T02:21:48.230534 | 2020-05-15T18:58:44 | 2020-05-15T18:58:44 | 264,273,622 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,081 | java | package mediSmart.Bean;
import java.util.Date;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import org.hibernate.annotations.GenericGenerator;
import mediSmart.Dao.DataInterface;
import mediSmart.Util.ConstantValues;
@Entity
@Table(name="sendtohardware")
public class SendBean implements DataInterface {
@Id
@GeneratedValue(generator=ConstantValues.INCREMENT)
@GenericGenerator(name=ConstantValues.INCREMENT,strategy=ConstantValues.INCREMENT)
private int sendId;
private Date entryDate;
private int scheduleId;
public int getSendId() {
return sendId;
}
public void setSendId(int sendId) {
this.sendId = sendId;
}
public Date getEntryDate() {
return entryDate;
}
public void setEntryDate(Date entryDate) {
this.entryDate = entryDate;
}
public int getScheduleId() {
return scheduleId;
}
public void setScheduleId(int scheduleId) {
this.scheduleId = scheduleId;
}
public SendBean() {
super();
// TODO Auto-generated constructor stub
}
}
| [
"[email protected]"
] | |
700c176159c2345a9c18f39d6d20859906740a35 | 2958df3f24ae8a8667394b6ebb083ba6a9a1d36a | /Universal08Cloud/src/br/UFSC/GRIMA/capp/movimentacoes/GenerateTrochoidalMovement1Main.java | 48f241aa9070db7a1d9077c47ceb668522e01923 | [] | no_license | igorbeninca/utevolux | 27ac6af9a6d03f21d815c057f18524717b3d1c4d | 3f602d9cf9f58d424c3ea458346a033724c9c912 | refs/heads/master | 2021-01-19T02:50:04.157218 | 2017-10-13T16:19:41 | 2017-10-13T16:19:41 | 51,842,805 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 16,056 | java | package br.UFSC.GRIMA.capp.movimentacoes;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.Vector;
import javax.vecmath.Point3d;
import org.junit.Test;
import br.UFSC.GRIMA.capp.CondicoesDeUsinagem;
import br.UFSC.GRIMA.capp.Workingstep;
import br.UFSC.GRIMA.capp.machiningOperations.BottomAndSideRoughMilling;
import br.UFSC.GRIMA.capp.machiningOperations.MachiningOperation;
import br.UFSC.GRIMA.capp.movimentacoes.estrategias.TrochoidalAndContourParallelStrategy;
import br.UFSC.GRIMA.capp.movimentacoes.estrategias.Two5DMillingStrategy;
import br.UFSC.GRIMA.capp.movimentacoes.generatePath.GenerateContournParallel;
import br.UFSC.GRIMA.entidades.Material;
import br.UFSC.GRIMA.entidades.features.Boss;
import br.UFSC.GRIMA.entidades.features.CircularBoss;
import br.UFSC.GRIMA.entidades.features.GeneralClosedPocket;
import br.UFSC.GRIMA.entidades.features.GeneralProfileBoss;
import br.UFSC.GRIMA.entidades.features.RectangularBoss;
import br.UFSC.GRIMA.entidades.ferramentas.FaceMill;
import br.UFSC.GRIMA.util.DesenhadorDeLimitedElements;
import br.UFSC.GRIMA.util.Path;
import br.UFSC.GRIMA.util.entidadesAdd.GeneralClosedPocketVertexAdd;
import br.UFSC.GRIMA.util.findPoints.LimitedArc;
import br.UFSC.GRIMA.util.findPoints.LimitedElement;
import br.UFSC.GRIMA.util.findPoints.LimitedLine;
import br.UFSC.GRIMA.util.geometricOperations.GeometricOperations;
public class GenerateTrochoidalMovement1Main
{
private static ArrayList<LimitedElement> elements = new ArrayList<LimitedElement>();
private static ArrayList<LimitedElement> formaOriginal;
private static GeneralClosedPocket pocket = new GeneralClosedPocket();
private static Workingstep ws;
public static void Project()
{
Point3d point1 = new Point3d(50, 50, 0);
Point3d point2 = new Point3d(70, 50, 0);
LimitedLine linha1 = new LimitedLine(point1, point2);
LimitedLine linha2 = new LimitedLine(linha1.getFinalPoint(), new Point3d(300, 300, 0));
// LimitedArc arco0= new LimitedArc(new Point3d(325.0,135.0,0), new Point3d(175.0,285.0,0), new Point3d(175.0,135.0,0));
// LimitedArc arco0= new LimitedArc(new Point3d(400, 200.0,0), new Point3d(350.0,250,0), new Point3d(350,200,0));
// LimitedArc arco0= new LimitedArc(new Point3d(350.0,250,0), new Point3d(400, 200.0,0), new Point3d(350,200,0));
// LimitedArc arco0= new LimitedArc(new Point3d(400, 200.0,0), new Point3d(350,200,0), Math.PI / 2);
LimitedLine l1= new LimitedLine(new Point3d(325.0,134.99999999999997,0), new Point3d(325.0,165.0,0));
LimitedLine l2= new LimitedLine(new Point3d(325.0,165.0,0), new Point3d(355.0000000000001,165.0,0));
LimitedLine l3= new LimitedLine(new Point3d(355.0,165.0000000000001,0), new Point3d(355.0,195.00000000000034,0));
LimitedLine l4= new LimitedLine(new Point3d(354.99999999999966,195.0,0), new Point3d(132.99999999999983,195.0,0));
LimitedLine l5= new LimitedLine(new Point3d(133.0,194.99999999999983,0), new Point3d(133.0,285.0,0));
LimitedLine l6= new LimitedLine(new Point3d(133.00000000000003,285.0,0), new Point3d(175.0,285.0,0));
LimitedLine l7= new LimitedLine(new Point3d(133.00000000000003,285.0,0), new Point3d(175.0,285.0,0));
LimitedLine l8= new LimitedLine(new Point3d(133.00000000000003,285.0,0), new Point3d(175.0,285.0,0));
// LimitedArc arco0 = new LimitedArc(new Point3d(400, 200.0, 0), new Point3d(350, 200, 0), Math.PI /2);
LimitedArc arco0 = new LimitedArc(new Point3d(400, 200.0, 0), new Point3d(400, 150, 0), Math.PI /2);
// elements.add(l1);
// elements.add(l2);
// elements.add(l3);
// elements.add(l4);
// elements.add(l5);
// elements.add(l6);
// elements.add(l7);
// elements.add(l8);
elements.add(arco0);
ArrayList<Point2D> points = new ArrayList<Point2D>();
//Forma 1
// points.add(new Point2D.Double(8, 160));
// points.add(new Point2D.Double(8, 320));
// points.add(new Point2D.Double(480, 320));
// points.add(new Point2D.Double(480, 40));
// points.add(new Point2D.Double(200, 40));
// points.add(new Point2D.Double(200,160));
//Forma 2
points.add(new Point2D.Double(500, 320));
points.add(new Point2D.Double(500, 160));
points.add(new Point2D.Double(280, 160));
points.add(new Point2D.Double(280, 40));
points.add(new Point2D.Double(0, 40));
points.add(new Point2D.Double(0, 320));
//Forma 3
// points.add(new Point2D.Double(8, 160));
// points.add(new Point2D.Double(8, 320));
// points.add(new Point2D.Double(480, 320));
// points.add(new Point2D.Double(700, 500));
// points.add(new Point2D.Double(700, 160));
// points.add(new Point2D.Double(480, 160));
// points.add(new Point2D.Double(480, 40));
// points.add(new Point2D.Double(200, 40));
// points.add(new Point2D.Double(200,160));
//Forma 4
// points.add(new Point2D.Double(10, 10));
// points.add(new Point2D.Double(200, 10));
// points.add(new Point2D.Double(200, 100));
// points.add(new Point2D.Double(350, 100));
// points.add(new Point2D.Double(350, 10));
// points.add(new Point2D.Double(500, 10));
// points.add(new Point2D.Double(500, 100));
// points.add(new Point2D.Double(400, 100));
// points.add(new Point2D.Double(400, 200));
// points.add(new Point2D.Double(180,200));
// points.add(new Point2D.Double(180, 100));
// points.add(new Point2D.Double(10, 100));
pocket.setPoints(points);
pocket.setRadius(30);
pocket.setPosicao(50, 50, 0);
pocket.setProfundidade(15);
ArrayList<Boss> itsBoss = new ArrayList<Boss>();
//Circular Boss
// CircularBoss arcBoss = new CircularBoss("", 200, 200, pocket.Z, 30, 15, pocket.getProfundidade());
CircularBoss arcBoss = new CircularBoss("", 200, 200, pocket.Z, 30, 30, pocket.getProfundidade());
itsBoss.add(arcBoss);
//Rectangular Boss
RectangularBoss rectBoss = new RectangularBoss(40, 40, pocket.getProfundidade(), 0);
rectBoss.setPosicao(120, 180, pocket.Z);
rectBoss.setRadius(10);
// itsBoss.add(rectBoss);
//General Boss
GeneralProfileBoss genBoss = new GeneralProfileBoss();
genBoss.setRadius(10);
ArrayList<Point2D> vertexPoints = new ArrayList<Point2D>();
vertexPoints.add(new Point2D.Double(150, 300));
vertexPoints.add(new Point2D.Double(300, 300));
vertexPoints.add(new Point2D.Double(300, 250));
vertexPoints.add(new Point2D.Double(200, 250));
vertexPoints.add(new Point2D.Double(200, 180));
// vertexPoints.add(new Point2D.Double(150, 180));
vertexPoints.add(new Point2D.Double(50, 180));
vertexPoints.add(new Point2D.Double(50, 240));
vertexPoints.add(new Point2D.Double(150, 240));
genBoss.setVertexPoints(vertexPoints);
// itsBoss.add(genBoss);
pocket.setItsBoss(itsBoss);
GeneralClosedPocketVertexAdd addPocketVertex = new GeneralClosedPocketVertexAdd(points, 0, 25);
formaOriginal = addPocketVertex.getElements();
// --- Menor distancia entre cavidade e protuberancia ---
ArrayList<LimitedElement> bossElement = new ArrayList<LimitedElement>();
for(ArrayList<LimitedElement> arrayTmp : GeometricOperations.tranformeBossToLimitedElement(itsBoss, pocket.Z))
{
for(LimitedElement elementTmp : arrayTmp)
{
bossElement.add(elementTmp);
}
}
double menorDistancia = GeometricOperations.minimumDistance(formaOriginal, bossElement);
// --- Criando Machining workingstep ----
// ---- criando Operacao ----
MachiningOperation operation = new BottomAndSideRoughMilling("Desbaste", 50);
operation.setCoolant(true);
// ---- criando Ferramenta ----
FaceMill ferramenta= new FaceMill();
ferramenta.setName("1");
ferramenta.setDiametroFerramenta(menorDistancia/2); //Diametro da ferramenta (mudei)
ferramenta.setMaterialClasse(Material.ACO_ALTA_LIGA);
// ---- criando Condicoes de usinagem -----
CondicoesDeUsinagem cond = new CondicoesDeUsinagem();
cond.setAp(2); //15
cond.setAe(10);
cond.setF(.0123);
cond.setN(1500);
// ---- criando estrategia -----
TrochoidalAndContourParallelStrategy strategy = new TrochoidalAndContourParallelStrategy();
strategy.setAllowMultiplePasses(true);
//Setar o trochoidalRadius nos proprios testes
strategy.setTrochoidalRadius(ferramenta.getDiametroFerramenta()/2);
// strategy.setTrochoidalFeedRate(20);
strategy.setOverLap(2);
strategy.setRotationDirectionCCW(Boolean.TRUE);
strategy.setTrochoidalSense(TrochoidalAndContourParallelStrategy.CCW);
// strategy.setRadialDephtPercent(20);
operation.setMachiningStrategy(strategy);
ws = new Workingstep();
ws.setId("milling test");
ws.setOperation(operation);
ws.setFerramenta(ferramenta);
ws.setFeature(pocket);
ws.setCondicoesUsinagem(cond);
Vector workingsteps = new Vector();
workingsteps.add(ws);
pocket.setWorkingsteps(workingsteps);
}
public void generateTrochoidalPathTest()
{
// ((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalRadius(20); //Raio
// ((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalFeedRate(25); //Avanco
ArrayList<ArrayList<LimitedElement>> parallel = GeometricOperations.parallelPath2(pocket, 90, 0);
ArrayList<Path> paths = new ArrayList<Path>();
for(ArrayList<LimitedElement> tmp : parallel)
{
GenerateTrochoidalMovement1 gen = new GenerateTrochoidalMovement1(tmp, ws);
for(Path pathTmp:gen.getPaths())
{
paths.add(pathTmp);
}
}
ArrayList<LimitedElement> movimentacoes = GenerateTrochoidalMovement1.transformPathsInLimitedElements(paths);
ArrayList<LimitedElement> all = new ArrayList<LimitedElement>();
for(LimitedElement tmp : formaOriginal)
{
all.add(tmp);
}
for(LimitedElement tmp : movimentacoes)
{
all.add(tmp);
}
DesenhadorDeLimitedElements desenhador = new DesenhadorDeLimitedElements(all);
desenhador.setVisible(true);
for(;;);
}
public static void main (String[] args) //generateMultipleParallelAndTrochoidalMovementTest()
{
Project();
double trochoidalRadius = ((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).getTrochoidalRadius();
System.out.println("Raio Trochoidal1: " + trochoidalRadius);
// double trochoidalPercent = 1.5;
double diametroFerramenta = ws.getFerramenta().getDiametroFerramenta();
System.out.println("diametro da Ferramenta1: " + diametroFerramenta);
double overLap =((Two5DMillingStrategy)ws.getOperation().getMachiningStrategy()).getOverLap();
double distance = trochoidalRadius + diametroFerramenta/2;
GenerateContournParallel generateContorun = new GenerateContournParallel(pocket, 0, 20 ,overLap);
ArrayList<ArrayList<ArrayList<LimitedElement>>> multiplePath = generateContorun.multipleParallelPath() ;
ArrayList<LimitedElement> pathsVector = new ArrayList<LimitedElement>();
for(int i = 0; i < multiplePath.size(); i++)
{
for(int j = 0; j < multiplePath.get(i).size(); j++)
{
// GeometricOperations.showElements(multiplePath.get(i).get(j));
GenerateTrochoidalMovement1 gen = new GenerateTrochoidalMovement1(multiplePath.get(i).get(j), ws); //trochoidalRadius, 15
ArrayList<LimitedElement> movimentacoes = GenerateTrochoidalMovement1.transformPathsInLimitedElements(gen.getPaths());
for(int k = 0; k < movimentacoes.size(); k ++)
{
pathsVector.add(movimentacoes.get(k));
}
}
}
ArrayList<LimitedElement> all = new ArrayList<LimitedElement>();
for(LimitedElement tmp : formaOriginal)
{
// all.add(tmp);
}
for(LimitedElement tmp : pathsVector)
{
all.add(tmp);
}
DesenhadorDeLimitedElements desenhador = new DesenhadorDeLimitedElements(all);
desenhador.setVisible(true);
for(;;);
}
public void generatePathsInLimitedLineBaseTest()
{
((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalRadius(10); //Raio
// ((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalFeedRate(5); //Avanco
ArrayList<LimitedElement> all = new ArrayList<LimitedElement>();
LimitedLine l1 = new LimitedLine(new Point3d(20,10,0), new Point3d(73,10,0));
all.add(l1);
ArrayList<LimitedElement> elements = new ArrayList<LimitedElement>();
elements.add(l1);
GenerateTrochoidalMovement1 gen = new GenerateTrochoidalMovement1(elements,ws);
ArrayList<Path> paths = gen.getPaths();
ArrayList<LimitedElement> pathToElements = GenerateTrochoidalMovement1.transformPathsInLimitedElements(paths);
for(LimitedElement tmp : pathToElements)
{
all.add(tmp);
}
DesenhadorDeLimitedElements desenhador = new DesenhadorDeLimitedElements(all);
desenhador.setVisible(true);
for(;;);
}
//Adicao dos transitionPaths:
//-Funcionado para linha-linha
@Test
public void generatePathsTest()
{
((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalRadius(10); //Raio
// ((TrochoidalAndContourParallelStrategy)ws.getOperation().getMachiningStrategy()).setTrochoidalFeedRate(5); //Avanco
ArrayList<LimitedElement> all = new ArrayList<LimitedElement>();
ArrayList<LimitedElement> elementos = new ArrayList<LimitedElement>();
double Z = -10;
//----------------------------------------------------------------------------------------------
//Linha - Linha
LimitedLine l1 = new LimitedLine(new Point3d(50,10,Z),new Point3d(83,10,Z));
LimitedLine l2 = new LimitedLine(new Point3d(83,10,Z), new Point3d(20,53,Z));
//----------------------------------------------------------------------------------------------
//Arco - Arco: Caso 1
LimitedArc a1 = new LimitedArc(new Point3d(50,50,0),new Point3d(50,0,0),Math.PI/2);
LimitedArc a2 = new LimitedArc(new Point3d(150,50,0),new Point3d(100,50,0),Math.PI/2);
//Arco - Arco: Caso 2
Point3d a1C = new Point3d(50,50,Z);
Point3d a1I = new Point3d(70,60,Z);
Point3d a1F = new Point3d(60,70,Z);
double a1Angle = GeometricOperations.calcDeltaAngle(a1I, a1F, a1C, Math.PI);
// LimitedArc a1 = new LimitedArc(a1C,a1I,a1Angle);
// LimitedArc a2 = new LimitedArc(new Point3d(70,50,Z),a1F,a1.getDeltaAngle());
//-----------------------------------------------------------------------------------------------
//Linha(l1) - Arco(a3)
Point3d unitVectorl1 = GeometricOperations.unitVector(l1.getInitialPoint(), l1.getFinalPoint());
double a3Radius = 15;
// Point3d a3Center = GeometricOperations.pointPlusEscalar(GeometricOperations.absoluteParallel(l1, a3Radius, true).getFinalPoint(),"x",-10);
// Point3d a3InitialPoint = l1.getFinalPoint();
// Point3d a3Center = new Point3d(l1.getFinalPoint().x + GeometricOperations.multiply(a3Radius, unitVectorl1).x, l1.getFinalPoint().y + GeometricOperations.multiply(a3Radius, unitVectorl1).y,l1.getFinalPoint().z);
//Arco(a3) - Linha(l1): Caso 1
LimitedLine parallelL1 = GeometricOperations.absoluteParallel(l1, a3Radius, true);
Point3d a3Center = parallelL1.getInitialPoint();
Point3d a3InitialPoint = new Point3d(parallelL1.getInitialPoint().x + GeometricOperations.multiply(-a3Radius, unitVectorl1).x,parallelL1.getInitialPoint().y + GeometricOperations.multiply(-a3Radius, unitVectorl1).y,l1.getInitialPoint().z);
LimitedArc a3 = new LimitedArc(a3Center,a3InitialPoint,Math.PI/2);
//Arco(a4) - Linha(l3): Caso 2 (ERRO!)
LimitedArc a4 = new LimitedArc(new Point3d(50,50,0),new Point3d(10,50,0),-Math.PI/2);
LimitedLine l3 = new LimitedLine(a4.getFinalPoint(),GeometricOperations.pointPlusEscalar(a4.getFinalPoint(), "x", 50));
//-----------------------------------------------------------------------------------------------
elementos.add(a1);
elementos.add(a2);
GenerateTrochoidalMovement1 gen = new GenerateTrochoidalMovement1(elementos, ws);
ArrayList<Path> paths = gen.getPaths();
ArrayList<LimitedElement> pathToElements = GenerateTrochoidalMovement1.transformPathsInLimitedElements(paths);
for(LimitedElement tmp : elementos)
{
all.add(tmp);
}
for(LimitedElement tmp : pathToElements)
{
all.add(tmp);
}
DesenhadorDeLimitedElements desenhador = new DesenhadorDeLimitedElements(all);
desenhador.setVisible(true);
for(;;);
}
}
| [
"[email protected]"
] | |
2cfac6be19e31312a8f409c8713198490f372eb3 | e3342af2d25d22eb351b99f8916af87f5de4a68b | /Eclipse/LB/src/ast/Break.java | 5b93352799b10e07ad2d5e0eeb84c29183a8ad77 | [] | no_license | tacsio/compilers | 64637290fab1ce835b36d477abd8f596c03ee982 | 301a25af789e359f35ac1fc493e84dcbcbe51f35 | refs/heads/master | 2016-09-06T08:31:54.003853 | 2012-10-17T02:26:43 | 2012-10-17T02:26:43 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 259 | java | package ast;
import org.antlr.runtime.Token;
import visitor.Visitor;
public class Break extends No {
public Break(Token payload) {
super(payload);
}
@Override
public Object accept(Visitor visitor, Object o) {
return visitor.visit(this, o);
}
}
| [
"[email protected]"
] | |
58f4a9fad89c759582036f1fc16b990fe68f1a93 | 56687f62f27343de445d02694139843e3ad82f3a | /src/cc4102/tarea3/adt/Circuit.java | f8e49a3d171c1a91c22ac5cb0cc156ebe8c913ae | [
"Apache-2.0"
] | permissive | ommirandap/EuclideanTSP | 883344c67bca71ad252711eedd3972581c68640b | 2aedb30666de6a469d92dc1264f805b8cd4ca73b | refs/heads/master | 2021-01-01T05:48:59.094834 | 2014-07-02T20:17:23 | 2014-07-02T20:17:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,817 | java | package cc4102.tarea3.adt;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import cc4102.tarea3.geom.Point;
public class Circuit extends LinkedList<Point> {
List<Double> distances;
public Circuit() {
super();
}
public Circuit(Collection<? extends Point> c) {
super(c);
}
@Override
public void add(int index, Point element) {
super.add(index, element);
updateDistanceAt(index);
//calculateDistances(index-1, index);
}
@Override
public boolean add(Point element) {
super.add(element);
updateDistanceAt(size()-1);
//calculateDistances(size()-2, size()-1);
return true;
}
private void updateDistanceAt(int index) {
distances.remove(index-1);
distances.add(index-1, get(index-1).distance(get(index)));
distances.add(index, get(index).distance(get((index+1) % size())));
}
public void calculateDistances() {
if(distances == null) {
distances = new ArrayList<Double>();
}
for(int i=0;i<size();i++) {
distances.add(i, get(i).distance(get((i+1) % size())));
}
}
/**
* Returns a precalculated distance between a consecutive pair of nodes in the path.
* @param nodeIndex Node index of the first node in the path.
* @return Distance between the node distance from the node located at nodeIndex to the next node in the path.
*/
public Double distanceAt(int nodeIndex) {
if(distances != null && distances.size() > nodeIndex) {
return distances.get(nodeIndex);
}
return null;
}
public Iterator<Double> getDistancesIterator() {
return distances.iterator();
}
public Iterator<Double> getDistancesIterator(int index) {
return distances.listIterator(index);
}
}
| [
"[email protected]"
] | |
09b22affb396e0ec3602357ffb21c507fa36e837 | 8c71d40b8731a9dbb7d06f0730a1e9bb91f5ca7b | /src/test/java/com/automation/test/day8/ForgotPassword.java | 3a9921a67fe4d564d92f691054a1090ffc447cc1 | [] | no_license | VolodymyrPodoinitsyn/Fall2019Selenium | 4b864ea188c060af693f8b63e372b11db0b02098 | 37ecbd17330c31d97d0eda2043beef315b7e39a1 | refs/heads/master | 2022-04-10T07:03:08.685274 | 2020-04-03T04:16:47 | 2020-04-03T04:16:47 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 67 | java | package com.automation.test.day8;
public class ForgotPassword {
}
| [
"[email protected]"
] | |
3a2fde1d0cc87e6d845739d38393c6d5a398f4dd | 913888dbf59f34f9010f8d55c1a7eb0ae6ca284d | /ConsoleApplications/OnlineMedicalMangementSystem/ServicesForDoctor.java | a91209b7845d24f908c602a46bd4c98e38b4b6ef | [] | no_license | shashipreetham4115/OOPs_Examples | ecadf35867c843d648e240a4060b737ed6bc2335 | 895e803df73a0a49d9e74d3870352a12e0c6337a | refs/heads/master | 2023-09-04T00:25:11.659106 | 2021-11-01T05:37:19 | 2021-11-01T05:37:19 | 416,185,065 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,399 | java | package ConsoleApplications.OnlineMedicalMangementSystem;
import java.util.*;
public class ServicesForDoctor extends ServicesForPatient implements DoctorServices {
public void AddMedicalPrescription(String dID) {
Scanner scanner = new Scanner(System.in);
System.out.println("\n----------------------------------------------");
System.out.println("---------Adding Medical Prescription----------\n");
System.out.print("Please Enter Patient ID : ");
String pID = scanner.next();
System.out.print("Please Enter Date : ");
String date = scanner.next();
System.out.print("Please Enter Health Issue : ");
String reason = scanner.next();
System.out.print("Please Enter Status of Patient : ");
String status = scanner.next();
System.out.println("Please Give E-Prescription : ");
String diagnosis = "";
while (scanner.hasNext()) {
String temp = scanner.nextLine();
if (temp.equals("--q"))
break;
diagnosis = diagnosis + "\n" + temp;
}
System.out.println("Please Give Healthcare Suggestions : ");
String suggestions = "";
while (scanner.hasNext()) {
String temp = scanner.nextLine();
if (temp.equals("--q"))
break;
suggestions = suggestions + "\n" + temp;
}
System.out.println("Is any donor helped if yes please enter donor id else enter -1 : ");
String donorId = scanner.next();
if (donorId.charAt(0) == 'g') {
if (donors_db.containsKey(donorId)) {
donors_db.get(donorId).status = "Donated";
}
}
MedicalReport mr = new MedicalReport(date, reason, status, diagnosis, suggestions, dID, donorId);
if (!medicalReports_db.containsKey(pID)) {
medicalReports_db.put(pID, new ArrayList<MedicalReport>());
}
medicalReports_db.get(pID).add(mr);
System.out.println("\n----------------------------------------------");
System.out.println(" New Report Added Successfully");
}
public void ViewDoctorAppointments(Doctor d, Map<String, Patient> map) {
String[] sts = { "9:00 AM", "10:00 AM", "11:00 AM", "12:00 PM", "1:30 PM", "2:30 PM", "3:30 PM", "4:30 PM",
"5:30 PM" };
int i = 0;
for (String s : sts) {
String sl = d.slots.get(s);
if (!sl.equals("")) {
i++;
Patient p = map.get(sl);
System.out.println("---------------------------------------");
System.out.println("\n Patient Details and Slot\n");
System.out.println("Patietn ID : " + p.id);
System.out.println("Name : " + p.name);
System.out.println("Age : " + p.age);
System.out.println("Gender : " + p.gender);
System.out.println("Blood Group : " + p.bloodGroup);
System.out.println("Mobile Number : " + p.number);
System.out.println("Slot : " + s);
System.out.println("\n---------------------------------------");
}
}
if (i == 0)
System.out.println("\nNo Appointments till Now");
}
}
| [
"[email protected]"
] | |
2c4b6884ec875642a5c73e16568de0402be24f64 | 62ce306030e35a246d440a5ffa93c23c0df955c9 | /gateway/src/test/java/com/dai/gateway/web/rest/TestUtil.java | 1462dfbe6356a74c905539609118d471a9d8d0ca | [] | no_license | RaphaelCSSilva/prisontech | 0fca5a5284396d64de500f9b78fbcfa3a5866d83 | 2dac955c66c32528797e084b41e8d9e85d646b2a | refs/heads/master | 2022-09-30T21:42:05.975623 | 2020-06-04T10:41:12 | 2020-06-04T10:41:12 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 6,194 | java | package com.dai.gateway.web.rest;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.http.MediaType;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeParseException;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Root;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Utility class for testing REST controllers.
*/
public final class TestUtil {
private static final ObjectMapper mapper = createObjectMapper();
/**
* MediaType for JSON
*/
public static final MediaType APPLICATION_JSON = MediaType.APPLICATION_JSON;
private static ObjectMapper createObjectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false);
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);
mapper.registerModule(new JavaTimeModule());
return mapper;
}
/**
* Convert an object to JSON byte array.
*
* @param object the object to convert.
* @return the JSON byte array.
* @throws IOException
*/
public static byte[] convertObjectToJsonBytes(Object object) throws IOException {
return mapper.writeValueAsBytes(object);
}
/**
* Create a byte array with a specific size filled with specified data.
*
* @param size the size of the byte array.
* @param data the data to put in the byte array.
* @return the JSON byte array.
*/
public static byte[] createByteArray(int size, String data) {
byte[] byteArray = new byte[size];
for (int i = 0; i < size; i++) {
byteArray[i] = Byte.parseByte(data, 2);
}
return byteArray;
}
/**
* A matcher that tests that the examined string represents the same instant as the reference datetime.
*/
public static class ZonedDateTimeMatcher extends TypeSafeDiagnosingMatcher<String> {
private final ZonedDateTime date;
public ZonedDateTimeMatcher(ZonedDateTime date) {
this.date = date;
}
@Override
protected boolean matchesSafely(String item, Description mismatchDescription) {
try {
if (!date.isEqual(ZonedDateTime.parse(item))) {
mismatchDescription.appendText("was ").appendValue(item);
return false;
}
return true;
} catch (DateTimeParseException e) {
mismatchDescription.appendText("was ").appendValue(item)
.appendText(", which could not be parsed as a ZonedDateTime");
return false;
}
}
@Override
public void describeTo(Description description) {
description.appendText("a String representing the same Instant as ").appendValue(date);
}
}
/**
* Creates a matcher that matches when the examined string represents the same instant as the reference datetime.
*
* @param date the reference datetime against which the examined string is checked.
*/
public static ZonedDateTimeMatcher sameInstant(ZonedDateTime date) {
return new ZonedDateTimeMatcher(date);
}
/**
* Verifies the equals/hashcode contract on the domain object.
*/
public static <T> void equalsVerifier(Class<T> clazz) throws Exception {
T domainObject1 = clazz.getConstructor().newInstance();
assertThat(domainObject1.toString()).isNotNull();
assertThat(domainObject1).isEqualTo(domainObject1);
assertThat(domainObject1.hashCode()).isEqualTo(domainObject1.hashCode());
// Test with an instance of another class
Object testOtherObject = new Object();
assertThat(domainObject1).isNotEqualTo(testOtherObject);
assertThat(domainObject1).isNotEqualTo(null);
// Test with an instance of the same class
T domainObject2 = clazz.getConstructor().newInstance();
assertThat(domainObject1).isNotEqualTo(domainObject2);
// HashCodes are equals because the objects are not persisted yet
assertThat(domainObject1.hashCode()).isEqualTo(domainObject2.hashCode());
}
/**
* Create a {@link FormattingConversionService} which use ISO date format, instead of the localized one.
* @return the {@link FormattingConversionService}.
*/
public static FormattingConversionService createFormattingConversionService() {
DefaultFormattingConversionService dfcs = new DefaultFormattingConversionService ();
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
registrar.setUseIsoFormat(true);
registrar.registerFormatters(dfcs);
return dfcs;
}
/**
* Makes a an executes a query to the EntityManager finding all stored objects.
* @param <T> The type of objects to be searched
* @param em The instance of the EntityManager
* @param clss The class type to be searched
* @return A list of all found objects
*/
public static <T> List<T> findAll(EntityManager em, Class<T> clss) {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(clss);
Root<T> rootEntry = cq.from(clss);
CriteriaQuery<T> all = cq.select(rootEntry);
TypedQuery<T> allQuery = em.createQuery(all);
return allQuery.getResultList();
}
private TestUtil() {}
}
| [
"[email protected]"
] | |
ee6230b46835c9c1ba1375a54b52c51e6b1342a6 | 8f541c7a0688c197206a303e2c5efa995740116e | /Hello.java | 83e0d77871af094021b96d498b29dd1dc95f3f01 | [] | no_license | Biswa77/Hello_Java | 949c30069d242c3eaf5bceced8bc4aab66936e7f | 56dd5bc28dd04196d9e7c5d4cdf4f0b3bbcf34f0 | refs/heads/master | 2022-04-19T17:03:18.010759 | 2020-04-18T14:36:17 | 2020-04-18T14:36:17 | 256,775,042 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 148 | java | public class Hello{
public static void main(String[] args){
for(int i=1;i<=10;i++){
System.out.println("Hello Hello World...");
}
}
} | [
"[email protected]"
] | |
77c2419a704c5ac49e300293b04e03e1eb0fb4d9 | d96230f6665d9896dd8ef62ee8b5d86fa61ba831 | /src/test/java/org/cap/MavenProject.java | 24c992e80b0597e845bd8e088fcf48cb73d0483d | [] | no_license | Nithyasri11/SampleProject | 04120a67dae1280d9a82ad2bc881fa1d4aca4374 | 04650cf4f9fbbc23e1e8b29271c39724b410438d | refs/heads/master | 2023-01-14T01:52:15.478166 | 2020-11-19T05:52:01 | 2020-11-19T05:52:01 | 314,145,629 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 181 | java | package org.cap;
import org.base.LibGlobal;
public class MavenProject extends LibGlobal{
public static void main(String[] args) {
LibGlobal lib = new LibGlobal();
}
}
| [
"[email protected]"
] | |
9610262a2009fd58f143609257417374296bc73a | e091fceec18827458f48de5b23836c81bd0966b1 | /main/plugins/org.talend.dataquality.sampling/src/main/java/org/talend/dataquality/datamasking/Functions/ReplaceFirstCharsInteger.java | a765f475d355e674c3291c4de26dc910ab1c6865 | [
"Apache-2.0"
] | permissive | Excedis/Gravitas-DQ-Studio-se | 6a8e2313ce2d0bfbfe8471ab407df4004b2732c4 | 650fb60d8711c1ed28d3b1e80cc9458f354b9567 | refs/heads/master | 2021-01-16T22:47:46.502662 | 2015-08-14T08:12:21 | 2015-08-14T08:12:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,666 | java | // ============================================================================
//
// Copyright (C) 2006-2015 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.dataquality.datamasking.Functions;
/**
* created by jgonzalez on 22 juin 2015. See ReplaceFirstChars.
*
*/
public class ReplaceFirstCharsInteger extends ReplaceFirstChars<Integer> {
private int parameter = 0;
@Override
public Integer generateMaskedRow(Integer i) {
if (i == null && keepNull) {
return null;
} else {
if (i != null && integerParam > 0) {
if (i == 0) {
return rnd.nextInt(9);
} else {
parameter = (int) Math.log10(i) + 1 <= integerParam ? (int) Math.log10(i) + 1 : integerParam;
StringBuilder sbu = new StringBuilder(i.toString());
StringBuilder remp = new StringBuilder(EMPTY_STRING);
for (int j = 0; j < parameter; ++j) {
remp.append(rnd.nextInt(9));
}
sbu.replace(0, parameter, remp.toString());
return Integer.parseInt(sbu.toString());
}
} else {
return 0;
}
}
}
} | [
"[email protected]"
] | |
1852424468ef6aa3970aaf83e078930764d8f914 | 27739a2880bb10e87956f5fd843a6edcebcaa1a6 | /src/ThomsonSphere.java | 1416858cda3abcd8ec2a90a9eef6ff0d158f3f79 | [] | no_license | martinsbalodis/thomson-problem | e4bc83fea371deb274b4155b1b43fff8bcefe811 | b86e2e8ffb9c7050f5b806572ca749f81b15575a | refs/heads/master | 2021-01-01T18:01:57.852750 | 2012-01-21T21:06:26 | 2012-01-21T21:06:26 | 3,218,415 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,048 | java | import java.util.Arrays;
import no.geosoft.cc.geometry.Geometry;
/**
*
* @author martins
*/
public class ThomsonSphere {
public ThomsonPoint[] points;
/**
* Point point_energy
*/
public double[][] point_energy;
public double[][] point_distances;
/**
* Energy sum from a point to all other points
*/
public double[] point_energy_sums;
/**
* initialize points
* @param points
*/
public ThomsonSphere(int point_count) {
this.points = new ThomsonPoint[point_count];
this.point_energy = new double[point_count][point_count];
this.point_distances = new double[point_count][point_count];
this.point_energy_sums = new double[point_count];
// create points
for (int i = 0; i < point_count; i++) {
this.points[i] = new ThomsonPoint();
this.points[i].put_in_random_position();
}
// calculate energy between points for the first time
calculate_point_energy();
}
/**
* recalculate energy between points
*/
public void calculate_point_energy() {
// clear point energy array
Arrays.fill(this.point_energy_sums, 0);
for (int i = 0; i < this.points.length; i++) {
for (int j = i + 1; j < this.points.length; j++) {
update_point_distance(i, j);
update_point_energy(i, j);
// add energy to each point energy sum
this.point_energy_sums[i] += this.point_energy[i][j];
this.point_energy_sums[j] += this.point_energy[i][j];
}
}
}
/**
* Update distance between two points by their keys in point array
* @param id1
* @param id2
*/
public void update_point_distance(int id1, int id2) {
double distance = this.points[id1].get_distance(this.points[id2]);
this.point_distances[id1][id2] = distance;
this.point_distances[id2][id1] = distance;
}
/**
* Update point energy.
* Before updating energy you must update distance
* @param id1
* @param id2
*/
public void update_point_energy(int id1, int id2) {
double energy = 1 / this.point_distances[id1][id2];
this.point_energy[id1][id2] = energy;
this.point_energy[id2][id1] = energy;
}
/**
* Calculate spheres energy
* @return double
*/
public double get_energy() {
double energy = 0;
for (int i = 0; i < this.points.length; i++) {
for (int j = i + 1; j < this.points.length; j++) {
energy += this.point_energy[i][j];
}
}
return energy;
}
/**
* Returns point with maximum energy
* @return int
*/
public int get_maximum_energy_point() {
// first point is with maximum energy
int maximum_energy_point = 0;
for (int i = 0; i < this.points.length; i++) {
if (this.point_energy_sums[i] > this.point_energy_sums[maximum_energy_point]) {
maximum_energy_point = i;
}
}
return maximum_energy_point;
}
/**
* Find closest point to a point
* @param point_id
* @return
*/
public int find_closest_point(int point_id) {
int closest_point = -1;
for (int i = 0; i < this.points.length; i++) {
if (point_id != i && (closest_point == -1
|| this.point_distances[point_id][i] < this.point_distances[point_id][closest_point])) {
closest_point = i;
}
}
return closest_point;
}
/**
* Arrange to their correct places
*/
public void arrange_points() {
// Find point with maximum energy
int maximum_energy_point = this.get_maximum_energy_point();
// Find closest, second closest neighbour
int closest_point = find_closest_point(maximum_energy_point);
// Move p0 away. in direction max_e_p->p0
move_point(closest_point, maximum_energy_point);
}
/**
* Move point away from other point
* @param point_move
* @param point_away_from
*/
public void move_point(int point_move, int point_away_from) {
// resulting vector for first point
double[] v1 = new double[3];
// vector p1->p2
v1 = Geometry.createVector(this.points[point_away_from].point, this.points[point_move].point);
double distance_koef = 1.3;
// strech vector
v1[0] *= distance_koef;
v1[1] *= distance_koef;
v1[2] *= distance_koef;
// add resulting vector to p1
this.points[point_move].point[0] = this.points[point_away_from].point[0] + v1[0];
this.points[point_move].point[1] = this.points[point_away_from].point[1] + v1[1];
this.points[point_move].point[2] = this.points[point_away_from].point[2] + v1[2];
ThomsonPoint.normalizeVector(this.points[point_move].point);
// After point is moved we must update distances
// and enrgies from this point to other points
for (int i = 0; i < this.points.length; i++) {
if (i != point_move) {
// update distance
this.update_point_distance(i, point_move);
// remove previously added energy from energy sums
this.point_energy_sums[i] -= this.point_energy[i][point_move];
this.point_energy_sums[point_move] -= this.point_energy[i][point_move];
// update energy
this.update_point_energy(i, point_move);
// add back new energy
this.point_energy_sums[i] += this.point_energy[i][point_move];
this.point_energy_sums[point_move] += this.point_energy[i][point_move];
}
}
}
}
| [
"[email protected]"
] | |
941126b71bf31e220ac3c507ecd1a2e88fd3996c | f5b75823a768f99c971b54224b5341654fdd8010 | /device_notification_msrvc/src/main/java/ReqNResp/ResponseModel.java | 6f67f15f42c8a91dadd32beeaa82841b79b5cbcf | [] | no_license | epasham/microservice | 8de0ae7734168737440372c77130151557458996 | 6993ec20ecbaafc11d8fe3fa6080875872ad2f6c | refs/heads/master | 2020-09-21T20:05:23.357398 | 2019-07-23T02:34:22 | 2019-07-23T02:34:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 524 | java | package ReqNResp;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class ResponseModel<T> {
private response_status status;
private T result;
private String err;
public ResponseModel(response_status status,T result){
this.status = status;
this.result = result;
this.err = "";
}
public ResponseModel(response_status status,T result,String err){
this.status = status;
this.result = result;
this.err = err;
}
}
| [
"[email protected]"
] | |
de5c0e4989f1c25eb8146c091120de9ecfaf3e3a | 6edf6c315706e14dc6aef57788a2abea17da10a3 | /com/planet_ink/marble_mud/Abilities/Traps/Bomb_Poison.java | 427e91b518d624f3897a682861e07b9fa19a4906 | [] | no_license | Cocanuta/Marble | c88efd73c46bd152098f588ba1cdc123316df818 | 4306fbda39b5488dac465a221bf9d8da4cbf2235 | refs/heads/master | 2020-12-25T18:20:08.253300 | 2012-09-10T17:09:50 | 2012-09-10T17:09:50 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,628 | java | package com.planet_ink.marble_mud.Abilities.Traps;
import com.planet_ink.marble_mud.core.interfaces.*;
import com.planet_ink.marble_mud.core.*;
import com.planet_ink.marble_mud.core.collections.*;
import com.planet_ink.marble_mud.Abilities.interfaces.*;
import com.planet_ink.marble_mud.Areas.interfaces.*;
import com.planet_ink.marble_mud.Behaviors.interfaces.*;
import com.planet_ink.marble_mud.CharClasses.interfaces.*;
import com.planet_ink.marble_mud.Commands.interfaces.*;
import com.planet_ink.marble_mud.Common.interfaces.*;
import com.planet_ink.marble_mud.Exits.interfaces.*;
import com.planet_ink.marble_mud.Items.interfaces.*;
import com.planet_ink.marble_mud.Locales.interfaces.*;
import com.planet_ink.marble_mud.MOBS.interfaces.*;
import com.planet_ink.marble_mud.Races.interfaces.*;
import java.util.*;
/*
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.
*/
@SuppressWarnings({"unchecked","rawtypes"})
public class Bomb_Poison extends StdBomb
{
public String ID() { return "Bomb_Poison"; }
public String name(){ return "poison gas bomb";}
protected int trapLevel(){return 5;}
public String requiresToSet(){return "some poison";}
public List<Item> getTrapComponents() {
Vector V=new Vector();
Item I=CMLib.materials().makeItemResource(RawMaterial.RESOURCE_POISON);
Ability A=CMClass.getAbility(text());
if(A==null) A=CMClass.getAbility("Poison");
I.addNonUninvokableEffect(A);
V.addElement(I);
return V;
}
public List<Ability> returnOffensiveAffects(Physical fromMe)
{
Vector offenders=new Vector();
for(final Enumeration<Ability> a=fromMe.effects();a.hasMoreElements();)
{
final Ability A=a.nextElement();
if((A!=null)&&((A.classificationCode()&Ability.ALL_ACODES)==Ability.ACODE_POISON))
offenders.addElement(A);
}
return offenders;
}
public boolean canSetTrapOn(MOB mob, Physical P)
{
if(!super.canSetTrapOn(mob,P)) return false;
List<Ability> V=returnOffensiveAffects(P);
if((!(P instanceof Drink))||(V.size()==0))
{
if(mob!=null)
mob.tell("You need some poison to make this out of.");
return false;
}
return true;
}
public Trap setTrap(MOB mob, Physical P, int trapBonus, int qualifyingClassLevel, boolean perm)
{
if(P==null) return null;
List<Ability> V=returnOffensiveAffects(P);
if(V.size()>0)
setMiscText(((Ability)V.get(0)).ID());
return super.setTrap(mob,P,trapBonus,qualifyingClassLevel,perm);
}
public void spring(MOB target)
{
if(target.location()!=null)
{
if((!invoker().mayIFight(target))
||(isLocalExempt(target))
||(invoker().getGroupMembers(new HashSet<MOB>()).contains(target))
||(target==invoker())
||(doesSaveVsTraps(target)))
target.location().show(target,null,null,CMMsg.MASK_ALWAYS|CMMsg.MSG_NOISE,"<S-NAME> avoid(s) the poison gas!");
else
if(target.location().show(invoker(),target,this,CMMsg.MASK_ALWAYS|CMMsg.MSG_NOISE,affected.name()+" spews poison gas all over <T-NAME>!"))
{
super.spring(target);
Ability A=CMClass.getAbility(text());
if(A==null) A=CMClass.getAbility("Poison");
if(A!=null) A.invoke(invoker(),target,true,0);
}
}
}
}
| [
"[email protected]"
] | |
a459967df90a488cfdd0fe4beddd4a11a7e2a3cf | 6e10dc75f1fb1c08c5c69355b9335abd21e93662 | /refrences/dex2jar.src/rx/internal/operators/OnSubscribeFromCallable.java | f9517312f33d87600b23ab64e43513a0f91d6577 | [] | no_license | heiliuer/XiaomiCard | d61e35a17c8e80e4dfaa8dfeeecb6d58906a2614 | 012a496a306469fec31dcd18cecef7bdb8dc9cc9 | refs/heads/master | 2020-05-30T19:10:49.072231 | 2017-05-10T04:14:47 | 2017-05-10T04:14:47 | 69,148,258 | 9 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,161 | java | package rx.internal.operators;
import java.util.concurrent.Callable;
import rx.Observable.OnSubscribe;
import rx.Subscriber;
import rx.exceptions.Exceptions;
import rx.internal.producers.SingleDelayedProducer;
public final class OnSubscribeFromCallable<T>
implements Observable.OnSubscribe<T>
{
private final Callable<? extends T> resultFactory;
public OnSubscribeFromCallable(Callable<? extends T> paramCallable)
{
this.resultFactory = paramCallable;
}
public void call(Subscriber<? super T> paramSubscriber)
{
SingleDelayedProducer localSingleDelayedProducer = new SingleDelayedProducer(paramSubscriber);
paramSubscriber.setProducer(localSingleDelayedProducer);
try
{
localSingleDelayedProducer.setValue(this.resultFactory.call());
return;
}
catch (Throwable localThrowable)
{
while (true)
{
Exceptions.throwIfFatal(localThrowable);
paramSubscriber.onError(localThrowable);
}
}
}
}
/* Location: d:\Users\Administrator\Desktop\111111_dex2jar.jar
* Qualified Name: rx.internal.operators.OnSubscribeFromCallable
* JD-Core Version: 0.6.0
*/ | [
"eee"
] | eee |
98483ae19a90682661ebe46553617b9f83916c18 | 0933c546e39e4069acc6d427d0ffea4fc710bfc7 | /src/main/java/onlineShop/controller/OrderController.java | 84cb0449779f949c63340652b2d03e53411acfe9 | [] | no_license | krischa90/onlineShop | 131c88e1705d3ba736d17a89c3b51c48ae363000 | eb2b1def256fafdbd552db973a9dca8ddc45e8ad | refs/heads/master | 2023-04-04T14:23:38.186625 | 2021-04-01T21:02:46 | 2021-04-01T21:02:46 | 345,241,558 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 519 | java | package onlineShop.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@Controller
public class OrderController {
@RequestMapping(value = "/order/{cartId}", method = RequestMethod.GET)
public String createOrder(@PathVariable("cartId") int cartId) {
return "redirect:/checkout?cartId=" + cartId;
}
}
| [
"[email protected]"
] | |
db06c4191ca58c1fe0354ddc85e9c6d980bf677d | 94ba421967f27f450aa9138e6f9ca90f16dab97f | /app/src/androidTest/java/com/example/softxperttask/ExampleInstrumentedTest.java | 7d79cc75407676b0a1b88780600695e4f494cbdc | [] | no_license | MnemElmorshidy/SoftxpertTask | 3372ef1428b02131434cecb7f6c3323120a22e1d | d5398a942b315ae76259030211c6c38eadf94b1a | refs/heads/master | 2023-05-31T04:58:25.466292 | 2021-06-21T22:14:04 | 2021-06-21T22:14:04 | 379,076,379 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | package com.example.softxperttask;
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("com.example.softxperttask", appContext.getPackageName());
}
} | [
"[email protected]"
] | |
c4eb86cc96d45bbbc8d760a08581047d16be169a | b5b66198f33c2ce442049d26feecca4d5d3f77c5 | /database-examples/jdbc-example/src/main/java/com/globomantics/jdbcexample/config/JdbcOutboundConfig.java | 16b6cc9410093176a193a51b376427ac09a01163 | [] | no_license | pfcit/channeladapters | 3a3b9eff2317bc782de0118c967d4f44e16754d8 | 6ce5c7e609721d14f506e3d43f5cb4b2098386fd | refs/heads/master | 2022-12-19T20:14:09.981801 | 2020-10-17T03:15:20 | 2020-10-17T03:15:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,616 | java | package com.globomantics.jdbcexample.config;
import com.globomantics.jdbcexample.model.Reservation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.annotation.MessagingGateway;
import org.springframework.integration.annotation.ServiceActivator;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.jdbc.JdbcMessageHandler;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.MessageHandler;
import javax.sql.DataSource;
@Configuration
public class JdbcOutboundConfig {
@Bean
public MessageChannel createReservationChannel() {
return new DirectChannel();
}
@Bean
@ServiceActivator(inputChannel = "createReservationChannel")
public MessageHandler jdbcReservationMessageHandler(DataSource dataSource) {
JdbcMessageHandler jdbcMessageHandler = new JdbcMessageHandler(dataSource,
"INSERT INTO reservation (id, name, status) VALUES (?, ?, 0)");
jdbcMessageHandler.setPreparedStatementSetter((ps, message) -> {
Reservation reservation = (Reservation) message.getPayload();
ps.setLong(1, reservation.getId());
ps.setString(2, reservation.getName());
});
return jdbcMessageHandler;
}
@MessagingGateway(defaultRequestChannel = "createReservationChannel")
public interface CreateReservationGateway {
void createReservation(Reservation reservation);
}
}
| [
"[email protected]"
] | |
2d197981f99fa57d4cdf5eb2cf053cb2492ee4c3 | 4520c9213c4ac4ca28e30c10e862c96461384396 | /hutool-core/src/main/java/com/xiaoleilu/hutool/io/resource/ResourceUtil.java | 7c340e5eeb4c8daa1d5dfd1adf5c9c3ee5610be1 | [
"Apache-2.0"
] | permissive | pigsoft2016/hutool | ec54e43c11f7cbd1709d542bb973193e46ec558c | c7877d83a34e31b9b71f567e92b2cfbf1371b725 | refs/heads/master | 2020-03-22T19:16:57.753436 | 2018-08-27T13:34:18 | 2018-08-27T13:34:18 | 140,518,070 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,325 | java | package com.xiaoleilu.hutool.io.resource;
import java.io.IOException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.Enumeration;
import java.util.List;
import com.xiaoleilu.hutool.io.IORuntimeException;
import com.xiaoleilu.hutool.util.ClassLoaderUtil;
import com.xiaoleilu.hutool.util.CollectionUtil;
/**
* ClassPath资源工具类
* @author Looly
*
*/
public class ResourceUtil {
/**
* 读取Classpath下的资源为字符串,使用UTF-8编码
* @param resource 资源路径,使用相对ClassPath的路径
* @return 资源内容
* @since 3.1.1
*/
public static String readUtf8Str(String resource) {
return new ClassPathResource(resource).readUtf8Str();
}
/**
* 读取Classpath下的资源为字符串
* @param resource 资源路径,使用相对ClassPath的路径
* @param charset 编码
* @return 资源内容
* @since 3.1.1
*/
public static String readStr(String resource, Charset charset) {
return new ClassPathResource(resource).readStr(charset);
}
/**
* 获得资源的URL<br>
* 路径用/分隔,例如:
* <pre>
* config/a/db.config
* spring/xml/test.xml
* </pre>
*
* @param resource 资源(相对Classpath的路径)
* @return 资源URL
*/
public static URL getResource(String resource) throws IORuntimeException{
return getResource(resource, null);
}
/**
* 获取指定路径下的资源列表<br>
* 路径格式必须为目录格式,用/分隔,例如:
* <pre>
* config/a
* spring/xml
* </pre>
*
* @param resource 资源路径
* @return 资源列表
*/
public static List<URL> getResources(String resource){
final Enumeration<URL> resources;
try {
resources = ClassLoaderUtil.getClassLoader().getResources(resource);
} catch (IOException e) {
throw new IORuntimeException(e);
}
return CollectionUtil.newArrayList(resources);
}
/**
* 获得资源相对路径对应的URL
* @param resource 资源相对路径
* @param baseClass 基准Class,获得的相对路径相对于此Class所在路径,如果为{@code null}则相对ClassPath
* @return {@link URL}
*/
public static URL getResource(String resource, Class<?> baseClass){
return (null != baseClass) ? baseClass.getResource(resource) : ClassLoaderUtil.getClassLoader().getResource(resource);
}
}
| [
"[email protected]"
] | |
fcab87fdc02bc3557973cd1a76200b98741a5e13 | 2779c5e11ab438fd0a9c7f2ab6113d0d558d391c | /core/src/com/leaptechjsc/anakachyofthe12warlords/model/magic/MagicData.java | d74af25ab4e64d4109e1782c34dd486d82514f02 | [] | no_license | ping203/BaoVeBienCuong | 64f0b2779ac8253fe69392ebb5902f2599089282 | a91a0e8728b27c770b42cf9eefd9ac3dd99a3d63 | refs/heads/master | 2020-04-22T20:46:25.071139 | 2018-10-04T02:42:55 | 2018-10-04T02:42:55 | 170,651,642 | 0 | 1 | null | 2019-02-14T08:02:35 | 2019-02-14T08:02:34 | null | UTF-8 | Java | false | false | 4,069 | java | package com.leaptechjsc.anakachyofthe12warlords.model.magic;
import java.util.ArrayList;
import com.leaptechjsc.anakachyofthe12warlords.controller.data.EffectData;
import com.leaptechjsc.anakachyofthe12warlords.model.scenario.Scenario;
import com.leaptechjsc.anakachyofthe12warlords.controller.data.EffectData;
import com.leaptechjsc.anakachyofthe12warlords.model.map.Coordinate;
import com.leaptechjsc.anakachyofthe12warlords.model.scenario.Scenario;
public abstract class MagicData {
protected int damage;
protected int areaOfEffect;
protected float castTime;
protected float duration;
protected float cooldownTime;
protected float damageSpeed;
//
protected float stateTime;
protected float startTime;
protected float controlStartTime;
protected int state;
protected float lastDamageTime;
//
public static ArrayList<EffectData> effectList;
public MagicData(EnumMagicList magic, int level) {
this.damage = magic.getDamage();
this.areaOfEffect = magic.getAreaOfEffect();
this.castTime = magic.getCastTime();
this.duration = magic.getDuration();
this.cooldownTime = magic.getCooldownTime();
this.damageSpeed = magic.getDamageSpeed();
this.startTime = cooldownTime;
this.lastDamageTime = 0;
this.stateTime = 0;
this.state = IMagicContants.WAITING;
this.controlStartTime = 0;
effectList = new ArrayList<EffectData>();
configData(level);
}
public int getDamage() {
return damage;
}
public void setDamage(int damage) {
this.damage = damage;
}
public int getAreaOfEffect() {
return areaOfEffect;
}
public void setAreaOfEffect(int areaOfEffect) {
this.areaOfEffect = areaOfEffect;
}
public float getCastTime() {
return castTime;
}
public void setCastTime(float castTime) {
this.castTime = castTime;
}
public float getDuration() {
return duration;
}
public void setDuration(float duration) {
this.duration = duration;
}
public float getCooldownPercent() {
if (startTime >= cooldownTime) {
return 1;
} else {
return startTime / cooldownTime;
}
}
public float getCooldownTime() {
return cooldownTime;
}
public void setCooldownTime(float cooldownTime) {
this.cooldownTime = cooldownTime;
}
public float getStateTime() {
return stateTime;
}
public void setStateTime(float stateTime) {
this.stateTime = stateTime;
}
public float getControlStartTime() {
return controlStartTime;
}
public void setControlStartTime(float controlStartTime) {
this.controlStartTime = controlStartTime;
}
public float getLastDamageTime() {
return lastDamageTime;
}
public void setLastDamageTime(float lastDamageTime) {
this.lastDamageTime = lastDamageTime;
}
public float getDamageSpeed() {
return damageSpeed;
}
public boolean isEndOfReloadTime() {
float reloadTime = 1f / damageSpeed;
if ((stateTime - lastDamageTime) < reloadTime) {
return false;
} else {
return true;
}
}
public void setDamageSpeed(float damageSpeed) {
this.damageSpeed = damageSpeed;
}
public float getStartTime() {
return startTime;
}
public void setStartTime(float startTime) {
this.startTime = startTime;
}
public void update(float delta, Scenario scenario) {
if (this.state == IMagicContants.CASTING) {
this.controlStartTime += delta;
if (this.controlStartTime > castTime) {
this.state = IMagicContants.ACTIVATING;
this.controlStartTime = 0;
}
} else if (this.state == IMagicContants.ACTIVATING) {
this.controlStartTime += delta;
if (this.controlStartTime > duration) {
this.state = IMagicContants.WAITING;
this.controlStartTime = 0;
}
}
this.startTime += delta;
this.stateTime += delta;
}
public abstract void configData(int level);
public abstract void act(Scenario scenario, Coordinate coor);
public abstract void use(Scenario scenario, Coordinate castPosition);
public abstract ArrayList<MagicObject> getMagicList();
} | [
"[email protected]"
] | |
64e50ff7431f5238960adace353a1ebed6b79555 | 80c58789dad840c0ecf5d12cf125edba6eec1cd8 | /src/main/java/com/sebas/service/impl/HabilidadServiceImpl.java | 25c7c2dbdb58088a3264c9bd69c6cbb18a4fcc74 | [] | no_license | Sebas-Villacis/SpringMicro | eb3af9058a2b280427f2aeb3d0b366348fda3326 | ee6fb2ad8da35d354ce4868981e11b5afc692ea2 | refs/heads/master | 2022-12-09T11:19:09.549810 | 2020-09-24T16:34:16 | 2020-09-24T16:39:50 | 295,803,721 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 908 | java | package com.sebas.service.impl;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sebas.dao.IHabilidadDAO;
import com.sebas.model.Habilidad;
import com.sebas.service.IHabilidadService;
@Service
public class HabilidadServiceImpl implements IHabilidadService{
@Autowired
private IHabilidadDAO dao;
@Override
public List<Habilidad> findAll() {
return dao.findAll();
}
@Override
public Habilidad create(Habilidad obj) {
return dao.save(obj);
}
@Override
public Habilidad find(Integer id) {
return dao.findOne(id);
}
@Override
public Habilidad update(Habilidad obj) {
return dao.save(obj);
}
@Override
public void delete(Integer id) {
dao.delete(id);
}
@Override
public List<Habilidad> getHabilidadByPersonaId(Integer id) {
return dao.getHabilidadByPersonaId(id);
}
}
| [
"[email protected]"
] | |
b563b485b5ba14cac851b83543dcaeec7006dfd3 | 65d3f0e55e26c560403e59c7b4b3a314311f8a1d | /src/main/java/observer/homework/weather/WeatherForecast.java | 3f04f4688f928dc46842af64490d42b4cd138d17 | [] | no_license | Cekus-K/design-patterns | 6be79a40371cc999e17a303b26f082f41e809f7f | 9a81c5c0fd02552b6f77d36d97add9cfb3a9d367 | refs/heads/master | 2022-11-25T01:16:53.729662 | 2020-07-23T20:16:22 | 2020-07-23T20:16:22 | 279,932,041 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,315 | java | package observer.homework.weather;
import observer.homework.notification.Observer;
import java.util.HashSet;
import java.util.Set;
public class WeatherForecast implements Observable {
private int temperature;
private int pressure;
private Set<Observer> registeredObservers = new HashSet<>();
public WeatherForecast(int temperature, int pressure) {
this.temperature = temperature;
this.pressure = pressure;
}
@Override
public void registerObserver(Observer observer) {
this.registeredObservers.add(observer);
}
@Override
public void unregisterObserver(Observer observer) {
this.registeredObservers.remove(observer);
}
@Override
public void notifyObservers() {
this.registeredObservers.forEach(observer -> observer.updateForecast(this));
}
public void changeWeather(int temperature, int pressure) {
this.temperature = temperature;
this.pressure = pressure;
notifyObservers();
}
public int getTemperature() {
return temperature;
}
void setTemperature(int temperature) {
this.temperature = temperature;
}
public int getPressure() {
return pressure;
}
void setPressure(int pressure) {
this.pressure = pressure;
}
}
| [
"[email protected]"
] | |
2109eb3bdda38dcfb6b7c337402037204931ab22 | c3a043fc8c8c3e7abafc3b7a8614a983b82d1053 | /src/server/generated/Bank/PersonalDataHolder.java | 4d4adc199678a41f424cbb0f5ac8e64416b0c20c | [] | no_license | norbert108/ajs | 4d7e333cd48a25f39dce76c678972a7a99e50ffb | 41da7b38ecf53bc70801529e68868a80f3e250fe | refs/heads/master | 2020-12-30T10:50:13.467728 | 2015-05-18T20:38:53 | 2015-05-18T20:38:53 | 35,809,689 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 739 | java | // **********************************************************************
//
// Copyright (c) 2003-2013 ZeroC, Inc. All rights reserved.
//
// This copy of Ice is licensed to you under the terms described in the
// ICE_LICENSE file included in this distribution.
//
// **********************************************************************
//
// Ice version 3.5.1
//
// <auto-generated>
//
// Generated from file `Bank.ice'
//
// Warning: do not edit this file.
//
// </auto-generated>
//
package server.generated.Bank;
public final class PersonalDataHolder
{
public
PersonalDataHolder()
{
}
public
PersonalDataHolder(PersonalData value)
{
this.value = value;
}
public PersonalData value;
}
| [
"[email protected]"
] | |
9e8e31945c989811031665b5a3617c069a1fe98c | a2513c67e5f8168faaae8c41243203e90a9835c2 | /src/main/java/top/longmarch/wx/service/IWxGzhApiService.java | 85eda78058adf44c830c9cca6ca7ab969d3022e3 | [] | no_license | 851874960/longmarch | b8106880a4302290b5fc234e7c5b1b3e47f75909 | 17b70466bbed923c361d018bf9d764a94569d25a | refs/heads/master | 2023-01-25T00:28:19.983898 | 2020-11-30T14:27:20 | 2020-11-30T14:27:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package top.longmarch.wx.service;
import top.longmarch.wx.entity.GzhAccount;
public interface IWxGzhApiService {
void tagAnalysis(GzhAccount gzhAccount, String lock);
void tagRemove(GzhAccount gzhAccount, String lock);
}
| [
"[email protected]"
] | |
230847c4b83e3041ec75ae657da658c5409fd8c9 | d758a582e91b5d083c725558d18a6f6ae1c23452 | /GargPagina15Exercicio2/src/Main.java | eeeddcff773012df959e0849e3191c75aa534cd5 | [] | no_license | Edd002/Desenvolvimento-de-Sistemas-Distribuidos-workspace | 5da4f3b67a1496411b580d42e65537252589e669 | 08b3b693186562e74a4926f7f66bcb03bca6e732 | refs/heads/master | 2022-11-08T20:54:24.943803 | 2020-06-28T23:30:33 | 2020-06-28T23:30:33 | 271,330,487 | 0 | 0 | null | null | null | null | ISO-8859-1 | Java | false | false | 2,090 | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Main {
public static void main(String[] args) {
int[] integerArray = generateArray(1000);
int elementPos = parallelSearch(750, integerArray, 10);
System.out.println("Array: " + Arrays.toString(integerArray));
System.out.println("Posição do elemento (-1 se não encontrado): " + elementPos);
}
private static int[] generateArray(int tam) {
int[] integerArray = new int[tam];
for (int i = 0; i < tam; i++)
integerArray[i] = i;
return integerArray;
}
public static int parallelSearch(int x, int[] A, int numThreads) {
List<Search> listSearchThread = new ArrayList<Search>();
int tamInterval = A.length / numThreads;
int leftLim = 0;
int rightLim = tamInterval;
// Criação das threads (quantidade definida pelo usuário) para pesquisar o elemento colocando todas em um array para uma controlar a outra (mandar parar caso ache)
for (int i = 0; i < numThreads; i++)
listSearchThread.add(new Search(x));
// Iniciar todas as threads com uma parte do array para cada
for (Search searchThread : listSearchThread) {
//System.out.println("L: " + leftLim);
//System.out.println("R: " + rightLim);
int[] ASplitted = Arrays.copyOfRange(A, leftLim, rightLim); // Dividir o array
searchThread.setASplitted(ASplitted); // Parte do array para procurar o elemento
searchThread.setListSearchThread(listSearchThread); // Array contendo todas as threads para uma controlar a outra
searchThread.start();
leftLim = rightLim;
rightLim += tamInterval;
}
// Aguardar o resultado ser retornado por uma das threads
for (Search searchThread : listSearchThread) {
try {
searchThread.join();
} catch (InterruptedException interruptedException) { }
}
// Verificar se alguma das threads encontrou o elemento
int contThread = 0;
for (Search searchThread : listSearchThread) {
if (searchThread.getFindedIndex() >= 0)
return searchThread.getFindedIndex() + (tamInterval * contThread);
contThread++;
}
return -1;
}
} | [
"[email protected]"
] | |
cb151b015d2df22c8045715fcc9be0bace119dd0 | 523b1f8646c15cb02cca7668ababd9dc54308b22 | /Listas/Lista4/Lista4exercicio6/src/main/LogSingleton.java | 501d21c7c1ed3268459b6e12347471546b79ddb3 | [
"MIT"
] | permissive | joaopedronardari/COO-EACHUSP | 13d274d5893647c62dd358a6a059bd4661a2b02a | ea243117598003ba5e46e532e6ccc6bcf99a49db | refs/heads/master | 2021-01-20T05:52:25.926718 | 2014-07-28T04:12:51 | 2014-07-28T04:12:51 | 20,363,811 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 605 | java | package main;
import java.io.FileWriter;
import java.io.IOException;
public class LogSingleton {
private static LogSingleton instance;
private LogSingleton() {
}
public static synchronized LogSingleton getInstance() {
if (instance == null)
instance = new LogSingleton();
return instance;
}
public void logLine(String tag, String text) {
String logLine = "LogLine-> " + tag + ": " + text + "\n";
try {
FileWriter fw = new FileWriter("log.txt");
fw.append(logLine);
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
System.out.println(logLine);
}
}
| [
"[email protected]"
] | |
42c12d6df2e16002fde1daf633b8e554ecec0813 | 8b688991040e5bf56f7079f80fac9a383274876f | /src/main/java/com/beyondbanking/ssh/flightoffers/model/response/City___.java | 844e6f26dd0a8890770e31e59695d5162d44181b | [] | no_license | arani87/flightoffers | c33784fdaf24486f45dbdb328a8bcd2a4323fbe4 | ef71ef4095fe416a6506189280cc40ff7f2aa196 | refs/heads/master | 2020-03-19T10:23:48.026375 | 2018-06-07T17:13:41 | 2018-06-07T17:13:41 | 136,366,418 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,395 | java |
package com.beyondbanking.ssh.flightoffers.model.response;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonPropertyOrder({
"name",
"code"
})
public class City___ {
@JsonProperty("name")
private String name;
@JsonProperty("code")
private String code;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
@JsonProperty("name")
public String getName() {
return name;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("code")
public String getCode() {
return code;
}
@JsonProperty("code")
public void setCode(String code) {
this.code = code;
}
@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
}
@JsonAnySetter
public void setAdditionalProperty(String name, Object value) {
this.additionalProperties.put(name, value);
}
}
| [
"[email protected]"
] | |
d3f73234346b377668c0582db49a8e8f15820fbf | 713725ed687c3947385204ba554516a540a9f107 | /src/main/java/com/cergenerator/service/helper/CertificateUtils.java | d9e7cda467b3d7699534f5f876eb473a934667b1 | [] | no_license | guymoyo/cert-generator | c34b3f859b48c4bde90c7755b780b8b8cc3c50dc | c4d1570d66dd58496e1f7f0a144dec4bd2a12247 | refs/heads/master | 2020-04-01T01:11:36.558877 | 2018-10-12T10:09:24 | 2018-10-12T10:09:24 | 152,729,611 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,520 | java | package com.cergenerator.service.helper;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.Security;
import java.security.cert.X509Certificate;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
import org.apache.commons.io.IOUtils;
import org.bouncycastle.jce.provider.BouncyCastleProvider;
import org.bouncycastle.openssl.PEMKeyPair;
import org.bouncycastle.openssl.PEMParser;
import org.bouncycastle.openssl.jcajce.JcaPEMKeyConverter;
import com.nimbusds.jose.util.X509CertUtils;
public class CertificateUtils {
public static String getCertificateByName(String filename) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream is = loader.getResourceAsStream("certificates/" + filename);
if (is != null) {
try {
byte[] bytes = IOUtils.toByteArray(is);
X509Certificate cert = X509CertUtils.parse(bytes);
String encodeCert = X509CertUtils.toPEMString(cert);
return encodeCert;
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
public static X509Certificate getCertificate(String filename) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream is = loader.getResourceAsStream("certificates/" + filename);
if (is != null) {
try {
byte[] bytes = IOUtils.toByteArray(is);
X509Certificate cert = X509CertUtils.parse(bytes);
return cert;
} catch (IOException e) {
e.printStackTrace();
}
}
return null;
}
public static PrivateKey getKeyFromFile(String keyPath) {
ClassLoader loader = Thread.currentThread().getContextClassLoader();
InputStream stream = loader.getResourceAsStream("certificates/" + keyPath);
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
try {
Security.addProvider(new BouncyCastleProvider());
PEMParser pp = new PEMParser(br);
PEMKeyPair pemKeyPair = (PEMKeyPair) pp.readObject();
KeyPair kp = new JcaPEMKeyConverter().getKeyPair(pemKeyPair);
pp.close();
return kp.getPrivate();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
/*public static PrivateKey convert2(String privateKey){
InputStream stream = new ByteArrayInputStream(privateKey.getBytes());
BufferedReader br = new BufferedReader(new InputStreamReader(stream));
String temp = null;
try {
while((temp = br.readLine()) != null){
System.out.println(temp);
}
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try {
Security.addProvider(new BouncyCastleProvider());
PEMParser pp = new PEMParser(br);
System.out.println(pp.toString());
PEMKeyPair pemKeyPair = (PEMKeyPair) pp.readObject();
KeyPair kp = new JcaPEMKeyConverter().getKeyPair(pemKeyPair);
pp.close();
return kp.getPrivate();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
*/
public static PrivateKey convertStr2PrivateKey(String privateKey) {
Security.addProvider(new BouncyCastleProvider());
KeyFactory factory = null;
PrivateKey key = null;
byte[] privateKeyFileBytes = privateKey.getBytes();
String KeyString = new String(privateKeyFileBytes);
KeyString = KeyString.replaceAll("-----BEGIN RSA PRIVATE KEY-----", "");
KeyString = KeyString.replaceAll("-----END RSA PRIVATE KEY-----", "");
KeyString = KeyString.replaceAll("[\n\r]", "");
KeyString = KeyString.trim();
byte[] encoded = Base64.getDecoder().decode(KeyString);
PKCS8EncodedKeySpec keySpec = new PKCS8EncodedKeySpec(encoded);
try {
factory = KeyFactory.getInstance("RSA");
key = factory.generatePrivate(keySpec);
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidKeySpecException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return key;
}
}
| [
"[email protected]"
] | |
a5516601b05119d130e950e4237375e1394d9d84 | d4e4f828a79b4877ffa9b76455770fb5c94f6883 | /client/am/console/src/main/java/org/apache/syncope/client/console/pages/SRA.java | bf21b023b1d86d716fef4eb4a8fa7c3aa02c811e | [
"Apache-2.0"
] | permissive | aalzehla/syncope | d8b74a35df013585fa9598bc39fcce75b79ec19f | 278216e8b102d6accb5343c08d882d6f175374fa | refs/heads/master | 2022-11-24T22:41:14.474597 | 2020-07-16T08:47:58 | 2020-07-16T08:47:58 | 280,235,265 | 1 | 0 | Apache-2.0 | 2020-07-16T19:01:46 | 2020-07-16T19:01:46 | null | UTF-8 | Java | false | false | 3,113 | java | /*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.syncope.client.console.pages;
import de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel;
import java.util.ArrayList;
import java.util.List;
import org.apache.syncope.client.console.BookmarkablePageLinkBuilder;
import org.apache.syncope.client.console.annotations.AMPage;
import org.apache.syncope.client.console.panels.SRARouteDirectoryPanel;
import org.apache.syncope.client.ui.commons.markup.html.form.AjaxTextFieldPanel;
import org.apache.wicket.extensions.markup.html.tabs.AbstractTab;
import org.apache.wicket.extensions.markup.html.tabs.ITab;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
@AMPage(label = "SRA", icon = "fas fa-share-alt", listEntitlement = "", priority = 0)
public class SRA extends BasePage {
private static final long serialVersionUID = 9200112197134882164L;
public SRA(final PageParameters parameters) {
super(parameters);
body.add(BookmarkablePageLinkBuilder.build("dashboard", "dashboardBr", Dashboard.class));
WebMarkupContainer content = new WebMarkupContainer("content");
content.setOutputMarkupId(true);
AjaxBootstrapTabbedPanel<ITab> tabbedPanel = new AjaxBootstrapTabbedPanel<>("tabbedPanel", buildTabList());
content.add(tabbedPanel);
body.add(content);
}
private List<ITab> buildTabList() {
List<ITab> tabs = new ArrayList<>(2);
tabs.add(new AbstractTab(new ResourceModel("routes")) {
private static final long serialVersionUID = 5211692813425391144L;
@Override
public Panel getPanel(final String panelId) {
return new SRARouteDirectoryPanel(panelId, getPageReference());
}
});
tabs.add(new AbstractTab(new ResourceModel("metrics")) {
private static final long serialVersionUID = 5211692813425391144L;
@Override
public Panel getPanel(final String panelId) {
return new AjaxTextFieldPanel(panelId, panelId, Model.of(""));
}
});
return tabs;
}
}
| [
"[email protected]"
] | |
9ddfa261bd62f238d8f579d684bfc4a4a49caa5e | 4e3d6d487fdccf7fa6dda534dcaf8bed6e84d26b | /src/main/java/com/neo/rabbit/test/Producer.java | 2e3600e75001333c7485b57555b2ac13bc61c49f | [] | no_license | 15234894457/gradleRabitmq | ea3f36c3d4d3f90aac45b42c808310ce6eed137c | 25598b604c9f664ab8f7c072e0f0f58491f438e7 | refs/heads/master | 2020-04-19T09:28:26.738157 | 2019-06-30T06:53:26 | 2019-06-30T06:53:26 | 168,112,274 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,678 | java | package com.neo.rabbit.test;
import java.io.IOException;
import com.rabbitmq.client.BlockedListener;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.MessageProperties;
import com.rabbitmq.client.ShutdownListener;
import com.rabbitmq.client.ShutdownSignalException;
import com.rabbitmq.client.impl.AMQCommand;
import com.rabbitmq.client.impl.AMQImpl;
public class Producer {
//交换机命名规范:e_模块_其他
private static final String EXCHANGE_NAME = "e_tyb_test";
//routingkey命名规范:r_模块_其他
private static final String ROUTING_KEY = "r_tyb_test";
public static void main(String[] argv) throws Exception {
//注意:factory应为单例,不要每次取消息新建一次对象
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("127.0.0.1");
factory.setPort(5672);// 默认端口
factory.setUsername("guest");// 默认用户名
factory.setPassword("guest");// 默认密码
factory.setVirtualHost("/");// 默认虚拟主机,区分权限
// 设置心跳时间,防止长时间未活动被防火墙杀死,默认600秒,单位:秒
// factory.setRequestedHeartbeat(60*4);
//连接超时时间,单位:毫秒
// factory.setConnectionTimeout(1000*2);
//注意:connection应为单例,不要每次取消息新建一次对象
Connection connection = factory.newConnection();
//监听connection关闭异常
connection.addShutdownListener(new ShutdownListener() {
@Override
public void shutdownCompleted(ShutdownSignalException cause) {
//connection异常
if (cause.isHardError()) {
System.out.println("connection异常:[" + cause.getMessage() + "]");
//程序引起的异常,如:connection.close()
if (cause.isInitiatedByApplication()) {
System.out.println("connection关闭异常,重连...begin...");
// connection = factory.newConnection();
System.out.println("connection关闭异常,重连...end...");
}else{//rabbitmq服务引起的异常
AMQCommand amqCommand = (AMQCommand)cause.getReason();
if( amqCommand.getMethod() instanceof AMQImpl.Connection.Close ){
AMQImpl.Connection.Close close = (AMQImpl.Connection.Close)amqCommand.getMethod();
if( 320==close.getReplyCode() ){//rabbitmq服务器强制关闭
System.out.println("connection关闭异常,请检查rabbitmq服务器是否正常启动!");
}
}
}
}
}
});
//监听connection阻塞异常
connection.addBlockedListener(new BlockedListener() {
@Override
public void handleUnblocked() throws IOException {
System.out.println("connection已解除阻塞!");
}
@Override
public void handleBlocked(String reason) throws IOException {
System.out.println("connection阻塞原因:["+reason+"],请检查内存是否够!");
}
});
//注意:channel应为单例,不要每次取消息新建一次对象
Channel channel = connection.createChannel();
//监听channel关闭异常
channel.addShutdownListener(new ShutdownListener() {
@Override
public void shutdownCompleted(ShutdownSignalException cause) {
//channel异常
if (!cause.isHardError()) {
System.out.println("channel异常:[" + cause.getMessage() + "]");
}
}
});
/**
* 创建交换机
* exchange 交换机名
* type 交换机类型 fanout:广播模式,所有消费者都能收到生产者发送的消息,速度更快,不需设置routingkey
* direct:只有与routingkey配置的消费者才能收到消息
* topic:与direct相同,只是支持模糊配置,类似正则表达式,功能更强,
* *表示通配一个词,#表示通配0个或多个词(注意:是词,不是字母)
*
* durable durable=true,交换机持久化,rabbitmq服务重启交换机依然存在,保证不丢失;
* durable=false,相反
*
*/
channel.exchangeDeclare(EXCHANGE_NAME, "direct",true);
//模拟发送消息
for (int i = 0; i < 100; i++) {
String message = "Hello World!";
message += i;
/**
* exchange 交换机名, ""为默认交换机,direct类型
* routingKey exchange为direct、topic类型时指定routingKey,exchange为fanout类型时指定queueName队列名
* props MessageProperties.PERSISTENT_TEXT_PLAIN:消息持久化,rabbitmq服务重启消息不会丢失;null:非持久化
* body 发送消息
*/
channel.basicPublish(EXCHANGE_NAME, ROUTING_KEY, MessageProperties.PERSISTENT_TEXT_PLAIN, message.getBytes());
System.out.println(" [x] Sent '" + message + "'");
}
//关闭连接
// channel.close();
// connection.close();
}
}
| [
"[email protected]"
] | |
d5ba1bc53446ab77a893eda1ee2946a6383c41dc | 4b0bf4787e89bcae7e4759bde6d7f3ab2c81f849 | /aliyun-java-sdk-cassandra/src/main/java/com/aliyuncs/cassandra/model/v20190101/ModifyClusterRequest.java | fe4369a977d7641ef456bd29fa8169f5beb53c2d | [
"Apache-2.0"
] | permissive | aliyun/aliyun-openapi-java-sdk | a263fa08e261f12d45586d1b3ad8a6609bba0e91 | e19239808ad2298d32dda77db29a6d809e4f7add | refs/heads/master | 2023-09-03T12:28:09.765286 | 2023-09-01T09:03:00 | 2023-09-01T09:03:00 | 39,555,898 | 1,542 | 1,317 | NOASSERTION | 2023-09-14T07:27:05 | 2015-07-23T08:41:13 | Java | UTF-8 | Java | false | false | 1,888 | java | /*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.aliyuncs.cassandra.model.v20190101;
import com.aliyuncs.RpcAcsRequest;
import com.aliyuncs.http.MethodType;
import com.aliyuncs.cassandra.Endpoint;
/**
* @author auto create
* @version
*/
public class ModifyClusterRequest extends RpcAcsRequest<ModifyClusterResponse> {
private String clusterName;
private String clusterId;
public ModifyClusterRequest() {
super("Cassandra", "2019-01-01", "ModifyCluster", "Cassandra");
setMethod(MethodType.POST);
try {
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointMap").set(this, Endpoint.endpointMap);
com.aliyuncs.AcsRequest.class.getDeclaredField("productEndpointRegional").set(this, Endpoint.endpointRegionalType);
} catch (Exception e) {}
}
public String getClusterName() {
return this.clusterName;
}
public void setClusterName(String clusterName) {
this.clusterName = clusterName;
if(clusterName != null){
putQueryParameter("ClusterName", clusterName);
}
}
public String getClusterId() {
return this.clusterId;
}
public void setClusterId(String clusterId) {
this.clusterId = clusterId;
if(clusterId != null){
putQueryParameter("ClusterId", clusterId);
}
}
@Override
public Class<ModifyClusterResponse> getResponseClass() {
return ModifyClusterResponse.class;
}
}
| [
"[email protected]"
] | |
917eb9f1d78d08c9f89e8fe5f5ccc096037aeac2 | 37f49914554e19ae72aeeb4038f253e05b707851 | /epi-core-app/src/androidTest/java/com/epitulsa/epicore/ExampleInstrumentedTest.java | 051cbd5fcfdb1caab341ebb4e5122083ab580783 | [] | no_license | amoydream/epi-core-android | 2e577e0fd8142a389c09ca9b8491fd87e62101e3 | 53559a98addb70eaba224a9e8317fbfd8c935db3 | refs/heads/master | 2021-04-24T11:31:27.873993 | 2017-11-01T08:43:02 | 2017-11-01T08:43:02 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 744 | java | package com.epitulsa.epicore;
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.*;
/**
* Instrumentation 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() throws Exception {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.epitulsa.epicore", appContext.getPackageName());
}
}
| [
"[email protected]"
] | |
21e9aea59368a789b524e1d64fb57b75026fde31 | 61637e2344437ba3094c846f199ce4d83be319ba | /src/data/src/utils/network/NetworkedBase.java | 67ed6127354bd27a3b5b220e32058db42d87efd4 | [
"MIT"
] | permissive | jraad360/VOOGASalad | d91953dd77dc540f81832b4ac68d5464f31abe3a | b8ae754fe82b997b26486752f22e0b8d36757e76 | refs/heads/master | 2020-06-03T03:48:00.064925 | 2019-06-12T14:11:21 | 2019-06-12T14:11:21 | 191,424,272 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,793 | java | package utils.network;
import utils.Connectable;
import utils.NetworkException;
import utils.SerializationException;
import utils.network.datagrams.Datagram;
import utils.network.datagrams.Request;
import utils.network.datagrams.Response;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.TimeoutException;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* Class which implements shared utilites between the client and the server.
* Its primary function is to read/write requests, and reply with Responses containing the result of the method
* calls if required.
* @author Jake Mullett
*/
public abstract class NetworkedBase implements Connectable {
private static final String ERROR_IN_CLOSING_CONNECTION = "Error in closing connection! ";
private static final String METHOD_CALL_HAS_TIMED_OUT = "Method call has timed out.";
private static final String RESPONSE_READER_THREAD_FAIL = "Error in trying to wait for response!";
private static final int TIMEOUT_REQUEST_MS = 500;
protected Logger LOGGER = Logger.getGlobal();
// Network accessors are private so that the NetworkedClient and NetworkedServer have to use
// methods set up in this class for consistency.
private ConcurrentMap<String, Response> requestPool;
private Socket socket;
private ObjectOutputStream objectOutputStream;
private ObjectInputStream objectInputStream;
private Thread readerThread;
private Object parent;
NetworkedBase(Object parentObject) {
parent = parentObject;
requestPool = new ConcurrentHashMap<>();
}
/**
* Send a request which expects a response, and thus has to wait for the response from the network.
* Package-private.
* @param request request to be made.
* @throws Throwable Exception which either occured in trying to transmit the request,
* or an exception in the operation of the request's method call.
*/
Object sendRequest(Request request) throws Throwable {
sendDatagram(request);
return request.requiresResponse() ? getResponse(request.getId()) : null;
}
/**
* Disconnects the networked object from the object it is currently connected to.
*
* If it is not connected, does nothing.
*/
public void disconnect(){
if (isConnected()) {
try {
objectInputStream.close();
objectOutputStream.close();
socket.close();
readerThread.interrupt();
} catch (Exception ex) {
LOGGER.log(Level.SEVERE, ERROR_IN_CLOSING_CONNECTION + ex.getMessage());
} finally {
readerThread.interrupt();
socket = null;
}
}
}
/**
* @return Returns if this object is currently connected or not.
*/
public boolean isConnected() {
return socket != null && socket.isConnected();
}
// Has Throwable as we could get literally any exception in response to the method call.
private Object getResponse(String id) throws Throwable {
long callTime = System.currentTimeMillis();
try {
synchronized(requestPool) {
while(!requestPool.containsKey(id)) {
if (System.currentTimeMillis() > callTime + TIMEOUT_REQUEST_MS) {
throw new TimeoutException(METHOD_CALL_HAS_TIMED_OUT);
}
requestPool.wait();
}
Object result = requestPool.remove(id).getResult();
// If we got an error as a result, throw it instead of returning it.
if (result instanceof Throwable) {
throw ((Throwable) result);
}
return result;
}
} catch (InterruptedException e) {
throw new NetworkException(RESPONSE_READER_THREAD_FAIL, e);
}
}
private void sendDatagram(Datagram datagram) throws IOException {
objectOutputStream.writeObject(datagram);
}
protected final void setupSocket(Socket newSocket) throws IOException {
socket = newSocket;
objectOutputStream = new ObjectOutputStream(socket.getOutputStream());
objectOutputStream.flush(); // flush to send header for initialiation of input stream
objectInputStream = new ObjectInputStream(socket.getInputStream());
readerThread = new Thread(new NetworkReaderWorker(this));
readerThread.start();
}
abstract void handleNetworkDisconnection();
void readDatagrams() throws IOException, ClassNotFoundException, SerializationException {
Datagram datagram = readDatagram();
while (datagram != null) {
switch (datagram.getType()) {
case REQUEST:
handleRequest((Request) datagram);
break;
case RESPONSE:
handleResponse((Response) datagram);
break;
}
datagram = readDatagram();
}
}
private Datagram readDatagram() throws IOException, ClassNotFoundException {
return (Datagram) objectInputStream.readObject();
}
private void handleRequest(Request datagram) throws IOException, SerializationException {
sendDatagram(datagram.applyRequest(parent));
}
private void handleResponse(Response response) {
synchronized (requestPool) {
requestPool.put(response.getId(), response);
requestPool.notifyAll();
}
}
}
| [
"[email protected]"
] | |
ca447b2159d6e90fca1566f7f8724d25a570b539 | 9a544fa6df77424ff844b27653cbdd2207e962f9 | /Oracle_Java_Course_Prt1/Topic_4/JFT4Ex3.java | f56ccffc2800a24ff50ad11936abd668e9d18948 | [] | no_license | Al-Murphy101/Personal_Projects | aaae70c6bbb0f3989a8e542ba6132ac9a2dbd3de | 7a71f5003f365990e7f2cfbb80684664e852e623 | refs/heads/main | 2023-08-24T17:29:58.863821 | 2021-10-16T08:22:48 | 2021-10-16T08:22:48 | 409,362,221 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,809 | java | public class JFT4Ex3 {
public static void main (String[] args)
{
String empName = "Alan Murphy";
final String ppsNo = "7039871A";
String departmentId = "Software Project Manager";
float basicHours = 50.5f;
float overTime = 13.5f;
float basicRate = 29.35f;
float totalWage = basicHours * basicRate;
float overTimeRate = basicRate * 1.5f;
float totalOT = overTimeRate * overTime;
float gross = totalWage + totalOT;
float tax = 0.35f;
float totalTax = gross * tax;
float netPay = gross - totalTax;
System.out.println("");
System.out.println("*****************Salay Report*****************");
System.out.println("");
System.out.println("***************Emplyee Details****************");
System.out.println("Employee Name: " + empName);
System.out.println("Employee PPS No: " + ppsNo);
System.out.println("Employee Department: " +departmentId);
System.out.println("");
System.out.println("*****************Hours Worked*****************");
System.out.println("No. of basic hours worked: " + basicHours);
System.out.println("The hourly rate for pay is at " + basicRate + " euro");
System.out.println("Basic salry: " + totalWage);
System.out.println("No. of overtime hours worked: " + overTime);
System.out.println("The hourly rate for overtime is time and a half at: " +overTimeRate);
System.out.println("Overtime salary: " + totalOT);
System.out.println("");
System.out.println("*****************Take Home Pay*****************");
System.out.println("Gross Pay: " + gross);
System.out.println("Income Tax Payable at: 35% is: " + totalTax);
System.out.println("Net Pay: " + netPay);
System.out.println("***********************************************");
}
} | [
"[email protected]"
] | |
00f1ac4ed00e65ec47fb91e0318565dc5e0a996f | c46fdd0a622ff41a648e3fec85df58d972797897 | /main/java/com/study/blog/controller/UserController.java | c63bfd540f20bd795fcc7cbfa2be7fcfb8d670c8 | [] | no_license | lxk-kk/Blog | aed0259afb463b2241c932756a71fc37fef6ae14 | c7b22b4af1d72cb5db4b1b81e0615958635af5e8 | refs/heads/master | 2023-04-06T13:47:31.734653 | 2021-04-29T05:22:27 | 2021-04-29T05:22:27 | 251,526,852 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 9,956 | java | package com.study.blog.controller;
import com.github.pagehelper.Page;
import com.study.blog.annotation.ValidateAnnotation;
import com.study.blog.entity.Authority;
import com.study.blog.entity.User;
import com.study.blog.service.AuthorityService;
import com.study.blog.service.impl.UserServiceImpl;
import com.study.blog.util.EntityTransfer;
import com.study.blog.util.PasswordValidation;
import com.study.blog.vo.ResultVO;
import com.study.blog.vo.UserVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.thymeleaf.expression.Strings;
import javax.servlet.http.HttpServletRequest;
import javax.validation.ConstraintViolationException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
/**
* @author 10652
* 【spring security】
* 在类上使用PreAuthorize注解:表示指定角色权限才能访问方法
* PreAuthorize("hasAuthority('ADMIN')")
* 在方法上添加这个注解:表示只有指定的用户名才能访问该方法
* PreAuthorize("authentication.name.equals(#username)")
*/
@RestController
@RequestMapping("/users")
@Slf4j
@PreAuthorize("hasAuthority('ROLE_ADMIN')")
public class UserController {
private final UserServiceImpl service;
private final AuthorityService authorityService;
@Autowired
public UserController(UserServiceImpl service, AuthorityService authorityService) {
this.authorityService = authorityService;
this.service = service;
}
/**
* 查询所有用户
*
* @param model model
* @return 用户列表页面
*/
@GetMapping
@ValidateAnnotation
public ModelAndView listUser(
@RequestParam(value = "async", required = false) boolean async,
@RequestParam(value = "pageIndex", required = false, defaultValue = "0") int pageIndex,
@RequestParam(value = "pageSize", required = false, defaultValue = "10") int pageSize,
@RequestParam(value = "name", required = false, defaultValue = "") String name,
Model model,
HttpServletRequest request) {
Page<User> users = service.listUsersByName(name, pageIndex, pageSize);
model.addAttribute("page", "");
// 将 users 转换为 userVOs
Page<UserVO> userVOS = EntityTransfer.usersToVOS(users);
log.info("获取用户列表:【Page<UserVO>:{}】", userVOS);
model.addAttribute("users", userVOS);
Strings strings = new Strings(Locale.CHINA);
request.setAttribute("strings", strings);
return new ModelAndView(async ? "users/list :: #mainContainerRepleace" : "users/list", "userModel", model);
}
/**
* 查询指定id的用户
*
* @param id id
* @param model model
* @return 用户详情页面
*/
@GetMapping("/{id}")
@ValidateAnnotation
ModelAndView searchById(@PathVariable("id") int id, Model model) {
// 将 user 转换为 userVO 前端展示
model.addAttribute("user", EntityTransfer.userToVO(service.searchById(id)));
model.addAttribute("title", "查询用户");
return new ModelAndView("users/view", "userModel", model);
}
/**
* 增加用户
*
* @param model model
* @return 具有form表单的用户信息填写页面
*/
@GetMapping("/add")
@ValidateAnnotation
ModelAndView createUser(Model model) {
model.addAttribute("user", new User());
return new ModelAndView("users/add", "userModel", model);
}
/**
* 修改指定id的用户
*
* @param id id
* @param model model
* @return 具有form表单的用户信息填写页面
*/
@GetMapping("/edit/{id}")
@ValidateAnnotation
ModelAndView updateUser(@PathVariable("id") int id, Model model) {
model.addAttribute("user", service.searchById(id));
return new ModelAndView("users/edit", "userModel", model);
}
/**
* 保存或者更新用户
*
* @param user 用户
* @return 重定向到用户列表页面
*/
@PostMapping
@ValidateAnnotation
ResponseEntity<ResultVO> saveOrUpdate(Integer authorityId, @Validated User user, BindingResult result) {
if (result.hasErrors()) {
log.error("用户信息出错");
return ResponseEntity.ok().body(new ResultVO(false, result.getFieldError().getDefaultMessage()));
}
List<Authority> authorities = new ArrayList<>(1);
authorities.add(authorityService.getAuthorityById(authorityId));
user.setAuthorities(authorities);
User originalUser;
if (user.getId() != null && (originalUser = service.searchById(user.getId())) != null) {
// 用户信息更新
/*
这里需要对密码进行等值判断:原因是
保存的密码是加密后的密码
如果用户修改了密码,则新密码是未加密的,所以需要进行判断
*/
if (!PasswordValidation.equalPassword(originalUser.getPassword(), user.getPassword())) {
log.info("更新密码了:{},{}", originalUser.getPassword(), user.getPassword());
// 如果密码被更新过,则需要对其进行加密保存
user.setEncodePassword(user.getPassword());
}
// 否则不需要更新密码
try {
service.updateUser(user);
} catch (ConstraintViolationException e) {
log.error("【更新用户信息 :Bean 校验异常】{}", e.getMessage());
return ResponseEntity.ok().body(new ResultVO(false, e.getMessage()));
}
} else {
// 新增用户
user.setEncodePassword(user.getPassword());
try {
service.createUser(user);
} catch (ConstraintViolationException e) {
String errorMsg = e.getMessage();
log.error("【新增用户 :Bean 校验异常】{}", errorMsg);
return ResponseEntity.ok().body(new ResultVO(false, errorMsg));
}
}
return ResponseEntity.ok().body(new ResultVO(true, "处理成功", user));
}
/**
* 删除指定id的用户
*
* @param id id
* @return 重定向到用户列表
*/
@DeleteMapping("/delete/{id}")
@ValidateAnnotation
ResponseEntity<ResultVO> deleteUser(@PathVariable("id") int id) {
try {
service.deleteUser(id);
} catch (Exception e) {
return ResponseEntity.ok().body(new ResultVO(false, e.getMessage()));
}
return ResponseEntity.ok().body(new ResultVO(true, "处理成功"));
}
/**
* 获取个人设置页面
*
* @param username 用户名
* @param modelAndView 模型视图
* @return 修改个人信息界面
*/
@GetMapping("/{username}/profile")
@PreAuthorize("authentication.name.equals(#username)")
@ValidateAnnotation
public ModelAndView profile(@PathVariable("username") String username, ModelAndView modelAndView) {
User user = (User) service.loadUserByUsername(username);
modelAndView.addObject("user", user);
modelAndView.setViewName("/userspace/profile");
modelAndView.setViewName("userModel");
return modelAndView;
}
/**
* @param username 用户名
* @param user 用户
* @return 用户个人信息页面
*/
@PostMapping("/{username}/profile")
@PreAuthorize("authentication.name.equals(#username)")
@ValidateAnnotation
public String saveProfile(@PathVariable("username") String username, User user) {
log.info("修改用户信息");
User originUser = service.searchByUsername(username);
originUser.setEmail(user.getEmail());
originUser.setName(user.getName());
if (!PasswordValidation.equalPassword(originUser.getPassword(), user.getPassword())) {
originUser.setEncodePassword(user.getPassword());
}
service.updateUser(originUser);
return "redirect:/u/" + username + "/profile";
}
/**
* 获取修改用户头像数据 到达用户编辑头像的页面
*
* @param username 用户名
* @param modelAndView 模型视图
* @return 编辑头像页面
*/
@GetMapping("/{username}/avatar")
@PreAuthorize("authentication.name.equals(#username)")
@ValidateAnnotation
public ModelAndView avatar(@PathVariable("username") String username, ModelAndView modelAndView) {
User originUser = service.searchByUsername(username);
modelAndView.addObject("user", originUser);
modelAndView.setViewName("/userspace/avatar");
modelAndView.setViewName("userModel");
return modelAndView;
}
/**
* 保存用户头像,响应新的头像地址
*
* @param username 用户名
* @param user 用户
* @return 处理结果
*/
@PostMapping("/{username}/avatar")
@PreAuthorize("authentication.name.equals(#username)")
@ValidateAnnotation
public ResponseEntity<ResultVO> avatar(@PathVariable("username") String username, @RequestBody User user) {
String avatar = user.getAvatar();
User originUser = service.searchByUsername(username);
originUser.setAvatar(avatar);
service.updateUser(originUser);
return ResponseEntity.ok().body(new ResultVO(true, "处理成功", avatar));
}
}
| [
"[email protected]"
] | |
f9dbf1b8f70c0158c9057ef3fbdac3f04d497b7d | eee820b7ab40b920aa3ea5be206257a10bf4dc59 | /Kruskal.java | 7bd7d226cd07713eb2d33e13152ac93809577372 | [] | no_license | malu0908/NovoKruskal | 39b1269e4d142c192aa5df3bb808d4f9d0bde3f0 | 150217b832a967b297b8a6eb8b4edddd8adbcf74 | refs/heads/master | 2022-01-06T16:33:57.026878 | 2019-05-27T10:15:07 | 2019-05-27T10:15:07 | 188,820,555 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,994 | java | package AlgKruskal;
import java.io.IOException;
import java.util.Arrays;
import java.util.Observable;
public class Kruskal extends Observable implements Runnable {
public static Aresta resultado[] = new Aresta[57];
public static Aresta[] arestas = new Aresta[(58 * 57) / 2];
UnionFind conjuntos = new UnionFind();
boolean setaGrafo;
public static Kruskal geraAgm = new Kruskal();
private Kruskal() {
// gera os conjuntos iniciais composto por conjuntos unitarios
conjuntos.criaEstrutura();
// cria uma vetor com as arestas em ordem crescente, considerando apenas a
// matriz triangular superior
int w = 0;
for (int i = 0; i < 58; i++) {
for (int j = i + 1; j < 58; j++) {
if (i != j) {
arestas[w] = new Aresta(i, j, Matrizes.getMatrizAdj()[i][j]);
w++;
}
}
}
Vetor.setVetorIni(arestas);
Arrays.sort(arestas);
}
public static Aresta[] getArestas() {
return arestas;
}
public static Kruskal getAgm() {
return geraAgm;
}
public void notifica() {
setChanged();
notifyObservers();
}
public void AlgKruskal() {
int w = 0;
conjuntos.criaEstrutura();
for (int i = 0; i < arestas.length; i++) {
if (!(conjuntos.teste(arestas[i].vertice1, arestas[i].vertice2)) && arestas[i].naoEhAcessivel == false) {
conjuntos.juntar(arestas[i].vertice1, arestas[i].vertice2);
resultado[w] = arestas[i];
w++;
}
}
}
public void executa() throws IOException {
AlgKruskal();
Vetor.setVetorAtual(resultado);
DesenhaTela.getTela().getDesenhaGrafoAtual().aresta = Vetor.getVetorAtual();
}
@Override
public void run() {
Vetor.setVetorAnterior(Vetor.getVetorAtual());
DesenhaTela.getTela().getDesenhaGrafoAnterior().aresta = Vetor.getVetorAnterior();
// TODO Auto-generated method stub
try {
Matrizes.executaOperacoes();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
| [
"[email protected]"
] | |
c923a926a69b1d3c11a6b69599cfe86ff4cc9602 | 5ee576119a5910465a35c26630f972ad1fbcc8aa | /WorldOfZuul/src/worldofzuul/TrashCan.java | 0a43a78e0e0acdbdf9147952049a6eb626f5a9cc | [] | no_license | Mlinnelyst/GruppeProjekt | cb8c2bb617108cadbf800cd0fe86e7d63b2dcef2 | da06e0b2f74d61a5700edf13abb29c7d00756f06 | refs/heads/master | 2022-06-28T17:09:43.121403 | 2022-06-13T20:40:45 | 2022-06-13T20:40:45 | 209,004,919 | 0 | 0 | null | 2019-12-09T12:11:09 | 2019-09-17T08:52:39 | Java | UTF-8 | Java | false | false | 2,503 | java | package worldofzuul;
import java.util.ArrayList;
public class TrashCan {
private final String name;
private final ArrayList<TrashType> trashType;
public ArrayList<Trash> trash;
public ScoreCounter scoreCounter;
public TrashCan(String name, ArrayList<TrashType> trashType, ScoreCounter scoreCounter) {
this.name = name;
this.trashType = trashType;
this.trash = new ArrayList<>();
this.scoreCounter = scoreCounter;
}
@Override
public String toString() {
return this.name;
}
public boolean containsTrashType(TrashType trashType) {
return this.trashType.contains(trashType);
}
// følgende funktion har til opgave at fjerne affald fra players inventory
// og tilføje affaldet ind til skraldespanden
public boolean addTrash(Inventory inv, Trash trash, ScoreCounter score) {
// først tjekker vi om det objekt overhovedet eksisterer i vores player
// inventory
if (inv.trash.containsValue(trash)) {
// vi tjekker også om vores skrald har samme skraldetype som vores skraldespand.
// det vil sige, vi definerer hvilken type skrald vores skraldespand kan
// acceptere.
// eksempelvis, kan vi ikke sætte en plastikflaske ind i en mad skraldesprand.
if (containsTrashType(trash.getTrashType())) {
// hvis det gør tilføjer vi det til skraldespandens "inventory"
this.trash.add(trash);
scoreCounter.addScore(10);
// vi skal også huske at fjerne objektet fra vores player inventory
inv.trash.remove(trash.toString());
return true;
} else {
// hvis skraldetypen og skraldespandstypen ikke korrespondere med hinanden
// vil spilleren miste point
scoreCounter.decreaseScore(15);
System.out.printf("Desværre. Du har mistet point! Du har sorteret forkert. Prøv med en anden skraldespand.\nDin score er nu: %d%n", score.getScore());
return false;
}
}
return false;
}
// print alle
public void printInventory() {
System.out.printf("----- Inventory of %s trashcan -----%n", this.name.toLowerCase());
trash.forEach((trash1) -> {
System.out.println(trash1.toString());
});
System.out.println("--------------------------------------");
}
}
| [
"[email protected]"
] | |
1c6e8b9b53d3fc0f3e4903ab8fdc8770a0761ab3 | cd5efb8e2ebdf92ca2d53082673bd1e56f22739f | /src/org/tatasu/gwt/client/cawidgets/loader/resources/LoaderWidgetResources.java | 3077abc15a6abaeaa9834154fddff679ac5d9c6b | [] | no_license | khafizovar/cawidgets-gwt | 866ca05a80415a045467d10d9d5f1837b1ff9c3f | 55ab61fc7bc0f4541384ba6f3166419c2a63f7ca | refs/heads/master | 2023-01-10T10:01:50.184900 | 2020-11-11T09:55:15 | 2020-11-11T09:55:15 | 225,298,211 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 361 | java | package org.tatasu.gwt.client.cawidgets.loader.resources;
import com.google.gwt.resources.client.ClientBundle;
import com.google.gwt.resources.client.ImageResource;
public interface LoaderWidgetResources extends ClientBundle {
@Source("org/tatasu/gwt/client/cawidgets/loader/resources/images/ajax-loader.gif")
ImageResource getLoaderImage();
}
| [
"HafizovAR@localhost"
] | HafizovAR@localhost |
f0f3bee496951319f754d8e0ad2fa4b2a7772bc9 | 3b3e033c2b45f8fc4d3f4549196550c0dcee4384 | /src/main/java/com/transactionmicroservice/model/TransactionDTO.java | 00e8bfafa3e6728eb8bc28a95f85fd56b62366d3 | [] | no_license | danidaryaweesh/xHire-transaction-micro-service | 8af1c73eac8592734edc3d3d584e2b8e8082c782 | 00fef358ce6a988d2e84705cd3f2e6ee052b50c0 | refs/heads/master | 2021-01-18T04:00:06.694839 | 2017-03-08T16:06:27 | 2017-03-08T16:06:27 | 85,772,552 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,500 | java | package com.transactionmicroservice.model;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by dani on 2017-02-23.
*/
public class TransactionDTO {
private Long userId;
private Long transactionId;
private String date;
private String description;
private int sum;
@JsonCreator
public TransactionDTO(@JsonProperty("userId") Long userId,@JsonProperty("date") String date, @JsonProperty("description") String description, @JsonProperty("sum") int sum, @JsonProperty("transactionId") Long transactionId) {
this.userId = userId;
this.transactionId = transactionId;
this.date = date;
this.description = description;
this.sum = sum;
}
public TransactionDTO(){}
public Long getUserId() { return userId; }
public void setUserId(Long userId) { this.userId = userId; }
public Long getTransactionId() {
return transactionId;
}
public void setTransactionId(Long transactionId) { this.transactionId = transactionId; }
public String getDate() { return date; }
public void setDate(String date) {
this.date = date;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public int getSum() {
return sum;
}
public void setSum(int sum) {
this.sum = sum;
}
}
| [
"[email protected]"
] | |
bd6c0f682fae683df9d95350fec44f089c9850b1 | 36ce1708ac9f23a06df524d94b2fd5bb61ecefd5 | /src/catena/gui/util/MyFileChooser.java | 04281460385956e1cf326e8d129511ea2468f8ec | [
"LicenseRef-scancode-other-permissive",
"MIT"
] | permissive | flavioesposito/catena | 9260b971f057aed416ad8823c8dc3023e90a939a | d43cf7e3e5fb9b158c707b1183eaa27e72b6ea24 | refs/heads/master | 2021-01-12T02:03:56.028038 | 2017-01-11T18:19:00 | 2017-01-11T18:19:00 | 78,461,967 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,258 | java |
package vinea.gui.util;
import java.io.File;
import javax.swing.JFileChooser;
/**
* File chooser: Extends JFileChooser, a Java library that provides a simple mechanisms to
* allow users choose a file
*
* This file is based on NED from Tatiana Kichkaylo at NYU and by Weishuai Yang at Binghamton Univ.
*/
public class MyFileChooser extends JFileChooser {
public static ExtFileFilter graphFilter = new ExtFileFilter( "alt", "ITM alt files" );
public static ExtFileFilter configFilter = new ExtFileFilter( "cfg", "Config files" );
public MyFileChooser() {}
private static class ExtFileFilter extends javax.swing.filechooser.FileFilter {
private String ext;
private String descr;
public ExtFileFilter( String ext, String descr ) {
this.ext = ext;
this.descr = descr;
}
public boolean accept( File f ) {
if ( f.isHidden() ) return false;
if ( f.isDirectory() ) return true;
String nm = f.getName();
if ( nm.indexOf( "." )<0 ) return false;
nm = nm.substring( nm.lastIndexOf( "." )+1 );
return nm.equals( ext );
}
public String getDescription() { return descr; }
}
} | [
"[email protected]"
] |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.