blob_id stringlengths 40 40 | directory_id stringlengths 40 40 | path stringlengths 4 410 | content_id stringlengths 40 40 | detected_licenses listlengths 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 listlengths 1 1 | author_id stringlengths 0 313 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
33f46d59714cce63eb33d1496c124a275f9af89d | bc7e6e1bc531149042742694191b60bceb76f1c8 | /modules/spring-web-test-client/src/test/java/io/restassured/module/webtestclient/RestDocsTest.java | 6ec3fd47334876bc24ca1444b915163c470f333d | [
"Apache-2.0"
] | permissive | juaordmar/rest-assured | 86d6f7f330ffc698038dde90907244fecfc18449 | c01cf094fcbdbad387e3f04aae7e8e7064056ac8 | refs/heads/master | 2023-04-18T10:14:38.586003 | 2021-04-10T11:28:56 | 2021-04-10T11:28:56 | 345,579,865 | 1 | 1 | Apache-2.0 | 2021-04-10T11:28:57 | 2021-03-08T08:16:00 | Java | UTF-8 | Java | false | false | 3,256 | java | /*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.restassured.module.webtestclient;
import io.restassured.module.webtestclient.setup.GreetingController;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.springframework.restdocs.JUnitRestDocumentation;
import org.springframework.restdocs.snippet.SnippetException;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.request.RequestDocumentation.parameterWithName;
import static org.springframework.restdocs.request.RequestDocumentation.pathParameters;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.documentationConfiguration;
public class RestDocsTest {
@Rule
public final JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("target/generated-snippets");
@Rule
public ExpectedException exception = ExpectedException.none();
@Test
public void path_parameters_are_automatically_supported() {
RestAssuredWebTestClient.given()
.standaloneSetup(new GreetingController(), documentationConfiguration(restDocumentation))
.queryParam("name", "John")
.when()
.consumeWith(document("greeting",
pathParameters(
parameterWithName("path").description("The path to greeting")),
responseFields(
fieldWithPath("id").description("The ID of the greeting"),
fieldWithPath("content").description("The content of the greeting"))
))
.get("/{path}", "greeting")
.then()
.body("id", equalTo(1))
.body("content", equalTo("Hello, John!"));
}
@Test
public void document_generation_is_executed() {
exception.expect(SnippetException.class);
exception.expectMessage("Path parameters with the following names were not documented: [path]. " +
"Path parameters with the following names were not found in the request: [xxx]");
RestAssuredWebTestClient.given()
.standaloneSetup(new GreetingController(), documentationConfiguration(restDocumentation))
.queryParam("name", "John")
.when()
.consumeWith(document("greeting",
pathParameters(
parameterWithName("xxx").description("The path to greeting")),
responseFields(
fieldWithPath("id").description("The ID of the greeting"),
fieldWithPath("content").description("The content of the greeting"))
))
.get("/{path}", "greeting");
}
}
| [
"johan.haleby@gmail.com"
] | johan.haleby@gmail.com |
a30d7165fc754a2e9f2c1bb05937546b072ad98b | 7a4a4382e146ffac47e7185aa021fc6cfa9c1379 | /codeStreak/2. Add Two Numbers/src/ListNode.java | d2dd4b6899bdc7629d7039a8990ae6ab60b247fb | [] | no_license | anijain1065/Ayu_CodeStreak | 475a11257f90c8b88540e5c26a149af688970977 | e3f687c45d438a78ecce388ea06f14ff3e25dfbf | refs/heads/main | 2023-09-04T22:10:46.874178 | 2021-11-04T17:11:21 | 2021-11-04T17:11:21 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 760 | java | public class ListNode {
int val;
ListNode next;
ListNode() {}
ListNode(int val) { this.val = val; }
ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}
class Solution {
public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
ListNode res = new ListNode(-1);
ListNode tail = res;
int carry = 0;
while(l1 != null || l2 != null || carry != 0){
int x1 = l1 == null ? 0 : l1.val;
int x2 = l2 == null ? 0 : l2.val;
tail.next = new ListNode((x1+x2+carry)%10);
carry = (x1+x2+carry)/10;
tail = tail.next;
if(l1 != null) l1 = l1.next;
if(l2 != null) l2 = l2.next;
}
return res.next;
}
} | [
"ayp.scp@gmail.com"
] | ayp.scp@gmail.com |
4ddb4e3634f3ee1144f8f84139762c8ff4d4b1b0 | 2147f7bcf884ae21fde0d8f7ed0c32ac9cfb8f5b | /Implementation/programmers_튜플.java | 4923665b06abe3dc9af9b4aa3efbfd8837c82e98 | [] | no_license | hhytruth/algorithm | 8f39de12bee9d60b1a9a854f8556a915a7f7b7e6 | 6d2110ca62dbe3a3ccbe4e0b9dedd9dd7e532a5e | refs/heads/main | 2023-08-26T09:38:58.223660 | 2021-10-08T14:58:35 | 2021-10-08T14:58:35 | 336,126,443 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 999 | java | import java.util.*;
class programmers_튜플 {
public static int[] solution(String s) {
int[] answer={};
String[] tmp=s.split("\\{");
Arrays.sort(tmp,new Comparator<String>() {
@Override
public int compare(String s1,String s2) {
return s1.length()-s2.length();
}
});
ArrayList<Integer> list=new ArrayList<>();
boolean[] visited=new boolean[100001];
for(String str:tmp){
str=str.replace("}","");
if(str.equals(""))continue;
String[] numbers=str.split(",");
for(String number:numbers) {
int num=Integer.parseInt(number);
if(!visited[num]) {
visited[num]=true;
list.add(num);
break;
}
}
}
answer=new int[list.size()];
for(int i=0;i<list.size();i++) {
answer[i]=list.get(i);
}
return answer;
}
}
| [
"noreply@github.com"
] | hhytruth.noreply@github.com |
c936e70c6c06958d5fa7b1fad53303ca4915941c | ab1e834273601798828d89753bc14e53513430d7 | /yulje_final/src/main/java/com/example/demo/dao/GoodDao.java | e62a3df246eb055b2e729f36be02a7368d0d0b58 | [] | no_license | miyony/zzzzz | f08307ae1c28cd2b29ae4fd4a589e18702e3223a | 1db1ce059e76d0b7580ca0daec5a43e55a9d3561 | refs/heads/master | 2023-01-24T01:44:38.067977 | 2020-11-21T05:14:27 | 2020-11-21T05:14:27 | 314,737,765 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 980 | java | package com.example.demo.dao;
import java.util.HashMap;
import java.util.List;
import org.springframework.stereotype.Repository;
import com.example.demo.db.GoodManager;
import com.example.demo.vo.Good_BoardVo;
@Repository
public class GoodDao {
public List<Good_BoardVo> findAll(HashMap map){
return GoodManager.findAll(map);
}
public int insert(Good_BoardVo gb) {
return GoodManager.insert(gb);
}
public Good_BoardVo findByNo(int no) {
return GoodManager.findByNo(no);
}
public int updateStep(HashMap map) {
return GoodManager.updateStep(map);
}
public int getNextNo() {
return GoodManager.getNextNo();
}
public int update(Good_BoardVo gb) {
return GoodManager.update(gb);
}
public int delete(HashMap map) {
return GoodManager.delete(map);
}
public int getTotalCount() {
return GoodManager.getTotalCount();
}
// public boolean isMember(String id, String pwd) {
// return NoticeManager.isMember(id, pwd);
//
// }
}
| [
"tazomi@naver.com"
] | tazomi@naver.com |
e04c9b7d2660cc6edb6ba6df06553fbdbe1a4241 | 04e1cbd903a9484a319c602b0ad8013b129bb1cb | /src/model/Node.java | b89d869dd284c5a01e28cd289f54f28cdff7ad12 | [] | no_license | lynh510/lynhgc00936_NguyenHaiLy_Project1 | 7c5b9cccd4cb253ac0c1e48971bddb0d4f4314d5 | b4e44a229cb0c081db08ed525f8330299156daf7 | refs/heads/master | 2021-01-22T10:56:45.200979 | 2017-06-07T12:38:16 | 2017-06-07T12:38:16 | 92,664,882 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 492 | 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;
public class Node<E> {
long key;
public E data;
public Node<E> left;
public Node<E> right;
public Node(long key, E data) {
this.key = key;
this.data = data;
}
@Override
public String toString() {
return String.valueOf(key);
}
}
| [
"lynhgc00936@fpt.edu.vn"
] | lynhgc00936@fpt.edu.vn |
688973b0c13fde359f1f00bfdd29640118e79059 | dd80a584130ef1a0333429ba76c1cee0eb40df73 | /libcore/luni/src/test/java/libcore/java/util/zip/OldZipFileTest.java | 9f2864bad82197b21b83f8df56f9a446ba07e40f | [
"MIT",
"LicenseRef-scancode-unicode",
"ICU",
"LicenseRef-scancode-newlib-historical",
"Apache-2.0",
"W3C-19980720",
"LicenseRef-scancode-generic-cla",
"W3C",
"CPL-1.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | karunmatharu/Android-4.4-Pay-by-Data | 466f4e169ede13c5835424c78e8c30ce58f885c1 | fcb778e92d4aad525ef7a995660580f948d40bc9 | refs/heads/master | 2021-03-24T13:33:01.721868 | 2017-02-18T17:48:49 | 2017-02-18T17:48:49 | 81,847,777 | 0 | 2 | MIT | 2020-03-09T00:02:12 | 2017-02-13T16:47:00 | null | UTF-8 | Java | false | false | 6,701 | 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 libcore.java.util.zip;
import tests.support.Support_PlatformFile;
import tests.support.resource.Support_Resources;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FilePermission;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.security.Permission;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
public class OldZipFileTest extends junit.framework.TestCase {
public byte[] getAllBytesFromStream(InputStream is) throws IOException {
ByteArrayOutputStream bs = new ByteArrayOutputStream();
byte[] buf = new byte[512];
int iRead;
while ((iRead = is.read(buf, 0, buf.length)) != -1) {
bs.write(buf, 0, iRead);
}
return bs.toByteArray();
}
public void test_size() throws IOException {
zfile.close();
try {
zfile.size();
fail("IllegalStateException expected");
} catch (IllegalStateException expected) {
}
}
public void test_getEntryLjava_lang_String_AndroidOnly() throws IOException {
java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
assertNotNull("Could not obtain ZipEntry", zentry);
int r;
InputStream in;
zentry = zfile.getEntry("testdir1");
assertNotNull("Must be able to obtain ZipEntry: testdir1", zentry);
in = zfile.getInputStream(zentry);
/*
* Android delivers empty InputStream, RI no InputStream at all. The
* spec doesn't clarify this, so we need to deal with both situations.
*/
int data = -1;
if (in != null) {
data = in.read();
in.close();
}
assertEquals("Must not be able to read directory data", -1, data);
}
// the file hyts_zipFile.zip in setup must be included as a resource
private String tempFileName;
private ZipFile zfile;
/**
* @throws IOException
* java.util.zip.ZipFile#close()
*/
public void test_close() throws IOException {
// Test for method void java.util.zip.ZipFile.close()
File fl = new File(tempFileName);
ZipFile zf = new ZipFile(fl);
InputStream is1 = zf.getInputStream(zf.getEntry("File1.txt"));
InputStream is2 = zf.getInputStream(zf.getEntry("File2.txt"));
is1.read();
is2.read();
zf.close();
try {
is1.read();
fail("IOException expected");
} catch (IOException ee) {
// expected
}
try {
is2.read();
fail("IOException expected");
} catch (IOException ee) {
// expected
}
}
public void test_getEntryLjava_lang_String_Ex() throws IOException {
java.util.zip.ZipEntry zentry = zfile.getEntry("File1.txt");
assertNotNull("Could not obtain ZipEntry", zentry);
zfile.close();
try {
zfile.getEntry("File2.txt");
fail("IllegalStateException expected");
} catch (IllegalStateException ee) {
}
}
/**
* @throws IOException
* java.util.zip.ZipFile#getInputStream(java.util.zip.ZipEntry)
*/
public void test_getInputStreamLjava_util_zip_ZipEntry() throws IOException {
// Test for method java.io.InputStream
// java.util.zip.ZipFile.getInputStream(java.util.zip.ZipEntry)
ZipEntry zentry = null;
InputStream is = null;
zentry = zfile.getEntry("File2.txt");
zfile.close();
try {
is = zfile.getInputStream(zentry);
fail("IllegalStateException expected");
} catch (IllegalStateException ee) {
// expected
}
}
/**
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
@Override
protected void setUp() throws IOException {
// Create a local copy of the file since some tests want to alter information.
tempFileName = System.getProperty("java.io.tmpdir");
String separator = System.getProperty("file.separator");
if (tempFileName.charAt(tempFileName.length() - 1) == separator.charAt(0)) {
tempFileName = Support_PlatformFile.getNewPlatformFile(tempFileName, "gabba.zip");
} else {
tempFileName = Support_PlatformFile.getNewPlatformFile(
tempFileName + separator, "gabba.zip");
}
File f = new File(tempFileName);
f.delete();
InputStream is = Support_Resources.getStream("hyts_ZipFile.zip");
FileOutputStream fos = new FileOutputStream(f);
byte[] rbuf = getAllBytesFromStream(is);
fos.write(rbuf, 0, rbuf.length);
is.close();
fos.close();
zfile = new ZipFile(f);
}
/**
* Tears down the fixture, for example, close a network connection. This
* method is called after a test is executed.
*/
@Override
protected void tearDown() throws IOException {
// Note zfile is a user-defined zip file used by other tests and
// should not be deleted
zfile.close();
tempFileName = System.getProperty("java.io.tmpdir");
String separator = System.getProperty("file.separator");
if (tempFileName.charAt(tempFileName.length() - 1) == separator
.charAt(0)) {
tempFileName = Support_PlatformFile.getNewPlatformFile(
tempFileName, "gabba.zip");
} else {
tempFileName = Support_PlatformFile.getNewPlatformFile(
tempFileName + separator, "gabba.zip");
}
File f = new File(tempFileName);
f.delete();
}
}
| [
"karun.matharu@gmail.com"
] | karun.matharu@gmail.com |
41115215bf42575cda9871a46eca18300437d42e | 98762ae40f95af7552bc6069ccddcc4fe1dfa65d | /src/main/java/org/una/lab02/services/CiudadServiceImplementation.java | 7b9cb053fc889a41c1d52874c339457c70a9cef8 | [] | no_license | GerardoArayaCeciliano/Laboratorio2 | ba22c1ffc9128f22b4c1e7f7a9c98e8ae4f9d790 | 38bc1968a537ab276109e83eef951ee4b9aea1c7 | refs/heads/master | 2022-12-24T04:29:32.985412 | 2020-10-04T00:36:56 | 2020-10-04T00:36:56 | 300,451,778 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,846 | 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 org.una.lab02.services;
import java.util.List;
import java.util.Optional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.una.lab02.dto.CiudadDto;
import org.una.lab02.entities.Ciudad;
import org.una.lab02.repositories.ICiudadRepository;
import org.una.lab02.utils.MapperUtils;
/**
*
* @author LordLalo
*/
@Service
public class CiudadServiceImplementation implements ICiudadService{
@Autowired
private ICiudadRepository ciudadRepository;
private Optional<List<CiudadDto>> findList(List<Ciudad> list) {
if (list != null) {
List<CiudadDto> autobusDto = MapperUtils.DtoListFromEntityList(list, CiudadDto.class);
return Optional.ofNullable(autobusDto);
} else {
return null;
}
}
private Optional<List<CiudadDto>> findList(Optional<List<Ciudad>> list) {
if (list.isPresent()) {
return findList(list.get());
} else {
return null;
}
}
private Optional<CiudadDto> oneToDto(Optional<Ciudad> one) {
if (one.isPresent()) {
CiudadDto autobusDto = MapperUtils.DtoFromEntity(one.get(), CiudadDto.class);
return Optional.ofNullable(autobusDto);
} else {
return null;
}
}
@Override
public Optional<CiudadDto> getById(long id) {
return oneToDto(ciudadRepository.findById(id));
}
@Override
public Optional<List<CiudadDto>> findAll() {
return findList(ciudadRepository.findAll());
}
}
| [
"roberth123pz@gmail.com"
] | roberth123pz@gmail.com |
d729c0d1ba0cc118dd60714d4728fca63afdf819 | f882f25f28751de4e76c81cd0b4508eb6dfefef5 | /Game.java | 48bd1646b980698ec1df872af523c021cbea29aa | [] | no_license | rtyuty/FinalsGame | 029d5aa7841233a805fd350abd934a96163d6509 | 7a6707f1b296012982e7ea6bdca9d4009bdc17ca | refs/heads/master | 2020-04-24T02:02:22.026212 | 2019-02-20T07:30:37 | 2019-02-20T07:30:37 | 171,622,331 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,462 | java | import java.awt.Canvas;
import java.awt.Graphics;
import java.awt.image.BufferStrategy;
import java.awt.Color;
public class Game extends Canvas implements Runnable{
private boolean isRunning = false;
private Thread thread;
public Game(){
new Window (1000,563,"TopDownGame", this);
start();
}
public void start(){
isRunning = true;
thread = new Thread(this);
thread.start();
}
public void stop(){
isRunning = false;
try {
thread.join();
}catch (InterruptedException e){
e.printStackTrace();
}
}
public void run(){
this.requestFocus();
long lastTime = System.nanoTime();
double amountOfTicks = 60.0;
double ns = 1000000000 / amountOfTicks;
double delta = 0;
long timer = System.currentTimeMillis();
int frames = 0;
while(isRunning){
long now = System.nanoTime();
delta += (now - lastTime) / ns;
lastTime= now;
while(delta >=1){
tick();
//updates++;
delta--;
}
render();
frames++;
if(System.currentTimeMillis() - timer > 1000){
timer += 1000;
frames = 0;
//updates = 0;
}
}
stop();
}
public void tick(){
}
public void render(){
BufferStrategy bs = getBufferStrategy();
if (bs == null) {
createBufferStrategy(3);
return;
}
Graphics g = bs.getDrawGraphics();
g.setColor(new Color(0,0,0));
g.fillRect(0, 0, 1000, 563);
g.dispose();
bs.show();
}
public static void main(String args[]){
new Game();
}
} | [
"eucliglen_magno@yahoo.com"
] | eucliglen_magno@yahoo.com |
63a6ce8804b3f64609535fa3ba426adaf9cac597 | 1488dd85e8954ce6688042417e3ad686393a5463 | /app/src/main/java/edu/noctrl/csc510/csc510_p2/MainActivity.java | 321796459c478be49aad8c5419f5e0e69173fd98 | [] | no_license | rhilsabeck/Android_Mobile_Weather_App | 8c10bb27ace777bc85d8a0c9f15a578ebdec46b9 | aed3e6db71bb471eaadec4ec437ae7094885d40b | refs/heads/master | 2016-09-14T08:24:18.915289 | 2016-05-26T17:38:46 | 2016-05-26T17:38:46 | 59,770,291 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 15,213 | java | //Ryan Hilsabeck and Tyler Koch Project 2
package edu.noctrl.csc510.csc510_p2;
import android.app.Activity;
import android.app.Fragment;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.app.FragmentTransaction;
import android.support.v4.app.NotificationCompat;
import android.support.v4.view.GestureDetectorCompat;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBarActivity;
import android.util.Log;
import android.view.GestureDetector;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.Toast;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
public class MainActivity extends ActionBarActivity implements CurrentConditions.OnFragmentInteractionListener,
ForecastFragment.OnFragmentInteractionListener, Enter_Zipcode_Dialog.OnFragmentInteractionListener,
AboutFragment.OnFragmentInteractionListener, UnitFragment.OnFragmentInteractionListener{
ImageView image;
String JSONurl, xmlURL, latitude, longitude, currentZip;
WeatherInfo weatherObject;
String json = "";
Activity activity;
/**
* The number of pages (wizard steps) to show in this demo.
*/
private static final int NUM_PAGES = 8;
/**
* The pager widget, which handles animation and allows swiping horizontally to access previous
* and next wizard steps.
*/
private ViewPager mPager;
/**
* The pager adapter, which provides the pages to the view pager widget.
*/
private PagerAdapter mPagerAdapter;
GestureDetector.OnGestureListener glistener = new GestureDetector.SimpleOnGestureListener(){
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
//swapFragments();
return super.onFling(e1, e2, velocityX, velocityY);
}
};
protected GestureDetectorCompat mDetector;
/* protected void swapFragments(){
android.support.v4.app.FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
trans.replace(R.id.container,ForecastFragment.newInstance("",""));
trans.addToBackStack(null);
trans.commit();
}*/
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
activity = this;
//remove preferences at the start of app for testing purposes
//SharedPreferences preferences = this.getPreferences(Context.MODE_PRIVATE);
//preferences.edit().remove("ZipList").commit();
//preferences.edit().remove(getString(R.string.units)).commit();
SharedPreferences sharedPref = this.getPreferences(Context.MODE_PRIVATE);
//Get preferred units and if not there yet, then set as imperial
String units = sharedPref.getString(getString(R.string.units),"Imperial");
Log.i("unit preference", units);
//get zip list and
String zips = sharedPref.getString("ZipList", null);
if(zips == null)
{
try {
onUserSelectValue("10002");
} catch (MalformedURLException e) {
e.printStackTrace();
}
}
else {
List arrayList = new ArrayList<String>(Arrays.asList(zips.split(",")));
String last = arrayList.get(arrayList.size()-1).toString();
Log.i("ryanDebug", zips);
try {
onUserSelectValue(last);
} catch (MalformedURLException e) {
e.printStackTrace();
}
Log.i("zips", zips);
}
}
@Override
public void onBackPressed() {
if (mPager.getCurrentItem() == 0) {
// If the user is currently looking at the first step, allow the system to handle the
// Back button. This calls finish() on this activity and pops the back stack.
super.onBackPressed();
} else {
// Otherwise, select the previous step.
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
//this.mDetector.onTouchEvent(event);
return super.onTouchEvent(event);
}
/**
* A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
* sequence.
*/
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
@Override
public android.support.v4.app.Fragment getItem(int position) {
switch(position) {
case 0:
return CurrentConditions.newInstance(weatherObject);
case 1:
return ForecastFragment.newInstance(weatherObject, 0); //today
case 2:
return ForecastFragment.newInstance(weatherObject, 1);
case 3:
return ForecastFragment.newInstance(weatherObject, 2);
case 4:
return ForecastFragment.newInstance(weatherObject, 3);
case 5:
return ForecastFragment.newInstance(weatherObject, 4);
case 6:
return ForecastFragment.newInstance(weatherObject, 5);
case 7:
return ForecastFragment.newInstance(weatherObject, 6);
case 8:
return ForecastFragment.newInstance(weatherObject, 7); //a wk from today
default:
return ForecastFragment.newInstance(weatherObject, 0);
}
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
switch(item.getItemId())
{
case R.id.enter_zipCode:
Enter_Zipcode_Dialog fragment = new Enter_Zipcode_Dialog();
fragment.show(getSupportFragmentManager(),"frag");
return true;
case R.id.current_weather:
mPager.setCurrentItem(0);
return true;
case R.id.sevenDay_Forecast:
mPager.setCurrentItem(1);
return true;
case R.id.units:
UnitFragment unitFrag = new UnitFragment();
unitFrag.show(getSupportFragmentManager(),"unitFrag");
return true;
case R.id.about:
AboutFragment aboutFrag = new AboutFragment();
aboutFrag.show(getSupportFragmentManager(),"aboutFrag");
return true;
}
return super.onOptionsItemSelected(item);
}
//this is the callback method to get the zip code entered by user in the enter
//zip code dialog. The zip code will be added to the url and then send it to
//the getJSON async task to get lat/long for the zip code.
public void onUserSelectValue(String selectedValue) throws MalformedURLException{
currentZip = selectedValue;
JSONurl = "http://craiginsdev.com/zipcodes/findzip.php?zip=" + selectedValue;
WeatherInfoIO.loadFromUrl(JSONurl,listen);
}
//This listener will be used to parse the JSON response and then handle the result to send to
//get the xml file
Downloader.DownloadListener<JSONObject> listen = new Downloader.DownloadListener<JSONObject>() {
@Override
public JSONObject parseResponse(InputStream in) {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(
in, "iso-8859-1"), 8);
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
json = sb.toString();
} catch (Exception e) {
Log.e("Buffer Error", "Error converting result " + e.toString());
}
// try parse the string to a JSON object
try {
JSONObject jsonObj = new JSONObject(json);
return jsonObj;
} catch (JSONException e) {
Log.e("JSON Parser", "Error parsing data " + e.toString());
return null;
}
}
@Override
public void handleResult(JSONObject result) {
try {
if(result == null)
showToast("This zip code does not exist or no internet connect. Try again.");
else {
latitude = result.getString("latitude");
longitude = result.getString("longitude");
xmlURL = "http://forecast.weather.gov/MapClick.php?lat=" + latitude +
"&lon=" + longitude + "&unit=0&lg=english&FcstType=dwml";
Log.i("ryanDebug", xmlURL);
handleXMLParse(xmlURL);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
};
//this listener will handle xml parsed weather object and create view pager
WeatherInfoIO.WeatherListener wListner = new WeatherInfoIO.WeatherListener() {
@Override
public void handleResult(WeatherInfo result){
weatherObject = result;
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
if(weatherObject.alerts.size() != 0)
{
alertsNotifications(weatherObject);
}
}
};
//this method will take the xml url needed and send it to another async task
//to go out and download the xml file and get the data we need to populate
//the fragments
public void handleXMLParse(String url)
{
WeatherInfoIO.loadFromUrl(url, wListner);
Log.i("ryanDebug", url);
}
//Use this to show Toast error messages
public void showToast(String message)
{
Toast toast = Toast.makeText(this, message, Toast.LENGTH_LONG);
toast.show();
}
//This will validate if the data entered by user is no more or no less then 5 characters and
//to make sure all the characters that were entered were numbers or else an error will show
public boolean zipValidation(String zip)
{
boolean zipValid = true;
if(zip.length() != 5)
{
zipValid = false;
}
else
{
try
{
double d = Double.parseDouble(zip);
}
catch(NumberFormatException nfe)
{
zipValid = false;
}
}
return zipValid;
}
//go through array of alerts and create a new notification for each alert
public void alertsNotifications(WeatherInfo weatherObject)
{
for(int i = 0; i < weatherObject.alerts.size(); i++)
{
String alertURL = weatherObject.alerts.get(i);
buildNotification(alertURL);
}
}
//This actually builds each unique alert notification to show
public void buildNotification(String url)
{
NotificationCompat.Builder b = new NotificationCompat.Builder(this);
b.setSmallIcon(R.drawable.alert)
.setContentTitle(getString(R.string.weatherAlert))
.setContentText(url);
Uri uri = Uri.parse(url);
Intent urlClick = new Intent(Intent.ACTION_VIEW, uri);
int uniqueInt = new Random().nextInt(543254);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, urlClick, PendingIntent.FLAG_UPDATE_CURRENT);
b.setContentIntent(pendingIntent);
NotificationManager nm =
(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nm.notify(uniqueInt,b.build());
}
//When user change units after they have already entered a zip and have info displaying, this
//will check to see what page the user is currently on and refresh the data with update to
//units
public void convertCurrentPage()
{
int currentPage = mPager.getCurrentItem();
FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
if(currentPage == 0) {
CurrentConditions cFrag = CurrentConditions.newInstance(weatherObject);
ft.replace(R.id.container, cFrag);
ft.commit();
}
else
{
ForecastFragment fFrag = ForecastFragment.newInstance(weatherObject,currentPage);
ft.replace(R.id.container, fFrag);
ft.commit();
}
}
@Override
public void onFragmentInteraction(Uri uri) {
}
/**
* A placeholder fragment containing a simple view.
*/
public static class PlaceholderFragment extends Fragment {
public PlaceholderFragment() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_current_conditions, container, false);
return rootView;
}
}
}
| [
"ryan.hilsabeck@gmail.com"
] | ryan.hilsabeck@gmail.com |
7c491979612a2d6fbef51d13612e85e1d24184c5 | e378790b3fdffc6a6e54bff2d75baf07831d10e3 | /aws-java-sdk-elasticloadbalancingv2/src/main/java/com/amazonaws/services/elasticloadbalancingv2/model/SetIpAddressTypeResult.java | 77ecc397ed6a1ace6ff8f9c7409d9937d736586b | [
"Apache-2.0"
] | permissive | TejasPatel007/aws-sdk-java | b0a1703171a516115a719c1649a4dbc0b830ce9a | 31c764c2bedad45ed6b51799e77889fb8ec8684b | refs/heads/master | 2021-07-07T07:54:58.070264 | 2017-10-03T17:49:17 | 2017-10-03T17:49:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,566 | java | /*
* Copyright 2012-2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.elasticloadbalancingv2.model;
import java.io.Serializable;
import javax.annotation.Generated;
/**
*
* @see <a href="http://docs.aws.amazon.com/goto/WebAPI/elasticloadbalancingv2-2015-12-01/SetIpAddressType"
* target="_top">AWS API Documentation</a>
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class SetIpAddressTypeResult extends com.amazonaws.AmazonWebServiceResult<com.amazonaws.ResponseMetadata> implements Serializable, Cloneable {
/**
* <p>
* The IP address type.
* </p>
*/
private String ipAddressType;
/**
* <p>
* The IP address type.
* </p>
*
* @param ipAddressType
* The IP address type.
* @see IpAddressType
*/
public void setIpAddressType(String ipAddressType) {
this.ipAddressType = ipAddressType;
}
/**
* <p>
* The IP address type.
* </p>
*
* @return The IP address type.
* @see IpAddressType
*/
@com.fasterxml.jackson.annotation.JsonProperty("ipAddressType")
public String getIpAddressType() {
return this.ipAddressType;
}
/**
* <p>
* The IP address type.
* </p>
*
* @param ipAddressType
* The IP address type.
* @return Returns a reference to this object so that method calls can be chained together.
* @see IpAddressType
*/
public SetIpAddressTypeResult withIpAddressType(String ipAddressType) {
setIpAddressType(ipAddressType);
return this;
}
/**
* <p>
* The IP address type.
* </p>
*
* @param ipAddressType
* The IP address type.
* @see IpAddressType
*/
@com.fasterxml.jackson.annotation.JsonIgnore
public void setIpAddressType(IpAddressType ipAddressType) {
withIpAddressType(ipAddressType);
}
/**
* <p>
* The IP address type.
* </p>
*
* @param ipAddressType
* The IP address type.
* @return Returns a reference to this object so that method calls can be chained together.
* @see IpAddressType
*/
public SetIpAddressTypeResult withIpAddressType(IpAddressType ipAddressType) {
this.ipAddressType = ipAddressType.toString();
return this;
}
/**
* Returns a string representation of this object; useful for testing and debugging.
*
* @return A string representation of this object.
*
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (getIpAddressType() != null)
sb.append("IpAddressType: ").append(getIpAddressType());
sb.append("}");
return sb.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (obj instanceof SetIpAddressTypeResult == false)
return false;
SetIpAddressTypeResult other = (SetIpAddressTypeResult) obj;
if (other.getIpAddressType() == null ^ this.getIpAddressType() == null)
return false;
if (other.getIpAddressType() != null && other.getIpAddressType().equals(this.getIpAddressType()) == false)
return false;
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int hashCode = 1;
hashCode = prime * hashCode + ((getIpAddressType() == null) ? 0 : getIpAddressType().hashCode());
return hashCode;
}
@Override
public SetIpAddressTypeResult clone() {
try {
return (SetIpAddressTypeResult) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
}
| [
""
] | |
4046f9b942fab6cf465513ea5c1c0e34709c7917 | 47bc46564f98f1416c49c28e6b958aef35e0072d | /app/src/main/java/com/harish/postit/Utils/FilePaths.java | a628f2bddbf62c1029b7f4d635b0ff626b052164 | [] | no_license | harishtanu007/PostIt | 13d2555798ba9b0365f40205c4b443960d81f543 | 3446ad58decc96d3026a2b4299dcff6f0035be66 | refs/heads/main | 2022-12-29T15:39:03.790133 | 2020-10-19T05:48:36 | 2020-10-19T05:48:36 | 303,054,088 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 558 | java | package com.harish.postit.Utils;
import android.content.Context;
import android.os.Environment;
/**
* Created by User on 7/24/2017.
*/
public class FilePaths {
//"storage/emulated/0"
public String ROOT_DIR = Environment.getExternalStorageDirectory().getPath();
public String PICTURES = ROOT_DIR + "/Pictures";
public String CAMERA = ROOT_DIR + "/DCIM/camera";
public String STORIES = ROOT_DIR + "/Stories";
public String FIREBASE_STORY_STORAGE = "stories/users";
public String FIREBASE_IMAGE_STORAGE = "photos/users/";
}
| [
"33089746+harishkunta@users.noreply.github.com"
] | 33089746+harishkunta@users.noreply.github.com |
84c4a047cd2ac7f827c6cea2151955cadcd2a729 | 989ad0dde27ebe4dafa98a61c549d2ea19033929 | /Memento13/src/main/java/com/zx/memento/note/NoteManager.java | 901cbb6a3f9e127562beafbd6db7d69cfdaab4b9 | [] | no_license | MrXiong/ZXDesignPattern | f9867aa235550e7d30a958c9f763f23d5740340b | 8ea306405294a123e52af048afd2abb58195f36c | refs/heads/master | 2021-08-12T01:41:45.408969 | 2017-11-14T08:50:32 | 2017-11-14T08:50:32 | 110,664,489 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 820 | java | package com.zx.memento.note;
import java.util.ArrayList;
import java.util.List;
/**
* Created by user on 2017/11/10.
*/
public class NoteManager {
private int MAX = 30;
private List<NoteMemoto> mMemotos = new ArrayList<>(MAX);
private int mIndex;
public void saveMemoto(NoteMemoto noteMemoto) {
if (mMemotos.size() > MAX) {
mMemotos.remove(0);
}
mMemotos.add(noteMemoto);
mIndex = mMemotos.size() - 1;
}
//获取上一个存档
public NoteMemoto getPrevMemoto() {
mIndex = mIndex > 0 ? --mIndex : mIndex;
return mMemotos.get(mIndex);
}
//获取下一个存档
public NoteMemoto getNextMemoto() {
mIndex = mIndex < mMemotos.size() - 1 ? ++mIndex : mIndex;
return mMemotos.get(mIndex);
}
}
| [
"zxmainwy@163.com"
] | zxmainwy@163.com |
0a603128f5671d53d5d8bddfad19a39afab70967 | 16f282c2166176326f44d6f234cc3378c3ad7d7c | /HibernateSpringBootBatchJsonFileForkJoin/src/main/java/com/citylots/forkjoin/JoiningComponent.java | b59c54ffa4085d8dd3696925202814a8237a0b67 | [
"Apache-2.0"
] | permissive | rzbrth/Hibernate-SpringBoot | 78ad0b764764aff74ad95a7c0dd1aa6b611fea1b | e91e1e0b2c8f2129fa0b9559701ac94ca68206af | refs/heads/master | 2020-12-13T05:59:51.024153 | 2020-01-15T16:38:39 | 2020-01-15T16:38:39 | 234,330,053 | 1 | 0 | Apache-2.0 | 2020-01-16T13:47:45 | 2020-01-16T13:47:44 | null | UTF-8 | Java | false | false | 1,285 | java | package com.citylots.forkjoin;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@Component
public class JoiningComponent {
private static final String SQL_INSERT = "INSERT INTO lots (lot) VALUES (?)";
private final JdbcTemplate jdbcTemplate;
public JoiningComponent(JdbcTemplate jdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
}
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void executeBatch(List<String> jsonList) {
jdbcTemplate.batchUpdate(SQL_INSERT,
new BatchPreparedStatementSetter() {
@Override
public void setValues(PreparedStatement pStmt, int i)
throws SQLException {
String jsonLine = jsonList.get(i);
pStmt.setString(1, jsonLine);
}
@Override
public int getBatchSize() {
return jsonList.size();
}
});
}
}
| [
"leoprivacy@yahoo.com"
] | leoprivacy@yahoo.com |
a419011d82a32029750f88655d150ef2eb069cab | 71a95830f0fd335ec0451d901c8214ada0ccf468 | /maintainclient/src/main/java/com/hdb/cloud/client/maintainclient/model/CorPersonFlat.java | a2c9abf373ba1ae3cb62a7b6eb3056e663b784f7 | [] | no_license | mvuppu/springcloud | 9fa261e8ee88b5b73ac17578eaea97317d48a4c2 | ac62658ce3ba8e5372103f37c98f7d2f2662ee5b | refs/heads/master | 2020-03-29T13:18:51.111880 | 2018-09-23T05:51:00 | 2018-09-23T05:51:00 | 149,951,635 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,005 | java | package com.hdb.cloud.client.maintainclient.model;
import java.io.Serializable;
public class CorPersonFlat implements Serializable{
private String firstname;
private String lastname;
private String middlename;
private String flatnumber;
public String getFirstname() {
return firstname;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public String getLastname() {
return lastname;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public String getMiddlename() {
return middlename;
}
public void setMiddlename(String middlename) {
this.middlename = middlename;
}
public String getBlocknumber() {
return blocknumber;
}
public void setBlocknumber(String blocknumber) {
this.blocknumber = blocknumber;
}
public String getFlatnumber() {
return flatnumber;
}
public void setFlatnumber(String flatnumber) {
this.flatnumber = flatnumber;
}
private String blocknumber;
}
| [
"noreply@github.com"
] | mvuppu.noreply@github.com |
d99b282d9d8dee9a52204fdb155d8974da068f13 | baed9a2d544226ba8226cfaa720eac01752a78dd | /src/main/java/annotate4j/core/runner/ConsoleRunner.java | 9265d51b2eabaec679d251a4c055d32cf2ae4a8c | [
"Apache-2.0"
] | permissive | esavin/annotate4j-core | a9ff48140d5168caedec3566a23f8a9285cff675 | 4fd5e5b7e132c20aa85a8cccca33e4f99a705898 | refs/heads/master | 2020-05-07T10:45:46.974429 | 2020-02-14T20:42:20 | 2020-02-14T20:42:20 | 180,430,765 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,640 | java | package annotate4j.core.runner;
import javax.management.*;
/**
* @author Eugene Savin
*/
public class ConsoleRunner implements ConsoleRunnerMBean {
private boolean stopFlag = false;
public static void main(String args[]) {
ConsoleRunner runner = new ConsoleRunner();
MBeanServer server = MBeanServerFactory.createMBeanServer("ConsoleRunner");
try {
server.registerMBean(runner, new ObjectName("ConsoleRunnerAgent:name=consoleRunner"));
} catch (MalformedObjectNameException mone) {
mone.printStackTrace();
} catch (NotCompliantMBeanException e) {
e.printStackTrace();
} catch (InstanceAlreadyExistsException e) {
e.printStackTrace();
} catch (MBeanRegistrationException e) {
e.printStackTrace();
}
runner.run();
}
public void run() {
Runner r = new Runner();
new Thread(r).start();
}
private class Runner implements Runnable {
@Override
public void run() {
int counter = 0;
synchronized (this) {
while (!isStopFlag()) {
try {
this.wait();
} catch (InterruptedException ie) {
ie.printStackTrace();
}
System.out.println("hello " + counter);
counter++;
}
}
}
}
public synchronized void setStopFlag(boolean f) {
stopFlag = f;
}
public boolean isStopFlag() {
return stopFlag;
}
}
| [
"eugene.savin@wari.com"
] | eugene.savin@wari.com |
6dbe74746f46c8ee43ea9bcd8ba035625be96adf | e31f5630dfeac06c029d32a99f0587f2e579d822 | /src/firefly/java/edu/caltech/ipac/firefly/visualize/MovingTargetContext.java | 68562d25dc8d43b7dddc05f03f41c3db0790b281 | [] | no_license | RajeshPatadiya/firefly-3 | 27a949c31a9c801bb813970315a4c294051d6b74 | b1c73d5d4bfa3dabde1b50d2c71a5dd394f56820 | refs/heads/master | 2020-03-07T20:39:16.751950 | 2017-11-16T03:47:05 | 2017-11-16T03:47:05 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,125 | java | /*
* License information at https://github.com/Caltech-IPAC/firefly/blob/master/License.txt
*/
package edu.caltech.ipac.firefly.visualize;
/**
* User: roby
* Date: 9/6/13
* Time: 2:05 PM
*/
import edu.caltech.ipac.util.ComparisonUtil;
import edu.caltech.ipac.visualize.plot.WorldPt;
/**
* @author Trey Roby
*/
public class MovingTargetContext {
private WorldPt positionOnImage;
private String name;
public MovingTargetContext(WorldPt positionOnImage, String name) {
this.positionOnImage = positionOnImage;
this.name = name;
}
public WorldPt getPositionOnImage() {
return positionOnImage;
}
public String getName() {
return name;
}
@Override
public boolean equals(Object obj) {
if (this==obj) return true;
boolean retval= false;
if (obj instanceof MovingTargetContext) {
MovingTargetContext mtc= (MovingTargetContext)obj;
retval= ComparisonUtil.equals(positionOnImage,mtc.positionOnImage) &&
ComparisonUtil.equals(name,name);
}
return retval;
}
}
| [
"roby@ipac.caltech.edu"
] | roby@ipac.caltech.edu |
23450f056ba0d2603f1a1d264b5d3ef72cadfffa | 0f3923f30e4b0132f518b58f5397f21598776d65 | /src/ua/nedz/margo/patterns/creation/abstract_factory/Main.java | af179412af2ac2639e5b1e534748199861dc2df5 | [] | no_license | leveretka/Patterns | 5138b8d276e60170241db715ee7f04d3095c4e57 | 993ffcaeb347464d105ae61eae202fe15f002fa4 | refs/heads/master | 2021-01-01T03:39:16.946898 | 2016-04-27T12:54:07 | 2016-04-27T12:54:07 | 57,213,057 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 493 | java | package ua.nedz.margo.patterns.creation.abstract_factory;
public class Main {
public static void main(String[] args) {
AbstractFactory factory1 = new WhiteFactory();
AbstractFactory factory2 = new BlackFactory();
factory1.createCircle().draw();
factory1.createRectangle().draw();
factory1.createSquare().draw();
factory2.createSquare().draw();
factory2.createRectangle().draw();
factory2.createCircle().draw();
}
}
| [
"leveretka@github.com"
] | leveretka@github.com |
5694e437cd2394a5872feffe22b73d05be7bcba9 | eada1fadc0ae0a50cdc28b098e6ca32f37b97ae7 | /src/by/epam/auctionhouse/command/impl/user/SignOutCommand.java | 19542e863615fb6ca879f129cd3133312e93c57d | [] | no_license | kirillslepuho/AuctionHouse | 7556a0830ade784498d8340d89ef7663e9b9bb0e | 43572087e7672e53a2d6aaae57e3cf8370c2590c | refs/heads/master | 2020-05-24T19:59:11.212697 | 2017-05-16T08:55:46 | 2017-05-16T08:55:46 | 84,872,522 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,838 | java | package by.epam.auctionhouse.command.impl.user;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import by.epam.auctionhouse.command.ICommand;
import by.epam.auctionhouse.service.ClientService;
import by.epam.auctionhouse.service.exception.ServiceException;
import by.epam.auctionhouse.service.factory.ServiceFactory;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
/**
* Provides an implementation of the ICommand interface.
*
* @author Kirill Slepuho
* @see ICommand
*/
public class SignOutCommand implements ICommand{
private final static String PATH = "/AuctionHouse/Controller?command=go_to_main_page";
private final static Logger logger = LogManager.getLogger("errorLogger");
/**
* Gets HttpSession from the request parameters and passes them to the signOut method in the ClientService, redirect to main page.
*
* @param httpRequest the HttpServletRequest object that contains the request the client made of the servlet
* @param httpResponse the HttpServletResponse object that contains the response the servlet returns to the client
* @see ServiceException
* @see ClientService
*/
@Override
public void execute(HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws ServletException, IOException {
ServiceFactory serviceFactory = ServiceFactory.getInstance();
ClientService clientService = serviceFactory.getClientService();
try {
HttpSession httpSession = httpRequest.getSession(false);
clientService.signOut(httpSession);
httpResponse.sendRedirect(PATH);
} catch (ServiceException exception) {
logger.error("Error while logging out");
}
}
}
| [
"kirillslepuho@mail.ru"
] | kirillslepuho@mail.ru |
1fc2f0c817cd165ed9ede2393e8b7e397ca86d33 | 727d6e4a1feb9f49fcd2fc546743dfa3c777f639 | /java/objects/Need.java | 62b59f5e9231eb230b2fd76f6bb36328b2b90b37 | [
"Apache-2.0"
] | permissive | hyperrixel/aaion | 54d558825b619eda75152ade4e493a32a913abb7 | 71ed7dbb67cff82d116e4472be7649c46ed20d72 | refs/heads/main | 2022-12-25T06:50:21.763301 | 2020-10-04T21:55:01 | 2020-10-04T21:55:01 | 300,715,947 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 868 | java | package com.hyperrixel.aaion.objects;
import com.hyperrixel.aaion.tools.MeasureUnit;
public class Need {
protected String name;
protected MeasureUnit unit;
protected double prefix;
protected Measure measureNow;
protected LabeledMeasureList measureHistory;
public Need(String name, MeasureUnit unit) {
this.name = name;
this.unit = unit;
this.prefix = 1;
measureHistory = new LabeledMeasureList(this.unit, this.prefix);
}
public Need(String name, Measure measure) {
this.name = name;
this.unit = measure.getUnit();
this.prefix = measure.getPrefix();
measureHistory = new LabeledMeasureList(this.unit, this.prefix);
measureHistory.add(measure, "initial value");
}
public String getName() {
return name;
}
}
| [
"noreply@github.com"
] | hyperrixel.noreply@github.com |
874089161aacf2951f6896f08f8bfb715dd006b0 | 78084e3dddfa39e14e335e5642ce58e3cecba9b9 | /usbcan/src/com/itu/ErrorType.java | 06741eadd38dd49dc0a1e802a957fe56b1e5a63c | [] | no_license | JinhuiLee/USB-CAN | 8a0cc6e42e3fcee48eb23242a4ac22ea1562aeb1 | 06e540a4ad30e29b316045fc6f4e71a5f4f497b3 | refs/heads/master | 2020-05-26T20:51:49.747961 | 2017-02-26T03:02:51 | 2017-02-26T03:02:51 | 82,505,200 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,108 | java | package com.itu;
public class ErrorType {
public static final int ERR_SUCCESS = 0;
public static final int ERR_PARAMETER_NULL = -1;
public static final int ERR_INPUT_DATA_TOO_MUCH = -2;
public static final int ERR_INPUT_DATA_TOO_LESS = -3;
public static final int ERR_INPUT_DATA_ILLEGALITY = -4;
public static final int ERR_USB_WRITE_DATA = -5;
public static final int ERR_USB_READ_DATA = -6;
public static final int ERR_READ_NO_DATA = -7;
public static final int ERR_OPEN_DEVICE = -8;
public static final int ERR_CLOSE_DEVICE = -9;
public static final int ERR_EXECUTE_CMD = -10;
public static final int ERR_SELECT_DEVICE = -11;
public static final int ERR_DEVICE_OPENED = -12;
public static final int ERR_DEVICE_NOTOPEN = -13;
public static final int ERR_BUFFER_OVERFLOW = -14;
public static final int ERR_DEVICE_NOTEXIST = -15;
public static final int ERR_LOAD_KERNELDLL = -16;
public static final int ERR_CMD_FAILED = -17;
public static final int ERR_BUFFER_CREATE = -18;
public static final int ERR_NO_PERMISSIONS = -19;
}
| [
"jinhui.li@pku.edu.cn"
] | jinhui.li@pku.edu.cn |
882a6844fa1cb9f529279b63a99abf354edcabbf | 836d06197d44867ed0c171ad27cf884bf5387869 | /src/ftp/Command.java | e6f1eea66c4ead5219780e943ba59bea0e7f9507 | [] | no_license | LeapDawn/ftpClient | 6dae01b003482c8cb0d50f6b457230f3f4885e66 | 44c40cfee26d3151ef58f9047ba893d8d20cc216 | refs/heads/master | 2021-01-18T20:47:27.992002 | 2017-08-17T01:46:20 | 2017-08-17T01:46:20 | 100,548,944 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,486 | java | package ftp;
public class Command {
private String command; // 命令
private String arg1; // 参数1
private String arg2; // 参数2
private String pwd; // 当前工作目录
public Command() {
super();
}
public Command(String inputStr, String pwd) {
if (inputStr != null && !inputStr.trim().equals("")) {
String[] split = inputStr.split(" ");
String[] tmp = new String[]{"","",""};
int tindex = 0;
for (int i = 0; i < split.length && tindex < tmp.length; i++) {
if (!"".equals(split[i])) {
tmp[tindex] = split[i];
tindex++;
}
}
this.command = tmp[0];
this.arg1 = tmp[1];
this.arg2 = tmp[2];
}
String temp = pwd != null ? pwd.trim() : "/";
this.pwd = temp.endsWith("/") ? temp :temp + "/";
}
public String getCommand() {
return command != null ? command.trim() : "";
}
public void setCommand(String command) {
this.command = command;
}
public String getArg1() {
if (arg1 == null) {
return "";
} else if (arg1.startsWith("/")) {
return arg1.trim();
} else {
return pwd + arg1.trim();
}
}
public void setArg1(String arg1) {
this.arg1 = arg1;
}
public String getArg2() {
return arg2 != null ? arg2.trim() : "";
}
public void setArg2(String arg2) {
this.arg2 = arg2;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
String temp = pwd != null ? pwd.trim() : "/";
this.pwd = temp.endsWith("/") ? temp :temp + "/";
}
}
| [
"zqh_evan@163.com"
] | zqh_evan@163.com |
a987fac666b54e77b243f662367533cbba410600 | 770bb4bb42384f90f53d1fbcd17a1b6ba56cb990 | /src/compiler/SyntacticalAnalyzer/Declarations/Constant/ConstantValueWrapper.java | 6a76aa377acbe603ed48b8eb028d3f37fc288698 | [] | no_license | Supremist/SignalCompiler | 35f216066f5cc5d849012160535fbca297729d01 | ef8e87e70f849928503da58507e9877b308702ed | refs/heads/master | 2020-04-06T04:08:53.907930 | 2016-06-04T16:05:40 | 2016-06-04T16:05:40 | 59,789,866 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,498 | java | package compiler.SyntacticalAnalyzer.Declarations.Constant;
import compiler.SyntacticalAnalyzer.Compilable;
import compiler.SyntacticalAnalyzer.CompilationInfo;
import compiler.Exceptions.CompileException;
import compiler.SyntacticalAnalyzer.Declarations.Variable.VariableType;
/**
* Created by supremist on 6/1/16.
*/
public class ConstantValueWrapper implements Compilable, IConstantValue{
private ConstantValue mValue;
public ConstantValueWrapper(ConstantValue value){
mValue = value;
}
public static String floatToAsm(double value){
//TODO Add mantissa and power generation
return String.valueOf(value);
}
public String getCode(){
if (mValue.isInteger()){
return String.valueOf(mValue.getInteger());
}
else if(mValue.isFloat()){
return floatToAsm(mValue.getReal());
}
else {
return "<"+String.valueOf(mValue.getReal()) + ", " +
String.valueOf(mValue.getImagine()) + "> ";
}
}
@Override
public StringBuilder toAsmCode(CompilationInfo info) throws CompileException {
StringBuilder buffer = new StringBuilder();
if (mValue.isInteger()){
buffer.append(VariableType.BaseType.INTEGER.getAsmType()).append(" ")
.append(mValue.getInteger()).append("\n");
}
else if(mValue.isFloat()){
buffer.append(VariableType.BaseType.FLOAT.getAsmType()).append(" ")
.append(floatToAsm(mValue.getReal())).append("\n");
}
else if(mValue.isComplexInt()){
buffer.append(String.format(
VariableType.COMPLEX_IMPLEMENTATION_TEMPLATE,
VariableType.BaseType.INTEGER.toString(),
String.valueOf((int) mValue.getReal()),
String.valueOf((int) mValue.getImagine())));
}
else {
buffer.append(String.format(
VariableType.COMPLEX_IMPLEMENTATION_TEMPLATE,
VariableType.BaseType.FLOAT.toString(),
String.valueOf(mValue.getReal()),
String.valueOf(mValue.getImagine())));
}
return buffer;
}
@Override
public void Compile(CompilationInfo info) throws CompileException {
}
@Override
public ConstantValue getConstantValue(IConstantTable constantTable) throws CompileException {
return mValue;
}
}
| [
"sergkarv@gmail.com"
] | sergkarv@gmail.com |
38736a70025c3beddad33e2a447e6f1b7dee59dc | 5097169d4280786d24b5bf8b4fcae3e4811470a9 | /app/src/main/java/com/patel/movies/ui/SpaceItemDecoration.java | d6ae43d9bd13097b3ea36ac44d87066b578af476 | [] | no_license | neelpatel6294/MvpMovieapp | b894a6563fba058b011542e240db8a776bd52d24 | 2598c2699195bc33692d0ce7718038ccc53bf6ed | refs/heads/master | 2020-05-05T08:03:09.949875 | 2019-04-06T15:09:58 | 2019-04-06T15:09:58 | 179,848,427 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 728 | java | package com.patel.movies.ui;
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class SpaceItemDecoration extends RecyclerView.ItemDecoration {
private final int mSpace;
public SpaceItemDecoration(int space) {
this.mSpace = space;
}
@Override
public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
outRect.left = mSpace;
outRect.right = mSpace;
outRect.bottom = mSpace;
//Add top margin only for the first item to avoid double space between items
if (parent.getChildAdapterPosition(view) == 0) {
outRect.top = mSpace;
}
}
}
| [
"neelpatel6294@gmail.com"
] | neelpatel6294@gmail.com |
0db5a9fcc1b6366407df3f0021bbd7f6eaaf8ad0 | 79ffb5cdc6165cc6af0f838ca57b910bfa8fe3f3 | /BlinovTasks/src/blinov/chapter1/Hello.java | 780a5e389d0e4348f31bc3309d9b62a72ccd3907 | [] | no_license | ISken86/test-repo | 18f2d24ae2a91c8cab914ff523ac72182cc6fa21 | 6ba0dea32066fb8d3705db8baebfaad7492b7dbf | refs/heads/master | 2021-01-10T18:51:10.314391 | 2016-05-04T15:26:54 | 2016-05-04T15:26:54 | 57,993,540 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,685 | java | package blinov.chapter1;
import java.io.*;
public class Hello {
public static void main(String[] args) {
//Hello.sayHello(); // 1.1
//Hello.reverseArgsOrder(args);// 1.2
//Hello.analizeArrayOfNumbers();
System.out.println((-5) % 3);
}
private static void sayHello() {
try(BufferedReader br = new BufferedReader(new
InputStreamReader(System.in))) {
System.out.print("Enter your name: ");
String name = br.readLine();
System.out.println();
System.out.println("Hello " + name);
} catch (IOException ex) {
System.out.println("IOException ocured.");
}
}
private static void reverseArgsOrder(String[] args) {
for(int i = args.length - 1; i >= 0; i--) {
System.out.print(args[i] + " ");
}
System.out.println();
}
private static void analizeArrayOfNumbers() {
String str = "";
try(BufferedReader br = new BufferedReader(new
InputStreamReader(System.in))) {
System.out.println("Enter numbers separated with space...");
str = br.readLine();
} catch (IOException ex) {
System.out.println("IOException ocured.");
}
String[] subStrings = str.split(" ");
int[] numbers = new int[subStrings.length];
for(int i = 0; i < subStrings.length; i++) {
numbers[i] = new Integer(subStrings[i]);
}
System.out.print("You entered : ");
for(int n : numbers) {
System.out.print(n + " ");
}
System.out.println();
//Even numbers
System.out.println("Even numbers : ");
for(int n : numbers) {
if(n % 2 == 0) {
System.out.print(n + " ");
}
}
System.out.println();
//Odd numbers
System.out.println("Odd numbers : ");
for(int n : numbers) {
if(n % 2 != 0) {
System.out.print(n + " ");
}
}
System.out.println();
//The largest and the smallest numbers
int largest = 0, smallest = 0;
largest = smallest = numbers[0];
for(int n : numbers) {
if(n > largest) {
largest = n;
continue;
}
if(n < smallest) {
smallest = n;
continue;
}
}
System.out.println("The largets number is " + largest);
System.out.println("The smallest number is " + smallest);
System.out.println();
//Numbers that divided by 3 or 9
System.out.println("Numbers that divided by 3 or 9 :");
for(int n : numbers) {
if((n % 9 == 0) || (n % 3 == 0)) {
System.out.print(n + " ");
}
}
System.out.println();
//Numbers that divided by 5 and 7
System.out.println("Numbers that divided by 5 and 7 :");
for(int n : numbers) {
if((n % 5 == 0) && (n % 7 == 0)) {
System.out.print(n + " ");
}
}
System.out.println();
}
}
| [
"aleks@gmail.com"
] | aleks@gmail.com |
0fcc7a3a8597124df54d228f5df65e8ba80e8484 | 8b1e74ee4a7d93b91981f5b82a2f9eb04ebe40f3 | /src/main/java/com/kenesis/domain/FileListVO.java | a245bedb847c7e02163fe71d46cb1d5b675bab73 | [] | no_license | Luyin/Kenesis | e29af0a89f48f64c9e79e8a8aae7d78df9992be5 | c15179e353ca6a3c0852d093b5a26a178801e380 | refs/heads/master | 2021-01-19T11:39:04.773012 | 2017-05-18T14:41:37 | 2017-05-18T14:41:37 | 87,985,757 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 578 | java | package com.kenesis.domain;
public class FileListVO {
private String path;
private String type;
private String fileid;
public String getPath() {
return path;
}
public void setPath(String path) {
this.path = path;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getFileid() {
return fileid;
}
public void setFileid(String fileid) {
this.fileid = fileid;
}
@Override
public String toString() {
return "FileListVO [path=" + path + ", type=" + type + ", fileid=" + fileid + "]";
}
}
| [
"myraous@gmail.com"
] | myraous@gmail.com |
b023f5f7848f9ef28e488e43e5614a8e350110fe | 8af1164bac943cef64e41bae312223c3c0e38114 | /results-java/shardingjdbc--sharding-jdbc/9d43ac188b63db59f0543dda55d227747a1398cf/before/TableRule.java | f5ee0e90af9791c77baf74cc902a3e36c1cd7e8b | [] | no_license | fracz/refactor-extractor | 3ae45c97cc63f26d5cb8b92003b12f74cc9973a9 | dd5e82bfcc376e74a99e18c2bf54c95676914272 | refs/heads/master | 2021-01-19T06:50:08.211003 | 2018-11-30T13:00:57 | 2018-11-30T13:00:57 | 87,353,478 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 11,512 | java | /*
* Copyright 1999-2015 dangdang.com.
* <p>
* 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.
* </p>
*/
package com.dangdang.ddframe.rdb.sharding.api.rule;
import com.dangdang.ddframe.rdb.sharding.keygen.KeyGenerator;
import com.dangdang.ddframe.rdb.sharding.keygen.KeyGeneratorFactory;
import com.dangdang.ddframe.rdb.sharding.routing.strategy.ShardingStrategy;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
/**
* Table rule configuration.
*
* @author zhangliang
*/
@Getter
@ToString
public final class TableRule {
private final String logicTable;
private final boolean dynamic;
private final List<DataNode> actualTables;
private final ShardingStrategy databaseShardingStrategy;
private final ShardingStrategy tableShardingStrategy;
private final String generateKeyColumn;
private final KeyGenerator keyGenerator;
private TableRule(final String logicTable, final boolean dynamic, final List<String> actualTables, final DataSourceRule dataSourceRule, final Collection<String> dataSourceNames,
final ShardingStrategy databaseShardingStrategy, final ShardingStrategy tableShardingStrategy,
final String generateKeyColumn, final KeyGenerator keyGenerator) {
Preconditions.checkNotNull(logicTable);
this.logicTable = logicTable;
this.dynamic = dynamic;
this.databaseShardingStrategy = databaseShardingStrategy;
this.tableShardingStrategy = tableShardingStrategy;
if (dynamic) {
Preconditions.checkNotNull(dataSourceRule);
this.actualTables = generateDataNodes(dataSourceRule);
} else if (null == actualTables || actualTables.isEmpty()) {
Preconditions.checkNotNull(dataSourceRule);
this.actualTables = generateDataNodes(Collections.singletonList(logicTable), dataSourceRule, dataSourceNames);
} else {
this.actualTables = generateDataNodes(actualTables, dataSourceRule, dataSourceNames);
}
this.generateKeyColumn = generateKeyColumn;
this.keyGenerator = keyGenerator;
}
/**
* Get table rule builder.
*
* @param logicTable logic table name
* @return table rule builder
*/
public static TableRuleBuilder builder(final String logicTable) {
return new TableRuleBuilder(logicTable);
}
private List<DataNode> generateDataNodes(final DataSourceRule dataSourceRule) {
Collection<String> dataSourceNames = dataSourceRule.getDataSourceNames();
List<DataNode> result = new ArrayList<>(dataSourceNames.size());
for (String each : dataSourceNames) {
result.add(new DynamicDataNode(each));
}
return result;
}
private List<DataNode> generateDataNodes(final List<String> actualTables, final DataSourceRule dataSourceRule, final Collection<String> actualDataSourceNames) {
Collection<String> dataSourceNames = getDataSourceNames(dataSourceRule, actualDataSourceNames);
List<DataNode> result = new ArrayList<>(actualTables.size() * (dataSourceNames.isEmpty() ? 1 : dataSourceNames.size()));
for (String actualTable : actualTables) {
if (DataNode.isValidDataNode(actualTable)) {
result.add(new DataNode(actualTable));
} else {
for (String dataSourceName : dataSourceNames) {
result.add(new DataNode(dataSourceName, actualTable));
}
}
}
return result;
}
private Collection<String> getDataSourceNames(final DataSourceRule dataSourceRule, final Collection<String> actualDataSourceNames) {
if (null == dataSourceRule) {
return Collections.emptyList();
}
if (null == actualDataSourceNames || actualDataSourceNames.isEmpty()) {
return dataSourceRule.getDataSourceNames();
}
return actualDataSourceNames;
}
/**
* Get actual data nodes via target data source and actual tables.
*
* @param targetDataSource target data source name
* @param targetTables target actual tables.
* @return actual data nodes
*/
public Collection<DataNode> getActualDataNodes(final String targetDataSource, final Collection<String> targetTables) {
return dynamic ? getDynamicDataNodes(targetDataSource, targetTables) : getStaticDataNodes(targetDataSource, targetTables);
}
private Collection<DataNode> getDynamicDataNodes(final String targetDataSource, final Collection<String> targetTables) {
Collection<DataNode> result = new LinkedHashSet<>(targetTables.size());
for (String each : targetTables) {
result.add(new DataNode(targetDataSource, each));
}
return result;
}
private Collection<DataNode> getStaticDataNodes(final String targetDataSource, final Collection<String> targetTables) {
Collection<DataNode> result = new LinkedHashSet<>(actualTables.size());
for (DataNode each : actualTables) {
if (targetDataSource.equals(each.getDataSourceName()) && targetTables.contains(each.getTableName())) {
result.add(each);
}
}
return result;
}
/**
* Get actual data source names.
*
* @return actual data source names
*/
public Collection<String> getActualDatasourceNames() {
Collection<String> result = new LinkedHashSet<>(actualTables.size());
for (DataNode each : actualTables) {
result.add(each.getDataSourceName());
}
return result;
}
/**
* Get actual table names via target data source name.
*
* @param targetDataSource target data source name
* @return names of actual tables
*/
public Collection<String> getActualTableNames(final String targetDataSource) {
Collection<String> result = new LinkedHashSet<>(actualTables.size());
for (DataNode each : actualTables) {
if (targetDataSource.equals(each.getDataSourceName())) {
result.add(each.getTableName());
}
}
return result;
}
int findActualTableIndex(final String dataSourceName, final String actualTableName) {
int result = 0;
for (DataNode each : actualTables) {
if (each.getDataSourceName().equalsIgnoreCase(dataSourceName) && each.getTableName().equalsIgnoreCase(actualTableName)) {
return result;
}
result++;
}
return -1;
}
/**
* Table rule builder..
*/
@RequiredArgsConstructor
public static class TableRuleBuilder {
private final String logicTable;
private boolean dynamic;
private final List<String> actualTables = new ArrayList<>();
private DataSourceRule dataSourceRule;
private final Collection<String> dataSourceNames = new LinkedList<>();
private ShardingStrategy databaseShardingStrategy;
private ShardingStrategy tableShardingStrategy;
private String generateKeyColumn;
private Class<? extends KeyGenerator> keyGeneratorClass;
/**
* Build is dynamic table.
*
* @param dynamic is dynamic table
* @return this builder
*/
public TableRuleBuilder dynamic(final boolean dynamic) {
this.dynamic = dynamic;
return this;
}
/**
* Build actual tables.
*
* @param actualTables actual tables
* @return this builder
*/
public TableRuleBuilder actualTables(final String... actualTables) {
this.actualTables.clear();
this.actualTables.addAll(Arrays.asList(actualTables));
return this;
}
/**
* Build data source rule.
*
* @param dataSourceRule data source rule
* @return this builder
*/
public TableRuleBuilder dataSourceRule(final DataSourceRule dataSourceRule) {
this.dataSourceRule = dataSourceRule;
return this;
}
/**
* Build data sources's names.
*
* @param dataSourceNames data sources's names
* @return this builder
*/
public TableRuleBuilder dataSourceNames(final String... dataSourceNames) {
this.dataSourceNames.clear();
this.dataSourceNames.addAll(Arrays.asList(dataSourceNames));
return this;
}
/**
* Build database sharding strategy.
*
* @param databaseShardingStrategy database sharding strategy
* @return this builder
*/
public TableRuleBuilder databaseShardingStrategy(final ShardingStrategy databaseShardingStrategy) {
this.databaseShardingStrategy = databaseShardingStrategy;
return this;
}
/**
* Build table sharding strategy.
*
* @param tableShardingStrategy table sharding strategy
* @return this builder
*/
public TableRuleBuilder tableShardingStrategy(final ShardingStrategy tableShardingStrategy) {
this.tableShardingStrategy = tableShardingStrategy;
return this;
}
/**
* Build generate key column.
*
* @param generateKeyColumn generate key column
* @return this builder
*/
public TableRuleBuilder generateKeyColumn(final String generateKeyColumn) {
this.generateKeyColumn = generateKeyColumn;
return this;
}
/**
* Build generate key column.
*
* @param generateKeyColumn generate key column
* @param keyGeneratorClass key generator class
* @return this builder
*/
public TableRuleBuilder generateKeyColumn(final String generateKeyColumn, final Class<? extends KeyGenerator> keyGeneratorClass) {
this.generateKeyColumn = generateKeyColumn;
this.keyGeneratorClass = keyGeneratorClass;
return this;
}
/**
* Build table rule.
*
* @return built table rule
*/
public TableRule build() {
KeyGenerator keyGenerator = null;
if (null != generateKeyColumn && null != keyGeneratorClass) {
keyGenerator = KeyGeneratorFactory.createKeyGenerator(keyGeneratorClass);
}
return new TableRule(logicTable, dynamic, actualTables, dataSourceRule, dataSourceNames, databaseShardingStrategy, tableShardingStrategy, generateKeyColumn, keyGenerator);
}
}
} | [
"fraczwojciech@gmail.com"
] | fraczwojciech@gmail.com |
1fe5ccca3798df0eb3816ea4ca87fbc9ec038611 | a875ae2a14b30728b981ee0e4ffa382225743f15 | /src/main/java/com/event/sourcing/controller/RoleController.java | c9bb7b9d58d39ab54e9a2ecb05f510e347d76982 | [] | no_license | mattsibs/event-sourcing | 8b0c26a6169facfa12105e09a3b753358e78008d | 26edd4252b33123cd4d0bf4e2a0324b4a141ac33 | refs/heads/master | 2021-01-01T20:19:13.589490 | 2017-07-30T16:48:09 | 2017-07-30T16:48:09 | 98,811,123 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,272 | java | package com.event.sourcing.controller;
import com.event.sourcing.model.permission.Permission;
import com.event.sourcing.model.role.Role;
import com.event.sourcing.model.user.User;
import com.event.sourcing.service.permission.PermissionService;
import com.event.sourcing.service.role.RoleService;
import com.event.sourcing.service.user.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class RoleController {
private final RoleService roleService;
private final UserService userService;
private final PermissionService permissionService;
public RoleController(final RoleService roleService, final UserService userService,
final PermissionService permissionService) {
this.roleService = roleService;
this.userService = userService;
this.permissionService = permissionService;
}
@GetMapping(value = "/role")
@ResponseBody
public List<Role> findRoles() {
return roleService.findAll();
}
@GetMapping(value = "/permission")
@ResponseBody
public List<Permission> findPermissions() {
return permissionService.findPermissions();
}
@PostMapping(value = "/role")
public void create() {
Permission permission = new Permission();
permission.setAction(Permission.Action.CREATE);
permission.setResource(Permission.Resource.USER);
roleService.create("role1", permissionService.findPermissions());
}
@PutMapping(value = "role/{roleId}")
public void grantRole(@PathVariable final long roleId, @RequestParam final long userId) {
User user = userService.find(userId).orElseThrow(() -> new RuntimeException("not-found"));
Role role = roleService.find(roleId).orElseThrow(() -> new RuntimeException("not-found"));
roleService.grantRole(user, role);
}
}
| [
"matthew.sibson.test@gmail.com"
] | matthew.sibson.test@gmail.com |
b3a8ec3748d290b67e69bed1ad64aae37598668d | 5f1f01b0b9435f296c89d3f4a1cca3e0893fa30b | /apex-squid/src/test/java/org/fundacionjala/enforce/sonarqube/apex/parser/grammar/ApexGrammarGenericTypeTest.java | 4f8964999201eea41cce26bb4d8f42e2afe4e19e | [
"MIT"
] | permissive | rahulAppirio/enforce-sonarqube-plugin | 05df5957a09322319f7661fde5bfcc4e88942ae4 | 47a7b1ece1f43a940997b04d4c25d605fe855c4b | refs/heads/master | 2020-04-10T05:33:33.329569 | 2018-03-11T13:43:09 | 2018-03-11T13:43:09 | 124,265,212 | 0 | 0 | MIT | 2018-03-11T13:30:32 | 2018-03-07T16:43:05 | Java | UTF-8 | Java | false | false | 1,070 | java | /*
* Copyright (c) Fundacion Jala. All rights reserved.
* Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
package org.fundacionjala.enforce.sonarqube.apex.parser.grammar;
import org.fundacionjala.enforce.sonarqube.apex.parser.ApexRuleTest;
import org.junit.Before;
import org.junit.Test;
import static org.fundacionjala.enforce.sonarqube.apex.api.grammar.ApexGrammarRuleKey.GENERIC_TYPE;
import static org.sonar.sslr.tests.Assertions.assertThat;
public class ApexGrammarGenericTypeTest extends ApexRuleTest {
@Before
public void init() {
setRootRule(GENERIC_TYPE);
}
@Test
public void positiveRules() {
assertThat(parser)
.matches("<SomeType>")
.matches("<SomeType, SomeOtherType>")
.matches("<list<set<someType>>>");
}
@Test
public void negativeRules() {
assertThat(parser)
.notMatches("<someType")
.notMatches("<sometype,>")
.notMatches("<>");
}
}
| [
"Vicente.Rodriguez@Jalasoft.com"
] | Vicente.Rodriguez@Jalasoft.com |
f29435fa44c68cfadd7162f937e6298b9089a737 | 163b25322ab3d06513c489ee15e865a138dfecad | /src/ru/innopolis/lesson_8_online_classloaders/Magic.java | ed7e6b9ccb855988533ce6a9100a488f46503f7d | [] | no_license | kesch9/STC12 | fa6524e40412749fa986a7bd17090f0ef38beee0 | 82393987a51e17934392e1ecee09248fdec7e46d | refs/heads/master | 2020-03-26T17:13:04.796290 | 2018-09-27T17:46:30 | 2018-09-27T17:46:30 | 145,148,450 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 144 | java | package ru.innopolis.lesson_8_online_classloaders;
public class Magic {
public void cast(){
System.out.println("Lumus");
}
}
| [
"kashenkovsergej@yandex.ru"
] | kashenkovsergej@yandex.ru |
99c25c638e73cd8d2c1c77d6207dd0f1742a14c2 | 20f5b63eff35695fdc1d9b6338999afdfe16be91 | /libWSLive/src/main/java/me/lake/librestreaming/core/ColorHelper.java | be7b6e41b09f39ae17fbfc6f781d427497ed81d6 | [] | no_license | WangShuo1143368701/WSLiveDemo | 402aa4ee454943cac8a99df3ca01683a6d326be0 | 0d7f8ff2a977cb75b84356d10bca9be5663ac28c | refs/heads/master | 2022-05-18T19:48:53.623124 | 2022-04-04T06:24:43 | 2022-04-04T06:24:43 | 123,081,789 | 2,050 | 562 | null | 2019-03-02T18:56:37 | 2018-02-27T06:10:53 | Java | UTF-8 | Java | false | false | 642 | java | package me.lake.librestreaming.core;
@SuppressWarnings("all")
public class ColorHelper {
static public native void NV21TOYUV420SP(byte[] src, byte[] dst, int YSize);
static public native void NV21TOYUV420P(byte[] src, byte[] dst, int YSize);
static public native void YUV420SPTOYUV420P(byte[] src, byte[] dst, int YSize);
static public native void NV21TOARGB(byte[] src, int[] dst, int width,int height);
static public native void FIXGLPIXEL(int[] src,int[] dst, int width,int height);
//slow
static public native void NV21Transform(byte[] src, byte[] dst, int srcwidth,int srcheight,int directionFlag);
}
| [
"wangshuo@chaonengjie.com"
] | wangshuo@chaonengjie.com |
bbbb5a9756861fe939aceeb92ac8b9c2d6d1fb1a | 471bf60a824d5466c0a917e175528aec811e6c01 | /2016-01-Shenzhen/Team 02 - AaaS/aaas-gui/src/main/java/cn/odl/daaas/app/topodemo/uitopo/NextLink.java | 491e873019ebd85a2ddbbb3398c05e90d48d4e51 | [] | no_license | donaldh/opendaylight-bootcamps | 4468c5629218c4274be5656bbd9cb0015c9035f7 | 03268f9b8db88e03692f44590960f97185fa05d3 | refs/heads/master | 2020-12-25T21:56:01.486848 | 2016-05-13T01:27:24 | 2016-05-13T01:27:24 | 58,688,772 | 0 | 1 | null | 2016-05-13T01:20:03 | 2016-05-13T01:20:03 | null | UTF-8 | Java | false | false | 585 | java | package cn.odl.daaas.app.topodemo.uitopo;
public class NextLink {
private String source;
private String target;
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getTarget() {
return target;
}
public void setTarget(String target) {
this.target = target;
}
@Override
public String toString()
{
String res = "source = " + getSource() + " "
+ "target = " + getTarget() + "\n";
return res;
}
}
| [
"ermcgann@cisco.com"
] | ermcgann@cisco.com |
65fe6b784bedb52e8a12524faa03e91a839ee883 | 36073e09d6a12a275cc85901317159e7fffa909e | /JetBrains_kotlin/modifiedFiles/10/old/TranslationUtils.java | 7dc8f4ca5b0359a38cdb84aa3629382512ae63ac | [] | no_license | monperrus/bug-fixes-saner16 | a867810451ddf45e2aaea7734d6d0c25db12904f | 9ce6e057763db3ed048561e954f7aedec43d4f1a | refs/heads/master | 2020-03-28T16:00:18.017068 | 2018-11-14T13:48:57 | 2018-11-14T13:48:57 | 148,648,848 | 3 | 0 | null | null | null | null | UTF-8 | Java | false | false | 21,232 | java | /*
* Copyright 2010-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.k2js.translate.utils;
import com.google.dart.compiler.backend.js.ast.*;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.Function;
import com.intellij.util.containers.ContainerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.impl.AnonymousFunctionDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.OverrideResolver;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.k2js.translate.context.TemporaryConstVariable;
import org.jetbrains.k2js.translate.context.TranslationContext;
import org.jetbrains.k2js.translate.general.Translation;
import java.util.*;
import static com.google.dart.compiler.backend.js.ast.JsBinaryOperator.*;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqName;
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.isAnonymousObject;
import static org.jetbrains.k2js.translate.context.Namer.getKotlinBackingFieldName;
import static org.jetbrains.k2js.translate.utils.BindingUtils.getCallableDescriptorForOperationExpression;
import static org.jetbrains.k2js.translate.utils.JsAstUtils.*;
public final class TranslationUtils {
public static final Comparator<FunctionDescriptor> OVERLOADED_FUNCTION_COMPARATOR = new OverloadedFunctionComparator();
private TranslationUtils() {
}
@NotNull
public static JsPropertyInitializer translateFunctionAsEcma5PropertyDescriptor(@NotNull JsFunction function,
@NotNull FunctionDescriptor descriptor,
@NotNull TranslationContext context) {
if (JsDescriptorUtils.isExtension(descriptor)) {
return translateExtensionFunctionAsEcma5DataDescriptor(function, descriptor, context);
}
else {
JsStringLiteral getOrSet = context.program().getStringLiteral(descriptor instanceof PropertyGetterDescriptor ? "get" : "set");
return new JsPropertyInitializer(getOrSet, function);
}
}
@NotNull
public static JsFunction simpleReturnFunction(@NotNull JsScope functionScope, @NotNull JsExpression returnExpression) {
return new JsFunction(functionScope, new JsBlock(new JsReturn(returnExpression)));
}
@NotNull
private static JsPropertyInitializer translateExtensionFunctionAsEcma5DataDescriptor(@NotNull JsFunction function,
@NotNull FunctionDescriptor descriptor, @NotNull TranslationContext context) {
JsObjectLiteral meta = createDataDescriptor(function, descriptor.getModality().isOverridable(), false);
return new JsPropertyInitializer(context.getNameForDescriptor(descriptor).makeRef(), meta);
}
@NotNull
public static JsExpression translateExclForBinaryEqualLikeExpr(@NotNull JsBinaryOperation baseBinaryExpression) {
return new JsBinaryOperation(notOperator(baseBinaryExpression.getOperator()), baseBinaryExpression.getArg1(), baseBinaryExpression.getArg2());
}
public static boolean isEqualLikeOperator(@NotNull JsBinaryOperator operator) {
return notOperator(operator) != null;
}
@Nullable
private static JsBinaryOperator notOperator(@NotNull JsBinaryOperator operator) {
switch (operator) {
case REF_EQ:
return REF_NEQ;
case REF_NEQ:
return REF_EQ;
case EQ:
return NEQ;
case NEQ:
return EQ;
default:
return null;
}
}
@NotNull
public static JsBinaryOperation isNullCheck(@NotNull JsExpression expressionToCheck) {
return nullCheck(expressionToCheck, false);
}
@NotNull
public static JsBinaryOperation isNotNullCheck(@NotNull JsExpression expressionToCheck) {
return nullCheck(expressionToCheck, true);
}
@NotNull
public static JsBinaryOperation nullCheck(@NotNull JsExpression expressionToCheck, boolean isNegated) {
JsBinaryOperator operator = isNegated ? JsBinaryOperator.NEQ : JsBinaryOperator.EQ;
return new JsBinaryOperation(operator, expressionToCheck, JsLiteral.NULL);
}
@NotNull
public static JsConditional notNullConditional(
@NotNull JsExpression expression,
@NotNull JsExpression elseExpression,
@NotNull TranslationContext context
) {
JsExpression testExpression;
JsExpression thenExpression;
if (isCacheNeeded(expression)) {
TemporaryConstVariable tempVar = context.getOrDeclareTemporaryConstVariable(expression);
testExpression = isNotNullCheck(tempVar.value());
thenExpression = tempVar.value();
}
else {
testExpression = isNotNullCheck(expression);
thenExpression = expression;
}
return new JsConditional(testExpression, thenExpression, elseExpression);
}
@NotNull
public static String getMangledName(@NotNull PropertyDescriptor descriptor, @NotNull String suggestedName) {
return getStableMangledName(suggestedName, getFqName(descriptor).asString());
}
@NotNull
public static String getSuggestedName(@NotNull DeclarationDescriptor descriptor) {
String suggestedName = descriptor.getName().asString();
if (descriptor instanceof FunctionDescriptor) {
suggestedName = getMangledName((FunctionDescriptor) descriptor);
}
return suggestedName;
}
@NotNull
private static String getMangledName(@NotNull FunctionDescriptor descriptor) {
if (needsStableMangling(descriptor)) {
return getStableMangledName(descriptor);
}
return getSimpleMangledName(descriptor);
}
//TODO extend logic for nested/inner declarations
private static boolean needsStableMangling(FunctionDescriptor descriptor) {
// Use stable mangling for overrides because we use stable mangling when any function inside a overridable declaration
// for avoid clashing names when inheritance.
if (JsDescriptorUtils.isOverride(descriptor)) {
return true;
}
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
if (containingDeclaration instanceof PackageFragmentDescriptor) {
return descriptor.getVisibility().isPublicAPI();
}
else if (containingDeclaration instanceof ClassDescriptor) {
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
// Use stable mangling when it inside a overridable declaration for avoid clashing names when inheritance.
if (classDescriptor.getModality().isOverridable()) {
return true;
}
// Don't use stable mangling when it inside a non-public API declaration.
if (!classDescriptor.getVisibility().isPublicAPI()) {
return false;
}
// Ignore the `protected` visibility because it can be use outside a containing declaration
// only when the containing declaration is overridable.
if (descriptor.getVisibility() == Visibilities.PUBLIC) {
return true;
}
return false;
}
assert containingDeclaration instanceof CallableMemberDescriptor :
"containingDeclaration for descriptor have unsupported type for mangling, " +
"descriptor: " + descriptor + ", containingDeclaration: " + containingDeclaration;
return false;
}
@NotNull
public static String getMangledMemberNameForExplicitDelegation(@NotNull String suggestedName, FqName classFqName, FqName typeFqName) {
String forCalculateId = classFqName.asString() + ":" + typeFqName.asString();
return getStableMangledName(suggestedName, forCalculateId);
}
@NotNull
private static String getStableMangledName(@NotNull String suggestedName, String forCalculateId) {
int absHashCode = Math.abs(forCalculateId.hashCode());
String suffix = absHashCode == 0 ? "" : ("_" + Integer.toString(absHashCode, Character.MAX_RADIX) + "$");
return suggestedName + suffix;
}
@NotNull
private static String getStableMangledName(@NotNull FunctionDescriptor descriptor) {
return getStableMangledName(descriptor.getName().asString(), getArgumentTypesAsString(descriptor));
}
@NotNull
private static String getSimpleMangledName(@NotNull final FunctionDescriptor descriptor) {
DeclarationDescriptor declaration = descriptor.getContainingDeclaration();
JetScope jetScope = null;
if (declaration instanceof PackageFragmentDescriptor) {
jetScope = ((PackageFragmentDescriptor) declaration).getMemberScope();
}
else if (declaration instanceof ClassDescriptor) {
jetScope = ((ClassDescriptor) declaration).getDefaultType().getMemberScope();
}
int counter = 0;
if (jetScope != null) {
Collection<DeclarationDescriptor> declarations = jetScope.getAllDescriptors();
List<FunctionDescriptor> overloadedFunctions = ContainerUtil.mapNotNull(declarations, new Function<DeclarationDescriptor, FunctionDescriptor>() {
@Override
public FunctionDescriptor fun(DeclarationDescriptor declarationDescriptor) {
if (!(declarationDescriptor instanceof FunctionDescriptor)) return null;
FunctionDescriptor functionDescriptor = (FunctionDescriptor) declarationDescriptor;
String name = AnnotationsUtils.getNameForAnnotatedObjectWithOverrides(functionDescriptor);
// when name == null it's mean that it's not native.
if (name == null) {
// skip functions without arguments, because we don't use mangling for them
if (needsStableMangling(functionDescriptor) && !functionDescriptor.getValueParameters().isEmpty()) return null;
name = declarationDescriptor.getName().asString();
}
return descriptor.getName().asString().equals(name) ? functionDescriptor : null;
}
});
if (overloadedFunctions.size() > 1) {
Collections.sort(overloadedFunctions, OVERLOADED_FUNCTION_COMPARATOR);
counter = ContainerUtil.indexOfIdentity(overloadedFunctions, descriptor);
assert counter >= 0;
}
}
String name = descriptor.getName().asString();
return counter == 0 ? name : name + '_' + counter;
}
private static String getArgumentTypesAsString(FunctionDescriptor descriptor) {
StringBuilder argTypes = new StringBuilder();
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
if (receiverParameter != null) {
argTypes.append(getJetTypeFqName(receiverParameter.getType())).append(".");
}
argTypes.append(StringUtil.join(descriptor.getValueParameters(), new Function<ValueParameterDescriptor, String>() {
@Override
public String fun(ValueParameterDescriptor descriptor) {
return getJetTypeFqName(descriptor.getType());
}
}, ","));
return argTypes.toString();
}
@NotNull
public static String getJetTypeFqName(@NotNull JetType jetType) {
ClassifierDescriptor declaration = jetType.getConstructor().getDeclarationDescriptor();
assert declaration != null;
if (declaration instanceof TypeParameterDescriptor) {
return getJetTypeFqName(((TypeParameterDescriptor) declaration).getUpperBoundsAsType());
}
return getFqName(declaration).asString();
}
@NotNull
public static JsNameRef backingFieldReference(@NotNull TranslationContext context,
@NotNull PropertyDescriptor descriptor) {
JsName backingFieldName = context.getNameForDescriptor(descriptor);
if(!JsDescriptorUtils.isSimpleFinalProperty(descriptor)) {
String backingFieldMangledName;
if (descriptor.getVisibility() != Visibilities.PRIVATE) {
backingFieldMangledName = getMangledName(descriptor, getKotlinBackingFieldName(backingFieldName.getIdent()));
} else {
backingFieldMangledName = getKotlinBackingFieldName(backingFieldName.getIdent());
}
backingFieldName = context.declarePropertyOrPropertyAccessorName(descriptor, backingFieldMangledName, false);
}
return new JsNameRef(backingFieldName, JsLiteral.THIS);
}
@NotNull
public static JsExpression assignmentToBackingField(@NotNull TranslationContext context,
@NotNull PropertyDescriptor descriptor,
@NotNull JsExpression assignTo) {
JsNameRef backingFieldReference = backingFieldReference(context, descriptor);
return assignment(backingFieldReference, assignTo);
}
@Nullable
public static JsExpression translateInitializerForProperty(@NotNull JetProperty declaration,
@NotNull TranslationContext context) {
JsExpression jsInitExpression = null;
JetExpression initializer = declaration.getInitializer();
if (initializer != null) {
jsInitExpression = Translation.translateAsExpression(initializer, context);
}
return jsInitExpression;
}
@NotNull
public static JsExpression translateBaseExpression(@NotNull TranslationContext context,
@NotNull JetUnaryExpression expression) {
JetExpression baseExpression = PsiUtils.getBaseExpression(expression);
return Translation.translateAsExpression(baseExpression, context);
}
@NotNull
public static JsExpression translateLeftExpression(@NotNull TranslationContext context,
@NotNull JetBinaryExpression expression) {
return translateLeftExpression(context, expression, context.dynamicContext().jsBlock());
}
@NotNull
public static JsExpression translateLeftExpression(
@NotNull TranslationContext context,
@NotNull JetBinaryExpression expression,
@NotNull JsBlock block
) {
JetExpression left = expression.getLeft();
assert left != null : "Binary expression should have a left expression: " + expression.getText();
return Translation.translateAsExpression(left, context, block);
}
@NotNull
public static JsExpression translateRightExpression(@NotNull TranslationContext context,
@NotNull JetBinaryExpression expression) {
return translateRightExpression(context, expression, context.dynamicContext().jsBlock());
}
@NotNull
public static JsExpression translateRightExpression(
@NotNull TranslationContext context,
@NotNull JetBinaryExpression expression,
@NotNull JsBlock block) {
JetExpression rightExpression = expression.getRight();
assert rightExpression != null : "Binary expression should have a right expression";
return Translation.translateAsExpression(rightExpression, context, block);
}
public static boolean hasCorrespondingFunctionIntrinsic(@NotNull TranslationContext context,
@NotNull JetOperationExpression expression) {
CallableDescriptor operationDescriptor = getCallableDescriptorForOperationExpression(context.bindingContext(), expression);
if (operationDescriptor == null || !(operationDescriptor instanceof FunctionDescriptor)) return true;
if (context.intrinsics().getFunctionIntrinsics().getIntrinsic((FunctionDescriptor) operationDescriptor).exists()) return true;
return false;
}
@NotNull
public static List<JsExpression> generateInvocationArguments(@NotNull JsExpression receiver, @NotNull List<JsExpression> arguments) {
if (arguments.isEmpty()) {
return Collections.singletonList(receiver);
}
List<JsExpression> argumentList = new ArrayList<JsExpression>(1 + arguments.size());
argumentList.add(receiver);
argumentList.addAll(arguments);
return argumentList;
}
public static boolean isCacheNeeded(@NotNull JsExpression expression) {
return !(expression instanceof JsLiteral) &&
(!(expression instanceof JsNameRef) || ((JsNameRef) expression).getQualifier() != null);
}
@NotNull
public static JsConditional sure(@NotNull JsExpression expression, @NotNull TranslationContext context) {
JsInvocation throwNPE = new JsInvocation(context.namer().throwNPEFunctionRef());
JsConditional ensureNotNull = notNullConditional(expression, throwNPE, context);
JsExpression thenExpression = ensureNotNull.getThenExpression();
if (thenExpression instanceof JsNameRef) {
// associate (cache) ensureNotNull expression to new TemporaryConstVariable with same name.
context.associateExpressionToLazyValue(ensureNotNull,
new TemporaryConstVariable(((JsNameRef) thenExpression).getName(), ensureNotNull));
}
return ensureNotNull;
}
@NotNull
public static String getSuggestedNameForInnerDeclaration(TranslationContext context, DeclarationDescriptor descriptor) {
String suggestedName = "";
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
//noinspection ConstantConditions
if (containingDeclaration != null &&
!(containingDeclaration instanceof ClassOrPackageFragmentDescriptor) &&
!(containingDeclaration instanceof AnonymousFunctionDescriptor) &&
!(containingDeclaration instanceof ConstructorDescriptor && isAnonymousObject(containingDeclaration.getContainingDeclaration()))) {
suggestedName = context.getNameForDescriptor(containingDeclaration).getIdent();
}
if (!suggestedName.isEmpty() && !suggestedName.endsWith("$")) {
suggestedName += "$";
}
if (descriptor.getName().isSpecial()) {
suggestedName += "f";
}
else {
suggestedName += context.getNameForDescriptor(descriptor).getIdent();
}
return suggestedName;
}
private static class OverloadedFunctionComparator implements Comparator<FunctionDescriptor> {
@Override
public int compare(@NotNull FunctionDescriptor a, @NotNull FunctionDescriptor b) {
// native functions first
if (isNativeOrOverrideNative(a)) {
if (!isNativeOrOverrideNative(b)) return -1;
}
else if (isNativeOrOverrideNative(b)) {
return 1;
}
// be visibility
// Actually "internal" > "private", but we want to have less number for "internal", so compare b with a instead of a with b.
Integer result = Visibilities.compare(b.getVisibility(), a.getVisibility());
if (result != null && result != 0) return result;
// by arity
int aArity = arity(a);
int bArity = arity(b);
if (aArity != bArity) return aArity - bArity;
// by stringify argument types
String aArguments = getArgumentTypesAsString(a);
String bArguments = getArgumentTypesAsString(b);
assert aArguments != bArguments;
return aArguments.compareTo(bArguments);
}
private static int arity(FunctionDescriptor descriptor) {
return descriptor.getValueParameters().size() + (descriptor.getReceiverParameter() == null ? 0 : 1);
}
private static boolean isNativeOrOverrideNative(FunctionDescriptor descriptor) {
if (AnnotationsUtils.isNativeObject(descriptor)) return true;
Set<FunctionDescriptor> declarations = OverrideResolver.getAllOverriddenDeclarations(descriptor);
for (FunctionDescriptor memberDescriptor : declarations) {
if (AnnotationsUtils.isNativeObject(memberDescriptor)) return true;
}
return false;
}
}
}
| [
"martin.monperrus@gnieh.org"
] | martin.monperrus@gnieh.org |
95e7346f85716ee4461f6db5db1d9a4b7a8de88f | 36f38c5424e6b985d14bb4ac088b6ef91b1c8fed | /src/main/java/com/github/davidhoyt/playground/functional/Pure.java | 93336b622f1a05fed31d08778fb88a998f410986 | [] | no_license | davidhoyt/playground-java | f42dc1a3ca5902cdf8246246ba5a239c80432f29 | 241307c0074b57e9887436e3f66b840d15dfe27e | refs/heads/master | 2021-01-18T17:28:25.373629 | 2015-09-14T16:35:10 | 2015-09-14T16:39:00 | 37,367,158 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 125 | java | package com.github.davidhoyt.playground.functional;
public interface Pure<M extends Pure<M, A>, A> {
M pure(A given);
}
| [
"dhoyt@netflix.com"
] | dhoyt@netflix.com |
349c68f2f60a35e943a9ca17defdd973fff18874 | 2844628d3eb4c436692c5a275b15bc1dc1e2445e | /taotao-portal/src/main/java/com/taotao/portal/pojo/SearchResult.java | 65a0f543af638dbab23b9c41e0434261d00bc1f4 | [] | no_license | fzwgit/TaoTao | 37064f5cf19e2cfaebb08a02868879e328c319f7 | d959ce4acbecbee6fc598202c30d356e4c1ff66a | refs/heads/master | 2021-09-18T22:07:08.609704 | 2018-07-20T06:37:22 | 2018-07-20T06:37:22 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 781 | java | package com.taotao.portal.pojo;
import java.util.List;
public class SearchResult
{
//商品列表
private List<Item> list;
//总记录数
private long recordCount;
//当前的总页数
private long pageCount;
//当前页页码
private long curPage;
public List<Item> getList()
{
return list;
}
public void setList(List<Item> list)
{
this.list = list;
}
public long getRecordCount()
{
return recordCount;
}
public void setRecordCount(long recordCount)
{
this.recordCount = recordCount;
}
public long getPageCount()
{
return pageCount;
}
public void setPageCount(long pageCount)
{
this.pageCount = pageCount;
}
public long getCurPage()
{
return curPage;
}
public void setCurPage(long curPage)
{
this.curPage = curPage;
}
}
| [
"fangzhiwei@keyone.club"
] | fangzhiwei@keyone.club |
a739a13ea0d6a444b88e7e584eef04b8cd2577ba | 071a9fa7cfee0d1bf784f6591cd8d07c6b2a2495 | /corpus/norm-class/eclipse.jdt.core/1467.java | ef3254648822630a6f62d2102137d316de662824 | [
"MIT"
] | permissive | masud-technope/ACER-Replication-Package-ASE2017 | 41a7603117f01382e7e16f2f6ae899e6ff3ad6bb | cb7318a729eb1403004d451a164c851af2d81f7a | refs/heads/master | 2021-06-21T02:19:43.602864 | 2021-02-13T20:44:09 | 2021-02-13T20:44:09 | 187,748,164 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,575 | java | copyright ibm corporation rights reserved program accompanying materials terms eclipse license accompanies distribution http eclipse org legal epl html contributors ibm corporation initial api implementation org eclipse jdt core tests eval junit framework test org eclipse jdt core compiler categorized problem categorizedproblem org eclipse jdt internal eval evaluation result evaluationresult org eclipse jdt internal eval i requestor irequestor org eclipse jdt internal eval install exception installexception sanity test i evaluation result ievaluationresult depth tests variable test variabletest code snippet test codesnippettest suppress warnings suppresswarnings rawtypes sanity test evaluation result sanitytestevaluationresult evaluation test evaluationtest evaluation result evaluationresult result creates sanity evaluation result test sanityevaluationresulttest sanity test evaluation result sanitytestevaluationresult string initializes test evaluation result coming evaluation code snippet set up setup exception set up setup i requestor irequestor requestor requestor accept result acceptresult evaluation result evaluationresult eval result evalresult sanity test evaluation result sanitytestevaluationresult result eval result evalresult context evaluate to char array tochararray get env getenv get compiler options getcompileroptions requestor get problem factory getproblemfactory install exception installexception error get message getmessage test suite setup suite setupsuite test class testclass test class testclass sanity test evaluation result sanitytestevaluationresult sanity test i evaluation result ievaluationresult get evaluation type getevaluationtype test get evaluation type testgetevaluationtype evaluation type evaluationtype result get evaluation type getevaluationtype assert equals assertequals evaluation type evaluation result evaluationresult code snippet evaluation type evaluationtype sanity test i evaluation result ievaluationresult get problems getproblems test get problems testgetproblems categorized problem categorizedproblem problems result get problems getproblems assert true asserttrue problems problems problems length sanity test i evaluation result ievaluationresult get value getvalue test get value testgetvalue tbd implemented sanity test i evaluation result ievaluationresult get value display string getvaluedisplaystring test get value display string testgetvaluedisplaystring display string displaystring result get value display string getvaluedisplaystring assert equals assertequals display string to char array tochararray display string displaystring sanity test i evaluation result ievaluationresult get value type name getvaluetypename test get value type name testgetvaluetypename type name typename result get value type name getvaluetypename assert equals assertequals type to char array tochararray type name typename sanity test i evaluation result ievaluationresult has errors haserrors test has errors testhaserrors assert true asserttrue result errors result has errors haserrors sanity test i evaluation result ievaluationresult has problems hasproblems test has problems testhasproblems assert true asserttrue result problems result has problems hasproblems sanity test i evaluation result ievaluationresult has value hasvalue test has value testhasvalue assert true asserttrue result result has value hasvalue sanity test i evaluation result ievaluationresult has warnings haswarnings test has warnings testhaswarnings assert true asserttrue result warnings result has warnings haswarnings | [
"masudcseku@gmail.com"
] | masudcseku@gmail.com |
354d363d90eb9235cf866faa449cb8774a730b32 | e760326163cfa14b2779934c9e71a7f7a76dfb35 | /src_oci/com/amarsoft/app/oci/ws/decision/prepare/CmdExp30perCnt.java | 93cc8686a5291e37a204af0a1a5484b80f7ab29f | [] | no_license | gaosy5945/easylifecore | 41e68bba747eb03f28edecf18d9d2ce2755db9d8 | 3fd630be1d990d0e66452735e84841536af5b9ba | refs/heads/master | 2020-05-19T17:25:29.370637 | 2016-09-21T08:29:40 | 2016-09-21T08:29:40 | null | 0 | 0 | null | null | null | null | GB18030 | Java | false | false | 1,733 | java | package com.amarsoft.app.oci.ws.decision.prepare;
import java.util.List;
import com.amarsoft.app.crqs2.i.bean.IReportMessage;
import com.amarsoft.app.crqs2.i.bean.one.CreditDetail;
import com.amarsoft.app.crqs2.i.bean.three.AwardCreditInfoParent;
import com.amarsoft.app.crqs2.i.bean.three.RepayInfoParent;
import com.amarsoft.app.crqs2.i.bean.two.Loancard;
/**
* 信用额度使用率Exposure为30%的信用卡个数(只包含贷记卡)
*
* @author t-lizp
*
*/
public class CmdExp30perCnt implements Command {
@Override
public Object execute(IReportMessage message) {
int count = 0;
CreditDetail detail = message.getCreditDetail();
if(detail == null) return 0;
List<Loancard> list = detail.getLoancard();
for (Loancard loancard : list) {
Double creditLimitAmount = getLimitAmout(loancard);//授信额度
Double usedCreditLimitAmount = getUsedAmount(loancard);//已用额度
if (creditLimitAmount > 0) {
double ratio = usedCreditLimitAmount / creditLimitAmount;
if (ratio > 0.3) count = count + 1;
}
}
return count;
}
private Double getUsedAmount(Loancard loancard) {
RepayInfoParent repayInfoParent = loancard.getRepayInfo();
String amount2 = repayInfoParent.getUsedCreditLimitAmount();
if (amount2 == null || amount2 == "") amount2 = "0";
Double usedCreditLimitAmount = Double.parseDouble(amount2);
return usedCreditLimitAmount;
}
private Double getLimitAmout(Loancard loancard) {
AwardCreditInfoParent awardCreditInfoParent = loancard.getAwardCreditInfo();
String amount = awardCreditInfoParent.getCreditLimitAmount();
if (amount == null || amount == "") amount = "0";
Double creditLimitAmount = Double.parseDouble(amount);
return creditLimitAmount;
}
}
| [
"jianbin_wang@139.com"
] | jianbin_wang@139.com |
6de50103e967724e706ae3d8f730d28859481a6e | 5ac3c341968b8337042e3992f5b75f27132d48de | /Heightmap/src/main/java/com/roger/heightmap/util/TextResourceReader.java | 93d797e2bcb72a21d1ee98e60428f0c12ee1f52d | [] | no_license | BigDendi/HelloNDK | 70360da9265679d2025c9a5fe139bf24cfdec91b | 11c5981f304a4734f9c62bc938c99fedd2eb33a5 | refs/heads/master | 2021-08-14T08:23:31.651562 | 2017-11-15T03:29:05 | 2017-11-15T03:29:10 | 110,777,949 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,117 | java | package com.roger.heightmap.util;
import android.content.Context;
import android.content.res.Resources;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
/**
* Created by Administrator on 2016/6/30.
*/
public class TextResourceReader {
public static String readTextFileFromResource(Context context, int resourceId) {
StringBuilder body = new StringBuilder();
try {
InputStream inputStream = context.getResources().openRawResource(resourceId);
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
String nextLine;
while ((nextLine = bufferedReader.readLine()) != null) {
body.append(nextLine);
body.append('\n');
}
} catch (IOException e) {
throw new RuntimeException("Could not open resource:" + resourceId, e);
} catch (Resources.NotFoundException nfe) {
throw new RuntimeException("Resource not found :" + resourceId, nfe);
}
return body.toString();
}
}
| [
"xiang2713@yeah.net"
] | xiang2713@yeah.net |
e5e501b0efb3965dbc38cea03bb9f7672eb81ca1 | aee496309b2380e0e3a472d881a127519f5f41b8 | /smartwebapp/src/main/java/mn/ineg/app/entity/MScheduler.java | 0757bd5a9c8897ec3858aa9abbf08da7e78f2788 | [] | no_license | khangaikhuu/smartwebapplication | 0cf1ab316063460197ac5e009396ffccdad1f917 | ce73e1bdabf490d53c12b5895176f11075b792f0 | refs/heads/master | 2021-01-21T16:16:06.257244 | 2017-05-22T08:59:29 | 2017-05-22T08:59:29 | 91,882,944 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,004 | 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 mn.ineg.app.entity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.Size;
/**
*
* @author developer
*/
@Entity
@Table(name = "m_scheduler")
public class MScheduler implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Basic(optional = false)
@Column(name = "id")
private Integer id;
@Size(max = 500)
@Column(name = "name")
private String name;
@Column(name = "date")
@Temporal(TemporalType.DATE)
private Date date;
@Size(max = 500)
@Column(name = "file_path")
private String filePath;
@JoinColumn(name = "type_id", referencedColumnName = "id")
@ManyToOne
private MScheduleType typeId;
public MScheduler() {
}
public MScheduler(Integer id) {
this.id = id;
}
public Integer getId() {
return id;
}
public void setId(Integer int1) {
this.id = int1;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Date getDate() {
return date;
}
public void setDate(Date date) {
this.date = date;
}
@JsonProperty("path")
public String getFilePath() {
return filePath;
}
public void setFilePath(String filePath) {
this.filePath = filePath;
}
@JsonIgnore
public MScheduleType getTypeId() {
return typeId;
}
public void setTypeId(MScheduleType typeId) {
this.typeId = typeId;
}
@Override
public int hashCode() {
int hash = 0;
hash += (id != null ? id.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof MScheduler)) {
return false;
}
MScheduler other = (MScheduler) object;
if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
return false;
}
return true;
}
@Override
public String toString() {
return "mn.ineg.model.MScheduler[ int1=" + id + " ]";
}
}
| [
"khangaikhuu@googlemail.com"
] | khangaikhuu@googlemail.com |
a2f62426ca78d73f91b53023c2cc4342f39851ba | eb19061c5c6012b2a20bac5d02357fec013d0618 | /src/test/java/com/ashwinchat/starsimulator/TestNormalStar.java | 7452069ba1c56f5b0b5e2a801c2f2a4127c476fe | [] | no_license | ashwinath/maple-star-simulator-discord-telegram | 0b0526b4f1c50f8d8d9553f7abd08bc162793283 | d06f90e579a428ecf899262ff0789f020bd40c6e | refs/heads/master | 2021-01-19T19:24:26.654979 | 2017-05-17T16:58:15 | 2017-05-17T16:58:15 | 88,416,132 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 835 | java | package com.ashwinchat.starsimulator;
import com.ashwinchat.starsimulator.enums.ItemType;
import com.ashwinchat.starsimulator.impl.StarSimulatorImpl;
import com.ashwinchat.starsimulator.pojos.StarResult;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
public class TestNormalStar {
private StarSimulatorImpl simulator;
@Before
public void init() {
this.simulator = StarSimulatorImpl.getInstance();
}
@Test
public void testStarringDestroy() {
StarResult result = this.simulator.runSimulation(18, ItemType.NORMAL);
Assert.assertTrue(result.getDestroyCount() > 0);
}
@Test
public void testNoDestroy() {
StarResult result = this.simulator.runSimulation(17, ItemType.NORMAL);
Assert.assertTrue(result.getDestroyCount() == 0);
}
}
| [
"ashwinath@hotmail.com"
] | ashwinath@hotmail.com |
8e81f62a3fd5d94566a0c2c1ab04e2d98dcc63b3 | f909ec612f17254be491c3ef9cdc1f0b186e8daf | /springboot_plugin/springboot_mybatis/src/main/java/cn/springboot/service/auth/impl/UserServiceImpl.java | 228d17daa328a99990cea66587e4683c182aa43d | [] | no_license | kingking888/jun_java_plugin | 8853f845f242ce51aaf01dc996ed88784395fd83 | f57e31fa496d488fc96b7e9bab3c245f90db5f21 | refs/heads/master | 2023-06-04T19:30:29.554726 | 2021-06-24T17:19:55 | 2021-06-24T17:19:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,794 | java | package cn.springboot.service.auth.impl;
import cn.springboot.common.constants.Constants;
import cn.springboot.common.exception.BusinessException;
import cn.springboot.common.util.salt.Digests;
import cn.springboot.common.util.salt.Encodes;
import cn.springboot.config.table.FactoryAboutKey;
import cn.springboot.config.table.TablesPKEnum;
import cn.springboot.mapper.auth.RoleMapper;
import cn.springboot.mapper.auth.UserMapper;
import cn.springboot.mapper.auth.UserRoleMapper;
import cn.springboot.model.auth.Role;
import cn.springboot.model.auth.User;
import cn.springboot.model.auth.UserRole;
import cn.springboot.service.auth.UserService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Calendar;
import java.util.List;
@Service("userService")
public class UserServiceImpl implements UserService {
private final static Logger log = LoggerFactory.getLogger(UserServiceImpl.class);
public static final String HASH_ALGORITHM = "SHA-1";
public static final int HASH_INTERATIONS = 1024;
private static final int SALT_SIZE = 8;
@Autowired
private RoleMapper roleMapper;
@Autowired
private UserRoleMapper userRoleMapper;
@Autowired
private UserMapper userMapper;
/**
* 设定安全的密码,生成随机的salt并经过1024次 sha-1 hash
*/
private void entryptPassword(User user) {
byte[] salt = Digests.generateSalt(SALT_SIZE);
user.setSalt(Encodes.encodeHex(salt));
byte[] hashPassword = Digests.sha1(user.getPassword().getBytes(), salt, HASH_INTERATIONS);
user.setPassword(Encodes.encodeHex(hashPassword));
}
@Transactional
@Override
public void addUser(User user, Role role) {
if (user == null || role == null) {
throw new BusinessException("user.registr.error", "注册信息错误");
}
if (StringUtils.isBlank(user.getUsername()) || StringUtils.isBlank(user.getPassword())) {
throw new BusinessException("user.registr.error", "注册信息错误");
}
if (StringUtils.isBlank(role.getId())) {
throw new BusinessException("user.registr.error", "用户未指定所属角色");
}
// Role r = daoService.getByPrimaryKey(Role.class, role.getId());
Role r = roleMapper.findById(role.getId());
if (r == null) {
throw new BusinessException("user.registr.error", "用户未指定所属组织或角色");
}
User u = userMapper.findUserByName(user.getUsername());
if(u!=null){
throw new BusinessException("user.registr.error", "用户账号已经存在,username="+user.getUsername());
}
entryptPassword(user);
user.setStatus(Constants.STATUS_VALID);
user.setCreateTime(Calendar.getInstance().getTime());
user.setId(FactoryAboutKey.getPK(TablesPKEnum.T_SYS_USER));
userMapper.insert(user);
UserRole ur = new UserRole();
ur.setRoleId(r.getId());
ur.setUserId(user.getId());
ur.setId(FactoryAboutKey.getPK(TablesPKEnum.T_SYS_USER_ROLE));
// daoService.save(ur);
userRoleMapper.insert(ur);
}
@Override
public void updatePassword(User user) {
if (log.isDebugEnabled()) {
log.debug("## update User password.");
}
User u = userMapper.findById(user.getId());
u.setPassword(user.getPassword());
entryptPassword(u);
u.setModifyTime(Calendar.getInstance().getTime());
// daoService.update(u);
userMapper.update(u);
}
@Override
public User findUserByName(String username) {
try {
return userMapper.findUserByName(username);
} catch (Exception e) {
log.error("# 根据账号查询用户报错 , username={}", username);
throw new BusinessException("1001", "查询用户失败");
}
}
@Transactional
@Override
public void updateUserLastLoginTime(User user) {
User u = userMapper.findById(user.getId());
if (u != null) {
user = new User();
user.setLastLoginTime(Calendar.getInstance().getTime());
user.setId(u.getId());
userMapper.update(u);
}
}
@Override
public List<User> findUsers() {
return userMapper.findUsers();
}
@Override
public List<User> findEmp(String shopId, String empName) {
return userMapper.findEmp(Constants.COMMON_ROLE_CODE, Constants.STATUS_VALID, shopId, empName);
}
}
| [
"wujun728@hotmail.com"
] | wujun728@hotmail.com |
30880e1c0c182acde0d4af36def0c529409599d8 | a8737bb1eeb85b65f79cd5e27c4e2c6b884528d7 | /modules/gateway/src/main/java/com/ltj/tool/service/StaticStorageService.java | dac0b1060b8692301c10deee404eb4903655fa3f | [] | no_license | a121bc/Tool | 3b656fd426f90271a0b6c0e27dde2aa54197e6b6 | 19d7d9c8a4c10034331f96b4497ccbfc6fa271b6 | refs/heads/main | 2023-03-23T19:05:30.974541 | 2021-03-18T07:55:06 | 2021-03-18T07:55:06 | 335,496,826 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,556 | java | package com.ltj.tool.service;
import com.ltj.tool.model.support.StaticFile;
import org.springframework.lang.NonNull;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* Static storage service interface class.
*
* @author Liu Tian Jun
* @date 2021-03-08 11:59
*/
public interface StaticStorageService {
String API_FOLDER_NAME = "api";
/**
* Static folder location.
*/
String STATIC_FOLDER = "static";
/**
* Lists static folder.
*
* @return List<StaticFile>
*/
List<StaticFile> listStaticFolder();
/**
* Delete file or folder by relative path
*
* @param relativePath relative path
*/
void delete(@NonNull String relativePath);
/**
* Create folder.
*
* @param basePath base path
* @param folderName folder name must not be null
*/
void createFolder(String basePath, @NonNull String folderName);
/**
* Update static file.
*
* @param basePath base path
* @param file file must not be null.
*/
void upload(String basePath, @NonNull MultipartFile file);
/**
* Rename static file or folder.
*
* @param basePath base path must not be null
* @param newName new name must not be null
*/
void rename(@NonNull String basePath, @NonNull String newName);
/**
* Save static file.
*
* @param path path must not be null
* @param content saved content
*/
void save(@NonNull String path, String content);
}
| [
"a121bc@163.com"
] | a121bc@163.com |
8b3d456120545c783d64b73be2ec8016e4f0dc45 | d5e7a0e3082c1ca9bc7b25b20f06435b1bbe3142 | /Spring/src/cn/yb/spring/test/test_byAnnotation02.java | f69f08b977f3648cf64cdcf3b8208cb176877b28 | [] | no_license | yaobin1107/frameWork | 13983e63d551e3279f59aa2ae85238cb088f1178 | b94c740dcc95e4cb9fe8b5c8810104cad48ae4a5 | refs/heads/master | 2022-12-20T09:16:31.493312 | 2019-07-02T13:43:09 | 2019-07-02T13:43:09 | 189,223,655 | 1 | 0 | null | 2022-12-16T02:56:20 | 2019-05-29T12:44:40 | Java | UTF-8 | Java | false | false | 808 | java | package cn.yb.spring.test;
import cn.yb.spring.model.User;
import cn.yb.spring.service.IUserService;
import cn.yb.spring.service.impl.UserServiceImpl;
import cn.yb.spring.web.action.UserAction;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class test_byAnnotation02 {
@Test
public void test1() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("beans_byAnnotation02.xml");
//Web开发流程:action->service->dao
UserAction userAction = (UserAction) applicationContext.getBean("userAction");
User user = new User();
user.setPassword("123");
user.setUsername("yb");
userAction.save(user);
}
}
| [
"1059843714@qq.com"
] | 1059843714@qq.com |
0e5aaeb2084d05f74beea0e050767e3a99168c1e | f24971da11abd8baa2007952f3291f4cae145810 | /Product/Production/Common/AurionCoreLib/src/main/java/org/alembic/aurion/mpilib/Patient.java | 4ba50bcc343955f8b12a3d45f50d671e7b35f1e4 | [] | no_license | AurionProject/Aurion_4.1 | 88e912dd0f688dea2092c80aff3873ad438d5aa9 | db21f7fe860550baa7942c1d78e49eab3ece82db | refs/heads/master | 2021-01-17T15:41:34.372017 | 2015-12-21T21:09:42 | 2015-12-21T21:09:42 | 49,459,325 | 0 | 2 | null | null | null | null | UTF-8 | Java | false | false | 3,868 | java | /*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2010(Year date of delivery) United States Government, as represented by the Secretary of Health and Human Services. All rights reserved.
*
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.alembic.aurion.mpilib;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
* @author rayj
*/
public class Patient implements java.io.Serializable {
private static Log log = LogFactory.getLog(Patient.class);
static final long serialVersionUID = 449060013287108229L;
private String dateOfBirth = null;
private String gender = "";
//private QualifiedSubjectId RequesterSubjectId = null;
private String ssn = "";
private String lastName = "";
private String firstName = "";
private PersonName name = null;
private PersonNames names = new PersonNames();
private Identifiers patientIdentifiers = new Identifiers();
private Address add = null;
private Addresses adds = new Addresses();
private String middleName = "";
private PhoneNumbers phoneNumbers = new PhoneNumbers();
private PhoneNumber phoneNumber = new PhoneNumber("70312312345");
private boolean optedIn = true;
public Patient() {
log.info("Patient initialized");
}
public boolean isOptedIn() {
return optedIn;
}
public void setOptedIn(boolean optedIn) {
this.optedIn = optedIn;
}
public String getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(String newVal) {
this.dateOfBirth = newVal;
}
public void setPhoneNumbers(PhoneNumbers val)
{
this.phoneNumbers = val;
}
public PhoneNumbers getPhoneNumbers()
{
return phoneNumbers;
}
public Identifiers getIdentifiers() {
return patientIdentifiers;
}
public void setIdentifiers(Identifiers newVal) {
this.patientIdentifiers = newVal;
}
public String getGender() {
return gender;
}
public void setGender(String newVal) {
this.gender = newVal;
}
public String getSSN() {
return ssn;
}
public void setSSN(String val) {
this.ssn = val;
}
public Addresses getAddresses()
{
return adds;
}
public void setAddresses(Addresses val)
{
this.adds = val;
}
@Deprecated
public Address getAddress()
{
if (add == null)
{
add = new Address();
}
return add;
}
@Deprecated
public void setAddress(Address value)
{
add = value;
}
@Deprecated
public PersonName getName() {
if (name == null) {
name = new PersonName();
}
return name;
}
@Deprecated
public void setName(PersonName newVal) {
this.name = newVal;
}
public void setNames(PersonNames newVal)
{
this.names = newVal;
}
public PersonNames getNames()
{
return names;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String newVal) {
this.firstName = newVal;
}
public String getLastName() {
return lastName;
}
public void setLastName(String newVal) {
this.lastName = newVal;
}
public String toString()
{
String result = "";
if(this.names.size() > 0)
{
for(PersonName personName : this.names)
{
result += "|" + personName.toString() ;
}
result.replaceFirst("|", "");
}
else
{
result = this.name.toString();
}
return result;
}
}
| [
"leswestberg@fake.com"
] | leswestberg@fake.com |
84353b4b42f12f0d10ade3df0039c3319dc8cfac | 45bc4010c9fa432b432ef4f00da70f280b77b5ff | /src/main/java/com/cloud/service/exception/ExceptionHandler.java | 7bbfc16b1f841805c4e00cd8b40101bf40a469f6 | [] | no_license | tianxiaoliang/security-restful-service-example | ba17310bdc3ea79d156aca5eb1d4e2612baf1985 | 488e887f214eb80a19eb22bc683599576eff7437 | refs/heads/master | 2020-04-23T21:38:47.415315 | 2015-01-12T07:53:18 | 2015-01-12T07:53:18 | 29,115,605 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 428 | java | package com.cloud.service.exception;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.springframework.stereotype.Component;
/**
*
*/
@Provider
@Component
public class ExceptionHandler implements ExceptionMapper<ServiceException>{
public Response toResponse(ServiceException ex) {
return Response.serverError().entity(ex.getMessage()).build();
}
}
| [
"xiaoliang.tian@gmail.com"
] | xiaoliang.tian@gmail.com |
efb89ab8ddde6fa55093f4858dbf7bb05658b785 | 327937c2ff754f225ec954af9946d95585c850d2 | /Crawler/src/main/java/google/places/Geometry.java | d9cd8f51e47990a3d08458c88d0419ac6e4f01fd | [] | no_license | Miriam-Asenjo/tfm | c5215cb4dcd2ecb68e88e1acb6ee9fb9c03baae4 | 2fbfb2d615884edbe9ffa1b856ec53aceb056e9a | refs/heads/master | 2020-04-18T19:07:36.499836 | 2016-09-25T17:43:52 | 2016-09-25T17:43:52 | 66,213,671 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 218 | java | package google.places;
public class Geometry
{
private Location location;
public Location getLocation() {
return location;
}
public void setLocation(Location location) {
this.location = location;
}
} | [
"miriam.g.asenjo@gmail.com"
] | miriam.g.asenjo@gmail.com |
093d72c25f747f1076b9950f01831d7e6f3237f7 | 6555851319497aa8935af134df0945d9afb8d58b | /src/day_17/ArrayEx41.java | 50a8c82d0d86f47596e1cdec51a14034f0c6d025 | [] | no_license | gi-hun/MEGA_Java_Day17_2Array-4- | 4c872a51344ee6b7349310bb131604d2ae40ee44 | 899fb7748a3c9c9905818ffc066dd5b0e3db26e3 | refs/heads/master | 2021-03-12T05:38:17.144704 | 2020-03-11T14:32:32 | 2020-03-11T14:32:32 | 246,594,251 | 0 | 0 | null | null | null | null | UHC | Java | false | false | 1,528 | java | //# 2차원배열 기본문제[3단계]
package day_17;
public class ArrayEx41 {
public static void main(String[] args) {
int[][] arr = {
{101, 102, 103, 104},
{201, 202, 203, 204},
{301, 302, 303, 304}
};
int[] garo = new int[3];
int[] sero = new int[4];
// 문제 1) 가로 합 출력
// 정답 1) 410, 810, 1210
System.out.println("문제 1) 가로 합 출력");
int sum1 = 0, sum2 = 0, sum3 = 0;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
if(i == 0)
{
sum1 = sum1 + arr[i][j];
}
else if(i == 1)
{
sum2 = sum2 + arr[i][j];
}
else if(i == 2)
{
sum3 = sum3 + arr[i][j];
}
}
}
System.out.println("sum1=" + sum1);
System.out.println("sum2=" + sum2);
System.out.println("sum3=" + sum3);
// 문제 2) 세로 합 출력
// 정답 2) 603, 606, 609, 612
System.out.println();
System.out.println("문제 2) 세로 합 출력");
sum1 = 0; sum2 = 0; sum3 = 0;
int sum4 = 0;
for(int i=0;i<3;i++)
{
for(int j=0;j<4;j++)
{
if(j == 0)
{
sum1 = sum1 + arr[i][j];
}
else if(j == 1)
{
sum2 = sum2 + arr[i][j];
}
else if(j == 2)
{
sum3 = sum3 + arr[i][j];
}
else if(j == 3)
{
sum3 = sum3 + arr[i][j];
}
}
}
System.out.println("sum1=" + sum1);
System.out.println("sum2=" + sum2);
System.out.println("sum3=" + sum3);
System.out.println("sum4=" + sum4);
}
}
| [
"duarl@DESKTOP-RLI1BQT"
] | duarl@DESKTOP-RLI1BQT |
9c847e56eec8aeadce1e137c3df42268bc9475c3 | ed5159d056e98d6715357d0d14a9b3f20b764f89 | /test/irvine/oeis/a178/A178934Test.java | 34c5004dab9934dcd9b133bf7ebc12fa838cac66 | [] | no_license | flywind2/joeis | c5753169cf562939b04dd246f8a2958e97f74558 | e5efd6971a0062ac99f4fae21a7c78c9f9e74fea | refs/heads/master | 2020-09-13T18:34:35.080552 | 2019-11-19T05:40:55 | 2019-11-19T05:40:55 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 195 | java | package irvine.oeis.a178;
import irvine.oeis.AbstractSequenceTest;
/**
* Tests the corresponding class.
* @author Sean A. Irvine
*/
public class A178934Test extends AbstractSequenceTest {
}
| [
"sean.irvine@realtimegenomics.com"
] | sean.irvine@realtimegenomics.com |
9faa8dd4a25af2303ebd20e8b502ff8f19ba472d | 2a6d7bc97709bcc13adc6d466d7bc1b5e96c9173 | /serviceMarket-manager/serviceMarket-manager-service/src/main/java/com/serviceMarket/service/GroupService.java | 77352f63ecf1f31708fb31d56ad48ba0e86183d8 | [] | no_license | zwp745233700/serviceMarket | e33d4030daaf5fe3db383088617d8a0f911111f4 | 8a82bf87612cac1c7839d71eda86cad768c934ff | refs/heads/master | 2020-03-25T08:55:17.094541 | 2018-08-05T22:23:24 | 2018-08-05T22:23:24 | 143,637,878 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,143 | java | package com.serviceMarket.service;
import java.util.List;
import org.springframework.stereotype.Service;
import com.serviceMarket.DTO.GroupDTO;
import com.serviceMarket.DTO.UserGroupDTO;
import com.serviceMarket.Vo.GroupsVo;
/**
* @author 作者 张维鹏:
* @version 创建时间:2017年12月2日 下午3:08:59
* 类说明 :团购Service的接口
*/
@Service
public interface GroupService {
//发起团购
boolean addGroups(GroupDTO groupDTO);
//删除团购
boolean deleteGroups(Integer groupId);
//查看该商家的团购;flag:1表示正在进行的,2表示即将开始的
public List<GroupsVo> getGroupsByshopId(Integer shopId,int flag);
//查看集市的团购,需要集市的id;flag:1表示正在进行的,2表示即将开始的
public List<GroupsVo> getGroupsByMarkId(Integer markId,int flag);
//加入团购
public boolean joinGroup(UserGroupDTO userGroupDTO);
//查看我参与的团购
public List<GroupsVo> myGroup(Integer userId);
//修改我的团购资料
public boolean updateUserGroup(UserGroupDTO userGroupDTO);
//退出团购
public boolean exitGroup(Integer userGroupId);
}
| [
"745233700@qq.com"
] | 745233700@qq.com |
c121ae093c51b0b8fb88571cd1a21744dc298e60 | 387af6405bf94614ab0fc5e13792d1f97426d7fa | /eCommerce/src/main/java/com/eCommerce/services/CartService.java | 5f82d4efacff49b83c682eb192ad00b61e462dce | [] | no_license | AmrEshra/ECommerce | 6f35b9fe476f3e2513c2169bda1c05f54c30de72 | 10d6550964cf7d524ea77d3507945a904ea320f9 | refs/heads/master | 2022-11-18T10:03:13.665357 | 2020-07-13T11:13:24 | 2020-07-13T11:13:24 | 273,891,922 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 431 | java | package com.eCommerce.services;
import java.util.List;
import com.eCommerce.entity.Cart;
import com.eCommerce.entity.CartDetails;
public interface CartService {
public List<CartDetails> getCartDetails();
public Cart getCartByProductId(Long productId);
public Cart addToCart(Cart cart);
public void removeFromCart(Long id);
public Cart updateCart(Long productId, Integer newItemCount);
public void removeAllFromCart();
}
| [
"amr.eshra@gmail.com"
] | amr.eshra@gmail.com |
70d4ddaff7b13d5e314276db82ab034e7f663f9f | 002724cfb29f5147b29e028a9b69206e50d5075d | /src/NoraCommon/src/main/java/org/jp/illg/util/BufferUtilObject.java | d46ae2e04e19279a1ba253076ab3ad43ee15007d | [
"MIT"
] | permissive | ahnd38/NoraSeries | eabfe9ef590811814b7baf6e443b01785b0b3fb3 | 623ef2f8eb4a038ad8230491534814ecd9f6f204 | refs/heads/master | 2023-04-17T10:44:58.197302 | 2021-05-03T04:38:06 | 2021-05-03T04:38:06 | 309,729,704 | 0 | 3 | MIT | 2021-05-03T04:38:07 | 2020-11-03T15:31:20 | Java | UTF-8 | Java | false | false | 823 | java | package org.jp.illg.util;
import java.nio.ByteBuffer;
import org.jp.illg.util.BufferUtil.BufferProcessResult;
import lombok.Getter;
import lombok.Setter;
public class BufferUtilObject{
@Getter
@Setter
private ByteBuffer buffer;
@Getter
@Setter
private BufferState bufferState;
@Getter
@Setter
private BufferProcessResult processResult;
private BufferUtilObject() {
super();
setBuffer(null);
setBufferState(BufferState.INITIALIZE);
setProcessResult(BufferProcessResult.Unknown);
}
public BufferUtilObject(ByteBuffer buffer, BufferState bufferState) {
this();
setBuffer(buffer);
setBufferState(bufferState);
}
public BufferUtilObject(ByteBuffer buffer, BufferState bufferState, BufferProcessResult processResult) {
this(buffer, bufferState);
setProcessResult(processResult);
}
}
| [
"neko38ch@gmail.com"
] | neko38ch@gmail.com |
1cff993f8ac68abaabbb3df9a98c51bea9f5c2b7 | ee461488c62d86f729eda976b421ac75a964114c | /tags/HtmlUnit-2.12/src/test/java/com/gargoylesoftware/htmlunit/html/DomAttrTest.java | 371add63c866048d6bf7fd567eebc8bd91db11b6 | [
"Apache-2.0"
] | permissive | svn2github/htmlunit | 2c56f7abbd412e6d9e0efd0934fcd1277090af74 | 6fc1a7d70c08fb50fef1800673671fd9cada4899 | refs/heads/master | 2023-09-03T10:35:41.987099 | 2015-07-26T13:12:45 | 2015-07-26T13:12:45 | 37,107,064 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,930 | java | /*
* Copyright (c) 2002-2013 Gargoyle Software Inc.
*
* 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.gargoylesoftware.htmlunit.html;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.gargoylesoftware.htmlunit.BrowserRunner;
import com.gargoylesoftware.htmlunit.SimpleWebTestCase;
/**
* Tests for {@link DomAttr}.
*
* @version $Revision$
* @author Marc Guillemot
*/
@RunWith(BrowserRunner.class)
public class DomAttrTest extends SimpleWebTestCase {
/**
* @throws Exception if the test fails
*/
@Test
public void getCanonicalXPath() throws Exception {
final String html = "<html id='foo'><body></body></html>";
final HtmlPage page = loadPage(html);
final DomAttr attr = page.getHtmlElementById("foo").getAttributeNode("id");
assertEquals("/html/@id", attr.getCanonicalXPath());
}
/**
* @throws Exception if the test fails
*/
@Test
public void textContent() throws Exception {
final String html = "<html id='foo'><body></body></html>";
final HtmlPage page = loadPage(html);
final DomAttr attr = page.getDocumentElement().getAttributeNode("id");
assertEquals("foo", attr.getTextContent());
attr.setTextContent("hello");
assertEquals("hello", attr.getTextContent());
assertEquals(page.getDocumentElement(), page.getHtmlElementById("hello"));
}
}
| [
"mguillem@5f5364db-9458-4db8-a492-e30667be6df6"
] | mguillem@5f5364db-9458-4db8-a492-e30667be6df6 |
08d6233a7cf81aaf24694a0204fa878fcf9039d6 | 65ebd9cc9b8ac76522f77c84b70fdc8b2c6d77e6 | /src/main/java/com/github/interview/amazon/MinCostToConnectAllNodes.java | 4f5b31ede7a5d4af9a7a5cb7c443bc74881cef80 | [] | no_license | SlumDunk/leetcode | 30af765c7f5e61317983af43230bafa23362e25a | c242f13e7b3a3ea67cdd70f3d8b216e83bd65829 | refs/heads/master | 2021-08-20T01:58:11.309819 | 2021-07-25T17:07:10 | 2021-07-25T17:07:10 | 121,602,686 | 0 | 0 | null | 2020-11-08T03:34:35 | 2018-02-15T07:38:45 | Java | UTF-8 | Java | false | false | 2,213 | java | package com.github.interview.amazon;
import java.util.Arrays;
import java.util.Comparator;
/**
* @Author: zerongliu
* @Date: 11/6/19 13:21
* @Description:
*/
public class MinCostToConnectAllNodes {
public static void main(String[] args) {
MinCostToConnectAllNodes main = new MinCostToConnectAllNodes();
int tc1 = main.minCostToConnect(6, new int[][]{{1, 4}, {4, 5}, {2, 3}}, new int[][]{{1, 2, 5}, {1, 3, 10}, {1, 6, 2}, {5, 6, 5}});
if (tc1 == 7) {
System.out.println("All Test Case Pases!");
} else {
System.out.println("There are test failures!");
}
}
int[] parents;
public int minCostToConnect(int n, int[][] edges, int[][] newEdges) {
parents = new int[n + 1];
int connected = n, minCost = 0;
for (int i = 0; i <= n; i++) {
parents[i] = i;
}
//union已有的边
for (int[] edge : edges) {
if (this.union(edge[0], edge[1])) {
connected--;
}
}
Arrays.sort(newEdges, new Comparator<int[]>() {
@Override
public int compare(int[] arr1, int[] arr2) {
return arr1[2] - arr2[2];
}
});
for (int[] newEdge : newEdges) {
if (this.union(newEdge[0], newEdge[1])) {
minCost += newEdge[2];
connected--;
}
if (connected == 1) {
return minCost;
}
}
return connected == 1 ? connected : -1;
}
/**
* union两个节点,如果本身属于同一个连通分量,那么不需要再Union,直接返回false
*
* @param x
* @param y
* @return
*/
private boolean union(int x, int y) {
int setX = find(x);
int setY = find(y);
if (setX != setY) {
parents[setY] = setX;
return true;
}
return false;
}
/**
* 获取根祖先
*
* @param num
* @return
*/
private int find(int num) {
if (parents[num] != num) {
parents[num] = find(parents[num]);
}
return parents[num];
}
}
| [
"zliu17@uncc.edu"
] | zliu17@uncc.edu |
516499c5c76e745d2aebdad4e2faac50abe292dc | 0b13e0adc33628caeefb16cb726528f2516a3962 | /Gun4/Gun4-Threads/src/tr/com/netas/threads/executorservice/MyThread.java | edaf7fde80cd2712644d3342c4b002d7dbc1cafe | [] | no_license | aysenuroruc/Java-Collections | de68e93222fefeb60b84a1d1d3bf5b522dececb7 | 9e3af976b850b6f92a9a2bd5493fee577855a389 | refs/heads/master | 2020-04-11T07:03:33.543999 | 2019-05-13T23:21:17 | 2019-05-13T23:21:17 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 383 | java | package tr.com.netas.threads.executorservice;
public class MyThread extends Thread{
private String name;
public MyThread(String name) {
super();
this.name = name;
}
@Override
public void run() {
try {
for(int i =0 ;i<10;i++)
{
Thread.sleep(1000);
System.out.println( name +" -- > "+ i);
}
}catch (Exception e) {
e.printStackTrace();
}
}
}
| [
"aoruc@netas.com.tr"
] | aoruc@netas.com.tr |
b33f067c26147d41ab25880950858292f1096ea8 | 492ab60eaa5619551af16c79c569bdb704b4d231 | /src/net/sourceforge/plantuml/graphic/USymbolBoundary.java | eab45733caa06bd81e8a6da923892e1616144a59 | [] | no_license | ddcjackm/plantuml | 36b89d07401993f6cbb109c955db4ab10a47ac78 | 4638f93975a0af9374cec8200d16e1fa180dafc2 | refs/heads/master | 2021-01-12T22:34:56.588483 | 2016-07-25T19:25:28 | 2016-07-25T19:25:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,733 | java | /* ========================================================================
* PlantUML : a free UML diagram generator
* ========================================================================
*
* (C) Copyright 2009-2017, Arnaud Roques
*
* Project Info: http://plantuml.com
*
* This file is part of PlantUML.
*
* PlantUML is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PlantUML distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
* License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*
* [Java is a trademark or registered trademark of Sun Microsystems, Inc.
* in the United States and other countries.]
*
* Original Author: Arnaud Roques
*
* Revision $Revision: 8066 $
*
*/
package net.sourceforge.plantuml.graphic;
import net.sourceforge.plantuml.svek.Boundary;
import net.sourceforge.plantuml.ugraphic.UStroke;
class USymbolBoundary extends USymbolSimpleAbstract {
@Override
public SkinParameter getSkinParameter() {
return SkinParameter.BOUNDARY;
}
@Override
protected TextBlock getDrawing(final SymbolContext symbolContext) {
return new Boundary(symbolContext.withDeltaShadow(symbolContext.isShadowing() ? 4.0 : 0.0).withStroke(
new UStroke(2)));
}
} | [
"plantuml@gmail.com"
] | plantuml@gmail.com |
ea4f0c17877a8e6309ff222eb995cab22bab1bd7 | 4b71e612c277572af1666ecebb58de32b41c8610 | /JavaBlog/src/javablog/servlet/admin/display/UserList.java | 467418a3e266e63b0fe4cc66b03805356eb9b2e5 | [] | no_license | ayugeak/javablog | 2656fd652dddb4727bb0cbb5e459c699c425d9e8 | bae5cc6efe0d7969533fd29527104a0662d082d0 | refs/heads/master | 2020-05-31T02:36:55.600376 | 2014-04-20T04:53:53 | 2014-04-20T04:53:53 | 18,940,680 | 1 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,146 | java | package javablog.servlet.admin.display;
import java.io.IOException;
import java.sql.Connection;
import java.util.ArrayList;
import javablog.database.DBConnectionPool;
import javablog.util.ConfigProperty;
import javablog.util.StrFilter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import javablog.bean.*;
public class UserList extends HttpServlet {
private static final long serialVersionUID = 1L;
public UserList() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html;charset=UTF-8");
request.setCharacterEncoding("UTF-8");
boolean flag = false;
HttpSession session = request.getSession(true);
String userIdText = (String) session.getAttribute("userId");
if (userIdText != null) {
String roleIdText = request.getParameter("roleId");
String statusText = request.getParameter("status");
String attribute = request.getParameter("attribute");// 排序字段
String order = request.getParameter("order");// 排序方式
String pageNowText = request.getParameter("pageNow");// 获得要显示的页数
StrFilter sf = new StrFilter();
int roleId = sf.parseInt(roleIdText);
int status = sf.parseInt(statusText);
int pageNow = sf.parseInt(pageNowText);
if (pageNow == 0) {
pageNow = 1;
}
if (attribute == null){
attribute = "";
}
if (order == null){
order = "";
}
if ((roleId >= 0)
&& this.isValidStatus(status)
&& this.isValidAttribute(attribute)
&& sf.isValidOrder(order)
&& pageNow > 0){
Connection connection = DBConnectionPool.getDBConnectionPool().getConnection();
if (connection != null){
UserBeanBo ubb = new UserBeanBo(connection);
UserBean ub = ubb.getUser(Integer.parseInt(userIdText));
if (ub != null && ub.getStatus() == ConfigProperty.STATUS_NORMAL){
RoleBeanBo ugbb = new RoleBeanBo(connection);
RoleBean role = ugbb.getRole(ub.getRoleId());
if (role != null && role.getStatus() == 0 && role.canReadUser()) {
ubb.setPageSize(ConfigProperty.admin_user_page_size);
ubb.setFilter(status, roleId, attribute, order);
ArrayList<UserBean> al = ubb.getUsers(pageNow);
request.setAttribute("userList", al);
request.setAttribute("role", role);
request.setAttribute("roleId", roleId + "");
request.setAttribute("pageNow", pageNow + "");
request.setAttribute("rowCount", ubb.getRowCount() + "");
request.setAttribute("pageCount", ubb.getPageCount() + "");
request.setAttribute("attribute", attribute);
request.setAttribute("order", order);
request.setAttribute("status", status + "");
flag = true;
}
}
ubb.closeConnection();
}
}
}
if (flag){
request.getRequestDispatcher("userList.jsp").forward(request,
response);
} else {
request.getRequestDispatcher("error.jsp")
.forward(request, response);
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
public void init() throws ServletException {
// Put your code here
}
private boolean isValidAttribute(String attribute){
boolean result = false;
if (attribute == null
|| attribute.length() == 0
|| attribute.equalsIgnoreCase("user_id")
|| attribute.equalsIgnoreCase("role_id")
|| attribute.equalsIgnoreCase("name")
|| attribute.equalsIgnoreCase("username")){
result = true;
}
return result;
}
private boolean isValidStatus(int status){
boolean result = false;
if (status == ConfigProperty.STATUS_NORMAL
|| status == ConfigProperty.STATUS_TRASH){
result = true;
}
return result;
}
}
| [
"ayugeak@gmail.com"
] | ayugeak@gmail.com |
54ec4ca381ca53cea941a7c55caedc43e904414d | a99cfc9bc17b0f4a27ec63b60f34512e9370e4d6 | /kkdai_report/kkdai_report/trunk/client/android/KkdaiReport/app/src/main/java/com/kuaikuaidai/kkdaireport/adapter/MenuAdapter.java | 99deceb7db604c13022cc198493b9840513a7154 | [] | no_license | trwupeng/secondecommit | 9a29360c0e0b5bcbdb0f0d56ac4c99af61891088 | 711cd9e531149644dc42a0b93f10a5716c5ecb7a | refs/heads/master | 2021-01-18T16:48:27.891571 | 2017-03-31T03:38:18 | 2017-03-31T03:38:18 | 86,771,995 | 4 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,330 | java | package com.kuaikuaidai.kkdaireport.adapter;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.TextView;
import com.kuaikuaidai.kkdaireport.R;
import com.kuaikuaidai.kkdaireport.bean.Menu;
/**
* 菜单适配器
*/
public class MenuAdapter extends BaseExpandableListAdapter {
private Context mContext;
private Menu menu;
private LayoutInflater mInfalter;
public MenuAdapter(Context context, Menu list) {
mContext = context;
mInfalter = ((Activity) mContext).getLayoutInflater();
menu = list;
}
@Override
public Object getChild(int groupPosition, int childPosition) {
return menu.getChildren().get(groupPosition).getChildren().get(childPosition);
}
@Override
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
@Override
public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {
ChildViewHolder childViewHolder;
if (convertView == null) {
convertView = mInfalter.inflate(R.layout.item_menu_child, parent, false);
childViewHolder = new ChildViewHolder();
childViewHolder.child = (TextView) convertView.findViewById(R.id.tv_menu_child);
convertView.setTag(childViewHolder);
} else {
childViewHolder = (ChildViewHolder) convertView.getTag();
}
childViewHolder.child.setText(menu.getChildren().get(groupPosition).getChildren().get(childPosition).getCapt());
return convertView;
}
@Override
public int getChildrenCount(int groupPosition) {
return menu.getChildren().get(groupPosition).getChildren().size();
}
@Override
public Object getGroup(int groupPosition) {
return getGroup(groupPosition);
}
@Override
public int getGroupCount() {
return menu.getChildren().size();
}
@Override
public long getGroupId(int groupPosition) {
return groupPosition;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {
GroupViewHolder groupViewHolder;
if (convertView == null) {
convertView = mInfalter.inflate(R.layout.item_menu_group, parent, false);
groupViewHolder = new GroupViewHolder();
groupViewHolder.group = (TextView) convertView.findViewById(R.id.tv_menu_group);
convertView.setTag(groupViewHolder);
} else {
groupViewHolder = (GroupViewHolder) convertView.getTag();
}
String name = menu.getChildren().get(groupPosition).getCapt();
groupViewHolder.group.setText(name);
return convertView;
}
@Override
public boolean hasStableIds() {
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
static class GroupViewHolder {
TextView group;
}
static class ChildViewHolder {
TextView child;
}
}
| [
"1954702819@qq.com"
] | 1954702819@qq.com |
e735ec8ad8298ddd4e4741abba96639af43e1d44 | c17b7d276f0cdc27b898ccab882199203abea2f6 | /app/src/main/java/com/example/android/moview/ui/MovieListFragment.java | 66b18860ca22b8f89e4d28d008936d0793660067 | [] | no_license | Mariana-Dantas/Moview | 5ad79b361fe30eed113afa63d3988530a3e7fc3a | aa9588bb18c8c6473ff8c01df73105656b06b0ba | refs/heads/master | 2023-01-11T23:51:29.101199 | 2020-11-20T14:46:39 | 2020-11-20T14:46:39 | 313,665,785 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,581 | java | package com.example.android.moview.ui;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.example.android.moview.BuildConfig;
import com.example.android.moview.R;
import com.example.android.moview.data.FavoriteDbHelper;
import com.example.android.moview.network.ApiService;
import com.example.android.moview.network.response.MovieResult;
import com.example.android.moview.utils.Mapper;
import com.example.android.moview.utils.Movie;
import com.example.android.moview.utils.MovieAdapter;
import com.example.android.moview.utils.Utils;
import java.io.IOException;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import static com.example.android.moview.R.string.error_best_ranked_movies;
public class MovieListFragment extends Fragment implements MovieAdapter.ListItemClickListener {
private RecyclerView recyclerMovie;
private MovieAdapter movieAdapter;
private View rootView;
private Toast mToast;
private FavoriteDbHelper favoriteDbHelper;
public static final String ARG_ITEM_POSITION = "1";
private int itemPosition = 1;
private final String[] errorType = {""};
private final String[] errorDesc = {""};
public static MovieListFragment newInstance(int position) {
MovieListFragment fragment = new MovieListFragment();
Bundle args = new Bundle();
args.putSerializable(ARG_ITEM_POSITION, position);
fragment.setArguments(args);
return fragment;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
rootView = inflater.inflate(R.layout.movie_list_fragment, container, false);
configAdapter();
favoriteDbHelper = new FavoriteDbHelper(getActivity());
((AppCompatActivity) getActivity()).getSupportActionBar().show();
Bundle bundle = this.getArguments();
super.onCreate(savedInstanceState);
if (bundle != null) {
itemPosition = (int) bundle.getSerializable(ARG_ITEM_POSITION);
if (itemPosition == 1) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.rating);
getBestRankedMovies();
} else if (itemPosition == 2) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.popularity);
getPopularMovies();
} else if (itemPosition == 3) {
((AppCompatActivity) getActivity()).getSupportActionBar().setTitle(R.string.favorits);
getFavMovies();
}
}
return rootView;
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
// Configs List Adapter
private void configAdapter() {
recyclerMovie = rootView.findViewById(R.id.recycler_movie);
movieAdapter = new MovieAdapter(this);
RecyclerView.LayoutManager movieLayoutManager;
//checkOrientation
int orientation = getResources().getConfiguration().orientation;
if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
movieLayoutManager = new GridLayoutManager(getContext(), 4);
// In landscape
} else {
movieLayoutManager = new GridLayoutManager(getContext(), 2);
// In portrait
}
//RecyclerView.LayoutManager movieLayoutManager = new GridLayoutManager(getActivity(), 2);
recyclerMovie.setLayoutManager(movieLayoutManager);
recyclerMovie.setAdapter(movieAdapter);
}
// gets most popular Movies from API
public void getPopularMovies() {
ApiService.getInstance()
.getPopularMovies(BuildConfig.API_KEY)
.enqueue(new Callback<MovieResult>() {
@Override
public void onResponse(@NonNull Call<MovieResult> call, @NonNull Response<MovieResult> response) {
if (response.isSuccessful()) {
movieAdapter.setMovies(
Mapper.fromResponseToMainMovie(response.body().getMovieResults())
);
} else {
Toast.makeText(getActivity(), R.string.error_pop_movies, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(@NonNull Call<MovieResult> call, @NonNull Throwable t) {
showError(t);
}
});
}
// gets Best ranked movies from API
public void getBestRankedMovies() {
ApiService.getInstance()
.getTopRatedMovies(BuildConfig.API_KEY)
.enqueue(new Callback<MovieResult>() {
@Override
public void onResponse(@NonNull Call<MovieResult> call, @NonNull Response<MovieResult> response) {
if (response.isSuccessful()) {
movieAdapter.setMovies(
Mapper.fromResponseToMainMovie(response.body().getMovieResults())
);
} else {
Toast.makeText(getActivity(), error_best_ranked_movies, Toast.LENGTH_SHORT).show();
}
}
@Override
public void onFailure(@NonNull Call<MovieResult> call, @NonNull Throwable t) {
Toast.makeText(getActivity(), R.string.error_showind_movie_list, Toast.LENGTH_SHORT).show();
showError(t);
}
});
}
private void showError(Throwable t) {
if (t instanceof IOException) {
errorType[0] = getString(R.string.Timeout);
errorDesc[0] = String.valueOf(t.getCause());
Log.i(errorType[0], errorDesc[0]);
} else if (t instanceof IllegalStateException) {
errorType[0] = getString(R.string.conversion_error);
errorDesc[0] = String.valueOf(t.getCause());
Log.i(errorType[0], errorDesc[0]);
} else {
errorType[0] = getString(R.string.other_error);
errorDesc[0] = String.valueOf(t.getLocalizedMessage());
Log.i(errorType[0], errorDesc[0]);
}
}
// Inflates menu
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
inflater.inflate(R.menu.main, menu);
super.onCreateOptionsMenu(menu, inflater);
}
// Gets Favorit Movies from the database
public void getFavMovies() {
movieAdapter.setMovies(
favoriteDbHelper.getAllFavorite()
);
}
// Click responce when a movie is clicked
@Override
public void onListItemClick(Movie movie) {
MovieDetailsFragment movieDetailsFragment = MovieDetailsFragment.newInstance(movie);
Utils.setFragment(getFragmentManager(), movieDetailsFragment);
}
}
| [
"marydantas97@gmail.com"
] | marydantas97@gmail.com |
2c56025f9f0353985cc8a68432935f9702e5ca6f | 4127028c90f319fd6ca7d536573b81840de47c38 | /app/src/main/java/edu/brandeis/cs/jiahuiming/resumeshare/models/RequestModel.java | 8079716f9df1aefc8801f6d89f7cab6b29b51409 | [] | no_license | alephO/ResumeShare | f6b5b2313c42f9a02f3ff2b180b7ab070a95adbd | 1acc114a30123a12ff126a1f4960c1b6a5180551 | refs/heads/master | 2020-06-19T00:31:07.053796 | 2016-11-28T22:09:25 | 2016-11-28T22:09:25 | 74,931,014 | 0 | 0 | null | 2016-11-28T02:48:15 | 2016-11-28T02:48:14 | null | UTF-8 | Java | false | false | 4,318 | java | package edu.brandeis.cs.jiahuiming.resumeshare.models;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;
import android.widget.Toast;
import org.json.JSONArray;
import org.json.JSONObject;
import edu.brandeis.cs.jiahuiming.resumeshare.adapters.ContactsAdapter;
import edu.brandeis.cs.jiahuiming.resumeshare.adapters.RequestAdapter;
import edu.brandeis.cs.jiahuiming.resumeshare.beans.Request;
import edu.brandeis.cs.jiahuiming.resumeshare.beans.User;
import edu.brandeis.cs.jiahuiming.resumeshare.utils.DBOpenHelper;
import edu.brandeis.cs.jiahuiming.resumeshare.utils.HttpTask;
/**
* Created by jiahuiming on 11/18/16.
*/
public class RequestModel { private Context context;
private String result;
public RequestModel(Context context) {
this.context = context;
}
public void addRequestToRemote(String hostaccount,String guestaccount,String hostname,String imageid,String message) {
HttpTask task = new HttpTask();
task.setTaskHandler(new HttpTask.HttpTaskHandler(){
public void taskSuccessful(String json) {
try {
result=json;
Toast.makeText(context,"Invitation has been send",Toast.LENGTH_SHORT).show();
Log.d("addRequestToRemote",result);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void taskFailed() {
}
});
task.execute("user","addRequest","hostaccount="+hostaccount+"&guestaccount="+guestaccount+"&message="+message+"&imageid="+imageid+"&hostname="+hostname);
}
public void loadRequestsfromRemote(String account,final RequestAdapter requestAdapter){
HttpTask task = new HttpTask();
task.setTaskHandler(new HttpTask.HttpTaskHandler(){
public void taskSuccessful(String json) {
try {
Request request=new Request();
String result_id;
String result_hostaccount;
String result_guestaccount;
String result_message;
String result_hostname;
String result_imageid;
JSONArray ja=new JSONArray(json);
for(int i =0; i<ja.length(); i++){
JSONObject jo=(JSONObject)ja.get(i);
result_id=jo.getString("id");
result_hostaccount=jo.getString("hostaccount");
result_guestaccount=jo.getString("guestaccount");
result_message=jo.getString("message");
result_hostname=jo.getString("hostname");
result_imageid=jo.getString("imageid");
request=new Request();
request.setId(result_id);
request.setHostAccount(result_hostaccount);
request.setGuestAccount(result_guestaccount);
request.setMessage(result_message);
request.setHostName(result_hostname);
request.setHostImageId(result_imageid);
requestAdapter.putData(request);
}
requestAdapter.notifyDataSetChanged();
Log.d("loadRequestsfromRemote",result);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void taskFailed() {
}
});
task.execute("user","showRequests","guestaccount="+account);
}
public void delRequestOnRemote(String id){
HttpTask task = new HttpTask();
task.setTaskHandler(new HttpTask.HttpTaskHandler(){
public void taskSuccessful(String json) {
try {
result=json;
Log.d("loadRequestsfromRemote",result);
}
catch (Exception e) {
e.printStackTrace();
}
}
public void taskFailed() {
}
});
task.execute("user","delRequest","id="+id);
}
}
| [
"jiahuiming@JiaHuimings-MacBook-Air.local"
] | jiahuiming@JiaHuimings-MacBook-Air.local |
add53cc5c52307c57e73ddbb332d9d328ff3bc82 | 19ef2b626e3bb9f0ffa1f15f3647179b4c948099 | /src/main/java/rocks/cleanstone/game/block/entity/BlockEntity.java | 34c848afcb95126ce19f557a2a9c7ff9ca4577d3 | [
"MIT"
] | permissive | iyzana/Cleanstone | 5a4dbebe36f0e07bc7ee30dfb1cdc764cb5adb9f | 8c2832e70c94a95125ad501df7d4fdb0b2211859 | refs/heads/master | 2020-03-21T18:49:53.332132 | 2018-06-26T21:35:34 | 2018-06-26T21:35:34 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 855 | java | package rocks.cleanstone.game.block.entity;
import rocks.cleanstone.game.block.Block;
import rocks.cleanstone.game.block.BlockState;
import rocks.cleanstone.game.material.MaterialRegistry;
import rocks.cleanstone.game.material.block.BlockType;
/**
* A block in the world with mutable state information and behavior optionally
*/
public abstract class BlockEntity implements Block {
private final BlockState state;
private final BlockType type;
public BlockEntity(BlockState state, BlockType type) {
this.state = state;
this.type = type;
}
public BlockEntity(BlockState state) {
this(state, MaterialRegistry.getBlockType(state.getMaterial()));
}
@Override
public BlockType getType() {
return type;
}
@Override
public BlockState getState() {
return state;
}
}
| [
"dev@myzelyam.de"
] | dev@myzelyam.de |
ca34e427e7b5361fa23c78e8466e5ba919df8968 | ae3ee915da16a35469841b50a2fae3c276a3b2c4 | /AirbusBackEnd/src/main/java/com/airbus/AirbusBackEnd/ServletInitializer.java | 0edd22bd0fd35324a0d0a07484034b8a88c59d4a | [] | no_license | dsenthilkumar95/AirBusChallenge | a1e3304de4b89d14662d9d4b5dbd19757f35a37e | cd442c7ca66cd35187032f9d76decf5d4453f951 | refs/heads/main | 2023-05-08T15:03:07.702864 | 2021-05-31T09:40:20 | 2021-05-31T09:40:20 | 365,686,195 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 421 | java | package com.airbus.AirbusBackEnd;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
public class ServletInitializer extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(AirbusBackEndApplication.class);
}
}
| [
"Senthil_KumarDas@comcast.com"
] | Senthil_KumarDas@comcast.com |
9ffce6a07c009651495b7521075cc8e0bdfea617 | e45dabef127bf9d7c539a014b36c19c1f9f7e077 | /src/com/yayo/warriors/module/chat/facade/impl/ChatFacadeImpl.java | 6f2a3bb506f427fcdaf93bae6e4bd7e41089207c | [] | no_license | zyb2013/Warriors | aaa26c89dde6b5777a8fcd3674d1ee61346ffda7 | 6ac80f1868d749295c298a36ad4b6425034d358f | refs/heads/master | 2021-01-01T19:46:57.730694 | 2014-01-17T01:41:45 | 2014-01-17T01:41:45 | 15,986,861 | 5 | 10 | null | null | null | null | UTF-8 | Java | false | false | 13,407 | java | package com.yayo.warriors.module.chat.facade.impl;
import static com.yayo.warriors.constant.CommonConstant.*;
import static com.yayo.warriors.module.chat.constant.ChatConstant.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.mina.core.session.IoSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.yayo.common.db.executor.DbService;
import com.yayo.common.lock.ChainLock;
import com.yayo.common.lock.LockUtils;
import com.yayo.common.socket.SessionManager;
import com.yayo.common.socket.type.SessionType;
import com.yayo.common.utility.EnumUtils;
import com.yayo.warriors.common.helper.MessagePushHelper;
import com.yayo.warriors.module.alliance.entity.Alliance;
import com.yayo.warriors.module.alliance.entity.PlayerAlliance;
import com.yayo.warriors.module.alliance.manager.AllianceManager;
import com.yayo.warriors.module.chat.facade.ChannelFacade;
import com.yayo.warriors.module.chat.facade.ChatFacade;
import com.yayo.warriors.module.chat.model.Channel;
import com.yayo.warriors.module.chat.model.ChatResponse;
import com.yayo.warriors.module.chat.rule.ChatRule;
import com.yayo.warriors.module.chat.type.ChatChannel;
import com.yayo.warriors.module.logger.log.GoodsLogger;
import com.yayo.warriors.module.logger.model.LoggerGoods;
import com.yayo.warriors.module.logger.type.Source;
import com.yayo.warriors.module.map.facade.MapFacade;
import com.yayo.warriors.module.pack.type.BackpackType;
import com.yayo.warriors.module.props.entity.UserProps;
import com.yayo.warriors.module.props.manager.PropsManager;
import com.yayo.warriors.module.team.manager.TeamManager;
import com.yayo.warriors.module.team.model.Team;
import com.yayo.warriors.module.user.entity.Player;
import com.yayo.warriors.module.user.entity.PlayerBattle;
import com.yayo.warriors.module.user.manager.UserManager;
import com.yayo.warriors.module.user.model.UserDomain;
import com.yayo.warriors.module.user.type.Camp;
import com.yayo.warriors.socket.handler.chat.gm.GMHelper;
/**
* 聊天Facade实现类
*
* @author Hyint
*/
@Component
public class ChatFacadeImpl implements ChatFacade {
@Autowired
private GMHelper gmHelper;
@Autowired
private MapFacade mapFacade;
@Autowired
private DbService dbService;
@Autowired
private TeamManager teamManager;
@Autowired
private UserManager userManager;
@Autowired
private PropsManager propsManager;
@Autowired
private ChannelFacade channelFacade;
@Autowired
private SessionManager sessionManager;
@Autowired
private AllianceManager allianceManager;
private final Logger LOGGER = LoggerFactory.getLogger(getClass());
public int doPlayerChat(long playerId, int channel, String chatInfo, String targetName) {
UserDomain userDomain = userManager.getUserDomain(playerId);
if(userDomain == null) {
return PLAYER_NOT_FOUND;
}
Player player = userDomain.getPlayer();
if (player.isForbid2Chat()) {
return PLAYER_CHAT_FORBID;
}
ChatChannel chatChannel = EnumUtils.getEnum(ChatChannel.class, channel);
if (chatChannel == null) {
return CHANNEL_NOT_FOUND;
} else if (!chatChannel.isCanSend()) {
return CHANNEL_CHAT_FORBID;
}
try {
if(gmHelper.executeCode(userDomain, chatInfo)) {
return SUCCESS;
}
} catch (Exception e) {
LOGGER.error("{}", e);
}
if(!validateChatInfo(chatInfo)) {
return CHATINFO_TOO_LENGTH;
} else if(validateChatCoolTime(playerId)){
return PLAYER_CHAT_COOLTIME;
}
int result = SUCCESS;
switch (chatChannel) {
// TODO 2011年11月26日17:29:59 屏蔽此代码
// case CAMP_CHANNEL: return doCampChat(player, channel, chatInfo, showTerms);
case WORLD_CHANNEL: result = doWorldChat(userDomain, channel, chatInfo); break;
case TEAM_CHANNEL: result = doTeamChat(userDomain, channel, chatInfo); break;
case CAMP_CHANNEL: result = doCampChat(userDomain, channel, chatInfo); break;
case BUGLET_CHANNEL: result = doBugletChat(userDomain, channel, chatInfo); break;
case ALLIANCE_CHANNEL: result = doAllianceChat(userDomain, channel, chatInfo); break;
case CURRENT_CHANNEL: result = doCurrentChat(userDomain, channel, chatInfo); break;
case PRIVATE_CHANNEL: result = doPrivateChat(userDomain, channel, chatInfo, targetName); break;
}
if(result != SUCCESS) {
removeChatCoolTime(playerId);
}
return result;
}
/**
* 阵营聊天
*
* @param userDomain
* @param channel
* @param chatInfo
* @return
*/
private int doCampChat(UserDomain userDomain, int channel, String chatInfo) {
Player player = userDomain.getPlayer();
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("角色:[{}] 发送阵营聊天信息:[{}] ", player.getId(), chatInfo);
}
if(player.getCamp() == null || player.getCamp() == Camp.NONE) {
return FAILURE;
}
Channel channels = Channel.valueOf(channel, player.getCamp().ordinal());
Collection<Long> players = channelFacade.getChannelPlayers(channels);
if(players == null || players.isEmpty()) {
return SUCCESS;
}
ChatResponse chatResponse = toChatResponse(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(players, chatResponse);
return SUCCESS;
}
/**
* 小喇叭聊天
*
* @param userDomain 用户域模型对象
* @param channel 聊天频道
* @param chatInfo 聊天信息
* @return {@link Integer} 聊天返回值
*/
private int doBugletChat(UserDomain userDomain, int channel, String chatInfo) {
Player player = userDomain.getPlayer();
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("角色:[{}] 发送世界聊天信息:[{}] ", player.getId(), chatInfo);
}
int propsId = ChatRule.BUGLET_ITEM_ID;
long playerId = userDomain.getPlayerId();
int backpack = BackpackType.DEFAULT_BACKPACK;
List<UserProps> propsList = propsManager.listUserPropByBaseId(playerId, propsId, backpack);
if(propsList == null || propsList.isEmpty()) {
return ITEM_NOT_FOUND;
}
UserProps costProps = null;
for (UserProps entity : propsList) {
if(entity.getCount() <= 0 || entity.isOutOfExpiration() || entity.isTrading()) {
continue;
}
ChainLock lock = LockUtils.getLock(entity);
try {
lock.lock();
if(entity.getCount() <= 0 || entity.isOutOfExpiration() || entity.isTrading()) {
continue;
}
entity.decreaseItemCount(1);
dbService.submitUpdate2Queue(entity);
if(entity.getCount() <= 0) {
propsManager.put2UserPropsIdsList(playerId, BackpackType.DROP_BACKPACK, entity);
propsManager.removeFromUserPropsIdsList(playerId, backpack, entity);
}
} finally {
lock.unlock();
}
costProps = entity;
break;
}
if(costProps == null) {
return ITEM_NOT_FOUND;
}
Set<Long> onlinePlayers = sessionManager.getOnlinePlayerIdList();
if(!onlinePlayers.isEmpty()) {
ChatResponse chatResponse = toChatResponse(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(onlinePlayers, chatResponse);
}
MessagePushHelper.pushUserProps2Client(playerId, backpack, false, costProps);
GoodsLogger.goodsLogger(player, Source.PLAYER_CHAT, LoggerGoods.outcomeProps(costProps.getId(), propsId, 1));
return SUCCESS;
}
/**
* 验证聊天信息出长度
*
* @param chatInfo 聊天信息
* @return {@link Boolean} 是否可以聊天
*/
public boolean validateChatInfo(String chatInfo) {
return chatInfo == null || chatInfo.length() < ChatRule.MAX_CHAT_INFO_LENTH;
}
/**
* 验证角色的CD时间
*
* @param playerId 角色ID
* @return {@link Boolean} 是否可以聊天
*/
public boolean validateChatCoolTime(long playerId) {
IoSession session = sessionManager.getIoSession(playerId);
if(session == null){
return false;
}
Long cdTime = (Long)session.getAttribute(SessionType.LAST_CHAT_KEY);
long currentMillis = System.currentTimeMillis();
if(cdTime == null || cdTime <= currentMillis) {
session.setAttribute(SessionType.LAST_CHAT_KEY, currentMillis + ChatRule.CHAT_COOL_TIME);
return false;
}
return true;
}
/**
* 移除聊天冷却时间
*
* @param session 连接对象
* @param endTime 冷却的结束时间
*/
public void removeChatCoolTime(long playerId) {
IoSession session = sessionManager.getIoSession(playerId);
if(session != null){
session.removeAttribute(SessionType.LAST_CHAT_KEY);
}
}
/**
* 当前频道聊天
*
* @param player
* @param chatRequest
* @return
*/
private int doCurrentChat(UserDomain userDomain, int channel, String chatInfo) {
long playerId = userDomain.getPlayerId();
Collection<Long> playerIdList = mapFacade.getScreenViews(playerId);
ChatResponse chatResponse = toChatResponse(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(playerIdList, chatResponse);
return SUCCESS;
}
/**
* 私聊
*
* @param player
* @param chatRequest
* @return
*/
private int doPrivateChat(UserDomain userDomain, int channel, String chatInfo, String targetName) {
if (StringUtils.isBlank(targetName)) {
return TARGET_NOT_FOUND;
}
Player target = userManager.getPlayer(targetName);
if (target == null) {
return TARGET_NOT_FOUND;
}
long targetId = target.getId();
if(!userManager.isOnline(targetId)) {
return TARGET_OFF_LINE;
}
long playerId = userDomain.getPlayerId();
ChatResponse chatResponse = toChatResponse(userDomain, target, channel, chatInfo);
MessagePushHelper.pushChat2Client(Arrays.asList(playerId, targetId), chatResponse);
return SUCCESS;
}
/**
* 世界聊天
*
* @param <T>
*/
private int doWorldChat(UserDomain userDomain, int channel, String chatInfo) {
Player player = userDomain.getPlayer();
if(LOGGER.isDebugEnabled()) {
LOGGER.debug("角色:[{}] 发送世界聊天信息:[{}] ", player.getId(), chatInfo);
}
PlayerBattle battle = userDomain.getBattle();
if(battle.getLevel() < ChatRule.WORLD_CHAT_LEVEL) {
return LEVEL_INVALID;
}
Collection<Long> players = channelFacade.getBranchingPlayers(player.getBranching());
if(players == null || players.isEmpty()) {
return SUCCESS;
}
ChatResponse chatResponse = toChatResponse(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(players, chatResponse);
return SUCCESS;
}
/**
* 团队聊天
*
* @param <T>
* @return
*/
private int doTeamChat(UserDomain userDomain, int channel, String chatInfo) {
long playerId = userDomain.getPlayerId();
Team team = teamManager.getPlayerTeam(playerId);
if(team == null) {
return FAILURE;
}
List<Long> onlinePlayers = new ArrayList<Long>(team.getMembers());
ChatResponse chatResponse = toChatResponse(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(onlinePlayers, chatResponse);
return SUCCESS;
}
/**
* 工会聊天
*
* @param <T>
* @param player
* @param chatRequest
* @return
*/
private int doAllianceChat(UserDomain userDomain, int channel, String chatInfo) {
PlayerBattle battle = userDomain.getBattle();
PlayerAlliance playerAlliance = allianceManager.getPlayerAlliance(battle);
if(playerAlliance == null) {
return FAILURE;
}
long allianceId = playerAlliance.getAllianceId();
Alliance alliance = allianceManager.getAlliance(allianceId);
if(alliance == null) {
return FAILURE;
}
List<Long> memberIds = allianceManager.getAllianceMembers(allianceId,false);
if(memberIds == null || memberIds.isEmpty()) {
return FAILURE;
}
ChatResponse chatResponse = toAllianceChat(userDomain, null, channel, chatInfo);
MessagePushHelper.pushChat2Client(memberIds, chatResponse);
return SUCCESS;
}
// TODO 2011年11月26日17:29:40 屏蔽此代码
// /**
// * 阵营聊天
// *
// * @param <T>
// * @param player
// * @param chatRequest
// * @return
// */
// private int doCampChat(Player player, int channel, String chatInfo, ShowTerm[] showTerms) {
// Channel campChannel = Channel.valueOf(ChannelType.CLAZZ_CHANNEL.ordinal());
// Collection<Long> onlinePlayers = channelFacade.getChannelPlayers(campChannel);
// ChatResponse chatResponse = toChatResponse(player, null, channel, chatInfo, showTerms);
// onlinePlayers = onlinePlayers == null ? Arrays.asList(player.getId()) : onlinePlayers;
// messagePushHelper.pushChat2Client(onlinePlayers, chatResponse);
// return SUCCESS;
// }
/**
* 构建聊天响应信息
*
* @param userDomain 角色的域模型
* @param target 私聊接收者
* @param chatRequest 聊天请求对象
* @return {@link ChatResponse} 聊天响应对象
*/
private ChatResponse toChatResponse(UserDomain userDomain, Player target, int channel, String chatInfo) {
return ChatResponse.normalResponse(channel, chatInfo, userDomain, target);
}
/**
* 构建聊天响应信息
*
* @param userDomain 角色的域模型
* @param target 私聊接收者
* @param chatRequest 聊天请求对象
* @return {@link ChatResponse} 聊天响应对象
*/
private ChatResponse toAllianceChat(UserDomain userDomain, Player target, int channel, String chatInfo) {
return ChatResponse.allianceResponse(channel, chatInfo, userDomain, target);
}
}
| [
"zhuyuanbiao2013@gmail.com"
] | zhuyuanbiao2013@gmail.com |
2fb50a971335f78e313f98bde4c672828904ce0f | d27e2aadfa6458e4a7b0836911f9d878947cb5c3 | /lesson6-ATM/src/test/java/lesson6/ATMRunnerTest.java | c7b216f8599b1192b2dc14a541b2d3ed041680e7 | [] | no_license | nlyskov/HelloWorld | 3094d17c28bf5704c8561ca1de4493a5cb7bd672 | bb277d40cc3ecff165a06ac876322bec27f6537d | refs/heads/master | 2023-03-12T02:21:40.155802 | 2021-01-29T22:16:15 | 2021-01-29T22:16:15 | 297,778,009 | 0 | 0 | null | 2021-02-02T17:42:42 | 2020-09-22T21:36:22 | Java | UTF-8 | Java | false | false | 740 | java | package lesson6;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static lesson6.CellValues.FIVEHUNDRED;
import static org.junit.jupiter.api.Assertions.assertEquals;
class ATMRunnerTest {
Cell cell_500 = new Cell(10, FIVEHUNDRED);
@Test
@DisplayName("Проверка баланса")
void balance() {
assertEquals(5000, cell_500.count());
}
@Test
@DisplayName("Пополнение баланса")
void put_money() {
cell_500.give(10);
assertEquals(0, cell_500.count());
}
@Test
@DisplayName("Снятие наличных")
void get_money() {
cell_500.get(10);
assertEquals(10000, cell_500.count());
}
}
| [
"lyskovn@gmail.com"
] | lyskovn@gmail.com |
6034cc8df7f114faa5026f18085984f23d955628 | 1e973e252dc976faad5ef27f2b53afdcb551a4ec | /src/msg/Message.java | d882315038f7ba8a7918973f0590df0bd8a5d10e | [] | no_license | xiaofanlu/Paxos | 93b044c402e146f911db844a9d956dc2064e3bfc | 60521461b0890f4caa33c94e2461f00d606462aa | refs/heads/master | 2016-09-10T11:29:12.619563 | 2015-03-31T21:52:34 | 2015-03-31T21:52:34 | 32,872,496 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 385 | java | package msg;
import java.io.Serializable;
/**
* Created by xiaofan on 3/26/15.
*/
public abstract class Message implements Serializable {
public static final long serialVersionUID = 6473128480951955693L;
public int src;
public int dst;
public String print () {
String rst = "\n" + src + " -> " + dst + "\t";
rst += this.toString() + "\n";
return rst;
}
}
| [
"lvxiaofan@gmail.com"
] | lvxiaofan@gmail.com |
8c131bcccddee792b4e4503d8dccfcd8010cfe3b | 627dafa165ee4420680b4144c849e141596ae0b0 | /wecardio/wecardio/src/main/java/com/borsam/repository/dao/patient/PatientWalletHistoryDao.java | bc0cf2f378e8c7c637e61e938cfebffbb630e070 | [] | no_license | tan-tian/wecardio | 97339383a00ecd090dd952ea3c4c3f32dac8a6f2 | 5e291d19bce2d4cebd43040e4195a26d18d947c3 | refs/heads/master | 2020-04-03T01:01:57.429064 | 2018-10-25T15:26:50 | 2018-10-25T15:26:50 | 154,917,227 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 878 | java | package com.borsam.repository.dao.patient;
import com.borsam.repository.entity.patient.PatientWalletHistory;
import com.borsam.repository.entity.service.ServicePackage;
import com.hiteam.common.base.repository.dao.BaseDao;
import java.util.Calendar;
/**
* Dao - 患者账户流水信息
* Created by tantian on 2015/8/4.
*/
public interface PatientWalletHistoryDao extends BaseDao<PatientWalletHistory, Long> {
/**
* 通过交易号查找记录
* @param sn 交易号
* @return 流水信息
*/
public PatientWalletHistory findBySn(String sn);
/**
* 购买服务包时,新增记录
* @param servicePackage 服务包
* @param uid 患者ID
* @param now 当前时间
* @return PatientWalletHistory
*/
public PatientWalletHistory addLogInSellService(ServicePackage servicePackage, Long uid, Calendar now);
}
| [
"tantiant@126.com"
] | tantiant@126.com |
9a7f99d735e7304b18f818a935b078571e6fd41a | b8cb48bea613a32a15e8957dd4690d39d95f65cb | /app/src/main/java/com/zeno/quanxueclient/bean/Category.java | 8a41c06e0c6418daca019be511cf609c4ff77b9b | [] | no_license | feiwodev/QuanXueClient | a3df12dd4c32cce5dd5f712cbf0f45975e89aaff | 4140170f63d7d254ac11970d2c4169ec7edf1332 | refs/heads/master | 2021-06-12T15:32:55.328688 | 2017-03-19T13:48:46 | 2017-03-19T13:48:46 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,729 | java | package com.zeno.quanxueclient.bean;
import android.os.Parcel;
import android.os.Parcelable;
import org.greenrobot.greendao.annotation.Entity;
import org.greenrobot.greendao.annotation.Generated;
/**
* Created by Administrator on 2016/12/7.
*
* 首页分类 item bean
*/
@Entity
public class Category implements Parcelable {
private String name;
private String desc;
private String picUrl;
private String webBaseUrl;
private String url;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDesc() {
return desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public String getPicUrl() {
return picUrl;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public String getWebBaseUrl() {
return webBaseUrl;
}
public void setWebBaseUrl(String webBaseUrl) {
this.webBaseUrl = webBaseUrl;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
@Override
public int describeContents() {
return 0;
}
@Override
public void writeToParcel(Parcel dest, int flags) {
dest.writeString(this.name);
dest.writeString(this.desc);
dest.writeString(this.picUrl);
dest.writeString(this.webBaseUrl);
dest.writeString(this.url);
}
public Category() {
}
protected Category(Parcel in) {
this.name = in.readString();
this.desc = in.readString();
this.picUrl = in.readString();
this.webBaseUrl = in.readString();
this.url = in.readString();
}
@Generated(hash = 1160807505)
public Category(String name, String desc, String picUrl, String webBaseUrl, String url) {
this.name = name;
this.desc = desc;
this.picUrl = picUrl;
this.webBaseUrl = webBaseUrl;
this.url = url;
}
public static final Parcelable.Creator<Category> CREATOR = new Parcelable.Creator<Category>() {
@Override
public Category createFromParcel(Parcel source) {
return new Category(source);
}
@Override
public Category[] newArray(int size) {
return new Category[size];
}
};
@Override
public String toString() {
return "Category{" +
"name='" + name + '\'' +
", desc='" + desc + '\'' +
", picUrl='" + picUrl + '\'' +
", webBaseUrl='" + webBaseUrl + '\'' +
", url='" + url + '\'' +
'}';
}
}
| [
"zhuyongit@163.com"
] | zhuyongit@163.com |
459fa0171680709528833918213af63cf032147b | 2aab562ac4b473fb3c5ad64ab0a3efded35f5da5 | /src/main/java/com/symbio/epb/bigfile/utils/JSONUtil.java | 66213bca74b4fc190a01ebc1234952b13e81c08e | [] | no_license | jly12345/PARSER | f92a79f6077c92a818ef6f5ab860555de2cc4507 | 277b4b3127f937cadf02b0f40939d06aee49490a | refs/heads/master | 2022-07-15T23:56:29.182078 | 2019-08-27T10:24:58 | 2019-08-27T10:24:58 | 204,661,091 | 0 | 0 | null | 2022-06-17T02:26:56 | 2019-08-27T08:52:18 | CSS | UTF-8 | Java | false | false | 1,418 | java | package com.symbio.epb.bigfile.utils;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.util.StringUtils;
import java.util.Map;
/**
*
* @author Yao Pan
*
*/
public class JSONUtil {
private final static ObjectMapper mapper = new ObjectMapper();
public static Object formatStr2Object(String json, Class<?> clazz) {
if (StringUtils.isEmpty(json)) {
return null;
}
try {
return mapper.readValue(json, clazz);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static JsonNode formatStr2JSONNode(String json) {
if (StringUtils.isEmpty(json)) {
return null;
}
try {
return mapper.readTree(json);
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
public static String formatOject2Str(Object object) {
if (object == null) {
return null;
}
try {
return mapper.writeValueAsString(object);
} catch (JsonProcessingException e) {
e.printStackTrace();
return null;
}
}
@SuppressWarnings("unchecked")
public static Map<? extends String, ? extends Object> convertJsonNodeToMap(JsonNode source) {
if(source==null){
return null;
}else{
Map<String, Object> result = mapper.convertValue(source, Map.class);
return result;
}
}
}
| [
"lingyun.jiang@symbio.com"
] | lingyun.jiang@symbio.com |
bad51764ca1e4ba8067f425eec75e9f4e28e7df6 | 7a7291b74e007f0d26d9bf2232f012df715ee3fa | /shareitemservice/src/main/java/com/xinflood/dao/ImageDao.java | 57ec91b069591d898849ceb7cad03344ce25c2eb | [] | no_license | ethan-fang/slickrent-backend | 29ecad0911902e99d6d837aec52ee5b5b547092f | 39baaf221b3492dde22d74803f90b3f51135248d | refs/heads/master | 2021-01-21T09:02:21.694455 | 2015-03-25T04:26:04 | 2015-03-25T04:26:04 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 233 | java | package com.xinflood.dao;
import java.io.IOException;
/**
* Created by xinxinwang on 11/16/14.
*/
public interface ImageDao {
boolean putImage(String key, byte[] image);
byte[] getImage(String key) throws IOException;
}
| [
"xinxin.wang.1@gmail.com"
] | xinxin.wang.1@gmail.com |
31b59c1910b813dce28958332e04b2cc6fb37391 | 54a64717c5279139fd8059b1a56403bf158a2526 | /library_base/src/main/java/cc/onion/cosyfans/base/network/ssl/SSLFactory.java | a25cf22b2d322178bc96552ef8eec2723144a56e | [] | no_license | guobihai/OnionCosyFans | 1c5f0c84dc240b8c7f8367c7f87f80ff1c8012ac | 8dc8cdbd8655834956b0e6a5c5504e6f74c43837 | refs/heads/master | 2023-02-21T06:30:50.988337 | 2021-01-21T05:44:41 | 2021-01-21T05:44:41 | 331,527,140 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 8,864 | java | /*
* Copyright 2016 jeasonlzy(廖子尧)
*
* 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 cc.onion.cosyfans.base.network.ssl;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyManagementException;
import java.security.KeyStore;
import java.security.NoSuchAlgorithmException;
import java.security.cert.Certificate;
import java.security.cert.CertificateException;
import java.security.cert.CertificateFactory;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.KeyManager;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager;
import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509TrustManager;
public class SSLFactory {
public static class SSLParams {
public SSLSocketFactory sSLSocketFactory;
public X509TrustManager trustManager;
}
public static SSLParams getSslSocketFactory() {
return getSslSocketFactoryBase(null, null, null);
}
/**
* https单向认证
* 可以额外配置信任服务端的证书策略,否则默认是按CA证书去验证的,若不是CA可信任的证书,则无法通过验证
*/
public static SSLParams getSslSocketFactory(X509TrustManager trustManager) {
return getSslSocketFactoryBase(trustManager, null, null);
}
/**
* https单向认证
* 用含有服务端公钥的证书校验服务端证书
*/
public static SSLParams getSslSocketFactory(InputStream... certificates) {
return getSslSocketFactoryBase(null, null, null, certificates);
}
/**
* https双向认证
* bksFile 和 password -> 客户端使用bks证书校验服务端证书
* certificates -> 用含有服务端公钥的证书校验服务端证书
*/
public static SSLParams getSslSocketFactory(InputStream bksFile, String password, InputStream... certificates) {
return getSslSocketFactoryBase(null, bksFile, password, certificates);
}
/**
* https双向认证
* bksFile 和 password -> 客户端使用bks证书校验服务端证书
* X509TrustManager -> 如果需要自己校验,那么可以自己实现相关校验,如果不需要自己校验,那么传null即可
*/
public static SSLParams getSslSocketFactory(InputStream bksFile, String password, X509TrustManager trustManager) {
return getSslSocketFactoryBase(trustManager, bksFile, password);
}
private static SSLParams getSslSocketFactoryBase(X509TrustManager trustManager, InputStream bksFile, String password, InputStream... certificates) {
SSLParams sslParams = new SSLParams();
try {
KeyManager[] keyManagers = prepareKeyManager(bksFile, password);
TrustManager[] trustManagers = prepareTrustManager(certificates);
X509TrustManager manager;
if (trustManager != null) {
//优先使用用户自定义的TrustManager
manager = trustManager;
} else if (trustManagers != null) {
//然后使用默认的TrustManager
manager = chooseTrustManager(trustManagers);
} else {
//否则使用不安全的TrustManager
manager = UnSafeTrustManager;
}
// 创建TLS类型的SSLContext对象, that uses our TrustManager
SSLContext sslContext = SSLContext.getInstance("TLS");
// 用上面得到的trustManagers初始化SSLContext,这样sslContext就会信任keyStore中的证书
// 第一个参数是授权的密钥管理器,用来授权验证,比如授权自签名的证书验证。第二个是被授权的证书管理器,用来验证服务器端的证书
sslContext.init(keyManagers, new TrustManager[]{manager}, null);
// 通过sslContext获取SSLSocketFactory对象
sslParams.sSLSocketFactory = sslContext.getSocketFactory();
sslParams.trustManager = manager;
return sslParams;
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
} catch (KeyManagementException e) {
throw new AssertionError(e);
}
}
private static KeyManager[] prepareKeyManager(InputStream bksFile, String password) {
try {
if (bksFile == null || password == null) return null;
KeyStore clientKeyStore = KeyStore.getInstance("BKS");
clientKeyStore.load(bksFile, password.toCharArray());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientKeyStore, password.toCharArray());
return kmf.getKeyManagers();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static TrustManager[] prepareTrustManager(InputStream... certificates) {
if (certificates == null || certificates.length <= 0) return null;
try {
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
// 创建一个默认类型的KeyStore,存储我们信任的证书
KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
keyStore.load(null);
int index = 0;
for (InputStream certStream : certificates) {
String certificateAlias = Integer.toString(index++);
// 证书工厂根据证书文件的流生成证书 cert
Certificate cert = certificateFactory.generateCertificate(certStream);
// 将 cert 作为可信证书放入到keyStore中
keyStore.setCertificateEntry(certificateAlias, cert);
try {
if (certStream != null) certStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
//我们创建一个默认类型的TrustManagerFactory
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
//用我们之前的keyStore实例初始化TrustManagerFactory,这样tmf就会信任keyStore中的证书
tmf.init(keyStore);
//通过tmf获取TrustManager数组,TrustManager也会信任keyStore中的证书
return tmf.getTrustManagers();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
private static X509TrustManager chooseTrustManager(TrustManager[] trustManagers) {
for (TrustManager trustManager : trustManagers) {
if (trustManager instanceof X509TrustManager) {
return (X509TrustManager) trustManager;
}
}
return null;
}
/**
* 为了解决客户端不信任服务器数字证书的问题,网络上大部分的解决方案都是让客户端不对证书做任何检查,
* 这是一种有很大安全漏洞的办法
*/
public static X509TrustManager UnSafeTrustManager = new X509TrustManager() {
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {
}
@Override
public X509Certificate[] getAcceptedIssuers() {
return new X509Certificate[]{};
}
};
/**
* 此类是用于主机名验证的基接口。 在握手期间,如果 URL 的主机名和服务器的标识主机名不匹配,
* 则验证机制可以回调此接口的实现程序来确定是否应该允许此连接。策略可以是基于证书的或依赖于其他验证方案。
* 当验证 URL 主机名使用的默认规则失败时使用这些回调。如果主机名是可接受的,则返回 true
*/
public static HostnameVerifier UnSafeHostnameVerifier = new HostnameVerifier() {
@Override
public boolean verify(String hostname, SSLSession session) {
return true;
}
};
}
| [
"15920165683@163.com"
] | 15920165683@163.com |
158c0f6a071698c8479e3f91a9c9b267a198650b | 6be39fc2c882d0b9269f1530e0650fd3717df493 | /weixin反编译/sources/com/d/a/a/ac.java | d1f34719638b3d7e6404f57046b1bffecc4d8b2a | [] | no_license | sir-deng/res | f1819af90b366e8326bf23d1b2f1074dfe33848f | 3cf9b044e1f4744350e5e89648d27247c9dc9877 | refs/heads/master | 2022-06-11T21:54:36.725180 | 2020-05-07T06:03:23 | 2020-05-07T06:03:23 | 155,177,067 | 5 | 0 | null | null | null | null | UTF-8 | Java | false | false | 322 | java | package com.d.a.a;
import android.net.wifi.WifiManager;
import android.os.Handler;
final class ac extends e {
private final WifiManager bni;
ac(WifiManager wifiManager, Handler handler) {
super(handler);
this.bni = wifiManager;
}
final void rW() {
this.bni.startScan();
}
}
| [
"denghailong@vargo.com.cn"
] | denghailong@vargo.com.cn |
86d669049fd97fbf4ba07ce6dc77af43550a4bb3 | 3a19da00fdcddeaa3694286369f76e4169d47c26 | /consumer/src/main/java/com/example/demo/config/KafkaConsumerConfig.java | 4c16f65c6f95a1212c4133aa87d9adc46101bb88 | [] | no_license | cyborgmg/spring-kafaka-object-ssl | ebccf9f9ad5b2ba3414110d0b7ba6b0c28ea020d | 66b297fa4cbf95275f4453c50c212984e25a44cb | refs/heads/main | 2023-04-11T04:28:39.184897 | 2021-04-25T08:22:28 | 2021-04-25T08:22:28 | 358,651,678 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 4,394 | java | package com.example.demo.config;
import com.example.demo.model.FooObject;
import com.example.demo.utils.ConstUtils;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.kafka.clients.CommonClientConfigs;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.common.config.SslConfigs;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.config.ConcurrentKafkaListenerContainerFactory;
import org.springframework.kafka.core.ConsumerFactory;
import org.springframework.kafka.core.DefaultKafkaConsumerFactory;
import org.springframework.kafka.listener.ContainerProperties;
import org.springframework.kafka.support.serializer.JsonDeserializer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Configuration
@EnableKafka
public class KafkaConsumerConfig {
@Value("${spring.cloud.stream.bootstrap-servers}")
private String bootstrapAddress;
@Value("${spring.cloud.stream.kafka-truststore-directory}")
private String kafkaTruststoreDirectory;
@Value("${spring.cloud.stream.kafka-truststore-password}")
private String kafkaTruststorePassword;
@Value("${spring.cloud.stream.kafka-keystore-directory}")
private String kafkaKeystoreDirectory;
@Value("${spring.cloud.stream.kafka-keystore-password}")
private String kafkaKeystorePassword;
public Map<String, Object> consumerConfigs() {
Map<String, Object> props = new HashMap<>();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ConsumerConfig.KEY_DESERIALIZER_CLASS_CONFIG, StringDeserializer.class);
props.put(ConsumerConfig.VALUE_DESERIALIZER_CLASS_CONFIG, JsonDeserializer.class);
props.put(ConsumerConfig.GROUP_ID_CONFIG, ConstUtils.GROUP);
props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
props.put(ConsumerConfig.ENABLE_AUTO_COMMIT_CONFIG, "false");
props.put(ConsumerConfig.MAX_POLL_RECORDS_CONFIG, "100"); // TODO ACERTAR PARA COLOCAR A QUANTIDADE NA // CONFIGURAÇÃO
// SSL encryption
props.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
props.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, kafkaKeystoreDirectory);
props.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, kafkaKeystorePassword);
props.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, kafkaTruststoreDirectory);
props.put(SslConfigs.SSL_KEY_PASSWORD_CONFIG, kafkaKeystorePassword);
props.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, kafkaTruststorePassword);
return props;
}
public ConsumerFactory<String, FooObject> consumerFactoryFooObject() {
return new DefaultKafkaConsumerFactory<>(consumerConfigs(),new StringDeserializer(),new JsonDeserializer<>(FooObject.class));
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, FooObject> fooListenerFooObject() {
ConcurrentKafkaListenerContainerFactory<String, FooObject> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactoryFooObject());
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
return factory;
}
public ConsumerFactory<String, List<FooObject>> consumerFactoryListFooObject(){
ObjectMapper om = new ObjectMapper();
JavaType type = om.getTypeFactory().constructParametricType(List.class, FooObject.class);
return new DefaultKafkaConsumerFactory<>(consumerConfigs(),new StringDeserializer(), new JsonDeserializer<List<FooObject>>(type, om, false));
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, List<FooObject>> fooListenerListFooObject(){
ConcurrentKafkaListenerContainerFactory<String, List<FooObject>> factory = new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactoryListFooObject());
factory.getContainerProperties().setAckMode(ContainerProperties.AckMode.MANUAL_IMMEDIATE);
return factory;
}
}
| [
"cyborgmg@gmail.com"
] | cyborgmg@gmail.com |
057a13fbb97424dd9b4fe185f0b5103a4a3e5dc2 | cd9ac93222da1264da2f97a4ac4c8e1454aedc7e | /23. JDBC [Java DataBase Connectivity]/src/DAO/Address/First/AddressDAO1.java | bd823980c5fb5e1cc67afd7bac2f4ccb11417d3d | [] | no_license | SeulkiWave/Eclipse_WorkSpace | d3a407c0f302721c57072d3fc4cb51751476121d | 6e19b69a7474a44c6a1d3a200e3297eebb6f70bf | refs/heads/master | 2023-06-22T05:53:45.406071 | 2021-07-21T00:19:36 | 2021-07-21T00:19:36 | 376,490,590 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 4,238 | java | /*
* DAO (Data Access Object)
- 회원들의 데이터를 저장하고 있는 파일(테이블)에 CRUD(Create, Read, Update, Delete) 작업을 할수있는 단위 메소드를 가지고 있는 클래스
-> 단위 메소드는 CRUD 업무만 담당!
- MemberService 객체의 요청(메소드 호출)을 받아서 Data Access(File, DB)에 관련된 단위기능(CRUD)을 수행하는 객체
*/
package DAO.Address.First;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class AddressDAO1 {
public void insert() throws Exception {
String driverClass = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@182.237.126.19:1521:xe";
String user = "javadeveloper0";
String password = "javadeveloper0";
String insertSql = "insert into address values(address_no_seq.nextval,'guard','김경호','123-4568','경기도 성남시')";//semicolon있으면 애로사항발생~~~~
Class.forName(driverClass);
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
int insertRowCount = stmt.executeUpdate(insertSql);
System.out.println(">> " + insertRowCount + " 행 insert");
stmt.close();
con.close();
}
public void deleteByNum() throws Exception{
String driverClass = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@182.237.126.19:1521:xe";
String user = "javadeveloper7";
String password = "javadeveloper7";
String deleteSQL = "delete address where no=1";
Class.forName(driverClass);
Connection con = DriverManager.getConnection(url, user, password);
Statement state = con.createStatement();
int deleteRowCount = state.executeUpdate(deleteSQL);
System.out.println(">> "+deleteRowCount);
}
public void updateByNum() throws Exception {
String driverClass = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@182.237.126.19:1521:xe";
String user = "javadeveloper7";
String password = "javadeveloper7";
String updateSQL = "update address set id='xxx',name='김경호',phone='899-9999',address='서울시 강남구' where no = 1";
Class.forName(driverClass); // 1
Connection con = DriverManager.getConnection(url, user, password); // 2
Statement state = con.createStatement(); // 3
int updateRowCount = state.executeUpdate(updateSQL);
System.out.println(">> "+updateRowCount);
}
public void selectByNum() throws Exception {
String driverClass = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@182.237.126.19:1521:xe";
String user = "javadeveloper0";
String password = "javadeveloper0";
String selectSql = "select no,id,name,phone,address from address where no=8";//semicolon있으면 애로사항발생~~~~
Class.forName(driverClass);
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(selectSql);
while (rs.next()) {
int no = rs.getInt("no");
String id = rs.getString("id");
String name = rs.getString("name");
String phone = rs.getString("phone");
String address = rs.getString("address");
System.out.println(no + "\t" + id + "\t" + name + "\t" + phone + "\t" + address);
}
rs.close();
stmt.close();
con.close();
}
public void selectAll() throws Exception {
String driverClass = "oracle.jdbc.OracleDriver";
String url = "jdbc:oracle:thin:@182.237.126.19:1521:xe";
String user = "javadeveloper0";
String password = "javadeveloper0";
String selectSql = "select no,id,name,phone,address from address";
Class.forName(driverClass);
Connection con = DriverManager.getConnection(url, user, password);
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery(selectSql);
while (rs.next()) {
int no = rs.getInt("no");
String id = rs.getString("id");
String name = rs.getString("name");
String phone = rs.getString("phone");
String address = rs.getString("address");
System.out.println(no + "\t" + id + "\t" + name + "\t" + phone + "\t" + address);
}
rs.close();
stmt.close();
con.close();
}
}
| [
"qnelw@DESKTOP-5D0UTA3"
] | qnelw@DESKTOP-5D0UTA3 |
585acf0d0bcba6be5663fb874b2f1f001450eabb | 02a65ed890e4346db7f63ccfe20d7a0f44dca044 | /src/InvertedIndex.java | a098205e3236407ab49d3f60e1bbb9afa0141c10 | [] | no_license | apostolosxenos/WorkingWithBigData | 7b8353868dc57853f9071af0e604f305da738278 | e352d58182798a696fa22c226d2ca0ee55b04786 | refs/heads/main | 2023-06-22T17:44:21.024239 | 2021-07-05T09:53:13 | 2021-07-05T09:53:13 | 383,082,130 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 3,216 | java | import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.mapreduce.InputSplit;
import org.apache.hadoop.mapreduce.lib.input.FileSplit;
public class InvertedIndex {
public static class WordMapper extends Mapper<Object, Text, Text, Text> {
private int n;
// Method that sets up to the program the minimum word's length
protected void setup(Context context) throws IOException, InterruptedException {
Configuration conf = context.getConfiguration();
n = Integer.parseInt(conf.get("N"));
}
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
String fileName = ((FileSplit) context.getInputSplit()).getPath().getName();
String lineWithoutPunctuation = value.toString().replaceAll("[^a-zA-Z ]", " ");
String inCaseSensitiveLine = lineWithoutPunctuation.toLowerCase();
StringTokenizer iterator = new StringTokenizer(inCaseSensitiveLine);
while (iterator.hasMoreTokens()) {
String nextWord = iterator.nextToken().trim();
// Word with length greater than user's input will be added to the context
if (nextWord.length() >= n) {
context.write(new Text(nextWord), new Text(fileName));
}
}
}
}
public static class WordFileNameSumReducer extends Reducer<Text, Text, Text, Text> {
private Set<String> fileNames;
public void reduce(Text key, Iterable<Text> values, Context context) throws IOException, InterruptedException {
fileNames = new HashSet<String>();
// Deduplicates files' names
for (Text val : values) {
fileNames.add(val.toString());
}
context.write(key, new Text(fileNames.toString()));
}
}
public static void main(String[] args) throws IOException, InterruptedException, ClassNotFoundException {
if (args.length != 3) {
throw new IllegalArgumentException("Usage <in> <out> <word's min length>");
}
Configuration conf = new Configuration();
conf.setInt("N", Integer.parseInt(args[2]));
Job job = Job.getInstance(conf, "inverted-index");
job.setJarByClass(InvertedIndex.class);
job.setMapperClass(WordMapper.class);
job.setReducerClass(WordFileNameSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
} | [
"apostolosxenos@outlook.com"
] | apostolosxenos@outlook.com |
8f1ddc286de45182e89683de09c0607cf81c312d | 4378af1f10f32f720f46af7fe9c382a149c6748f | /src/Entidades/hr_job.java | 215b6b51b9a55c8d84f11d9dfb6e27f3838bc7d1 | [
"MIT"
] | permissive | robante15/odoo-connector | 9b02b343def92a1d3d00d5f4d4601aaebf189841 | 1d91569e12771f4cf689313ce1669ca97227ac22 | refs/heads/master | 2021-03-14T05:05:54.104237 | 2020-03-17T05:06:14 | 2020-03-17T05:06:14 | 246,739,097 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 5,593 | 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 Entidades;
/**
*
* @author Usuario
*/
public class hr_job {
int id;
int message_main_attachment_id;
String name;
int expected_employees;
int no_if_employee;
int no_of_recruitment;
int no_of_hired_employee;
String description;
String requirements;
int department_id;
String state;
int create_uid;
String create_date; // Reemplazar el tipo de dato
int write_uid;
String write_date;
int address_id;
int manager_id;
int user_id;
int hr_responsible_id;
int alias_id;
int color;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getMessage_main_attachment_id() {
return message_main_attachment_id;
}
public void setMessage_main_attachment_id(int message_main_attachment_id) {
this.message_main_attachment_id = message_main_attachment_id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getExpected_employees() {
return expected_employees;
}
public void setExpected_employees(int expected_employees) {
this.expected_employees = expected_employees;
}
public int getNo_if_employee() {
return no_if_employee;
}
public void setNo_if_employee(int no_if_employee) {
this.no_if_employee = no_if_employee;
}
public int getNo_of_recruitment() {
return no_of_recruitment;
}
public void setNo_of_recruitment(int no_of_recruitment) {
this.no_of_recruitment = no_of_recruitment;
}
public int getNo_of_hired_employee() {
return no_of_hired_employee;
}
public void setNo_of_hired_employee(int no_of_hired_employee) {
this.no_of_hired_employee = no_of_hired_employee;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getRequirements() {
return requirements;
}
public void setRequirements(String requirements) {
this.requirements = requirements;
}
public int getDepartment_id() {
return department_id;
}
public void setDepartment_id(int department_id) {
this.department_id = department_id;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public int getCreate_uid() {
return create_uid;
}
public void setCreate_uid(int create_uid) {
this.create_uid = create_uid;
}
public String getCreate_date() {
return create_date;
}
public void setCreate_date(String create_date) {
this.create_date = create_date;
}
public int getWrite_uid() {
return write_uid;
}
public void setWrite_uid(int write_uid) {
this.write_uid = write_uid;
}
public String getWrite_date() {
return write_date;
}
public void setWrite_date(String write_date) {
this.write_date = write_date;
}
public int getAddress_id() {
return address_id;
}
public void setAddress_id(int address_id) {
this.address_id = address_id;
}
public int getManager_id() {
return manager_id;
}
public void setManager_id(int manager_id) {
this.manager_id = manager_id;
}
public int getUser_id() {
return user_id;
}
public void setUser_id(int user_id) {
this.user_id = user_id;
}
public int getHr_responsible_id() {
return hr_responsible_id;
}
public void setHr_responsible_id(int hr_responsible_id) {
this.hr_responsible_id = hr_responsible_id;
}
public int getAlias_id() {
return alias_id;
}
public void setAlias_id(int alias_id) {
this.alias_id = alias_id;
}
public int getColor() {
return color;
}
public void setColor(int color) {
this.color = color;
}
public hr_job(int id, int message_main_attachment_id, String name, int expected_employees, int no_if_employee, int no_of_recruitment, int no_of_hired_employee, String description, String requirements, int department_id, String state, int create_uid, String create_date, int write_uid, String write_date, int address_id, int manager_id, int user_id, int hr_responsible_id, int alias_id, int color) {
this.id = id;
this.message_main_attachment_id = message_main_attachment_id;
this.name = name;
this.expected_employees = expected_employees;
this.no_if_employee = no_if_employee;
this.no_of_recruitment = no_of_recruitment;
this.no_of_hired_employee = no_of_hired_employee;
this.description = description;
this.requirements = requirements;
this.department_id = department_id;
this.state = state;
this.create_uid = create_uid;
this.create_date = create_date;
this.write_uid = write_uid;
this.write_date = write_date;
this.address_id = address_id;
this.manager_id = manager_id;
this.user_id = user_id;
this.hr_responsible_id = hr_responsible_id;
this.alias_id = alias_id;
this.color = color;
}
}
| [
"robante12@gmail.com"
] | robante12@gmail.com |
58044802a72fe896db4b67f360d2a8c2ec6f3e7b | afa910e7b1be367841c0677c1313b0945e3c0a8e | /Java/Elias/Moko/src/moko/client/ClientMain.java | 0eeec207fa8b55825c05cd461835f20ac6105774 | [] | no_license | melikestolearn/uniworks | a07144a63d053a44eb0369985dc1240c36e6b8c0 | 063f8ee612d1d17047982d556684d6035a28788f | refs/heads/master | 2020-12-24T15:40:17.177558 | 2012-03-23T15:04:48 | 2012-03-23T15:04:48 | 2,606,866 | 2 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,561 | java | package moko.client;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;
import javax.swing.JOptionPane;
public class ClientMain {
private static Console console;
private static Socket server;
public static void main(String[] args) throws IOException, InterruptedException {
final BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String serverIP = null;
int port = 0;
String name = null;
String inputS = JOptionPane.showInputDialog("Enter Server Adress");
serverIP = inputS;
String inputP = JOptionPane.showInputDialog("Enter Server Port");
port = Integer.parseInt(inputP);
String inputN = JOptionPane.showInputDialog("Enter your name");
name = inputN;
server = new Socket(serverIP, port);
final OutputStream serverOutStream = server.getOutputStream();
final PrintWriter serverOutWriter = new PrintWriter(new OutputStreamWriter(serverOutStream));
serverOutWriter.println(name);
serverOutWriter.flush();
new Thread(new Runnable() {
public void run() {
console = new Console("Moko");
}
}).start();
Thread.sleep(1000);
final KeyboardReader keybrdReader = new KeyboardReader(console, serverOutStream);
final ServerWriter svrWriter = new ServerWriter(console, server.getInputStream());
keybrdReader.start();
svrWriter.start();
}
public static Socket getMySocket() {
return server;
}
}
| [
"Mayer25@hm.edu"
] | Mayer25@hm.edu |
cde7faafffc6460de2065d7f33caf77685ebb977 | 6c56eababec22b43f26bc4d5cf6021fe85df6a61 | /dspace-xmlui/dspace-xmlui-wing/src/main/java/org/dspace/app/xmlui/wing/element/Select.java | f8c267ada15d10dc19227fb5278029cb77ad5df8 | [] | no_license | osulibraries/dspace-daln | cf040e24997abe25f72f898ffd5cffa9c6814a27 | 08a55349b5ebd1c126ba696e3ec6cb6f6546e11d | refs/heads/master | 2021-01-20T19:26:22.629154 | 2016-08-18T14:14:12 | 2016-08-18T14:14:12 | 65,042,498 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 10,466 | java | /*
* Select.java
*
* Version: $Revision: 3705 $
*
* Date: $Date: 2009-04-11 13:02:24 -0400 (Sat, 11 Apr 2009) $
*
* Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
* Institute of Technology. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* - Neither the name of the Hewlett-Packard Company nor the name of the
* Massachusetts Institute of Technology nor the names of their
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*/
package org.dspace.app.xmlui.wing.element;
/**
*
* A class representing a select input control. The select input control allows
* the user to select from a list of available options.
*
* @author Scott Phillips
*/
import org.dspace.app.xmlui.wing.Message;
import org.dspace.app.xmlui.wing.WingContext;
import org.dspace.app.xmlui.wing.WingException;
public class Select extends Field
{
/**
* Construct a new field.
*
* @param context
* (Required) The context this element is contained in, such as
* where to route SAX events and what i18n catalogue to use.
*
* @param name
* (Required) a non-unique local identifier used to differentiate
* the element from its siblings within an interactive division.
* This is the name of the field use when data is submitted back
* to the server.
* @param rend
* (May be null) a rendering hint used to override the default
* display of the element.
*/
protected Select(WingContext context, String name, String rend)
throws WingException
{
super(context, name, Field.TYPE_SELECT, rend);
this.params = new Params(context);
}
/**
* Enable the user to select multiple options.
*
*/
public void setMultiple()
{
this.params.setMultiple(true);
}
/**
* Set whether the user is able to select multiple options.
*
* @param multiple
* (Required) The multiple state.
*/
public void setMultiple(boolean multiple)
{
this.params.setMultiple(multiple);
}
/**
* Set the number of options visible at any one time.
*
* @param size
* (Required) The number of options to display.
*/
public void setSize(int size)
{
this.params.setSize(size);
}
/**
* Enable the add operation for this field. When this is enabled the
* front end will add a button to add more items to the field.
*
*/
public void enableAddOperation() throws WingException
{
this.params.enableAddOperation();
}
/**
* Enable the delete operation for this field. When this is enabled then
* the front end will provide a way for the user to select fields (probably
* checkboxes) along with a submit button to delete the selected fields.
*
*/
public void enableDeleteOperation()throws WingException
{
this.params.enableDeleteOperation();
}
/**
* Add a select option.
*
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
*/
public Option addOption(String returnValue)
throws WingException
{
Option option = new Option(context, returnValue);
options.add(option);
return option;
}
/**
* Add a select option.
*
* @param selected
* (Required) Set the field as selected.
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
*/
public Option addOption(boolean selected, String returnValue)
throws WingException
{
if (selected)
setOptionSelected(returnValue);
return addOption(returnValue);
}
/**
* Add a select option.
*
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param characters
* (Required) The text to set as the visible option.
*/
public void addOption(String returnValue, String characters) throws WingException
{
Option option = this.addOption(returnValue);
option.addContent(characters);
}
/**
* Add a select option.
*
* @param selected
* (Required) Set the field as selected.
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param characters
* (Required) The text to set as the visible option.
*/
public void addOption(boolean selected,String returnValue, String characters) throws WingException
{
if (selected)
setOptionSelected(returnValue);
addOption(returnValue,characters);
}
/**
* Add a select option.
*
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param characters
* (Required) The text to set as the visible option.
*/
public void addOption(int returnValue, String characters) throws WingException
{
Option option = this.addOption(String.valueOf(returnValue));
option.addContent(characters);
}
/**
* Add a select option.
*
* @param selected
* (Required) Set the field as selected.
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param characters
* (Required) The text to set as the visible option.
*/
public void addOption(boolean selected, int returnValue, String characters) throws WingException
{
if (selected)
setOptionSelected(returnValue);
addOption(returnValue,characters);
}
/**
* Add a select option.
*
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param message
* (Required) The transalted text to set as the visible option.
*/
public void addOption(String returnValue, Message message) throws WingException
{
Option option = this.addOption(returnValue);
option.addContent(message);
}
/**
* Add a select option.
*
* @param selected
* (Required) Set the field as selected.
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param message
* (Required) The transalted text to set as the visible option.
*/
public void addOption(boolean selected, String returnValue, Message message) throws WingException
{
if (selected)
setOptionSelected(returnValue);
addOption(returnValue,message);
}
/**
* Add a select option.
*
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param message
* (Required) The transalted text to set as the visible option.
*/
public void addOption(int returnValue, Message message) throws WingException
{
Option option = this.addOption(String.valueOf(returnValue));
option.addContent(message);
}
/**
* Add a select option.
*
* @param selected
* (Required) Set the field as selected.
* @param returnValue
* (Required) The value to be passed back if this option is
* selected.
* @param message
* (Required) The transalted text to set as the visible option.
*/
public void addOption(boolean selected, int returnValue, Message message) throws WingException
{
if (selected)
setOptionSelected(returnValue);
addOption(returnValue,message);
}
/**
* Set the given option as selected.
*
* @param returnValue
* (Required) The return value of the option to be selected.
*/
public void setOptionSelected(String returnValue) throws WingException
{
Value value = new Value(context,Value.TYPE_OPTION,returnValue);
values.add(value);
}
/**
* Set the given option as selected.
*
* @param returnValue
* (Required) The return value of the option to be selected.
*/
public void setOptionSelected(int returnValue) throws WingException
{
Value value = new Value(context,Value.TYPE_OPTION,String.valueOf(returnValue));
values.add(value);
}
/**
* Add a field instance
* @return instance
*/
public Instance addInstance() throws WingException
{
Instance instance = new Instance(context);
instances.add(instance);
return instance;
}
}
| [
"hinshaw.25@osu.edu"
] | hinshaw.25@osu.edu |
a24003976c0126f2b7ce8c386aad2d0d636feb81 | ea149bac265fd790d8f1527be2ef3e4eaa261f4c | /src/solution39.java | c6297a755bd80ff1ee48c9579f5dcf8cc4885eb2 | [] | no_license | pengxinyu-hub/leetcode | 495bca1bbf63612064f3a8585bc2aa22a4627ece | d73d36ca2e726b266496e2b09adf1f5d78b37a51 | refs/heads/master | 2023-04-10T20:32:45.717863 | 2021-05-01T11:24:29 | 2021-05-01T11:24:29 | 363,378,176 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,090 | java | import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class solution39 {
public List<List<Integer>> combinationSum(int[] candidates, int target) {
List<List<Integer>> ans=new ArrayList<>();
boolean[] marked=new boolean[candidates.length];
Arrays.sort(candidates);
backtracking(0,ans,new ArrayList<>(),target,candidates);
return ans;
}
private void backtracking(int start,List<List<Integer>> ans,List<Integer> cur,int target,int[] candidates){
if(target<0)
return;
if(target==0){
ans.add(new ArrayList<>(cur));
return;
}
for(int i=start;i<candidates.length;i++){
if(i>start&&candidates[i-1]==candidates[i]) continue;
cur.add(candidates[i]);
backtracking(i+1,ans,cur,target-candidates[i],candidates);
cur.remove(cur.size()-1);
}
}
public static void main(String[] args) {
int[] a={1,1,6,7};
System.out.println(new solution39().combinationSum(a,8));
}
}
| [
"13121125012@163.com"
] | 13121125012@163.com |
4be1701b4b4c9824df934d1361027a5a5bbbaaa9 | 79747f6d49647a927c606714f5eab30768ad0cf8 | /src/main/java/legacycode/spy/Email.java | 551f911d4bfe0cc628f87125344896cee834be78 | [] | no_license | eduardlofitskyi/tdd-samples | 9a2c4e31cafa317bc0fd6f086501b291cf08c75a | 3d025511d06e56c641f4a507dee3ec363dd033ff | refs/heads/master | 2021-01-01T03:44:56.971415 | 2016-05-09T15:28:20 | 2016-05-09T15:28:20 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 505 | java | package legacycode.spy;
/**
* Created by eduard on 1/9/16.
*/
public class Email {
private String address;
private String title;
private String body;
public Email(String address, String title, String body) {
this.address = address;
this.title = title;
this.body = body;
}
public String getAddress() {
return address;
}
public String getTitle() {
return title;
}
public String getBody() {
return body;
}
}
| [
"edosgk@gmail.com"
] | edosgk@gmail.com |
df200fb5b36cc2e41582cc8155318691bd5d083d | d07784192b390368af1268d8c618275d2301c976 | /src/main/java/com/demo/gateway/client/CustomClientAsync.java | 57502f0d271b12bfc510fc78a1c82db7c2684019 | [] | no_license | xxiubinbin/netty-gatewayDemo | 4f9af068fc59e8e866f8c522ef851c427655dab2 | 27790e425470ebe8e3fe111591050f52f4b862ba | refs/heads/main | 2023-01-15T16:18:38.185307 | 2020-11-21T09:03:18 | 2020-11-21T09:03:18 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 7,780 | java | package com.demo.gateway.client;
import com.demo.gateway.annotation.RequestFilterAnnotation;
import com.demo.gateway.annotation.ResponseFilterAnnotation;
import com.demo.gateway.annotation.RouteAnnotation;
import com.demo.gateway.common.CreatResponse;
import com.demo.gateway.jms.MessageCenter;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.http.FullHttpRequest;
import io.netty.handler.codec.http.FullHttpResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ConcurrentHashMap;
/**
* 自己实现的异步非阻塞阻塞客户端
* @author lw
*/
@Component
@EnableAspectJAutoProxy(exposeProxy = true)
public class CustomClientAsync extends Client implements DisposableBean, ClientAsync {
private static final Logger logger = LoggerFactory.getLogger(CustomClientAsync.class);
private EventLoopGroup clientGroup = new NioEventLoopGroup(new ThreadFactoryBuilder().setNameFormat("client work-%d").build());
private final int cpuProcessors = Runtime.getRuntime().availableProcessors() * 2;
/**
* 空闲Channel缓存池
*/
private ConcurrentHashMap<String, ArrayBlockingQueue<Channel>> freeChannels = new ConcurrentHashMap<>();
/**
* 繁忙Channel持有(繁忙池),起一个
*/
private ConcurrentHashMap<String, ConcurrentHashMap<Integer, Channel>> busyChannels = new ConcurrentHashMap<>();
@Value("${client.SO_REUSEADDR}")
private boolean soReuseaddr;
@Value("${client.TCP_NODELAY}")
private boolean tcpNodelay;
@Value("${client.AUTO_CLOSE}")
private boolean autoClose;
@Value("${client.SO_KEEPALIVE}")
private boolean soKeepalive;
CustomClientAsync() {}
/**
* 获取 client channel 发送请求
* 发生错误时需要将 channel 放回缓存池
* @param request 请求
*/
@Override
@RouteAnnotation
@RequestFilterAnnotation
public void sendRequest(FullHttpRequest request, int channelHashCode) {
Channel channel;
try {
channel = getChannel(request, channelHashCode);
} catch (URISyntaxException | InterruptedException e) {
e.printStackTrace();
returnResponse(CreatResponse.creat404(request), channelHashCode, request);
return;
}
CustomClientAsyncHandler handler = new CustomClientAsyncHandler(this, channelHashCode, request);
channel.pipeline().replace("clientHandler", "clientHandler", handler);
try {
channel.writeAndFlush(request).sync();
} catch (InterruptedException e) {
e.printStackTrace();
logger.error("client channel send failed");
repayChannel(request, channelHashCode);
}
}
/**
* 获取Client Channel
*
* 一、如果不存在此ip地址和端口的Channel缓存池,直接新建,加入繁忙池(下面将ip地址和端口称为key)
*
* 二、存在key的Channel缓存池
* 1.如果有空闲的Channel,从空闲池中取出,放入繁忙池
*
* 2.如果此key的繁忙池中的channel数量小于 CPU核心*2,则新建一个channel,放入繁忙池
*
* 3.上面两种情况都不成立,则阻塞一直等待缓冲池中有channel可用时返回,从空闲池中取出,放入繁忙池
*
* @param request request
* @param channelHashCode server outbound hashcode
* @return channel
* @throws URISyntaxException exception
* @throws InterruptedException exception
*/
private Channel getChannel(FullHttpRequest request, int channelHashCode) throws URISyntaxException, InterruptedException {
URI uri = new URI(request.uri());
String key = uri.getHost() + "::" + uri.getPort();
Channel channel;
if (!freeChannels.containsKey(key)) {
channel = createChannel(uri.getHost(), uri.getPort());
} else {
if (!freeChannels.get(key).isEmpty()) {
channel = freeChannels.get(key).take();
} else if (busyChannels.get(key).size() < cpuProcessors) {
channel = createChannel(uri.getHost(), uri.getPort());
} else {
channel = freeChannels.get(key).take();
}
}
ConcurrentHashMap<Integer, Channel> requestMapChannel = busyChannels.getOrDefault(key,
new ConcurrentHashMap<>(cpuProcessors));
requestMapChannel.put(channelHashCode, channel);
busyChannels.put(key, requestMapChannel);
return channel;
}
/**
* 归还channel到缓冲池
* 缓存池添加,繁忙池删除
* @param request request
* @param channelHashCode server outbound hashcode
*/
private void repayChannel(FullHttpRequest request, int channelHashCode) {
URI uri;
try {
uri = new URI(request.uri());
} catch (URISyntaxException e) {
e.printStackTrace();
logger.error("uri parse error:" + request.uri());
return;
}
String key = uri.getHost() + "::" + uri.getPort();
Channel channel = busyChannels.get(key).get(channelHashCode);
if (!freeChannels.containsKey(key)) {
freeChannels.put(key, new ArrayBlockingQueue<>(cpuProcessors));
}
freeChannels.get(key).add(channel);
busyChannels.get(key).remove(channelHashCode);
}
/**
* 返回新的Channel
* @param address ip地址
* @param port 端口
* @return channel
* @throws InterruptedException exception
*/
private Channel createChannel(String address, int port) throws InterruptedException {
Bootstrap bootstrap = new Bootstrap();
bootstrap.group(clientGroup)
.option(ChannelOption.SO_REUSEADDR, soReuseaddr)
.option(ChannelOption.TCP_NODELAY, tcpNodelay)
.option(ChannelOption.AUTO_CLOSE, autoClose)
.option(ChannelOption.SO_KEEPALIVE, soKeepalive)
.channel(NioSocketChannel.class)
.handler(new CustomClientInitializer());
return bootstrap.connect(address, port).sync().channel();
}
/**
* 关闭线程池
*/
@Override
public void destroy() {
clientGroup.shutdownGracefully();
}
/**
* 从MessageCenter 中获取对应的 server outbound,返回响应,归还 client channel
* 接收并返回响应后才将channel放回缓冲池是为了让 client channel一个时间点处理特定的请求即可,避免冲突
* @param response response
* @param channelHashCode server outbound hash code
* @param request request
*/
@ResponseFilterAnnotation
void returnResponse(FullHttpResponse response, int channelHashCode, FullHttpRequest request) {
try {
MessageCenter.getChannel(channelHashCode).writeAndFlush(response).sync();
} catch (InterruptedException e) {
e.printStackTrace();
logger.error("Server inbound can't use");
}
repayChannel(request, channelHashCode);
}
}
| [
"qq1243925457@gmail.com"
] | qq1243925457@gmail.com |
aefe46110f89d587023c93d41a5250fb4453b305 | 14287fb90a9d6e6573983d379f6399bdbc8c9f69 | /src/backpacks/Backpack.java | 08ab8fde1d72c43bb4ef6967136c3f28df03605d | [] | no_license | maxim12321/java-swing-backpack | c7eee52e874b767d93b188ff1a0346df68c8711b | 560b6c08108a809f60892659f10d30b7b17e8649 | refs/heads/main | 2023-03-25T06:18:03.486306 | 2021-03-13T19:08:37 | 2021-03-13T19:08:37 | 302,388,986 | 0 | 0 | null | 2021-03-13T19:08:38 | 2020-10-08T15:45:10 | Java | UTF-8 | Java | false | false | 1,503 | java | package backpacks;
import backpacks.exporters.BackpackExporter;
import backpacks.exporters.XMLBackpackExporter;
import exceptions.FullBackpackException;
import shapes.*;
import java.math.BigDecimal;
import java.util.*;
public class Backpack {
List<Shape> shapes;
BigDecimal capacity;
public Backpack(BigDecimal capacity) {
this.capacity = capacity;
shapes = new ArrayList<>();
}
public void addShape(Shape shape) throws FullBackpackException {
if (getVolume().add(shape.getVolume()).compareTo(capacity) > 0) {
throw new FullBackpackException();
}
int insertIndex = 0;
while (insertIndex < shapes.size() &&
shapes.get(insertIndex).getVolume().compareTo(shape.getVolume()) > 0) {
insertIndex++;
}
shapes.add(insertIndex, shape);
}
public void removeShape(int index) {
shapes.remove(index);
}
public Shape getShape(int index) {
return shapes.get(index);
}
public int size() {
return shapes.size();
}
public BigDecimal getVolume() {
BigDecimal volume = new BigDecimal(0);
for (Shape shape : shapes) {
volume = volume.add(shape.getVolume());
}
return volume;
}
public BigDecimal getCapacity() {
return capacity;
}
@Override
public String toString() {
return "Backpack(\n" + shapes + "\n). Total volume = " + getVolume() + "\n";
}
}
| [
"noreply@github.com"
] | maxim12321.noreply@github.com |
c60137b18e9768b6ea9e45d47d007f98a27873cf | 4af46c51990059c509ed9278e8708f6ec2067613 | /java/l2server/gameserver/network/serverpackets/ReceiveVipProductList.java | 48890fef122b3a1977bd108dcabd56308b54c460 | [] | no_license | bahamus007/l2helios | d1519d740c11a66f28544075d9e7c628f3616559 | 228cf88db1981b1169ea5705eb0fab071771a958 | refs/heads/master | 2021-01-12T13:17:19.204718 | 2017-11-15T02:16:52 | 2017-11-15T02:16:52 | 72,180,803 | 1 | 2 | null | null | null | null | UTF-8 | Java | false | false | 203 | java | package l2server.gameserver.network.serverpackets;
/**
* @author MegaParzor!
*/
public class ReceiveVipProductList extends L2GameServerPacket
{
@Override
public void writeImpl()
{
}
}
| [
"singto52@hotmail.com"
] | singto52@hotmail.com |
f9c278073fc294689bd5da85e36cb2dc8bddb5c5 | 25ea2e9063c404167eaf758e71660a29f2a10506 | /src/com/allenanker/chapter3/DeleteNodeInList.java | e4e885d4e4957913eac759724be9bdf8f30b2f66 | [] | no_license | flirtinthedarkness/ForOffers | 4d9f043f8576e100c0e7de9a27aeead19405ebc0 | d2a7819368db88b3678430692901832dc957c3b3 | refs/heads/master | 2023-04-03T09:38:16.905869 | 2019-02-20T09:02:23 | 2019-02-20T09:02:23 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,394 | java | package com.allenanker.chapter3;
public class DeleteNodeInList {
/**
* Delete a node in a linked list in O(1) time complexity
*
* @param head head of the linked list
* @param toBeDeleted the node to be deleted
*/
public static void deleteNode(ListNode head, ListNode toBeDeleted) {
if (head == null || toBeDeleted == null) {
throw new IllegalArgumentException("Invalid parameters");
}
if (toBeDeleted.next != null) {
toBeDeleted.value = toBeDeleted.next.value;
toBeDeleted.next = toBeDeleted.next.next;
toBeDeleted.next = null;
} else if (toBeDeleted == head) {
// this does not actually delete the head, it doesn't work
head = null;
} else {
ListNode curr = head;
while (curr.next != toBeDeleted) {
curr = curr.next;
}
curr.next = null;
}
}
public static void main(String[] args) {
ListNode head = new ListNode(1);
ListNode node2 = new ListNode(2);
ListNode node3 = new ListNode(3);
head.next = node2;
node2.next = node3;
deleteNode(head, node3);
System.out.println(head);
}
}
class ListNode {
int value;
ListNode next;
public ListNode(int value) {
this.value = value;
}
} | [
"theallenanker@gmail.com"
] | theallenanker@gmail.com |
70d36c6f2f31fd024affaafb5c9f062fd3c26757 | d75fcb658d3e4b0becd855b9110b89f148f516a4 | /DiamondDocs/src/main/java/com/diamond/pojo/Member.java | e4e051bd9d18b06733f95377e3819330232f239e | [] | no_license | hhidk/RuanGongSummerBackEnd | 884d8a4b0f6f22a7947c9047036ce0d46d7b290b | 2b91d96ee56603585868def3df2b4070c2cb84b0 | refs/heads/master | 2022-12-04T07:13:15.641029 | 2020-08-19T14:50:00 | 2020-08-19T14:50:00 | 286,882,991 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 442 | java | package com.diamond.pojo;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
public class Member {
private String userID;
private int userIdentity;
private String teamID;
private String lastVisitTime;
public Member(String userID, int userIdentity, String teamID){
this.userID=userID;
this.teamID=teamID;
this.userIdentity=userIdentity;
}
}
| [
"295809364@qq.com"
] | 295809364@qq.com |
f0348bf9a43e3ea00fd37ba59b1576b75224ab7e | dd76d0b680549acb07278b2ecd387cb05ec84d64 | /divestory-Fernflower/kotlin/coroutines/experimental/migration/ContextMigration.java | e098232f67bf10a164171f51b257ab3346468f15 | [] | no_license | ryangardner/excursion-decompiling | 43c99a799ce75a417e636da85bddd5d1d9a9109c | 4b6d11d6f118cdab31328c877c268f3d56b95c58 | refs/heads/master | 2023-07-02T13:32:30.872241 | 2021-08-09T19:33:37 | 2021-08-09T19:33:37 | 299,657,052 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 2,307 | java | package kotlin.coroutines.experimental.migration;
import kotlin.Metadata;
import kotlin.coroutines.AbstractCoroutineContextElement;
import kotlin.coroutines.experimental.CoroutineContext;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
@Metadata(
bv = {1, 0, 3},
d1 = {"\u0000\u0012\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0002\u0018\u0000 \u00072\u00020\u0001:\u0001\u0007B\r\u0012\u0006\u0010\u0002\u001a\u00020\u0003¢\u0006\u0002\u0010\u0004R\u0011\u0010\u0002\u001a\u00020\u0003¢\u0006\b\n\u0000\u001a\u0004\b\u0005\u0010\u0006¨\u0006\b"},
d2 = {"Lkotlin/coroutines/experimental/migration/ContextMigration;", "Lkotlin/coroutines/AbstractCoroutineContextElement;", "context", "Lkotlin/coroutines/experimental/CoroutineContext;", "(Lkotlin/coroutines/experimental/CoroutineContext;)V", "getContext", "()Lkotlin/coroutines/experimental/CoroutineContext;", "Key", "kotlin-stdlib-coroutines"},
k = 1,
mv = {1, 1, 16}
)
final class ContextMigration extends AbstractCoroutineContextElement {
public static final ContextMigration.Key Key = new ContextMigration.Key((DefaultConstructorMarker)null);
private final CoroutineContext context;
public ContextMigration(CoroutineContext var1) {
Intrinsics.checkParameterIsNotNull(var1, "context");
super((kotlin.coroutines.CoroutineContext.Key)Key);
this.context = var1;
}
public final CoroutineContext getContext() {
return this.context;
}
@Metadata(
bv = {1, 0, 3},
d1 = {"\u0000\u0010\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\b\u0086\u0003\u0018\u00002\b\u0012\u0004\u0012\u00020\u00020\u0001B\u0007\b\u0002¢\u0006\u0002\u0010\u0003¨\u0006\u0004"},
d2 = {"Lkotlin/coroutines/experimental/migration/ContextMigration$Key;", "Lkotlin/coroutines/CoroutineContext$Key;", "Lkotlin/coroutines/experimental/migration/ContextMigration;", "()V", "kotlin-stdlib-coroutines"},
k = 1,
mv = {1, 1, 16}
)
public static final class Key implements kotlin.coroutines.CoroutineContext.Key<ContextMigration> {
private Key() {
}
// $FF: synthetic method
public Key(DefaultConstructorMarker var1) {
this();
}
}
}
| [
"ryan.gardner@coxautoinc.com"
] | ryan.gardner@coxautoinc.com |
31d0bbb9e26e4d03df8264282c3c4c06c63f882e | 8267f720b5aef349c3a24fb1c019868c36873401 | /Myconcurrency/src/main/java/DeadLock.java | 0e28efe30507bd49a20ca9d6c989bf520530a697 | [] | no_license | xuchunfa/Java-Algorithm | 61713229944badcffb797e377ed34b1f97b12e0a | f5f9d34af49a933923e056a03ce40ca2191d885e | refs/heads/master | 2022-06-30T00:42:41.343397 | 2020-01-29T09:36:12 | 2020-01-29T09:36:12 | 141,983,277 | 1 | 0 | null | 2022-06-21T01:07:19 | 2018-07-23T08:14:44 | Java | UTF-8 | Java | false | false | 740 | java | /**
* @description:
* @author: Xu chunfa
* @create: 2018-08-28 10:36
**/
public class DeadLock {
static class SynAddRunnable implements Runnable{
private int a,b;
public SynAddRunnable(int a,int b){
this.a = a;
this.b = b;
}
@Override
public void run() {
synchronized (Integer.valueOf(a)){
synchronized (Integer.valueOf(b)){
System.out.println(a + b);
}
}
}
}
public static void main(String[] args) {
for (int i = 0; i < 1000; i++) {
new Thread(new SynAddRunnable(1,2)).start();
new Thread(new SynAddRunnable(2,1)).start();
}
}
}
| [
"731227680@qq.com"
] | 731227680@qq.com |
96bc942c8753c11afd4521c9cd82b4bdc9679cc8 | 3927de025294b7dfa353b6da1ea7999d862c1b55 | /API/src/main/java/dev/qpixel/helios/api/HeliosAPI.java | 11f7b41221a396a986009c1e711c69b24ed702a6 | [
"MIT"
] | permissive | QPixel/helios | 7f0afab85a78f0c4b6a2b1fc05f29682b47cac10 | b8efd3f35911625326eef7a31a523306a5d1cd5a | refs/heads/main | 2023-06-10T18:02:07.838433 | 2021-07-06T08:03:48 | 2021-07-06T08:03:48 | 383,287,661 | 0 | 0 | null | 2021-07-05T23:38:13 | 2021-07-05T23:36:22 | Java | UTF-8 | Java | false | false | 2,469 | java | package dev.qpixel.helios.api;
import dev.qpixel.helios.api.message.MessageCreation;
import dev.qpixel.helios.api.util.PropertiesReader;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
public class HeliosAPI {
private PropertiesReader reader;
private HeliosPlugin plugin;
private static BukkitAudiences adventure;
protected static String version;
protected static boolean Spigot;
private static List<String> loadedPlugins = new ArrayList();
public static @NotNull BukkitAudiences adventure() {
if (adventure == null) {
throw new IllegalStateException("Tried to access adventure while disabled");
}
return adventure;
}
public @NotNull BukkitAudiences getAudience() {
if (adventure == null) {
throw new IllegalStateException("Tried to access adventure while disabled");
}
return adventure;
}
public void init(HeliosPlugin plugin) {
this.plugin = plugin;
if (plugin.getServer().getVersion().toLowerCase(Locale.ROOT).contains("spigot")) {
Spigot = true;
plugin.getLogger().info("plugin is running on spigot");
adventure = BukkitAudiences.create(plugin);
}
registerPlugin(String.format("%s %s",plugin.getName(), plugin.getDescription().getVersion()));
try {
reader = new PropertiesReader("build-info.properties");
version = reader.getProperty("heliosapi.version");
} catch (IOException e) {
plugin.getLogger().warning("Unable to read internal properties");
version = "1.0.0-SNAPSHOT-error";
}
}
public void unload() {
if (adventure != null) {
adventure.close();
adventure = null;
}
unregisterPlugins();
}
public static String getVersion() {
return version;
}
public static boolean isSpigot() {
return Spigot;
}
private void registerPlugin(String pluginName) {
loadedPlugins.add(pluginName);
}
private void unregisterPlugins() {
loadedPlugins.clear();
}
public ArrayList<String> getIterablePlugin() {
return (ArrayList<String>) loadedPlugins;
}
public HeliosAPI() {
}
}
| [
"riley@rileysmith.me"
] | riley@rileysmith.me |
9fa16326a77cfe7ab9c945fb5270c3b7a5040c59 | 9ac1228744c3691e815c4ec75a2edfaa90a35bed | /backend/src/main/java/com/eduport/demo/entity/Admin.java | 20aac8805a34043488be9ec9e20402c3f31518f5 | [] | no_license | saneshs/Eduport | 6d53a4b223142b56f1ceb286c4a83ed5ede76478 | a8c6a562076b54676457104632be5cb6bbcabafb | refs/heads/master | 2022-12-20T08:32:22.780719 | 2020-09-25T16:39:08 | 2020-09-25T16:39:08 | 298,625,242 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 536 | java | package com.eduport.demo.entity;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@Entity
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class Admin {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
int id;
String adminId;
String adminSecret;
String changePasswordKey=null;
}
| [
"43962286+saneshs@users.noreply.github.com"
] | 43962286+saneshs@users.noreply.github.com |
231d7e675bd67e0aaeca550ebfa42c3b8aeccbb4 | 79d402a5d651dfa9c63c17ffb220cbf2e22c48c2 | /src/main/java/com/piketalks/beservicejava/repository/SubtalkRepository.java | 64c8c1654d6271ad66c5b5eb9ff8852777e7e734 | [] | no_license | KonstantinIvanchenko/piketalks | ee7b4f9fb796e2acc3742e73bd20849a98b51f03 | 481d769b729d19ae4ffab250ce19ea1510fe5571 | refs/heads/master | 2022-12-03T19:31:37.334264 | 2020-08-26T21:12:02 | 2020-08-26T21:12:02 | 276,500,416 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 382 | java | package com.piketalks.beservicejava.repository;
import com.piketalks.beservicejava.model.Subtalk;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.Optional;
@Repository
public interface SubtalkRepository extends JpaRepository<Subtalk, Long> {
Optional<Subtalk> findByName(String subtalkName);
}
| [
"ikv.mstu@gmail.com"
] | ikv.mstu@gmail.com |
169e0129d7dcf1bef4774eefccea3a2563fe6d66 | 372e4adc8d3a9e1c118b45951d82f56f15e89383 | /software_projects/java_projects/netbeans_projects/audio_track_finder/src/audio_track_finder/SimpleFilter.java | 07afb1b09f1f99fa0c54774b40ab069588d0e3c6 | [] | no_license | infocelab/embedded-projects | d190a23b9254b272643eb1a13259ae079ffa934d | ba4d099538df964feac0ee7cc7af10b3271db7b0 | refs/heads/master | 2021-01-12T18:09:01.718780 | 2015-08-18T13:36:18 | 2015-08-18T13:36:18 | 41,009,390 | 1 | 0 | null | null | null | null | UTF-8 | Java | false | false | 644 | java | import javax.swing.filechooser.FileFilter;
import java.io.*;
public class SimpleFilter extends FileFilter
{
private String m_description = null;
private String m_extension = null;
public SimpleFilter(String extension, String description) {
m_description = description;
m_extension = "." + extension.toLowerCase();
}
public String getDescription() {
return m_description;
}
public boolean accept(File f) {
if (f == null)
return false;
if (f.isDirectory())
return true;
return f.getName().toLowerCase().endsWith(m_extension);
}
} | [
"celab2010@gmail.com"
] | celab2010@gmail.com |
badd56158eaf61f537cf93bd483ddb471e7dbd9a | ca240cec87eaa0ffb67bb6b736a50fdede255eb1 | /src/main/java/net/xin/web/webapps/form/admin/LoginForm.java | ecea1265f8b3b74c85321665ea4ae4037d27640d | [
"Apache-2.0"
] | permissive | b20vineeth/8120 | 221124cb76171702ec52fdac435fb97d7ae3a826 | 5bddf7d23af007d9afe6b7eb58b24406f66e2dee | refs/heads/master | 2020-03-27T05:54:03.547931 | 2018-09-08T14:09:27 | 2018-09-08T14:09:27 | 146,060,881 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 847 | java | package net.xin.web.webapps.form.admin;
public class LoginForm {
String Username;
String Password;
String Captcha;
String attempt="1";
String redirectUrl;
public String getUsername() {
return Username;
}
public void setUsername(String username) {
Username = username;
}
public String getPassword() {
return Password;
}
public void setPassword(String password) {
Password = password;
}
public String getCaptcha() {
return Captcha;
}
public void setCaptcha(String captcha) {
Captcha = captcha;
}
public String getAttempt() {
return attempt;
}
public void setAttempt(String attempt) {
this.attempt = attempt;
}
public String getRedirectUrl() {
return redirectUrl;
}
public void setRedirectUrl(String redirectUrl) {
this.redirectUrl = redirectUrl;
}
}
| [
"vineeth@DESKTOP-7EJ08UV"
] | vineeth@DESKTOP-7EJ08UV |
49fa7fccea2489af67fe0d90510769985136b34d | 4d66ae645bcb9159a4b6d0fdb2f24e029da00847 | /busi-root/busi-service/src/main/java/com/huatek/busi/dto/progress/BusiProgressImageToBranchConnectDto.java | 5298bdeaa3365e42846d29b3dfbfc0a10d59970e | [] | no_license | GitWangH/JiFen | 1e3722d49502e8ac7de2cfa4e97e99cf47e404df | 0cec185c83c0f76a97b4d00fc8f1cfb230415a8e | refs/heads/master | 2022-12-20T13:28:57.456912 | 2019-05-24T06:00:16 | 2019-05-24T06:00:16 | 131,266,103 | 0 | 2 | null | 2022-12-10T01:13:11 | 2018-04-27T08:07:02 | JavaScript | UTF-8 | Java | false | false | 1,682 | java | package com.huatek.busi.dto.progress;
/**
* 标段形象清单划分实体类.
*
* @ClassName: BusiProgressImage
* @Description:
* @author: jordan_li
* @Email :
* @date: 2017-12-06 10:58:13
* @version: Windows 7
*/
public class BusiProgressImageToBranchConnectDto {
private Long id;
private Long imageId;// 形象清单id
private String imageCode;//形象清单编号
private String imageName;// 形象清单名称
private Long branchId;// 分部分项id
private String branchCode;//分部分项编号
private String branchName;//分部分项名称
public BusiProgressImageToBranchConnectDto() {
super();
}
public BusiProgressImageToBranchConnectDto(Long imageId, Long branchId) {
super();
this.imageId = imageId;
this.branchId = branchId;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Long getImageId() {
return imageId;
}
public void setImageId(Long imageId) {
this.imageId = imageId;
}
public Long getBranchId() {
return branchId;
}
public void setBranchId(Long branchId) {
this.branchId = branchId;
}
public String getImageName() {
return imageName;
}
public void setImageName(String imageName) {
this.imageName = imageName;
}
public String getBranchName() {
return branchName;
}
public void setBranchName(String branchName) {
this.branchName = branchName;
}
public String getImageCode() {
return imageCode;
}
public void setImageCode(String imageCode) {
this.imageCode = imageCode;
}
public String getBranchCode() {
return branchCode;
}
public void setBranchCode(String branchCode) {
this.branchCode = branchCode;
}
}
| [
"15771883191@163.com"
] | 15771883191@163.com |
be47741c5e272f6784a824c2bc02751026a5a8b1 | 6489135f21ede605b9b9410c6f6ee2a47e7a7065 | /src/sorting/BucketSort.java | 4a0a36bf2d0b5b1d7170acf6704e91696f0ff160 | [] | no_license | thiepha/DSABasic | 4e7e66872ee61b4bd4166918a2ccc41c431e6b9b | bf2d4827a4449181ff681198389689fba7911154 | refs/heads/master | 2023-08-16T07:14:00.086933 | 2021-10-03T03:38:12 | 2021-10-03T03:38:12 | 412,966,886 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,379 | java | package sorting;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public class BucketSort {
public static void main(String[] args) {
int[] input = {42, 46, 92, 78, 91, 43, 34, 51, 55, 10, 11, 15, 68, 62};
System.out.println(Arrays.toString(input));
bucketSort(input);
System.out.println(Arrays.toString(input));
}
public static void bucketSort(int[] input) {
int size = 10;
List<Integer>[] buckets = new List[size];
// scatter phase: values of bucket [i - 1] < values of bucket[i] < values of bucket[i + 1]
for (int i = 0; i < size; i++) {
buckets[i] = new ArrayList<>();
}
for (int i = 0; i < input.length; i++) {
buckets[hash(input[i])].add(input[i]);
}
// sort each bucket: usually use insertion sort, here we use merge sort
for (int i = 0; i < buckets.length; i++) {
Collections.sort(buckets[i]);
}
// merge phase: collect values from sorted buckets
int pos = 0;
for (int i = 0; i < buckets.length; i++) {
for (int j = 0; j < buckets[i].size(); j++) {
input[pos++] = buckets[i].get(j);
}
}
}
public static int hash(int value) {
return (value / 10) % 10;
}
}
| [
"haminhthiep@gmail.com"
] | haminhthiep@gmail.com |
9913746699a7cee8e523fe956d3a9b2e5febabd6 | c714b00b366fabc7350e20a9c46412ae5df946dc | /src/com/leecoder/src/FourSum.java | 3314d51dd29b40caa4f50b0de375b445d6b119e6 | [] | no_license | uestc-xst/LeeCoder | 998ffa58008da2c23af0ec385986d154b8f2bab0 | 0a461befe4e37b47579eed84d2d641f7eef4b3a3 | refs/heads/master | 2021-01-21T13:04:02.796567 | 2016-05-14T01:53:58 | 2016-05-14T01:53:58 | 54,543,088 | 0 | 0 | null | null | null | null | WINDOWS-1252 | Java | false | false | 1,435 | java | package com.leecoder.src;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class FourSum {
/**
* 4Sum
* @param nums
* @param target
* @return
*/
public static List<List<Integer>> fourSum(int[] nums, int target) {
List<List<Integer>> returnlist = new ArrayList<List<Integer>>();
Arrays.sort(nums); //¶ÔÊäÈëÊý×éÅÅÐò
for (int i = 0; i < nums.length-3; i++) {
while(i>0&&nums[i]==nums[i-1]){
i++;
}
int firtarget = target - nums[i];
for(int j=i+1;j<nums.length-2;j++){
while(j>(i+1)&&j<(nums.length-2)&&nums[j]==nums[j-1]){
j++;
}
int sectarget = firtarget - nums[j];
int start = j+1;
int end = nums.length-1;
while (start<end) {
if (nums[start]+nums[end]==sectarget) {
List<Integer> resulist = new ArrayList<>();
resulist.add(nums[i]);
resulist.add(nums[j]);
resulist.add(nums[start]);
resulist.add(nums[end]);
returnlist.add(resulist);
start++;
end--;
while(start<=(nums.length-1)&&nums[start-1]==nums[start]){
start++;
}
while(end>=(j+1)&&nums[end]==nums[end+1]){
end--;
}
}else if (nums[start]+nums[end]>sectarget) {
end--;
}else if (nums[start]+nums[end]<sectarget) {
start++;
}
}
}
}
return returnlist;
}
}
| [
"1072152863@qq.com"
] | 1072152863@qq.com |
31f6c35081d1c1ae662004064717648aa799280d | 294cf780927bccd618f5bd51adb38ceac444b6a1 | /app/src/main/java/com/VitaBit/VitaBit/logic/UI/main/datachatactivity/sleepUtils/SleepEntry.java | dc0713c4a28f0193de5de95ae3db7a0b0c0a078b | [] | no_license | linkloving/helanGit | 3630719d8c2c17360cde9eb73f5451943ec18d09 | a8465c1f0d9134eb81c72f7727c59dce905be704 | refs/heads/master | 2021-01-17T23:36:52.779437 | 2016-11-10T03:34:54 | 2016-11-10T03:34:54 | 68,589,803 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 484 | java | package com.VitaBit.VitaBit.logic.UI.main.datachatactivity.sleepUtils;
import android.os.Parcel;
import com.github.mikephil.charting.data.Entry;
/**
* Created by Administrator on 2016/4/11.
*/
public class SleepEntry extends Entry {
public SleepEntry(float val, int xIndex) {
super(val, xIndex);
}
public SleepEntry(float val, int xIndex, Object data) {
super(val, xIndex, data);
}
protected SleepEntry(Parcel in) {
super(in);
}
}
| [
"279779782@qq.com"
] | 279779782@qq.com |
c27399b62022a8b8905bf821248cba878e44fa0d | a2df6764e9f4350e0d9184efadb6c92c40d40212 | /aliyun-java-sdk-ocr/src/main/java/com/aliyuncs/ocr/model/v20191230/RecognizeQrCodeResponse.java | cc33a3cbb463ee846bf2c75d86ea7611ac7f1907 | [
"Apache-2.0"
] | permissive | warriorsZXX/aliyun-openapi-java-sdk | 567840c4bdd438d43be6bd21edde86585cd6274a | f8fd2b81a5f2cd46b1e31974ff6a7afed111a245 | refs/heads/master | 2022-12-06T15:45:20.418475 | 2020-08-20T08:37:31 | 2020-08-26T06:17:49 | 290,450,773 | 1 | 0 | NOASSERTION | 2020-08-26T09:15:48 | 2020-08-26T09:15:47 | null | UTF-8 | Java | false | false | 3,104 | 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.ocr.model.v20191230;
import java.util.List;
import com.aliyuncs.AcsResponse;
import com.aliyuncs.ocr.transform.v20191230.RecognizeQrCodeResponseUnmarshaller;
import com.aliyuncs.transform.UnmarshallerContext;
/**
* @author auto create
* @version
*/
public class RecognizeQrCodeResponse extends AcsResponse {
private String requestId;
private Data data;
public String getRequestId() {
return this.requestId;
}
public void setRequestId(String requestId) {
this.requestId = requestId;
}
public Data getData() {
return this.data;
}
public void setData(Data data) {
this.data = data;
}
public static class Data {
private List<Element> elements;
public List<Element> getElements() {
return this.elements;
}
public void setElements(List<Element> elements) {
this.elements = elements;
}
public static class Element {
private String taskId;
private String imageURL;
private List<Result> results;
public String getTaskId() {
return this.taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public String getImageURL() {
return this.imageURL;
}
public void setImageURL(String imageURL) {
this.imageURL = imageURL;
}
public List<Result> getResults() {
return this.results;
}
public void setResults(List<Result> results) {
this.results = results;
}
public static class Result {
private String label;
private String suggestion;
private Float rate;
private List<String> qrCodesData;
public String getLabel() {
return this.label;
}
public void setLabel(String label) {
this.label = label;
}
public String getSuggestion() {
return this.suggestion;
}
public void setSuggestion(String suggestion) {
this.suggestion = suggestion;
}
public Float getRate() {
return this.rate;
}
public void setRate(Float rate) {
this.rate = rate;
}
public List<String> getQrCodesData() {
return this.qrCodesData;
}
public void setQrCodesData(List<String> qrCodesData) {
this.qrCodesData = qrCodesData;
}
}
}
}
@Override
public RecognizeQrCodeResponse getInstance(UnmarshallerContext context) {
return RecognizeQrCodeResponseUnmarshaller.unmarshall(this, context);
}
@Override
public boolean checkShowJsonItemName() {
return false;
}
}
| [
"sdk-team@alibabacloud.com"
] | sdk-team@alibabacloud.com |
50110275824c1e34a9942be04e1ae35937c340d9 | b5b1079d1ea70a1122d9330bbcebd5b7c5b2540f | /putked/putked-lib/src/putked/EditorTypeService.java | 153b686241b11b88eb80504b9d751a46b1b7d37d | [] | no_license | raxptor/putki-historical | 84acf6c4004a6f0f4c6e3ac34602935a07a40fa4 | c588b75e4729b1bbff4d28d19da82f2dfb7b260f | refs/heads/master | 2020-04-12T20:25:16.050023 | 2016-01-05T09:41:28 | 2016-01-05T09:41:28 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 107 | java | package putked;
public interface EditorTypeService
{
public ProxyObject createProxy(String typeName);
}
| [
"raxptor@gmail.com"
] | raxptor@gmail.com |
1e35dfbcd62a380ee1e90a6267ba15e99941ea90 | 36f0d7fc47c68064d6dad96b461084580a70c053 | /src/androidTest/java/com/example/sanmolsoftware/popularmovies/ExampleInstrumentedTest.java | fd14f188646166c0d1c3a6b2e095ecd999b1ac0e | [] | no_license | tedyi2005/PopularMovie | 1ebee27554ce3fbf31829f78c7ca587eb679b3b8 | af23a73a400a7bea5cbe35aca691ba89adbfc4cd | refs/heads/master | 2020-07-11T18:32:54.900099 | 2019-08-27T03:55:42 | 2019-08-27T03:55:42 | 204,385,335 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 764 | java | package com.example.sanmolsoftware.popularmovies;
import android.content.Context;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getTargetContext();
assertEquals("com.example.sanmolsoftware.popularmovies", appContext.getPackageName());
}
}
| [
"tkidb@allstate.com"
] | tkidb@allstate.com |
8f37c9098a9443d1a9c9443e26ce14a724c61cc1 | ddf6f45dc6ee66b2e2ab69645c93da3b8eba2a9e | /src/main/java/ru/eugene/backend/VoucherService.java | 909bcb887ba37bf6385c08259533c300e30c77e2 | [] | no_license | EugeneZaharova/PE_labs_2020 | 3b9238698838830337c0ef19ecc1ea9f058283b5 | 6abddef9aa67b8777d684c7928bc630c45a14dc8 | refs/heads/master | 2023-02-21T05:29:24.107491 | 2021-01-15T02:49:22 | 2021-01-15T02:49:22 | 305,655,520 | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,887 | java | package ru.eugene.backend;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import ru.eugene.backend.model.VoucherModel;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@Service
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class VoucherService {
private final VoucherRepository repository;
List<VoucherModel> getAllVouchers() {
return iterableToList(repository.findAll());
}
VoucherModel getVoucher(@RequestParam(name = "id") UUID id) {
return repository.findById(id)
.orElseThrow(() -> new NotFoundException());
}
void addVoucher(@RequestBody VoucherModel voucher) {
repository.save(voucher);
}
void editVoucher(@RequestBody VoucherModel voucher) {
VoucherModel foundModel = repository.findById(voucher.getId())
.orElseThrow(() -> new NotFoundException());
foundModel.setName(voucher.getName());
foundModel.setDescription(voucher.getDescription());
foundModel.setPrice(voucher.getPrice());
foundModel.setDestinationCountry(voucher.getDestinationCountry());
foundModel.setDestinationRegion(voucher.getDestinationRegion());
repository.save(foundModel);
}
void deleteVoucher(@RequestParam(name = "id") UUID id) {
//Для того, чтобы если объекта нет, вылетела ошибка
getVoucher(id);
repository.deleteById(id);
}
private <T> List<T> iterableToList(Iterable<T> iterable) {
List<T> result = new ArrayList();
iterable.forEach(i -> result.add(i));
return result;
}
}
| [
"eugenezaharova@mail.ru"
] | eugenezaharova@mail.ru |
6a59d4081c2d3993859ccd48fbea406ea3b651ae | 2ba4536e6c77a70f6900625871e43fea21bbfc10 | /src/com/easylink/android/FirstTimeConfig2.java | 08dc36649066c23ce23bd04f4a7f60acabf66660 | [] | no_license | MiCOLab/EasyLink_3.1 | 4e08680cbdb5fdd0d66cd88012cae3c53d41f7a7 | d5a0382b41680529a6d0378a6cbcf6a1e1a41395 | refs/heads/master | 2021-01-21T02:46:42.865423 | 2015-10-22T03:22:55 | 2015-10-22T03:22:55 | 44,727,880 | 1 | 1 | null | null | null | null | GB18030 | Java | false | false | 14,568 | java | package com.easylink.android;
import java.io.IOException;
import java.io.InterruptedIOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.MulticastSocket;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.crypto.Cipher;
import javax.crypto.spec.SecretKeySpec;
import android.content.Context;
public class FirstTimeConfig2 {
private boolean stopSending;
private String ip;
private String ssid;
private String key;
private String mDnsAckString;
private int nSetup;
private int nSync;
private String syncLString;
private String syncHString;
private byte[] encryptionKey;
private FtcEncode ftcData;
InetSocketAddress sockAddr;
private MulticastSocket listenSocket;
int localPort;
int listenPort;
int waitForAckSocketTimeout;
private FirstTimeConfigListener m_listener = null;
Thread sendingThread;
Thread ackWaitThread;
private boolean isListenSocketGracefullyClosed;
Thread mDnsThread;
Thread listen = null;
public static boolean listening=false;
private static ServerSocket server = null;
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid) throws Exception {
this(listener, Key, EncryptionKey, Ip, Ssid, "EMW3161");
}
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid, String ackString)
throws Exception {
this(listener, Key, EncryptionKey, Ip, Ssid, ackString, 5353);
}
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid, String ackString,
int notifyListenPort) throws Exception {
this(listener, Key, EncryptionKey, Ip, Ssid, ackString,
notifyListenPort, 15000);
}
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid, String ackString,
int notifyListenPort, int localPort) throws Exception {
this(listener, Key, EncryptionKey, Ip, Ssid, ackString,
notifyListenPort, localPort, 300000);
}
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid, String ackString,
int notifyListenPort, int localPort, int WaitForAckSocketTimeout)
throws Exception {
this(listener, Key, EncryptionKey, Ip, Ssid, ackString,
notifyListenPort, localPort, WaitForAckSocketTimeout, 4, 10,
"abc", "abcdefghijklmnopqrstuvw");
}
public FirstTimeConfig2(FirstTimeConfigListener listener, String Key,
byte[] EncryptionKey, String Ip, String Ssid, String ackString,
int notifyListenPort, int LocalPort, int WaitForAckSocketTimeout,
int numberOfSetups, int numberOfSyncs, String syncL, String syncH)
throws Exception {
int AES_LENGTH = 16;
this.m_listener = listener;
if ((EncryptionKey != null) && (EncryptionKey.length != 0)
&& (EncryptionKey.length != 16)) {
throw new Exception("Encryption key must have 16 characters!");
}
if (Key.length() > 32) {
throw new Exception(
"Password is too long! Maximum length is 32 characters.");
}
if (Ssid.length() > 32) {
throw new Exception(
"Network name (SSID) is too long! Maximum length is 32 characters.");
}
this.stopSending = true;
this.isListenSocketGracefullyClosed = false;
this.listenSocket = null;
this.ip = Ip;
this.ssid = Ssid;
this.key = Key;
this.nSetup = numberOfSetups;
this.nSync = numberOfSyncs;
this.syncLString = syncL;
this.syncHString = syncH;
this.encryptionKey = EncryptionKey;
this.mDnsAckString = ackString;
createBroadcastUDPSocket(notifyListenPort);
this.localPort = new Random().nextInt(65535);
this.listenPort = 5353;
this.waitForAckSocketTimeout = WaitForAckSocketTimeout;
this.sockAddr = new InetSocketAddress(this.ip, this.localPort);
byte[] keyData = new byte[this.key.length()];
System.arraycopy(this.key.getBytes(), 0, keyData, 0, this.key.length());
keyData = encryptData(keyData);
this.ftcData = new FtcEncode(this.ssid, keyData);
}
private void createBroadcastUDPSocket(int port) throws Exception {
InetAddress wildcardAddr = null;
InetSocketAddress localAddr = null;
localAddr = new InetSocketAddress(wildcardAddr, port);
this.listenSocket = new MulticastSocket(null);
this.listenSocket.setReuseAddress(true);
this.listenSocket.bind(localAddr);
this.listenSocket.setTimeToLive(255);
this.listenSocket.joinGroup(InetAddress.getByName("224.0.0.251"));
this.listenSocket.setBroadcast(true);
}
@SuppressWarnings("null")
private void sendSync() throws SocketException, Exception {
Context context = null;
// this.ssid = "MXCHIP_FRON";
// this.key = "stm32f215";
// WifiManager wifiManager = (WifiManager) context.getApplicationContext().getSystemService(Context.WIFI_SERVICE);
// WifiInfo wifiInfo = wifiManager.getConnectionInfo();
int ipAddress = EasyLinkSearchActivity.ipAddr;
byte[] syncLBuffer = this.syncLString.getBytes();
byte[] syncHBuffer = this.syncHString.getBytes();
byte[] s_key = new byte[this.key.length()];
byte[] s_ssid = new byte[this.ssid.getBytes("UTF-8").length];
byte[] data = new byte[2];
byte[] userinfo = new byte[5];
userinfo[0]=0x23; // #
// int userlength = EasyLinkConfigActivity.mDeviceNameInputField.getText()
// .toString().getBytes().length;
// System.arraycopy(Helper.ConvertIntTo2bytesHexaFormat(ipAddress), 0, userinfo, 1, 4);
String s = Integer.toHexString(ipAddress);
s = String.format("%08x", ipAddress);
System.arraycopy(Helper.hexStringToBytes(s), 0, userinfo, 1, 4);
int userlength = userinfo.length;
// if (userlength == 0) {
// userlength++;
// userinfo = new byte[1];
// userinfo[0] = 0;
// } else {
// userinfo = new byte[userlength];
// System.arraycopy(userinfo, 0, userinfo, 0,
// userlength);
// }
System.arraycopy(this.key.getBytes(), 0, s_key, 0, this.key.length());
System.arraycopy(this.ssid.getBytes("UTF-8"), 0, s_ssid, 0,
this.ssid.getBytes("UTF-8").length);
data[0] = (byte) s_ssid.length;
data[1] = (byte) s_key.length;
byte[] temp = Helper.byteMerger(s_ssid, s_key);
data = Helper.byteMerger(data, temp);
String head = "239.118.0.0";
this.ip = head;
for (int i = 0; i < 5; i++) {
this.sockAddr = new InetSocketAddress(
InetAddress.getByName(this.ip), getRandomNumber());
sendData(new DatagramPacket(syncHBuffer, 20, this.sockAddr));
Thread.sleep(10L);
}
// if (userlength == 0) {
// for (int k = 0; k < data.length; k += 2) {
// if (k + 1 < data.length)
// this.ip = "239.126." + (int) (data[k] & 0xff) + "."
// + (int) (data[k + 1] & 0xff);
// else
// this.ip = "239.126." + (int) (data[k] & 0xff) + ".0";
// this.sockAddr = new InetSocketAddress(
// InetAddress.getByName(this.ip), 10000);
// byte[] bbbb = new byte[k / 2 + 20];
// sendData(new DatagramPacket(bbbb, k / 2 + 20, this.sockAddr));
// // Thread.sleep(5L);
// }
// } else {
if (data.length % 2 == 0) {
if (userinfo.length == 0) {
byte[] temp_length = { (byte) userlength, 0, 0 };
data = Helper.byteMerger(data, temp_length);
} else {
byte[] temp_length = { (byte) userlength, 0 };
data = Helper.byteMerger(data, temp_length);
}
} else {
byte[] temp_length = { 0, (byte) userlength, 0 };
data = Helper.byteMerger(data, temp_length);
}
data = Helper.byteMerger(data, userinfo);
for (int k = 0; k < data.length; k += 2) {
if (k + 1 < data.length)
this.ip = "239.126." + (int) (data[k] & 0xff) + "."
+ (int) (data[k + 1] & 0xff);
else
this.ip = "239.126." + (int) (data[k] & 0xff) + ".0";
this.sockAddr = new InetSocketAddress(
InetAddress.getByName(this.ip), getRandomNumber());
byte[] bbbb = new byte[k / 2 + 20];
sendData(new DatagramPacket(bbbb, k / 2 + 20, this.sockAddr));
Thread.sleep(10L);
}
// }
}
private void send() throws Exception {
// int numberOfPackets = this.ftcData.getmData().size();
//
// ArrayList packets = new ArrayList();
// byte[] ftcBuffer = new byte[1600];
// ftcBuffer = makePaddedByteArray(ftcBuffer.length);
// packets = this.ftcData.getmData();
while (!this.stopSending) {
// for (int i = 0; i < this.nSetup; i++) {
sendSync();
// for (int j = 0; j < numberOfPackets; j++) {
// sendData(
// new DatagramPacket(ftcBuffer,
// ((Integer) packets.get(j)).intValue(),
// this.sockAddr), getRandomNumber());
// }
// }
// Thread.sleep(10L);
}
}
private void sendData(DatagramPacket packet) throws Exception {
MulticastSocket sock = null;
sock = new MulticastSocket(12345);
sock.joinGroup(InetAddress.getByName(this.ip));
// sock.setReuseAddress(true);
sock.send(packet);
sock.close();
}
public void transmitSettings() throws Exception {
this.stopSending = false;
this.sendingThread = new Thread(new Runnable() {
public void run() {
try {
// if(listen==null)
listening=true;
listen = new Thread(new MyService());
listen.start();
FirstTimeConfig2.this.send();
//new MyService().run();
} catch (Exception e) {
new FirstTimeConfig2.NotifyThread(
FirstTimeConfig2.this.m_listener, e);
}
}
});
this.sendingThread.start();
// this.ackWaitThread = new Thread(new Runnable() {
// public void run() {
// try {
// FirstTimeConfig.this.waitForAck();
// } catch (Exception e) {
// new FirstTimeConfig.NotifyThread(
// FirstTimeConfig.this.m_listener, e);
// }
// }
// });
// this.ackWaitThread.start();
}
public static class MyService implements Runnable{
// 定义保存所有的Socket
public static List<Socket> socketList = new ArrayList<Socket>();
public void run() {
while (listening == true) {
if (null == server) {
try {
server = new ServerSocket(8000);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
Socket s = null;
try {
s = server.accept();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
socketList.add(s);
// 每当客户端连接之后启动一条ServerThread线程为该客户端服务
new Thread(new ServiceThread(s)).start();
}
try {
server.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
public void stopTransmitting() throws Exception {
this.isListenSocketGracefullyClosed = true;
this.listenSocket.close();
listening=false;
this.stopSending = true;
listen.interrupt();
listen = null;
if (Thread.currentThread() != this.sendingThread)
this.sendingThread.join();
if (Thread.currentThread() != this.ackWaitThread)
this.ackWaitThread.join();
}
private void waitForAck() throws Exception {
int RECV_BUFFER_LENGTH = 16384;
byte[] recvBuffer = new byte[16384];
DatagramPacket listenPacket = new DatagramPacket(recvBuffer, 16384);
int timeout = this.waitForAckSocketTimeout;
while (!this.stopSending) {
long start = System.nanoTime();
this.listenSocket.setSoTimeout(timeout);
try {
this.listenSocket.receive(listenPacket);
} catch (InterruptedIOException e) {
if (this.isListenSocketGracefullyClosed)
break;
new NotifyThread(this.m_listener,
FirstTimeConfigListener.FtcEvent.FTC_TIMEOUT);
break;
} catch (Exception e) {
if (!this.isListenSocketGracefullyClosed)
break;
}
break;
}
}
private boolean parseMDns(byte[] data) throws Exception {
int MDNS_HEADER_SIZE = 12;
int MDNS_HEADER_SIZE2 = 10;
int pos = 12;
if (data.length < pos + 1)
return false;
int len = data[pos] & 0xFF;
pos++;
while (len > 0) {
if (data.length < pos + len) {
return false;
}
pos += len;
if (data.length < pos + 1)
return false;
len = data[pos] & 0xFF;
pos++;
}
pos += 10;
if (data.length < pos + 1)
return false;
len = data[pos] & 0xFF;
pos++;
if (data.length < pos + len)
return false;
String name = new String(data, pos, len);
boolean bRet = name.equals(this.mDnsAckString);
return bRet;
}
private byte[] encryptData(byte[] data) throws Exception {
if (this.encryptionKey == null)
return data;
if (this.encryptionKey.length == 0) {
return data;
}
int ZERO_OFFSET = 0;
int AES_LENGTH = 16;
int DATA_LENGTH = 32;
Cipher c = null;
byte[] encryptedData = null;
byte[] paddedData = new byte[32];
byte[] aesKey = new byte[16];
for (int x = 0; x < 16; x++) {
if (x < this.encryptionKey.length) {
aesKey[x] = this.encryptionKey[x];
} else {
aesKey[x] = 0;
}
}
int dataOffset = 0;
if (data.length < 32) {
paddedData[dataOffset] = ((byte) data.length);
dataOffset++;
}
System.arraycopy(data, 0, paddedData, dataOffset, data.length);
dataOffset += data.length;
while (dataOffset < 32) {
paddedData[dataOffset] = 0;
dataOffset++;
}
c = Cipher.getInstance("AES/ECB/NoPadding");
SecretKeySpec k = null;
k = new SecretKeySpec(aesKey, "AES");
c.init(1, k);
encryptedData = c.doFinal(paddedData);
return encryptedData;
}
private byte[] makePaddedByteArray(int length) throws Exception {
byte[] paddedArray = new byte[length];
for (int x = 0; x < length; x++) {
paddedArray[x] = ((byte) "1".charAt(0));
}
return paddedArray;
}
private class NotifyThread implements Runnable {
private FirstTimeConfigListener m_listener;
private FirstTimeConfigListener.FtcEvent t_event;
private Exception t_ex;
public NotifyThread(FirstTimeConfigListener listener,
FirstTimeConfigListener.FtcEvent event) {
this.m_listener = listener;
this.t_event = event;
this.t_ex = null;
// Thread t = new Thread(this);
// t.start();
}
public NotifyThread(FirstTimeConfigListener listener, Exception ex) {
this.m_listener = listener;
this.t_event = FirstTimeConfigListener.FtcEvent.FTC_ERROR;
this.t_ex = ex;
// Thread t = new Thread(this);
// t.start();
}
public void run() {
try {
// if (this.m_listener != null)
// this.m_listener.onFirstTimeConfigEvent(this.t_event,
// this.t_ex);
} catch (Exception localException) {
}
}
}
private int getRandomNumber() {
int num = new Random().nextInt(65536);
if (num > 10000)
return num;
else
return 15000;
}
} | [
"bringmehome@vip.qq.com"
] | bringmehome@vip.qq.com |
5c88d6219bd8f5f6c26920309ff4449054437b33 | 08b7722ad49d6b11a39f7b6628dc2638ede840e2 | /MyAccount/src/myAccount/servlet/design/Footer.java | 31bf93e9ed613b0da61b750e6ebe6d746dc562e3 | [] | no_license | niteshgoevive/AccountManager | 663d4a46fd5b5375bedb9442df3d4fe8ea688781 | cad3eebe5edb6490e154baf5e3372298783bf87b | refs/heads/master | 2020-04-18T04:36:44.762537 | 2018-04-08T12:33:33 | 2018-04-08T12:33:33 | null | 0 | 0 | null | null | null | null | UTF-8 | Java | false | false | 1,440 | java | package myAccount.servlet.design;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Servlet implementation class Footer
*/
@WebServlet("/Footer")
public class Footer extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Footer() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doPost(request,response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
PrintWriter out=response.getWriter();
out.println("<div id=\"footer\">");
out.println("<p style=\"font-size:150%\" id=\"legal\">©2017 My Account. All Rights Reserved.<br />");
out.println("Designed by <a href=\"UserProfile\" > Jay Prakash </a> </p>");
}
}
| [
"jayprakashjp007@gmail.com"
] | jayprakashjp007@gmail.com |
19e59248b7c7b3e89e9ebbfea3dca9b4c3809008 | 1f8741a16aa96ae0ad4119bedc6dd7cb59c40fe6 | /src/main/java/com/sicredidigitalpautas/eduardabrum/controller/PautaController.java | a3799fae547ab5d107f4ec04f84e841aac93a6c8 | [] | no_license | eduardadebrum/SicrediDigitalPauta | 1925a358e67fbfa7b5f532406f0181cc17772fc7 | eff4364aa9855184a11f0322f65ba61a62af8ce2 | refs/heads/master | 2020-04-08T04:47:28.744057 | 2018-11-27T20:20:04 | 2018-11-27T20:20:04 | 159,032,124 | 0 | 1 | null | null | null | null | UTF-8 | Java | false | false | 1,593 | java | package com.sicredidigitalpautas.eduardabrum.controller;
import com.sicredidigitalpautas.eduardabrum.domain.PautaDomain;
import com.sicredidigitalpautas.eduardabrum.entity.Pauta;
import com.sicredidigitalpautas.eduardabrum.service.PautaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import javax.validation.Valid;
/**
* Classe Rest Controller para os serviços relacionados ao {@link Pauta}.
*
* @author Eduarda de Brum Lucena
*/
@Api(description = "Esse é o Serviço da Pauta.")
@RestController
public class PautaController {
private final PautaService pautaService;
@Autowired
public PautaController(PautaService pautaService) {
this.pautaService = pautaService;
}
@ApiOperation(
value = "Cadastro da Pauta.",
notes = "Cadastra as informações relacionadas a Pauta.")
@PostMapping("/pauta")
public Pauta save(@Valid @RequestBody PautaDomain pautaDomain) {
return pautaService.save(pautaDomain);
}
@ApiOperation(
value = "Lista de Pautas.",
notes = "Busca Todas as Pautas Cadastradas.")
@GetMapping("/pautas")
public List<Pauta> findAllPauta() {
return pautaService.findAllPauta();
}
}
| [
"eduarda.lucena@ntconsult.com.br"
] | eduarda.lucena@ntconsult.com.br |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.